r26144 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r26143‎ | r26144 | r26145 >
Date:08:41, 26 September 2007
Author:ilabarg1
Status:old
Tags:
Comment:
No change on functionality. Changes to make easier merge.
Modified paths:
  • /branches/ApiEdit_Vodafone/includes/EditPage.php (modified) (history)

Diff [purge]

Index: branches/ApiEdit_Vodafone/includes/EditPage.php
@@ -1,3 +1,4 @@
 2+
23 <?php
34 /**
45 * Contains the EditPage class
@@ -10,35 +11,33 @@
1112 * interfaces.
1213 */
1314 class EditPage {
14 - //----------------------------------------
15 - //**** ATTEMPTSAVE CONSTANTS (2xx) value ****
16 - const AS_SUCCESS_UPDATE = 200;
17 - const AS_SUCCESS_NEW_ARTICLE = 201;
18 - const AS_HOOK_ERROR = 210;
19 - const AS_FILTERING = 211;
20 - const AS_HOOK_ERROR_EXPECTED = 212;
21 - const AS_BLOCKED_PAGE_FOR_USER = 215;
22 - const AS_CONTENT_TOO_BIG = 216;
23 - const AS_USER_CANNOT_EDIT = 217;
24 - const AS_READ_ONLY_PAGE_ANON = 218;
25 - const AS_READ_ONLY_PAGE_LOGGED = 219;
26 - const AS_READ_ONLY_PAGE = 220;
27 - const AS_RATE_LIMITED = 221;
28 - const AS_ARTICLE_WAS_DELETED = 222;
29 - const AS_NO_CREATE_PERMISSION = 223;
30 - const AS_BLANK_ARTICLE = 224;
31 - const AS_CONFLICT_DETECTED = 225;
32 - const AS_SUMMARY_NEEDED = 226;
33 - const AS_TEXTBOX_EMPTY = 228;
34 - const AS_MAX_ARTICLE_SIZE_EXCEDED = 229;
35 - const AS_OK = 230;
36 - const AS_END = 231;
37 - const AS_SPAM_ERROR = 232;
38 - //----------------------------------------
 15+ const AS_SUCCESS_UPDATE = 200;
 16+ const AS_SUCCESS_NEW_ARTICLE = 201;
 17+ const AS_HOOK_ERROR = 210;
 18+ const AS_FILTERING = 211;
 19+ const AS_HOOK_ERROR_EXPECTED = 212;
 20+ const AS_BLOCKED_PAGE_FOR_USER = 215;
 21+ const AS_CONTENT_TOO_BIG = 216;
 22+ const AS_USER_CANNOT_EDIT = 217;
 23+ const AS_READ_ONLY_PAGE_ANON = 218;
 24+ const AS_READ_ONLY_PAGE_LOGGED = 219;
 25+ const AS_READ_ONLY_PAGE = 220;
 26+ const AS_RATE_LIMITED = 221;
 27+ const AS_ARTICLE_WAS_DELETED = 222;
 28+ const AS_NO_CREATE_PERMISSION = 223;
 29+ const AS_BLANK_ARTICLE = 224;
 30+ const AS_CONFLICT_DETECTED = 225;
 31+ const AS_SUMMARY_NEEDED = 226;
 32+ const AS_TEXTBOX_EMPTY = 228;
 33+ const AS_MAX_ARTICLE_SIZE_EXCEDED = 229;
 34+ const AS_OK = 230;
 35+ const AS_END = 231;
 36+ const AS_SPAM_ERROR = 232;
 37+
3938 # Needed to mantain values in SWITCH attempSave
4039 var $matches = array();
4140
42 - var $mArticle;
 41+ var $mArticle;
4342 var $mTitle;
4443 var $mMetaData = '';
4544 var $isConflict = false;
@@ -90,7 +89,7 @@
9190 $this->editFormTextAfterTools =
9291 $this->editFormTextBottom = "";
9392 }
94 -
 93+
