Disclaimer: This is a patch against a slightly customized variant of version 1.6.0, so it might not apply cleanly. It is not tested very much and it might not be backwards compliant with older MediaWiki releases.
Also, please note that to support self links correctly, it will be necessary to either modify core or to copy and paste the method 'replaceInternalLinks2' from the core parser.
=== modified file 'extensions/WYSIWYG/CKeditor.body.php'
--- extensions/WYSIWYG/CKeditor.body.php 2012-02-27 13:33:51 +0000
+++ extensions/WYSIWYG/CKeditor.body.php 2012-03-05 07:37:32 +0000
@@ -130,7 +130,9 @@
}
public static function onParserBeforeStrip( &$parser, &$text, &$stripState ) {
- $text = $parser->strip( $text, $stripState );
+ if (get_class($parser) == 'CKeditorParser') {
+ $text = $parser->strip( $text, $stripState );
+ }
return true;
}
@@ -219,25 +221,22 @@
public function onCustomEditor( $article, $user ) {
- global $wgRequest, $mediaWiki;
+ global $wgRequest, $wgUseExternalEditor;
- $action = $mediaWiki->getVal( 'Action' );
+ $action = $wgRequest->getVal( 'action', 'view' );
$internal = $wgRequest->getVal( 'internaledit' );
$external = $wgRequest->getVal( 'externaledit' );
$section = $wgRequest->getVal( 'section' );
$oldid = $wgRequest->getVal( 'oldid' );
- if( !$mediaWiki->getVal( 'UseExternalEditor' ) || $action == 'submit' || $internal ||
+ if( !$wgUseExternalEditor || $action == 'submit' || $internal ||
$section || $oldid || ( !$user->getOption( 'externaleditor' ) && !$external ) ) {
$editor = new CKeditorEditPage( $article );
- $editor->submit();
- } elseif( $mediaWiki->getVal( 'UseExternalEditor' ) && ( $external || $user->getOption( 'externaleditor' ) ) ) {
- $mode = $wgRequest->getVal( 'mode' );
- $extedit = new ExternalEdit( $article, $mode );
- $extedit->edit();
+ $editor->edit();
+ return false;
+ } else {
+ return true;
}
-
- return false;
}
public static function onDoEditSectionLink ($skin, $title, $section, $tooltip, $result, $lang = false ) {
@@ -491,7 +490,7 @@
$skin->mTitle =& $wgTitle;
$skin->initPage( $wgOut );
$skin->userpage = $wgUser->getUserPage()->getPrefixedText();
- $skin->setupUserCss( $wgOut );
+ $skin->setupSkinUserCss( $wgOut );
if( !empty( $skin->usercss ) && preg_match_all( '/@import "([^"]+)";/', $skin->usercss, $matches ) ) {
$userStyles = $matches[1];
@@ -692,13 +691,6 @@
*/
if( showFCKEditor & RTE_VISIBLE ){
if ( toolbar ){ // insert wiki buttons
- // Remove the mwSetupToolbar onload hook to avoid a JavaScript error with FF.
- if ( window.removeEventListener )
- window.removeEventListener( 'load', mwSetupToolbar, false );
- else if ( window.detachEvent )
- window.detachEvent( 'onload', mwSetupToolbar );
- mwSetupToolbar = function(){ return false ; };
-
for( var i = 0; i < mwEditButtons.length; i++ ) {
mwInsertEditButton(toolbar, mwEditButtons[i]);
}
=== added file 'extensions/WYSIWYG/CKeditorLinker.php'
--- extensions/WYSIWYG/CKeditorLinker.php 1970-01-01 00:00:00 +0000
+++ extensions/WYSIWYG/CKeditorLinker.php 2012-03-05 07:52:14 +0000
@@ -0,0 +1,448 @@
+<?php
+
+/**
+ * Since the core parser have moved to use a static method pattern for
+ * rendering links, the functionality from CKeditorSkin has been moved
+ * here and now relies on hooks.
+ *
+ * The methods in the skin that as of 1.19 are no longer called from
+ * core has been ignored, which means that some extensions might break.
+ *
+ * The method 'makeSelfLinkObj' is called directly from the core
+ * parser, but no hook is available for it, so a patch to core is
+ * required to support it.
+ *
+ * The public methods of CKeditorSkin are:
+ *
+ * makeImageLink2 - used in core, hook available: ImageBeforeProduceHTML
+ * makeLinkObj - deprecated, unused in core
+ * makeKnownLinkObj - deprecated, unused in core
+ * makeColouredLinkObj - deprecated, unused in core
+ * makeBrokenLinkObj - only used in makeImageLink2
+ * makeSelfLinkObj - used by core parser, impossible to hook
+ * makeMediaLinkObj - only used by formatComment in core
+ * makeExternalLink - used in core, hook available: LinkerMakeExternalLink
+ */
+class CKeditorLinker {
+
+ public static function addHooks() {
+ global $wgHooks;
+
+ $wgHooks['ImageBeforeProduceHTML'][] = 'CKeditorLinker::makeImageLink2';
+ $wgHooks['LinkerMakeExternalLink'][] = 'CKeditorLinker::makeExternalLink';
+ $wgHooks['LinkEnd'][] = 'CKeditorLinker::linkEnd';
+ $wgHooks['LinkBegin'][] = 'CKeditorLinker::linkBegin';
+ }
+
+ public static function removeHooks() {
+ self::removeHook('ImageBeforeProduceHTML', 'CKeditorLinker::makeImageLink2');
+ self::removeHook('LinkerMakeExternalLink', 'CKeditorLinker::makeExternalLink');
+ self::removeHook('LinkEnd', 'CKeditorLinker::linkEnd');
+ self::removeHook('LinkBegin', 'CKeditorLinker::linkBegin');
+ }
+
+ private static function removeHook($hookName, $function) {
+ global $wgHooks;
+ $hook = $wgHooks[$hookName];
+ $i = array_search($function, $hook);
+ if ($i) {
+ $wgHooks[$hookName] = array_splice($hook, $i, 1);
+ }
+ }
+
+ /**
+ * Make an image link in MediaWiki 1.11
+ * @param Title $title Title object
+ * @param File $file File object, or false if it doesn't exist
+ *
+ * @param array $frameParams Associative array of parameters external to the media handler.
+ * Boolean parameters are indicated by presence or absence, the value is arbitrary and
+ * will often be false.
+ * thumbnail If present, downscale and frame
+ * manualthumb Image name to use as a thumbnail, instead of automatic scaling
+ * framed Shows image in original size in a frame
+ * frameless Downscale but don't frame
+ * upright If present, tweak default sizes for portrait orientation
+ * upright_factor Fudge factor for "upright" tweak (default 0.75)
+ * border If present, show a border around the image
+ * align Horizontal alignment (left, right, center, none)
+ * valign Vertical alignment (baseline, sub, super, top, text-top, middle,
+ * bottom, text-bottom)
+ * alt Alternate text for image (i.e. alt attribute). Plain text.
+ * caption HTML for image caption.
+ *
+ * @param array $handlerParams Associative array of media handler parameters, to be passed
+ * to transform(). Typical keys are "width" and "page".
+ */
+ static function makeImageLink2( $skin, Title $nt, $file, $frameParams = array(), $handlerParams = array(), $time, &$ret ) {
+ $orginal = $nt->getText();
+ $file = RepoGroup::singleton()->getLocalRepo()->newFile( $nt );
+ $found = $file->exists();
+
+ if( !empty( $frameParams['alt'] ) && $frameParams['alt'] == 'RTENOTITLE' ){ // 2223
+ $frameParams['alt'] = '';
+ }
+ if( $found ) {
+ $type = 'image';
+ if ($file->getMediaType() == MEDIATYPE_VIDEO) {
+ $type = 'video';
+ } else if ($file->getMediaType() == MEDIATYPE_AUDIO) {
+ $type = 'audio';
+ }
+ if ($type == 'image') {
+ $url = $file->getUrl();
+ } else {
+ $url = $file->createThumb( 230 );
+ }
+ }
+
+ // Shortcuts
+ $fp =& $frameParams;
+ $hp =& $handlerParams;
+
+ if( !isset( $fp['align'] ) ) {
+ $fp['align'] = '';
+ }
+
+ $ret = '<img ';
+
+ if( $found ) {
+ $ret .= "src=\"{$url}\" ";
+ } else {
+ $ret .= "_fck_mw_valid=\"false"."\" ";
+ }
+ $ret .= "_fck_mw_filename=\"{$orginal}\" ";
+
+ if( $fp['align'] ) {
+ $ret .= "_fck_mw_location=\"" . strtolower( $fp['align'] ) . "\" ";
+ }
+ if( !empty( $hp ) ) {
+ if( isset( $hp['width'] ) ) {
+ $ret .= "_fck_mw_width=\"" . $hp['width'] . "\" ";
+ }
+ if( isset( $hp['height'] ) ) {
+ $ret .= "_fck_mw_height=\"" . $hp['height'] . "\" ";
+ }
+ }
+ $class = '';
+ if( isset( $fp['thumbnail'] ) ) {
+ $ret .= "_fck_mw_type=\"thumb" . "\" ";
+ $class .= 'fck_mw_frame';
+ } else if( isset( $fp['border'] ) ) {
+ $ret .= "_fck_mw_type=\"border" . "\" ";
+ $class .= 'fck_mw_border';
+ } else if( isset( $fp['framed'] ) ) {
+ $ret .= "_fck_mw_type=\"frame" . "\" ";
+ $class .= 'fck_mw_frame';
+ }
+
+ if( $fp['align'] == 'right' ) {
+ $class .= ( $class ? ' ': '' ) . 'fck_mw_right';
+ } else if( $fp['align'] == 'center' ) {
+ $class .= ( $class ? ' ' : '' ) . 'fck_mw_center';
+ } else if( $fp['align'] == 'left' ) {
+ $class .= ( $class ? ' ': '' ) . 'fck_mw_left';
+ } else if( isset( $fp['framed'] ) || isset( $fp['thumbnail'] ) ) {
+ $class .= ( $class ? ' ' : '' ) . 'fck_mw_right';
+ }
+
+ if( !$found ) {
+ $class .= ( $class ? ' ' : '' ) . 'fck_mw_notfound';
+ }
+
+ if( isset( $fp['alt'] ) && !empty( $fp['alt'] ) && $fp['alt'] != 'Image:' . $orginal ) {
+ $ret .= "alt=\"" . htmlspecialchars( $fp['alt'] ) . "\" ";
+ } else {
+ $ret .= "alt=\"\" ";
+ }
+
+ if( $class ) {
+ $ret .= "class=\"$class\" ";
+ }
+ if (isset($fp['no-link']))
+ $ret .= 'no-link="1" ';
+ if (isset($fp['link-title']) && is_object($fp['link-title']))
+ $ret .= 'link="'.htmlentities ($fp['link-title']->getFullText()).'" ';
+ if (isset($fp['link-url']))
+ $ret .= 'link="'.$fp['link-url'].'" ';
+
+ $ret .= '/>';
+
+ return false;
+ }
+
+ static function makeExternalLink( $url, $text, &$link, &$attribs, $linktype ) {
+ $url = htmlspecialchars( $url );
+ $text = htmlspecialchars( $text );
+ $url = preg_replace( "/^RTECOLON/", ":", $url ); // change 'RTECOLON' => ':'
+ $args = '';
+ if( $text == 'RTENOTITLE' ){ // 2223
+ $args .= '_fcknotitle="true" ';
+ $text = $url;
+ }
+ $link= '<a ' . $args . 'href="' . $url . '">' . $text . '</a>';
+
+ return false;
+ }
+
+ function makeColouredLinkObj( $nt, $colour, $text = '', $query = '', $trail = '', $prefix = '' ) {
+ return self::makeKnownLinkObj( $nt, $text, $query, $trail, $prefix, '', $style );
+ }
+
+ function makeKnownLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' , $aprops = '', $style = '' ) {
+ wfProfileIn( __METHOD__ );
+
+ $args = '';
+ if ( !is_object( $nt ) ) {
+ wfProfileOut( __METHOD__ );
+ return $text;
+ }
+
+ $u = $nt->getFullText();
+ $u = rawurlencode($u); // Fix for links containing "
+ //#Updating links tables -> #Updating_links_tables
+ $u = str_replace( "#" . $nt->getFragment(), $nt->getFragmentForURL(), $u );
+
+ if ( $nt->getFragment() != '' ) {
+ if( $nt->getPrefixedDBkey() == '' ) {
+ $u = '';
+ if ( '' == $text ) {
+ $text = htmlspecialchars( $nt->getFragment() );
+ }
+ }
+
+ /**
+ * See tickets 1386 and 1690 before changing anything
+ */
+ if( $nt->getPartialUrl() == '' ) {
+ $u .= $nt->getFragmentForURL();
+ }
+ }
+ if ( $text == '' ) {
+ $text = htmlspecialchars( $nt->getPrefixedText() );
+ }
+
+ if( $nt->getNamespace() == NS_CATEGORY ) {
+ $u = ':' . $u;
+ }
+
+ list( $inside, $trail ) = Linker::splitTrail( $trail );
+ $title = "{$prefix}{$text}{$inside}";
+
+ $u = preg_replace( "/^RTECOLON/", ":", $u ); // change 'RTECOLON' => ':'
+ if( substr( $text, 0, 10 ) == 'RTENOTITLE' ){ // starts with RTENOTITLE
+ $args .= '_fcknotitle="true" ';
+ $title = rawurldecode($u);
+ $trail = substr( $text, 10 ) . $trail;
+ }
+
+ $r = "<a {$args}href=\"{$u}\">{$title}</a>{$trail}";
+ wfProfileOut( __METHOD__ );
+ return $r;
+ }
+
+ function makeBrokenLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
+ # Fail gracefully
+ if ( !isset( $nt ) ) {
+ # throw new MWException();
+ return "<!-- ERROR -->{$prefix}{$text}{$trail}";
+ }
+ $args = '';
+
+ wfProfileIn( __METHOD__ );
+
+ $u = $nt->getFullText();
+ $u = rawurlencode($u); // Fix for links containing "
+
+ //#Updating links tables -> #Updating_links_tables
+ $u = str_replace( "#" . $nt->getFragment(), $nt->getFragmentForURL(), $u );
+
+ if ( '' == $text ) {
+ $text = htmlspecialchars( $nt->getPrefixedText() );
+ }
+ if( $nt->getNamespace() == NS_CATEGORY ) {
+ $u = ':' . $u;
+ }
+
+ list( $inside, $trail ) = Linker::splitTrail( $trail );
+ $title = "{$prefix}{$text}{$inside}";
+
+ $u = preg_replace( "/^RTECOLON/", ":", $u ); // change 'RTECOLON' => ':'
+ if( substr( $text, 0, 10 ) == 'RTENOTITLE' ){ // starts with RTENOTITLE
+ $args .= '_fcknotitle="true" ';
+ $title = rawurldecode($u);
+ $trail = substr( $text, 10 ) . $trail;
+ }
+ $s = "<a {$args}href=\"{$u}\">{$title}</a>{$trail}";
+
+ wfProfileOut( __METHOD__ );
+ return $s;
+ }
+
+ static function makeSelfLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
+ $args = '';
+ if ( '' == $text ) {
+ $text = $nt->mDbkeyform;
+ }
+ list( $inside, $trail ) = Linker::splitTrail( $trail );
+ $title = "{$prefix}{$text}";
+ if( $text == 'RTENOTITLE' ){ // 2223
+ $args .= '_fcknotitle="true" ';
+ $title = $nt->mDbkeyform;
+ }
+ return "<a {$args}href=\"".$nt->mDbkeyform."\" class=\"selflink\">{$title}</a>{$inside}{$trail}";
+ }
+
+ /**
+ * Create a direct link to a given uploaded file.
+ *
+ * @param $title Title object.
+ * @param $text String: pre-sanitized HTML
+ * @return string HTML
+ *
+ * @todo Handle invalid or missing images better.
+ */
+ static function makeMediaLinkObj( $title, $text = '' ) {
+ if( is_null( $title ) ) {
+ ### HOTFIX. Instead of breaking, return empty string.
+ return $text;
+ } else {
+ $args = '';
+ $orginal = $title->getPartialURL();
+ $img = wfFindFile( $title );
+ if( $img ) {
+ $url = $img->getURL();
+ $class = 'internal';
+ } else {
+ $upload = SpecialPage::getTitleFor( 'Upload' );
+ $url = $upload->getLocalUrl( 'wpDestFile=' . urlencode( $title->getDBkey() ) );
+ $class = 'new';
+ }
+ $alt = htmlspecialchars( $title->getText() );
+ if( $text == '' ) {
+ $text = $alt;
+ }
+ $orginal = preg_replace( "/^RTECOLON/", ":", $orginal ); // change 'RTECOLON' => ':'
+ if( $text == 'RTENOTITLE' ){ // 2223
+ $args .= '_fcknotitle="true" ';
+ $text = $orginal;
+ $alt = $orginal;
+ }
+ return "<a href=\"{$orginal}\" class=\"$class\" {$args} _fck_mw_filename=\"{$orginal}\" _fck_mw_type=\"media\" title=\"{$alt}\">{$text}</a>";
+ }
+ }
+
+ static function linkBegin( $skin, Title $target, &$text, array &$attribs, &$query, &$options, &$ret) {
+ if ( $target->isExternal() ) {
+ $args = '';
+ $u = $target->getFullURL();
+ $link = $target->getPrefixedURL();
+ if ( '' == $text ) {
+ $text = $target->getPrefixedText();
+ }
+ $style = Linker::getInterwikiLinkAttributes( $link, $text, 'extiw' );
+
+ if( $text == 'RTENOTITLE' ) { // 2223
+ $text = $u = $link;
+ $args .= '_fcknotitle="true" ';
+ }
+ $t = "<a {$args}href=\"{$u}\"{$style}>{$text}</a>";
+
+ wfProfileOut( __METHOD__ );
+ $ret = $t;
+ return false;
+ }
+
+ return true;
+ }
+
+ static function linkEnd( $skin, Title $target, array $options, &$text, array &$attribs, &$ret ) {
+
+ if ( in_array('known', $options) ) {
+ $args = '';
+ if ( !is_object( $target ) ) {
+ wfProfileOut( __METHOD__ );
+ return $text;
+ }
+
+ $u = $target->getFullText();
+ $u = rawurlencode($u); // Fix for links containing "
+ //#Updating links tables -> #Updating_links_tables
+ $u = str_replace( "#" . $target->getFragment(), $target->getFragmentForURL(), $u );
+
+ if ( $target->getFragment() != '' ) {
+ if( $target->getPrefixedDBkey() == '' ) {
+ $u = '';
+ if ( '' == $text ) {
+ $text = htmlspecialchars( $target->getFragment() );
+ }
+ }
+
+ /**
+ * See tickets 1386 and 1690 before changing anything
+ */
+ if( $target->getPartialUrl() == '' ) {
+ $u .= $target->getFragmentForURL();
+ }
+ }
+ if ( $text == '' ) {
+ $text = htmlspecialchars( $target->getPrefixedText() );
+ }
+
+ if( $target->getNamespace() == NS_CATEGORY ) {
+ $u = ':' . $u;
+ }
+
+ $u = preg_replace( "/^RTECOLON/", ":", $u ); // change 'RTECOLON' => ':'
+ if( substr( $text, 0, 10 ) == 'RTENOTITLE' ){ // starts with RTENOTITLE
+ $args .= '_fcknotitle="true" ';
+ $text = rawurldecode($u);
+ }
+
+ $r = "<a {$args}href=\"{$u}\">{$text}</a>";
+ wfProfileOut( __METHOD__ );
+
+ $ret = $r;
+
+ return false;
+ }
+
+
+ if (in_array('broken', $options)) {
+ if ( !isset( $target ) ) {
+ # throw new MWException();
+ return "<!-- ERROR -->{$prefix}{$text}";
+ }
+ $args = '';
+
+ wfProfileIn( __METHOD__ );
+
+ $u = $target->getFullText();
+ $u = rawurlencode($u); // Fix for links containing "
+
+ //#Updating links tables -> #Updating_links_tables
+ $u = str_replace( "#" . $target->getFragment(), $target->getFragmentForURL(), $u );
+
+ if ( '' == $text ) {
+ $text = htmlspecialchars( $target->getPrefixedText() );
+ }
+ if( $target->getNamespace() == NS_CATEGORY ) {
+ $u = ':' . $u;
+ }
+
+ $u = preg_replace( "/^RTECOLON/", ":", $u ); // change 'RTECOLON' => ':'
+ if( substr( $text, 0, 10 ) == 'RTENOTITLE' ){ // starts with RTENOTITLE
+ $args .= '_fcknotitle="true" ';
+ $text = rawurldecode($u);
+ }
+ $s = "<a {$args}href=\"{$u}\">{$text}</a>";
+
+ wfProfileOut( __METHOD__ );
+ $ret = $s;
+ return false;
+ }
+
+ return true;
+ }
+
+}
\ No newline at end of file
=== modified file 'extensions/WYSIWYG/CKeditorParser.body.php'
--- extensions/WYSIWYG/CKeditorParser.body.php 2012-02-27 13:33:51 +0000
+++ extensions/WYSIWYG/CKeditorParser.body.php 2012-03-02 11:17:39 +0000
@@ -391,17 +390,11 @@
if (!$stripcomments && $element == '!--') {
$commentState->setPair($marker, $output);
} elseif ($element == 'html' || $element == 'nowiki') {
- $nowikiItems[$marker] = $output;
+ $state->addNoWiki($marker, $output);
} else {
- $generalItems[$marker] = $output;
+ $state->addGeneral($marker, $output);
}
}
- # Add the new items to the state
- # We do this after the loop instead of during it to avoid slowing
- # down the recursive unstrip
- $state->nowiki->mergeArray($nowikiItems);
- $state->general->mergeArray($generalItems);
-
# Unstrip comments unless explicitly told otherwise.
# (The comments are always stripped prior to this point, so as to
# not invoke any extension tags / parser hooks contained within
@@ -728,66 +721,73 @@
}
function parse($text, Title $title, ParserOptions $options, $linestart = true, $clearState = true, $revid = null) {
- $text = preg_replace("/^#REDIRECT/", '<!--FCK_REDIRECT-->', $text);
- $text = preg_replace("/\<(noinclude|includeonly|onlyinclude)\>/i", '%%%start-$1%%%', $text);
- $text = preg_replace("/\<\/(noinclude|includeonly|onlyinclude)\>/i", '%%%end-$1%%%', $text);
- $parserOutput = parent::parse($text, $title, $options, $linestart, $clearState, $revid);
-
-
- $parserOutput->setText(strtr($parserOutput->getText(), array('FCKLR_fcklr_FCKLR' => '<br fcklr="true"/>')));
- $parserOutput->setText(strtr($parserOutput->getText(), array('--~~~~' => '<span class="fck_mw_signature">_</span>')));
-
- if (!empty($this->fck_mw_strtr_span)) {
- global $leaveRawTemplates;
- if (!empty($leaveRawTemplates)) {
- foreach ($leaveRawTemplates as $l) {
- $this->fck_mw_strtr_span[$l] = substr($this->fck_mw_strtr_span[$l], 30, -7);
- }
- }
- $text = strtr($parserOutput->getText(), $this->fck_mw_strtr_span);
- $parserOutput->setText(strtr($text, $this->fck_mw_strtr_span));
-
- //replace fckLR strings with empty strings
-// $parserOutput->setText( strtr( $parserOutput->getText(), array('fckLR' => '') ) );
- }
-
- // there were properties, look for the placeholder FCK_PROPERTY_X_FOUND and replace
- // it with <span class="fck_mw_property">property string without brakets</span>
- if (count($this->fck_mw_propertyAtPage) > 0) {
- $tmpText = $parserOutput->getText();
- foreach ($this->fck_mw_propertyAtPage as $p => $val)
- $tmpText = str_replace('FCK_PROPERTY_' . $p . '_FOUND', $val, $tmpText);
- $parserOutput->setText($tmpText);
- }
- // there were Richmedia links, look for the placeholder FCK_RICHMEDIA_X_FOUND and replace
- // it with <a title="My Document.doc" _fck_mw_type="Document" _fck_mw_filename="My Document.doc"
- // _fcksavedurl="Document:MyDocument.doc" href="My_Document.doc">Document:My Document.doc</a>
- if (count($this->fck_mw_richmediaLinkAtPage) > 0) {
- $tmpText = $parserOutput->getText();
- foreach ($this->fck_mw_richmediaLinkAtPage as $p => $val)
- $tmpText = str_replace('FCK_RICHMEDIA_' . $p . '_FOUND', $val, $tmpText);
- $parserOutput->setText($tmpText);
- }
-
- if (!empty($this->fck_matches)) {
- $text = $parserOutput->getText();
- foreach ($this->fck_matches as $key => $m) {
- $text = str_replace($key, $m[3], $text);
- }
- $parserOutput->setText($text);
- }
-
- if (!empty($parserOutput->mLanguageLinks)) {
- foreach ($parserOutput->mLanguageLinks as $l) {
- $parserOutput->setText($parserOutput->getText() . "\n" . '<a href="' . $l . '">' . $l . '</a>');
- }
- }
-
- $parserOutput->setText(str_replace('<!--FCK_REDIRECT-->', '#REDIRECT', $parserOutput->getText()));
- $parserOutput->setText(preg_replace('/%%%start\-(noinclude|includeonly|onlyinclude)%%%/i', '<span class="fck_mw_$1" _fck_mw_tagname="$1" startTag="true"></span>', $parserOutput->getText()));
- $parserOutput->setText(preg_replace('/%%%end\-(noinclude|includeonly|onlyinclude)%%%/i', 'fckLR<span class="fck_mw_$1" _fck_mw_tagname="$1" endTag="true"></span>', $parserOutput->getText()));
- return $parserOutput;
+ CKeditorLinker::addHooks();
+ try {
+ $text = preg_replace("/^#REDIRECT/", '<!--FCK_REDIRECT-->', $text);
+ $text = preg_replace("/\<(noinclude|includeonly|onlyinclude)\>/i", '%%%start-$1%%%', $text);
+ $text = preg_replace("/\<\/(noinclude|includeonly|onlyinclude)\>/i", '%%%end-$1%%%', $text);
+ $parserOutput = parent::parse($text, $title, $options, $linestart, $clearState, $revid);
+
+
+ $parserOutput->setText(strtr($parserOutput->getText(), array('FCKLR_fcklr_FCKLR' => '<br fcklr="true"/>')));
+ $parserOutput->setText(strtr($parserOutput->getText(), array('--~~~~' => '<span class="fck_mw_signature">_</span>')));
+
+ if (!empty($this->fck_mw_strtr_span)) {
+ global $leaveRawTemplates;
+ if (!empty($leaveRawTemplates)) {
+ foreach ($leaveRawTemplates as $l) {
+ $this->fck_mw_strtr_span[$l] = substr($this->fck_mw_strtr_span[$l], 30, -7);
+ }
+ }
+ $text = strtr($parserOutput->getText(), $this->fck_mw_strtr_span);
+ $parserOutput->setText(strtr($text, $this->fck_mw_strtr_span));
+
+ //replace fckLR strings with empty strings
+ // $parserOutput->setText( strtr( $parserOutput->getText(), array('fckLR' => '') ) );
+ }
+
+ // there were properties, look for the placeholder FCK_PROPERTY_X_FOUND and replace
+ // it with <span class="fck_mw_property">property string without brakets</span>
+ if (count($this->fck_mw_propertyAtPage) > 0) {
+ $tmpText = $parserOutput->getText();
+ foreach ($this->fck_mw_propertyAtPage as $p => $val)
+ $tmpText = str_replace('FCK_PROPERTY_' . $p . '_FOUND', $val, $tmpText);
+ $parserOutput->setText($tmpText);
+ }
+ // there were Richmedia links, look for the placeholder FCK_RICHMEDIA_X_FOUND and replace
+ // it with <a title="My Document.doc" _fck_mw_type="Document" _fck_mw_filename="My Document.doc"
+ // _fcksavedurl="Document:MyDocument.doc" href="My_Document.doc">Document:My Document.doc</a>
+ if (count($this->fck_mw_richmediaLinkAtPage) > 0) {
+ $tmpText = $parserOutput->getText();
+ foreach ($this->fck_mw_richmediaLinkAtPage as $p => $val)
+ $tmpText = str_replace('FCK_RICHMEDIA_' . $p . '_FOUND', $val, $tmpText);
+ $parserOutput->setText($tmpText);
+ }
+
+ if (!empty($this->fck_matches)) {
+ $text = $parserOutput->getText();
+ foreach ($this->fck_matches as $key => $m) {
+ $text = str_replace($key, $m[3], $text);
+ }
+ $parserOutput->setText($text);
+ }
+
+ if (!empty($parserOutput->mLanguageLinks)) {
+ foreach ($parserOutput->mLanguageLinks as $l) {
+ $parserOutput->setText($parserOutput->getText() . "\n" . '<a href="' . $l . '">' . $l . '</a>');
+ }
+ }
+
+ $parserOutput->setText(str_replace('<!--FCK_REDIRECT-->', '#REDIRECT', $parserOutput->getText()));
+ $parserOutput->setText(preg_replace('/%%%start\-(noinclude|includeonly|onlyinclude)%%%/i', '<span class="fck_mw_$1" _fck_mw_tagname="$1" startTag="true"></span>', $parserOutput->getText()));
+ $parserOutput->setText(preg_replace('/%%%end\-(noinclude|includeonly|onlyinclude)%%%/i', 'fckLR<span class="fck_mw_$1" _fck_mw_tagname="$1" endTag="true"></span>', $parserOutput->getText()));
+ CKeditorLinker::removeHooks();
+ return $parserOutput;
+ } catch (Exception $e) {
+ CKeditorLinker::removeHooks();
+ throw $e;
+ }
}
/**
=== modified file 'extensions/WYSIWYG/CKeditorSajax.body.php'
--- extensions/WYSIWYG/CKeditorSajax.body.php 2012-02-27 13:33:51 +0000
+++ extensions/WYSIWYG/CKeditorSajax.body.php 2012-03-02 10:15:19 +0000
@@ -3,6 +3,53 @@
* AJAX functions used by CKeditor extension
*/
+/**
+ * Function converts an Javascript escaped string back into a string with
+ * specified charset (default is UTF-8).
+ * Modified function from http://pure-essence.net/stuff/code/utf8RawUrlDecode.phps
+ *
+ * @param $source String escaped with Javascript's escape() function
+ * @param $iconv_to String destination character set will be used as second parameter
+ * in the iconv function. Default is UTF-8.
+ * @return string
+ */
+function js_unescape( $source, $iconv_to = 'UTF-8' ) {
+ $decodedStr = '';
+ $pos = 0;
+ $len = strlen ( $source );
+
+ while ( $pos < $len ) {
+ $charAt = substr ( $source, $pos, 1 );
+ if ( $charAt == '%' ) {
+ $pos++;
+ $charAt = substr ( $source, $pos, 1 );
+
+ if ( $charAt == 'u' ) {
+ // we got a unicode character
+ $pos++;
+ $unicodeHexVal = substr ( $source, $pos, 4 );
+ $unicode = hexdec ( $unicodeHexVal );
+ $decodedStr .= code2utf( $unicode );
+ $pos += 4;
+ } else {
+ // we have an escaped ascii character
+ $hexVal = substr ( $source, $pos, 2 );
+ $decodedStr .= chr ( hexdec ( $hexVal ) );
+ $pos += 2;
+ }
+ } else {
+ $decodedStr .= $charAt;
+ $pos++;
+ }
+ }
+
+ if ( $iconv_to != "UTF-8" ) {
+ $decodedStr = iconv( "utf-8", $iconv_to, $decodedStr );
+ }
+
+ return $decodedStr;
+}
+
function wfSajaxGetMathUrl( $term ) {
$originalLink = MathRenderer::renderMath( $term );
@@ -124,8 +171,8 @@
global $wgContLang, $wgExtraNamespaces;
$limit = 30;
$ns = array(NS_MAIN, NS_CATEGORY, NS_IMAGE, NS_TEMPLATE, NS_USER, NS_HELP);
- if (defined(SF_NS_FORM)) $ns[]= SF_NS_FORM;
- if (defined(SMW_NS_PROPERTY)) $ns[]= SMW_NS_PROPERTY;
+ if (defined('SF_NS_FORM')) $ns[]= SF_NS_FORM;
+ if (defined('SMW_NS_PROPERTY')) $ns[]= SMW_NS_PROPERTY;
$term = $wgContLang->checkTitleEncoding( $wgContLang->recodeInput( js_unescape( $term ) ) );
$prefix = "";
=== modified file 'extensions/WYSIWYG/WYSIWYG.php'
--- extensions/WYSIWYG/WYSIWYG.php 2012-02-27 13:33:51 +0000
+++ extensions/WYSIWYG/WYSIWYG.php 2012-03-02 10:09:52 +0000
@@ -99,6 +99,7 @@
$wgAutoloadClasses['CKeditorParser'] = $dir . 'CKeditorParser.body.php';
$wgAutoloadClasses['CKeditorParserOptions'] = $dir . 'CKeditorParserOptions.body.php';
$wgAutoloadClasses['CKeditorParserWrapper'] = $dir . 'CKeditorParserWrapper.body.php';
+$wgAutoloadClasses['CKeditorLinker'] = $dir . 'CKeditorLinker.php';
$wgAutoloadClasses['CKeditorSkin'] = $dir . 'CKeditorSkin.body.php';
$wgAutoloadClasses['CKeditorEditPage'] = $dir . 'CKeditorEditPage.body.php';
$wgAutoloadClasses['CKeditor_MediaWiki'] = $dir . 'CKeditor.body.php';