X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiQueryBacklinks.php;h=1df14e0b8aec4b9b8b99a946db0c4b2e72a8c84a;hb=6f8a05822e08a3aaf1f41221d33e030e9bb3c56c;hp=e344236c93dd1b73ff69acbb578d9d079f4f9df9;hpb=9268b6f763f60d7949300d8b05e0181254857ae5;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiQueryBacklinks.php b/includes/api/ApiQueryBacklinks.php index e344236c93..1df14e0b8a 100644 --- a/includes/api/ApiQueryBacklinks.php +++ b/includes/api/ApiQueryBacklinks.php @@ -194,7 +194,7 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase { $a = array( 'pageid' => intval( $row->page_id ) ); ApiQueryBase::addTitleInfo( $a, $t ); if ( $row->page_is_redirect ) { - $a['redirect'] = ''; + $a['redirect'] = true; } // Put all the results in an array first $this->resultArr[$a['pageid']] = $a; @@ -313,7 +313,7 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase { $a['pageid'] = intval( $row->page_id ); ApiQueryBase::addTitleInfo( $a, Title::makeTitle( $row->page_namespace, $row->page_title ) ); if ( $row->page_is_redirect ) { - $a['redirect'] = ''; + $a['redirect'] = true; } $parentID = $this->pageMap[$ns][$row->{$this->bl_title}]; // Put all the results in an array first @@ -338,7 +338,7 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase { if ( $this->params['limit'] == 'max' ) { $this->params['limit'] = $this->getMain()->canApiHighLimits() ? $botMax : $userMax; - $result->setParsedLimit( $this->getModuleName(), $this->params['limit'] ); + $result->addParsedLimit( $this->getModuleName(), $this->params['limit'] ); } else { $this->params['limit'] = intval( $this->params['limit'] ); $this->validateLimit( 'limit', $this->params['limit'], 1, $userMax, $botMax ); @@ -422,7 +422,15 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase { if ( is_null( $resultPageSet ) ) { // Try to add the result data in one go and pray that it fits - $fit = $result->addValue( 'query', $this->getModuleName(), array_values( $this->resultArr ) ); + $code = $this->bl_code; + $data = array_map( function ( $arr ) use ( $result, $code ) { + if ( isset( $arr['redirlinks'] ) ) { + $arr['redirlinks'] = array_values( $arr['redirlinks'] ); + ApiResult::setIndexedTagName( $arr['redirlinks'], $code ); + } + return $arr; + }, array_values( $this->resultArr ) ); + $fit = $result->addValue( 'query', $this->getModuleName(), $data ); if ( !$fit ) { // It didn't fit. Add elements one by one until the // result is full. @@ -474,7 +482,7 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase { $hasRedirs = true; } if ( $hasRedirs ) { - $result->setIndexedTagName_internal( + $result->addIndexedTagName( array( 'query', $this->getModuleName(), $idx, 'redirlinks' ), $this->bl_code ); } @@ -486,7 +494,7 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase { } } - $result->setIndexedTagName_internal( + $result->addIndexedTagName( array( 'query', $this->getModuleName() ), $this->bl_code ); @@ -504,7 +512,9 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase { 'pageid' => array( ApiBase::PARAM_TYPE => 'integer', ), - 'continue' => null, + 'continue' => array( + ApiBase::PARAM_HELP_MSG => 'api-help-param-continue', + ), 'namespace' => array( ApiBase::PARAM_ISMULTI => true, ApiBase::PARAM_TYPE => 'namespace' @@ -540,59 +550,25 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase { return $retval; } - public function getParamDescription() { - $retval = array( - 'title' => "Title to search. Cannot be used together with {$this->bl_code}pageid", - 'pageid' => "Pageid to search. Cannot be used together with {$this->bl_code}title", - 'continue' => 'When more results are available, use this to continue', - 'namespace' => 'The namespace to enumerate', - 'dir' => 'The direction in which to list', - ); - if ( $this->getModuleName() != 'embeddedin' ) { - return array_merge( $retval, array( - 'redirect' => 'If linking page is a redirect, find all pages ' . - 'that link to that redirect as well. Maximum limit is halved.', - 'filterredir' => 'How to filter for redirects. If set to ' . - "nonredirects when {$this->bl_code}redirect is enabled, " . - 'this is only applied to the second level', - 'limit' => 'How many total pages to return. If ' . - "{$this->bl_code}redirect is enabled, limit applies to each " . - 'level separately (which means you may get up to 2 * limit results).' - ) ); - } - - return array_merge( $retval, array( - 'filterredir' => 'How to filter for redirects', - 'limit' => 'How many total pages to return' - ) ); - } - - public function getDescription() { - switch ( $this->getModuleName() ) { - case 'backlinks': - return 'Find all pages that link to the given page.'; - case 'embeddedin': - return 'Find all pages that embed (transclude) the given title.'; - case 'imageusage': - return 'Find all pages that use the given image title.'; - default: - ApiBase::dieDebug( __METHOD__, 'Unknown module name.' ); - } - } - - public function getExamples() { + protected function getExamplesMessages() { static $examples = array( 'backlinks' => array( - 'api.php?action=query&list=backlinks&bltitle=Main%20Page', - 'api.php?action=query&generator=backlinks&gbltitle=Main%20Page&prop=info' + 'action=query&list=backlinks&bltitle=Main%20Page' + => 'apihelp-query+backlinks-example-simple', + 'action=query&generator=backlinks&gbltitle=Main%20Page&prop=info' + => 'apihelp-query+backlinks-example-generator', ), 'embeddedin' => array( - 'api.php?action=query&list=embeddedin&eititle=Template:Stub', - 'api.php?action=query&generator=embeddedin&geititle=Template:Stub&prop=info' + 'action=query&list=embeddedin&eititle=Template:Stub' + => 'apihelp-query+embeddedin-example-simple', + 'action=query&generator=embeddedin&geititle=Template:Stub&prop=info' + => 'apihelp-query+embeddedin-example-generator', ), 'imageusage' => array( - 'api.php?action=query&list=imageusage&iutitle=File:Albert%20Einstein%20Head.jpg', - 'api.php?action=query&generator=imageusage&giutitle=File:Albert%20Einstein%20Head.jpg&prop=info' + 'action=query&list=imageusage&iutitle=File:Albert%20Einstein%20Head.jpg' + => 'apihelp-query+imageusage-example-simple', + 'action=query&generator=imageusage&giutitle=File:Albert%20Einstein%20Head.jpg&prop=info' + => 'apihelp-query+imageusage-example-generator', ) );