Index: branches/apiedit/phase3/includes/Article.php |
— | — | @@ -39,15 +39,14 @@ |
40 | 40 | /** |
41 | 41 | * Constants used by internal components to get rollback results |
42 | 42 | */ |
43 | | - const SUCCESS = 0; |
| 43 | + const SUCCESS = 0; // Operation successful |
44 | 44 | const PERM_DENIED = 1; // Permission denied |
45 | | - const BLOCKED = 2; // User has been blocked |
46 | | - const READONLY = 3; // Wiki is in read-only mode |
| 45 | + const BLOCKED = 2; // User has been blocked |
| 46 | + const READONLY = 3; // Wiki is in read-only mode |
47 | 47 | const BAD_TOKEN = 4; // Invalid token specified |
48 | 48 | const BAD_TITLE = 5; // $this is not a valid Article |
49 | | - const ALREADYROLLED = 6;// Someone else already rolled this back. $info['usertext'] and $info['comment'] will be set |
| 49 | + const ALREADY_ROLLED = 6;// Someone else already rolled this back. $from and $summary will be set |
50 | 50 | const ONLY_AUTHOR = 7; // User is the only author of the page |
51 | | - const EDIT_FAILED = 8; // Article::doEdit() failed. This is a very weird error |
52 | 51 | |
53 | 52 | /** |
54 | 53 | * Constructor and clear the article |
— | — | @@ -1458,19 +1457,16 @@ |
1459 | 1458 | # Clear caches |
1460 | 1459 | Article::onArticleCreate( $this->mTitle ); |
1461 | 1460 | |
1462 | | - wfRunHooks( 'ArticleInsertComplete', array( &$this, &$wgUser, $text, |
1463 | | - $summary, $flags & EDIT_MINOR, |
1464 | | - null, null, &$flags ) ); |
| 1461 | + wfRunHooks( 'ArticleInsertComplete', array( &$this, &$wgUser, $text, $summary, |
| 1462 | + $flags & EDIT_MINOR, null, null, &$flags, $revision ) ); |
1465 | 1463 | } |
1466 | 1464 | |
1467 | 1465 | if ( $good && !( $flags & EDIT_DEFER_UPDATES ) ) { |
1468 | 1466 | wfDoUpdates(); |
1469 | 1467 | } |
1470 | 1468 | |
1471 | | - wfRunHooks( 'ArticleSaveComplete', |
1472 | | - array( &$this, &$wgUser, $text, |
1473 | | - $summary, $flags & EDIT_MINOR, |
1474 | | - null, null, &$flags ) ); |
| 1469 | + wfRunHooks( 'ArticleSaveComplete', array( &$this, &$wgUser, $text, $summary, |
| 1470 | + $flags & EDIT_MINOR, null, null, &$flags, $revision ) ); |
1475 | 1471 | |
1476 | 1472 | wfProfileOut( __METHOD__ ); |
1477 | 1473 | return $good; |
— | — | @@ -2119,7 +2115,8 @@ |
2120 | 2116 | 'ar_text_id' => 'rev_text_id', |
2121 | 2117 | 'ar_text' => '\'\'', // Be explicit to appease |
2122 | 2118 | 'ar_flags' => '\'\'', // MySQL's "strict mode"... |
2123 | | - 'ar_len' => 'rev_len' |
| 2119 | + 'ar_len' => 'rev_len', |
| 2120 | + 'ar_page' => $id |
2124 | 2121 | ), array( |
2125 | 2122 | 'page_id' => $id, |
2126 | 2123 | 'page_id = rev_page' |
— | — | @@ -2171,17 +2168,26 @@ |
2172 | 2169 | return true; |
2173 | 2170 | } |
2174 | 2171 | |
2175 | | - /** Backend rollback implementation. UI logic is in rollback() |
| 2172 | + /** |
| 2173 | + * Roll back the most recent consecutive set of edits to a page |
| 2174 | + * from the same user; fails if there are no eligible edits to |
| 2175 | + * roll back to, e.g. user is the sole contributor |
| 2176 | + * |
2176 | 2177 | * @param string $fromP - Name of the user whose edits to rollback. |
| 2178 | + * @param string $summary - Custom summary. Set to default summary if empty. |
2177 | 2179 | * @param string $token - Rollback token. |
2178 | 2180 | * @param bool $bot - If true, mark all reverted edits as bot. |
2179 | | - * @param string $newComment - Custom summary. Set to default summary if empty. |
2180 | | - * @param array $info - Reference to associative array that will be set to contain the revision ID, edit summary, etc. |
| 2181 | + * |
| 2182 | + * @param array $resultDetails contains result-specific dict of additional values |
| 2183 | + * ALREADY_ROLLED : 'current' (rev) |
| 2184 | + * SUCCESS : 'summary' (str), 'current' (rev), 'target' (rev) |
| 2185 | + * |
2181 | 2186 | * @return self::SUCCESS on succes, self::* on failure |
2182 | 2187 | */ |
2183 | | - public function doRollback($fromP, $token, $bot = false, $newComment = "", &$info = NULL) { |
| 2188 | + public function doRollback( $fromP, $summary, $token, $bot, &$resultDetails ) { |
2184 | 2189 | global $wgUser, $wgUseRCPatrol; |
2185 | | - |
| 2190 | + $resultDetails = null; |
| 2191 | + |
2186 | 2192 | if( $wgUser->isAllowed( 'rollback' ) ) { |
2187 | 2193 | if( $wgUser->isBlocked() ) { |
2188 | 2194 | return self::BLOCKED; |
— | — | @@ -2189,19 +2195,15 @@ |
2190 | 2196 | } else { |
2191 | 2197 | return self::PERM_DENIED; |
2192 | 2198 | } |
2193 | | - |
| 2199 | + |
2194 | 2200 | if ( wfReadOnly() ) { |
2195 | 2201 | return self::READONLY; |
2196 | 2202 | } |
2197 | | - if( !$wgUser->matchEditToken( $token, |
2198 | | - array( $this->mTitle->getPrefixedText(), |
2199 | | - $fromP ) ) ) { |
| 2203 | + if( !$wgUser->matchEditToken( $token, array( $this->mTitle->getPrefixedText(), $fromP ) ) ) |
2200 | 2204 | return self::BAD_TOKEN; |
2201 | | - } |
| 2205 | + |
2202 | 2206 | $dbw = wfGetDB( DB_MASTER ); |
2203 | 2207 | |
2204 | | - # Replace all this user's current edits with the next one down |
2205 | | - |
2206 | 2208 | # Get the last editor |
2207 | 2209 | $current = Revision::newFromTitle( $this->mTitle ); |
2208 | 2210 | if( is_null( $current ) ) { |
— | — | @@ -2211,9 +2213,8 @@ |
2212 | 2214 | |
2213 | 2215 | $from = str_replace( '_', ' ', $fromP ); |
2214 | 2216 | if( $from != $current->getUserText() ) { |
2215 | | - $info['usertext'] = $current->getUserText(); |
2216 | | - $info['comment'] = $current->getComment(); |
2217 | | - return self::ALREADYROLLED; |
| 2217 | + $resultDetails = array( 'current' => $current ); |
| 2218 | + return self::ALREADY_ROLLED; |
2218 | 2219 | } |
2219 | 2220 | |
2220 | 2221 | # Get the last edit not by this guy |
— | — | @@ -2234,7 +2235,6 @@ |
2235 | 2236 | return self::ONLY_AUTHOR; |
2236 | 2237 | } |
2237 | 2238 | |
2238 | | - // If the reverted edits should be marked bot or patrolled, do so |
2239 | 2239 | $set = array(); |
2240 | 2240 | if ( $bot ) { |
2241 | 2241 | # Mark all reverted edits as bot |
— | — | @@ -2257,86 +2257,88 @@ |
2258 | 2258 | |
2259 | 2259 | # Get the edit summary |
2260 | 2260 | $target = Revision::newFromId( $s->rev_id ); |
2261 | | - if(empty($newComment)) |
2262 | | - $newComment = wfMsgForContent( 'revertpage', $target->getUserText(), $from ); |
| 2261 | + if( empty( $summary ) ) |
| 2262 | + $summary = wfMsgForContent( 'revertpage', $target->getUserText(), $from ); |
2263 | 2263 | |
2264 | | - # Save it! |
| 2264 | + # Save |
2265 | 2265 | $flags = EDIT_UPDATE | EDIT_MINOR; |
2266 | | - if($bot) |
| 2266 | + if( $bot ) |
2267 | 2267 | $flags |= EDIT_FORCE_BOT; |
2268 | | - if(!$this->doEdit( $target->getText(), $newComment, $flags)) |
2269 | | - return self::EDIT_FAILED; |
| 2268 | + $this->doEdit( $target->getText(), $summary, $flags ); |
2270 | 2269 | |
2271 | | - if(is_null($info)) |
2272 | | - // Save time |
2273 | | - return self::SUCCESS; |
2274 | | - |
2275 | | - $info['title'] = $this->mTitle->getPrefixedText(); |
2276 | | - $info['pageid'] = $current->getPage(); |
2277 | | - $info['summary'] = $newComment; |
2278 | | - // NOTE: If the rollback turned out to be a null edit, revid and old_revid will be equal |
2279 | | - $info['revid'] = $this->mTitle->getLatestRevID(); // The revid of your rollback |
2280 | | - $info['old_revid'] = $current->getId(); // The revid of the last edit before your rollback |
2281 | | - $info['last_revid'] = $s->rev_id; // The revid of the last edit that was not rolled back |
2282 | | - $info['user'] = $fromP; // The name of the victim |
2283 | | - $info['userid'] = $user; // And their userid |
2284 | | - $info['to'] = $target->getUserText(); // The user whose last version was reverted to |
2285 | | - if($bot) |
2286 | | - $info['bot'] = ""; |
| 2270 | + $resultDetails = array( |
| 2271 | + 'summary' => $summary, |
| 2272 | + 'current' => $current, |
| 2273 | + 'target' => $target |
| 2274 | + ); |
2287 | 2275 | return self::SUCCESS; |
2288 | 2276 | } |
2289 | 2277 | |
2290 | | - /** UI entry point for rollbacks. Relies on doRollback() to do the hard work */ |
| 2278 | + /** |
| 2279 | + * User interface for rollback operations |
| 2280 | + */ |
2291 | 2281 | function rollback() { |
2292 | 2282 | global $wgUser, $wgOut, $wgRequest, $wgUseRCPatrol; |
2293 | 2283 | |
2294 | | - // Basically, we just call doRollback() and interpret its return value |
2295 | | - $info = array(); |
2296 | | - $retval = $this->doRollback($wgRequest->getVal('from'), $wgRequest->getVal('token'), $wgRequest->getBool('bot'), |
2297 | | - $wgRequest->getText('summary'), &$info); |
2298 | | - switch($retval) |
2299 | | - { |
2300 | | - default: |
2301 | | - throw new MWException( "Unknown retval $retval" ); |
| 2284 | + $details = null; |
| 2285 | + $result = $this->doRollback( |
| 2286 | + $wgRequest->getVal( 'from' ), |
| 2287 | + $wgRequest->getText( 'summary' ), |
| 2288 | + $wgRequest->getVal( 'token' ), |
| 2289 | + $wgRequest->getBool( 'bot' ), |
| 2290 | + $details |
| 2291 | + ); |
| 2292 | + |
| 2293 | + switch( $result ) { |
| 2294 | + case self::BLOCKED: |
| 2295 | + $wgOut->blockedPage(); |
2302 | 2296 | break; |
2303 | | - case self::SUCCESS: |
2304 | | - case self::EDIT_FAILED: // Is ignored |
2305 | | - $wgOut->setPagetitle( wfMsg( 'actioncomplete' ) ); |
2306 | | - $wgOut->setRobotpolicy( 'noindex,nofollow' ); |
2307 | | - $wgOut->addHTML( '<h2>' . htmlspecialchars( $info['summary'] ) . "</h2>\n<hr />\n" ); |
2308 | | - $this->doRedirect(true); |
2309 | | - $wgOut->returnToMain(false); |
2310 | | - break; |
2311 | 2297 | case self::PERM_DENIED: |
2312 | | - $wgOut->permissionRequired('rollback'); |
| 2298 | + $wgOut->permissionRequired( 'rollback' ); |
2313 | 2299 | break; |
2314 | | - case self::BLOCKED: |
2315 | | - $wgOut->blockedPage(); |
2316 | | - break; |
2317 | 2300 | case self::READONLY: |
2318 | | - $wgOut->readOnlyPage($this->getContent()); |
| 2301 | + $wgOut->readOnlyPage( $this->getContent() ); |
2319 | 2302 | break; |
2320 | 2303 | case self::BAD_TOKEN: |
2321 | | - $wgOut->setPageTitle(wfMsg('rollbackfailed')); |
2322 | | - $wgOut->addWikiText(wfMsg('sessionfailure')); |
| 2304 | + $wgOut->setPageTitle( wfMsg( 'rollbackfailed' ) ); |
| 2305 | + $wgOut->addWikiText( wfMsg( 'sessionfailure' ) ); |
2323 | 2306 | break; |
2324 | 2307 | case self::BAD_TITLE: |
2325 | | - $wgOut->addHTML(wfMsg('notanarticle')); |
| 2308 | + $wgOut->addHtml( wfMsg( 'notanarticle' ) ); |
2326 | 2309 | break; |
2327 | | - case self::ALREADYROLLED: |
2328 | | - $wgOut->setPageTitle(wfMsg('rollbackfailed')); |
2329 | | - $wgOut->addWikiText(wfMsg('alreadyrolled', |
2330 | | - htmlspecialchars($this->mTitle->getPrefixedText()), |
2331 | | - htmlspecialchars($wgRequest->getVal('from')), |
2332 | | - htmlspecialchars($info['usertext']))); |
2333 | | - if($info['comment'] != '') |
2334 | | - $wgOut->addHTML(wfMsg('editcomment', |
2335 | | - $wgUser->getSkin()->formatComment($info['comment']))); |
| 2310 | + case self::ALREADY_ROLLED: |
| 2311 | + $current = $details['current']; |
| 2312 | + $wgOut->setPageTitle( wfMsg( 'rollbackfailed' ) ); |
| 2313 | + $wgOut->addWikiText( |
| 2314 | + wfMsg( 'alreadyrolled', |
| 2315 | + htmlspecialchars( $this->mTitle->getPrefixedText() ), |
| 2316 | + htmlspecialchars( $wgRequest->getVal( 'from' ) ), |
| 2317 | + htmlspecialchars( $current->getUserText() ) |
| 2318 | + ) |
| 2319 | + ); |
| 2320 | + if( $current->getComment() != '' ) { |
| 2321 | + $wgOut->addHtml( wfMsg( 'editcomment', |
| 2322 | + $wgUser->getSkin()->formatComment( $current->getComment() ) ) ); |
| 2323 | + } |
2336 | 2324 | break; |
2337 | 2325 | case self::ONLY_AUTHOR: |
2338 | | - $wgOut->setPageTitle(wfMsg('rollbackfailed')); |
2339 | | - $wgOut->addHTML(wfMsg('cantrollback')); |
| 2326 | + $wgOut->setPageTitle( wfMsg( 'rollbackfailed' ) ); |
| 2327 | + $wgOut->addHtml( wfMsg( 'cantrollback' ) ); |
2340 | 2328 | break; |
| 2329 | + case self::SUCCESS: |
| 2330 | + $current = $details['current']; |
| 2331 | + $target = $details['target']; |
| 2332 | + $wgOut->setPageTitle( wfMsg( 'actioncomplete' ) ); |
| 2333 | + $wgOut->setRobotPolicy( 'noindex,nofollow' ); |
| 2334 | + $old = $wgUser->getSkin()->userLink( $current->getUser(), $current->getUserText() ) |
| 2335 | + . $wgUser->getSkin()->userToolLinks( $current->getUser(), $current->getUserText() ); |
| 2336 | + $new = $wgUser->getSkin()->userLink( $target->getUser(), $target->getUserText() ) |
| 2337 | + . $wgUser->getSkin()->userToolLinks( $target->getUser(), $target->getUserText() ); |
| 2338 | + $wgOut->addHtml( wfMsgExt( 'rollback-success', array( 'parse', 'replaceafter' ), $old, $new ) ); |
| 2339 | + $wgOut->returnToMain( false, $this->mTitle ); |
| 2340 | + break; |
| 2341 | + default: |
| 2342 | + throw new MWException( __METHOD__ . ": Unknown return value `{$retval}`" ); |
2341 | 2343 | } |
2342 | 2344 | } |
2343 | 2345 | |
— | — | @@ -2803,16 +2805,22 @@ |
2804 | 2806 | $page = $this->mTitle->getSubjectPage(); |
2805 | 2807 | |
2806 | 2808 | $wgOut->setPagetitle( $page->getPrefixedText() ); |
2807 | | - $wgOut->setSubtitle( wfMsg( 'infosubtitle' )); |
| 2809 | + $wgOut->setPageTitleActionText( wfMsg( 'info_short' ) ); |
| 2810 | + $wgOut->setSubtitle( wfMsg( 'infosubtitle' ) ); |
2808 | 2811 | |
2809 | | - # first, see if the page exists at all. |
2810 | | - $exists = $page->getArticleId() != 0; |
2811 | | - if( !$exists ) { |
2812 | | - if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) { |
2813 | | - $wgOut->addHTML(wfMsgWeirdKey ( $this->mTitle->getText() ) ); |
| 2812 | + if( !$this->mTitle->exists() ) { |
| 2813 | + $wgOut->addHtml( '<div class="noarticletext">' ); |
| 2814 | + if( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) { |
| 2815 | + // This doesn't quite make sense; the user is asking for |
| 2816 | + // information about the _page_, not the message... -- RC |
| 2817 | + $wgOut->addHtml( htmlspecialchars( wfMsgWeirdKey( $this->mTitle->getText() ) ) ); |
2814 | 2818 | } else { |
2815 | | - $wgOut->addHTML(wfMsg( $wgUser->isLoggedIn() ? 'noarticletext' : 'noarticletextanon' ) ); |
| 2819 | + $msg = $wgUser->isLoggedIn() |
| 2820 | + ? 'noarticletext' |
| 2821 | + : 'noarticletextanon'; |
| 2822 | + $wgOut->addHtml( wfMsgExt( $msg, 'parse' ) ); |
2816 | 2823 | } |
| 2824 | + $wgOut->addHtml( '</div>' ); |
2817 | 2825 | } else { |
2818 | 2826 | $dbr = wfGetDB( DB_SLAVE ); |
2819 | 2827 | $wl_clause = array( |
Index: branches/apiedit/phase3/includes/api/ApiQueryUserInfo.php |
— | — | @@ -0,0 +1,134 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/* |
| 5 | + * Created on July 30, 2007 |
| 6 | + * |
| 7 | + * API for MediaWiki 1.8+ |
| 8 | + * |
| 9 | + * Copyright (C) 2007 Yuri Astrakhan <Firstname><Lastname>@gmail.com |
| 10 | + * |
| 11 | + * This program is free software; you can redistribute it and/or modify |
| 12 | + * it under the terms of the GNU General Public License as published by |
| 13 | + * the Free Software Foundation; either version 2 of the License, or |
| 14 | + * (at your option) any later version. |
| 15 | + * |
| 16 | + * This program is distributed in the hope that it will be useful, |
| 17 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 | + * GNU General Public License for more details. |
| 20 | + * |
| 21 | + * You should have received a copy of the GNU General Public License along |
| 22 | + * with this program; if not, write to the Free Software Foundation, Inc., |
| 23 | + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 24 | + * http://www.gnu.org/copyleft/gpl.html |
| 25 | + */ |
| 26 | + |
| 27 | +if (!defined('MEDIAWIKI')) { |
| 28 | + // Eclipse helper - will be ignored in production |
| 29 | + require_once ('ApiQueryBase.php'); |
| 30 | +} |
| 31 | + |
| 32 | +/** |
| 33 | + * Query module to get information about the currently logged-in user |
| 34 | + * |
| 35 | + * @addtogroup API |
| 36 | + */ |
| 37 | +class ApiQueryUserInfo extends ApiQueryBase { |
| 38 | + |
| 39 | + public function __construct($query, $moduleName) { |
| 40 | + parent :: __construct($query, $moduleName, 'ui'); |
| 41 | + } |
| 42 | + |
| 43 | + public function execute() { |
| 44 | + |
| 45 | + global $wgUser; |
| 46 | + |
| 47 | + $params = $this->extractRequestParams(); |
| 48 | + $result = $this->getResult(); |
| 49 | + |
| 50 | + $vals = array(); |
| 51 | + $vals['name'] = $wgUser->getName(); |
| 52 | + |
| 53 | + if( $wgUser->isAnon() ) $vals['anon'] = ''; |
| 54 | + |
| 55 | + if (!is_null($params['prop'])) { |
| 56 | + $prop = array_flip($params['prop']); |
| 57 | + if (isset($prop['blockinfo'])) { |
| 58 | + if ($wgUser->isBlocked()) { |
| 59 | + $id = $wgUser->blockedBy(); |
| 60 | + $vals['blockedby'] = is_numeric($id) ? User::whoIs($id) : $id; |
| 61 | + $vals['blockreason'] = $wgUser->blockedFor(); |
| 62 | + } |
| 63 | + } |
| 64 | + if (isset($prop['hasmsg']) && $wgUser->getNewtalk()) { |
| 65 | + $vals['messages'] = ''; |
| 66 | + } |
| 67 | + if (isset($prop['groups'])) { |
| 68 | + $vals['groups'] = $wgUser->getGroups(); |
| 69 | + $result->setIndexedTagName($vals['groups'], 'g'); // even if empty |
| 70 | + } |
| 71 | + if (isset($prop['rights'])) { |
| 72 | + $vals['rights'] = $wgUser->getRights(); |
| 73 | + $result->setIndexedTagName($vals['rights'], 'r'); // even if empty |
| 74 | + } |
| 75 | + } |
| 76 | + |
| 77 | + if (!empty($params['option'])) { |
| 78 | + foreach( $params['option'] as $option ) { |
| 79 | + if (empty($option)) |
| 80 | + $this->dieUsage('Empty value is not allowed for the option parameter', 'option'); |
| 81 | + $vals['options'][$option] = $wgUser->getOption($option); |
| 82 | + } |
| 83 | + } |
| 84 | + |
| 85 | + $result->addValue(null, $this->getModuleName(), $vals); |
| 86 | + } |
| 87 | + |
| 88 | + protected function getAllowedParams() { |
| 89 | + return array ( |
| 90 | + 'prop' => array ( |
| 91 | + ApiBase :: PARAM_DFLT => NULL, |
| 92 | + ApiBase :: PARAM_ISMULTI => true, |
| 93 | + ApiBase :: PARAM_TYPE => array ( |
| 94 | + 'blockinfo', |
| 95 | + 'hasmsg', |
| 96 | + 'groups', |
| 97 | + 'rights', |
| 98 | + )), |
| 99 | + 'option' => array ( |
| 100 | + ApiBase :: PARAM_DFLT => NULL, |
| 101 | + ApiBase :: PARAM_ISMULTI => true, |
| 102 | + ), |
| 103 | + ); |
| 104 | + } |
| 105 | + |
| 106 | + protected function getParamDescription() { |
| 107 | + return array ( |
| 108 | + 'prop' => array( |
| 109 | + 'What pieces of information to include', |
| 110 | + ' blockinfo - tags if the user is blocked, by whom, and for what reason', |
| 111 | + ' hasmsg - adds a tag "message" if user has pending messages', |
| 112 | + ' groups - lists all the groups the current user belongs to', |
| 113 | + ' rights - lists of all rights the current user has', |
| 114 | + ), |
| 115 | + 'option' => 'A list of user preference options to get', |
| 116 | + ); |
| 117 | + } |
| 118 | + |
| 119 | + protected function getDescription() { |
| 120 | + return 'Get information about the current user'; |
| 121 | + } |
| 122 | + |
| 123 | + protected function getExamples() { |
| 124 | + return array ( |
| 125 | + 'api.php?action=query&meta=userinfo', |
| 126 | + 'api.php?action=query&meta=userinfo&uiprop=blockinfo|groups|rights|hasmsg', |
| 127 | + 'api.php?action=query&meta=userinfo&uioption=rememberpassword', |
| 128 | + ); |
| 129 | + } |
| 130 | + |
| 131 | + public function getVersion() { |
| 132 | + return __CLASS__ . ': $Id: ApiQueryUserInfo.php 24494 2007-07-31 17:53:37Z yurik $'; |
| 133 | + } |
| 134 | +} |
| 135 | + |
Property changes on: branches/apiedit/phase3/includes/api/ApiQueryUserInfo.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 136 | + native |
Index: branches/apiedit/phase3/includes/SpecialUndelete.php |
— | — | @@ -23,6 +23,7 @@ |
24 | 24 | */ |
25 | 25 | class PageArchive { |
26 | 26 | protected $title; |
| 27 | + var $fileStatus; |
27 | 28 | |
28 | 29 | function __construct( $title ) { |
29 | 30 | if( is_null( $title ) ) { |
— | — | @@ -269,10 +270,10 @@ |
270 | 271 | $dbw = wfGetDB(DB_MASTER); |
271 | 272 | $dbw->begin(); |
272 | 273 | $restoreAll = empty( $timestamps ) && empty( $fileVersions ); |
273 | | - |
| 274 | + |
274 | 275 | $restoreText = $restoreAll || !empty( $timestamps ); |
275 | 276 | $restoreFiles = $restoreAll || !empty( $fileVersions ); |
276 | | - |
| 277 | + |
277 | 278 | if( $restoreFiles && $this->title->getNamespace() == NS_IMAGE ) { |
278 | 279 | $img = wfLocalFile( $this->title ); |
279 | 280 | $this->fileStatus = $img->restore( $fileVersions ); |
— | — | @@ -280,7 +281,7 @@ |
281 | 282 | } else { |
282 | 283 | $filesRestored = 0; |
283 | 284 | } |
284 | | - |
| 285 | + |
285 | 286 | if( $restoreText ) { |
286 | 287 | $textRestored = $this->undeleteRevisions( $timestamps ); |
287 | 288 | if($textRestored < 0) // It must be one of UNDELETE_* |
— | — | @@ -291,7 +292,7 @@ |
292 | 293 | } else { |
293 | 294 | $textRestored = 0; |
294 | 295 | } |
295 | | - |
| 296 | + |
296 | 297 | // Touch the log! |
297 | 298 | global $wgContLang; |
298 | 299 | $log = new LogPage( 'delete' ); |
— | — | @@ -461,6 +462,7 @@ |
462 | 463 | return $restored; |
463 | 464 | } |
464 | 465 | |
| 466 | + function getFileStatus() { return $this->fileStatus; } |
465 | 467 | } |
466 | 468 | |
467 | 469 | /** |
— | — | @@ -744,8 +746,13 @@ |
745 | 747 | $logViewer = new LogViewer( |
746 | 748 | new LogReader( |
747 | 749 | new FauxRequest( |
748 | | - array( 'page' => $this->mTargetObj->getPrefixedText(), |
749 | | - 'type' => 'delete' ) ) ) ); |
| 750 | + array( |
| 751 | + 'page' => $this->mTargetObj->getPrefixedText(), |
| 752 | + 'type' => 'delete' |
| 753 | + ) |
| 754 | + ) |
| 755 | + ), LogViewer::NO_ACTION_LINK |
| 756 | + ); |
750 | 757 | $logViewer->showList( $wgOut ); |
751 | 758 | |
752 | 759 | if( $this->mAllowed && ( $haveRevisions || $haveFiles ) ) { |
— | — | @@ -818,7 +825,7 @@ |
819 | 826 | } |
820 | 827 | |
821 | 828 | if( $haveFiles ) { |
822 | | - $wgOut->addHtml( "<h2>" . wfMsgHtml( 'imghistory' ) . "</h2>\n" ); |
| 829 | + $wgOut->addHtml( "<h2>" . wfMsgHtml( 'filehist' ) . "</h2>\n" ); |
823 | 830 | $wgOut->addHtml( "<ul>" ); |
824 | 831 | while( $row = $files->fetchObject() ) { |
825 | 832 | $ts = wfTimestamp( TS_MW, $row->fa_timestamp ); |
— | — | @@ -868,15 +875,24 @@ |
869 | 876 | $this->mTargetTimestamp, |
870 | 877 | $this->mComment, |
871 | 878 | $this->mFileVersions ); |
872 | | - |
| 879 | + |
873 | 880 | if( is_array($ok) ) { |
874 | 881 | $skin = $wgUser->getSkin(); |
875 | 882 | $link = $skin->makeKnownLinkObj( $this->mTargetObj ); |
876 | 883 | $wgOut->addHtml( wfMsgWikiHtml( 'undeletedpage', $link ) ); |
877 | | - return true; |
| 884 | + } else { |
| 885 | + $wgOut->showFatalError( wfMsg( "cannotundelete" ) ); |
878 | 886 | } |
| 887 | + |
| 888 | + // Show file deletion warnings and errors |
| 889 | + $status = $archive->getFileStatus(); |
| 890 | + if ( $status && !$status->isGood() ) { |
| 891 | + $wgOut->addWikiText( $status->getWikiText( 'undelete-error-short', 'undelete-error-long' ) ); |
| 892 | + } |
| 893 | + } else { |
| 894 | + $wgOut->showFatalError( wfMsg( "cannotundelete" ) ); |
879 | 895 | } |
880 | | - $wgOut->showFatalError( wfMsg( "cannotundelete" ) ); |
| 896 | + |
881 | 897 | return false; |
882 | 898 | } |
883 | 899 | } |