MediaWiki  1.23.2
Go to the documentation of this file.
1 <?php
35  public function __construct( $query, $moduleName ) {
36  parent::__construct( $query, $moduleName, 'pwp' );
37  }
39  public function execute() {
40  $this->run();
41  }
43  public function getCacheMode( $params ) {
44  return 'public';
45  }
47  public function executeGenerator( $resultPageSet ) {
48  $this->run( $resultPageSet );
49  }
55  private function run( $resultPageSet = null ) {
56  $params = $this->extractRequestParams();
58  $prop = array_flip( $params['prop'] );
59  $fld_ids = isset( $prop['ids'] );
60  $fld_title = isset( $prop['title'] );
61  $fld_value = isset( $prop['value'] );
63  if ( $resultPageSet === null ) {
64  $this->addFields( array( 'page_id' ) );
65  $this->addFieldsIf( array( 'page_title', 'page_namespace' ), $fld_title );
66  $this->addFieldsIf( 'pp_value', $fld_value );
67  } else {
68  $this->addFields( $resultPageSet->getPageTableFields() );
69  }
70  $this->addTables( array( 'page_props', 'page' ) );
71  $this->addWhere( 'pp_page=page_id' );
72  $this->addWhereFld( 'pp_propname', $params['propname'] );
74  $dir = ( $params['dir'] == 'ascending' ) ? 'newer' : 'older';
76  if ( $params['continue'] ) {
77  $cont = explode( '|', $params['continue'] );
78  $this->dieContinueUsageIf( count( $cont ) != 1 );
80  // Add a WHERE clause
81  $from = (int)$cont[0];
82  $this->addWhereRange( 'pp_page', $dir, $from, null );
83  }
85  $sort = ( $params['dir'] === 'descending' ? ' DESC' : '' );
86  $this->addOption( 'ORDER BY', 'pp_page' . $sort );
88  $limit = $params['limit'];
89  $this->addOption( 'LIMIT', $limit + 1 );
91  $result = $this->getResult();
92  $count = 0;
93  foreach ( $this->select( __METHOD__ ) as $row ) {
94  if ( ++$count > $limit ) {
95  // We've reached the one extra which shows that there are
96  // additional pages to be had. Stop here...
97  $this->setContinueEnumParameter( 'continue', $row->page_id );
98  break;
99  }
101  if ( $resultPageSet === null ) {
102  $vals = array();
103  if ( $fld_ids ) {
104  $vals['pageid'] = (int)$row->page_id;
105  }
106  if ( $fld_title ) {
107  $title = Title::makeTitle( $row->page_namespace, $row->page_title );
109  }
110  if ( $fld_value ) {
111  $vals['value'] = $row->pp_value;
112  }
113  $fit = $result->addValue( array( 'query', $this->getModuleName() ), null, $vals );
114  if ( !$fit ) {
115  $this->setContinueEnumParameter( 'continue', $row->page_id );
116  break;
117  }
118  } else {
119  $resultPageSet->processDbRow( $row );
120  }
121  }
123  if ( $resultPageSet === null ) {
124  $result->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), 'page' );
125  }
126  }
128  public function getAllowedParams() {
129  return array(
130  'propname' => array(
131  ApiBase::PARAM_TYPE => 'string',
132  ApiBase::PARAM_REQUIRED => true,
133  ),
134  'prop' => array(
135  ApiBase::PARAM_DFLT => 'ids|title',
136  ApiBase::PARAM_ISMULTI => true,
138  'ids',
139  'title',
140  'value',
141  )
142  ),
143  'continue' => null,
144  'limit' => array(
145  ApiBase::PARAM_TYPE => 'limit',
146  ApiBase::PARAM_DFLT => 10,
147  ApiBase::PARAM_MIN => 1,
150  ),
151  'dir' => array(
152  ApiBase::PARAM_DFLT => 'ascending',
154  'ascending',
155  'descending',
156  )
157  ),
158  );
159  }
161  public function getParamDescription() {
162  return array(
163  'propname' => 'Page prop for which to enumerate pages',
164  'prop' => array(
165  'What pieces of information to include',
166  ' ids - Adds the page ID',
167  ' title - Adds the title and namespace ID of the page',
168  ' value - Adds the value of the page prop',
169  ),
170  'dir' => 'In which direction to sort',
171  'continue' => 'When more results are available, use this to continue',
172  'limit' => 'The maximum number of pages to return',
173  );
174  }
176  public function getDescription() {
177  return 'List all pages using a given page prop.';
178  }
180  public function getExamples() {
181  return array(
182  'api.php?action=query&list=pageswithprop&pwppropname=displaytitle&pwpprop=ids|title|value'
183  => 'Get first 10 pages using {{DISPLAYTITLE:}}',
184  'api.php?action=query&generator=pageswithprop&gpwppropname=notoc&prop=info'
185  => 'Get page info about first 10 pages using __NOTOC__',
186  );
187  }
189  public function getHelpUrls() {
190  return '';
191  }
192 }
Definition: ApiQueryPagesWithProp.php:189
static & makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:398
Returns usage examples for this module.
Definition: ApiQueryPagesWithProp.php:180
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message. Please note the header message cannot receive/use parameters. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. $reader:XMLReader object $logInfo:Array of information Return false to stop further processing of the tag 'ImportHandlePageXMLTag':When parsing a XML tag in a page. $reader:XMLReader object $pageInfo:Array of information Return false to stop further processing of the tag 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information Return false to stop further processing of the tag 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. $reader:XMLReader object Return false to stop further processing of the tag 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. $reader:XMLReader object $revisionInfo:Array of information Return false to stop further processing of the tag 'InfoAction':When building information to display on the action=info page. $context:IContextSource object & $pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect. $title:Title object for the current page $request:WebRequest $ignoreRedirect:boolean to skip redirect check $target:Title/string of redirect target $article:Article object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not. Return true without providing an interwiki to continue interwiki search. $prefix:interwiki prefix we are looking for. & $iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InternalParseBeforeSanitize':during Parser 's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings. Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InternalParseBeforeLinks':during Parser 's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InvalidateEmailComplete':Called after a user 's email has been invalidated successfully. $user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification. Callee may modify $url and $query, URL will be constructed as $url . $query & $url:URL to index.php & $query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) $article:article(object) being checked 'IsTrustedProxy':Override the result of wfIsTrustedProxy() $ip:IP being check $result:Change this value to override the result of wfIsTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from & $allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of User::isValidEmailAddr(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers 'LanguageGetMagic':DEPRECATED, use $magicWords in a file listed in $wgExtensionMessagesFiles instead. Use this to define synonyms of magic words depending of the language $magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetSpecialPageAliases':DEPRECATED, use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead. Use to define aliases of special pages names depending of the language $specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names. & $names:array of language code=> language name $code language of the preferred translations 'LanguageLinks':Manipulate a page 's language links. This is called in various places to allow extensions to define the effective language links for a page. $title:The page 's Title. & $links:Associative array mapping language codes to prefixed links of the form "language:title". & $linkFlags:Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. 'LinkBegin':Used when generating internal and interwiki links in Linker::link(), before processing starts. Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters. $skin:the Skin object $target:the Title that the link is pointing to & $html:the contents that the< a > tag should have(raw HTML) $result
Definition: hooks.txt:1528
addFields( $value)
Add a set of fields to select to the internal array.
Definition: ApiQueryBase.php:117
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
Definition: ApiBase.php:62
run( $resultPageSet=null)
Definition: ApiQueryPagesWithProp.php:55
Definition: ApiBase.php:50
Get the result object.
Definition: ApiBase.php:205
select( $method, $extraQuery=array())
Execute a SELECT query based on the values in the internal arrays.
Definition: ApiQueryBase.php:274
Definition: importImages.php:90
Definition: styleTest.css.php:40
if( $sleep) $limit
Definition: importImages.php:99
addOption( $name, $value=null)
Add an option such as LIMIT or USE INDEX.
Definition: ApiQueryBase.php:252
A query module to enumerate pages that use a particular prop.
Definition: ApiQueryPagesWithProp.php:33
addFieldsIf( $value, $condition)
Same as addFields(), but add the fields only if a condition is met.
Definition: ApiQueryBase.php:131
__construct( $query, $moduleName)
Definition: ApiQueryPagesWithProp.php:35
getCacheMode( $params)
Get the cache mode for the data generated by this module.
Definition: ApiQueryPagesWithProp.php:43
Returns an array of parameter descriptions.
Definition: ApiQueryPagesWithProp.php:161
setContinueEnumParameter( $paramName, $paramValue)
Overrides base in case of generator & smart continue to notify ApiQueryMain instead of adding them to...
Definition: ApiQueryBase.php:676
Definition: ApiBase.php:56
Evaluates the parameters, performs the requested query, and sets up the result.
Definition: ApiQueryPagesWithProp.php:39
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
Definition: ApiQueryPagesWithProp.php:128
const LIMIT_BIG1
Definition: ApiBase.php:78
Definition: ApiBase.php:52
addTables( $tables, $alias=null)
Add a set of tables to the internal array.
Definition: ApiQueryBase.php:82
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
Definition: profileinfo.php:301
addWhereRange( $field, $dir, $start, $end, $sort=true)
Add a WHERE clause corresponding to a range, and an ORDER BY clause to sort in the right direction.
Definition: ApiQueryBase.php:205
extractRequestParams( $parseLimit=true)
Using getAllowedParams(), this function makes an array of the values provided by the user,...
Definition: ApiBase.php:687
presenting them properly to the user as errors is done by the caller $title
Definition: hooks.txt:1324
dieContinueUsageIf( $condition)
Die with the $prefix.
Definition: ApiBase.php:1965
addWhereFld( $field, $value)
Equivalent to addWhere(array($field => $value))
Definition: ApiQueryBase.php:185
Definition: UtfNormalTest2.php:96
Definition: ApiQueryBase.php:626
const LIMIT_BIG2
Definition: ApiBase.php:79
if(count( $args)==0) $dir
Definition: importImages.php:49
Definition: ApiBase.php:46
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
Get the name of the module being executed by this instance.
Definition: ApiBase.php:148
Definition: ApiBase.php:48
const PARAM_MAX2
Definition: ApiBase.php:54
addWhere( $value)
Add a set of WHERE clauses to the internal array.
Definition: ApiQueryBase.php:152
Returns the description string for this module.
Definition: ApiQueryPagesWithProp.php:176
return true to allow those checks to and false if checking is done use this to change the tables headers temp or archived zone change it to an object instance and return false override the list derivative used the name of the old file when set the default code will be skipped add a value to it if you want to add a cookie that have to vary cache options can modify $query
Definition: hooks.txt:1105
executeGenerator( $resultPageSet)
Execute this module as a generator.
Definition: ApiQueryPagesWithProp.php:47
static addTitleInfo(&$arr, $title, $prefix='')
Add information (title and namespace) about a Title object to a result array.
Definition: ApiQueryBase.php:339