http://www.mediawiki.org/wiki/Special:Code/MediaWiki/66598
Revision: 66598 Author: aaron Date: 2010-05-18 01:36:52 +0000 (Tue, 18 May 2010) Log Message: ----------- * Removed API call to setWasPosted() * Fixed and refactored PageStabilityForm title handling Modified Paths: -------------- trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php trunk/extensions/FlaggedRevs/api/ApiStabilize.php trunk/extensions/FlaggedRevs/forms/PageStabilityForm.php trunk/extensions/FlaggedRevs/specialpages/Stabilization_body.php Modified: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php =================================================================== --- trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php 2010-05-18 01:11:53 UTC (rev 66597) +++ trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php 2010-05-18 01:36:52 UTC (rev 66598) @@ -2225,7 +2225,7 @@ return true; // user cannot change anything } $form = new PageStabilityProtectForm(); - $form->setTarget( $article->getTitle() ); // target page + $form->setPage( $article->getTitle() ); // target page $permission = $wgRequest->getVal( 'mwStabilityLevel' ); if ( $permission == "none" ) { $permission = ''; // 'none' => '' Modified: trunk/extensions/FlaggedRevs/api/ApiStabilize.php =================================================================== --- trunk/extensions/FlaggedRevs/api/ApiStabilize.php 2010-05-18 01:11:53 UTC (rev 66597) +++ trunk/extensions/FlaggedRevs/api/ApiStabilize.php 2010-05-18 01:36:52 UTC (rev 66598) @@ -51,7 +51,7 @@ ? new PageStabilityProtectForm() : new PageStabilityGeneralForm(); - $form->setTarget( $title ); # Our target page + $form->setPage( $title ); # Our target page $form->setWatchThis( $params['watch'] ); # Watch this page $form->setReason( $params['reason'] ); # Reason $form->setReasonSelection( 'other' ); # Reason dropdown @@ -75,7 +75,6 @@ $restriction = ''; // 'none' => '' } $form->setAutoreview( $restriction ); # Autoreview restriction - $form->setWasPosted( true ); // already validated $form->ready(); $status = $form->submit(); // true/error message key Modified: trunk/extensions/FlaggedRevs/forms/PageStabilityForm.php =================================================================== --- trunk/extensions/FlaggedRevs/forms/PageStabilityForm.php 2010-05-18 01:11:53 UTC (rev 66597) +++ trunk/extensions/FlaggedRevs/forms/PageStabilityForm.php 2010-05-18 01:36:52 UTC (rev 66598) @@ -13,7 +13,7 @@ abstract class PageStabilityForm { /* Form parameters which can be user given */ - protected $target = null; # Target page text + protected $page = false; # Target page obj protected $watchThis = null; # Watch checkbox protected $reviewThis = null; # Auto-review option... protected $reason = ''; # Custom/extra reason @@ -23,19 +23,17 @@ protected $override = -1; # Default version protected $autoreview = ''; # Autoreview restrictions... - protected $page = false; # Target page obj (of $target) protected $oldConfig = array(); # Old page config protected $oldExpiry = ''; # Old page config expiry (GMT) protected $inputLock = 0; # Disallow bad submissions - public function getTarget() { - return $this->target; + public function getPage() { + return $this->page; } - public function setTarget( $value ) { - $this->trySet( $this->target, $value ); - $this->page = Title::newFromURL( $this->target ); + public function setPage( Title $value ) { + $this->trySet( $this->page, $value ); } public function getWatchThis() { @@ -165,7 +163,6 @@ * @return mixed (true on success, error string on failure) */ protected function checkTarget() { - $this->page = Title::newFromURL( $this->target ); if ( is_null( $this->page ) ) { return 'stabilize_page_invalid'; } elseif ( !$this->page->exists() ) { @@ -185,17 +182,6 @@ } /* - * Gets the target page Obj - * @return mixed (Title or null) - */ - public function getPage() { - if ( !$this->inputLock ) { - throw new MWException( __CLASS__ . " input fields not set yet.\n"); - } - return $this->page; - } - - /* * Gets the current config expiry in GMT (or 'infinite') * @return string */ Modified: trunk/extensions/FlaggedRevs/specialpages/Stabilization_body.php =================================================================== --- trunk/extensions/FlaggedRevs/specialpages/Stabilization_body.php 2010-05-18 01:11:53 UTC (rev 66597) +++ trunk/extensions/FlaggedRevs/specialpages/Stabilization_body.php 2010-05-18 01:36:52 UTC (rev 66598) @@ -35,11 +35,16 @@ # Set page title $this->setHeaders(); $this->sk = $wgUser->getSkin(); - + $this->form = new PageStabilityGeneralForm(); $form = $this->form; // convenience # Target page - $form->setTarget( $wgRequest->getVal( 'page', $par ) ); + $title = Title::newFromURL( $wgRequest->getVal( 'page', $par ) ); + if ( !$title ) { + $wgOut->showErrorPage( 'notargettitle', 'notargettext' ); + return; + } + $form->setPage( $title ); # Watch checkbox $form->setWatchThis( (bool)$wgRequest->getCheck( 'wpWatchthis' ) ); # Get auto-review option... @@ -57,11 +62,6 @@ $form->setAutoreview( $wgRequest->getVal( 'mwProtect-level-autoreview' ) ); $status = $form->ready(); // params all set - if ( $status === 'stabilize_page_invalid' ) { - $wgOut->showErrorPage( 'notargettitle', 'notargettext' ); - return; - } - $title = $form->getPage(); // convenience if ( $status === 'stabilize_page_notexists' ) { $wgOut->addWikiText( wfMsg( 'stabilization-notexists', $title->getPrefixedText() ) ); _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs