}
}
+if( !function_exists( 'floatval' ) ) {
+ /**
+ * First defined in PHP 4.2.0
+ * @param mixed $var;
+ * @return float
+ */
+ function floatval( $var ) {
+ return (float)$var;
+ }
+}
+
/**
* Where as we got a random seed
* @var bool $wgTotalViews
if ( '' == $wgReadOnlyFile ) {
return false;
}
- return is_file( $wgReadOnlyFile );
+
+ // Set $wgReadOnly and unset $wgReadOnlyFile, for faster access next time
+ if ( is_file( $wgReadOnlyFile ) ) {
+ $wgReadOnly = true;
+ } else {
+ $wgReadOnly = false;
+ }
+ $wgReadOnlyFile = '';
+ return $wgReadOnly;
}
function wfMsgHtml( $key ) {
$args = func_get_args();
array_shift( $args );
- return wfMsgReplaceArgs(
- htmlspecialchars( wfMsgGetKey( $key, $args, true ) ),
- $args );
+ return wfMsgReplaceArgs( htmlspecialchars( wfMsgGetKey( $key, true ) ), $args );
}
/**
$msg .= "\n<p>Backtrace:</p>\n$backtrace";
}
}
- die( $msg );
+ echo $msg;
+ die( -1 );
}
function wfBacktrace() {
$pairs = array(
"\\" => "\\\\",
"\"" => "\\\"",
- "\'" => "\\\'",
+ '\'' => '\\\'',
"\n" => "\\n",
"\r" => "\\r",
wfProfileIn( $fname );
$notice = wfMsg( 'sitenotice' );
- if($notice == '<sitenotice>') $notice = '';
- # Allow individual wikis to turn it off
- if ( $notice == '-' ) {
+ if( $notice == '<sitenotice>' || $notice == '-' ) {
$notice = '';
- } else {
- if ($notice == '') {
- $notice = $wgSiteNotice;
- }
- if($notice != '-' && $notice != '') {
- $specialparser = new Parser();
- $parserOutput = $specialparser->parse( $notice, $wgTitle, $wgOut->mParserOptions, false );
- $notice = $parserOutput->getText();
- }
+ }
+ if( $notice == '' ) {
+ # We may also need to override a message with eg downtime info
+ # FIXME: make this work!
+ $notice = $wgSiteNotice;
+ }
+ if($notice != '-' && $notice != '') {
+ $specialparser = new Parser();
+ $parserOutput = $specialparser->parse( $notice, $wgTitle, $wgOut->mParserOptions, false );
+ $notice = $parserOutput->getText();
}
wfProfileOut( $fname );
return $notice;
return true;
}
-
+/**
+ * Increment a statistics counter
+ */
function wfIncrStats( $key ) {
global $wgDBname, $wgMemc;
$key = "$wgDBname:stats:$key";
}
}
+/**
+ * @param mixed $nr The number to format
+ * @param int $acc The number of digits after the decimal point, default 2
+ * @param bool $round Whether or not to round the value, default true
+ * @return float
+ */
+function percent( $nr, $acc = 2, $round = true ) {
+ $ret = sprintf( "%.${acc}f", $nr );
+ return $round ? round( $ret, $acc ) . '%' : "$ret%";
+}
?>