Index: trunk/phase3/includes/OutputPage.php |
— | — | @@ -1357,8 +1357,8 @@ |
1358 | 1358 | } |
1359 | 1359 | $ret .= "xml:lang=\"$wgContLanguageCode\" lang=\"$wgContLanguageCode\" $rtl>\n"; |
1360 | 1360 | $ret .= "<head>\n<title>" . htmlspecialchars( $this->getHTMLTitle() ) . "</title>\n"; |
1361 | | - array_push( $this->mMetatags, array( "http:Content-type", "$wgMimeType; charset={$wgOutputEncoding}" ) ); |
1362 | | - |
| 1361 | + $this->addMeta( "http:Content-type", "$wgMimeType; charset={$wgOutputEncoding}" ); |
| 1362 | + |
1363 | 1363 | $ret .= $this->getHeadLinks(); |
1364 | 1364 | global $wgStylePath; |
1365 | 1365 | if( $this->isPrintable() ) { |
— | — | @@ -1381,13 +1381,38 @@ |
1382 | 1382 | $ret .= "</head>\n"; |
1383 | 1383 | return $ret; |
1384 | 1384 | } |
| 1385 | + |
| 1386 | + protected function addDefaultMeta() { |
| 1387 | + global $wgVersion; |
| 1388 | + $this->addMeta( "generator", "MediaWiki $wgVersion" ); |
| 1389 | + |
| 1390 | + $p = $this->mRobotpolicy; |
| 1391 | + if( $p !== '' && $p != 'index,follow' ) { |
| 1392 | + // http://www.robotstxt.org/wc/meta-user.html |
| 1393 | + // Only show if it's different from the default robots policy |
| 1394 | + $this->addMeta( 'robots', $p ); |
| 1395 | + } |
1385 | 1396 | |
| 1397 | + if ( count( $this->mKeywords ) > 0 ) { |
| 1398 | + $strip = array( |
| 1399 | + "/<.*?>/" => '', |
| 1400 | + "/_/" => ' ' |
| 1401 | + ); |
| 1402 | + $this->addMeta( 'keywords', preg_replace(array_keys($strip), array_values($strip),implode( ",", $this->mKeywords ) ) ); |
| 1403 | + } |
| 1404 | + } |
| 1405 | + |
1386 | 1406 | /** |
1387 | 1407 | * @return string HTML tag links to be put in the header. |
1388 | 1408 | */ |
1389 | 1409 | public function getHeadLinks() { |
1390 | | - global $wgRequest, $wgFeed, $wgVersion; |
1391 | | - $ret = "<meta name=\"generator\" content=\"MediaWiki " . $wgVersion . "\" />\n"; |
| 1410 | + global $wgRequest, $wgFeed; |
| 1411 | + |
| 1412 | + // Ideally this should happen earlier, somewhere. :P |
| 1413 | + $this->addDefaultMeta(); |
| 1414 | + |
| 1415 | + $tags = array(); |
| 1416 | + |
1392 | 1417 | foreach ( $this->mMetatags as $tag ) { |
1393 | 1418 | if ( 0 == strcasecmp( 'http:', substr( $tag[0], 0, 5 ) ) ) { |
1394 | 1419 | $a = 'http-equiv'; |
— | — | @@ -1395,30 +1420,13 @@ |
1396 | 1421 | } else { |
1397 | 1422 | $a = 'name'; |
1398 | 1423 | } |
1399 | | - $ret .= "<meta $a=\"{$tag[0]}\" content=\"{$tag[1]}\" />\n"; |
| 1424 | + $tags[] = Xml::element( 'meta', |
| 1425 | + array( |
| 1426 | + $a => $tag[0], |
| 1427 | + 'content' => $tag[1] ) ); |
1400 | 1428 | } |
1401 | | - |
1402 | | - $p = $this->mRobotpolicy; |
1403 | | - if( $p !== '' && $p != 'index,follow' ) { |
1404 | | - // http://www.robotstxt.org/wc/meta-user.html |
1405 | | - // Only show if it's different from the default robots policy |
1406 | | - $ret .= "<meta name=\"robots\" content=\"$p\" />\n"; |
1407 | | - } |
1408 | | - |
1409 | | - if ( count( $this->mKeywords ) > 0 ) { |
1410 | | - $strip = array( |
1411 | | - "/<.*?>/" => '', |
1412 | | - "/_/" => ' ' |
1413 | | - ); |
1414 | | - $ret .= "\t\t<meta name=\"keywords\" content=\"" . |
1415 | | - htmlspecialchars(preg_replace(array_keys($strip), array_values($strip),implode( ",", $this->mKeywords ))) . "\" />\n"; |
1416 | | - } |
1417 | 1429 | foreach ( $this->mLinktags as $tag ) { |
1418 | | - $ret .= "\t\t<link"; |
1419 | | - foreach( $tag as $attr => $val ) { |
1420 | | - $ret .= " $attr=\"" . htmlspecialchars( $val ) . "\""; |
1421 | | - } |
1422 | | - $ret .= " />\n"; |
| 1430 | + $tags[] = Xml::element( 'link', $tag ); |
1423 | 1431 | } |
1424 | 1432 | |
1425 | 1433 | if( $wgFeed ) { |
— | — | @@ -1429,7 +1437,7 @@ |
1430 | 1438 | # with having the same name for different feeds corresponding to |
1431 | 1439 | # the same page, but we can't avoid that at this low a level. |
1432 | 1440 | |
1433 | | - $ret .= $this->feedLink( |
| 1441 | + $tags[] = $this->feedLink( |
1434 | 1442 | $format, |
1435 | 1443 | $link, |
1436 | 1444 | wfMsg( "page-{$format}-feed", $wgTitle->getPrefixedText() ) ); # Used messages: 'page-rss-feed' and 'page-atom-feed' (for an easier grep) |
— | — | @@ -1444,18 +1452,18 @@ |
1445 | 1453 | if ( $wgTitle->getPrefixedText() != $rctitle->getPrefixedText() ) { |
1446 | 1454 | global $wgSitename; |
1447 | 1455 | |
1448 | | - $ret .= $this->feedLink( |
| 1456 | + $tags[] = $this->feedLink( |
1449 | 1457 | 'rss', |
1450 | 1458 | $rctitle->getFullURL( 'feed=rss' ), |
1451 | 1459 | wfMsg( 'site-rss-feed', $wgSitename ) ); |
1452 | | - $ret .= $this->feedLink( |
| 1460 | + $tags[] = $this->feedLink( |
1453 | 1461 | 'atom', |
1454 | 1462 | $rctitle->getFullURL( 'feed=atom' ), |
1455 | 1463 | wfMsg( 'site-atom-feed', $wgSitename ) ); |
1456 | 1464 | } |
1457 | 1465 | } |
1458 | 1466 | |
1459 | | - return $ret; |
| 1467 | + return implode( "\n\t\t", $tags ) . "\n"; |
1460 | 1468 | } |
1461 | 1469 | |
1462 | 1470 | /** |
— | — | @@ -1488,7 +1496,7 @@ |
1489 | 1497 | 'rel' => 'alternate', |
1490 | 1498 | 'type' => "application/$type+xml", |
1491 | 1499 | 'title' => $text, |
1492 | | - 'href' => $url ) ) . "\n"; |
| 1500 | + 'href' => $url ) ); |
1493 | 1501 | } |
1494 | 1502 | |
1495 | 1503 | /** |