appendQuery() and escapeAppendQuery() to WebRequest.
# To add an http-equiv meta tag, precede the name with "http:"
function addMeta( $name, $val ) { array_push( $this->mMetatags, array( $name, $val ) ); }
function addKeyword( $text ) { array_push( $this->mKeywords, $text ); }
- function addLink( $rel, $rev, $target ) { array_push( $this->mLinktags, array( $rel, $rev, $target ) ); }
+ function addLink( $rel, $rev, $target, $type="" ) { array_push( $this->mLinktags, array( $rel, $rev, $target, $type ) ); }
# checkLastModified tells the client to use the client-cached page if
# possible. If sucessful, the OutputPage is disabled so that
/* private */ function headElement()
{
- global $wgDocType, $wgDTD, $wgUser, $wgLanguageCode, $wgOutputEncoding, $wgLang;
+ global $wgDocType, $wgDTD, $wgUser, $wgLanguageCode, $wgOutputEncoding, $wgLang, $wgRequest;
$ret = "<!DOCTYPE HTML PUBLIC \"$wgDocType\"\n \"$wgDTD\">\n";
$ret .= "<link ";
if ( "" != $tag[0] ) { $ret .= "rel=\"{$tag[0]}\" "; }
if ( "" != $tag[1] ) { $ret .= "rev=\"{$tag[1]}\" "; }
+ if ( !empty( $tag[3] ) ) { $ret .= "type=\"{$tag[3]}\" "; }
$ret .= "href=\"{$tag[2]}\">\n";
}
+ if( $this->isSyndicated() ) {
+ $link = $wgRequest->escapeAppendQuery( "feed=rss" );
+ $ret .= "<link rel='alternate' type='application/rss+xml' title='RSS' href='$link'>\n";
+ }
$sk = $wgUser->getSkin();
$ret .= $sk->getHeadScripts();
$ret .= $sk->getUserStyles();
function printableLink()
{
- global $wgOut, $wgFeedClasses;
+ global $wgOut, $wgFeedClasses, $wgRequest;
$baseurl = $_SERVER['REQUEST_URI'];
if( strpos( "?", $baseurl ) == false ) {
$baseurl .= "&";
}
$baseurl = htmlspecialchars( $baseurl );
+ $printurl = $wgRequest->escapeAppendQuery( "printable=yes" );
- $s = "<a href=\"{$baseurl}printable=yes\">" . wfMsg( "printableversion" ) . "</a>";
+ $s = "<a href=\"$printurl\">" . wfMsg( "printableversion" ) . "</a>";
if( $wgOut->isSyndicated() ) {
foreach( $wgFeedClasses as $format => $class ) {
- $s .= " | <a href=\"{$baseurl}feed={$format}\">{$format}</a>";
+ $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
+ $s .= " | <a href=\"$feedurl\">{$format}</a>";
}
}
return $s;
<?php
+# Copyright (C) 2003 Brion Vibber <brion@pobox.com>
+# http://www.mediawiki.org/
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+# http://www.gnu.org/copyleft/gpl.html
# And turn on $wgUseSmarty so this file gets included
<?php
+# Deal with importing all those nasssty globals and things
+#
+# Copyright (C) 2003 Brion Vibber <brion@pobox.com>
+# http://www.mediawiki.org/
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+# http://www.gnu.org/copyleft/gpl.html
# Hypothetically, we could use a WebRequest object to fake a
# self-contained request.
## Enable this to debug total elimination of register_globals
#define( "DEBUG_GLOBALS", 1 );
-# Deal with importing all those nasssty globals and things
class WebRequest {
function WebRequest() {
if( defined('DEBUG_GLOBALS') ) error_reporting(E_ALL);
function checkSessionCookie() {
return isset( $_COOKIE[ini_get("session.name")] );
}
+
+ function getRequestURL() {
+ return $_SERVER['REQUEST_URI'];
+ }
+
+ function getFullRequestURL() {
+ global $wgServer;
+ return $wgServer . $this->getRequestURL();
+ }
+
+ # Take an arbitrary query and rewrite the present URL to include it
+ function appendQuery( $query ) {
+ global $wgTitle;
+ $basequery = "";
+ foreach( $_GET as $var => $val ) {
+ if( $var == "title" ) continue;
+ $basequery .= "&" . urlencode( $var ) . "=" . urlencode( $val );
+ }
+ $basequery .= "&" . $query;
+
+ # Trim the extra &
+ $basequery = substr( $basequery, 1 );
+ return $wgTitle->getLocalURL( $basequery );
+ }
+
+ function escapeAppendQuery( $query ) {
+ return htmlspecialchars( $this->appendQuery( $query ) );
+ }
+
}
?>
\ No newline at end of file