Property changes on: trunk/phase3/maintenance/archives/patch-protected_titles.sql |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 1 | + native |
Property changes on: trunk/phase3/includes/SpecialProtectedtitles.php |
___________________________________________________________________ |
Added: svn:eol-style |
2 | 2 | + native |
Index: trunk/phase3/includes/api/ApiQueryAllCategories.php |
— | — | @@ -1,142 +1,142 @@ |
2 | | -<?php
|
3 | | -
|
4 | | -/*
|
5 | | - * Created on December 12, 2007
|
6 | | - *
|
7 | | - * API for MediaWiki 1.8+
|
8 | | - *
|
9 | | - * Copyright (C) 2007 Roan Kattouw <Firstname>.<Lastname>@home.nl
|
10 | | - *
|
11 | | - * This program is free software; you can redistribute it and/or modify
|
12 | | - * it under the terms of the GNU General Public License as published by
|
13 | | - * the Free Software Foundation; either version 2 of the License, or
|
14 | | - * (at your option) any later version.
|
15 | | - *
|
16 | | - * This program is distributed in the hope that it will be useful,
|
17 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
19 | | - * GNU General Public License for more details.
|
20 | | - *
|
21 | | - * You should have received a copy of the GNU General Public License along
|
22 | | - * with this program; if not, write to the Free Software Foundation, Inc.,
|
23 | | - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
24 | | - * http://www.gnu.org/copyleft/gpl.html
|
25 | | - */
|
26 | | -
|
27 | | -if (!defined('MEDIAWIKI')) {
|
28 | | - // Eclipse helper - will be ignored in production
|
29 | | - require_once ('ApiQueryBase.php');
|
30 | | -}
|
31 | | -
|
32 | | -/**
|
33 | | - * Query module to enumerate all categories, even the ones that don't have
|
34 | | - * category pages.
|
35 | | - *
|
36 | | - * @addtogroup API
|
37 | | - */
|
38 | | -class ApiQueryAllCategories extends ApiQueryGeneratorBase {
|
39 | | -
|
40 | | - public function __construct($query, $moduleName) {
|
41 | | - parent :: __construct($query, $moduleName, 'ac');
|
42 | | - }
|
43 | | -
|
44 | | - public function execute() {
|
45 | | - $this->run();
|
46 | | - }
|
47 | | -
|
48 | | - public function executeGenerator($resultPageSet) {
|
49 | | - $this->run($resultPageSet);
|
50 | | - }
|
51 | | -
|
52 | | - private function run($resultPageSet = null) {
|
53 | | -
|
54 | | - $db = $this->getDB();
|
55 | | - $params = $this->extractRequestParams();
|
56 | | -
|
57 | | - $this->addTables('categorylinks');
|
58 | | - $this->addFields('cl_to');
|
59 | | -
|
60 | | - if (!is_null($params['from']))
|
61 | | - $this->addWhere('cl_to>=' . $db->addQuotes(ApiQueryBase :: titleToKey($params['from'])));
|
62 | | - if (isset ($params['prefix']))
|
63 | | - $this->addWhere("cl_to LIKE '" . $db->escapeLike(ApiQueryBase :: titleToKey($params['prefix'])) . "%'");
|
64 | | -
|
65 | | - $this->addOption('LIMIT', $params['limit']+1);
|
66 | | - $this->addOption('ORDER BY', 'cl_to' . ($params['dir'] == 'ZtoA' ? ' DESC' : ''));
|
67 | | - $this->addOption('DISTINCT');
|
68 | | -
|
69 | | - $res = $this->select(__METHOD__);
|
70 | | -
|
71 | | - $pages = array();
|
72 | | - $count = 0;
|
73 | | - while ($row = $db->fetchObject($res)) {
|
74 | | - if (++ $count > $params['limit']) {
|
75 | | - // We've reached the one extra which shows that there are additional cats to be had. Stop here...
|
76 | | - // TODO: Security issue - if the user has no right to view next title, it will still be shown
|
77 | | - $this->setContinueEnumParameter('from', ApiQueryBase :: keyToTitle($row->cl_to));
|
78 | | - break;
|
79 | | - }
|
80 | | -
|
81 | | - // Normalize titles
|
82 | | - $titleObj = Title::makeTitle(NS_CATEGORY, $row->cl_to);
|
83 | | - if(!is_null($resultPageSet))
|
84 | | - $pages[] = $titleObj->getPrefixedText();
|
85 | | - else
|
86 | | - // Don't show "Category:" everywhere in non-generator mode
|
87 | | - $pages[] = $titleObj->getText();
|
88 | | - }
|
89 | | - $db->freeResult($res);
|
90 | | -
|
91 | | - if (is_null($resultPageSet)) {
|
92 | | - $result = $this->getResult();
|
93 | | - $result->setIndexedTagName($pages, 'c');
|
94 | | - $result->addValue('query', $this->getModuleName(), $pages);
|
95 | | - } else {
|
96 | | - $resultPageSet->populateFromTitles($pages);
|
97 | | - }
|
98 | | - }
|
99 | | -
|
100 | | - protected function getAllowedParams() {
|
101 | | - return array (
|
102 | | - 'from' => null,
|
103 | | - 'prefix' => null,
|
104 | | - 'dir' => array(
|
105 | | - ApiBase :: PARAM_DFLT => 'ascending',
|
106 | | - ApiBase :: PARAM_TYPE => array(
|
107 | | - 'ascending',
|
108 | | - 'descending'
|
109 | | - ),
|
110 | | - ),
|
111 | | - 'limit' => array (
|
112 | | - ApiBase :: PARAM_DFLT => 10,
|
113 | | - ApiBase :: PARAM_TYPE => 'limit',
|
114 | | - ApiBase :: PARAM_MIN => 1,
|
115 | | - ApiBase :: PARAM_MAX => ApiBase :: LIMIT_BIG1,
|
116 | | - ApiBase :: PARAM_MAX2 => ApiBase :: LIMIT_BIG2
|
117 | | - )
|
118 | | - );
|
119 | | - }
|
120 | | -
|
121 | | - protected function getParamDescription() {
|
122 | | - return array (
|
123 | | - 'from' => 'The category to start enumerating from.',
|
124 | | - 'prefix' => 'Search for all category titles that begin with this value.',
|
125 | | - 'dir' => 'Direction to sort in.',
|
126 | | - 'limit' => 'How many categories to return.'
|
127 | | - );
|
128 | | - }
|
129 | | -
|
130 | | - protected function getDescription() {
|
131 | | - return 'Enumerate all categories';
|
132 | | - }
|
133 | | -
|
134 | | - protected function getExamples() {
|
135 | | - return array (
|
136 | | - 'api.php?action=query&generator=allcategories&gacprefix=List&prop=info',
|
137 | | - );
|
138 | | - }
|
139 | | -
|
140 | | - public function getVersion() {
|
141 | | - return __CLASS__ . ': $Id: ApiQueryAllLinks.php 28216 2007-12-06 18:33:18Z vasilievvv $';
|
142 | | - }
|
143 | | -}
|
| 2 | +<?php |
| 3 | + |
| 4 | +/* |
| 5 | + * Created on December 12, 2007 |
| 6 | + * |
| 7 | + * API for MediaWiki 1.8+ |
| 8 | + * |
| 9 | + * Copyright (C) 2007 Roan Kattouw <Firstname>.<Lastname>@home.nl |
| 10 | + * |
| 11 | + * This program is free software; you can redistribute it and/or modify |
| 12 | + * it under the terms of the GNU General Public License as published by |
| 13 | + * the Free Software Foundation; either version 2 of the License, or |
| 14 | + * (at your option) any later version. |
| 15 | + * |
| 16 | + * This program is distributed in the hope that it will be useful, |
| 17 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 | + * GNU General Public License for more details. |
| 20 | + * |
| 21 | + * You should have received a copy of the GNU General Public License along |
| 22 | + * with this program; if not, write to the Free Software Foundation, Inc., |
| 23 | + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 24 | + * http://www.gnu.org/copyleft/gpl.html |
| 25 | + */ |
| 26 | + |
| 27 | +if (!defined('MEDIAWIKI')) { |
| 28 | + // Eclipse helper - will be ignored in production |
| 29 | + require_once ('ApiQueryBase.php'); |
| 30 | +} |
| 31 | + |
| 32 | +/** |
| 33 | + * Query module to enumerate all categories, even the ones that don't have |
| 34 | + * category pages. |
| 35 | + * |
| 36 | + * @addtogroup API |
| 37 | + */ |
| 38 | +class ApiQueryAllCategories extends ApiQueryGeneratorBase { |
| 39 | + |
| 40 | + public function __construct($query, $moduleName) { |
| 41 | + parent :: __construct($query, $moduleName, 'ac'); |
| 42 | + } |
| 43 | + |
| 44 | + public function execute() { |
| 45 | + $this->run(); |
| 46 | + } |
| 47 | + |
| 48 | + public function executeGenerator($resultPageSet) { |
| 49 | + $this->run($resultPageSet); |
| 50 | + } |
| 51 | + |
| 52 | + private function run($resultPageSet = null) { |
| 53 | + |
| 54 | + $db = $this->getDB(); |
| 55 | + $params = $this->extractRequestParams(); |
| 56 | + |
| 57 | + $this->addTables('categorylinks'); |
| 58 | + $this->addFields('cl_to'); |
| 59 | + |
| 60 | + if (!is_null($params['from'])) |
| 61 | + $this->addWhere('cl_to>=' . $db->addQuotes(ApiQueryBase :: titleToKey($params['from']))); |
| 62 | + if (isset ($params['prefix'])) |
| 63 | + $this->addWhere("cl_to LIKE '" . $db->escapeLike(ApiQueryBase :: titleToKey($params['prefix'])) . "%'"); |
| 64 | + |
| 65 | + $this->addOption('LIMIT', $params['limit']+1); |
| 66 | + $this->addOption('ORDER BY', 'cl_to' . ($params['dir'] == 'ZtoA' ? ' DESC' : '')); |
| 67 | + $this->addOption('DISTINCT'); |
| 68 | + |
| 69 | + $res = $this->select(__METHOD__); |
| 70 | + |
| 71 | + $pages = array(); |
| 72 | + $count = 0; |
| 73 | + while ($row = $db->fetchObject($res)) { |
| 74 | + if (++ $count > $params['limit']) { |
| 75 | + // We've reached the one extra which shows that there are additional cats to be had. Stop here... |
| 76 | + // TODO: Security issue - if the user has no right to view next title, it will still be shown |
| 77 | + $this->setContinueEnumParameter('from', ApiQueryBase :: keyToTitle($row->cl_to)); |
| 78 | + break; |
| 79 | + } |
| 80 | + |
| 81 | + // Normalize titles |
| 82 | + $titleObj = Title::makeTitle(NS_CATEGORY, $row->cl_to); |
| 83 | + if(!is_null($resultPageSet)) |
| 84 | + $pages[] = $titleObj->getPrefixedText(); |
| 85 | + else |
| 86 | + // Don't show "Category:" everywhere in non-generator mode |
| 87 | + $pages[] = $titleObj->getText(); |
| 88 | + } |
| 89 | + $db->freeResult($res); |
| 90 | + |
| 91 | + if (is_null($resultPageSet)) { |
| 92 | + $result = $this->getResult(); |
| 93 | + $result->setIndexedTagName($pages, 'c'); |
| 94 | + $result->addValue('query', $this->getModuleName(), $pages); |
| 95 | + } else { |
| 96 | + $resultPageSet->populateFromTitles($pages); |
| 97 | + } |
| 98 | + } |
| 99 | + |
| 100 | + protected function getAllowedParams() { |
| 101 | + return array ( |
| 102 | + 'from' => null, |
| 103 | + 'prefix' => null, |
| 104 | + 'dir' => array( |
| 105 | + ApiBase :: PARAM_DFLT => 'ascending', |
| 106 | + ApiBase :: PARAM_TYPE => array( |
| 107 | + 'ascending', |
| 108 | + 'descending' |
| 109 | + ), |
| 110 | + ), |
| 111 | + 'limit' => array ( |
| 112 | + ApiBase :: PARAM_DFLT => 10, |
| 113 | + ApiBase :: PARAM_TYPE => 'limit', |
| 114 | + ApiBase :: PARAM_MIN => 1, |
| 115 | + ApiBase :: PARAM_MAX => ApiBase :: LIMIT_BIG1, |
| 116 | + ApiBase :: PARAM_MAX2 => ApiBase :: LIMIT_BIG2 |
| 117 | + ) |
| 118 | + ); |
| 119 | + } |
| 120 | + |
| 121 | + protected function getParamDescription() { |
| 122 | + return array ( |
| 123 | + 'from' => 'The category to start enumerating from.', |
| 124 | + 'prefix' => 'Search for all category titles that begin with this value.', |
| 125 | + 'dir' => 'Direction to sort in.', |
| 126 | + 'limit' => 'How many categories to return.' |
| 127 | + ); |
| 128 | + } |
| 129 | + |
| 130 | + protected function getDescription() { |
| 131 | + return 'Enumerate all categories'; |
| 132 | + } |
| 133 | + |
| 134 | + protected function getExamples() { |
| 135 | + return array ( |
| 136 | + 'api.php?action=query&generator=allcategories&gacprefix=List&prop=info', |
| 137 | + ); |
| 138 | + } |
| 139 | + |
| 140 | + public function getVersion() { |
| 141 | + return __CLASS__ . ': $Id: ApiQueryAllLinks.php 28216 2007-12-06 18:33:18Z vasilievvv $'; |
| 142 | + } |
| 143 | +} |
Property changes on: trunk/phase3/includes/api/ApiQueryAllCategories.php |
___________________________________________________________________ |
Added: svn:eol-style |
144 | 144 | + native |