9594 /**
9695 * Fetch initial editing page content.
9796 */
@@ -108,7 +107,7 @@
109108 $text = '';
110109 if( !$this->mTitle->exists() ) {
111110 if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
112 - # If this is a system message, get the default text.
 111+ # If this is a system message, get the default text.
113112 $text = wfMsgWeirdKey ( $this->mTitle->getText() ) ;
114113 } else {
115114 # If requested, preload some text.
@@ -326,7 +325,7 @@
327326 */
328327 function edit() {
329328 global $wgOut, $wgUser, $wgRequest, $wgTitle;
330 -
 329+
331330 if ( ! wfRunHooks( 'AlternateEdit', array( &$this ) ) )
332331 return;
333332
@@ -427,7 +426,7 @@
428427 # Show applicable editing introductions
429428 if( $this->formtype == 'initial' || $this->firsttime )
430429 $this->showIntro();
431 -
 430+
432431 if( $this->mTitle->isTalkPage() ) {
433432 $wgOut->addWikiText( wfMsg( 'talkpagetext' ) );
434433 }
@@ -455,7 +454,7 @@
456455 wfProfileOut( $fname );
457456 return;
458457 }
459 - if( !$this->mTitle->getArticleId() )
 458+ if( !$this->mTitle->getArticleId() )
460459 wfRunHooks( 'EditFormPreloadText', array( &$this->textbox1, &$this->mTitle ) );
461460 }
462461
@@ -566,7 +565,7 @@
567566 $this->allowBlankSummary = $request->getBool( 'wpIgnoreBlankSummary' );
568567 }
569568
570 - $this->autoSumm = $request->getText( 'wpAutoSummary' );
 569+ $this->autoSumm = $request->getText( 'wpAutoSummary' );
571570 } else {
572571 # Not a posted form? Start with nothing.
573572 wfDebug( "$fname: Not a posted form.\n" );
@@ -625,7 +624,7 @@
626625 $this->showDeletionLog( $wgOut );
627626 }
628627 }
629 -
 628+
