Merge "Displaying search results for multiple wikis"
[lhc/web/wiklou.git] / includes / api / ApiQueryBase.php
index 6c9d999..c4592c8 100644 (file)
@@ -421,7 +421,14 @@ abstract class ApiQueryBase extends ApiBase {
                $this->addFields( 'ipb_deleted' );
 
                if ( $showBlockInfo ) {
-                       $this->addFields( array( 'ipb_id', 'ipb_by', 'ipb_by_text', 'ipb_reason', 'ipb_expiry', 'ipb_timestamp' ) );
+                       $this->addFields( array(
+                               'ipb_id',
+                               'ipb_by',
+                               'ipb_by_text',
+                               'ipb_reason',
+                               'ipb_expiry',
+                               'ipb_timestamp'
+                       ) );
                }
 
                // Don't show hidden names
@@ -457,7 +464,7 @@ abstract class ApiQueryBase extends ApiBase {
         */
        protected function addPageSubItems( $pageId, $data ) {
                $result = $this->getResult();
-               $result->setIndexedTagName( $data, $this->getModulePrefix() );
+               ApiResult::setIndexedTagName( $data, $this->getModulePrefix() );
 
                return $result->addValue( array( 'query', 'pages', intval( $pageId ) ),
                        $this->getModuleName(),
@@ -482,7 +489,7 @@ abstract class ApiQueryBase extends ApiBase {
                if ( !$fit ) {
                        return false;
                }
-               $result->setIndexedTagName_internal( array( 'query', 'pages', $pageId,
+               $result->addIndexedTagName( array( 'query', 'pages', $pageId,
                        $this->getModuleName() ), $elemname );
 
                return true;
@@ -494,7 +501,7 @@ abstract class ApiQueryBase extends ApiBase {
         * @param string|array $paramValue Parameter value
         */
        protected function setContinueEnumParameter( $paramName, $paramValue ) {
-               $this->getResult()->setContinueParam( $this, $paramName, $paramValue );
+               $this->getContinuationManager()->addContinueParam( $this, $paramName, $paramValue );
        }
 
        /**
@@ -504,7 +511,7 @@ abstract class ApiQueryBase extends ApiBase {
         * capitalization settings.
         *
         * @param string $titlePart Title part
-        * @param int $defaultNamespace Namespace of the title
+        * @param int $namespace Namespace of the title
         * @return string DBkey (no namespace prefix)
         */
        public function titlePartToKey( $titlePart, $namespace = NS_MAIN ) {
@@ -525,6 +532,24 @@ abstract class ApiQueryBase extends ApiBase {
                return substr( $t->getDbKey(), 0, -1 );
        }
 
+       /**
+        * Convert an input title or title prefix into a namespace constant and dbkey.
+        *
+        * @since 1.26
+        * @param string $titlePart Title part
+        * @param int $defaultNamespace Default namespace if none is given
+        * @return array (int, string) Namespace number and DBkey
+        */
+       public function prefixedTitlePartToKey( $titlePart, $defaultNamespace = NS_MAIN ) {
+               $t = Title::newFromText( $titlePart . 'x', $defaultNamespace );
+               if ( !$t || $t->hasFragment() || $t->isExternal() ) {
+                       // Invalid title (e.g. bad chars) or contained a '#'.
+                       $this->dieUsageMsg( array( 'invalidtitle', $titlePart ) );
+               }
+
+               return array( $t->getNamespace(), substr( $t->getDbKey(), 0, -1 ) );
+       }
+
        /**
         * Gets the personalised direction parameter description
         *
@@ -711,7 +736,7 @@ abstract class ApiQueryGeneratorBase extends ApiQueryBase {
         */
        protected function setContinueEnumParameter( $paramName, $paramValue ) {
                if ( $this->mGeneratorPageSet !== null ) {
-                       $this->getResult()->setGeneratorContinueParam( $this, $paramName, $paramValue );
+                       $this->getContinuationManager()->addGeneratorContinueParam( $this, $paramName, $paramValue );
                } else {
                        parent::setContinueEnumParameter( $paramName, $paramValue );
                }