Changeset 601

Show
Ignore:
Timestamp:
2007-07-31 11:30:39 (18 months ago)
Author:
wwalc
Message:

added basic category handling... still interwiki language prefixes needs to be done

Location:
MediaWiki/trunk/extensions/FCKeditor
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • MediaWiki/trunk/extensions/FCKeditor/FCKeditorParser.body.php

    r583 r601  
    170170    } 
    171171 
     172    function parse( $text, &$title, $options, $linestart = true, $clearState = true, $revid = null ) { 
     173        $parserOutput = parent::parse($text, &$title, $options, $linestart , $clearState , $revid ); 
     174         
     175        $categories = $parserOutput->getCategories(); 
     176        if ($categories) { 
     177            $appendString = ""; 
     178            foreach ($categories as $cat=>$val) { 
     179                $appendString .= "<a href=\"Category:" . $cat ."\">Category:" . $cat ."</a> "; 
     180            } 
     181            $parserOutput->setText($parserOutput->getText() . $appendString); 
     182        }                 
     183         
     184        return $parserOutput; 
     185    } 
     186     
    172187    /* 
    173188    function replaceVariables( $text, $args = array(), $argsOnly = false ) { 
  • MediaWiki/trunk/extensions/FCKeditor/FCKeditorSajax.body.php

    r579 r601  
    7575{ 
    7676    global $wgContLang, $wgOut; 
    77     $limit = 10; 
    78  
     77    $limit = 10;     
     78    $ns = NS_MAIN; 
     79     
    7980    $term = $wgContLang->checkTitleEncoding( $wgContLang->recodeInput( js_unescape( $term ) ) ); 
     81     
     82    if (strpos($term, "Category:") === 0) { 
     83        $ns = NS_CATEGORY; 
     84        $term = substr($term, 9); 
     85        $prefix = "Category:"; 
     86    } 
     87    else if (strpos($term, ":Category:") === 0) { 
     88        $ns = NS_CATEGORY; 
     89        $term = substr($term, 10);         
     90        $prefix = ":Category:"; 
     91    } 
     92     
    8093    $term1 = str_replace( ' ', '_', $wgContLang->ucfirst( $term ) ); 
    8194    $term2 = str_replace( ' ', '_', $wgContLang->lc( $term ) ); 
     
    8396    $term = $term1; 
    8497 
    85     if ( strlen( str_replace( '_', '', $term ) )<3 ) 
    86     return ""; 
     98    if ( strlen( str_replace( '_', '', $term ) )<3 ) { 
     99        return ""; 
     100    } 
    87101 
    88102    $db =& wfGetDB( DB_SLAVE ); 
    89103    $res = $db->select( 'page', 'page_title', 
    90     array(  'page_namespace' => NS_MAIN, 
     104    array(  'page_namespace' => $ns, 
    91105    "LCASE(page_title) LIKE '%". $db->strencode( $term2 ) ."%'" ), 
    92106    "wfSajaxSearch", 
     
    97111    $i=0; 
    98112    while ( ( $row = $db->fetchObject( $res ) ) && ( ++$i <= $limit ) ) { 
     113        if (!is_null($prefix)) { 
     114            $ret .= $prefix; 
     115        } 
    99116        $ret .= $row->page_title ."\n"; 
    100117    } 
  • MediaWiki/trunk/extensions/FCKeditor/FCKeditorSkin.body.php

    r582 r601  
    123123            $text = htmlspecialchars( $nt->getPrefixedText() ); 
    124124        } 
     125         
     126        if ($nt->getNamespace() == NS_CATEGORY) { 
     127            $u = ':' . $u; 
     128        } 
    125129 
    126130        list( $inside, $trail ) = Linker::splitTrail( $trail ); 
     
    141145        wfProfileIn( $fname ); 
    142146 
    143         //$u = $nt->escapeLocalURL( $query ); 
    144         //$u = $nt->getText(); 
    145         //$u = $nt->getEscapedText(); 
    146147        $u = $nt->getFullText(); 
    147         //print_r($nt); 
    148148 
    149149        if ( '' == $text ) { 
    150150            $text = htmlspecialchars( $nt->getPrefixedText() ); 
     151        } 
     152        if ($nt->getNamespace() == NS_CATEGORY) { 
     153            $u = ':' . $u; 
    151154        } 
    152155