Index: trunk/phase3/maintenance/language/messages.inc |
— | — | @@ -1182,6 +1182,7 @@ |
1183 | 1183 | 'protect-summary-cascade', |
1184 | 1184 | 'protect-expiring', |
1185 | 1185 | 'protect-cascade', |
| 1186 | + 'protect-robotspolicy', |
1186 | 1187 | 'restriction-type', |
1187 | 1188 | 'restriction-level', |
1188 | 1189 | 'minimum-size', |
Index: trunk/phase3/includes/ProtectionForm.php |
— | — | @@ -43,6 +43,7 @@ |
44 | 44 | // but the db allows multiples separated by commas. |
45 | 45 | $this->mRestrictions[$action] = implode( '', $this->mTitle->getRestrictions( $action ) ); |
46 | 46 | } |
| 47 | + $this->mRestrictions['robots'] = implode( ',', $this->mTitle->getRestrictions( 'robots' ) ); |
47 | 48 | |
48 | 49 | $this->mCascade = $this->mTitle->areRestrictionsCascading(); |
49 | 50 | |
— | — | @@ -72,9 +73,17 @@ |
73 | 74 | $this->mRestrictions[$action] = $val; |
74 | 75 | } |
75 | 76 | } |
| 77 | + |
| 78 | + // Read checkboxex only if user is allowed to change robots policy, otherwise keep previous policy |
| 79 | + if ( $wgUser->isAllowed( 'editrobots' ) ) { |
| 80 | + $robotspolicy = $wgRequest->getBool( 'mwProtect-robots-noindex' ) ? 'noindex' : 'index'; |
| 81 | + $robotspolicy .= $wgRequest->getBool( 'mwProtect-robots-nofollow' ) ? ',nofollow' : ',follow'; |
| 82 | + // 'index,follow' is default, no need to set this explicitly at this point; is done at Article::View |
| 83 | + $this->mRestrictions['robots'] = ( $robotspolicy == 'index,follow' ) ? '' : $robotspolicy; |
| 84 | + } |
76 | 85 | } |
77 | 86 | } |
78 | | - |
| 87 | + |
79 | 88 | function execute() { |
80 | 89 | global $wgRequest; |
81 | 90 | if( $wgRequest->wasPosted() ) { |
— | — | @@ -199,7 +208,7 @@ |
200 | 209 | } |
201 | 210 | |
202 | 211 | function buildForm() { |
203 | | - global $wgUser; |
| 212 | + global $wgUser, $wgRestrictionTypes; |
204 | 213 | |
205 | 214 | $out = ''; |
206 | 215 | if( !$this->disabled ) { |
— | — | @@ -223,14 +232,17 @@ |
224 | 233 | $out .= "<tr>\n"; |
225 | 234 | foreach( $this->mRestrictions as $action => $required ) { |
226 | 235 | /* Not all languages have V_x <-> N_x relation */ |
227 | | - $out .= "<th>" . wfMsgHtml( 'restriction-' . $action ) . "</th>\n"; |
| 236 | + if ( in_array( $action, $wgRestrictionTypes ) ) |
| 237 | + $out .= "<th>" . wfMsgHtml( 'restriction-' . $action ) . "</th>\n"; |
228 | 238 | } |
229 | 239 | $out .= "</tr>\n"; |
230 | 240 | $out .= "<tr>\n"; |
231 | 241 | foreach( $this->mRestrictions as $action => $selected ) { |
232 | | - $out .= "<td>\n"; |
233 | | - $out .= $this->buildSelector( $action, $selected ); |
234 | | - $out .= "</td>\n"; |
| 242 | + if ( in_array( $action, $wgRestrictionTypes ) ) { |
| 243 | + $out .= "<td>\n"; |
| 244 | + $out .= $this->buildSelector( $action, $selected ); |
| 245 | + $out .= "</td>\n"; |
| 246 | + } |
235 | 247 | } |
236 | 248 | $out .= "</tr>\n"; |
237 | 249 | |
— | — | @@ -249,6 +261,7 @@ |
250 | 262 | if( !$this->disabled ) |
251 | 263 | $out .= '<tr><td></td><td>' . $this->buildWatchInput() . "</td></tr>\n"; |
252 | 264 | |
| 265 | + $out .= $this->buildRobotsInput(); |
253 | 266 | $out .= $this->buildExpiryInput(); |
254 | 267 | |
255 | 268 | if( !$this->disabled ) { |
— | — | @@ -317,6 +330,20 @@ |
318 | 331 | return $ci; |
319 | 332 | } |
320 | 333 | |
| 334 | + function buildRobotsInput() { |
| 335 | + global $wgUser; |
| 336 | + $robotsallowed = $wgUser->isAllowed( 'editrobots' ) ? array() : array( 'disabled' => 'disabled' ); |
| 337 | + $noindexset = ( isset( $this->mRestrictions['robots'] ) && strstr( $this->mRestrictions['robots'], 'noindex' ) ) ? true : false; |
| 338 | + $nofollowset = ( isset( $this->mRestrictions['robots'] ) && strstr( $this->mRestrictions['robots'], 'nofollow' ) ) ? true : false; |
| 339 | + $ret = "<tr><td align=\"right\">"; |
| 340 | + $ret .= Xml::label( wfMsg( 'protect-robotspolicy' ), 'mwProtect-robots-label' ); |
| 341 | + $ret .= "</td> <td align=\"left\" width=\"60\">"; |
| 342 | + $ret .= Xml::checkLabel( 'noindex', 'mwProtect-robots-noindex', 'mwProtect-robots-noindex', $noindexset, $robotsallowed ); |
| 343 | + $ret .= Xml::checkLabel( 'nofollow', 'mwProtect-robots-nofollow', 'mwProtect-robots-nofollow', $nofollowset, $robotsallowed ); |
| 344 | + $ret .= "</td></tr>"; |
| 345 | + return $ret; |
| 346 | + } |
| 347 | + |
321 | 348 | function buildExpiryInput() { |
322 | 349 | $attribs = array( 'id' => 'expires' ) + $this->disabledAttrib; |
323 | 350 | return '<tr>' |
Index: trunk/phase3/includes/Article.php |
— | — | @@ -641,6 +641,8 @@ |
642 | 642 | } elseif( isset( $wgNamespaceRobotPolicies[$ns] ) ) { |
643 | 643 | # Honour customised robot policies for this namespace |
644 | 644 | $policy = $wgNamespaceRobotPolicies[$ns]; |
| 645 | + } elseif ( $this->mTitle->getRestrictions( 'robots' ) ) { |
| 646 | + $policy = implode( ',', $this->mTitle->getRestrictions( 'robots' ) ); |
645 | 647 | } else { |
646 | 648 | # Default to encourage indexing and following links |
647 | 649 | $policy = 'index,follow'; |
— | — | @@ -1675,6 +1677,7 @@ |
1676 | 1678 | $current = array(); |
1677 | 1679 | foreach( $wgRestrictionTypes as $action ) |
1678 | 1680 | $current[$action] = implode( '', $this->mTitle->getRestrictions( $action ) ); |
| 1681 | + $current['robots'] = implode( '', $this->mTitle->getRestrictions( 'robots' ) ); |
1679 | 1682 | |
1680 | 1683 | $current = Article::flattenRestrictions( $current ); |
1681 | 1684 | $updated = Article::flattenRestrictions( $limit ); |
— | — | @@ -1710,7 +1713,9 @@ |
1711 | 1714 | foreach( $limit as $action => $restrictions ) { |
1712 | 1715 | # Check if the group level required to edit also can protect pages |
1713 | 1716 | # Otherwise, people who cannot normally protect can "protect" pages via transclusion |
1714 | | - $cascade = ( $cascade && isset($wgGroupPermissions[$restrictions]['protect']) && $wgGroupPermissions[$restrictions]['protect'] ); |
| 1717 | + if ( in_array( $restrictions, $wgRestrictionTypes ) ) { |
| 1718 | + $cascade = ( $cascade && isset($wgGroupPermissions[$restrictions]['protect']) && $wgGroupPermissions[$restrictions]['protect'] ); |
| 1719 | + } |
1715 | 1720 | } |
1716 | 1721 | |
1717 | 1722 | $cascade_description = ''; |
Index: trunk/phase3/includes/Title.php |
— | — | @@ -940,6 +940,9 @@ |
941 | 941 | if( $this->getNamespace() == NS_SPECIAL ) |
942 | 942 | return true; |
943 | 943 | |
| 944 | + if ( $this->getRestrictions( 'robots' ) && $this->getRestrictions( 'robots' ) != '' ) |
| 945 | + return true; |
| 946 | + |
944 | 947 | # Check regular protection levels |
945 | 948 | if( $action == 'edit' || $action == '' ) { |
946 | 949 | $r = $this->getRestrictions( 'edit' ); |
Index: trunk/phase3/includes/DefaultSettings.php |
— | — | @@ -1063,6 +1063,7 @@ |
1064 | 1064 | $wgGroupPermissions['sysop']['upload_by_url'] = true; |
1065 | 1065 | $wgGroupPermissions['sysop']['ipblock-exempt'] = true; |
1066 | 1066 | $wgGroupPermissions['sysop']['blockemail'] = true; |
| 1067 | +$wgGroupPermissions['sysop']['editrobots'] = true; |
1067 | 1068 | |
1068 | 1069 | // Permission to change users' group assignments |
1069 | 1070 | $wgGroupPermissions['bureaucrat']['userrights'] = true; |
Index: trunk/phase3/languages/messages/MessagesEn.php |
— | — | @@ -1839,6 +1839,7 @@ |
1840 | 1840 | 'protect-summary-cascade' => 'cascading', |
1841 | 1841 | 'protect-expiring' => 'expires $1 (UTC)', |
1842 | 1842 | 'protect-cascade' => 'Protect pages included in this page (cascading protection)', |
| 1843 | +'protect-robotspolicy' => 'Robot policy:', |
1843 | 1844 | 'restriction-type' => 'Permission:', |
1844 | 1845 | 'restriction-level' => 'Restriction level:', |
1845 | 1846 | 'minimum-size' => 'Min size', |
Index: trunk/phase3/languages/messages/MessagesDe.php |
— | — | @@ -1442,6 +1442,7 @@ |
1443 | 1443 | 'protect-summary-cascade' => 'kaskadierend', |
1444 | 1444 | 'protect-expiring' => 'bis $1 (UTC)', |
1445 | 1445 | 'protect-cascade' => 'Kaskadierende Sperre – alle in diese Seite eingebundenen Vorlagen werden ebenfalls gesperrt.', |
| 1446 | +'protect-robotspolicy' => 'Anweisung für Suchroboter:', |
1446 | 1447 | 'restriction-type' => 'Schutzstatus', |
1447 | 1448 | 'restriction-level' => 'Schutzhöhe', |
1448 | 1449 | 'minimum-size' => 'Mindestgröße:', |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -95,6 +95,8 @@ |
96 | 96 | * Throw a showstopper exception when a hook function fails to return a value. |
97 | 97 | Forgetting to give a 'true' return value is a very common error which tends |
98 | 98 | to cause hard-to-track-down interactions between extensions. |
| 99 | +* (bug 9415) Added options to Special:Protect to allow setting of per-page robot |
| 100 | + policies. This can be done only by users with the 'editrobots' permission |
99 | 101 | |
100 | 102 | == Bugfixes since 1.10 == |
101 | 103 | |