MediaWiki
REL1_22
|
00001 <?php 00033 class ApiQueryPagePropNames extends ApiQueryBase { 00034 00035 public function __construct( $query, $moduleName ) { 00036 parent::__construct( $query, $moduleName, 'ppn' ); 00037 } 00038 00039 public function getCacheMode( $params ) { 00040 return 'public'; 00041 } 00042 00043 public function execute() { 00044 $params = $this->extractRequestParams(); 00045 00046 $this->addTables( 'page_props' ); 00047 $this->addFields( 'pp_propname' ); 00048 $this->addOption( 'DISTINCT' ); 00049 $this->addOption( 'ORDER BY', 'pp_propname' ); 00050 00051 if ( $params['continue'] ) { 00052 $cont = explode( '|', $params['continue'] ); 00053 $this->dieContinueUsageIf( count( $cont ) != 1 ); 00054 00055 // Add a WHERE clause 00056 $this->addWhereRange( 'pp_propname', 'newer', $cont[0], null ); 00057 } 00058 00059 $limit = $params['limit']; 00060 $this->addOption( 'LIMIT', $limit + 1 ); 00061 00062 $result = $this->getResult(); 00063 $count = 0; 00064 foreach ( $this->select( __METHOD__ ) as $row ) { 00065 if ( ++$count > $limit ) { 00066 // We've reached the one extra which shows that there are additional pages to be had. Stop here... 00067 $this->setContinueEnumParameter( 'continue', $row->pp_propname ); 00068 break; 00069 } 00070 00071 $vals = array(); 00072 $vals['propname'] = $row->pp_propname; 00073 $fit = $result->addValue( array( 'query', $this->getModuleName() ), null, $vals ); 00074 if ( !$fit ) { 00075 $this->setContinueEnumParameter( 'continue', $row->pp_propname ); 00076 break; 00077 } 00078 } 00079 00080 $result->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), 'p' ); 00081 } 00082 00083 public function getAllowedParams() { 00084 return array( 00085 'continue' => null, 00086 'limit' => array( 00087 ApiBase::PARAM_TYPE => 'limit', 00088 ApiBase::PARAM_DFLT => 10, 00089 ApiBase::PARAM_MIN => 1, 00090 ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1, 00091 ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2 00092 ), 00093 ); 00094 } 00095 00096 public function getParamDescription() { 00097 return array( 00098 'continue' => 'When more results are available, use this to continue', 00099 'limit' => 'The maximum number of pages to return', 00100 ); 00101 } 00102 00103 public function getDescription() { 00104 return 'List all page prop names in use on the wiki'; 00105 } 00106 00107 public function getExamples() { 00108 return array( 00109 'api.php?action=query&list=pagepropnames' => 'Get first 10 prop names', 00110 ); 00111 } 00112 00113 public function getHelpUrls() { 00114 return 'https://www.mediawiki.org/wiki/API:Pagepropnames'; 00115 } 00116 }