function wfMungeToUtf8( $string ) {
global $wgInputEncoding; # This is debatable
#$string = iconv($wgInputEncoding, "UTF-8", $string);
- $string = preg_replace ( '/&#([0-9]+);/e', 'wfUtf8Sequence($1)', $string );
+ $string = preg_replace ( '/�*([0-9]+);/e', 'wfUtf8Sequence($1)', $string );
$string = preg_replace ( '/&#x([0-9a-f]+);/ie', 'wfUtf8Sequence(0x$1)', $string );
# Should also do named entities here
return $string;
$forward .= ' from ' . $_SERVER['HTTP_FROM'];
if( $forward )
$forward = "\t(proxied via {$_SERVER['REMOTE_ADDR']}{$forward})";
- if($wgUser->getId() == 0)
+ if( $wgUser->isAnon() )
$forward .= ' anon';
$log = sprintf( "%s\t%04.3f\t%s\n",
gmdate( 'YmdHis' ), $elapsed,
if( is_object( $wgMessageCache ) ) {
$message = $wgMessageCache->get( $key, $useDB, $forContent );
- }
- else {
+ } else {
if( $forContent ) {
$lang = &$wgContLang;
} else {
}
wfSuppressWarnings();
+
if( is_object( $lang ) ) {
$message = $lang->getMessage( $key );
} else {
*/
function wfEscapeWikiText( $text ) {
$text = str_replace(
- array( '[', '|', "'", 'ISBN ' , '://' , "\n=", '{{' ),
+ array( '[', '|', '\'', 'ISBN ' , '://' , "\n=", '{{' ),
array( '[', '|', ''', 'ISBN ', '://' , "\n=", '{{' ),
htmlspecialchars($text) );
return $text;
wfEscapeShellArg( $yourtextName );
$handle = popen( $cmd, 'r' );
- if( fgets( $handle ) ){
+ if( fgets( $handle, 1024 ) ){
$conflict = true;
} else {
$conflict = false;
# Don't send content if it's a HEAD request.
if( $_SERVER['REQUEST_METHOD'] == 'HEAD' ) {
header( 'Content-type: text/plain' );
- print "$desc\n";
+ print $desc."\n";
}
}
return wfTimestamp( TS_MW, time() );
}
-/**
- * Sorting hack for MySQL 3, which doesn't use index sorts for DESC
- */
-function wfInvertTimestamp( $ts ) {
- return strtr(
- $ts,
- '0123456789',
- '9876543210'
- );
-}
-
/**
* Reference-counted warning suppression
*/
$uts=$ts;
} else {
# Bogus value; fall back to the epoch...
- wfDebug("wfTimestamp() given bogus time value.\n");
+ wfDebug("wfTimestamp() fed bogus time value: $outputtype; $ts\n");
$uts = 0;
}
- if ($ts==0)
- $uts=time();
+ if ($ts==0) { $uts=time(); }
+
switch($outputtype) {
- case TS_UNIX:
- return $uts;
- case TS_MW:
- return gmdate( 'YmdHis', $uts );
- case TS_DB:
- return gmdate( 'Y-m-d H:i:s', $uts );
- case TS_RFC2822:
- return gmdate( "D, d M Y H:i:s", $uts ) . ' GMT';
- default:
- wfDebugDieBacktrace( 'wfTimestamp() called with illegal output type.');
+ case TS_UNIX:
+ return $uts;
+ case TS_MW:
+ return gmdate( 'YmdHis', $uts );
+ case TS_DB:
+ return gmdate( 'Y-m-d H:i:s', $uts );
+ case TS_RFC2822:
+ return gmdate( 'D, d M Y H:i:s', $uts ) . ' GMT';
+ default:
+ wfDebugDieBacktrace( 'wfTimestamp() called with illegal output type.');
}
}
/**
* Check where as the operating system is Windows
*
- * @todo document
* @return bool True if it's windows, False otherwise.
*/
function wfIsWindows() {
}
}
+/**
+ * Swap two variables
+ */
+function swap( &$x, &$y ) {
+ $z = $x;
+ $x = $y;
+ $y = $z;
+}
+
+function wfGetSiteNotice() {
+ global $wgSiteNotice, $wgTitle, $wgOut;
+ $fname = 'wfGetSiteNotice';
+ wfProfileIn( $fname );
+
+ $notice = wfMsg( 'sitenotice' );
+ if($notice == '<sitenotice>') $notice = '';
+ # Allow individual wikis to turn it off
+ if ( $notice == '-' ) {
+ $notice = '';
+ } else {
+ if ($notice == '') {
+ $notice = $wgSiteNotice;
+ }
+ if($notice != '-' && $notice != '') {
+ $specialparser = new Parser();
+ $parserOutput = $specialparser->parse( $notice, $wgTitle, $wgOut->mParserOptions, false );
+ $notice = $parserOutput->getText();
+ }
+ }
+ wfProfileOut( $fname );
+ return $notice;
+}
+
+/**
+ * Format an XML element with given attributes and, optionally, text content.
+ * Element and attribute names are assumed to be ready for literal inclusion.
+ * Strings are assumed to not contain XML-illegal characters; special
+ * characters (<, >, &) are escaped but illegals are not touched.
+ *
+ * @param string $element
+ * @param array $attribs Name=>value pairs. Values will be escaped.
+ * @param bool $contents NULL to make an open tag only; '' for a contentless closed tag (default)
+ * @return string
+ */
+function wfElement( $element, $attribs = array(), $contents = '') {
+ $out = '<' . $element;
+ foreach( $attribs as $name => $val ) {
+ $out .= ' ' . $name . '="' . htmlspecialchars( $val ) . '"';
+ }
+ if( is_null( $contents ) ) {
+ $out .= '>';
+ } else {
+ if( $contents == '' ) {
+ $out .= ' />';
+ } else {
+ $out .= '>';
+ $out .= htmlspecialchars( $contents );
+ $out .= "</$element>";
+ }
+ }
+ return $out;
+}
+
?>