Index: trunk/phase3/includes/parser/Parser.php |
— | — | @@ -3411,11 +3411,7 @@ |
3412 | 3412 | global $wgMaxTocLevel, $wgContLang; |
3413 | 3413 | |
3414 | 3414 | $doNumberHeadings = $this->mOptions->getNumberHeadings(); |
3415 | | - if( !$this->mTitle->quickUserCan( 'edit' ) ) { |
3416 | | - $showEditLink = 0; |
3417 | | - } else { |
3418 | | - $showEditLink = $this->mOptions->getEditSection(); |
3419 | | - } |
| 3415 | + $showEditLink = $this->mOptions->getEditSection(); |
3420 | 3416 | |
3421 | 3417 | # Inhibit editsection links if requested in the page |
3422 | 3418 | if ( isset( $this->mDoubleUnderscores['noeditsection'] ) ) { |
— | — | @@ -3609,10 +3605,20 @@ |
3610 | 3606 | if( $isTemplate ) { |
3611 | 3607 | # Put a T flag in the section identifier, to indicate to extractSections() |
3612 | 3608 | # that sections inside <includeonly> should be counted. |
3613 | | - $editlink = $sk->doEditSectionLink(Title::newFromText( $titleText ), "T-$sectionIndex"); |
| 3609 | + $titleObj = Title::newFromText( $titleText ); |
| 3610 | + $section = "T-$sectionIndex"; |
| 3611 | + $tooltip = $headlineHint; |
3614 | 3612 | } else { |
3615 | | - $editlink = $sk->doEditSectionLink($this->mTitle, $sectionIndex, $headlineHint); |
| 3613 | + $titleObj = $this->mTitle; |
| 3614 | + $section = $sectionIndex; |
| 3615 | + $tooltip = ''; |
3616 | 3616 | } |
| 3617 | + // Use Title::getUserPermissionsErrorsInternal() so that we can pass our User object |
| 3618 | + if( $titleObj->getUserPermissionsErrorsInternal( 'edit', $this->mOptions->getUser(), false ) === array() ){ |
| 3619 | + $editlink = $sk->doEditSectionLink( $titleObj, $section, $tooltip ); |
| 3620 | + } else { |
| 3621 | + $editlink = ''; |
| 3622 | + } |
3617 | 3623 | } else { |
3618 | 3624 | $editlink = ''; |
3619 | 3625 | } |
— | — | @@ -4042,7 +4048,6 @@ |
4043 | 4049 | * $options is a bit field, RLH_FOR_UPDATE to select for update |
4044 | 4050 | */ |
4045 | 4051 | function replaceLinkHolders( &$text, $options = 0 ) { |
4046 | | - global $wgUser; |
4047 | 4052 | global $wgContLang; |
4048 | 4053 | |
4049 | 4054 | $fname = 'Parser::replaceLinkHolders'; |
— | — | @@ -4058,7 +4063,7 @@ |
4059 | 4064 | wfProfileIn( $fname.'-check' ); |
4060 | 4065 | $dbr = wfGetDB( DB_SLAVE ); |
4061 | 4066 | $page = $dbr->tableName( 'page' ); |
4062 | | - $threshold = $wgUser->getOption('stubthreshold'); |
| 4067 | + $threshold = $this->mOptions->getStubThreshold(); |
4063 | 4068 | |
4064 | 4069 | # Sort by namespace |
4065 | 4070 | asort( $this->mLinkHolders['namespaces'] ); |
Index: trunk/phase3/includes/parser/ParserOptions.php |
— | — | @@ -5,32 +5,32 @@ |
6 | 6 | * @todo document |
7 | 7 | * @ingroup Parser |
8 | 8 | */ |
9 | | -class ParserOptions |
10 | | -{ |
| 9 | +class ParserOptions { |
11 | 10 | # All variables are supposed to be private in theory, although in practise this is not the case. |
12 | | - var $mUseTeX; # Use texvc to expand <math> tags |
13 | | - var $mUseDynamicDates; # Use DateFormatter to format dates |
14 | | - var $mInterwikiMagic; # Interlanguage links are removed and returned in an array |
15 | | - var $mAllowExternalImages; # Allow external images inline |
16 | | - var $mAllowExternalImagesFrom; # If not, any exception? |
17 | | - var $mSkin; # Reference to the preferred skin |
18 | | - var $mDateFormat; # Date format index |
19 | | - var $mEditSection; # Create "edit section" links |
20 | | - var $mNumberHeadings; # Automatically number headings |
21 | | - var $mAllowSpecialInclusion; # Allow inclusion of special pages |
22 | | - var $mTidy; # Ask for tidy cleanup |
23 | | - var $mInterfaceMessage; # Which lang to call for PLURAL and GRAMMAR |
24 | | - var $mTargetLanguage; # Overrides above setting with arbitrary language |
25 | | - var $mMaxIncludeSize; # Maximum size of template expansions, in bytes |
26 | | - var $mMaxPPNodeCount; # Maximum number of nodes touched by PPFrame::expand() |
27 | | - var $mMaxPPExpandDepth; # Maximum recursion depth in PPFrame::expand() |
28 | | - var $mMaxTemplateDepth; # Maximum recursion depth for templates within templates |
29 | | - var $mRemoveComments; # Remove HTML comments. ONLY APPLIES TO PREPROCESS OPERATIONS |
30 | | - var $mTemplateCallback; # Callback for template fetching |
31 | | - var $mEnableLimitReport; # Enable limit report in an HTML comment on output |
32 | | - var $mTimestamp; # Timestamp used for {{CURRENTDAY}} etc. |
| 11 | + var $mUseTeX; //!< Use texvc to expand <math> tags |
| 12 | + var $mUseDynamicDates; //!< Use DateFormatter to format dates |
| 13 | + var $mInterwikiMagic; //!< Interlanguage links are removed and returned in an array |
| 14 | + var $mAllowExternalImages; //!< Allow external images inline |
| 15 | + var $mAllowExternalImagesFrom; //!< If not, any exception? |
| 16 | + var $mSkin; //!< Reference to the preferred skin |
| 17 | + var $mDateFormat; //!< Date format index |
| 18 | + var $mEditSection; //!< Create "edit section" links |
| 19 | + var $mNumberHeadings; //!< Automatically number headings |
| 20 | + var $mStubThreshold; //!< Treshold for marking pages as "stub" |
| 21 | + var $mAllowSpecialInclusion; //!< Allow inclusion of special pages |
| 22 | + var $mTidy; //!< Ask for tidy cleanup |
| 23 | + var $mInterfaceMessage; //!< Which lang to call for PLURAL and GRAMMAR |
| 24 | + var $mTargetLanguage; //!< Overrides above setting with arbitrary language |
| 25 | + var $mMaxIncludeSize; //!< Maximum size of template expansions, in bytes |
| 26 | + var $mMaxPPNodeCount; //!< Maximum number of nodes touched by PPFrame::expand() |
| 27 | + var $mMaxPPExpandDepth; //!< Maximum recursion depth in PPFrame::expand() |
| 28 | + var $mMaxTemplateDepth; //!< Maximum recursion depth for templates within templates |
| 29 | + var $mRemoveComments; //!< Remove HTML comments. ONLY APPLIES TO PREPROCESS OPERATIONS |
| 30 | + var $mTemplateCallback; //!< Callback for template fetching |
| 31 | + var $mEnableLimitReport; //!< Enable limit report in an HTML comment on output |
| 32 | + var $mTimestamp; //!< Timestamp used for {{CURRENTDAY}} etc. |
33 | 33 | |
34 | | - var $mUser; # Stored user object, just used to initialise the skin |
| 34 | + var $mUser; //!< Stored user object |
35 | 35 | |
36 | 36 | function getUseTeX() { return $this->mUseTeX; } |
37 | 37 | function getUseDynamicDates() { return $this->mUseDynamicDates; } |
— | — | @@ -39,6 +39,7 @@ |
40 | 40 | function getAllowExternalImagesFrom() { return $this->mAllowExternalImagesFrom; } |
41 | 41 | function getEditSection() { return $this->mEditSection; } |
42 | 42 | function getNumberHeadings() { return $this->mNumberHeadings; } |
| 43 | + function getStubThreshold() { return $this->mStubThreshold; } |
43 | 44 | function getAllowSpecialInclusion() { return $this->mAllowSpecialInclusion; } |
44 | 45 | function getTidy() { return $this->mTidy; } |
45 | 46 | function getInterfaceMessage() { return $this->mInterfaceMessage; } |
— | — | @@ -50,6 +51,10 @@ |
51 | 52 | function getTemplateCallback() { return $this->mTemplateCallback; } |
52 | 53 | function getEnableLimitReport() { return $this->mEnableLimitReport; } |
53 | 54 | |
| 55 | + function getUser() { |
| 56 | + return $this->mUser; |
| 57 | + } |
| 58 | + |
54 | 59 | function getSkin() { |
55 | 60 | if ( !isset( $this->mSkin ) ) { |
56 | 61 | $this->mSkin = $this->mUser->getSkin(); |
— | — | @@ -79,6 +84,7 @@ |
80 | 85 | function setDateFormat( $x ) { return wfSetVar( $this->mDateFormat, $x ); } |
81 | 86 | function setEditSection( $x ) { return wfSetVar( $this->mEditSection, $x ); } |
82 | 87 | function setNumberHeadings( $x ) { return wfSetVar( $this->mNumberHeadings, $x ); } |
| 88 | + function setStubThreshold( $x ) { return wfSetVar( $this->mStubThreshold, $x ); } |
83 | 89 | function setAllowSpecialInclusion( $x ) { return wfSetVar( $this->mAllowSpecialInclusion, $x ); } |
84 | 90 | function setTidy( $x ) { return wfSetVar( $this->mTidy, $x); } |
85 | 91 | function setSkin( $x ) { $this->mSkin = $x; } |
— | — | @@ -98,7 +104,7 @@ |
99 | 105 | |
100 | 106 | /** |
101 | 107 | * Get parser options |
102 | | - * @static |
| 108 | + * @param $user User |
103 | 109 | */ |
104 | 110 | static function newFromUser( $user ) { |
105 | 111 | return new ParserOptions( $user ); |
— | — | @@ -109,8 +115,9 @@ |
110 | 116 | global $wgUseTeX, $wgUseDynamicDates, $wgInterwikiMagic, $wgAllowExternalImages; |
111 | 117 | global $wgAllowExternalImagesFrom, $wgAllowSpecialInclusion, $wgMaxArticleSize; |
112 | 118 | global $wgMaxPPNodeCount, $wgMaxTemplateDepth, $wgMaxPPExpandDepth; |
113 | | - $fname = 'ParserOptions::initialiseFromUser'; |
114 | | - wfProfileIn( $fname ); |
| 119 | + |
| 120 | + wfProfileIn( __METHOD__ ); |
| 121 | + |
115 | 122 | if ( !$userInput ) { |
116 | 123 | global $wgUser; |
117 | 124 | if ( isset( $wgUser ) ) { |
— | — | @@ -133,6 +140,7 @@ |
134 | 141 | $this->mDateFormat = null; # Deferred |
135 | 142 | $this->mEditSection = true; |
136 | 143 | $this->mNumberHeadings = $user->getOption( 'numberheadings' ); |
| 144 | + $this->mStubThreshold = $user->getOption( 'stubthreshold' ); |
137 | 145 | $this->mAllowSpecialInclusion = $wgAllowSpecialInclusion; |
138 | 146 | $this->mTidy = false; |
139 | 147 | $this->mInterfaceMessage = false; |
— | — | @@ -144,6 +152,7 @@ |
145 | 153 | $this->mRemoveComments = true; |
146 | 154 | $this->mTemplateCallback = array( 'Parser', 'statelessFetchTemplate' ); |
147 | 155 | $this->mEnableLimitReport = false; |
148 | | - wfProfileOut( $fname ); |
| 156 | + |
| 157 | + wfProfileOut( __METHOD__ ); |
149 | 158 | } |
150 | 159 | } |
Index: trunk/phase3/includes/Title.php |
— | — | @@ -1134,7 +1134,7 @@ |
1135 | 1135 | * @param bool $doExpensiveQueries Set this to false to avoid doing unnecessary queries. |
1136 | 1136 | * @return array Array of arrays of the arguments to wfMsg to explain permissions problems. |
1137 | 1137 | */ |
1138 | | - private function getUserPermissionsErrorsInternal( $action, $user, $doExpensiveQueries = true ) { |
| 1138 | + public function getUserPermissionsErrorsInternal( $action, $user, $doExpensiveQueries = true ) { |
1139 | 1139 | wfProfileIn( __METHOD__ ); |
1140 | 1140 | |
1141 | 1141 | $errors = array(); |