Moved getNameSpaceKey() from SkinTemplate to title.
[lhc/web/wiklou.git] / includes / GlobalFunctions.php
index 7a46e5a..4837481 100644 (file)
@@ -716,7 +716,7 @@ function wfShowingResultsNum( $offset, $limit, $num ) {
  * @todo document
  */
 function wfViewPrevNext( $offset, $limit, $link, $query = '', $atend = false ) {
-       global $wgUser, $wgLang;
+       global $wgLang;
        $fmtLimit = $wgLang->formatNum( $limit );
        $prev = wfMsg( 'prevn', $fmtLimit );
        $next = wfMsg( 'nextn', $fmtLimit );
@@ -760,7 +760,7 @@ function wfViewPrevNext( $offset, $limit, $link, $query = '', $atend = false ) {
  * @todo document
  */
 function wfNumLink( $offset, $limit, &$title, $query = '' ) {
-       global $wgUser, $wgLang;
+       global $wgLang;
        if ( '' == $query ) { $q = ''; }
        else { $q = $query.'&'; }
        $q .= 'limit='.$limit.'&offset='.$offset;
@@ -956,7 +956,28 @@ function wfEscapeShellArg( ) {
                }
 
                if ( wfIsWindows() ) {
-                       $retVal .= '"' . str_replace( '"','\"', $arg ) . '"';
+                       // Escaping for an MSVC-style command line parser
+                       // Ref: http://mailman.lyra.org/pipermail/scite-interest/2002-March/000436.html
+                       // Double the backslashes before any double quotes. Escape the double quotes.
+                       $tokens = preg_split( '/(\\\\*")/', $arg, -1, PREG_SPLIT_DELIM_CAPTURE );
+                       $arg = '';
+                       $delim = false;
+                       foreach ( $tokens as $token ) {
+                               if ( $delim ) {
+                                       $arg .= str_replace( '\\', '\\\\', substr( $token, 0, -1 ) ) . '\\"';
+                               } else {
+                                       $arg .= $token;
+                               }
+                               $delim = !$delim;
+                       }
+                       // Double the backslashes before the end of the string, because
+                       // we will soon add a quote
+                       if ( preg_match( '/^(.*?)(\\\\+)$/', $arg, $m ) ) {
+                               $arg = $m[1] . str_replace( '\\', '\\\\', $m[2] );
+                       }
+
+                       // Add surrounding quotes
+                       $retVal .= '"' . $arg . '"';
                } else {
                        $retVal .= escapeshellarg( $arg );
                }
@@ -1255,7 +1276,7 @@ define('TS_ORACLE', 6);
 /**
  * @param mixed $outputtype A timestamp in one of the supported formats, the
  *                          function will autodetect which format is supplied
                           and act accordingly.
*                          and act accordingly.
  * @return string Time in the format specified in $outputtype
  */
 function wfTimestamp($outputtype=TS_UNIX,$ts=0) {
@@ -1504,7 +1525,7 @@ function &HTMLnamespaceselector($selected = '', $allnamespaces = null) {
                        $selected = intval( $selected );
                }
        }
-       $s = "<select name='namespace' class='namespaceselector'>\n\t";
+       $s = "<select id='namespace' name='namespace' class='namespaceselector'>\n\t";
        $arr = $wgContLang->getFormattedNamespaces();
        if( !is_null($allnamespaces) ) {
                $arr = array($allnamespaces => wfMsgHtml('namespacesall')) + $arr;
@@ -1599,26 +1620,26 @@ function wfMkdirParents( $fullDir, $mode ) {
 /**
  * Increment a statistics counter
  */
-function wfIncrStats( $key ) {
-       global $wgDBname, $wgMemc;
-        /* LIVE HACK AVOID MEMCACHED ACCESSES DURING HIGH LOAD */
-        if ($wgDBname != 'enwiki' and $wgDBname != 'dewiki' and $wgDBname != 'commonswiki' and $wgDBname != 'testwiki')
-            return true;
-        static $socket;
-        if (!$socket) {
-            $socket=socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
-            $statline="{$wgDBname} - 1 1 1 1 1 -total\n";
-            socket_sendto($socket,$statline,strlen($statline),0,"webster","3811");
-        }
-        $statline="{$wgDBname} - 1 1 1 1 1 {$key}\n";
-        socket_sendto($socket,$statline,strlen($statline),0,"webster","3811");
-        return true;
-
-       $key = "$wgDBname:stats:$key";
-       if ( is_null( $wgMemc->incr( $key ) ) ) {
-               $wgMemc->add( $key, 1 );
-       }
-}
+ function wfIncrStats( $key ) {
+        global $wgDBname, $wgMemc;
+        /* LIVE HACK AVOID MEMCACHED ACCESSES DURING HIGH LOAD */
+        if ($wgDBname != 'enwiki' and $wgDBname != 'dewiki' and $wgDBname != 'commonswiki' and $wgDBname != 'testwiki')
+                return true;
+        static $socket;
+        if (!$socket) {
+                $socket=socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
+                $statline="{$wgDBname} - 1 1 1 1 1 -total\n";
+                socket_sendto($socket,$statline,strlen($statline),0,"webster","3811");
+        }
+        $statline="{$wgDBname} - 1 1 1 1 1 {$key}\n";
+        socket_sendto($socket,$statline,strlen($statline),0,"webster","3811");
+        return true;
+
+        $key = "$wgDBname:stats:$key";
+        if ( is_null( $wgMemc->incr( $key ) ) ) {
+                $wgMemc->add( $key, 1 );
+        }
+ }
 
 /**
  * @param mixed $nr The number to format
@@ -1692,11 +1713,17 @@ function in_string( $needle, $str ) {
 function wfUrlProtocols() {
        global $wgUrlProtocols;
 
-       $protocols = array();
-       foreach ($wgUrlProtocols as $protocol)
-               $protocols[] = preg_quote( $protocol, '/' );
+       // Support old-style $wgUrlProtocols strings, for backwards compatibility
+       // with LocalSettings files from 1.5
+       if ( is_array( $wgUrlProtocols ) ) {
+               $protocols = array();
+               foreach ($wgUrlProtocols as $protocol)
+                       $protocols[] = preg_quote( $protocol, '/' );
 
-       return implode( '|', $protocols );
+               return implode( '|', $protocols );
+       } else {
+               return $wgUrlProtocols;
+       }
 }
 
 /**
@@ -1883,7 +1910,7 @@ function wfMakeUrlIndex( $url ) {
 function wfDoUpdates()
 {
        global $wgPostCommitUpdateList, $wgDeferredUpdateList;
-       foreach ( $wgDeferredUpdateList as $update ) { 
+       foreach ( $wgDeferredUpdateList as $update ) {
                $update->doUpdate();
        }
        foreach ( $wgPostCommitUpdateList as $update ) {