* Includes some static functions for handling the special page list deprecated
* in favor of SpecialPageFactory.
*
- * @todo Turn this into a real ContextSource
* @ingroup SpecialPage
*/
class SpecialPage {
// Minimum user level required to access this page, or "" for anyone.
// Also used to categorise the pages in Special:Specialpages
- private $mRestriction;
+ protected $mRestriction;
// Listed in Special:Specialpages?
private $mListed;
}
/**
- * If the user is not logged in, throws UserNotLoggedIn error.
+ * If the user is not logged in, throws UserNotLoggedIn error
*
- * Default error message includes a link to Special:Userlogin with properly set 'returnto' query
- * parameter.
+ * The user will be redirected to Special:Userlogin with the given message as an error on
+ * the form.
*
* @since 1.23
- * @param string|Message $reasonMsg [optional] Passed on to UserNotLoggedIn constructor. Strings
- * will be used as message keys. If a string is given, the message will also receive a
- * formatted login link (generated using the 'loginreqlink' message) as first parameter. If a
- * Message is given, it will be passed on verbatim.
- * @param string|Message $titleMsg [optional] Passed on to UserNotLoggedIn constructor. Strings
- * will be used as message keys.
+ * @param string $reasonMsg [optional] Message key to be displayed on login page
+ * @param string $titleMsg [optional] Passed on to UserNotLoggedIn constructor
* @throws UserNotLoggedIn
*/
- public function requireLogin( $reasonMsg = null, $titleMsg = null ) {
+ public function requireLogin(
+ $reasonMsg = 'exception-nologin-text', $titleMsg = 'exception-nologin'
+ ) {
if ( $this->getUser()->isAnon() ) {
- // Use default messages if not given or explicit null passed
- if ( !$reasonMsg ) {
- $reasonMsg = 'exception-nologin-text-manual';
- }
- if ( !$titleMsg ) {
- $titleMsg = 'exception-nologin';
- }
-
- // Convert to Messages with current context
- if ( is_string( $reasonMsg ) ) {
- $loginreqlink = Linker::linkKnown(
- SpecialPage::getTitleFor( 'Userlogin' ),
- $this->msg( 'loginreqlink' )->escaped(),
- array(),
- array( 'returnto' => $this->getPageTitle()->getPrefixedText() )
- );
- $reasonMsg = $this->msg( $reasonMsg )->rawParams( $loginreqlink );
- }
- if ( is_string( $titleMsg ) ) {
- $titleMsg = $this->msg( $titleMsg );
- }
-
throw new UserNotLoggedIn( $reasonMsg, $titleMsg );
}
}
* - `prefixSearchSubpages( "" )` should return `array( foo", "bar", "baz" )`
*
* @param string $search Prefix to search for
- * @param int $limit Maximum number of results to return
+ * @param int $limit Maximum number of results to return (usually 10)
+ * @param int $offset Number of results to skip (usually 0)
* @return string[] Matching subpages
*/
- public function prefixSearchSubpages( $search, $limit = 10 ) {
+ public function prefixSearchSubpages( $search, $limit, $offset ) {
+ $subpages = $this->getSubpagesForPrefixSearch();
+ if ( !$subpages ) {
+ return array();
+ }
+
+ return self::prefixSearchArray( $search, $limit, $subpages, $offset );
+ }
+
+ /**
+ * Return an array of subpages that this special page will accept for prefix
+ * searches. If this method requires a query you might instead want to implement
+ * prefixSearchSubpages() directly so you can support $limit and $offset. This
+ * method is better for static-ish lists of things.
+ *
+ * @return string[] subpages to search from
+ */
+ protected function getSubpagesForPrefixSearch() {
return array();
}
* @param string $search
* @param int $limit
* @param array $subpages
+ * @param int $offset
* @return string[]
*/
- protected static function prefixSearchArray( $search, $limit, array $subpages ) {
+ protected static function prefixSearchArray( $search, $limit, array $subpages, $offset ) {
$escaped = preg_quote( $search, '/' );
- return array_slice( preg_grep( "/^$escaped/i", $subpages ), 0, $limit );
+ return array_slice( preg_grep( "/^$escaped/i",
+ array_slice( $subpages, $offset ) ), 0, $limit );
}
/**
$out->setArticleRelated( false );
$out->setRobotPolicy( $this->getRobotPolicy() );
$out->setPageTitle( $this->getDescription() );
+ if ( $this->getConfig()->get( 'UseMediaWikiUIEverywhere' ) ) {
+ $out->addModuleStyles( array(
+ 'mediawiki.ui.input',
+ 'mediawiki.ui.checkbox',
+ ) );
+ }
}
/**
* @param array $params
*/
protected function addFeedLinks( $params ) {
- global $wgFeedClasses;
-
$feedTemplate = wfScript( 'api' );
- foreach ( $wgFeedClasses as $format => $class ) {
+ foreach ( $this->getConfig()->get( 'FeedClasses' ) as $format => $class ) {
$theseParams = $params + array( 'feedformat' => $format );
$url = wfAppendQuery( $feedTemplate, $theseParams );
$this->getOutput()->addFeedLink( $format, $url );
* @since 1.21
*/
public function getFinalGroupName() {
- global $wgSpecialPageGroups;
$name = $this->getName();
+ $specialPageGroups = $this->getConfig()->get( 'SpecialPageGroups' );
// Allow overbidding the group from the wiki side
$msg = $this->msg( 'specialpages-specialpagegroup-' . strtolower( $name ) )->inContentLanguage();
// 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];
+ if ( $group === '-' && isset( $specialPageGroups[$name] ) ) {
+ $group = $specialPageGroups[$name];
}
}