Index: trunk/phase3/includes/api/ApiQueryInfo.php |
— | — | @@ -36,7 +36,7 @@ |
37 | 37 | class ApiQueryInfo extends ApiQueryBase { |
38 | 38 | |
39 | 39 | public function __construct($query, $moduleName) { |
40 | | - parent :: __construct($query, $moduleName); |
| 40 | + parent :: __construct($query, $moduleName, 'in'); |
41 | 41 | } |
42 | 42 | |
43 | 43 | public function requestExtraData($pageSet) { |
— | — | @@ -50,6 +50,13 @@ |
51 | 51 | |
52 | 52 | public function execute() { |
53 | 53 | |
| 54 | + $params = $this->extractRequestParams(); |
| 55 | + $fld_protection = false; |
| 56 | + if(!is_null($params['prop'])) { |
| 57 | + $prop = array_flip($params['prop']); |
| 58 | + $fld_protection = isset($prop['protection']); |
| 59 | + } |
| 60 | + |
54 | 61 | $pageSet = $this->getPageSet(); |
55 | 62 | $titles = $pageSet->getGoodTitles(); |
56 | 63 | $result = $this->getResult(); |
— | — | @@ -61,6 +68,23 @@ |
62 | 69 | $pageLatest = $pageSet->getCustomField('page_latest'); |
63 | 70 | $pageLength = $pageSet->getCustomField('page_len'); |
64 | 71 | |
| 72 | + if ($fld_protection) { |
| 73 | + $this->addTables('page_restrictions'); |
| 74 | + $this->addFields(array('pr_page', 'pr_type', 'pr_level', 'pr_expiry')); |
| 75 | + $this->addWhereFld('pr_page', array_keys($titles)); |
| 76 | + |
| 77 | + $db = $this->getDB(); |
| 78 | + $res = $this->select(__METHOD__); |
| 79 | + while($row = $db->fetchObject($res)) { |
| 80 | + $protections[$row->pr_page][] = array( |
| 81 | + 'type' => $row->pr_type, |
| 82 | + 'level' => $row->pr_level, |
| 83 | + 'expiry' => Block::decodeExpiry( $row->pr_expiry, TS_ISO_8601 ) |
| 84 | + ); |
| 85 | + } |
| 86 | + $db->freeResult($res); |
| 87 | + } |
| 88 | + |
65 | 89 | foreach ( $titles as $pageid => $unused ) { |
66 | 90 | $pageInfo = array ( |
67 | 91 | 'touched' => wfTimestamp(TS_ISO_8601, $pageTouched[$pageid]), |
— | — | @@ -75,6 +99,15 @@ |
76 | 100 | if ($pageIsNew[$pageid]) |
77 | 101 | $pageInfo['new'] = ''; |
78 | 102 | |
| 103 | + if($fld_protection) { |
| 104 | + if (isset($protections[$pageid])) { |
| 105 | + $pageInfo['protection'] = $protections[$pageid]; |
| 106 | + $result->setIndexedTagName($pageInfo['protection'], 'pr'); |
| 107 | + } else { |
| 108 | + $pageInfo['protection'] = array(); |
| 109 | + } |
| 110 | + } |
| 111 | + |
79 | 112 | $result->addValue(array ( |
80 | 113 | 'query', |
81 | 114 | 'pages' |
— | — | @@ -82,13 +115,35 @@ |
83 | 116 | } |
84 | 117 | } |
85 | 118 | |
| 119 | + protected function getAllowedParams() { |
| 120 | + return array ( |
| 121 | + 'prop' => array ( |
| 122 | + ApiBase :: PARAM_DFLT => NULL, |
| 123 | + ApiBase :: PARAM_ISMULTI => true, |
| 124 | + ApiBase :: PARAM_TYPE => array ( |
| 125 | + 'protection' |
| 126 | + )) |
| 127 | + ); |
| 128 | + } |
| 129 | + |
| 130 | + protected function getParamDescription() { |
| 131 | + return array ( |
| 132 | + 'prop' => array ( |
| 133 | + 'Which additional properties to get:', |
| 134 | + ' "protection" - List the protection level of each page' |
| 135 | + ) |
| 136 | + ); |
| 137 | + } |
| 138 | + |
| 139 | + |
86 | 140 | protected function getDescription() { |
87 | 141 | return 'Get basic page information such as namespace, title, last touched date, ...'; |
88 | 142 | } |
89 | 143 | |
90 | 144 | protected function getExamples() { |
91 | 145 | return array ( |
92 | | - 'api.php?action=query&prop=info&titles=Main%20Page' |
| 146 | + 'api.php?action=query&prop=info&titles=Main%20Page', |
| 147 | + 'api.php?action=query&prop=info&inprop=protection&titles=Main%20Page' |
93 | 148 | ); |
94 | 149 | } |
95 | 150 | |
Index: trunk/phase3/includes/Block.php |
— | — | @@ -628,11 +628,11 @@ |
629 | 629 | /** |
630 | 630 | * Decode expiry which has come from the DB |
631 | 631 | */ |
632 | | - static function decodeExpiry( $expiry ) { |
| 632 | + static function decodeExpiry( $expiry, $timestampType = TS_MW ) { |
633 | 633 | if ( $expiry == '' || $expiry == Block::infinity() ) { |
634 | 634 | return Block::infinity(); |
635 | 635 | } else { |
636 | | - return wfTimestamp( TS_MW, $expiry ); |
| 636 | + return wfTimestamp( $timestampType, $expiry ); |
637 | 637 | } |
638 | 638 | } |
639 | 639 | |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -209,6 +209,7 @@ |
210 | 210 | * (bug 10147) Now interwiki titles are not processed but added to a separate |
211 | 211 | "interwiki" section of the output. |
212 | 212 | * Added categorymembers list to query for pages in a category. |
| 213 | +* (bug 10260) Show page protection status |
213 | 214 | |
214 | 215 | == Maintenance script changes since 1.10 == |
215 | 216 | |