MediaWiki namespace
[lhc/web/wiklou.git] / includes / GlobalFunctions.php
1 <?
2 # Global functions used everywhere
3
4 $wgNumberOfArticles = -1; # Unset
5 $wgTotalViews = -1;
6 $wgTotalEdits = -1;
7
8 global $IP;
9 include_once( "$IP/DatabaseFunctions.php" );
10 include_once( "$IP/UpdateClasses.php" );
11 include_once( "$IP/LogPage.php" );
12
13 # PHP 4.1+ has array_key_exists, PHP 4.0.6 has key_exists instead, and earlier
14 # versions of PHP have neither. So we roll our own. Note that this
15 # function will return false even for keys that exist but whose associated
16 # value is NULL.
17 #
18 if ( phpversion() == "4.0.6" ) {
19 function array_key_exists( $k, $a ) {
20 return key_exists( $k, $a );
21 }
22 } else if (phpversion() < "4.1") {
23 function array_key_exists( $k, $a ) {
24 return isset($a[$k]);
25 }
26 }
27
28 $wgRandomSeeded = false;
29
30 function wfSeedRandom()
31 {
32 global $wgRandomSeeded;
33
34 if ( ! $wgRandomSeeded ) {
35 $seed = hexdec(substr(md5(microtime()),-8)) & 0x7fffffff;
36 mt_srand( $seed );
37 $wgRandomSeeded = true;
38 }
39 }
40
41 function wfLocalUrl( $a, $q = "" )
42 {
43 global $wgServer, $wgScript, $wgArticlePath;
44
45 $a = str_replace( " ", "_", $a );
46 #$a = wfUrlencode( $a ); # This stuff is _already_ URL-encoded.
47
48 if ( "" == $a ) {
49 if( "" == $q ) {
50 $a = $wgScript;
51 } else {
52 $a = "{$wgScript}?{$q}";
53 }
54 } else if ( "" == $q ) {
55 $a = str_replace( "$1", $a, $wgArticlePath );
56 } else {
57 $a = "{$wgScript}?title={$a}&{$q}";
58 }
59 return $a;
60 }
61
62 function wfLocalUrlE( $a, $q = "" )
63 {
64 return wfEscapeHTML( wfLocalUrl( $a, $q ) );
65 }
66
67 function wfFullUrl( $a, $q = "" ) {
68 global $wgServer;
69 return $wgServer . wfLocalUrl( $a, $q );
70 }
71
72 function wfFullUrlE( $a, $q = "" ) {
73 return wfEscapeHTML( wfFullUrl( $a, $q ) );
74 }
75
76 function wfImageUrl( $img )
77 {
78 global $wgUploadPath;
79
80 $nt = Title::newFromText( $img );
81 $name = $nt->getDBkey();
82 $hash = md5( $name );
83
84 $url = "{$wgUploadPath}/" . $hash{0} . "/" .
85 substr( $hash, 0, 2 ) . "/{$name}";
86 return wfUrlencode( $url );
87 }
88
89 function wfImageArchiveUrl( $name )
90 {
91 global $wgUploadPath;
92
93 $hash = md5( substr( $name, 15) );
94 $url = "{$wgUploadPath}/archive/" . $hash{0} . "/" .
95 substr( $hash, 0, 2 ) . "/{$name}";
96 return $url;
97 }
98
99 function wfUrlencode ( $s )
100 {
101 $ulink = urlencode( $s );
102 $ulink = preg_replace( "/%3[Aa]/", ":", $ulink );
103 $ulink = preg_replace( "/%2[Ff]/", "/", $ulink );
104 return $ulink;
105 }
106
107 function wfUtf8Sequence($codepoint) {
108 if($codepoint < 0x80) return chr($codepoint);
109 if($codepoint < 0x800) return chr($codepoint >> 6 & 0x3f | 0xc0) .
110 chr($codepoint & 0x3f | 0x80);
111 if($codepoint < 0x10000) return chr($codepoint >> 12 & 0x0f | 0xe0) .
112 chr($codepoint >> 6 & 0x3f | 0x80) .
113 chr($codepoint & 0x3f | 0x80);
114 if($codepoint < 0x100000) return chr($codepoint >> 18 & 0x07 | 0xf0) . # Double-check this
115 chr($codepoint >> 12 & 0x3f | 0x80) .
116 chr($codepoint >> 6 & 0x3f | 0x80) .
117 chr($codepoint & 0x3f | 0x80);
118 # Doesn't yet handle outside the BMP
119 return "&#$codepoint;";
120 }
121
122 function wfMungeToUtf8($string) {
123 global $wgInputEncoding; # This is debatable
124 #$string = iconv($wgInputEncoding, "UTF-8", $string);
125 $string = preg_replace ( '/&#([0-9]+);/e', 'wfUtf8Sequence($1)', $string );
126 $string = preg_replace ( '/&#x([0-9a-f]+);/ie', 'wfUtf8Sequence(0x$1)', $string );
127 # Should also do named entities here
128 return $string;
129 }
130
131 function wfDebug( $text, $logonly = false )
132 {
133 global $wgOut, $wgDebugLogFile, $wgDebugComments;
134
135 if ( $wgDebugComments && !$logonly ) {
136 $wgOut->debug( $text );
137 }
138 if ( "" != $wgDebugLogFile ) {
139 error_log( $text, 3, $wgDebugLogFile );
140 }
141 }
142
143 if( !isset( $wgProfiling ) )
144 $wgProfiling = false;
145 $wgProfileStack = array();
146 $wgProfileWorkStack = array();
147
148 if( $wgProfiling ) {
149 function wfProfileIn( $functionname )
150 {
151 global $wgProfileStack, $wgProfileWorkStack;
152 array_push( $wgProfileWorkStack, "$functionname " .
153 count( $wgProfileWorkStack ) . " " . microtime() );
154 }
155
156 function wfProfileOut() {
157 global $wgProfileStack, $wgProfileWorkStack;
158 $bit = array_pop( $wgProfileWorkStack );
159 $bit .= " " . microtime();
160 array_push( $wgProfileStack, $bit );
161 }
162 } else {
163 function wfProfileIn( $functionname ) { }
164 function wfProfileOut( ) { }
165 }
166
167 function wfReadOnly()
168 {
169 global $wgReadOnlyFile;
170
171 if ( "" == $wgReadOnlyFile ) { return false; }
172 return is_file( $wgReadOnlyFile );
173 }
174
175 $wgReplacementKeys = array( "$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9" );
176
177 function wfMsg( $key ) {
178 $args = func_get_args();
179 if ( count( $args ) ) {
180 array_shift( $args );
181 }
182 return wfMsgReal( $key, $args, true );
183 }
184
185 function wfMsgNoDB( $key ) {
186 $args = func_get_args();
187 if ( count( $args ) ) {
188 array_shift( $args );
189 }
190 return wfMsgReal( $key, $args, false );
191 }
192
193 function wfMsgReal( $key, $args, $useDB ) {
194 global $wgLang, $wgReplacementKeys, $wgMemc, $wgDBname;
195 global $wgUseDatabaseMessages;
196
197 static $l1cache = array();
198 $fname = "wfMsg";
199 $message = false;
200 $l1hit = false;
201
202 # Check for DB suppression
203 if ( !$wgUseDatabaseMessages || !$useDB ) {
204 $message = $wgLang->getMessage( $key );
205 }
206
207 # Try L1 cache
208 if ( $message === false && array_key_exists( $key, $l1cache ) ) {
209 $message = $l1cache[$key];
210 if ( $message === false ) {
211 $message = $wgLang->getMessage( $key );
212 }
213 $l1hit = true;
214 }
215
216 # Try memcached
217 if ( $message === false ) {
218 $titleObj = Title::newFromText( $key );
219 $title = $titleObj->getDBkey();
220 $mcKey = "$wgDBname:MediaWiki:title:$title";
221 $message = $wgMemc->get( $mcKey );
222 }
223
224 # Try database
225 if ( $message === false) {
226 if ( $useDB ) {
227 $sql = "SELECT cur_text FROM cur WHERE cur_namespace=" . NS_MEDIAWIKI .
228 " AND cur_title='$title'";
229 $res = wfQuery( $sql, DB_READ, $fname );
230
231 if ( wfNumRows( $res ) ) {
232 # Got it from the database, now store in MemCached
233 $obj = wfFetchObject( $res );
234 $message = $obj->cur_text;
235 wfFreeResult( $res );
236 $wgMemc->set( $key, $message, time() + 1800 );
237 }
238 }
239 }
240
241 # Finally, try the array in $wgLang
242 if ( $message === false ) {
243 $message = $wgLang->getMessage( $key );
244 $l1cache[$key] = false;
245 } elseif ( !$l1hit && $wgUseDatabaseMessages) {
246 $l1cache[$key] = $message;
247 }
248
249 # Replace arguments
250 if( count( $args ) ) {
251 $message = str_replace( $wgReplacementKeys, $args, $message );
252 }
253
254 if ( "" == $message ) {
255 # Let's at least _try_ to be graceful about this.
256 return "&lt;$key&gt;";
257 }
258 return $message;
259 }
260
261 function wfCleanFormFields( $fields )
262 {
263 global $HTTP_POST_VARS;
264 global $wgInputEncoding, $wgOutputEncoding, $wgEditEncoding, $wgLang;
265
266 if ( get_magic_quotes_gpc() ) {
267 foreach ( $fields as $fname ) {
268 if ( isset( $HTTP_POST_VARS[$fname] ) ) {
269 $HTTP_POST_VARS[$fname] = stripslashes(
270 $HTTP_POST_VARS[$fname] );
271 }
272 global ${$fname};
273 if ( isset( ${$fname} ) ) {
274 ${$fname} = stripslashes( ${$fname} );
275 }
276 }
277 }
278 $enc = $wgOutputEncoding;
279 if( $wgEditEncoding != "") $enc = $wgEditEncoding;
280 if ( $enc != $wgInputEncoding ) {
281 foreach ( $fields as $fname ) {
282 if ( isset( $HTTP_POST_VARS[$fname] ) ) {
283 $HTTP_POST_VARS[$fname] = $wgLang->iconv(
284 $wgOutputEncoding, $wgInputEncoding,
285 $HTTP_POST_VARS[$fname] );
286 }
287 global ${$fname};
288 if ( isset( ${$fname} ) ) {
289 ${$fname} = $wgLang->iconv(
290 $enc, $wgInputEncoding, ${$fname} );
291 }
292 }
293 }
294 }
295
296 function wfMungeQuotes( $in )
297 {
298 $out = str_replace( "%", "%25", $in );
299 $out = str_replace( "'", "%27", $out );
300 $out = str_replace( "\"", "%22", $out );
301 return $out;
302 }
303
304 function wfDemungeQuotes( $in )
305 {
306 $out = str_replace( "%22", "\"", $in );
307 $out = str_replace( "%27", "'", $out );
308 $out = str_replace( "%25", "%", $out );
309 return $out;
310 }
311
312 function wfCleanQueryVar( $var )
313 {
314 global $wgLang;
315 if ( get_magic_quotes_gpc() ) {
316 $var = stripslashes( $var );
317 }
318 return $wgLang->recodeInput( $var );
319 }
320
321 function wfSpecialPage()
322 {
323 global $wgUser, $wgOut, $wgTitle, $wgLang;
324
325 /* FIXME: this list probably shouldn't be language-specific, per se */
326 $validSP = $wgLang->getValidSpecialPages();
327 $sysopSP = $wgLang->getSysopSpecialPages();
328 $devSP = $wgLang->getDeveloperSpecialPages();
329
330 $wgOut->setArticleFlag( false );
331 $wgOut->setRobotpolicy( "noindex,follow" );
332
333 $par = NULL;
334 list($t, $par) = split( "/", $wgTitle->getDBkey(), 2 );
335
336 if ( array_key_exists( $t, $validSP ) ||
337 ( $wgUser->isSysop() && array_key_exists( $t, $sysopSP ) ) ||
338 ( $wgUser->isDeveloper() && array_key_exists( $t, $devSP ) ) ) {
339 if($par !== NULL)
340 $wgTitle = Title::makeTitle( Namespace::getSpecial(), $t );
341
342 $wgOut->setPageTitle( wfMsg( strtolower( $wgTitle->getText() ) ) );
343
344 $inc = "Special" . $t . ".php";
345 include_once( $inc );
346 $call = "wfSpecial" . $t;
347 $call( $par );
348 } else if ( array_key_exists( $t, $sysopSP ) ) {
349 $wgOut->sysopRequired();
350 } else if ( array_key_exists( $t, $devSP ) ) {
351 $wgOut->developerRequired();
352 } else {
353 $wgOut->errorpage( "nosuchspecialpage", "nospecialpagetext" );
354 }
355 }
356
357 function wfSearch( $s )
358 {
359 $se = new SearchEngine( wfCleanQueryVar( $s ) );
360 $se->showResults();
361 }
362
363 function wfGo( $s )
364 { # pick the nearest match
365 $se = new SearchEngine( wfCleanQueryVar( $s ) );
366 $se->goResult();
367 }
368
369 function wfNumberOfArticles()
370 {
371 global $wgNumberOfArticles;
372
373 wfLoadSiteStats();
374 return $wgNumberOfArticles;
375 }
376
377 /* private */ function wfLoadSiteStats()
378 {
379 global $wgNumberOfArticles, $wgTotalViews, $wgTotalEdits;
380 if ( -1 != $wgNumberOfArticles ) return;
381
382 $sql = "SELECT ss_total_views, ss_total_edits, ss_good_articles " .
383 "FROM site_stats WHERE ss_row_id=1";
384 $res = wfQuery( $sql, DB_READ, "wfLoadSiteStats" );
385
386 if ( 0 == wfNumRows( $res ) ) { return; }
387 else {
388 $s = wfFetchObject( $res );
389 $wgTotalViews = $s->ss_total_views;
390 $wgTotalEdits = $s->ss_total_edits;
391 $wgNumberOfArticles = $s->ss_good_articles;
392 }
393 }
394
395 function wfEscapeHTML( $in )
396 {
397 return str_replace(
398 array( "&", "\"", ">", "<" ),
399 array( "&amp;", "&quot;", "&gt;", "&lt;" ),
400 $in );
401 }
402
403 function wfEscapeHTMLTagsOnly( $in ) {
404 return str_replace(
405 array( "\"", ">", "<" ),
406 array( "&quot;", "&gt;", "&lt;" ),
407 $in );
408 }
409
410 function wfUnescapeHTML( $in )
411 {
412 $in = str_replace( "&lt;", "<", $in );
413 $in = str_replace( "&gt;", ">", $in );
414 $in = str_replace( "&quot;", "\"", $in );
415 $in = str_replace( "&amp;", "&", $in );
416 return $in;
417 }
418
419 function wfImageDir( $fname )
420 {
421 global $wgUploadDirectory;
422
423 $hash = md5( $fname );
424 $oldumask = umask(0);
425 $dest = $wgUploadDirectory . "/" . $hash{0};
426 if ( ! is_dir( $dest ) ) { mkdir( $dest, 0777 ); }
427 $dest .= "/" . substr( $hash, 0, 2 );
428 if ( ! is_dir( $dest ) ) { mkdir( $dest, 0777 ); }
429
430 umask( $oldumask );
431 return $dest;
432 }
433
434 function wfImageArchiveDir( $fname )
435 {
436 global $wgUploadDirectory;
437
438 $hash = md5( $fname );
439 $oldumask = umask(0);
440 $archive = "{$wgUploadDirectory}/archive";
441 if ( ! is_dir( $archive ) ) { mkdir( $archive, 0777 ); }
442 $archive .= "/" . $hash{0};
443 if ( ! is_dir( $archive ) ) { mkdir( $archive, 0777 ); }
444 $archive .= "/" . substr( $hash, 0, 2 );
445 if ( ! is_dir( $archive ) ) { mkdir( $archive, 0777 ); }
446
447 umask( $oldumask );
448 return $archive;
449 }
450
451 function wfRecordUpload( $name, $oldver, $size, $desc )
452 {
453 global $wgUser, $wgLang, $wgTitle, $wgOut, $wgDeferredUpdateList;
454 global $wgUseCopyrightUpload , $wpUploadCopyStatus , $wpUploadSource ;
455
456 $fname = "wfRecordUpload";
457
458 $sql = "SELECT img_name,img_size,img_timestamp,img_description,img_user," .
459 "img_user_text FROM image WHERE img_name='" . wfStrencode( $name ) . "'";
460 $res = wfQuery( $sql, DB_READ, $fname );
461
462 $now = wfTimestampNow();
463 $won = wfInvertTimestamp( $now );
464
465 if ( $wgUseCopyrightUpload )
466 {
467 $textdesc = "== " . wfMsg ( "filedesc" ) . " ==\n" . $desc . "\n" .
468 "== " . wfMsg ( "filestatus" ) . " ==\n" . $wpUploadCopyStatus . "\n" .
469 "== " . wfMsg ( "filesource" ) . " ==\n" . $wpUploadSource ;
470 }
471 else $textdesc = $desc ;
472
473 if ( 0 == wfNumRows( $res ) ) {
474 $sql = "INSERT INTO image (img_name,img_size,img_timestamp," .
475 "img_description,img_user,img_user_text) VALUES ('" .
476 wfStrencode( $name ) . "',{$size},'{$now}','" .
477 wfStrencode( $desc ) . "', '" . $wgUser->getID() .
478 "', '" . wfStrencode( $wgUser->getName() ) . "')";
479 wfQuery( $sql, DB_WRITE, $fname );
480
481 $sql = "SELECT cur_id,cur_text FROM cur WHERE cur_namespace=" .
482 Namespace::getImage() . " AND cur_title='" .
483 wfStrencode( $name ) . "'";
484 $res = wfQuery( $sql, DB_READ, $fname );
485 if ( 0 == wfNumRows( $res ) ) {
486 $common =
487 Namespace::getImage() . ",'" .
488 wfStrencode( $name ) . "','" .
489 wfStrencode( $desc ) . "','" . $wgUser->getID() . "','" .
490 wfStrencode( $wgUser->getName() ) . "','" . $now .
491 "',1";
492 $sql = "INSERT INTO cur (cur_namespace,cur_title," .
493 "cur_comment,cur_user,cur_user_text,cur_timestamp,cur_is_new," .
494 "cur_text,inverse_timestamp,cur_touched) VALUES (" .
495 $common .
496 ",'" . wfStrencode( $textdesc ) . "','{$won}','{$now}')";
497 wfQuery( $sql, DB_WRITE, $fname );
498 $id = wfInsertId() or 0; # We should throw an error instead
499 $sql = "INSERT INTO recentchanges (rc_namespace,rc_title,
500 rc_comment,rc_user,rc_user_text,rc_timestamp,rc_new,
501 rc_cur_id,rc_cur_time) VALUES ({$common},{$id},'{$now}')";
502 wfQuery( $sql, DB_WRITE, $fname );
503 $u = new SearchUpdate( $id, $name, $desc );
504 $u->doUpdate();
505 }
506 } else {
507 $s = wfFetchObject( $res );
508
509 $sql = "INSERT INTO oldimage (oi_name,oi_archive_name,oi_size," .
510 "oi_timestamp,oi_description,oi_user,oi_user_text) VALUES ('" .
511 wfStrencode( $s->img_name ) . "','" .
512 wfStrencode( $oldver ) .
513 "',{$s->img_size},'{$s->img_timestamp}','" .
514 wfStrencode( $s->img_description ) . "','" .
515 wfStrencode( $s->img_user ) . "','" .
516 wfStrencode( $s->img_user_text) . "')";
517 wfQuery( $sql, DB_WRITE, $fname );
518
519 $sql = "UPDATE image SET img_size={$size}," .
520 "img_timestamp='" . wfTimestampNow() . "',img_user='" .
521 $wgUser->getID() . "',img_user_text='" .
522 wfStrencode( $wgUser->getName() ) . "', img_description='" .
523 wfStrencode( $desc ) . "' WHERE img_name='" .
524 wfStrencode( $name ) . "'";
525 wfQuery( $sql, DB_WRITE, $fname );
526
527 $sql = "UPDATE cur SET cur_touched='{$now}' WHERE cur_namespace=" .
528 Namespace::getImage() . " AND cur_title='" .
529 wfStrencode( $name ) . "'";
530 wfQuery( $sql, DB_WRITE, $fname );
531 }
532
533 $log = new LogPage( wfMsg( "uploadlogpage" ), wfMsg( "uploadlogpagetext" ) );
534 $da = str_replace( "$1", "[[:" . $wgLang->getNsText(
535 Namespace::getImage() ) . ":{$name}|{$name}]]",
536 wfMsg( "uploadedimage" ) );
537 $ta = str_replace( "$1", $name, wfMsg( "uploadedimage" ) );
538 $log->addEntry( $da, $desc, $ta );
539 }
540
541
542 /* Some generic result counters, pulled out of SearchEngine */
543
544 function wfShowingResults( $offset, $limit )
545 {
546 $top = str_replace( "$1", $limit, wfMsg( "showingresults" ) );
547 $top = str_replace( "$2", $offset+1, $top );
548 return $top;
549 }
550
551 function wfShowingResultsNum( $offset, $limit, $num )
552 {
553 $top = str_replace( "$1", $limit, wfMsg( "showingresultsnum" ) );
554 $top = str_replace( "$2", $offset+1, $top );
555 $top = str_replace( "$3", $num, $top );
556 return $top;
557 }
558
559 function wfViewPrevNext( $offset, $limit, $link, $query = "" )
560 {
561 global $wgUser;
562 $prev = str_replace( "$1", $limit, wfMsg( "prevn" ) );
563 $next = str_replace( "$1", $limit, wfMsg( "nextn" ) );
564
565 $sk = $wgUser->getSkin();
566 if ( 0 != $offset ) {
567 $po = $offset - $limit;
568 if ( $po < 0 ) { $po = 0; }
569 $q = "limit={$limit}&offset={$po}";
570 if ( "" != $query ) { $q .= "&{$query}"; }
571 $plink = "<a href=\"" . wfLocalUrlE( $link, $q ) . "\">{$prev}</a>";
572 } else { $plink = $prev; }
573
574 $no = $offset + $limit;
575 $q = "limit={$limit}&offset={$no}";
576 if ( "" != $query ) { $q .= "&{$query}"; }
577
578 $nlink = "<a href=\"" . wfLocalUrlE( $link, $q ) . "\">{$next}</a>";
579 $nums = wfNumLink( $offset, 20, $link , $query ) . " | " .
580 wfNumLink( $offset, 50, $link, $query ) . " | " .
581 wfNumLink( $offset, 100, $link, $query ) . " | " .
582 wfNumLink( $offset, 250, $link, $query ) . " | " .
583 wfNumLink( $offset, 500, $link, $query );
584
585 $sl = str_replace( "$1", $plink, wfMsg( "viewprevnext" ) );
586 $sl = str_replace( "$2", $nlink, $sl );
587 $sl = str_replace( "$3", $nums, $sl );
588 return $sl;
589 }
590
591 function wfNumLink( $offset, $limit, $link, $query = "" )
592 {
593 global $wgUser;
594 if ( "" == $query ) { $q = ""; }
595 else { $q = "{$query}&"; }
596 $q .= "limit={$limit}&offset={$offset}";
597
598 $s = "<a href=\"" . wfLocalUrlE( $link, $q ) . "\">{$limit}</a>";
599 return $s;
600 }
601
602 function wfClientAcceptsGzip() {
603 global $wgUseGzip;
604 if( $wgUseGzip ) {
605 # FIXME: we may want to blacklist some broken browsers
606 if( preg_match(
607 '/\bgzip(?:;(q)=([0-9]+(?:\.[0-9]+)))?\b/',
608 $_SERVER["HTTP_ACCEPT_ENCODING"],
609 $m ) ) {
610 if( ( $m[1] == "q" ) && ( $m[2] == 0 ) ) return false;
611 wfDebug( " accepts gzip\n" );
612 return true;
613 }
614 }
615 return false;
616 }
617
618 # Yay, more global functions!
619 function wfCheckLimits( $deflimit = 50, $optionname = "rclimit" ) {
620 global $wgUser;
621
622 $limit = (int)$_REQUEST['limit'];
623 if( $limit < 0 ) $limit = 0;
624 if( ( $limit == 0 ) && ( $optionname != "" ) ) {
625 $limit = (int)$wgUser->getOption( $optionname );
626 }
627 if( $limit <= 0 ) $limit = $deflimit;
628 if( $limit > 5000 ) $limit = 5000; # We have *some* limits...
629
630 $offset = (int)$_REQUEST['offset'];
631 $offset = (int)$offset;
632 if( $offset < 0 ) $offset = 0;
633 if( $offset > 65000 ) $offset = 65000; # do we need a max? what?
634
635 return array( $limit, $offset );
636 }
637
638 # Used in OutputPage::replaceVariables and Article:pstPass2
639 function replaceMsgVar( $matches ) {
640 return wfMsg( $matches[1] );
641 }
642
643 function replaceMsgVarNw( $matches ) {
644 $text = htmlspecialchars( wfMsg( $matches[1] ) );
645 return $text;
646 }
647
648 ?>