Index: trunk/phase3/includes/EditPage.php |
— | — | @@ -11,7 +11,7 @@ |
12 | 12 | * interfaces. |
13 | 13 | * |
14 | 14 | * EditPage cares about two distinct titles: |
15 | | - * $wgTitle is the page that forms submit to, links point to, |
| 15 | + * $this->mContextTitle is the page that forms submit to, links point to, |
16 | 16 | * redirects go to, etc. $this->mTitle (as well as $mArticle) is the |
17 | 17 | * page in the database that is actually being edited. These are |
18 | 18 | * usually the same, but they are now allowed to be different. |
— | — | @@ -44,6 +44,7 @@ |
45 | 45 | |
46 | 46 | var $mArticle; |
47 | 47 | var $mTitle; |
| 48 | + private $mContextTitle = null; |
48 | 49 | var $action; |
49 | 50 | var $isConflict = false; |
50 | 51 | var $isCssJsSubpage = false; |
— | — | @@ -117,8 +118,32 @@ |
118 | 119 | return $this->mArticle; |
119 | 120 | } |
120 | 121 | |
| 122 | + /** |
| 123 | + * Set the context Title object |
| 124 | + * |
| 125 | + * @param $title Title object or null |
| 126 | + */ |
| 127 | + public function setContextTitle( $title ) { |
| 128 | + $this->mContextTitle = $title; |
| 129 | + } |
121 | 130 | |
122 | 131 | /** |
| 132 | + * Get the context title object. |
| 133 | + * If not set, $wgTitle will be returned. This behavior might changed in |
| 134 | + * the future to return $this->mTitle instead. |
| 135 | + * |
| 136 | + * @return Title object |
| 137 | + */ |
| 138 | + public function getContextTitle() { |
| 139 | + if ( is_null( $this->mContextTitle ) ) { |
| 140 | + global $wgTitle; |
| 141 | + return $wgTitle; |
| 142 | + } else { |
| 143 | + return $this->mContextTitle; |
| 144 | + } |
| 145 | + } |
| 146 | + |
| 147 | + /** |
123 | 148 | * Fetch initial editing page content. |
124 | 149 | * @returns mixed string on success, $def_text for invalid sections |
125 | 150 | * @private |
— | — | @@ -1200,23 +1225,23 @@ |
1201 | 1226 | } |
1202 | 1227 | |
1203 | 1228 | function setHeaders() { |
1204 | | - global $wgOut, $wgTitle; |
| 1229 | + global $wgOut; |
1205 | 1230 | $wgOut->setRobotPolicy( 'noindex,nofollow' ); |
1206 | 1231 | if ( $this->formtype == 'preview' ) { |
1207 | 1232 | $wgOut->setPageTitleActionText( wfMsg( 'preview' ) ); |
1208 | 1233 | } |
1209 | 1234 | if ( $this->isConflict ) { |
1210 | | - $wgOut->setPageTitle( wfMsg( 'editconflict', $wgTitle->getPrefixedText() ) ); |
| 1235 | + $wgOut->setPageTitle( wfMsg( 'editconflict', $this->getContextTitle()->getPrefixedText() ) ); |
1211 | 1236 | } elseif ( $this->section != '' ) { |
1212 | 1237 | $msg = $this->section == 'new' ? 'editingcomment' : 'editingsection'; |
1213 | | - $wgOut->setPageTitle( wfMsg( $msg, $wgTitle->getPrefixedText() ) ); |
| 1238 | + $wgOut->setPageTitle( wfMsg( $msg, $this->getContextTitle()->getPrefixedText() ) ); |
1214 | 1239 | } else { |
1215 | 1240 | # Use the title defined by DISPLAYTITLE magic word when present |
1216 | 1241 | if ( isset( $this->mParserOutput ) |
1217 | 1242 | && ( $dt = $this->mParserOutput->getDisplayTitle() ) !== false ) { |
1218 | 1243 | $title = $dt; |
1219 | 1244 | } else { |
1220 | | - $title = $wgTitle->getPrefixedText(); |
| 1245 | + $title = $this->getContextTitle()->getPrefixedText(); |
1221 | 1246 | } |
1222 | 1247 | $wgOut->setPageTitle( wfMsg( 'editing', $title ) ); |
1223 | 1248 | } |
— | — | @@ -1229,15 +1254,8 @@ |
1230 | 1255 | * near the top, for captchas and the like. |
1231 | 1256 | */ |
1232 | 1257 | function showEditForm( $formCallback = null ) { |
1233 | | - global $wgOut, $wgUser, $wgTitle; |
| 1258 | + global $wgOut, $wgUser; |
1234 | 1259 | |
1235 | | - # If $wgTitle is null, that means we're in API mode. |
1236 | | - # Some hook probably called this function without checking |
1237 | | - # for is_null($wgTitle) first. Bail out right here so we don't |
1238 | | - # do lots of work just to discard it right after. |
1239 | | - if ( is_null( $wgTitle ) ) |
1240 | | - return; |
1241 | | - |
1242 | 1260 | wfProfileIn( __METHOD__ ); |
1243 | 1261 | |
1244 | 1262 | $sk = $wgUser->getSkin(); |
— | — | @@ -1263,7 +1281,7 @@ |
1264 | 1282 | return; |
1265 | 1283 | } |
1266 | 1284 | |
1267 | | - $action = htmlspecialchars( $this->getActionURL( $wgTitle ) ); |
| 1285 | + $action = htmlspecialchars( $this->getActionURL( $this->getContextTitle() ) ); |
1268 | 1286 | |
1269 | 1287 | if ( $wgUser->getOption( 'showtoolbar' ) and !$this->isCssJsSubpage ) { |
1270 | 1288 | # prepare toolbar for edit buttons |
— | — | @@ -1397,7 +1415,7 @@ |
1398 | 1416 | } |
1399 | 1417 | |
1400 | 1418 | protected function showHeader() { |
1401 | | - global $wgOut, $wgUser, $wgTitle, $wgMaxArticleSize, $wgLang; |
| 1419 | + global $wgOut, $wgUser, $wgMaxArticleSize, $wgLang; |
1402 | 1420 | if ( $this->isConflict ) { |
1403 | 1421 | $wgOut->wrapWikiMsg( "<div class='mw-explainconflict'>\n$1\n</div>", 'explainconflict' ); |
1404 | 1422 | $this->edittime = $this->mArticle->getTimestamp(); |
— | — | @@ -1471,7 +1489,7 @@ |
1472 | 1490 | if ( $this->isCssJsSubpage ) { |
1473 | 1491 | # Check the skin exists |
1474 | 1492 | if ( $this->isWrongCaseCssJsPage ) { |
1475 | | - $wgOut->wrapWikiMsg( "<div class='error' id='mw-userinvalidcssjstitle'>\n$1\n</div>", array( 'userinvalidcssjstitle', $wgTitle->getSkinFromCssJsSubpage() ) ); |
| 1493 | + $wgOut->wrapWikiMsg( "<div class='error' id='mw-userinvalidcssjstitle'>\n$1\n</div>", array( 'userinvalidcssjstitle', $this->getContextTitle()->getSkinFromCssJsSubpage() ) ); |
1476 | 1494 | } |
1477 | 1495 | if ( $this->formtype !== 'preview' ) { |
1478 | 1496 | if ( $this->isCssSubpage ) |
— | — | @@ -1922,7 +1940,7 @@ |
1923 | 1941 | } |
1924 | 1942 | |
1925 | 1943 | # don't parse user css/js, show message about preview |
1926 | | - # XXX: stupid php bug won't let us use $wgTitle->isCssJsSubpage() here -- This note has been there since r3530. Sure the bug was fixed time ago? |
| 1944 | + # XXX: stupid php bug won't let us use $this->getContextTitle()->isCssJsSubpage() here -- This note has been there since r3530. Sure the bug was fixed time ago? |
1927 | 1945 | |
1928 | 1946 | if ( $this->isCssJsSubpage || $this->mTitle->isCssOrJsPage() ) { |
1929 | 1947 | $level = 'user'; |
— | — | @@ -2040,7 +2058,7 @@ |
2041 | 2059 | * Produce the stock "please login to edit pages" page |
2042 | 2060 | */ |
2043 | 2061 | function userNotLoggedInPage() { |
2044 | | - global $wgUser, $wgOut, $wgTitle; |
| 2062 | + global $wgUser, $wgOut; |
2045 | 2063 | $skin = $wgUser->getSkin(); |
2046 | 2064 | |
2047 | 2065 | $loginTitle = SpecialPage::getTitleFor( 'Userlogin' ); |
— | — | @@ -2048,7 +2066,7 @@ |
2049 | 2067 | $loginTitle, |
2050 | 2068 | wfMsgHtml( 'loginreqlink' ), |
2051 | 2069 | array(), |
2052 | | - array( 'returnto' => $wgTitle->getPrefixedText() ), |
| 2070 | + array( 'returnto' => $this->getContextTitle()->getPrefixedText() ), |
2053 | 2071 | array( 'known', 'noclasses' ) |
2054 | 2072 | ); |
2055 | 2073 | |
— | — | @@ -2057,7 +2075,7 @@ |
2058 | 2076 | $wgOut->setArticleRelated( false ); |
2059 | 2077 | |
2060 | 2078 | $wgOut->addWikiMsgArray( 'whitelistedittext', array( $loginLink ), array( 'replaceafter' ) ); |
2061 | | - $wgOut->returnToMain( false, $wgTitle ); |
| 2079 | + $wgOut->returnToMain( false, $this->getContextTitle() ); |
2062 | 2080 | } |
2063 | 2081 | |
2064 | 2082 | /** |
— | — | @@ -2107,7 +2125,7 @@ |
2108 | 2126 | * @param $match Text which triggered one or more filters |
2109 | 2127 | */ |
2110 | 2128 | public function spamPageWithContent( $match = false ) { |
2111 | | - global $wgOut, $wgTitle; |
| 2129 | + global $wgOut; |
2112 | 2130 | $this->textbox2 = $this->textbox1; |
2113 | 2131 | |
2114 | 2132 | $wgOut->setPageTitle( wfMsg( 'spamprotectiontitle' ) ); |
— | — | @@ -2129,7 +2147,7 @@ |
2130 | 2148 | $wgOut->wrapWikiMsg( '<h2>$1</h2>', "yourtext" ); |
2131 | 2149 | $this->showTextbox2(); |
2132 | 2150 | |
2133 | | - $wgOut->addReturnTo( $wgTitle, array( 'action' => 'edit' ) ); |
| 2151 | + $wgOut->addReturnTo( $this->getContextTitle(), array( 'action' => 'edit' ) ); |
2134 | 2152 | } |
2135 | 2153 | |
2136 | 2154 | |
— | — | @@ -2504,7 +2522,7 @@ |
2505 | 2523 | |
2506 | 2524 | |
2507 | 2525 | public function getCancelLink() { |
2508 | | - global $wgUser, $wgTitle; |
| 2526 | + global $wgUser; |
2509 | 2527 | |
2510 | 2528 | $cancelParams = array(); |
2511 | 2529 | if ( !$this->isConflict && $this->mArticle->getOldID() > 0 ) { |
— | — | @@ -2512,7 +2530,7 @@ |
2513 | 2531 | } |
2514 | 2532 | |
2515 | 2533 | return $wgUser->getSkin()->link( |
2516 | | - $wgTitle, |
| 2534 | + $this->getContextTitle(), |
2517 | 2535 | wfMsgExt( 'cancel', array( 'parseinline' ) ), |
2518 | 2536 | array( 'id' => 'mw-editform-cancel' ), |
2519 | 2537 | $cancelParams, |
— | — | @@ -2683,7 +2701,7 @@ |
2684 | 2702 | * @return bool false if output is done, true if the rest of the form should be displayed |
2685 | 2703 | */ |
2686 | 2704 | function attemptSave() { |
2687 | | - global $wgUser, $wgOut, $wgTitle; |
| 2705 | + global $wgUser, $wgOut; |
2688 | 2706 | |
2689 | 2707 | $resultDetails = false; |
2690 | 2708 | # Allow bots to exempt some edits from bot flagging |
— | — | @@ -2761,7 +2779,7 @@ |
2762 | 2780 | return; |
2763 | 2781 | |
2764 | 2782 | case self::AS_BLANK_ARTICLE: |
2765 | | - $wgOut->redirect( $wgTitle->getFullURL() ); |
| 2783 | + $wgOut->redirect( $this->getContextTitle()->getFullURL() ); |
2766 | 2784 | return false; |
2767 | 2785 | |
2768 | 2786 | case self::AS_IMAGE_REDIRECT_LOGGED: |
Index: trunk/phase3/includes/api/ApiEditPage.php |
— | — | @@ -181,6 +181,8 @@ |
182 | 182 | } |
183 | 183 | |
184 | 184 | $ep = new EditPage( $articleObj ); |
| 185 | + $ep->setContextTitle( $titleObj ); |
| 186 | + |
185 | 187 | // EditPage wants to parse its stuff from a WebRequest |
186 | 188 | // That interface kind of sucks, but it's workable |
187 | 189 | $reqArr = array( |