r2621 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r2620‎ | r2621 | r2622 >
Date:01:49, 6 March 2004
Author:timstarling
Status:old
Tags:
Comment:
* Fixed magic quotes in $_REQUEST, in Setup.php
* Converted many instances of globals from the query to $_REQUEST
* Renamed near-useless Title::getURL() to Title::getPartialURL()
* Created new Title::getURL(), to replace wfLocalUrl, wfLocalUrlE, wfFullUrl and wfFullUrlE. Replaced most instances throughout the code
* In Parser.php, generalised stripping of <nowiki>, <pre> and <math> to allow more general use such as nesting
* Moved body of Article::preSaveTransform to Parser.php
* Put lots of comments in Title.php
Modified paths:
  • /trunk/phase3/includes/Article.php (modified) (history)
  • /trunk/phase3/includes/Database.php (modified) (history)
  • /trunk/phase3/includes/EditPage.php (modified) (history)
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)
  • /trunk/phase3/includes/MagicWord.php (modified) (history)
  • /trunk/phase3/includes/Namespace.php (modified) (history)
  • /trunk/phase3/includes/OutputPage.php (modified) (history)
  • /trunk/phase3/includes/PageHistory.php (modified) (history)
  • /trunk/phase3/includes/Parser.php (modified) (history)
  • /trunk/phase3/includes/SearchEngine.php (modified) (history)
  • /trunk/phase3/includes/Setup.php (modified) (history)
  • /trunk/phase3/includes/Skin.php (modified) (history)
  • /trunk/phase3/includes/SkinCologneBlue.php (modified) (history)
  • /trunk/phase3/includes/SkinSmarty.php (modified) (history)
  • /trunk/phase3/includes/SpecialAsksql.php (modified) (history)
  • /trunk/phase3/includes/SpecialBlockip.php (modified) (history)
  • /trunk/phase3/includes/SpecialEmailuser.php (modified) (history)
  • /trunk/phase3/includes/SpecialExport.php (modified) (history)
  • /trunk/phase3/includes/SpecialImagelist.php (modified) (history)
  • /trunk/phase3/includes/SpecialIpblocklist.php (modified) (history)
  • /trunk/phase3/includes/SpecialLockdb.php (modified) (history)
  • /trunk/phase3/includes/SpecialMakesysop.php (modified) (history)
  • /trunk/phase3/includes/SpecialMovepage.php (modified) (history)
  • /trunk/phase3/includes/SpecialPreferences.php (modified) (history)
  • /trunk/phase3/includes/SpecialUndelete.php (modified) (history)
  • /trunk/phase3/includes/SpecialUnlockdb.php (modified) (history)
  • /trunk/phase3/includes/SpecialUpload.php (modified) (history)
  • /trunk/phase3/includes/SpecialUserlogin.php (modified) (history)
  • /trunk/phase3/includes/SpecialWatchlist.php (modified) (history)
  • /trunk/phase3/includes/SpecialWhatlinkshere.php (modified) (history)
  • /trunk/phase3/includes/SquidUpdate.php (modified) (history)
  • /trunk/phase3/includes/Title.php (modified) (history)
  • /trunk/phase3/index.php (modified) (history)

Diff [purge]

Index: trunk/phase3/index.php
@@ -25,22 +25,25 @@
2626
2727 # Query string fields
2828 #
29 -global $action, $title, $search, $go, $target, $printable;
30 -global $returnto, $diff, $oldid, $curid;
 29+#global $action, $title, $search, $go, $target, $printable;
 30+#global $returnto, $diff, $oldid, $curid;
3131
 32+$action = $_REQUEST['action'];
 33+$title = $_REQUEST['title'];
 34+
3235 # Placeholders in case of DB error
3336 $wgTitle = Title::newFromText( wfMsg( "badtitle" ) );
3437 $wgArticle = new Article($wgTitle);
3538
3639 $action = strtolower( trim( $action ) );
3740 if ( "" == $action ) { $action = "view"; }
38 -if ( "yes" == $printable ) { $wgOut->setPrintable(); }
 41+if ( "yes" == $_REQUEST['printable'] ) { $wgOut->setPrintable(); }
