Ticket #2223: 2223_7.patch

File 2223_7.patch, 11.3 KB (added by arczi, 18 months ago)
  • FCKeditorParser.body.php

     
    305305        } 
    306306 
    307307        function replaceInternalLinks( $text ) { 
    308                 $text = preg_replace("/\[\[([^|\[\]]*?)\]\]/", "[[RTENOTITLE$1|$1]]", $text);   //#2223: [[()]] =>      [[RTENOTITLE%1|%1]] 
     308                $text = preg_replace("/\[\[([^|\[\]]*?)\]\]/", "[[$1|RTENOTITLE]]", $text);     //#2223: [[()]] =>      [[%1|RTENOTITLE]] 
    309309                $text = preg_replace("/\[\[:(.*?)\]\]/", "[[RTECOLON$1]]", $text);      //change ':' => 'RTECOLON' in links 
    310310                $text = parent::replaceInternalLinks($text); 
    311                 $text = preg_replace("/<strong class=\"selflink\">(.*?)<\/strong>/", "<a href=\"".$this->mTitle->mDbkeyform."\" class=\"selflink\">$1</a>", $text);                             // #2075 
    312                 $text = preg_replace("/\[\[RTENOTITLE(.*?)\|/", "[[", $text);                           // remove unused RTENOTITLE 
     311                $text = preg_replace("/\|RTENOTITLE\]\]/", "]]", $text);                                // remove unused RTENOTITLE 
    313312 
    314313                return $text; 
    315314        } 
     
    468467                if ($categories) { 
    469468                        $appendString = ""; 
    470469                        foreach ($categories as $cat=>$val) { 
     470                                $args = ''; 
     471                                if( $val == 'RTENOTITLE' ){ 
     472                                                $args .= '_fcknotitle="true" '; 
     473                                        $val = $cat; 
     474                                } 
    471475                                if ($val != $title->mTextform) { 
    472                                         $appendString .= "<a href=\"Category:" . $cat ."\">" . $val ."</a> "; 
     476                                        $appendString .= "<a ".$args."href=\"Category:" . $cat ."\">" . $val ."</a> "; 
    473477                                } 
    474478                                else { 
    475                                         $appendString .= "<a href=\"Category:" . $cat ."\">Category:" . $cat ."</a> "; 
     479                                        $appendString .= "<a ".$args."href=\"Category:" . $cat ."\">Category:" . $cat ."</a> "; 
    476480                                } 
    477481                        } 
    478482                        $parserOutput->setText($parserOutput->getText() . $appendString); 
  • FCKeditorSkin.body.php

     
    2424                $imgName = $img->getName(); 
    2525                $found = $img->getURL(); 
    2626 
     27                if (!is_null($alt) && ( $alt == 'RTENOTITLE' ))  {              //2223 
     28                        $alt = ''; 
     29                } 
     30 
    2731                if ($found) { 
    2832                        //trick to get real Url for image: 
    2933                        $originalLink = strip_tags(Linker::makeImageLinkObj($nt, $label, $alt, $align , $params , $framed , $thumb , $manual_thumb , $valign ), "<img>"); 
     
    125129                $imgName = $img->getName(); 
    126130                $found = $img->getURL(); 
    127131 
     132                if( $frameParams['alt'] == 'RTENOTITLE' ){      //2223 
     133                        $frameParams['alt'] = ''; 
     134                } 
    128135                if ($found) { 
    129136                        $linker = new Linker(); 
    130137                        $originalLink = $linker->makeImageLink2( $nt, $file, $frameParams, $handlerParams); 
     
    212219 
    213220                return $ret; 
    214221        } 
     222         
     223        function makeLinkObj( $nt, $text= '', $query = '', $trail = '', $prefix = '' ) { 
     224                global $wgUser; 
    215225 
     226                wfProfileIn( __METHOD__ ); 
     227                if ( $nt->isExternal() ) { 
     228                        $args = ''; 
     229                        $u = $nt->getFullURL(); 
     230                        $link = $nt->getPrefixedURL(); 
     231                        if ( '' == $text ) { $text = $nt->getPrefixedText(); } 
     232                        $style = $this->getInterwikiLinkAttributes( $link, $text, 'extiw' ); 
     233 
     234                        $inside = ''; 
     235                        if ( '' != $trail ) { 
     236                                $m = array(); 
     237                                if ( preg_match( '/^([a-z]+)(.*)$$/sD', $trail, $m ) ) { 
     238                                        $inside = $m[1]; 
     239                                        $trail = $m[2]; 
     240                                } 
     241                        } 
     242                        if( $text == 'RTENOTITLE' ) {   //2223 
     243                                $text = $u = $link; 
     244                                $args .= '_fcknotitle="true" '; 
     245                        } 
     246                        $t = "<a {$args}href=\"{$u}\"{$style}>{$text}{$inside}</a>"; 
     247 
     248                        wfProfileOut( __METHOD__ ); 
     249                        return $t; 
     250                } 
     251                 
     252                return Linker::makeLinkObj($nt, $text, $query, $trail, $prefix); 
     253         
     254        } 
    216255        function makeKnownLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' , $aprops = '', $style = '' ) { 
    217256                $fname = 'FCKeditorSkin::makeKnownLinkObj'; 
    218257                wfProfileIn( $fname ); 
    219258 
     259                $args = ''; 
    220260                if ( !is_object( $nt ) ) { 
    221261                        wfProfileOut( $fname ); 
    222262                        return $text; 
    223263                } 
    224264 
    225265                //$u = $nt->escapeLocalURL( $query ); 
    226                 $u = $nt->getFullText(); 
     266          $u = $nt->getFullText(); 
     267          //#Updating links tables -> #Updating_links_tables 
     268          $u = str_replace("#".$nt->getFragment(), $nt->getFragmentForURL(), $u); 
    227269 
    228270                if ( $nt->getFragment() != '' ) { 
    229271                        if( $nt->getPrefixedDbkey() == '' ) { 
     
    249291                } 
    250292 
    251293                list( $inside, $trail ) = Linker::splitTrail( $trail ); 
    252                 $r = "<a href=\"{$u}\">{$prefix}{$text}{$inside}</a>{$trail}"; 
     294                $title = "{$prefix}{$text}{$inside}"; 
     295 
     296                $u = preg_replace("/^RTECOLON/", ":", $u);      //change 'RTECOLON' => ':' 
     297                if( substr($text, 0, 10) == 'RTENOTITLE' ){             //starts with RTENOTITLE 
     298                        $args .= '_fcknotitle="true" '; 
     299                        $title = $u; 
     300                        $trail = substr($text, 10).$trail; 
     301                } 
     302 
     303                $r = "<a {$args}href=\"{$u}\">{$title}</a>{$trail}"; 
    253304                wfProfileOut( $fname ); 
    254305                return $r; 
    255306        } 
     
    260311                        # throw new MWException(); 
    261312                        return "<!-- ERROR -->{$prefix}{$text}{$trail}"; 
    262313                } 
     314                $args = ''; 
    263315 
    264316                $fname = 'FCKeditorSkin::makeBrokenLinkObj'; 
    265317                wfProfileIn( $fname ); 
    266318 
    267                 $u = $nt->getFullText(); 
     319          $u = $nt->getFullText(); 
     320          //#Updating links tables -> #Updating_links_tables 
     321          $u = str_replace("#".$nt->getFragment(), $nt->getFragmentForURL(), $u); 
    268322 
    269323                if ( '' == $text ) { 
    270324                        $text = htmlspecialchars( $nt->getPrefixedText() ); 
     
    274328                } 
    275329 
    276330                list( $inside, $trail ) = Linker::splitTrail( $trail ); 
    277                 $s = "<a href=\"{$u}\">{$prefix}{$text}{$inside}</a>{$trail}"; 
     331                $title = "{$prefix}{$text}{$inside}"; 
    278332 
     333                $u = preg_replace("/^RTECOLON/", ":", $u);      //change 'RTECOLON' => ':' 
     334                if( substr($text, 0, 10) == 'RTENOTITLE' ){             //starts with RTENOTITLE 
     335                        $args .= '_fcknotitle="true" '; 
     336                        $title = $u; 
     337                        $trail = substr($text, 10).$trail; 
     338                } 
     339                $s = "<a {$args}href=\"{$u}\">{$title}</a>{$trail}"; 
     340 
    279341                wfProfileOut( $fname ); 
    280342                return $s; 
    281343        } 
    282344 
     345        function makeSelfLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) { 
     346                $args = ''; 
     347                if ( '' == $text ) { 
     348                        $text = $nt->mDbkeyform; 
     349                } 
     350                list( $inside, $trail ) = Linker::splitTrail( $trail ); 
     351                $title = "{$prefix}{$text}"; 
     352                if( $text == 'RTENOTITLE' ){                    //2223 
     353                        $args .= '_fcknotitle="true" '; 
     354                        $title = $nt->mDbkeyform; 
     355                } 
     356                return "<a {$args}href=\"".$nt->mDbkeyform."\" class=\"selflink\">{$title}</a>{$inside}{$trail}"; 
     357        } 
     358 
    283359        /** 
    284360         * Create a direct link to a given uploaded file. 
    285361         * 
     
    295371                        ### HOTFIX. Instead of breaking, return empty string. 
    296372                        return $text; 
    297373                } else { 
     374                        $args = ''; 
    298375                        $orginal = $title->getPartialURL(); 
    299376                        // Mediawiki 1.11 
    300377                        if ( function_exists('wfFindFile') ) { 
     
    324401                        if( $text == '' ) { 
    325402                                $text = $alt; 
    326403                        } 
    327                         $u = htmlspecialchars( $url ); 
    328                         return "<a href=\"{$orginal}\" class=\"$class\" _fck_mw_filename=\"{$orginal}\" _fck_mw_type=\"media\" title=\"{$alt}\">{$text}</a>"; 
     404                        $orginal = preg_replace("/^RTECOLON/", ":", $orginal);  //change 'RTECOLON' => ':' 
     405                        if( $text == 'RTENOTITLE' ){                    //2223 
     406                                $args .= '_fcknotitle="true" '; 
     407                                $text = $orginal; 
     408                                $alt = $orginal; 
     409                        } 
     410                        return "<a href=\"{$orginal}\" class=\"$class\" {$args} _fck_mw_filename=\"{$orginal}\" _fck_mw_type=\"media\" title=\"{$alt}\">{$text}</a>"; 
    329411                } 
    330412        } 
    331413 
     
    334416                if( $escape ) { 
    335417                        $text = htmlspecialchars( $text ); 
    336418                } 
     419                $url = preg_replace("/^RTECOLON/", ":", $url);  //change 'RTECOLON' => ':' 
    337420                if ($linktype == 'autonumber') { 
    338421                        return '<a href="'.$url.'">[n]</a>'; 
    339422                } 
    340                 return '<a href="'.$url.'">'.$text.'</a>'; 
     423                $args = ''; 
     424                if( $text == 'RTENOTITLE' ){                                                            //2223 
     425                        $args .= '_fcknotitle="true" '; 
     426                        $text = $url; 
     427                } 
     428                return '<a '.$args.'href="'.$url.'">'.$text.'</a>'; 
    341429        } 
    342430 
    343431        function __call( $m, $a) { 
  • mw12/FCKeditorParser_OldPP.body.php

     
    306306        } 
    307307 
    308308        function replaceInternalLinks( $text ) { 
    309                 $text = preg_replace("/\[\[([^|\[\]]*?)\]\]/", "[[RTENOTITLE$1|$1]]", $text);   //#2223: [[()]] =>      [[RTENOTITLE%1|%1]] 
     309                $text = preg_replace("/\[\[([^|\[\]]*?)\]\]/", "[[$1|RTENOTITLE]]", $text);     //#2223: [[()]] =>      [[%1|RTENOTITLE]] 
    310310                $text = preg_replace("/\[\[:(.*?)\]\]/", "[[RTECOLON$1]]", $text);      //change ':' => 'RTECOLON' in links 
    311311                $text = parent::replaceInternalLinks($text); 
    312                 $text = preg_replace("/<strong class=\"selflink\">(.*?)<\/strong>/", "<a href=\"".$this->mTitle->mDbkeyform."\" class=\"selflink\">$1</a>", $text);                             // #2075 
    313                 $text = preg_replace("/\[\[RTENOTITLE(.*?)\|/", "[[", $text);                           // remove unused RTENOTITLE 
     312                $text = preg_replace("/\|RTENOTITLE\]\]/", "]]", $text);                                // remove unused RTENOTITLE 
    314313 
    315314                return $text; 
    316315        } 
     
    469468                if ($categories) { 
    470469                        $appendString = ""; 
    471470                        foreach ($categories as $cat=>$val) { 
     471                                $args = ''; 
     472                                if( $val == 'RTENOTITLE' ){ 
     473                                                $args .= '_fcknotitle="true" '; 
     474                                        $val = $cat; 
     475                                } 
    472476                                if ($val != $title->mTextform) { 
    473                                         $appendString .= "<a href=\"Category:" . $cat ."\">" . $val ."</a> "; 
     477                                        $appendString .= "<a ".$args."href=\"Category:" . $cat ."\">" . $val ."</a> "; 
    474478                                } 
    475479                                else { 
    476                                         $appendString .= "<a href=\"Category:" . $cat ."\">Category:" . $cat ."</a> "; 
     480                                        $appendString .= "<a ".$args."href=\"Category:" . $cat ."\">Category:" . $cat ."</a> "; 
    477481                                } 
    478482                        } 
    479483                        $parserOutput->setText($parserOutput->getText() . $appendString); 
  • plugins/mediawiki/dialogs/link.html

     
    7070                sHRef = oLink.getAttribute( 'href' , 2 ) || '' ; 
    7171                 
    7272        sHRef = FCKConfig.ProtectedSource.Revert(sHRef, 0);             //#2509 
    73         if (sHRef.toLowerCase().StartsWith( 'rtenotitle' ) ) 
    74         { 
    75                 sHRef = sHRef.substring(10); 
    76                 bLinkEqualsName = true; 
    77         } 
    7873                 
    7974        if ( sHRef == oLink.innerHTML ) 
    8075                bLinkEqualsName = true ; 
     
    189184        var sUri = GetE('txtUrl').value ; 
    190185        sUri  = FCKConfig.ProtectedSource.Protect(sUri);                //#2509 
    191186        var realUri = sUri; 
    192         if ( bLinkEqualsName ) { 
    193                 sUri = 'RTENOTITLE'+ sUri; 
    194         } 
    195187        if (sUri.StartsWith( ':' ) ) 
    196188                sUri = sUri.replace(/:/, "rtecolon"); 
    197189        var sInnerHtml ; 
  • plugins/mediawiki/fckplugin.js

     
    367367                                                                stringBuilder.push( isWikiUrl ? '[[' : '[' ) ; 
    368368                                                        } 
    369369                                                        //#2223 
    370                                                         if (href.toLowerCase().StartsWith( 'rtenotitle' )) 
     370                                                        if (htmlNode.getAttribute( '_fcknotitle' ) && htmlNode.getAttribute( '_fcknotitle' ) == "true") 
    371371                                                        { 
    372                                                                 href = href.substring(10); 
    373                                                                 if ( FCKConfig.ProtectedSource.Revert(htmlNode.innerHTML, 0) == FCKConfig.ProtectedSource.Revert(href, 0) ) pipeline = false; 
     372                                                                var testInner = FCKConfig.ProtectedSource.Revert(htmlNode.innerHTML, 0); 
     373                                                                if (href.toLowerCase().StartsWith( 'category:' )) testInner = 'Category:'+testInner; 
     374                                                                testInner = testInner.replace(/&amp;/, "&")  
     375                                                                if ( testInner == FCKConfig.ProtectedSource.Revert(href, 0) ) pipeline = false; 
    374376                                                        } 
    375377                                                        if (href.toLowerCase().StartsWith( 'rtecolon' ))                //change 'rtecolon=' => ':' in links 
    376378                                                        { 
     
    929931        { 
    930932                if (a.className == 'extiw') 
    931933                { 
    932                          a.href = ":" + a.title ; 
    933                          a.setAttribute( '_fcksavedurl', ":" + a.title ) ; 
     934                         a.href = a.title ; 
     935                         a.setAttribute( '_fcksavedurl', a.href ) ; 
    934936                } 
    935937                else 
    936938                {