* (bug 10132, 10134) Restore back-compatibility Image::imageUrl() function
[lhc/web/wiklou.git] / includes / AjaxFunctions.php
index 600cd57..86f853d 100644 (file)
@@ -1,7 +1,13 @@
 <?php
 
-if( !defined( 'MEDIAWIKI' ) )
-        die( 1 );
+/** 
+ * @package MediaWiki
+ * @addtogroup Ajax
+ */
+
+if( !defined( 'MEDIAWIKI' ) ) {
+       die( 1 );
+}
 
 /**
  * Function converts an Javascript escaped string back into a string with
@@ -13,40 +19,39 @@ if( !defined( 'MEDIAWIKI' ) )
  * @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;
+       $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;
 }
 
 /**
@@ -81,7 +86,7 @@ function wfSajaxSearch( $term ) {
        if ( strlen( str_replace( '_', '', $term ) )<3 )
                return;
 
-       $db =& wfGetDB( DB_SLAVE );
+       $db = wfGetDB( DB_SLAVE );
        $res = $db->select( 'page', 'page_title',
                        array(  'page_namespace' => 0,
                                "page_title LIKE '". $db->strencode( $term) ."%'" ),
@@ -152,14 +157,14 @@ function wfAjaxWatch($pageID = "", $watch = "") {
 
        if($watch) {
                if(!$watching) {
-                       $dbw =& wfGetDB(DB_MASTER);
+                       $dbw = wfGetDB(DB_MASTER);
                        $dbw->begin();
                        $article->doWatch();
                        $dbw->commit();
                }
        } else {
                if($watching) {
-                       $dbw =& wfGetDB(DB_MASTER);
+                       $dbw = wfGetDB(DB_MASTER);
                        $dbw->begin();
                        $article->doUnwatch();
                        $dbw->commit();