X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FSpecialPage.php;h=46d4304820f145bc5e7745a08004b4118728ffb8;hb=e05c4e9df06d68fcd43ce8eb888a0bea71b9dadf;hp=3b3a5ee1cda088c29c88d560ad541e75e11457ae;hpb=7bb29a97ae51ce8c74599871f8e688e72aac2811;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/SpecialPage.php b/includes/SpecialPage.php index 3b3a5ee1cd..46d4304820 100644 --- a/includes/SpecialPage.php +++ b/includes/SpecialPage.php @@ -135,7 +135,7 @@ class SpecialPage { * preferred method is now to add a SpecialPage_initList hook. * @deprecated since 1.18 * - * @param $name String the page to remove + * @param string $name the page to remove */ static function removePage( $name ) { wfDeprecated( __METHOD__, '1.18' ); @@ -145,7 +145,7 @@ class SpecialPage { /** * Check if a given name exist as a special page or as a special page alias * - * @param $name String: name of a special page + * @param string $name name of a special page * @return Boolean: true if a special page exists with this name * @deprecated since 1.18 call SpecialPageFactory method directly */ @@ -253,8 +253,8 @@ class SpecialPage { * Get a localised Title object for a specified special page name * * @param $name String - * @param $subpage String|Bool subpage string, or false to not use a subpage - * @param $fragment String the link fragment (after the "#") + * @param string|Bool $subpage subpage string, or false to not use a subpage + * @param string $fragment the link fragment (after the "#") * @throws MWException * @return Title object */ @@ -271,7 +271,7 @@ class SpecialPage { * Get a localised Title object for a page name with a possibly unvalidated subpage * * @param $name String - * @param $subpage String|Bool subpage string, or false to not use a subpage + * @param string|Bool $subpage subpage string, or false to not use a subpage * @return Title object or null if the page doesn't exist */ public static function getSafeTitleFor( $name, $subpage = false ) { @@ -302,15 +302,15 @@ 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 - * @param $restriction String: user right required, e.g. "block" or "delete" - * @param $listed Bool: whether the page is listed in Special:Specialpages + * @param string $name name of the special page, as seen in links and URLs + * @param string $restriction user right required, e.g. "block" or "delete" + * @param bool $listed whether the page is listed in Special:Specialpages * @param $function Callback|Bool: function called by execute(). By default it is constructed from $name - * @param $file String: file which is included by execute(). It is also constructed from $name by default - * @param $includable Bool: whether the page can be included in normal pages + * @param string $file file which is included by execute(). It is also constructed from $name by default + * @param bool $includable whether the page can be included in normal pages */ public function __construct( $name = '', $restriction = '', $listed = true, @@ -322,12 +322,12 @@ class SpecialPage { /** * Do the real work for the constructor, mainly so __call() can intercept * calls to SpecialPage() - * @param $name String: name of the special page, as seen in links and URLs - * @param $restriction String: user right required, e.g. "block" or "delete" - * @param $listed Bool: whether the page is listed in Special:Specialpages + * @param string $name name of the special page, as seen in links and URLs + * @param string $restriction user right required, e.g. "block" or "delete" + * @param bool $listed whether the page is listed in Special:Specialpages * @param $function Callback|Bool: function called by execute(). By default it is constructed from $name - * @param $file String: file which is included by execute(). It is also constructed from $name by default - * @param $includable Bool: whether the page can be included in normal pages + * @param string $file file which is included by execute(). It is also constructed from $name by default + * @param bool $includable whether the page can be included in normal pages */ private function init( $name, $restriction, $listed, $function, $file, $includable ) { $this->mName = $name; @@ -350,8 +350,8 @@ class SpecialPage { * Use PHP's magic __call handler to get calls to the old PHP4 constructor * because PHP E_STRICT yells at you for having __construct() and SpecialPage() * - * @param $fName String Name of called method - * @param $a Array Arguments to the method + * @param string $fName Name of called method + * @param array $a Arguments to the method * @throws MWException * @deprecated since 1.17, call parent::__construct() */ @@ -670,10 +670,10 @@ class SpecialPage { /** * Outputs a summary message on top of special pages * Per default the message key is the canonical name of the special page - * May be overriden, i.e. by extensions to stick with the naming conventions + * May be overridden, i.e. by extensions to stick with the naming conventions * for message keys: 'extensionname-xxx' * - * @param $summaryMessageKey String: message key of the summary + * @param string $summaryMessageKey message key of the summary */ function outputHeader( $summaryMessageKey = '' ) { global $wgContLang; @@ -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 @@ -827,7 +827,7 @@ class SpecialPage { // RequestContext passes context to wfMessage, and the language is set from // the context, but setting the language for Message class removes the // interface message status, which breaks for example usernameless gender - // invokations. Restore the flag when not including special page in content. + // invocations. Restore the flag when not including special page in content. if ( $this->including() ) { $message->setInterfaceMessageFlag( false ); } @@ -850,6 +850,57 @@ class SpecialPage { $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 overbidding 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 overrides 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 '-'; + } } /** @@ -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() { @@ -932,7 +983,7 @@ abstract class FormSpecialPage extends SpecialPage { /** * Basic SpecialPage workflow: get a form, send it to the user; get some data back, * - * @param $par String Subpage string if one was specified + * @param string $par Subpage string if one was specified */ public function execute( $par ) { $this->setParameter( $par ); @@ -1031,7 +1082,7 @@ abstract class RedirectSpecialPage extends UnlistedSpecialPage { // Query parameters that can be passed through redirects protected $mAllowedRedirectParams = array(); - // Query parameteres added by redirects + // Query parameters added by redirects protected $mAddedRedirectParams = array(); public function execute( $par ) { @@ -1039,7 +1090,7 @@ abstract class RedirectSpecialPage extends UnlistedSpecialPage { $query = $this->getRedirectQuery(); // Redirect to a page title with possible query parameters if ( $redirect instanceof Title ) { - $url = $redirect->getFullUrl( $query ); + $url = $redirect->getFullURL( $query ); $this->getOutput()->redirect( $url ); return $redirect; // Redirect to index.php with query parameters @@ -1049,7 +1100,7 @@ abstract class RedirectSpecialPage extends UnlistedSpecialPage { $this->getOutput()->redirect( $url ); return $redirect; } else { - $class = __CLASS__; + $class = get_class( $this ); throw new MWException( "RedirectSpecialPage $class doesn't redirect!" ); } } @@ -1058,7 +1109,7 @@ abstract class RedirectSpecialPage extends UnlistedSpecialPage { * If the special page is a redirect, then get the Title object it redirects to. * False otherwise. * - * @param $par String Subpage string + * @param string $par Subpage string * @return Title|bool */ abstract public function getRedirect( $par ); @@ -1140,7 +1191,7 @@ class SpecialCreateAccount extends SpecialRedirectToSpecial { } /** * SpecialMypage, SpecialMytalk and SpecialMycontributions special pages - * are used to get user independant links pointing to the user page, talk + * are used to get user independent links pointing to the user page, talk * page and list of contributions. * This can let us cache a single copy of any generated content for all * users.