3942
4043 if ( "" == $title && "delete" != $action ) {
4144 $wgTitle = Title::newFromText( wfMsg( "mainpage" ) );
42 -} elseif ( $curid ) {
 45+} elseif ( $_REQUEST['curid'] ) {
4346 # URLs like this are generated by RC, because rc_title isn't always accurate
44 - $wgTitle = Title::newFromID( $curid );
 47+ $wgTitle = Title::newFromID( $_REQUEST['curid'] );
4548 } else {
4649 $wgTitle = Title::newFromURL( $title );
4750 }
@@ -56,11 +59,11 @@
5760 }
5861 }
5962
60 -if ( "" != $search ) {
 63+if ( "" != $_REQUEST['search'] ) {
6164 if( isset($_REQUEST['fulltext']) ) {
62 - wfSearch( $search );
 65+ wfSearch( $_REQUEST['search'] );
6366 } else {
64 - wfGo( $search );
 67+ wfGo( $_REQUEST['search'] );
6568 }
6669 } else if( !$wgTitle or $wgTitle->getInterwiki() != "" or $wgTitle->getDBkey() == "" ) {
6770 $wgTitle = Title::newFromText( wfMsg( "badtitle" ) );
Index: trunk/phase3/includes/SpecialUndelete.php
@@ -77,7 +77,8 @@
7878
7979 $wgOut->addWikiText( wfMsg( "undeletehistory" ) . "\n<hr>\n" . $row->ar_text );
8080
81 - $action = wfLocalUrlE( $wgLang->specialPage( "Undelete" ), "action=submit" );
 81+ $titleObj = Title::makeTitle( NS_SPECIAL, "Undelete" );
 82+ $action = $titleObj->getURL( "action=submit", true );
8283 $wgOut->addHTML("<p>
8384 <form id=\"undelete\" method=\"post\" action=\"{$action}\">
8485 <input type=hidden name=\"target\" value=\"{$target}\">
Index: trunk/phase3/includes/MagicWord.php
@@ -54,14 +54,14 @@
5555 # Preliminary initialisation
5656 /* private */ function initRegex()
5757 {
58 - $variableClass = "A-Za-z0-9_\-\x80-\xff";
 58+ $variableClass = Title::legalChars();
5959 $escSyn = array_map( "preg_quote", $this->mSynonyms );
6060 $this->mBaseRegex = implode( "|", $escSyn );
6161 $case = $this->mCaseSensitive ? "" : "i";
6262 $this->mRegex = "/{$this->mBaseRegex}/{$case}";
6363 $this->mRegexStart = "/^{$this->mBaseRegex}/{$case}";
64 - $this->mVariableRegex = str_replace( "\\$1", "([$variableClass]*)", $this->mRegex );
65 - $this->mVariableStartToEndRegex = str_replace( "\\$1", "([$variableClass]*)",
 64+ $this->mVariableRegex = str_replace( "\\$1", "([$variableClass]*?)", $this->mRegex );
 65+ $this->mVariableStartToEndRegex = str_replace( "\\$1", "([$variableClass]*?)",
6666 "/^{$this->mBaseRegex}$/{$case}" );
6767 }
6868
Index: trunk/phase3/includes/SpecialImagelist.php
@@ -48,8 +48,8 @@
4949 $sk = $wgUser->getSkin();
5050 $cap = wfMsg( "ilshowmatch" );
5151 $sub = wfMsg( "ilsubmit" );
52 - $action = wfLocalUrlE( $wgLang->specialPage( "Imagelist" ),
53 - "sort=byname&limit={$limit}" );
 52+ $titleObj = Title::makeTitle( NS_SPECIAL, "Imagelist" );
 53+ $action = $titleObj->getURL( "sort=byname&limit={$limit}", true );
5454
5555 $wgOut->addHTML( "<form id=\"imagesearch\" method=\"post\" action=\"" .
5656 "{$action}\">" .
Index: trunk/phase3/includes/SpecialIpblocklist.php
@@ -38,8 +38,8 @@
3939 $ipa = wfMsg( "ipaddress" );
4040 $ipr = wfMsg( "ipbreason" );
4141 $ipus = wfMsg( "ipusubmit" );
42 - $action = wfLocalUrlE( $wgLang->specialPage( "Ipblocklist" ),
43 - "action=submit" );
 42+ $titleObj = Title::makeTitle( NS_SPECIAL, "Ipblocklist" );
 43+ $action = $titleObj->getURL( "action=submit", true );
4444
4545 if ( "" != $err ) {
4646 $wgOut->setSubtitle( wfMsg( "formerror" ) );
@@ -87,8 +87,8 @@
8888 $log->addEntry( $action, $wpUnblockReason );
8989
9090 # Report to the user
91 - $success = wfLocalUrl( $wgLang->specialPage( "Ipblocklist" ),
92 - "action=success&ip=" . urlencode($wpUnblockAddress) );
 91+ $titleObj = Title::makeTitle( NS_SPECIAL, "Ipblocklist" );
 92+ $success = $titleObj->getURL( "action=success&ip=" . urlencode($wpUnblockAddress) );
9393 $wgOut->redirect( $success );
9494 }
9595
@@ -130,15 +130,16 @@
131131 $wgOut->addHTML( "<li>{$line}" );
132132
133133 if ( !$block->mAuto ) {
134 - $clink = "<a href=\"" . wfLocalUrlE( $wgLang->specialPage(
135 - "Contributions" ), "target={$block->mAddress}" ) . "\">" .
 134+ $titleObj = Title::makeTitle( NS_SPECIAL, "Contributions" );
 135+ $clink = "<a href=\"" . $titleObj->getURL( "target={$block->mAddress}", true ) . "\">" .
136136 wfMsg( "contribslink" ) . "</a>";
137137 $wgOut->addHTML( " ({$clink})" );
138138 }
139139
140140 if ( $wgUser->isSysop() ) {
141 - $ublink = "<a href=\"" . wfLocalUrlE( $wgLang->specialPage(
142 - "Ipblocklist" ), "action=unblock&ip=" . urlencode( $addr ) ) . "\">" .
 141+ $titleObj = Title::makeTitle( NS_SPECIAL, "Ipblocklist" );
 142+ $ublink = "<a href=\"" .
 143+ $titleObj->getURL( "action=unblock&ip=" . urlencode( $addr ), true ) . "\">" .
143144 wfMsg( "unblocklink" ) . "</a>";
144145 $wgOut->addHTML( " ({$ublink})" );
145146 }
Index: trunk/phase3/includes/Title.php
@@ -3,12 +3,31 @@
44
55 /* private static */ $title_interwiki_cache = array();
66
 7+# Title class
 8+#
 9+# * Represents a title, which may contain an interwiki designation or namespace
 10+# * Can fetch various kinds of data from the database, albeit inefficiently.
 11+#
712 class Title {
8 - /* private */ var $mTextform, $mUrlform, $mDbkeyform;
9 - /* private */ var $mNamespace, $mInterwiki, $mFragment;
10 - /* private */ var $mArticleID, $mRestrictions, $mRestrictionsLoaded;
11 - /* private */ var $mPrefixedText;
 13+ # All member variables should be considered private
 14+ # Please use the accessor functions
1215
 16+ var $mTextform; # Text form (spaces not underscores) of the main part
 17+ var $mUrlform; # URL-encoded form of the main part
 18+ var $mDbkeyform; # Main part with underscores
 19+ var $mNamespace; # Namespace index, i.e. one of the NS_xxxx constants
 20+ var $mInterwiki; # Interwiki prefix (or null string)
 21+ var $mFragment; # Title fragment (i.e. the bit after the #)
 22+ var $mArticleID; # Article ID, fetched from the link cache on demand
 23+ var $mRestrictions; # Array of groups allowed to edit this article
 24+ # Only null or "sysop" are supported
 25+ var $mRestrictionsLoaded; # Boolean for initialisation on demand
 26+ var $mPrefixedText; # Text form including namespace/interwiki, initialised on demand
 27+
 28+#----------------------------------------------------------------------------
 29+# Construction
 30+#----------------------------------------------------------------------------
 31+
1332 /* private */ function Title()
1433 {
1534 $this->mInterwiki = $this->mUrlform =
@@ -19,9 +38,8 @@
2039 $this->mRestrictions = array();
2140 }
2241
23 - # Static factory methods
24 - #
25 - function newFromDBkey( $key )
 42+ # From a prefixed DB key
 43+ /* static */ function newFromDBkey( $key )
2644 {
2745 $t = new Title();
2846 $t->mDbkeyform = $key;
@@ -31,7 +49,8 @@
3250 return NULL;
3351 }
3452
35 - function newFromText( $text )
 53+ # From text, such as what you would find in a link
 54+ /* static */ function newFromText( $text )
3655 {
3756 static $trans;
3857 $fname = "Title::newFromText";
@@ -51,7 +70,9 @@
5271
5372 $text = wfMungeToUtf8( $text );
5473
55 - $text = urldecode( $text );
 74+
 75+ # What was this for? TS 2004-03-03
 76+ # $text = urldecode( $text );
5677
5778 $t = new Title();
5879 $t->mDbkeyform = str_replace( " ", "_", $text );
@@ -63,23 +84,26 @@
6485 }
6586 }
6687
67 - function newFromURL( $url )
 88+ # From a URL-encoded title
 89+ /* static */ function newFromURL( $url )
6890 {
6991 global $wgLang, $wgServer;
70 -
7192 $t = new Title();
7293 $s = urldecode( $url ); # This is technically wrong, as anything
7394 # we've gotten is already decoded by PHP.
7495 # Kept for backwards compatibility with
7596 # buggy URLs we had for a while...
 97+ $s = $url;
7698
7799 # For links that came from outside, check for alternate/legacy
78100 # character encoding.
79101 wfDebug( "Refer: {$_SERVER['HTTP_REFERER']}\n" );
80102 wfDebug( "Servr: $wgServer\n" );
81103 if( empty( $_SERVER["HTTP_REFERER"] ) ||
82 - strncmp($wgServer, $_SERVER["HTTP_REFERER"], strlen( $wgServer ) ) )
 104+ strncmp($wgServer, $_SERVER["HTTP_REFERER"], strlen( $wgServer ) ) )
 105+ {
83106 $s = $wgLang->checkTitleEncoding( $s );
 107+ }
84108
85109 $t->mDbkeyform = str_replace( " ", "_", $s );
86110 if( $t->secureAndSplit() ) {
@@ -89,9 +113,10 @@
90114 }
91115 }
92116
93 - # Create a title from a cur id
94 - # This is inefficiently implemented
95 - function newFromID( $id )
 117+ # From a cur_id
 118+ # This is inefficiently implemented, the cur row is requested but not
 119+ # used for anything else
 120+ /* static */ function newFromID( $id )
96121 {
97122 $fname = "Title::newFromID";
98123 $row = wfGetArray( "cur", array( "cur_namespace", "cur_title" ),
@@ -103,9 +128,31 @@
104129 }
105130 return $title;
106131 }
 132+
 133+ # From a namespace index and a DB key
 134+ /* static */ function makeTitle( $ns, $title )
 135+ {
 136+ $t = new Title();
 137+ $t->mDbkeyform = Title::makeName( $ns, $title );
 138+ if( $t->secureAndSplit() ) {
 139+ return $t;
 140+ } else {
 141+ return NULL;
 142+ }
 143+ }
107144
108 - function nameOf( $id )
 145+ function newMainPage()
109146 {
 147+ return Title::newFromText( wfMsg( "mainpage" ) );
 148+ }
 149+
 150+#----------------------------------------------------------------------------
 151+# Static functions
 152+#----------------------------------------------------------------------------
 153+
 154+ # Get the prefixed DB key associated with an ID
 155+ /* static */ function nameOf( $id )
 156+ {
110157 $sql = "SELECT cur_namespace,cur_title FROM cur WHERE " .
111158 "cur_id={$id}";
112159 $res = wfQuery( $sql, DB_READ, "Article::nameOf" );
@@ -116,20 +163,56 @@
117164 return $n;
118165 }
119166
120 -
 167+ # Get a regex character class describing the legal characters in a link
121168 /* static */ function legalChars()
122169 {
123 - global $wgInputEncoding;
124 - if( $wgInputEncoding == "utf-8" ) {
125 - return "-,.()' &;%!?_0-9A-Za-z\\/:\\x80-\\xFF";
126 - } else {
127 - # ISO 8859-* don't allow 0x80-0x9F
128 - #return "-,.()' &;%!?_0-9A-Za-z\\/:\\xA0-\\xFF";
129 - # But that breaks interlanguage links at the moment. Temporary:
130 - return "-,.()' &;%!?_0-9A-Za-z\\/:\\x80-\\xFF";
 170+ # Missing characters:
 171+ # * []|# Needed for link syntax
 172+ # * % and + are corrupted by Apache when they appear in the path
 173+ #
 174+ # Theoretically 0x80-0x9F of ISO 8859-1 should be disallowed, but
 175+ # this breaks interlanguage links
 176+
 177+ $set = " !\"$&'()*,\\-.\\/0-9:;<=>?@A-Z\\\\^_`a-z{}~\\x80-\\xFF";
 178+ return $set;
 179+ }
 180+
 181+ # Returns a stripped-down a title string ready for the search index
 182+ # Takes a namespace index and a text-form main part
 183+ /* static */ function indexTitle( $ns, $title )
 184+ {
 185+ global $wgDBminWordLen, $wgLang;
 186+
 187+ $lc = SearchEngine::legalSearchChars() . "&#;";
 188+ $t = $wgLang->stripForSearch( $title );
 189+ $t = preg_replace( "/[^{$lc}]+/", " ", $t );
 190+ $t = strtolower( $t );
 191+
 192+ # Handle 's, s'
 193+ $t = preg_replace( "/([{$lc}]+)'s( |$)/", "\\1 \\1's ", $t );
 194+ $t = preg_replace( "/([{$lc}]+)s'( |$)/", "\\1s ", $t );
 195+
 196+ $t = preg_replace( "/\\s+/", " ", $t );
 197+
 198+ if ( $ns == Namespace::getImage() ) {
 199+ $t = preg_replace( "/ (png|gif|jpg|jpeg|ogg)$/", "", $t );
131200 }
 201+ return trim( $t );
132202 }
 203+
 204+ # Make a prefixed DB key from a DB key and a namespace index
 205+ /* static */ function makeName( $ns, $title )
 206+ {
 207+ global $wgLang;
133208
 209+ $n = $wgLang->getNsText( $ns );
 210+ if ( "" == $n ) { return $title; }
 211+ else { return "{$n}:{$title}"; }
 212+ }
 213+
 214+ # Arguably static
 215+ # Returns the URL associated with an interwiki prefix
 216+ # The URL contains $1, which is replaced by the title
134217 function getInterwikiLink( $key )
135218 {
136219 global $wgMemc, $wgDBname, $title_interwiki_cache;
@@ -157,61 +240,29 @@
158241 $title_interwiki_cache[$k] = $s;
159242 return $s->iw_url;
160243 }
 244+
 245+#----------------------------------------------------------------------------
 246+# Other stuff
 247+#----------------------------------------------------------------------------
161248
 249+ # Simple accessors
 250+ # See the definitions at the top of this file
 251+
162252 function getText() { return $this->mTextform; }
163 - function getURL() { return $this->mUrlform; }
 253+ function getPartialURL() { return $this->mUrlform; }
164254 function getDBkey() { return $this->mDbkeyform; }
165255 function getNamespace() { return $this->mNamespace; }
166256 function setNamespace( $n ) { $this->mNamespace = $n; }
167257 function getInterwiki() { return $this->mInterwiki; }
168258 function getFragment() { return $this->mFragment; }
169259
170 - /* static */ function indexTitle( $ns, $title )
171 - {
172 - global $wgDBminWordLen, $wgLang;
173 -
174 - $lc = SearchEngine::legalSearchChars() . "&#;";
175 - $t = $wgLang->stripForSearch( $title );
176 - $t = preg_replace( "/[^{$lc}]+/", " ", $t );
177 - $t = strtolower( $t );
178 -
179 - # Handle 's, s'
180 - $t = preg_replace( "/([{$lc}]+)'s( |$)/", "\\1 \\1's ", $t );
181 - $t = preg_replace( "/([{$lc}]+)s'( |$)/", "\\1s ", $t );
182 -
183 - $t = preg_replace( "/\\s+/", " ", $t );
184 -
185 - if ( $ns == Namespace::getImage() ) {
186 - $t = preg_replace( "/ (png|gif|jpg|jpeg|ogg)$/", "", $t );
187 - }
188 - return trim( $t );
189 - }
190 -
 260+ # Get title for search index
191261 function getIndexTitle()
192262 {
193263 return Title::indexTitle( $this->mNamespace, $this->mTextform );
194264 }
195265
196 - /* static */ function makeName( $ns, $title )
197 - {
198 - global $wgLang;
199 -
200 - $n = $wgLang->getNsText( $ns );
201 - if ( "" == $n ) { return $title; }
202 - else { return "{$n}:{$title}"; }
203 - }
204 -
205 - /* static */ function makeTitle( $ns, $title )
206 - {
207 - $t = new Title();
208 - $t->mDbkeyform = Title::makeName( $ns, $title );
209 - if( $t->secureAndSplit() ) {
210 - return $t;
211 - } else {
212 - return NULL;
213 - }
214 - }
215 -
 266+ # Get prefixed title with underscores
216267 function getPrefixedDBkey()
217268 {
218269 $s = $this->prefix( $this->mDbkeyform );
@@ -219,9 +270,10 @@
220271 return $s;
221272 }
222273
 274+ # Get prefixed title with spaces
 275+ # This is the form usually used for display
223276 function getPrefixedText()
224277 {
225 - # TEST THIS @@@
226278 if ( empty( $this->mPrefixedText ) ) {
227279 $s = $this->prefix( $this->mTextform );
228280 $s = str_replace( "_", " ", $s );
@@ -230,23 +282,27 @@
231283 return $this->mPrefixedText;
232284 }
233285
 286+ # Get a URL-encoded title (not an actual URL) including interwiki
234287 function getPrefixedURL()
235288 {
236289 $s = $this->prefix( $this->mDbkeyform );
237290 $s = str_replace( " ", "_", $s );
238291
239 - $s = urlencode ( $s ) ;
 292+ $s = wfUrlencode ( $s ) ;
 293+
240294 # Cleaning up URL to make it look nice -- is this safe?
241295 $s = preg_replace( "/%3[Aa]/", ":", $s );
242296 $s = preg_replace( "/%2[Ff]/", "/", $s );
243297 $s = str_replace( "%28", "(", $s );
244298 $s = str_replace( "%29", ")", $s );
 299+
245300 return $s;
246301 }
247302
 303+ # Get a real URL referring to this title, with interwiki link and fragment
248304 function getFullURL()
249305 {
250 - global $wgLang, $wgArticlePath;
 306+ global $wgLang, $wgArticlePath, $wgServer, $wgScript;
251307
252308 if ( "" == $this->mInterwiki ) {
253309 $p = $wgArticlePath;
@@ -262,24 +318,67 @@
263319 return $u;
264320 }
265321
 322+ # Get a URL with an optional query string, no fragment
 323+ # * If $query=="", it will use $wgArticlePath
 324+ # * Returns a full for an interwiki link, loses any query string
 325+ # * Optionally adds the server and escapes for HTML
 326+ # * Setting $query to "-" makes an old-style URL with nothing in the
 327+ # query except a title
 328+ function getURL( $query = "", $escape = false, $full = false )
 329+ {
 330+ global $wgLang, $wgArticlePath, $wgScript, $wgServer;
 331+
 332+ if ( $this->isExternal() ) {
 333+ return $this->getFullURL();
 334+ }
 335+
 336+ $dbkey = wfUrlencode( $this->getPrefixedDBkey() );
 337+ if ( $query == "" ) {
 338+ $url = str_replace( "$1", $dbkey, $wgArticlePath );
 339+ } else {
 340+ if ( $query == "-" ) {
 341+ $query = "";
 342+ }
 343+ if ( $wgScript != "" ) {
 344+ $url = "{$wgScript}?title={$dbkey}&{$query}";
 345+ } else {
 346+ # Top level wiki
 347+ $url = "/{$dbkey}&{$query}";
 348+ }
 349+ }
 350+
 351+ if ( $full ) {
 352+ $url = $wgServer . $url;
 353+ }
 354+
 355+ if ( $escape ) {
 356+ $url = wfEscapeHTML( $url );
 357+ }
 358+ return $url;
 359+ }
 360+
 361+ # Get the edit URL, or a null string if it is an interwiki link
266362 function getEditURL()
267363 {
268364 global $wgServer, $wgScript;
269365
270366 if ( "" != $this->mInterwiki ) { return ""; }
271 - $s = wfLocalUrl( $this->getPrefixedURL(), "action=edit" );
 367+ $s = $this->getURL( "action=edit" );
272368
273369 return $s;
274370 }
275371
 372+ # Get HTML-escaped displayable text
276373 # For the title field in <a> tags
277374 function getEscapedText()
278375 {
279376 return wfEscapeHTML( $this->getPrefixedText() );
280377 }
281378
 379+ # Is the title interwiki?
282380 function isExternal() { return ( "" != $this->mInterwiki ); }
283381
 382+ # Does the title correspond to a protected article?
284383 function isProtected()
285384 {
286385 if ( -1 == $this->mNamespace ) { return true; }
@@ -288,6 +387,10 @@
289388 return false;
290389 }
291390
 391+ # Is the page a log page, i.e. one where the history is messed up by
 392+ # LogPage.php? This used to be used for suppressing diff links in recent
 393+ # changes, but now that's done by setting a flag in the recentchanges
 394+ # table. Hence, this probably is no longer used.
292395 function isLog()
293396 {
294397 if ( $this->mNamespace != Namespace::getWikipedia() ) {
@@ -300,6 +403,7 @@
301404 return false;
302405 }
303406
 407+ # Is $wgUser is watching this page?
304408 function userIsWatching()
305409 {
306410 global $wgUser;
@@ -310,6 +414,7 @@
311415 return $wgUser->isWatched( $this );
312416 }
313417
 418+ # Can $wgUser edit this page?
314419 function userCanEdit()
315420 {
316421 global $wgUser;
@@ -327,6 +432,7 @@
328433 return true;
329434 }
330435
 436+ # Accessor/initialisation for mRestrictions
331437 function getRestrictions()
332438 {
333439 $id = $this->getArticleID();
@@ -340,6 +446,7 @@
341447 return $this->mRestrictions;
342448 }
343449
 450+ # Is there a version of this page in the deletion archive?
344451 function isDeleted() {
345452 $ns = $this->getNamespace();
346453 $t = wfStrencode( $this->getDBkey() );
@@ -351,6 +458,8 @@
352459 return 0;
353460 }
354461
 462+ # Get the article ID from the link cache
 463+ # Used very heavily, e.g. in Parser::replaceInternalLinks()
355464 function getArticleID()
356465 {
357466 global $wgLinkCache;
@@ -360,6 +469,9 @@
361470 return $this->mArticleID;
362471 }
363472
 473+ # This clears some fields in this object, and clears any associated keys in the
 474+ # "bad links" section of $wgLinkCache. This is called from Article::insertNewArticle()
 475+ # to allow loading of the new cur_id. It's also called from Article::doDeleteArticle()
364476 function resetArticleID( $newid )
365477 {
366478 global $wgLinkCache;
@@ -371,6 +483,8 @@
372484 $this->mRestrictions = array();
373485 }
374486
 487+ # Updates cur_touched
 488+ # Called from LinksUpdate.php
375489 function invalidateCache() {
376490 $now = wfTimestampNow();
377491 $ns = $this->getNamespace();
@@ -379,6 +493,7 @@
380494 return wfQuery( $sql, DB_WRITE, "Title::invalidateCache" );
381495 }
382496
 497+ # Prefixes some arbitrary text with the namespace or interwiki prefix of this object
383498 /* private */ function prefix( $name )
384499 {
385500 global $wgLang;
@@ -393,6 +508,8 @@
394509 return $p . $name;
395510 }
396511
 512+ # Secure and split - main initialisation function for this object
 513+ #
397514 # Assumes that mDbkeyform has been set, and is urldecoded
398515 # and uses undersocres, but not otherwise munged. This function
399516 # removes illegal characters, splits off the winterwiki and
@@ -436,19 +553,25 @@
437554 $this->mDbkeyform = $t;
438555 $done = false;
439556
 557+ # :Image: namespace
440558 if ( 0 == strncasecmp( $imgpre, $t, strlen( $imgpre ) ) ) {
441559 $t = substr( $t, 1 );
442560 }
 561+
 562+ # Redundant initial colon
443563 if ( ":" == $t{0} ) {
444564 $r = substr( $t, 1 );
445565 } else {
 566+ # Namespace or interwiki prefix
446567 if ( preg_match( "/^((?:i|x|[a-z]{2,3})(?:-[a-z0-9]+)?|[A-Za-z0-9_\\x80-\\xff]+):_*(.*)$/", $t, $m ) ) {
447568 #$p = strtolower( $m[1] );
448569 $p = $m[1];
449570 if ( $ns = $wgLang->getNsIndex( strtolower( $p ) )) {
 571+ # Ordinary namespace
450572 $t = $m[2];
451573 $this->mNamespace = $ns;
452574 } elseif ( $this->getInterwikiLink( $p ) ) {
 575+ # Interwiki link
453576 $t = $m[2];
454577 $this->mInterwiki = $p;
455578
@@ -461,6 +584,8 @@
462585 }
463586 $r = $t;
464587 }
 588+
 589+ # Redundant interwiki prefix to the local wiki
465590 if ( 0 == strcmp( $this->mInterwiki, $wgLocalInterwiki ) ) {
466591 $this->mInterwiki = "";
467592 }
@@ -486,19 +611,25 @@
487612 return false;
488613 }
489614
 615+ # Initial capital letter
490616 if( $this->mInterwiki == "") $t = $wgLang->ucfirst( $r );
 617+
 618+ # Fill fields
491619 $this->mDbkeyform = $t;
492620 $this->mUrlform = wfUrlencode( $t );
 621+
493622 $this->mTextform = str_replace( "_", " ", $t );
494623
495624 wfProfileOut( $fname );
496625 return true;
497626 }
498627
 628+ # Get a title object associated with the talk page of this article
499629 function getTalkPage() {
500630 return Title::makeTitle( Namespace::getTalk( $this->getNamespace() ), $this->getDBkey() );
501631 }
502632
 633+ # Get a title object associated with the subject page of this talk page
503634 function getSubjectPage() {
504635 return Title::makeTitle( Namespace::getSubject( $this->getNamespace() ), $this->getDBkey() );
505636 }
Index: trunk/phase3/includes/SpecialExport.php
@@ -19,7 +19,8 @@
2020 }
2121
2222 $wgOut->addWikiText( wfMsg( "exporttext" ) );
23 - $action = wfLocalUrlE( $wgLang->SpecialPage( "Export" ) );
 23+ $titleObj = Title::makeTitle( NS_SPECIAL, "Export" );
 24+ $action = $titleObj->getURL( "", true );
2425 $wgOut->addHTML( "
2526 <form method='post' action=\"$action\">
2627 <input type='hidden' name='action' value='submit' />
Index: trunk/phase3/includes/Article.php
@@ -154,8 +154,7 @@
155155 return;
156156 }
157157 if ( $rt->getNamespace() == Namespace::getSpecial() ) {
158 - $wgOut->redirect( wfLocalUrl(
159 - $rt->getPrefixedURL() ) );
 158+ $wgOut->redirect( $rt->getURL() );
160159 return;
161160 }
162161 $rid = $rt->getArticleID();
@@ -431,7 +430,7 @@
432431 # Squid purging
433432 if ( $wgUseSquid ) {
434433 $urlArr = Array(
435 - $wgInternalServer.wfLocalUrl( $this->mTitle->getPrefixedURL())
 434+ $wgInternalServer.$this->mTitle->getURL()
436435 );
437436 wfPurgeSquidServers($urlArr);
438437 /* this needs to be done after LinksUpdate */
@@ -547,7 +546,7 @@
548547
549548 if ( $wgUseSquid ) {
550549 $urlArr = Array(
551 - $wgInternalServer.wfLocalUrl( $this->mTitle->getPrefixedURL())
 550+ $wgInternalServer.$this->mTitle->getURL()
552551 );
553552 wfPurgeSquidServers($urlArr);
554553 }
@@ -578,7 +577,7 @@
579578 $r = "redirect=no";
580579 else
581580 $r = "";
582 - $wgOut->redirect( wfLocalUrl( $this->mTitle->getPrefixedURL(), $r ) );
 581+ $wgOut->redirect( $this->mTitle->getURL( $r ) );
583582 }
584583
585584 # Add this page to my watchlist
@@ -651,7 +650,7 @@
652651 } else {
653652 $log->addEntry( wfMsg( "protectedarticle", $this->mTitle->getPrefixedText() ), "" );
654653 }
655 - $wgOut->redirect( wfLocalUrl( $this->mTitle->getPrefixedURL() ) );
 654+ $wgOut->redirect( $this->mTitle->getURL() );
656655 }
657656
658657 function unprotect()
@@ -767,9 +766,8 @@
768767 $wgOut->setRobotpolicy( "noindex,nofollow" );
769768 $wgOut->addWikiText( wfMsg( "confirmdeletetext" ) );
770769
771 - $t = $this->mTitle->getPrefixedURL();
772 -
773 - $formaction = wfEscapeHTML( wfLocalUrl( $t, "action=delete" . $par ) );
 770+ $formaction = $this->mTitle->getURL( $this->mTitle, "action=delete" . $par, true );
 771+
774772 $confirm = wfMsg( "confirm" );
775773 $check = wfMsg( "confirmcheck" );
776774 $delcom = wfMsg( "deletecomment" );
@@ -837,7 +835,7 @@
838836 # Squid purging
839837 if ( $wgUseSquid ) {
840838 $urlArr = Array(
841 - $wgInternalServer.wfLocalUrl( $this->mTitle->getPrefixedURL())
 839+ $wgInternalServer.$this->mTitle->getURL()
842840 );
843841 wfPurgeSquidServers($urlArr);
844842
@@ -847,7 +845,7 @@
848846 while ( $BL = wfFetchObject ( $res ) )
849847 {
850848 $tobj = Title::newFromDBkey( $BL->l_from) ;
851 - $blurlArr[] = $wgInternalServer.wfLocalUrl( $tobj->getPrefixedURL() );
 849+ $blurlArr[] = $wgInternalServer.$tobj->getURL();
852850 }
853851 wfFreeResult ( $res ) ;
854852 $u = new SquidUpdate( $this->mTitle, $blurlArr );
@@ -1092,86 +1090,10 @@
10931091
10941092 function preSaveTransform( $text )
10951093 {
1096 - $s = "";
1097 - while ( "" != $text ) {
1098 - $p = preg_split( "/<\\s*nowiki\\s*>/i", $text, 2 );
1099 - $s .= $this->pstPass2( $p[0] );
1100 -
1101 - if ( ( count( $p ) < 2 ) || ( "" == $p[1] ) ) { $text = ""; }
1102 - else {
1103 - $q = preg_split( "/<\\/\\s*nowiki\\s*>/i", $p[1], 2 );
1104 - $s .= "<nowiki>{$q[0]}</nowiki>";
1105 - $text = $q[1];
1106 - }
1107 - }
1108 - return rtrim( $s );
 1094+ global $wgParser, $wgUser;
 1095+ return $wgParser->preSaveTransform( $text, $this->mTitle, $wgUser, ParserOptions::newFromUser( $wgUser ) );
11091096 }
1110 -
1111 - /* private */ function pstPass2( $text )
1112 - {
1113 - global $wgUser, $wgLang, $wgLocaltimezone;
1114 -
1115 - # Signatures
1116 - #
1117 - $n = $wgUser->getName();
1118 - $k = $wgUser->getOption( "nickname" );
1119 - if ( "" == $k ) { $k = $n; }
1120 - if(isset($wgLocaltimezone)) {
1121 - $oldtz = getenv("TZ"); putenv("TZ=$wgLocaltimezone");
1122 - }
1123 - /* Note: this is an ugly timezone hack for the European wikis */
1124 - $d = $wgLang->timeanddate( date( "YmdHis" ), false ) .
1125 - " (" . date( "T" ) . ")";
1126 - if(isset($wgLocaltimezone)) putenv("TZ=$oldtz");
1127 -
1128 - $text = preg_replace( "/~~~~/", "[[" . $wgLang->getNsText(
1129 - Namespace::getUser() ) . ":$n|$k]] $d", $text );
1130 - $text = preg_replace( "/~~~/", "[[" . $wgLang->getNsText(
1131 - Namespace::getUser() ) . ":$n|$k]]", $text );
1132 -
1133 - # Context links: [[|name]] and [[name (context)|]]
1134 - #
1135 - $tc = "[&;%\\-,.\\(\\)' _0-9A-Za-z\\/:\\x80-\\xff]";
1136 - $np = "[&;%\\-,.' _0-9A-Za-z\\/:\\x80-\\xff]"; # No parens
1137 - $namespacechar = '[ _0-9A-Za-z\x80-\xff]'; # Namespaces can use non-ascii!
1138 - $conpat = "/^({$np}+) \\(({$tc}+)\\)$/";
1139 -
1140 - $p1 = "/\[\[({$np}+) \\(({$np}+)\\)\\|]]/"; # [[page (context)|]]
1141 - $p2 = "/\[\[\\|({$tc}+)]]/"; # [[|page]]
1142 - $p3 = "/\[\[($namespacechar+):({$np}+)\\|]]/"; # [[namespace:page|]]
1143 - $p4 = "/\[\[($namespacechar+):({$np}+) \\(({$np}+)\\)\\|]]/";
1144 - # [[ns:page (cont)|]]
1145 - $context = "";
1146 - $t = $this->mTitle->getText();
1147 - if ( preg_match( $conpat, $t, $m ) ) {
1148 - $context = $m[2];
1149 - }
1150 - $text = preg_replace( $p4, "[[\\1:\\2 (\\3)|\\2]]", $text );
1151 - $text = preg_replace( $p1, "[[\\1 (\\2)|\\1]]", $text );
1152 - $text = preg_replace( $p3, "[[\\1:\\2|\\2]]", $text );
1153 -
1154 - if ( "" == $context ) {
1155 - $text = preg_replace( $p2, "[[\\1]]", $text );
1156 - } else {
1157 - $text = preg_replace( $p2, "[[\\1 ({$context})|\\1]]", $text );
1158 - }
1159 -
1160 - # {{SUBST:xxx}} variables
1161 - #
1162 - $mw =& MagicWord::get( MAG_SUBST );
1163 - $text = $mw->substituteCallback( $text, "wfReplaceSubstVar" );
1164 -
1165 -/* Experimental:
1166 - # Trim trailing whitespace
1167 - # MAG_END (__END__) tag allows for trailing
1168 - # whitespace to be deliberately included
1169 - $text = rtrim( $text );
1170 - $mw =& MagicWord::get( MAG_END );
1171 - $mw->matchAndRemove( $text );
1172 -*/
1173 - return $text;
1174 - }
1175 -
 1097+
11761098 /* Caching functions */
11771099
11781100 # checkLastModified returns true iff it has taken care of all
Index: trunk/phase3/includes/SkinCologneBlue.php
@@ -19,12 +19,13 @@
2020
2121 $s = "";
2222 $qb = $this->qbSetting();
23 -
 23+ $mainPageObj = Title::newMainPage();
 24+
2425 $s .= "\n<div id='content'>\n<div id='topbar'>" .
2526 "<table width='100%' border=0 cellspacing=0 cellpadding=8><tr>";
2627
2728 $s .= "<td class='top' align=left valign=middle nowrap>";
28 - $s .= "<a href=\"" . wfLocalUrlE( urlencode( wfMsg( "mainpage" ) ) ) . "\">";
 29+ $s .= "<a href=\"" . $mainPageObj->getURL("", true) . "\">";
2930 $s .= "<span id='sitetitle'>" . wfMsg( "sitetitle" ) . "</span></a>";
3031
3132 $s .= "</td><td class='top' align=right valign=bottom width='100%'>";
Index: trunk/phase3/includes/GlobalFunctions.php
@@ -49,12 +49,14 @@
5050 }
5151 }
5252
 53+# Generates a URL from a URL-encoded title and a query string
 54+# Title::getURL() is preferred in most cases
 55+#
5356 function wfLocalUrl( $a, $q = "" )
5457 {
5558 global $wgServer, $wgScript, $wgArticlePath;
5659
5760 $a = str_replace( " ", "_", $a );
58 - #$a = wfUrlencode( $a ); # This stuff is _already_ URL-encoded.
5961
6062 if ( "" == $a ) {
6163 if( "" == $q ) {
@@ -78,12 +80,14 @@
7981 }
8082
8183 function wfFullUrl( $a, $q = "" ) {
82 - global $wgServer;
83 - return $wgServer . wfLocalUrl( $a, $q );
 84+ $titleObj = Title::newFromURL( $a );
 85+ return $titleObj->getURL( $q, false, true );
8486 }
8587
8688 function wfFullUrlE( $a, $q = "" ) {
87 - return wfEscapeHTML( wfFullUrl( $a, $q ) );
 89+ $titleObj = Title::newFromURL( $a );
 90+ return $titleObj->getURL( $q, true, true );
 91+
8892 }
8993
9094 function wfImageUrl( $img )
@@ -154,10 +158,11 @@
155159
156160 function wfUrlencode ( $s )
157161 {
158 - $ulink = urlencode( $s );
159 - $ulink = preg_replace( "/%3[Aa]/", ":", $ulink );
160 - $ulink = preg_replace( "/%2[Ff]/", "/", $ulink );
161 - return $ulink;
 162+ $s = urlencode( $s );
 163+ $s = preg_replace( "/%3[Aa]/", ":", $s );
 164+ $s = preg_replace( "/%2[Ff]/", "/", $s );
 165+
 166+ return $s;
162167 }
163168
164169 function wfUtf8Sequence($codepoint) {
@@ -604,6 +609,7 @@
605610 global $wgUser;
606611 $prev = wfMsg( "prevn", $limit );
607612 $next = wfMsg( "nextn", $limit );
 613+ $link = wfUrlencode( $link );
608614
609615 $sk = $wgUser->getSkin();
610616 if ( 0 != $offset ) {
@@ -725,6 +731,7 @@
726732 return "&#$ord;$newText";
727733 }
728734
 735+# Sets dest to source and returns the original value of dest
729736 function wfSetVar( &$dest, $source )
730737 {
731738 $temp = $dest;
@@ -732,7 +739,8 @@
733740 return $temp;
734741 }
735742
736 -function &wfSetRef( &$dest, $source )
 743+# Sets dest to a reference to source and returns the original dest
 744+function &wfSetRef( &$dest, &$source )
737745 {
738746 $temp =& $dest;
739747 $dest =& $source;
Index: trunk/phase3/includes/Namespace.php
@@ -20,6 +20,10 @@
2121 define("NS_MEDIAWIKI", 8);
2222 define("NS_MEDIAWIKI_TALK", 9);
2323
 24+# Reserved:
 25+define("NS_TEMPLATE", 10);
 26+define("NS_TEMPLATE_TALK", 11);
 27+
2428 class Namespace {
2529
2630 /* These functions are deprecated */
Index: trunk/phase3/includes/SpecialLockdb.php
@@ -35,8 +35,8 @@
3636 $lc = wfMsg( "lockconfirm" );
3737 $lb = wfMsg( "lockbtn" );
3838 $elr = wfMsg( "enterlockreason" );
39 - $action = wfLocalUrlE( $wgLang->specialPage( "Lockdb" ),
40 - "action=submit" );
 39+ $titleObj = Title::makeTitle( NS_SPECIAL, "Lockdb" );
 40+ $action = $titleObj->getURL( "action=submit", true );
4141
4242 $wgOut->addHTML( "<p>
4343 <form id=\"lockdb\" method=\"post\" action=\"{$action}\">
@@ -76,9 +76,8 @@
7777 $wgLang->timeanddate( wfTimestampNow() ) . ")\n" );
7878 fclose( $fp );
7979
80 - $success = wfLocalUrl( $wgLang->specialPage( "Lockdb" ),
81 - "action=success" );
82 - $wgOut->redirect( $success );
 80+ $titleObj = Title::makeTitle( NS_SPECIAL, "Lockdb" );
 81+ $wgOut->redirect( $titleObj->getURL( "action=success" ) );
8382 }
8483
8584 function showSuccess()
Index: trunk/phase3/includes/SpecialUnlockdb.php
@@ -31,8 +31,8 @@
3232 }
3333 $lc = wfMsg( "unlockconfirm" );
3434 $lb = wfMsg( "unlockbtn" );
35 - $action = wfLocalUrlE( $wgLang->specialPage( "Unlockdb" ),
36 - "action=submit" );
 35+ $titleObj = Title::makeTitle( NS_SPECIAL, "Unlockdb" );
 36+ $action = $titleObj->getURL( "action=submit", true );
3737
3838 $wgOut->addHTML( "<p>
3939 <form id=\"unlockdb\" method=\"post\" action=\"{$action}\">
@@ -62,8 +62,8 @@
6363 $wgOut->fileDeleteError( $wgReadOnlyFile );
6464 return;
6565 }
66 - $success = wfLocalUrl( $wgLang->specialPage( "Unlockdb" ),
67 - "action=success" );
 66+ $titleObj = Title::makeTitle( NS_SPECIAL, "Unlockdb" );
 67+ $success = $titleObj->getURL( "action=success" );
6868 $wgOut->redirect( $success );
6969 }
7070
Index: trunk/phase3/includes/SpecialPreferences.php
@@ -237,7 +237,8 @@
238238 $dateopts = $wgLang->getDateFormats();
239239 $togs = $wgLang->getUserToggles();
240240
241 - $action = wfLocalUrlE( $wgLang->specialPage( "Preferences" ));
 241+ $titleObj = Title::makeTitle( NS_SPECIAL, "Preferences" );
 242+ $action = $titleObj->getURL( "", true );
242243
243244 $qb = wfMsg( "qbsettings" );
244245 $cp = wfMsg( "changepassword" );
Index: trunk/phase3/includes/SpecialUserlogin.php
@@ -4,9 +4,7 @@
55
66 function wfSpecialUserlogin()
77 {
8 - global $wpCreateaccount, $wpCreateaccountMail;
9 - global $wpLoginattempt, $wpMailmypassword;
10 - global $action, $_REQUEST, $wgCommandLineMode;
 8+ global $wgCommandLineMode;
119 if( !$wgCommandLineMode && !isset( $_COOKIE[ini_get("session.name")] ) ) {
1210 User::SetupSession();
1311 }
@@ -16,20 +14,20 @@
1715 wfCleanFormFields( $fields );
1816
1917 # When switching accounts, it sucks to get automatically logged out
20 - global $returnto, $wgLang;
21 - if( $returnto == $wgLang->specialPage( "Userlogout" ) ) $returnto = "";
 18+ global $wgLang;
 19+ if( $_REQUEST['returnto'] == $wgLang->specialPage( "Userlogout" ) ) $_REQUEST['returnto'] = "";
2220
2321 $wpCookieCheck = $_REQUEST[ "wpCookieCheck" ];
2422
2523 if ( isset( $wpCookieCheck ) ) {
2624 onCookieRedirectCheck( $wpCookieCheck );
27 - } else if ( isset( $wpCreateaccount ) ) {
 25+ } else if ( isset( $_REQUEST['wpCreateaccount'] ) ) {
2826 addNewAccount();
29 - } else if ( isset( $wpCreateaccountMail ) ) {
 27+ } else if ( isset( $_REQUEST['wpCreateaccountMail'] ) ) {
3028 addNewAccountMailPassword();
31 - } else if ( isset( $wpMailmypassword ) ) {
 29+ } else if ( isset( $_REQUEST['wpMailmypassword'] ) ) {
3230 mailPassword();
33 - } else if ( "submit" == $action || isset( $wpLoginattempt ) ) {
 31+ } else if ( "submit" == $_REQUEST['action'] || array_key_exists('wpLoginattempt', $_REQUEST) ) {
3432 processLogin();
3533 } else {
3634 mainLoginForm( "" );
@@ -39,10 +37,10 @@
4038
4139 /* private */ function addNewAccountMailPassword()
4240 {
43 - global $wgOut, $wpEmail, $wpName;
 41+ global $wgOut;
4442
45 - if ("" == $wpEmail) {
46 - mainLoginForm( wfMsg( "noemail", $wpName ) );
 43+ if ("" == $_REQUEST['wpEmail']) {
 44+ mainLoginForm( wfMsg( "noemail", $_REQUEST['wpName'] ) );
4745 return;
4846 }
4947
@@ -70,8 +68,8 @@
7169
7270 /* private */ function addNewAccount()
7371 {
74 - global $wgUser, $wgOut, $wpPassword, $wpRetype, $wpName, $wpRemember;
75 - global $wpEmail, $wgDeferredUpdateList;
 72+ global $wgUser, $wgOut;
 73+ global $wgDeferredUpdateList;
7674
7775 $u = addNewAccountInternal();
7876
@@ -95,23 +93,24 @@
9694
9795 /* private */ function addNewAccountInternal()
9896 {
99 - global $wgUser, $wgOut, $wpPassword, $wpRetype, $wpName, $wpRemember;
100 - global $wpEmail, $wgMaxNameChars;
 97+ global $wgUser, $wgOut;
 98+ global $wgMaxNameChars;
10199
102100 if (!$wgUser->isAllowedToCreateAccount()) {
103101 userNotPrivilegedMessage();
104102 return;
105103 }
106104
107 - if ( 0 != strcmp( $wpPassword, $wpRetype ) ) {
 105+ if ( 0 != strcmp( $_REQUEST['wpPassword'], $_REQUEST['wpRetype'] ) ) {
108106 mainLoginForm( wfMsg( "badretype" ) );
109107 return;
110108 }
111 - $wpName = trim( $wpName );
112 - if ( ( "" == $wpName ) ||
113 - preg_match( "/\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}/", $wpName ) ||
114 - (strpos( $wpName, "/" ) !== false) ||
115 - (strlen( $wpName ) > $wgMaxNameChars) )
 109+
 110+ $name = trim( $_REQUEST['wpName'] );
 111+ if ( ( "" == $name ) ||
 112+ preg_match( "/\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}/", $name ) ||
 113+ (strpos( $name, "/" ) !== false) ||
 114+ (strlen( $name ) > $wgMaxNameChars) )
116115 {
117116 mainLoginForm( wfMsg( "noname" ) );
118117 return;
@@ -120,16 +119,16 @@
121120 $wgOut->readOnlyPage();
122121 return;
123122 }
124 - $u = User::newFromName( $wpName );
 123+ $u = User::newFromName( $name );
125124
126125 if ( 0 != $u->idForName() ) {
127126 mainLoginForm( wfMsg( "userexists" ) );
128127 return;
129128 }
130129 $u->addToDatabase();
131 - $u->setPassword( $wpPassword );
132 - $u->setEmail( $wpEmail );
133 - if ( 1 == $wpRemember ) { $r = 1; }
 130+ $u->setPassword( $_REQUEST['wpPassword'] );
 131+ $u->setEmail( $_REQUEST['wpEmail'] );
 132+ if ( 1 == $_REQUEST['wpRemember'] ) { $r = 1; }
134133 else { $r = 0; }
135134 $u->setOption( "rememberpassword", $r );
136135
@@ -141,15 +140,14 @@
142141
143142 /* private */ function processLogin()
144143 {
145 - global $wgUser, $wpName, $wpPassword, $wpRemember;
 144+ global $wgUser;
146145 global $wgDeferredUpdateList;
147 - global $returnto;
148146
149 - if ( "" == $wpName ) {
 147+ if ( "" == $_REQUEST['wpName'] ) {
150148 mainLoginForm( wfMsg( "noname" ) );
151149 return;
152150 }
153 - $u = User::newFromName( $wpName );
 151+ $u = User::newFromName( $_REQUEST['wpName'] );
154152 $id = $u->idForName();
155153 if ( 0 == $id ) {
156154 mainLoginForm( wfMsg( "nosuchuser", $u->getName() ) );
@@ -157,7 +155,7 @@
158156 }
159157 $u->setId( $id );
160158 $u->loadFromDatabase();
161 - $ep = $u->encryptPassword( $wpPassword );
 159+ $ep = $u->encryptPassword( $_REQUEST['wpPassword'] );
162160 if ( 0 != strcmp( $ep, $u->getPassword() ) ) {
163161 if ( 0 != strcmp( $ep, $u->getNewpassword() ) ) {
164162 mainLoginForm( wfMsg( "wrongpassword" ) );
@@ -167,9 +165,9 @@
168166
169167 # We've verified now, update the real record
170168 #
171 - if ( 1 == $wpRemember ) {
 169+ if ( 1 == $_REQUEST['wpRemember'] ) {
172170 $r = 1;
173 - $u->setCookiePassword( $wpPassword );
 171+ $u->setCookiePassword( $_REQUEST['wpPassword'] );
174172 } else {
175173 $r = 0;
176174 }
@@ -190,14 +188,14 @@
191189
192190 /* private */ function mailPassword()
193191 {
194 - global $wgUser, $wpName, $wgDeferredUpdateList, $wgOutputEncoding;
 192+ global $wgUser, $wgDeferredUpdateList, $wgOutputEncoding;
195193 global $wgCookiePath, $wgCookieDomain, $wgDBname;
196194
197 - if ( "" == $wpName ) {
 195+ if ( "" == $_REQUEST['wpName'] ) {
198196 mainLoginForm( wfMsg( "noname" ) );
199197 return;
200198 }
201 - $u = User::newFromName( $wpName );
 199+ $u = User::newFromName( $_REQUEST['wpName'] );
202200 $id = $u->idForName();
203201 if ( 0 == $id ) {
204202 mainLoginForm( wfMsg( "nosuchuser", $u->getName() ) );
@@ -216,7 +214,7 @@
217215
218216 /* private */ function mailPasswordInternal( $u )
219217 {
220 - global $wpName, $wgDeferredUpdateList, $wgOutputEncoding;
 218+ global $wgDeferredUpdateList, $wgOutputEncoding;
221219 global $wgPasswordSender, $wgDBname, $wgIP;
222220
223221 if ( "" == $u->getEmail() ) {
@@ -271,9 +269,8 @@
272270
273271 /* private */ function mainLoginForm( $err )
274272 {
275 - global $wgUser, $wgOut, $wgLang, $returnto;
276 - global $wpName, $wpPassword, $wpRetype, $wpRemember;
277 - global $wpEmail, $HTTP_COOKIE_VARS, $wgDBname;
 273+ global $wgUser, $wgOut, $wgLang;
 274+ global $HTTP_COOKIE_VARS, $wgDBname;
278275
279276 $le = wfMsg( "loginerror" );
280277 $yn = wfMsg( "yourname" );
@@ -289,8 +286,11 @@
290287 $mmp = wfMsg( "mailmypassword" );
291288 $endText = wfMsg( "loginend" );
292289
 290+ if ( $endText = "&lt;loginend&gt;" ) {
 291+ $endText = "";
 292+ }
293293
294 - $name = $wpName;
 294+ $name = $_REQUEST['wpName'];
295295 if ( "" == $name ) {
296296 if ( 0 != $wgUser->getID() ) {
297297 $name = $wgUser->getName();
@@ -298,7 +298,7 @@
299299 $name = $HTTP_COOKIE_VARS["{$wgDBname}UserName"];
300300 }
301301 }
302 - $pwd = $wpPassword;
 302+ $pwd = $_REQUEST['wpPassword'];
303303
304304 $wgOut->setPageTitle( wfMsg( "userlogin" ) );
305305 $wgOut->setRobotpolicy( "noindex,nofollow" );
@@ -317,13 +317,14 @@
318318 $checked = "";
319319 }
320320 $q = "action=submit";
321 - if ( "" != $returnto ) { $q .= "&returnto=" . wfUrlencode($returnto); }
322 - $action = wfLocalUrlE( $wgLang->specialPage( "Userlogin" ), $q );
 321+ if ( "" != $_REQUEST['returnto'] ) { $q .= "&returnto=" . wfUrlencode($_REQUEST['returnto']); }
 322+ $titleObj = Title::makeTitle( NS_SPECIAL, "Userlogin" );
 323+ $action = $titleObj->getURL( $q, true );
323324
324 - $wpName = wfEscapeHTML( $wpName );
325 - $wpPassword = wfEscapeHTML( $wpPassword );
326 - $wpRetype = wfEscapeHTML( $wpRetype );
327 - $wpEmail = wfEscapeHTML( $wpEmail );
 325+ $encName = wfEscapeHTML( $name );
 326+ $encPassword = wfEscapeHTML( $pwd );
 327+ $encRetype = wfEscapeHTML( $_REQUEST['wpRetype'] );
 328+ $encEmail = wfEscapeHTML( $_REQUEST['wpEmail'] );
328329
329330 if ($wgUser->getID() != 0) {
330331 $cambutton = "<input tabindex=6 type=submit name=\"wpCreateaccountMail\" value=\"{$cam}\">";
@@ -334,7 +335,7 @@
335336 <table border=0><tr>
336337 <td align=right>$yn:</td>
337338 <td align=left>
338 -<input tabindex=1 type=text name=\"wpName\" value=\"{$name}\" size=20>
 339+<input tabindex=1 type=text name=\"wpName\" value=\"{$encName}\" size=20>
339340 </td>
340341 <td align=left>
341342 <input tabindex=3 type=submit name=\"wpLoginattempt\" value=\"{$li}\">
@@ -343,7 +344,7 @@
344345 <tr>
345346 <td align=right>$yp:</td>
346347 <td align=left>
347 -<input tabindex=2 type=password name=\"wpPassword\" value=\"{$pwd}\" size=20>
 348+<input tabindex=2 type=password name=\"wpPassword\" value=\"{$encPassword}\" size=20>
348349 </td>
349350 <td align=left>
350351 <input tabindex=7 type=checkbox name=\"wpRemember\" value=\"1\" id=\"wpRemember\"$checked><label for=\"wpRemember\">$rmp</label>
@@ -351,17 +352,18 @@
352353 </tr>");
353354
354355 if ($wgUser->isAllowedToCreateAccount()) {
355 -
 356+ $encRetype = htmlspecialchars( $_REQUEST['wpRetype'] );
 357+ $encEmail = htmlspecialchars( $_REQUEST['wpCreateAccount'] );
356358 $wgOut->addHTML("<tr><td colspan=3>&nbsp;</td></tr><tr>
357359 <td align=right>$ypa:</td>
358360 <td align=left>
359 -<input tabindex=4 type=password name=\"wpRetype\" value=\"{$wpRetype}\"
 361+<input tabindex=4 type=password name=\"wpRetype\" value=\"{$encRetype}\"
360362 size=20>
361363 </td><td>$nuo</td></tr>
362364 <tr>
363365 <td align=right>$ye:</td>
364366 <td align=left>
365 -<input tabindex=5 type=text name=\"wpEmail\" value=\"{$wpEmail}\" size=20>
 367+<input tabindex=5 type=text name=\"wpEmail\" value=\"{$encEmail}\" size=20>
366368 </td><td align=left>
367369 <input tabindex=6 type=submit name=\"wpCreateaccount\" value=\"{$ca}\">
368370 $cambutton
@@ -388,8 +390,8 @@
389391 {
390392 global $wgOut, $wgLang;
391393
392 - $check = wfLocalUrl( wfUrlEncode( $wgLang->specialPage( "Userlogin" ) ),
393 - "wpCookieCheck=$type" );
 394+ $titleObj = Title::makeTitle( NS_SPECIAL, "Userlogin" );
 395+ $check = $titleObj->getURL( "wpCookieCheck=$type" );
394396
395397 return $wgOut->redirect( $check );
396398 }
Index: trunk/phase3/includes/SpecialWhatlinkshere.php
@@ -8,7 +8,7 @@
99 if($par) {
1010 $target = $par;
1111 } else {
12 - $target = wfCleanQueryVar( $_REQUEST['target'] );
 12+ $target = $_REQUEST['target'] ;
1313 }
1414 if ( "" == $target ) {
1515 $wgOut->errorpage( "notargettitle", "notargettext" );
Index: trunk/phase3/includes/SquidUpdate.php
@@ -21,7 +21,7 @@
2222 while ( $BL = wfFetchObject ( $res ) )
2323 {
2424 $t = Title::newFromDBkey( $BL->l_from) ;
25 - $this->urlArr[] = $wgInternalServer.wfLocalUrl( $t->getPrefixedURL() );
 25+ $this->urlArr[] = $wgInternalServer.$t->getURL() ;
2626 }
2727 wfFreeResult ( $res ) ;
2828
Index: trunk/phase3/includes/SearchEngine.php
@@ -130,8 +130,10 @@
131131 wfMsg("powersearch") . "\">\n";
132132 $ret = str_replace( "$9", $tempText, $ret );
133133
 134+ $titleObj = NULL; # this does tricky stuff
 135+
134136 $ret = "<br><br>\n<form id=\"powersearch\" method=\"get\" " .
135 - "action=\"" . wfLocalUrl( "" ) . "\">\n{$ret}\n</form>\n";
 137+ "action=\"" . $titleObj->getUrl() . "\">\n{$ret}\n</form>\n";
136138
137139 if ( isset ( $searchx ) ) {
138140 if ( ! $listredirs ) {
@@ -433,7 +435,7 @@
434436 }
435437
436438 if ( 0 != $t->getArticleID() ) {
437 - $wgOut->redirect( wfLocalUrl( $t->getPrefixedURL() ) );
 439+ $wgOut->redirect( $t->getURL() );
438440 return;
439441 }
440442
@@ -441,7 +443,7 @@
442444 #
443445 $t = Title::newFromText( strtolower( $search ) );
444446 if ( 0 != $t->getArticleID() ) {
445 - $wgOut->redirect( wfLocalUrl( $t->getPrefixedURL() ) );
 447+ $wgOut->redirect( $t->getURL() );
446448 return;
447449 }
448450
@@ -449,7 +451,7 @@
450452 #
451453 $t = Title::newFromText( ucwords( strtolower( $search ) ) );
452454 if ( 0 != $t->getArticleID() ) {
453 - $wgOut->redirect( wfLocalUrl( $t->getPrefixedURL() ) );
 455+ $wgOut->redirect( $t->getURL() );
454456 return;
455457 }
456458
@@ -457,13 +459,14 @@
458460 #
459461 $t = Title::newFromText( strtoupper( $search ) );
460462 if ( 0 != $t->getArticleID() ) {
461 - $wgOut->redirect( wfLocalUrl( $t->getPrefixedURL() ) );
 463+ $wgOut->redirect( $t->getURL() );
462464 return;
463465 }
464 - $wgOut->addHTML( wfMsg("nogomatch",
465 - htmlspecialchars( wfLocalUrl( ucfirst($this->mUsertext), "action=edit") ) )
466 - . "\n<p>" );
467466
 467+ # No match, generate an edit URL
 468+ $t = Title::newFromText( $this->mUsertext );
 469+ $wgOut->addHTML( wfMsg("nogomatch", $t->getURL( "action=edit", true ) ) . "\n<p>" );
 470+
468471 # Try a fuzzy title search
469472 $anyhit = false;
470473 global $wgDisableFuzzySearch;
Index: trunk/phase3/includes/Parser.php
@@ -9,15 +9,18 @@
1010 # Globals used:
1111 # objects: $wgLang, $wgDateFormatter, $wgLinkCache, $wgCurOut
1212 #
 13+# NOT $wgArticle, $wgUser or $wgTitle. Keep them away!
 14+#
1315 # settings: $wgUseTex*, $wgUseCategoryMagic*, $wgUseDynamicDates*, $wgInterwikiMagic*,
14 -# $wgNamespacesWithSubpages, $wgLanguageCode, $wgAllowExternalImages*
 16+# $wgNamespacesWithSubpages, $wgLanguageCode, $wgAllowExternalImages*,
 17+# $wgLocaltimezone
1518 #
1619 # * only within ParserOptions
1720
1821 class Parser
1922 {
2023 # Cleared with clearState():
21 - var $mOutput, $mAutonumber, $mLastSection, $mDTopen;
 24+ var $mOutput, $mAutonumber, $mLastSection, $mDTopen, $mStripState;
2225
2326 # Temporary:
2427 var $mOptions, $mTitle;
@@ -33,6 +36,7 @@
3437 $this->mAutonumber = 0;
3538 $this->mLastSection = "";
3639 $this->mDTopen = false;
 40+ $this->mStripState = false;
3741 }
3842
3943 # First pass--just handle <nowiki> sections, pass the rest off
@@ -44,18 +48,6 @@
4549 {
4650 $fname = "Parser::parse";
4751 wfProfileIn( $fname );
48 - $unique = "3iyZiyA7iMwg5rhxP0Dcc9oTnj8qD1jm1Sfv4";
49 - $unique2 = "4LIQ9nXtiYFPCSfitVwDw7EYwQlL4GeeQ7qSO";
50 - $unique3 = "fPaA8gDfdLBqzj68Yjg9Hil3qEF8JGO0uszIp";
51 - $nwlist = array();
52 - $nwsecs = 0;
53 - $mathlist = array();
54 - $mathsecs = 0;
55 - $prelist = array ();
56 - $presecs = 0;
57 - $stripped = "";
58 - $stripped2 = "";
59 - $stripped3 = "";
6052
6153 if ( $clearState ) {
6254 $this->clearState();
@@ -64,20 +56,63 @@
6557 $this->mOptions = $options;
6658 $this->mTitle =& $title;
6759
 60+ $stripState = NULL;
 61+ $text = $this->strip( $text, $this->mStripState, true );
 62+ $text = $this->doWikiPass2( $text, $linestart );
 63+ $text = $this->unstrip( $text, $this->mStripState );
 64+
 65+ $this->mOutput->setText( $text );
 66+ wfProfileOut( $fname );
 67+ return $this->mOutput;
 68+ }
 69+
 70+ /* static */ function getRandomString()
 71+ {
 72+ return dechex(mt_rand(0, 0x7fffffff)) . dechex(mt_rand(0, 0x7fffffff));
 73+ }
 74+
 75+ # Strips <nowiki>, <pre> and <math>
 76+ # Returns the text, and fills an array with data needed in unstrip()
 77+ #
 78+ function strip( $text, &$state, $render = true )
 79+ {
 80+ $state = array(
 81+ 'nwlist' => array(),
 82+ 'nwsecs' => 0,
 83+ 'nwunq' => Parser::getRandomString(),
 84+ 'mathlist' => array(),
 85+ 'mathsecs' => 0,
 86+ 'mathunq' => Parser::getRandomString(),
 87+ 'prelist' => array(),
 88+ 'presecs' => 0,
 89+ 'preunq' => Parser::getRandomString()
 90+ );
 91+
 92+ $stripped = "";
 93+ $stripped2 = "";
 94+ $stripped3 = "";
 95+
6896 # Replace any instances of the placeholders
69 - $text = str_replace( $unique, wfHtmlEscapeFirst( $unique ), $text );
70 - $text = str_replace( $unique2, wfHtmlEscapeFirst( $unique2 ), $text );
71 - $text = str_replace( $unique3, wfHtmlEscapeFirst( $unique3 ), $text );
72 -
 97+ $text = str_replace( $state['nwunq'], wfHtmlEscapeFirst( $state['nwunq'] ), $text );
 98+ $text = str_replace( $state['mathunq'], wfHtmlEscapeFirst( $state['mathunq'] ), $text );
 99+ $text = str_replace( $state['preunq'], wfHtmlEscapeFirst( $state['preunq'] ), $text );
 100+
73101 while ( "" != $text ) {
74102 $p = preg_split( "/<\\s*nowiki\\s*>/i", $text, 2 );
75103 $stripped .= $p[0];
76 - if ( ( count( $p ) < 2 ) || ( "" == $p[1] ) ) { $text = ""; }
77 - else {
 104+ if ( ( count( $p ) < 2 ) || ( "" == $p[1] ) ) {
 105+ $text = "";
 106+ } else {
78107 $q = preg_split( "/<\\/\\s*nowiki\\s*>/i", $p[1], 2 );
79 - ++$nwsecs;
80 - $nwlist[$nwsecs] = wfEscapeHTMLTagsOnly($q[0]);
81 - $stripped .= $unique . $nwsecs . "s";
 108+ ++$state['nwsecs'];
 109+
 110+ if ( $render ) {
 111+ $state['nwlist'][$state['nwsecs']] = wfEscapeHTMLTagsOnly($q[0]);
 112+ } else {
 113+ $state['nwlist'][$state['nwsecs']] = "<nowiki>{$q[0]}</nowiki>";
 114+ }
 115+
 116+ $stripped .= $state['nwunq'] . sprintf("%08X", $state['nwsecs']);
82117 $text = $q[1];
83118 }
84119 }
@@ -86,12 +121,19 @@
87122 while ( "" != $stripped ) {
88123 $p = preg_split( "/<\\s*math\\s*>/i", $stripped, 2 );
89124 $stripped2 .= $p[0];
90 - if ( ( count( $p ) < 2 ) || ( "" == $p[1] ) ) { $stripped = ""; }
91 - else {
 125+ if ( ( count( $p ) < 2 ) || ( "" == $p[1] ) ) {
 126+ $stripped = "";
 127+ } else {
92128 $q = preg_split( "/<\\/\\s*math\\s*>/i", $p[1], 2 );
93 - ++$mathsecs;
94 - $mathlist[$mathsecs] = renderMath($q[0]);
95 - $stripped2 .= $unique2 . $mathsecs . "s";
 129+ ++$state['mathsecs'];
 130+
 131+ if ( $render ) {
 132+ $state['mathlist'][$state['mathsecs']] = renderMath($q[0]);
 133+ } else {
 134+ $state['mathlist'][$state['mathsecs']] = "<math>{$q[0]}</math>";
 135+ }
 136+
 137+ $stripped2 .= $state['mathunq'] . sprintf("%08X", $state['mathsecs']);
96138 $stripped = $q[1];
97139 }
98140 }
@@ -102,40 +144,39 @@
103145 while ( "" != $stripped2 ) {
104146 $p = preg_split( "/<\\s*pre\\s*>/i", $stripped2, 2 );
105147 $stripped3 .= $p[0];
106 - if ( ( count( $p ) < 2 ) || ( "" == $p[1] ) ) { $stripped2 = ""; }
107 - else {
 148+ if ( ( count( $p ) < 2 ) || ( "" == $p[1] ) ) {
 149+ $stripped2 = "";
 150+ } else {
108151 $q = preg_split( "/<\\/\\s*pre\\s*>/i", $p[1], 2 );
109 - ++$presecs;
110 - $prelist[$presecs] = "<pre>". wfEscapeHTMLTagsOnly($q[0]). "</pre>\n";
111 - $stripped3 .= $unique3 . $presecs . "s";
 152+ ++$state['presecs'];
 153+
 154+ if ( $render ) {
 155+ $state['prelist'][$state['presecs']] = "<pre>". wfEscapeHTMLTagsOnly($q[0]). "</pre>\n";
 156+ } else {
 157+ $state['prelist'][$state['presecs']] = "<pre>{$q[0]}</pre>";
 158+ }
 159+
 160+ $stripped3 .= $state['preunq'] . sprintf("%08X", $state['presecs']);
112161 $stripped2 = $q[1];
113162 }
114163 }
 164+ return $stripped3;
 165+ }
115166
116 - $text = $this->doWikiPass2( $stripped3, $linestart );
117 -
118 - $specialChars = array("\\", "$");
119 - $escapedChars = array("\\\\", "\\$");
120 -
121 - # Go backwards so that {$unique1}1 doesn't overwrite {$unique1}10
122 - for ( $i = $presecs; $i >= 1; --$i ) {
123 - $text = preg_replace( "/{$unique3}{$i}s/", str_replace( $specialChars,
124 - $escapedChars, $prelist[$i] ), $text );
 167+ function unstrip( $text, &$state )
 168+ {
 169+ for ( $i = 1; $i <= $state['presecs']; ++$i ) {
 170+ $text = str_replace( $state['preunq'] . sprintf("%08X", $i), $state['prelist'][$i], $text );
125171 }
126172
127 - for ( $i = $mathsecs; $i >= 1; --$i ) {
128 - $text = preg_replace( "/{$unique2}{$i}s/", str_replace( $specialChars,
129 - $escapedChars, $mathlist[$i] ), $text );
 173+ for ( $i = 1; $i <= $state['mathsecs']; ++$i ) {
 174+ $text = str_replace( $state['mathunq'] . sprintf("%08X", $i), $state['mathlist'][$i], $text );
130175 }
131176
132 - for ( $i = $nwsecs; $i >= 1; --$i ) {
133 - $text = preg_replace( "/{$unique}{$i}s/", str_replace( $specialChars,
134 - $escapedChars, $nwlist[$i] ), $text );
 177+ for ( $i = 1; $i <= $state['nwsecs']; ++$i ) {
 178+ $text = str_replace( $state['nwunq'] . sprintf("%08X", $i), $state['nwlist'][$i], $text );
135179 }
136 -
137 - $this->mOutput->setText( $text );
138 - wfProfileOut( $fname );
139 - return $this->mOutput;
 180+ return $text;
140181 }
141182
142183 function categoryMagic ()
@@ -1182,8 +1223,9 @@
11831224 }
11841225
11851226 // The canonized header is a version of the header text safe to use for links
1186 -
1187 - $canonized_headline=preg_replace("/<.*?>/","",$headline); // strip out HTML
 1227+ // Avoid insertion of weird stuff like <math> by expanding the relevant sections
 1228+ $canonized_headline=Parser::unstrip( $headline, $this->mStripState );
 1229+ $canonized_headline=preg_replace("/<.*?>/","",$canonized_headline); // strip out HTML
11881230 $tocline = trim( $canonized_headline );
11891231 $canonized_headline=str_replace('"',"",$canonized_headline);
11901232 $canonized_headline=str_replace(" ","_",trim($canonized_headline));
@@ -1287,8 +1329,8 @@
12881330 if ( "" == $num ) {
12891331 $text .= "ISBN $blank$x";
12901332 } else {
1291 - $text .= "<a href=\"" . wfLocalUrlE( $wgLang->specialPage(
1292 - "Booksources"), "isbn={$num}" ) . "\" class=\"internal\">ISBN $isbn</a>";
 1333+ $titleObj = Title::makeTitle( NS_SPECIAL, "Booksources" );
 1334+ $text .= "<a href=\"" . $titleObj->getUrl( "isbn={$num}", false, true ) . "\" class=\"internal\">ISBN $isbn</a>";
12931335 $text .= $x;
12941336 }
12951337 }
@@ -1300,7 +1342,86 @@
13011343 return $text;
13021344 }
13031345
 1346+ function preSaveTransform( $text, &$title, &$user, $options, $clearState = true )
 1347+ {
 1348+ $this->mOptions = $options;
 1349+ $this->mTitle = $title;
 1350+ if ( $clearState ) {
 1351+ $this->clearState;
 1352+ }
 1353+
 1354+ $stripState = false;
 1355+ $text = $this->strip( $text, $stripState, false );
 1356+ $text = $this->pstPass2( $text, $user );
 1357+ $text = $this->unstrip( $text, $stripState );
 1358+ return $text;
 1359+ }
13041360
 1361+ /* private */ function pstPass2( $text, &$user )
 1362+ {
 1363+ global $wgLang, $wgLocaltimezone;
 1364+
 1365+ # Signatures
 1366+ #
 1367+ $n = $user->getName();
 1368+ $k = $user->getOption( "nickname" );
 1369+ if ( "" == $k ) { $k = $n; }
 1370+ if(isset($wgLocaltimezone)) {
 1371+ $oldtz = getenv("TZ"); putenv("TZ=$wgLocaltimezone");
 1372+ }
 1373+ /* Note: this is an ugly timezone hack for the European wikis */
 1374+ $d = $wgLang->timeanddate( date( "YmdHis" ), false ) .
 1375+ " (" . date( "T" ) . ")";
 1376+ if(isset($wgLocaltimezone)) putenv("TZ=$oldtz");
 1377+
 1378+ $text = preg_replace( "/~~~~/", "[[" . $wgLang->getNsText(
 1379+ Namespace::getUser() ) . ":$n|$k]] $d", $text );
 1380+ $text = preg_replace( "/~~~/", "[[" . $wgLang->getNsText(
 1381+ Namespace::getUser() ) . ":$n|$k]]", $text );
 1382+
 1383+ # Context links: [[|name]] and [[name (context)|]]
 1384+ #
 1385+ $tc = "[&;%\\-,.\\(\\)' _0-9A-Za-z\\/:\\x80-\\xff]";
 1386+ $np = "[&;%\\-,.' _0-9A-Za-z\\/:\\x80-\\xff]"; # No parens
 1387+ $namespacechar = '[ _0-9A-Za-z\x80-\xff]'; # Namespaces can use non-ascii!
 1388+ $conpat = "/^({$np}+) \\(({$tc}+)\\)$/";
 1389+
 1390+ $p1 = "/\[\[({$np}+) \\(({$np}+)\\)\\|]]/"; # [[page (context)|]]
 1391+ $p2 = "/\[\[\\|({$tc}+)]]/"; # [[|page]]
 1392+ $p3 = "/\[\[($namespacechar+):({$np}+)\\|]]/"; # [[namespace:page|]]
 1393+ $p4 = "/\[\[($namespacechar+):({$np}+) \\(({$np}+)\\)\\|]]/";
 1394+ # [[ns:page (cont)|]]
 1395+ $context = "";
 1396+ $t = $this->mTitle->getText();
 1397+ if ( preg_match( $conpat, $t, $m ) ) {
 1398+ $context = $m[2];
 1399+ }
 1400+ $text = preg_replace( $p4, "[[\\1:\\2 (\\3)|\\2]]", $text );
 1401+ $text = preg_replace( $p1, "[[\\1 (\\2)|\\1]]", $text );
 1402+ $text = preg_replace( $p3, "[[\\1:\\2|\\2]]", $text );
 1403+
 1404+ if ( "" == $context ) {
 1405+ $text = preg_replace( $p2, "[[\\1]]", $text );
 1406+ } else {
 1407+ $text = preg_replace( $p2, "[[\\1 ({$context})|\\1]]", $text );
 1408+ }
 1409+
 1410+ # {{SUBST:xxx}} variables
 1411+ #
 1412+ $mw =& MagicWord::get( MAG_SUBST );
 1413+ $text = $mw->substituteCallback( $text, "wfReplaceSubstVar" );
 1414+
 1415+ # Trim trailing whitespace
 1416+ # MAG_END (__END__) tag allows for trailing
 1417+ # whitespace to be deliberately included
 1418+ $text = rtrim( $text );
 1419+ $mw =& MagicWord::get( MAG_END );
 1420+ $mw->matchAndRemove( $text );
 1421+
 1422+ return $text;
 1423+ }
 1424+
 1425+
13051426 }
13061427
13071428 class ParserOutput
@@ -1398,6 +1519,8 @@
13991520 $this->mNumberHeadings = $user->getOption( "numberheadings" );
14001521 $this->mShowToc = $user->getOption( "showtoc" );
14011522 }
 1523+
 1524+
14021525 }
14031526
14041527 # Regex callbacks, used in OutputPage::replaceVariables
Index: trunk/phase3/includes/PageHistory.php
@@ -106,7 +106,7 @@
107107 global $wgTitle;
108108 $this->lastdate = $this->lastline = "";
109109 $s = "\n<p>" . wfMsg( "histlegend" ) . "\n<ul>";
110 - $url = wfLocalUrl( $wgTitle->getPrefixedText(), "dummy=1");
 110+ $url = $wgTitle->getURL("-");
111111 $s .= "<SCRIPT>
112112 var sel = -1;
113113 function anysel(oid){
Index: trunk/phase3/includes/Setup.php
@@ -74,7 +74,16 @@
7575 wfDebug( "$REQUEST_METHOD $REQUEST_URI\n" );
7676 }
7777
 78+# Fix "magic" quotes
 79+if ( get_magic_quotes_gpc() ) {
 80+ foreach ( $_REQUEST as $field => $value ) {
 81+ $_REQUEST[$field] = stripslashes( $value );
 82+ print "$field: $value -> {$_REQUEST[$field]}<br>\n";
 83+ }
 84+}
7885
 86+# Set up Memcached
 87+#
7988 class MemCachedClientforWiki extends memcached {
8089 function _debugprint( $text ) {
8190 wfDebug( "memcached: $text\n" );
Index: trunk/phase3/includes/SkinSmarty.php
@@ -75,12 +75,12 @@
7676 global $wgLang;
7777 $action = "";
7878 $popup = "";
79 - $page = "";
 79+ $title = NULL;
8080
8181 if($params['action']) $action = "action=" . $params['action'];
8282
8383 if($params['special']) {
84 - $page = $wgLang->specialPage( $params['special'] );
 84+ $title = Title::makeTitle( NS_SPECIAL, $params['special'] );
8585 #$text = $wgLang->getSpecialPageName( $params['special'] );
8686 $text = $popup = $params['special'];
8787 if($params['target']) $action .= "target=" . urlencode( $params['target'] );
@@ -93,10 +93,9 @@
9494 $title = Title::makeTitle( $title->getNamespace() ^ 1, $title->getDbKey() );
9595 }
9696 $text = $popup = $title->getPrefixedText();
97 - $page = urlencode( $title->getPrefixedUrl() );
9897 }
9998
100 - $url = wfLocalUrlE( $page, $action );
 99+ $url = $title->getURL( $action, true );
101100
102101 if($params['text']) $text = $params['text'];
103102 if($params['key']) $text = wfMsg( $params['key'] );
Index: trunk/phase3/includes/Skin.php
@@ -175,14 +175,13 @@
176176 (!$wgTitle->isProtected() || $wgUser->isSysop())
177177
178178 ) {
179 - $n = $wgTitle->getPrefixedURL();
180179 $t = wfMsg( "editthispage" );
181180 $oid = $red = "";
182181 if ( $redirect ) { $red = "&redirect={$redirect}"; }
183182 if ( $oldid && ! isset( $diff ) ) {
184183 $oid = "&oldid={$oldid}";
185184 }
186 - $s = wfLocalUrlE($n,"action=edit{$oid}{$red}");
 185+ $s = $wgTitle->getUrl( "action=edit{$oid}{$red}", false, true );
187186 $s = "document.location = \"" .$s ."\";";
188187 $a += array ("ondblclick" => $s);
189188
@@ -690,9 +689,10 @@
691690 {
692691 if ( "" != $align ) { $a = " align='{$align}'"; }
693692 else { $a = ""; }
694 -
 693+
695694 $mp = wfMsg( "mainpage" );
696 - $s = "<a href=\"" . wfLocalUrlE( urlencode( str_replace(' ','_',$mp) ) )
 695+ $titleObj = Title::newFromText( $mp );
 696+ $s = "<a href=\"" . $titleObj->getURL( "", true )
697697 . "\"><img{$a} border=0 src=\""
698698 . $this->getLogo() . "\" alt=\"" . "[{$mp}]\"></a>";
699699 return $s;
@@ -1035,7 +1035,7 @@
10361036 global $wgTitle, $wgLang;
10371037
10381038 $s = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
1039 - wfMsg( "contributions" ), "target=" . $wgTitle->getURL() );
 1039+ wfMsg( "contributions" ), "target=" . $wgTitle->getPartialURL() );
10401040 return $s;
10411041 }
10421042
@@ -1044,7 +1044,7 @@
10451045 global $wgTitle, $wgLang;
10461046
10471047 $s = $this->makeKnownLink( $wgLang->specialPage( "Emailuser" ),
1048 - wfMsg( "emailuser" ), "target=" . $wgTitle->getURL() );
 1048+ wfMsg( "emailuser" ), "target=" . $wgTitle->getPartialURL() );
10491049 return $s;
10501050 }
10511051
@@ -1332,7 +1332,7 @@
13331333 $u = "";
13341334 if ( "" == $text ) { $text = $nt->getFragment(); }
13351335 } else {
1336 - $u = wfLocalUrlE( $link, $query );
 1336+ $u = $nt->getURL( $query, true );
13371337 }
13381338 if ( "" != $nt->getFragment() ) {
13391339 $u .= "#" . wfEscapeHTML( $nt->getFragment() );
@@ -1364,7 +1364,7 @@
13651365
13661366 if ( "" == $query ) { $q = "action=edit"; }
13671367 else { $q = "action=edit&{$query}"; }
1368 - $u = wfLocalUrlE( $link, $q );
 1368+ $u = $nt->getURL( $q );
13691369
13701370 if ( "" == $text ) { $text = $nt->getPrefixedText(); }
13711371 $style = $this->getInternalLinkAttributesObj( $nt, $text, "yes" );
@@ -1394,7 +1394,7 @@
13951395
13961396 $link = $nt->getPrefixedURL();
13971397
1398 - $u = wfLocalUrlE( $link, $query );
 1398+ $u = $nt->getURL( $query, true );
13991399
14001400 if ( "" == $text ) { $text = $nt->getPrefixedText(); }
14011401 $style = $this->getInternalLinkAttributesObj( $nt, $text, "stub" );
@@ -1439,7 +1439,6 @@
14401440
14411441 function makeImageLinkObj( $nt, $alt = "" ) {
14421442 global $wgLang, $wgUseImageResize;
1443 - $link = $nt->getPrefixedURL();
14441443 $name = $nt->getDBKey();
14451444 $url = wfImageUrl( $name );
14461445 $align = "";
@@ -1523,7 +1522,7 @@
15241523 }
15251524 $alt = htmlspecialchars( $alt );
15261525
1527 - $u = wfLocalUrlE( $link );
 1526+ $u = $nt->getURL( "", true );
15281527 $s = "<a href=\"{$u}\" class='image' title=\"{$alt}\">" .
15291528 "<img border=\"0\" src=\"{$url}\" alt=\"{$alt}\"></a>";
15301529 if ( "" != $align ) {
@@ -1632,7 +1631,6 @@
16331632 global $wgUploadPath;
16341633 $name = $nt->getDBKey();
16351634 $image = Title::makeTitle( Namespace::getImage(), $name );
1636 - $link = $image->getPrefixedURL();
16371635 $url = wfImageUrl( $name );
16381636 $path = wfImagePath( $name );
16391637
@@ -1649,7 +1647,7 @@
16501648
16511649 $thumbUrl = $this->createThumb( $name, $boxwidth );
16521650
1653 - $u = wfLocalUrlE( $link );
 1651+ $u = $nt->getURL( "", true );
16541652
16551653 $more = htmlspecialchars(wfMsg( "thumbnail-more" ));
16561654
@@ -2150,8 +2148,8 @@
21512149 $url = wfImageUrl( $img );
21522150 $rlink = $cur;
21532151 if ( $wgUser->isSysop() ) {
2154 - $link = wfLocalUrlE( $wgTitle->getPrefixedText(), "image=" . $wgTitle->getURL() .
2155 - "&action=delete" );
 2152+ $link = $wgTitle->getURL( "image=" . $wgTitle->getPartialURL() .
 2153+ "&action=delete", true );
21562154 $style = $this->getInternalLinkAttributes( $link, $del );
21572155
21582156 $dlink = "<a href=\"{$link}\"{$style}>{$del}</a>";
@@ -2239,7 +2237,7 @@
22402238
22412239 global $wgTitle,$wgUser,$oldid;
22422240 if($oldid) return $head;
2243 - $url = wfLocalUrlE(urlencode(str_replace(' ','_',$wgTitle->getPrefixedText())),"action=edit&section=$section");
 2241+ $url = $wgTitle->getUrl( "action=edit&section=$section", true );
22442242 return "<span onContextMenu='document.location=\"".$url."\";return false;'>{$head}</span>";
22452243 }
22462244
Index: trunk/phase3/includes/SpecialMakesysop.php
@@ -42,8 +42,8 @@
4343
4444 $wgOut->addWikiText( wfMsg( "makesysoptext" ) );
4545
46 - $action = wfLocalUrlE( $wgLang->specialPage( "Makesysop" ),
47 - "action=submit" );
 46+ $titleObj = Title::makeTitle( NS_SPECIAL, "Makesysop" );
 47+ $action = $titleObj->getURL( "action=submit", true );
4848
4949 if ( "" != $err ) {
5050 $wgOut->setSubtitle( wfMsg( "formerror" ) );
Index: trunk/phase3/includes/EditPage.php
@@ -129,8 +129,7 @@
130130 # append them and the string comparison fails
131131 if ( ( "" == $wpTextbox1 ) ||
132132 ( wfMsg( "newarticletext" ) == rtrim( preg_replace("/\r/","",$wpTextbox1) ) ) ) {
133 - $wgOut->redirect( wfLocalUrl(
134 - $this->mTitle->getPrefixedURL() ) );
 133+ $wgOut->redirect( $this->mTitle->getURL() );
135134 return;
136135 }
137136 $this->mArticle->insertNewArticle( $wpTextbox1, $wpSummary, $wpMinoredit, $wpWatchthis );
@@ -228,7 +227,7 @@
229228
230229 $q = "action=submit";
231230 if ( "no" == $redirect ) { $q .= "&redirect=no"; }
232 - $action = wfEscapeHTML( wfLocalUrl( $this->mTitle->getPrefixedURL(), $q ) );
 231+ $action = $this->mTitle->getURL( $q, true );
233232
234233 $summary = wfMsg( "summary" );
235234 $subject = wfMsg("subject");
Index: trunk/phase3/includes/SpecialBlockip.php
@@ -39,8 +39,8 @@
4040 $mIpbexpiry = wfMsg( "ipbexpiry" );
4141 $mIpbreason = wfMsg( "ipbreason" );
4242 $mIpbsubmit = wfMsg( "ipbsubmit" );
43 - $action = wfLocalUrlE( $wgLang->specialPage( "Blockip" ),
44 - "action=submit" );
 43+ $titleObj = Title::makeTitle( NS_SPECIAL, "Blockip" );
 44+ $action = $titleObj->getURL( "action=submit", true );
4545
4646 if ( "" != $err ) {
4747 $wgOut->setSubtitle( wfMsg( "formerror" ) );
@@ -145,9 +145,8 @@
146146 $log->addEntry( $action, $wpBlockReason );
147147
148148 # Report to the user
149 - $success = wfLocalUrl( $wgLang->specialPage( "Blockip" ),
150 - "action=success&ip={$wpBlockAddress}" );
151 - $wgOut->redirect( $success );
 149+ $titleObj = Title::makeTitle( NS_SPECIAL, "Blockip" );
 150+ $wgOut->redirect( $titleObj->getURL( "action=success&ip={$wpBlockAddress}" ) );
152151 }
153152
154153 function showSuccess()
Index: trunk/phase3/includes/SpecialUpload.php
@@ -208,8 +208,8 @@
209209 $reupload = wfMsg( "reupload" );
210210 $iw = wfMsg( "ignorewarning" );
211211 $reup = wfMsg( "reuploaddesc" );
212 - $action = wfLocalUrlE( $wgLang->specialPage( "Upload" ),
213 - "action=submit" );
 212+ $titleObj = Title::makeTitle( NS_SPECIAL, "Upload" );
 213+ $action = $titleObj->getURL( "action=submit", true );
214214
215215 if ( $wgUseCopyrightUpload )
216216 {
@@ -267,7 +267,8 @@
268268 $ca = wfMsg( "affirmation", $clink );
269269 $iw = wfMsg( "ignorewarning" );
270270
271 - $action = wfLocalUrl( $wgLang->specialPage( "Upload" ) );
 271+ $titleObj = Title::makeTitle( NS_SPECIAL, "Upload" );
 272+ $action = $titleObj->getURL( "", true );
272273
273274 $source = "
274275 <td align=right>
Index: trunk/phase3/includes/OutputPage.php
@@ -534,8 +534,8 @@
535535
536536 $r = wfMsg( "returnto", $link );
537537 if ( $auto ) {
538 - $wgOut->addMeta( "http:Refresh", "10;url=" .
539 - wfLocalUrlE( wfUrlencode( $returnto ) ) );
 538+ $titleObj = Title::newFromText( $returnto );
 539+ $wgOut->addMeta( "http:Refresh", "10;url=" . $titleObj->getUrl( "", true, true ));
540540 }
541541 $wgOut->addHTML( "\n<p>$r\n" );
542542 }
Index: trunk/phase3/includes/SpecialWatchlist.php
@@ -14,6 +14,8 @@
1515 $wgOut->setSubtitle( $sub );
1616 $wgOut->setRobotpolicy( "noindex,nofollow" );
1717
 18+ $specialTitle = Title::makeTitle( NS_SPECIAL, "Watchlist" );
 19+
1820 $uid = $wgUser->getID();
1921 if( $uid == 0 ) {
2022 $wgOut->addHTML( wfMsg( "nowatchlist" ) );
@@ -91,7 +93,7 @@
9294 "<p>" . wfMsg( "watcheditlist" ) . "</p>\n" );
9395
9496 $wgOut->addHTML( "<form action='" .
95 - wfLocalUrl( $wgLang->specialPage( "Watchlist" ), "action=submit" ) .
 97+ $specialTitle->getURL( "action=submit", true ) .
9698 "' method='post'>\n" .
9799 "<ul>\n" );
98100 $sql = "SELECT wl_namespace,wl_title FROM watchlist WHERE wl_user=$uid";
@@ -130,8 +132,9 @@
131133 $z = "(wl_namespace=cur_namespace OR wl_namespace+1=cur_namespace)";
132134 }
133135
 136+
134137 $wgOut->addHTML( "<i>" . wfMsg( "watchdetails", $nitems, $npages, $y,
135 - wfLocalUrl( $wgLang->specialPage("Watchlist"),"magic=yes" ) ) . "</i><br>\n" );
 138+ $specialTitle->getURL( "magic=yes", true ) ) . "</i><br>\n" );
136139
137140
138141 $sql = "SELECT
Index: trunk/phase3/includes/Database.php
@@ -106,8 +106,8 @@
107107 $success = false;
108108 }
109109 } else {
110 - # Delay USE
111 - $success = true;
 110+ # Delay USE query
 111+ $success = !!$this->mConn;
112112 }
113113
114114 if ( !$success ) {
Index: trunk/phase3/includes/SpecialMovepage.php
@@ -3,7 +3,7 @@
44
55 function wfSpecialMovepage()
66 {
7 - global $wgUser, $wgOut, $action, $target;
 7+ global $wgUser, $wgOut;
88
99 if ( 0 == $wgUser->getID() or $wgUser->isBlocked() ) {
1010 $wgOut->errorpage( "movenologin", "movenologintext" );
@@ -18,8 +18,8 @@
1919
2020 $f = new MovePageForm();
2121
22 - if ( "success" == $action ) { $f->showSuccess(); }
23 - else if ( "submit" == $action ) { $f->doSubmit(); }
 22+ if ( "success" == $_REQUEST['action'] ) { $f->showSuccess(); }
 23+ else if ( "submit" == $_REQUEST['action'] ) { $f->doSubmit(); }
2424 else { $f->showForm( "" ); }
2525 }
2626
@@ -36,19 +36,22 @@
3737 function showForm( $err )
3838 {
3939 global $wgOut, $wgUser, $wgLang;
40 - global $wpNewTitle, $wpOldTitle, $wpMovetalk, $target;
4140
4241 $wgOut->setPagetitle( wfMsg( "movepage" ) );
4342
44 - if ( ! $wpOldTitle ) {
45 - $target = wfCleanQueryVar( $target );
46 - if ( "" == $target ) {
 43+ if ( ! $_REQUEST['wpOldTitle'] ) {
 44+ if ( "" == $_REQUEST['target'] ) {
4745 $wgOut->errorpage( "notargettitle", "notargettext" );
4846 return;
4947 }
50 - $wpOldTitle = $target;
 48+ $oldTitle = htmlspecialchars( $_REQUEST['target'] );
 49+ } else {
 50+ $oldTitle = htmlspecialchars( $_REQUEST['wpOldTitle'] );
5151 }
52 - $ot = Title::newFromURL( $wpOldTitle );
 52+
 53+ $encOldTitle = htmlspecialchars( $oldTitle );
 54+ $encNewTitle = htmlspecialchars( $_REQUEST['wpNewTitle'] );
 55+ $ot = Title::newFromURL( $oldTitle );
5356 $ott = $ot->getPrefixedText();
5457
5558 $wgOut->addWikiText( wfMsg( "movepagetext" ) );
@@ -60,8 +63,8 @@
6164 $mpb = wfMsg( "movepagebtn" );
6265 $movetalk = wfMsg( "movetalk" );
6366
64 - $action = wfLocalUrlE( $wgLang->specialPage( "Movepage" ),
65 - "action=submit" );
 67+ $titleObj = Title::makeTitle( NS_SPECIAL, "Movepage" );
 68+ $action = $titleObj->getURL( "action=submit", true );
6669
6770 if ( "" != $err ) {
6871 $wgOut->setSubtitle( wfMsg( "formerror" ) );
@@ -75,8 +78,8 @@
7679 </tr><tr>
7780 <td align=right>{$newt}:</td>
7881 <td align=left>
79 -<input type=text size=40 name=\"wpNewTitle\" value=\"{$wpNewTitle}\">
80 -<input type=hidden name=\"wpOldTitle\" value=\"{$wpOldTitle}\">
 82+<input type=text size=40 name=\"wpNewTitle\" value=\"{$encNewTitle}\">
 83+<input type=hidden name=\"wpOldTitle\" value=\"{$encOldTitle}\">
8184 </td>
8285 </tr>" );
8386
@@ -100,13 +103,12 @@
101104 function doSubmit()
102105 {
103106 global $wgOut, $wgUser, $wgLang;
104 - global $wpNewTitle, $wpOldTitle, $wpMovetalk, $target;
105107 global $wgDeferredUpdateList, $wgMessageCache;
106108 global $wgUseSquid, $wgInternalServer;
107109 $fname = "MovePageForm::doSubmit";
108110
109 - $this->ot = Title::newFromText( $wpOldTitle );
110 - $this->nt = Title::newFromText( $wpNewTitle );
 111+ $this->ot = Title::newFromText( $_REQUEST['wpOldTitle'] );
 112+ $this->nt = Title::newFromText( $_REQUEST['wpNewTitle'] );
111113 if( !$this->ot or !$this->nt ) {
112114 $this->showForm( wfMsg( "badtitletext" ) );
113115 return;
@@ -166,9 +168,9 @@
167169 /* this needs to be done after LinksUpdate */
168170 $urlArr = Array(
169171 # purge new title
170 - $wgInternalServer.wfLocalUrl( $this->nt->getPrefixedURL()),
 172+ $wgInternalServer.$this->nt->getURL(),
171173 # purge old title
172 - $wgInternalServer.wfLocalUrl( $this->ot->getPrefixedURL())
 174+ $wgInternalServer.$this->ot->getURL())
173175 );
174176 wfPurgeSquidServers($urlArr);
175177 # purge pages linking to new title
@@ -185,7 +187,7 @@
186188 # and target namespaces are identical, (3) the namespaces are not
187189 # themselves talk namespaces, and of course (4) it exists.
188190
189 - if ( ( 1 == $wpMovetalk ) &&
 191+ if ( ( 1 == $_REQUEST['wpMovetalk'] ) &&
190192 ( ! Namespace::isTalk( $this->ons ) ) &&
191193 ( $this->ons == $this->nns ) ) {
192194
@@ -223,9 +225,9 @@
224226 /* this needs to be done after LinksUpdate */
225227 $urlArr = Array(
226228 # purge new title
227 - $wgInternalServer.wfLocalUrl( $this->nt->getPrefixedURL()),
 229+ $wgInternalServer.$nt->getURL()),
228230 # purge old title
229 - $wgInternalServer.wfLocalUrl( $this->ot->getPrefixedURL())
 231+ $wgInternalServer.$ot->getURL())
230232 );
231233 wfPurgeSquidServers($urlArr);
232234 # purge pages linking to new title
@@ -239,7 +241,8 @@
240242 }
241243 }
242244 }
243 - $success = wfLocalUrl( $wgLang->specialPage( "Movepage" ),
 245+ $titleObj = Title::makeTitle( NS_SPECIAL, "Movepage" );
 246+ $success = $titleObj->getURL(
244247 "action=success&oldtitle=" . wfUrlencode( $this->ofx ) .
245248 "&newtitle=" . wfUrlencode( $this->nfx ) .
246249 "&talkmoved={$this->talkmoved}" );
@@ -250,23 +253,19 @@
251254 function showSuccess()
252255 {
253256 global $wgOut, $wgUser;
254 - global $newtitle, $oldtitle, $talkmoved;
255257
256258 $wgOut->setPagetitle( wfMsg( "movepage" ) );
257259 $wgOut->setSubtitle( wfMsg( "pagemovedsub" ) );
258 -
259 - $fields = array( "oldtitle", "newtitle" );
260 - wfCleanFormFields( $fields );
261 -
262 - $text = wfMsg( "pagemovedtext", $oldtitle, $newtitle );
 260+
 261+ $text = wfMsg( "pagemovedtext", $_REQUEST['oldtitle'], $_REQUEST['newtitle'] );
263262 $wgOut->addWikiText( $text );
264263
265 - if ( 1 == $talkmoved ) {
 264+ if ( 1 == $_REQUEST['talkmoved'] ) {
266265 $wgOut->addHTML( "\n<p>" . wfMsg( "talkpagemoved" ) );
267 - } elseif( 'invalid' == $talkmoved ) {
 266+ } elseif( 'invalid' == $_REQUEST['talkmoved'] ) {
268267 $wgOut->addHTML( "\n<p><strong>" . wfMsg( "talkexists" ) . "</strong>" );
269268 } else {
270 - $ot = Title::newFromURL( $oldtitle );
 269+ $ot = Title::newFromURL( $_REQUEST['oldtitle'] );
271270 if ( ! Namespace::isTalk( $ot->getNamespace() ) ) {
272271 $wgOut->addHTML( "\n<p>" . wfMsg( "talkpagenotmoved" ) );
273272 }
Index: trunk/phase3/includes/SpecialEmailuser.php
@@ -69,8 +69,8 @@
7070 $emm = wfMsg( "emailmessage" );
7171 $ems = wfMsg( "emailsend" );
7272
73 - $action = wfLocalUrlE( $wgLang->specialPage( "Emailuser" ),
74 - "target={$target}&action=submit" );
 73+ $titleObj = Title::makeTitle( NS_SPECIAL, "Emailuser" );
 74+ $action = $titleObj->getURL( "target={$target}&action=submit", true );
7575
7676 if ( "" != $err ) {
7777 $wgOut->setSubtitle( wfMsg( "formerror" ) );
@@ -114,9 +114,8 @@
115115
116116 if (! $mailResult)
117117 {
118 - $success = wfLocalUrl( $wgLang->specialPage( "Emailuser" ),
119 - "target={$target}&action=success" );
120 - $wgOut->redirect( $success );
 118+ $titleObj = Title::makeTitle( NS_SPECIAL, "Emailuser" );
 119+ $wgOut->redirect( $titleObj->getURL( "target={$target}&action=success" ) );
121120 }
122121 else
123122 $wgOut->addHTML( wfMsg( "usermailererror" ) . $mailResult);
Index: trunk/phase3/includes/SpecialAsksql.php
@@ -36,8 +36,8 @@
3737 if ( ! $wpSqlQuery ) { $wpSqlQuery = "SELECT ... FROM ... WHERE ..."; }
3838 $q = wfMsg( "sqlquery" );
3939 $qb = wfMsg( "querybtn" );
40 - $action = wfLocalUrlE( $wgLang->specialPage( "Asksql" ),
41 - "action=submit" );
 40+ $titleObj = Title::makeTitle( NS_SPECIAL, "Asksql" );
 41+ $action = $titleObj->getURL( "action=submit", true );
4242
4343 $wgOut->addHTML( "<p>
4444 <form id=\"asksql\" method=\"post\" action=\"{$action}\">
@@ -101,8 +101,6 @@
102102 if ( $titleList ) {
103103 $r = "";
104104 foreach ( $a as $y ) {
105 - $o = "<a href=\"" . wfLocalUrlE($o) . "\" class='internal'>" .
106 - htmlspecialchars( $y->$x ) . "</a>" ;
107105 $sTitle = htmlspecialchars( $y->cur_title );
108106 if ( $y->cur_namespace ) {
109107 $sNamespace = $wgLang->getNsText( $y->cur_namespace );

Follow-up revisions

RevisionCommit summaryAuthorDate
r84386Makes wikilinks nicer when possible...hashar14:57, 20 March 2011
r87964merge in prettyURL patch...hashar11:41, 13 May 2011

Status & tagging log