wfMsgForContentNoTrans() was removed
[mediawiki.git] / includes / api / ApiQueryGeneratorBase.php
blob67fe0d61a7f6e3c0416306b3b1343741e210b8ca
1 <?php
2 /**
5 * Created on Sep 7, 2006
7 * Copyright © 2006 Yuri Astrakhan "<Firstname><Lastname>@gmail.com"
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 * http://www.gnu.org/copyleft/gpl.html
24 * @file
27 /**
28 * @ingroup API
30 abstract class ApiQueryGeneratorBase extends ApiQueryBase {
32 private $mGeneratorPageSet = null;
34 /**
35 * Switch this module to generator mode. By default, generator mode is
36 * switched off and the module acts like a normal query module.
37 * @since 1.21 requires pageset parameter
38 * @param ApiPageSet $generatorPageSet ApiPageSet object that the module will get
39 * by calling getPageSet() when in generator mode.
41 public function setGeneratorMode( ApiPageSet $generatorPageSet ) {
42 if ( $generatorPageSet === null ) {
43 ApiBase::dieDebug( __METHOD__, 'Required parameter missing - $generatorPageSet' );
45 $this->mGeneratorPageSet = $generatorPageSet;
48 /**
49 * Get the PageSet object to work on.
50 * If this module is generator, the pageSet object is different from other module's
51 * @return ApiPageSet
53 protected function getPageSet() {
54 if ( $this->mGeneratorPageSet !== null ) {
55 return $this->mGeneratorPageSet;
58 return parent::getPageSet();
61 /**
62 * Overrides ApiBase to prepend 'g' to every generator parameter
63 * @param string $paramName Parameter name
64 * @return string Prefixed parameter name
66 public function encodeParamName( $paramName ) {
67 if ( $this->mGeneratorPageSet !== null ) {
68 return 'g' . parent::encodeParamName( $paramName );
69 } else {
70 return parent::encodeParamName( $paramName );
74 /**
75 * Overridden to set the generator param if in generator mode
76 * @param string $paramName Parameter name
77 * @param string|array $paramValue Parameter value
79 protected function setContinueEnumParameter( $paramName, $paramValue ) {
80 if ( $this->mGeneratorPageSet !== null ) {
81 $this->getContinuationManager()->addGeneratorContinueParam( $this, $paramName, $paramValue );
82 } else {
83 parent::setContinueEnumParameter( $paramName, $paramValue );
87 /**
88 * @see ApiBase::getHelpFlags()
90 * Corresponding messages: api-help-flag-generator
92 protected function getHelpFlags() {
93 $flags = parent::getHelpFlags();
94 $flags[] = 'generator';
95 return $flags;
98 /**
99 * Execute this module as a generator
100 * @param ApiPageSet $resultPageSet All output should be appended to this object
102 abstract public function executeGenerator( $resultPageSet );