Merge "Make sure Parsoid doesn't get snobbish and treat non-html5 tags badly."
[lhc/web/wiklou.git] / includes / SpecialPage.php
index da150c9..5412d65 100644 (file)
@@ -302,7 +302,7 @@ class SpecialPage {
         *     be displayed by the default execute() method, without the global function ever
         *     being called.
         *
-        *     If you override execute(), you can recover the default behaviour with userCanExecute()
+        *     If you override execute(), you can recover the default behavior with userCanExecute()
         *     and displayRestrictionError()
         *
         * @param $name String: name of the special page, as seen in links and URLs
@@ -598,7 +598,7 @@ class SpecialPage {
         *
         * @param $subPage string|null
         */
-       public final function run( $subPage ) {
+       final public function run( $subPage ) {
                /**
                 * Gets called before @see SpecialPage::execute.
                 *
@@ -695,7 +695,7 @@ class SpecialPage {
         * also the name that will be listed in Special:Specialpages
         *
         * Derived classes can override this, but usually it is easier to keep the
-        * default behaviour. Messages can be added at run-time, see
+        * default behavior. Messages can be added at run-time, see
         * MessageCache.php.
         *
         * @return String
@@ -846,10 +846,61 @@ class SpecialPage {
 
                foreach ( $wgFeedClasses as $format => $class ) {
                        $theseParams = $params + array( 'feedformat' => $format );
-                       $url = $feedTemplate . wfArrayToCGI( $theseParams );
+                       $url = $feedTemplate . wfArrayToCgi( $theseParams );
                        $this->getOutput()->addFeedLink( $format, $url );
                }
        }
+
+       /**
+        * Get the group that the special page belongs in on Special:SpecialPage
+        * Use this method, instead of getGroupName to allow customization
+        * of the group name from the wiki side
+        *
+        * @return string Group of this special page
+        * @since 1.21
+        */
+       public function getFinalGroupName() {
+               global $wgSpecialPageGroups;
+               $name = $this->getName();
+               $group = '-';
+
+               // Allow overridding the group from the wiki side
+               $msg = $this->msg( 'specialpages-specialpagegroup-' . strtolower( $name ) )->inContentLanguage();
+               if ( !$msg->isBlank() ) {
+                       $group = $msg->text();
+               } else {
+                       // Than use the group from this object
+                       $group = $this->getGroupName();
+
+                       // Group '-' is used as default to have the chance to determine,
+                       // if the special pages overriddes this method,
+                       // if not overridden, $wgSpecialPageGroups is checked for b/c
+                       if ( $group === '-' && isset( $wgSpecialPageGroups[$name] ) ) {
+                               $group = $wgSpecialPageGroups[$name];
+                       }
+               }
+
+               // never give '-' back, change to 'other'
+               if ( $group === '-' ) {
+                       $group = 'other';
+               }
+
+               return $group;
+       }
+
+       /**
+        * Under which header this special page is listed in Special:SpecialPages
+        * See messages 'specialpages-group-*' for valid names
+        * This method defaults to group 'other'
+        *
+        * @return string
+        * @since 1.21
+        */
+       protected function getGroupName() {
+               // '-' used here to determine, if this group is overridden or has a hardcoded 'other'
+               // Needed for b/c in getFinalGroupName
+               return '-';
+       }
 }
 
 /**
@@ -863,7 +914,7 @@ abstract class FormSpecialPage extends SpecialPage {
         * Get an HTMLForm descriptor array
         * @return Array
         */
-       protected abstract function getFormFields();
+       abstract protected function getFormFields();
 
        /**
         * Add pre- or post-text to the form
@@ -889,7 +940,7 @@ abstract class FormSpecialPage extends SpecialPage {
        }
 
        /**
-        * Get the HTMLForm to control behaviour
+        * Get the HTMLForm to control behavior
         * @return HTMLForm|null
         */
        protected function getForm() {
@@ -904,7 +955,7 @@ abstract class FormSpecialPage extends SpecialPage {
                // Retain query parameters (uselang etc)
                $params = array_diff_key(
                        $this->getRequest()->getQueryValues(), array( 'title' => null ) );
-               $form->addHiddenField( 'redirectparams', wfArrayToCGI( $params ) );
+               $form->addHiddenField( 'redirectparams', wfArrayToCgi( $params ) );
 
                $form->addPreText( $this->preText() );
                $form->addPostText( $this->postText() );
@@ -921,13 +972,13 @@ abstract class FormSpecialPage extends SpecialPage {
         * @param  $data Array
         * @return Bool|Array true for success, false for didn't-try, array of errors on failure
         */
-       public abstract function onSubmit( array $data );
+       abstract public function onSubmit( array $data );
 
        /**
         * Do something exciting on successful processing of the form, most likely to show a
         * confirmation message
         */
-       public abstract function onSuccess();
+       abstract public function onSuccess();
 
        /**
         * Basic SpecialPage workflow: get a form, send it to the user; get some data back,
@@ -1045,7 +1096,7 @@ abstract class RedirectSpecialPage extends UnlistedSpecialPage {
                // Redirect to index.php with query parameters
                } elseif ( $redirect === true ) {
                        global $wgScript;
-                       $url = $wgScript . '?' . wfArrayToCGI( $query );
+                       $url = $wgScript . '?' . wfArrayToCgi( $query );
                        $this->getOutput()->redirect( $url );
                        return $redirect;
                } else {
@@ -1278,7 +1329,7 @@ class SpecialMytalk extends RedirectSpecialArticle {
  */
 class SpecialMycontributions extends RedirectSpecialPage {
        function __construct() {
-               parent::__construct(  'Mycontributions' );
+               parent::__construct( 'Mycontributions' );
                $this->mAllowedRedirectParams = array( 'limit', 'namespace', 'tagfilter',
                        'offset', 'dir', 'year', 'month', 'feed' );
        }