* @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 );
* @todo document
*/
function wfNumLink( $offset, $limit, &$title, $query = '' ) {
- global $wgUser, $wgLang;
+ global $wgLang;
if ( '' == $query ) { $q = ''; }
else { $q = $query.'&'; }
$q .= 'limit='.$limit.'&offset='.$offset;
}
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 );
}
/**
* @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) {
$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;
/**
* 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
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;
+ }
}
/**
function wfDoUpdates()
{
global $wgPostCommitUpdateList, $wgDeferredUpdateList;
- foreach ( $wgDeferredUpdateList as $update ) {
+ foreach ( $wgDeferredUpdateList as $update ) {
$update->doUpdate();
}
foreach ( $wgPostCommitUpdateList as $update ) {