Changeset 567

Show
Ignore:
Timestamp:
2007-07-26 20:16:45 (18 months ago)
Author:
wwalc
Message:

added ajax function to resolve image url

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

Legend:

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

    r539 r567  
    5252$wgAjaxExportList[] = 'wfSajaxSearchArticleFCKeditor'; 
    5353$wgAjaxExportList[] = 'wfSajaxWikiToHTML'; 
     54$wgAjaxExportList[] = 'wfSajaxGetImageUrl'; 
    5455 
    5556$wgExtensionCredits['other'][] = array( 
  • MediaWiki/trunk/extensions/FCKeditor/FCKeditorSajax.body.php

    r565 r567  
    11<?php 
     2 
     3function wfSajaxGetImageUrl( $term ) 
     4{ 
     5    global $wgContLang, $wgOut; 
     6 
     7    $term = $wgContLang->checkTitleEncoding( $wgContLang->recodeInput( js_unescape( $term ) ) ); 
     8    $term1 = str_replace( ' ', '_', $wgContLang->ucfirst( $term ) ); 
     9    $term2 = str_replace( ' ', '_', $wgContLang->lc( $term ) ); 
     10    $term3 = str_replace( ' ', '_', $wgContLang->uc( $term ) ); 
     11    $term = $term1; 
     12 
     13    if ( strlen( str_replace( '_', '', $term ) )<3 ) 
     14    return ""; 
     15 
     16    $db =& wfGetDB( DB_SLAVE ); 
     17    $res = $db->select( 'page', 'page_title', 
     18    array(  'page_namespace' => NS_IMAGE, 
     19    "LCASE(page_title) = '". $db->strencode( $term2 ) ."'" ), 
     20    "wfSajaxSearch", 
     21    array( 'LIMIT' => 1 ) 
     22    ); 
     23 
     24    $row = $db->fetchObject( $res ); 
     25    if (!$row) { 
     26        return ""; 
     27    } 
     28     
     29    $ret = $row->page_title; 
     30 
     31    if (!is_null($ret)) { 
     32        $title = new Title(); 
     33        $nt = Title::newFromText( $term , NS_IMAGE); 
     34        $img   = new Image( $nt ); 
     35        return $img->getURL(); 
     36    } else { 
     37        return ""; 
     38    } 
     39 
     40    return $ret; 
     41} 
    242 
    343function wfSajaxSearchImageFCKeditor( $term )