Index: branches/ApiEdit_Vodafone/includes/EditPage.php |
— | — | @@ -1,3 +1,4 @@ |
| 2 | + |
2 | 3 | <?php |
3 | 4 | /** |
4 | 5 | * Contains the EditPage class |
— | — | @@ -10,35 +11,33 @@ |
11 | 12 | * interfaces. |
12 | 13 | */ |
13 | 14 | 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 | + |
39 | 38 | # Needed to mantain values in SWITCH attempSave |
40 | 39 | var $matches = array(); |
41 | 40 | |
42 | | - var $mArticle; |
| 41 | + var $mArticle; |
43 | 42 | var $mTitle; |
44 | 43 | var $mMetaData = ''; |
45 | 44 | var $isConflict = false; |
— | — | @@ -90,7 +89,7 @@ |
91 | 90 | $this->editFormTextAfterTools = |
92 | 91 | $this->editFormTextBottom = ""; |
93 | 92 | } |
94 | | - |
| 93 | + |
95 | 94 | /** |
96 | 95 | * Fetch initial editing page content. |
97 | 96 | */ |
— | — | @@ -108,7 +107,7 @@ |
109 | 108 | $text = ''; |
110 | 109 | if( !$this->mTitle->exists() ) { |
111 | 110 | 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. |
113 | 112 | $text = wfMsgWeirdKey ( $this->mTitle->getText() ) ; |
114 | 113 | } else { |
115 | 114 | # If requested, preload some text. |
— | — | @@ -326,7 +325,7 @@ |
327 | 326 | */ |
328 | 327 | function edit() { |
329 | 328 | global $wgOut, $wgUser, $wgRequest, $wgTitle; |
330 | | - |
| 329 | + |
331 | 330 | if ( ! wfRunHooks( 'AlternateEdit', array( &$this ) ) ) |
332 | 331 | return; |
333 | 332 | |
— | — | @@ -427,7 +426,7 @@ |
428 | 427 | # Show applicable editing introductions |
429 | 428 | if( $this->formtype == 'initial' || $this->firsttime ) |
430 | 429 | $this->showIntro(); |
431 | | - |
| 430 | + |
432 | 431 | if( $this->mTitle->isTalkPage() ) { |
433 | 432 | $wgOut->addWikiText( wfMsg( 'talkpagetext' ) ); |
434 | 433 | } |
— | — | @@ -455,7 +454,7 @@ |
456 | 455 | wfProfileOut( $fname ); |
457 | 456 | return; |
458 | 457 | } |
459 | | - if( !$this->mTitle->getArticleId() ) |
| 458 | + if( !$this->mTitle->getArticleId() ) |
460 | 459 | wfRunHooks( 'EditFormPreloadText', array( &$this->textbox1, &$this->mTitle ) ); |
461 | 460 | } |
462 | 461 | |
— | — | @@ -566,7 +565,7 @@ |
567 | 566 | $this->allowBlankSummary = $request->getBool( 'wpIgnoreBlankSummary' ); |
568 | 567 | } |
569 | 568 | |
570 | | - $this->autoSumm = $request->getText( 'wpAutoSummary' ); |
| 569 | + $this->autoSumm = $request->getText( 'wpAutoSummary' ); |
571 | 570 | } else { |
572 | 571 | # Not a posted form? Start with nothing. |
573 | 572 | wfDebug( "$fname: Not a posted form.\n" ); |
— | — | @@ -625,7 +624,7 @@ |
626 | 625 | $this->showDeletionLog( $wgOut ); |
627 | 626 | } |
628 | 627 | } |
629 | | - |
| 628 | + |
630 | 629 | /** |
631 | 630 | * Attempt to show a custom editing introduction, if supplied |
632 | 631 | * |
— | — | @@ -672,7 +671,6 @@ |
673 | 672 | # Check for spam |
674 | 673 | $matches = array(); |
675 | 674 | if ( $wgSpamRegex && preg_match( $wgSpamRegex, $this->textbox1, $matches ) ) { |
676 | | -// $this->spamPage ( $matches[0] ); |
677 | 675 | wfProfileOut( "$fname-checks" ); |
678 | 676 | wfProfileOut( $fname ); |
679 | 677 | return self::AS_SPAM_ERROR; |
— | — | @@ -696,7 +694,6 @@ |
697 | 695 | } |
698 | 696 | if ( $wgUser->isBlockedFrom( $this->mTitle, false ) ) { |
699 | 697 | # Check block state against master, thus 'false'. |
700 | | -// $this->blockedPage(); |
701 | 698 | wfProfileOut( "$fname-checks" ); |
702 | 699 | wfProfileOut( $fname ); |
703 | 700 | return self::AS_BLOCKED_PAGE_FOR_USER; |
— | — | @@ -704,7 +701,6 @@ |
705 | 702 | $this->kblength = (int)(strlen( $this->textbox1 ) / 1024); |
706 | 703 | if ( $this->kblength > $wgMaxArticleSize ) { |
707 | 704 | // Error will be displayed by showEditForm() |
708 | | -// $this->tooBig = true; |
709 | 705 | wfProfileOut( "$fname-checks" ); |
710 | 706 | wfProfileOut( $fname ); |
711 | 707 | return self::AS_CONTENT_TOO_BIG; |
— | — | @@ -712,13 +708,11 @@ |
713 | 709 | |
714 | 710 | if ( !$wgUser->isAllowed('edit') ) { |
715 | 711 | if ( $wgUser->isAnon() ) { |
716 | | -// $this->userNotLoggedInPage(); |
717 | 712 | wfProfileOut( "$fname-checks" ); |
718 | 713 | wfProfileOut( $fname ); |
719 | 714 | return self::AS_READ_ONLY_PAGE_ANON; |
720 | 715 | } |
721 | 716 | else { |
722 | | -// $wgOut->readOnlyPage(); |
723 | 717 | wfProfileOut( "$fname-checks" ); |
724 | 718 | wfProfileOut( $fname ); |
725 | 719 | return self::AS_READ_ONLY_PAGE_LOGGED; |
— | — | @@ -726,13 +720,11 @@ |
727 | 721 | } |
728 | 722 | |
729 | 723 | if ( wfReadOnly() ) { |
730 | | -// $wgOut->readOnlyPage(); |
731 | 724 | wfProfileOut( "$fname-checks" ); |
732 | 725 | wfProfileOut( $fname ); |
733 | 726 | return self::AS_READ_ONLY_PAGE; |
734 | 727 | } |
735 | 728 | if ( $wgUser->pingLimiter() ) { |
736 | | -// $wgOut->rateLimited(); |
737 | 729 | wfProfileOut( "$fname-checks" ); |
738 | 730 | wfProfileOut( $fname ); |
739 | 731 | return self::AS_RATE_LIMITED; |
— | — | @@ -755,14 +747,12 @@ |
756 | 748 | // Late check for create permission, just in case *PARANOIA* |
757 | 749 | if ( !$this->mTitle->userCan( 'create' ) ) { |
758 | 750 | wfDebug( "$fname: no create permission\n" ); |
759 | | -// $this->noCreatePermission(); |
760 | 751 | wfProfileOut( $fname ); |
761 | 752 | return self::AS_NO_CREATE_PERMISSION; |
762 | 753 | } |
763 | 754 | |
764 | 755 | # Don't save a new article if it's blank. |
765 | 756 | if ( ( '' == $this->textbox1 ) ) { |
766 | | -// $wgOut->redirect( $this->mTitle->getFullURL() ); |
767 | 757 | wfProfileOut( $fname ); |
768 | 758 | return self::AS_BLANK_ARTICLE; |
769 | 759 | } |
— | — | @@ -1468,9 +1458,9 @@ |
1469 | 1459 | |
1470 | 1460 | $previewHTML = $parserOutput->getText(); |
1471 | 1461 | $wgOut->addParserOutputNoText( $parserOutput ); |
1472 | | - |
| 1462 | + |
1473 | 1463 | # 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() ) ); |
1475 | 1465 | |
1476 | 1466 | foreach ( $parserOutput->getTemplates() as $ns => $template) |
1477 | 1467 | foreach ( array_keys( $template ) as $dbk) |
— | — | @@ -1589,7 +1579,6 @@ |
1590 | 1580 | // This is the revision the editor started from |
1591 | 1581 | $baseRevision = Revision::loadFromTimestamp( |
1592 | 1582 | $db, $this->mArticle->mTitle, $this->edittime ); |
1593 | | -//$baseRevision=true; |
1594 | 1583 | if( is_null( $baseRevision ) ) { |
1595 | 1584 | wfProfileOut( $fname ); |
1596 | 1585 | return false; |
— | — | @@ -2089,7 +2078,7 @@ |
2090 | 2079 | $wgOut->setPageTitle( wfMsg( 'nocreatetitle' ) ); |
2091 | 2080 | $wgOut->addWikiText( wfMsg( 'nocreatetext' ) ); |
2092 | 2081 | } |
2093 | | - |
| 2082 | + |
2094 | 2083 | /** |
2095 | 2084 | * If there are rows in the deletion log for this page, show them, |
2096 | 2085 | * along with a nice little note for the user |
— | — | @@ -2111,86 +2100,82 @@ |
2112 | 2101 | $out->addWikiText( wfMsg( 'recreate-deleted-warn' ) ); |
2113 | 2102 | $viewer = new LogViewer( $reader ); |
2114 | 2103 | $viewer->showList( $out ); |
2115 | | - $out->addHtml( '</div>' ); |
2116 | | - } |
| 2104 | + $out->addHtml( '</div>' ); |
| 2105 | + } |
2117 | 2106 | } |
2118 | | - |
| 2107 | + |
2119 | 2108 | function processAttemptSave($value) { |
2120 | 2109 | global $wgUser, $wgOut; |
2121 | 2110 | |
2122 | 2111 | switch ($value) |
2123 | 2112 | { |
2124 | 2113 | case self::AS_END: |
2125 | | - //wfProfileOut( $fname ); |
2126 | | - return true; |
| 2114 | + return true; |
2127 | 2115 | |
2128 | | - case self::AS_SUCCESS_UPDATE: |
2129 | | - return false; |
| 2116 | + case self::AS_SUCCESS_UPDATE: |
| 2117 | + return false; |
2130 | 2118 | |
2131 | | - case self::AS_MAX_ARTICLE_SIZE_EXCEDED: |
2132 | | - return true; |
| 2119 | + case self::AS_MAX_ARTICLE_SIZE_EXCEDED: |
| 2120 | + return true; |
2133 | 2121 | |
2134 | | - case self::AS_TEXTBOX_EMPTY: |
2135 | | - return true; |
| 2122 | + case self::AS_TEXTBOX_EMPTY: |
| 2123 | + return true; |
2136 | 2124 | |
2137 | | - case self::AS_SUMMARY_NEEDED: |
2138 | | - return true; |
| 2125 | + case self::AS_SUMMARY_NEEDED: |
| 2126 | + return true; |
2139 | 2127 | |
2140 | | - case self::AS_CONFLICT_DETECTED: |
2141 | | - return true; |
| 2128 | + case self::AS_CONFLICT_DETECTED: |
| 2129 | + return true; |
2142 | 2130 | |
2143 | | - case self::AS_SUCCESS_NEW_ARTICLE: |
2144 | | - return false; |
| 2131 | + case self::AS_SUCCESS_NEW_ARTICLE: |
| 2132 | + return false; |
2145 | 2133 | |
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; |
2149 | 2137 | |
2150 | | - case self::AS_NO_CREATE_PERMISSION; |
2151 | | - $this->noCreatePermission(); |
2152 | | - return; |
| 2138 | + case self::AS_NO_CREATE_PERMISSION; |
| 2139 | + $this->noCreatePermission(); |
| 2140 | + return; |
2153 | 2141 | |
2154 | | - case self::AS_ARTICLE_WAS_DELETED: |
2155 | | - return true; |
| 2142 | + case self::AS_ARTICLE_WAS_DELETED: |
| 2143 | + return true; |
2156 | 2144 | |
2157 | | - case self::AS_RATE_LIMITED: |
2158 | | - $wgOut->rateLimited(); |
2159 | | - return false; |
| 2145 | + case self::AS_RATE_LIMITED: |
| 2146 | + $wgOut->rateLimited(); |
| 2147 | + return false; |
2160 | 2148 | |
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; |
2164 | 2152 | |
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; |
2168 | 2156 | |
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; |
2172 | 2160 | |
2173 | | - case self::AS_CONTENT_TOO_BIG: |
2174 | | - return true; |
| 2161 | + case self::AS_CONTENT_TOO_BIG: |
| 2162 | + return true; |
2175 | 2163 | |
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; |
2179 | 2167 | |
2180 | | - case self::AS_HOOK_ERROR: |
2181 | | - return false; |
| 2168 | + case self::AS_HOOK_ERROR: |
| 2169 | + return false; |
2182 | 2170 | |
2183 | | - case self::AS_HOOK_ERROR_EXPECTED: |
2184 | | - return true; |
| 2171 | + case self::AS_HOOK_ERROR_EXPECTED: |
| 2172 | + return true; |
2185 | 2173 | |
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; |
2189 | 2177 | |
2190 | | - case self::AS_FILTERING: |
2191 | | - return false; |
2192 | | - |
2193 | | -// case DEFAULT: |
2194 | | -// return true; |
| 2178 | + case self::AS_FILTERING: |
| 2179 | + return false; |
2195 | 2180 | } |
2196 | 2181 | } |
2197 | 2182 | } |