public function prefixSearchSubpages( $search, $limit, $offset ) {
$subpages = $this->getSubpagesForPrefixSearch();
if ( !$subpages ) {
- return array();
+ return [];
}
return self::prefixSearchArray( $search, $limit, $subpages, $offset );
* @return string[] subpages to search from
*/
protected function getSubpagesForPrefixSearch() {
- return array();
+ return [];
+ }
+
+ /**
+ * Perform a regular substring search for prefixSearchSubpages
+ * @param string $search Prefix to search for
+ * @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
+ */
+ protected function prefixSearchString( $search, $limit, $offset ) {
+ $title = Title::newFromText( $search );
+ if ( !$title || !$title->canExist() ) {
+ // No prefix suggestion in special and media namespace
+ return [];
+ }
+
+ $search = SearchEngine::create();
+ $search->setLimitOffset( $limit, $offset );
+ $search->setNamespaces( [] );
+ $result = $search->defaultPrefixSearch( $search );
+ return array_map( function( Title $t ) {
+ return $t->getPrefixedText();
+ }, $result );
}
/**
$out->setRobotPolicy( $this->getRobotPolicy() );
$out->setPageTitle( $this->getDescription() );
if ( $this->getConfig()->get( 'UseMediaWikiUIEverywhere' ) ) {
- $out->addModuleStyles( array(
+ $out->addModuleStyles( [
'mediawiki.ui.input',
'mediawiki.ui.radio',
'mediawiki.ui.checkbox',
- ) );
+ ] );
}
}
* @param SpecialPage $this
* @param string|null $subPage
*/
- Hooks::run( 'SpecialPageBeforeExecute', array( $this, $subPage ) );
+ Hooks::run( 'SpecialPageBeforeExecute', [ $this, $subPage ] );
$this->beforeExecute( $subPage );
$this->execute( $subPage );
* @param SpecialPage $this
* @param string|null $subPage
*/
- Hooks::run( 'SpecialPageAfterExecute', array( $this, $subPage ) );
+ Hooks::run( 'SpecialPageAfterExecute', [ $this, $subPage ] );
}
/**
*/
public function msg( /* $args */ ) {
$message = call_user_func_array(
- array( $this->getContext(), 'msg' ),
+ [ $this->getContext(), 'msg' ],
func_get_args()
);
// RequestContext passes context to wfMessage, and the language is set from
$feedTemplate = wfScript( 'api' );
foreach ( $this->getConfig()->get( 'FeedClasses' ) as $format => $class ) {
- $theseParams = $params + array( 'feedformat' => $format );
+ $theseParams = $params + [ 'feedformat' => $format ];
$url = wfAppendQuery( $feedTemplate, $theseParams );
$this->getOutput()->addFeedLink( $format, $url );
}
return $group;
}
+ /**
+ * Indicates whether this special page may perform database writes
+ *
+ * @return bool
+ * @since 1.27
+ */
+ public function doesWrites() {
+ return false;
+ }
+
/**
* Under which header this special page is listed in Special:SpecialPages
* See messages 'specialpages-group-*' for valid names