fixed Uncategorizedcategories caching
[lhc/web/wiklou.git] / includes / GlobalFunctions.php
index d310e27..c0c9e0a 100644 (file)
@@ -79,6 +79,17 @@ if ( !function_exists( 'mb_substr' ) ) {
        }
 }
 
+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
@@ -373,9 +384,7 @@ function wfMsgReplaceArgs( $message, $args ) {
 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 );
 }
 
 /**
@@ -431,7 +440,8 @@ function wfDebugDieBacktrace( $msg = '' ) {
                        $msg .= "\n<p>Backtrace:</p>\n$backtrace";
                }
         }
-        die( $msg );
+        echo $msg;
+        die( -1 );
 }
 
 function wfBacktrace() {
@@ -642,7 +652,7 @@ function wfEscapeJsString( $string ) {
        $pairs = array(
                "\\" => "\\\\",
                "\"" => "\\\"",
-               "\'" => "\\\'",
+               '\'' => '\\\'',
                "\n" => "\\n",
                "\r" => "\\r",
                
@@ -1116,19 +1126,18 @@ function wfGetSiteNotice() {
        wfProfileIn( $fname );
 
        $notice = wfMsg( 'sitenotice' );
-       if($notice == '&lt;sitenotice&gt;') $notice = '';
-       # Allow individual wikis to turn it off
-       if ( $notice == '-' ) {
+       if( $notice == '&lt;sitenotice&gt;' || $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;
@@ -1267,4 +1276,14 @@ function wfIncrStats( $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%";
+}
 ?>