630629 /**
631630 * Attempt to show a custom editing introduction, if supplied
632631 *
@@ -672,7 +671,6 @@
673672 # Check for spam
674673 $matches = array();
675674 if ( $wgSpamRegex && preg_match( $wgSpamRegex, $this->textbox1, $matches ) ) {
676 -// $this->spamPage ( $matches[0] );
677675 wfProfileOut( "$fname-checks" );
678676 wfProfileOut( $fname );
679677 return self::AS_SPAM_ERROR;
@@ -696,7 +694,6 @@
697695 }
698696 if ( $wgUser->isBlockedFrom( $this->mTitle, false ) ) {
699697 # Check block state against master, thus 'false'.
700 -// $this->blockedPage();
701698 wfProfileOut( "$fname-checks" );
702699 wfProfileOut( $fname );
703700 return self::AS_BLOCKED_PAGE_FOR_USER;
@@ -704,7 +701,6 @@
705702 $this->kblength = (int)(strlen( $this->textbox1 ) / 1024);
706703 if ( $this->kblength > $wgMaxArticleSize ) {
707704 // Error will be displayed by showEditForm()
708 -// $this->tooBig = true;
709705 wfProfileOut( "$fname-checks" );
710706 wfProfileOut( $fname );
711707 return self::AS_CONTENT_TOO_BIG;
@@ -712,13 +708,11 @@
713709
714710 if ( !$wgUser->isAllowed('edit') ) {
715711 if ( $wgUser->isAnon() ) {
716 -// $this->userNotLoggedInPage();
717712 wfProfileOut( "$fname-checks" );
718713 wfProfileOut( $fname );
719714 return self::AS_READ_ONLY_PAGE_ANON;
720715 }
721716 else {
722 -// $wgOut->readOnlyPage();
723717 wfProfileOut( "$fname-checks" );
724718 wfProfileOut( $fname );
725719 return self::AS_READ_ONLY_PAGE_LOGGED;
@@ -726,13 +720,11 @@
727721 }
728722
729723 if ( wfReadOnly() ) {
730 -// $wgOut->readOnlyPage();
731724 wfProfileOut( "$fname-checks" );
732725 wfProfileOut( $fname );
733726 return self::AS_READ_ONLY_PAGE;
734727 }
735728 if ( $wgUser->pingLimiter() ) {
736 -// $wgOut->rateLimited();
737729 wfProfileOut( "$fname-checks" );
738730 wfProfileOut( $fname );
739731 return self::AS_RATE_LIMITED;
@@ -755,14 +747,12 @@
756748 // Late check for create permission, just in case *PARANOIA*
757749 if ( !$this->mTitle->userCan( 'create' ) ) {
758750 wfDebug( "$fname: no create permission\n" );
759 -// $this->noCreatePermission();
760751 wfProfileOut( $fname );
761752 return self::AS_NO_CREATE_PERMISSION;
762753 }
763754
764755 # Don't save a new article if it's blank.
765756 if ( ( '' == $this->textbox1 ) ) {
766 -// $wgOut->redirect( $this->mTitle->getFullURL() );
767757 wfProfileOut( $fname );
768758 return self::AS_BLANK_ARTICLE;
769759 }
@@ -1468,9 +1458,9 @@
14691459
14701460 $previewHTML = $parserOutput->getText();
14711461 $wgOut->addParserOutputNoText( $parserOutput );
1472 -
 1462+
14731463 # ParserOutput might have altered the page title, so reset it
1474 - $wgOut->setPageTitle( wfMsg( 'editing', $this->mTitle->getPrefixedText() ) );
 1464+ $wgOut->setPageTitle( wfMsg( 'editing', $this->mTitle->getPrefixedText() ) );
14751465
14761466 foreach ( $parserOutput->getTemplates() as $ns => $template)
14771467 foreach ( array_keys( $template ) as $dbk)
@@ -1589,7 +1579,6 @@
15901580 // This is the revision the editor started from
15911581 $baseRevision = Revision::loadFromTimestamp(
15921582 $db, $this->mArticle->mTitle, $this->edittime );
1593 -//$baseRevision=true;
15941583 if( is_null( $baseRevision ) ) {
15951584 wfProfileOut( $fname );
15961585 return false;
@@ -2089,7 +2078,7 @@
20902079 $wgOut->setPageTitle( wfMsg( 'nocreatetitle' ) );
20912080 $wgOut->addWikiText( wfMsg( 'nocreatetext' ) );
20922081 }
2093 -
 2082+
20942083 /**
20952084 * If there are rows in the deletion log for this page, show them,
20962085 * along with a nice little note for the user
@@ -2111,86 +2100,82 @@
21122101 $out->addWikiText( wfMsg( 'recreate-deleted-warn' ) );
21132102 $viewer = new LogViewer( $reader );
21142103 $viewer->showList( $out );
2115 - $out->addHtml( '</div>' );
2116 - }
 2104+ $out->addHtml( '</div>' );
 2105+ }
21172106 }
2118 -
 2107+
21192108 function processAttemptSave($value) {
21202109 global $wgUser, $wgOut;
21212110
21222111 switch ($value)
21232112 {
21242113 case self::AS_END:
2125 - //wfProfileOut( $fname );
2126 - return true;
 2114+ return true;
21272115
2128 - case self::AS_SUCCESS_UPDATE:
2129 - return false;
 2116+ case self::AS_SUCCESS_UPDATE:
 2117+ return false;
21302118
2131 - case self::AS_MAX_ARTICLE_SIZE_EXCEDED:
2132 - return true;
 2119+ case self::AS_MAX_ARTICLE_SIZE_EXCEDED:
 2120+ return true;
21332121
2134 - case self::AS_TEXTBOX_EMPTY:
2135 - return true;
 2122+ case self::AS_TEXTBOX_EMPTY:
 2123+ return true;
21362124
2137 - case self::AS_SUMMARY_NEEDED:
2138 - return true;
 2125+ case self::AS_SUMMARY_NEEDED:
 2126+ return true;
21392127
2140 - case self::AS_CONFLICT_DETECTED:
2141 - return true;
 2128+ case self::AS_CONFLICT_DETECTED:
 2129+ return true;
21422130
2143 - case self::AS_SUCCESS_NEW_ARTICLE:
2144 - return false;
 2131+ case self::AS_SUCCESS_NEW_ARTICLE:
 2132+ return false;
21452133
2146 - case self::AS_BLANK_ARTICLE:
2147 - $wgOut->redirect( $this->mTitle->getFullURL() );
2148 - return false;
 2134+ case self::AS_BLANK_ARTICLE:
 2135+ $wgOut->redirect( $this->mTitle->getFullURL() );
 2136+ return false;
21492137
2150 - case self::AS_NO_CREATE_PERMISSION;
2151 - $this->noCreatePermission();
2152 - return;
 2138+ case self::AS_NO_CREATE_PERMISSION;
 2139+ $this->noCreatePermission();
 2140+ return;
21532141
2154 - case self::AS_ARTICLE_WAS_DELETED:
2155 - return true;
 2142+ case self::AS_ARTICLE_WAS_DELETED:
 2143+ return true;
21562144
2157 - case self::AS_RATE_LIMITED:
2158 - $wgOut->rateLimited();
2159 - return false;
 2145+ case self::AS_RATE_LIMITED:
 2146+ $wgOut->rateLimited();
 2147+ return false;
21602148
2161 - case self::AS_READ_ONLY_PAGE:
2162 - $wgOut->readOnlyPage();
2163 - return false;
 2149+ case self::AS_READ_ONLY_PAGE:
 2150+ $wgOut->readOnlyPage();
 2151+ return false;
21642152
2165 - case self::AS_READ_ONLY_PAGE_LOGGED:
2166 - $wgOut->readOnlyPage();
2167 - return false;
 2153+ case self::AS_READ_ONLY_PAGE_LOGGED:
 2154+ $wgOut->readOnlyPage();
 2155+ return false;
21682156
2169 - case self::AS_READ_ONLY_PAGE_ANON:
2170 - $this->userNotLoggedInPage();
2171 - return false;
 2157+ case self::AS_READ_ONLY_PAGE_ANON:
 2158+ $this->userNotLoggedInPage();
 2159+ return false;
21722160
2173 - case self::AS_CONTENT_TOO_BIG:
2174 - return true;
 2161+ case self::AS_CONTENT_TOO_BIG:
 2162+ return true;
21752163
2176 - case self::AS_BLOCKED_PAGE_FOR_USER:
2177 - $this->blockedPage();
2178 - return false;
 2164+ case self::AS_BLOCKED_PAGE_FOR_USER:
 2165+ $this->blockedPage();
 2166+ return false;
21792167
2180 - case self::AS_HOOK_ERROR:
2181 - return false;
 2168+ case self::AS_HOOK_ERROR:
 2169+ return false;
21822170
2183 - case self::AS_HOOK_ERROR_EXPECTED:
2184 - return true;
 2171+ case self::AS_HOOK_ERROR_EXPECTED:
 2172+ return true;
21852173
2186 - case self::AS_SPAM_ERROR:
2187 - $this->spamPage ( $matches[0] );
2188 - return false;
 2174+ case self::AS_SPAM_ERROR:
 2175+ $this->spamPage ( $matches[0] );
 2176+ return false;
21892177
2190 - case self::AS_FILTERING:
2191 - return false;
2192 -
2193 -// case DEFAULT:
2194 -// return true;
 2178+ case self::AS_FILTERING:
 2179+ return false;
21952180 }
21962181 }
21972182 }

Status & tagging log