Index: trunk/extensions/AdvancedSearch/AdvancedSearch.i18n.php |
— | — | @@ -6,7 +6,7 @@ |
7 | 7 | * (at your option) any later version. |
8 | 8 | * |
9 | 9 | * @author Roan Kattouw <roan.kattouw@home.nl> |
10 | | - * @copyright Copyright (C) 2008 Roan Kattouw |
| 10 | + * @copyright Copyright (C) 2008 Roan Kattouw |
11 | 11 | * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License |
12 | 12 | * |
13 | 13 | * An extension that allows for searching inside categories |
— | — | @@ -14,49 +14,41 @@ |
15 | 15 | * For information how to install and use this extension, see the README file. |
16 | 16 | * |
17 | 17 | */ |
18 | | -# Alert the user that this is not a valid entry point to MediaWiki if they try to access the extension file directly. |
19 | | -if (!defined('MEDIAWIKI')) { |
20 | | - echo <<<EOT |
21 | | -To install the AdvancedSearch extension, put the following line in LocalSettings.php: |
22 | | -require_once( "\$IP/extensions/AdvancedSearch/AdvancedSearch.setup.php" ); |
23 | | -EOT; |
24 | | - exit(1); |
25 | | -} |
26 | 18 | |
27 | 19 | $messages = array(); |
28 | 20 | |
29 | 21 | $messages['en'] = array( |
30 | | - 'advancedsearch' => 'Advanced Search', |
31 | | - 'advancedsearch-toptext' => 'This is the advanced search, see [[Help:Search]] for more information', |
32 | | - 'advancedsearch-pagename' => 'AdvancedSearch', |
33 | | - 'advancedsearch-title' => 'Advanced Search', |
34 | | - 'advancedsearch-contentsearch' => 'Search in page content', |
35 | | - 'advancedsearch-searchin' => 'Search in:', |
36 | | - 'advancedsearch-searchin-title' => 'titles', |
37 | | - 'advancedsearch-searchin-content' => 'content', |
38 | | - 'advancedsearch-content-include' => 'List articles that contain:', |
39 | | - 'advancedsearch-content-exclude' => 'Don\'t list articles that contain:', |
40 | | - 'advancedsearch-categorysearch' => 'Search in categories', |
41 | | - 'advancedsearch-category-include' => 'List articles in these categories:', |
42 | | - 'advancedsearch-category-exclude' => 'Don\'t list articles in these categories:', |
43 | | - 'advancedsearch-speedcats' => 'Common categories', |
44 | | - 'advancedsearch-speedcat-dropdown' => 'Choose a category:', |
45 | | - 'advancedsearch-namespaces' => 'Namespaces', |
46 | | - 'advancedsearch-selectall' => 'Select all', |
47 | | - 'advancedsearch-selectnone' => 'Deselect all', |
48 | | - 'advancedsearch-invertselection' => 'Invert selection', |
49 | | - 'advancedsearch-submit' => 'Search', |
50 | | - 'advancedsearch-keyword-and' => 'AND', |
51 | | - 'advancedsearch-keyword-or' => 'OR', |
52 | | - 'advancedsearch-permalink' => 'A permanent link to this search is $1.', |
53 | | - 'advancedsearch-permalink-text' => 'here', |
54 | | - 'advancedsearch-permalink-check' => 'Get a permanent link to this search', |
55 | | - 'advancedsearch-permalink-invalid' => 'The permanent link you clicked is invalid', |
56 | | - 'advancedsearch-parse-error-1' => 'Parse error: unexpected \'$2\': <i>$1 <b>$2</b> $3</i>', |
57 | | - 'advancedsearch-parse-error-2' => 'Parse error: found \')\' without matching \'(\': <i>$1 <b>$2</b> $3</i>', |
58 | | - 'advancedsearch-parse-error-3' => 'Parse error: found more \'(\' than \')\'', |
59 | | - 'advancedsearch-parse-error-4' => 'Parse error: unterminated "', |
60 | | - 'advancedsearch-parse-error-5' => '"$1" is shorter than four letters. Such short words are not allowed', |
61 | | - 'advancedsearch-parse-error-6' => '"$1" is a frequently-used word. Such words are not allowed', |
62 | | - 'advancedsearch-empty-result' => 'No matches were found for your search', |
| 22 | + 'advancedsearch' => 'Advanced Search', |
| 23 | + 'advancedsearch-toptext' => 'This is the advanced search, see [[Help:Search]] for more information', |
| 24 | + 'advancedsearch-pagename' => 'AdvancedSearch', |
| 25 | + 'advancedsearch-title' => 'Advanced Search', |
| 26 | + 'advancedsearch-contentsearch' => 'Search in page content', |
| 27 | + 'advancedsearch-searchin' => 'Search in:', |
| 28 | + 'advancedsearch-searchin-title' => 'titles', |
| 29 | + 'advancedsearch-searchin-content' => 'content', |
| 30 | + 'advancedsearch-content-include' => 'List articles that contain:', |
| 31 | + 'advancedsearch-content-exclude' => 'Don\'t list articles that contain:', |
| 32 | + 'advancedsearch-categorysearch' => 'Search in categories', |
| 33 | + 'advancedsearch-category-include' => 'List articles in these categories:', |
| 34 | + 'advancedsearch-category-exclude' => 'Don\'t list articles in these categories:', |
| 35 | + 'advancedsearch-speedcats' => 'Common categories', |
| 36 | + 'advancedsearch-speedcat-dropdown' => 'Choose a category:', |
| 37 | + 'advancedsearch-namespaces' => 'Namespaces', |
| 38 | + 'advancedsearch-selectall' => 'Select all', |
| 39 | + 'advancedsearch-selectnone' => 'Deselect all', |
| 40 | + 'advancedsearch-invertselection' => 'Invert selection', |
| 41 | + 'advancedsearch-submit' => 'Search', |
| 42 | + 'advancedsearch-keyword-and' => 'AND', |
| 43 | + 'advancedsearch-keyword-or' => 'OR', |
| 44 | + 'advancedsearch-permalink' => 'A permanent link to this search is $1.', |
| 45 | + 'advancedsearch-permalink-text' => 'here', |
| 46 | + 'advancedsearch-permalink-check' => 'Get a permanent link to this search', |
| 47 | + 'advancedsearch-permalink-invalid' => 'The permanent link you clicked is invalid', |
| 48 | + 'advancedsearch-parse-error-1' => 'Parse error: unexpected \'$2\': <i>$1 <b>$2</b> $3</i>', |
| 49 | + 'advancedsearch-parse-error-2' => 'Parse error: found \')\' without matching \'(\': <i>$1 <b>$2</b> $3</i>', |
| 50 | + 'advancedsearch-parse-error-3' => 'Parse error: found more \'(\' than \')\'', |
| 51 | + 'advancedsearch-parse-error-4' => 'Parse error: unterminated "', |
| 52 | + 'advancedsearch-parse-error-5' => '"$1" is shorter than four letters. Such short words are not allowed', |
| 53 | + 'advancedsearch-parse-error-6' => '"$1" is a frequently-used word. Such words are not allowed', |
| 54 | + 'advancedsearch-empty-result' => 'No matches were found for your search', |
63 | 55 | ); |
Index: trunk/extensions/AdvancedSearch/AdvancedSearch.setup.php |
— | — | @@ -6,7 +6,7 @@ |
7 | 7 | * (at your option) any later version. |
8 | 8 | * |
9 | 9 | * @author Roan Kattouw <roan.kattouw@home.nl> |
10 | | - * @copyright Copyright (C) 2008 Roan Kattouw |
| 10 | + * @copyright Copyright (C) 2008 Roan Kattouw |
11 | 11 | * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License |
12 | 12 | * |
13 | 13 | * An extension that allows for searching inside categories |
— | — | @@ -15,12 +15,12 @@ |
16 | 16 | * |
17 | 17 | */ |
18 | 18 | # Alert the user that this is not a valid entry point to MediaWiki if they try to access the extension file directly. |
19 | | -if (!defined('MEDIAWIKI')) { |
| 19 | +if ( !defined( 'MEDIAWIKI' ) ) { |
20 | 20 | echo <<<EOT |
21 | 21 | To install the AdvancedSearch extension, put the following line in LocalSettings.php: |
22 | 22 | require_once( "\$IP/extensions/AdvancedSearch/AdvancedSearch.setup.php" ); |
23 | 23 | EOT; |
24 | | - exit(1); |
| 24 | + exit( 1 ); |
25 | 25 | } |
26 | 26 | |
27 | 27 | $wgExtensionCredits['specialpage'][] = array( |
— | — | @@ -33,7 +33,7 @@ |
34 | 34 | 'descriptionmsg' => 'advancedsearch-desc', |
35 | 35 | ); |
36 | 36 | |
37 | | -$dir = dirname(__FILE__) . '/'; |
| 37 | +$dir = dirname( __FILE__ ) . '/'; |
38 | 38 | $wgExtensionMessagesFiles['AdvancedSearch'] = $dir . 'AdvancedSearch.i18n.php'; |
39 | 39 | $wgAutoloadClasses['AdvancedSearch'] = $dir . 'AdvancedSearch.body.php'; |
40 | 40 | $wgAutoloadClasses['AdvancedSearchPager'] = $dir . 'AdvancedSearchPager.php'; |
— | — | @@ -45,20 +45,18 @@ |
46 | 46 | $wgHooks['LinksUpdate'][] = 'AdvancedSearchCategoryIntersector::LinksUpdate'; |
47 | 47 | $wgHooks['ArticleDeleteComplete'][] = 'AdvancedSearchCategoryIntersector::ArticleDeleteComplete'; |
48 | 48 | |
49 | | -function AdvancedSearchLocalizedPageName(&$specialPageArray, $code) |
50 | | -{ |
51 | | - wfLoadExtensionMessages('AdvancedSearch'); |
52 | | - $text = wfMsg('advancedsearch-pagename'); |
| 49 | +function AdvancedSearchLocalizedPageName( &$specialPageArray, $code ) { |
| 50 | + wfLoadExtensionMessages( 'AdvancedSearch' ); |
| 51 | + $text = wfMsg( 'advancedsearch-pagename' ); |
53 | 52 | |
54 | | - $title = Title::newFromText($text); |
| 53 | + $title = Title::newFromText( $text ); |
55 | 54 | $specialPageArray['AdvancedSearch'][] = $title->getDBkey(); |
56 | 55 | return true; |
57 | 56 | } |
58 | 57 | |
59 | | -function AdvancedSearchSchemaUpdate() |
60 | | -{ |
| 58 | +function AdvancedSearchSchemaUpdate() { |
61 | 59 | global $wgExtNewTables; |
62 | | - $dir = dirname(__FILE__) . '/'; |
63 | | - $wgExtNewTables[] = array('categorysearch', $dir . 'categorysearch.sql'); |
| 60 | + $dir = dirname( __FILE__ ) . '/'; |
| 61 | + $wgExtNewTables[] = array( 'categorysearch', $dir . 'categorysearch.sql' ); |
64 | 62 | return true; |
65 | 63 | } |
Index: trunk/extensions/AdvancedSearch/AdvancedSearchPager.php |
— | — | @@ -6,7 +6,7 @@ |
7 | 7 | * (at your option) any later version. |
8 | 8 | * |
9 | 9 | * @author Roan Kattouw <roan.kattouw@home.nl> |
10 | | - * @copyright Copyright (C) 2008 Roan Kattouw |
| 10 | + * @copyright Copyright (C) 2008 Roan Kattouw |
11 | 11 | * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License |
12 | 12 | * |
13 | 13 | * An extension that allows for searching inside categories |
— | — | @@ -15,26 +15,25 @@ |
16 | 16 | * |
17 | 17 | */ |
18 | 18 | # Alert the user that this is not a valid entry point to MediaWiki if they try to access the extension file directly. |
19 | | -if (!defined('MEDIAWIKI')) { |
| 19 | +if ( !defined( 'MEDIAWIKI' ) ) { |
20 | 20 | echo <<<EOT |
21 | 21 | To install the AdvancedSearch extension, put the following line in LocalSettings.php: |
22 | 22 | require_once( "\$IP/extensions/AdvancedSearch/AdvancedSearch.setup.php" ); |
23 | 23 | EOT; |
24 | | - exit(1); |
| 24 | + exit( 1 ); |
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
28 | 28 | * Class that pages search results |
29 | | - * |
| 29 | + * |
30 | 30 | * FIXME: Only works with MySQL, not with PostGreSQL or Oracle |
31 | 31 | */ |
32 | | -class AdvancedSearchPager |
33 | | -{ |
| 32 | +class AdvancedSearchPager { |
34 | 33 | // array(array('foo', bar'), array('baz')) means |
35 | 34 | // foo AND bar OR baz |
36 | 35 | protected $mInclText, $mExclText, $mInclCats, $mExclCats, $mNamespaces; |
37 | 36 | protected $mSearchTitle, $mSearchContent, $mKey; |
38 | | - |
| 37 | + |
39 | 38 | /** A list of stop words ignored by the MySQL fulltext search */ |
40 | 39 | static $stopWords = array( |
41 | 40 | 'a\'s', 'able', 'about', 'above', 'according', 'accordingly', |
— | — | @@ -61,7 +60,7 @@ |
62 | 61 | 'elsewhere', 'enough', 'entirely', 'especially', 'et', 'etc', |
63 | 62 | 'even', 'ever', 'every', 'everybody', 'everyone', 'everything', |
64 | 63 | 'everywhere', 'ex', 'exactly', 'example', 'except', 'far', |
65 | | - 'few', 'fifth', 'first', 'five', 'followed', 'following', |
| 64 | + 'few', 'fifth', 'first', 'five', 'followed', 'following', |
66 | 65 | 'follows', 'for', 'former', 'formerly', 'forth', 'four', |
67 | 66 | 'from', 'further', 'furthermore', 'get', 'gets', 'getting', |
68 | 67 | 'given', 'gives', 'go', 'goes', 'going', 'gone', 'got', |
— | — | @@ -124,7 +123,7 @@ |
125 | 124 | 'whose', 'why', 'will', 'willing', 'wish', 'with', 'within', |
126 | 125 | 'without', 'won\'t', 'wonder', 'would', 'would', 'wouldn\'t', |
127 | 126 | 'yes', 'yet', 'you', 'you\'d', 'you\'ll', 'you\'re', 'you\'ve', |
128 | | - 'your', 'yours', 'yourself', 'yourselves', 'zero'); |
| 127 | + 'your', 'yours', 'yourself', 'yourselves', 'zero' ); |
129 | 128 | |
130 | 129 | /** |
131 | 130 | * Constructor |
— | — | @@ -136,54 +135,49 @@ |
137 | 136 | * @param $namespaces array Array of NS_* constants |
138 | 137 | * @param $permalink bool If true, cache this query longer |
139 | 138 | */ |
140 | | - public function __construct($incltext, $excltext, $inclcats, $exclcats, $speedcats, $dropdown, $namespaces, $searchTitle, $searchContent) |
141 | | - { |
142 | | - $this->mInclText = $this->parse($incltext, true); |
143 | | - $this->mExclText = $this->parse($excltext, true); |
| 139 | + public function __construct( $incltext, $excltext, $inclcats, $exclcats, $speedcats, $dropdown, $namespaces, $searchTitle, $searchContent ) { |
| 140 | + $this->mInclText = $this->parse( $incltext, true ); |
| 141 | + $this->mExclText = $this->parse( $excltext, true ); |
144 | 142 | |
145 | | - $sc = implode(' ' . wfMsg('advancedsearch-keyword-or') . ' ', $speedcats); |
| 143 | + $sc = implode( ' ' . wfMsg( 'advancedsearch-keyword-or' ) . ' ', $speedcats ); |
146 | 144 | $ic = "( $inclcats ) AND ( $sc ) AND ( $dropdown )"; |
147 | | - $this->mInclCats = $this->parse($ic, false); |
148 | | - $this->mExclCats = $this->parse($exclcats, false); |
| 145 | + $this->mInclCats = $this->parse( $ic, false ); |
| 146 | + $this->mExclCats = $this->parse( $exclcats, false ); |
149 | 147 | $this->mNamespaces = $namespaces; |
150 | 148 | $this->mSearchTitle = $searchTitle; |
151 | 149 | $this->mSearchContent = $searchContent; |
152 | | - $this->mKey = md5(implode("\0", array($incltext, $excltext, $ic, $exclcats, |
153 | | - implode(',', $namespaces), |
| 150 | + $this->mKey = md5( implode( "\0", array( $incltext, $excltext, $ic, $exclcats, |
| 151 | + implode( ',', $namespaces ), |
154 | 152 | $searchTitle ? 1 : 0, |
155 | | - $searchContent ? 1 : 0))); |
| 153 | + $searchContent ? 1 : 0 ) ) ); |
156 | 154 | |
157 | 155 | # Check whether all namespace boxes were checked |
158 | 156 | # If so, save some work |
159 | | - if($this->mNamespaces == array_keys(AdvancedSearch::searchableNamespaces())) |
| 157 | + if ( $this->mNamespaces == array_keys( AdvancedSearch::searchableNamespaces() ) ) |
160 | 158 | $this->mNamespaces = array(); |
161 | | - $this->mDb = wfGetDb(DB_SLAVE); |
| 159 | + $this->mDb = wfGetDb( DB_SLAVE ); |
162 | 160 | } |
163 | | - |
164 | | - public function getSearchTitle() |
165 | | - { |
| 161 | + |
| 162 | + public function getSearchTitle() { |
166 | 163 | return $this->mSearchTitle; |
167 | 164 | } |
168 | | - |
169 | | - public function getSearchContent() |
170 | | - { |
| 165 | + |
| 166 | + public function getSearchContent() { |
171 | 167 | return $this->mSearchContent; |
172 | 168 | } |
173 | | - |
174 | | - public function cacheQuery() |
175 | | - { |
| 169 | + |
| 170 | + public function cacheQuery() { |
176 | 171 | global $wgMemc; |
177 | | - $key = wfMemcKey('advancedsearch', $this->mKey); |
178 | | - $wgMemc->set($key, $this); |
| 172 | + $key = wfMemcKey( 'advancedsearch', $this->mKey ); |
| 173 | + $wgMemc->set( $key, $this ); |
179 | 174 | return $this->mKey; |
180 | 175 | } |
181 | | - |
182 | | - public static function newFromKey($key) |
183 | | - { |
| 176 | + |
| 177 | + public static function newFromKey( $key ) { |
184 | 178 | global $wgMemc; |
185 | | - $retval = $wgMemc->get(wfMemcKey('advancedsearch', $key)); |
186 | | - if($retval instanceof AdvancedSearchPager) |
187 | | - $retval->mDb = wfGetDb(DB_SLAVE); |
| 179 | + $retval = $wgMemc->get( wfMemcKey( 'advancedsearch', $key ) ); |
| 180 | + if ( $retval instanceof AdvancedSearchPager ) |
| 181 | + $retval->mDb = wfGetDb( DB_SLAVE ); |
188 | 182 | return $retval; |
189 | 183 | } |
190 | 184 | |
— | — | @@ -191,13 +185,12 @@ |
192 | 186 | * Find out whether any errors occurred when parsing the search strings |
193 | 187 | * @return array Array of errors, which are either strings or false (no error) |
194 | 188 | */ |
195 | | - public function getParseErrors() |
196 | | - { |
| 189 | + public function getParseErrors() { |
197 | 190 | return array( |
198 | | - (is_string($this->mInclText) ? $this->mInclText : false), |
199 | | - (is_string($this->mExclText) ? $this->mExclText : false), |
200 | | - (is_string($this->mInclCats) ? $this->mInclCats : false), |
201 | | - (is_string($this->mExclCats) ? $this->mExclCats : false) |
| 191 | + ( is_string( $this->mInclText ) ? $this->mInclText : false ), |
| 192 | + ( is_string( $this->mExclText ) ? $this->mExclText : false ), |
| 193 | + ( is_string( $this->mInclCats ) ? $this->mInclCats : false ), |
| 194 | + ( is_string( $this->mExclCats ) ? $this->mExclCats : false ) |
202 | 195 | ); |
203 | 196 | } |
204 | 197 | |
— | — | @@ -207,12 +200,11 @@ |
208 | 201 | * @param $indices array Array of indices, i.e. array(1,2,3) gets $arr[1][2][3] |
209 | 202 | * @return mixed |
210 | 203 | */ |
211 | | - public static function getFromArray($arr, $indices) |
212 | | - { |
213 | | - $i = array_shift($indices); |
214 | | - if(empty($indices)) |
| 204 | + public static function getFromArray( $arr, $indices ) { |
| 205 | + $i = array_shift( $indices ); |
| 206 | + if ( empty( $indices ) ) |
215 | 207 | return @$arr[$i]; |
216 | | - return self::getFromArray(@$arr[$i], $indices); |
| 208 | + return self::getFromArray( @$arr[$i], $indices ); |
217 | 209 | } |
218 | 210 | |
219 | 211 | /** |
— | — | @@ -221,13 +213,12 @@ |
222 | 214 | * @param $arr array Array to work on |
223 | 215 | * @param $indices array See getFromArray() |
224 | 216 | */ |
225 | | - public static function setInArray($value, &$arr, $indices) |
226 | | - { |
227 | | - $i = array_shift($indices); |
228 | | - if(empty($indices)) |
| 217 | + public static function setInArray( $value, &$arr, $indices ) { |
| 218 | + $i = array_shift( $indices ); |
| 219 | + if ( empty( $indices ) ) |
229 | 220 | $arr[$i] = $value; |
230 | 221 | else |
231 | | - self::setInArray($value, $arr[$i], $indices); |
| 222 | + self::setInArray( $value, $arr[$i], $indices ); |
232 | 223 | } |
233 | 224 | |
234 | 225 | /** |
— | — | @@ -236,67 +227,66 @@ |
237 | 228 | * @param $parseSpaces bool If true, parse spaces as ANDs |
238 | 229 | * @return mixed Array, or error message (string) if $text is invalid |
239 | 230 | */ |
240 | | - protected function parse($text, $parseSpaces) |
241 | | - { |
| 231 | + protected function parse( $text, $parseSpaces ) { |
242 | 232 | $arr = array(); |
243 | | - $boom = explode(' ', $text); |
| 233 | + $boom = explode( ' ', $text ); |
244 | 234 | // Keep track of where we are in $arr |
245 | | - $indices = array(0, 0); |
| 235 | + $indices = array( 0, 0 ); |
246 | 236 | $depth = 0; |
247 | | - $tokens = array(wfMsg('advancedsearch-keyword-and'), |
248 | | - wfMsg('advancedsearch-keyword-or'), |
249 | | - '(', ')', ''); |
| 237 | + $tokens = array( wfMsg( 'advancedsearch-keyword-and' ), |
| 238 | + wfMsg( 'advancedsearch-keyword-or' ), |
| 239 | + '(', ')', '' ); |
250 | 240 | // We can expect two things: |
251 | 241 | // 'token': we expect AND, OR, ) or a continuation |
252 | 242 | // 'word': we expect ( or text |
253 | 243 | $expecting = 'word'; |
254 | | - for($i = 0; $i < count($boom); $i++) |
| 244 | + for ( $i = 0; $i < count( $boom ); $i++ ) |
255 | 245 | { |
256 | | - if($expecting == 'token') |
| 246 | + if ( $expecting == 'token' ) |
257 | 247 | { |
258 | | - if($boom[$i] == wfMsg('advancedsearch-keyword-and')) |
| 248 | + if ( $boom[$i] == wfMsg( 'advancedsearch-keyword-and' ) ) |
259 | 249 | { |
260 | 250 | // Increment the last index |
261 | | - end($indices); |
262 | | - $indices[key($indices)]++; |
| 251 | + end( $indices ); |
| 252 | + $indices[key( $indices )]++; |
263 | 253 | $expecting = 'word'; |
264 | 254 | continue; |
265 | 255 | } |
266 | | - if($boom[$i] == wfMsg('advancedsearch-keyword-or')) |
| 256 | + if ( $boom[$i] == wfMsg( 'advancedsearch-keyword-or' ) ) |
267 | 257 | { |
268 | 258 | // Increment the second-to-last index |
269 | 259 | // and set the last one to 0 |
270 | | - end($indices); |
271 | | - $indices[key($indices)] = 0; |
272 | | - prev($indices); |
273 | | - $indices[key($indices)]++; |
| 260 | + end( $indices ); |
| 261 | + $indices[key( $indices )] = 0; |
| 262 | + prev( $indices ); |
| 263 | + $indices[key( $indices )]++; |
274 | 264 | $expecting = 'word'; |
275 | 265 | continue; |
276 | 266 | } |
277 | 267 | // ( is invalid here |
278 | | - if($boom[$i] == '(') |
279 | | - return wfMsg('advancedsearch-parse-error-1', |
280 | | - htmlspecialchars(@$boom[$i - 1]), |
281 | | - htmlspecialchars($boom[$i]), |
282 | | - htmlspecialchars(@$boom[$i + 1])); |
| 268 | + if ( $boom[$i] == '(' ) |
| 269 | + return wfMsg( 'advancedsearch-parse-error-1', |
| 270 | + htmlspecialchars( @$boom[$i - 1] ), |
| 271 | + htmlspecialchars( $boom[$i] ), |
| 272 | + htmlspecialchars( @$boom[$i + 1] ) ); |
283 | 273 | // We found a word, so it's a continuation |
284 | | - if($parseSpaces && $boom[$i] != ')') |
| 274 | + if ( $parseSpaces && $boom[$i] != ')' ) |
285 | 275 | { |
286 | 276 | // Increment the last index |
287 | | - end($indices); |
288 | | - $indices[key($indices)]++; |
| 277 | + end( $indices ); |
| 278 | + $indices[key( $indices )]++; |
289 | 279 | } |
290 | 280 | } |
291 | 281 | // We're expecting a word |
292 | 282 | // Check that it's not a token |
293 | | - if($boom[$i] == wfMsg('advancedsearch-keyword-and') || |
294 | | - $boom[$i] == wfMsg('advancedsearch-keyword-or')) |
295 | | - return wfMsg('advancedsearch-parse-error-1', |
296 | | - htmlspecialchars(@$boom[$i - 1]), |
297 | | - htmlspecialchars($boom[$i]), |
298 | | - htmlspecialchars(@$boom[$i + 1])); |
| 283 | + if ( $boom[$i] == wfMsg( 'advancedsearch-keyword-and' ) || |
| 284 | + $boom[$i] == wfMsg( 'advancedsearch-keyword-or' ) ) |
| 285 | + return wfMsg( 'advancedsearch-parse-error-1', |
| 286 | + htmlspecialchars( @$boom[$i - 1] ), |
| 287 | + htmlspecialchars( $boom[$i] ), |
| 288 | + htmlspecialchars( @$boom[$i + 1] ) ); |
299 | 289 | // See if it's ( or ) |
300 | | - if($boom[$i] == '(') |
| 290 | + if ( $boom[$i] == '(' ) |
301 | 291 | { |
302 | 292 | // Go one level deeper |
303 | 293 | $indices[] = 0; |
— | — | @@ -305,283 +295,272 @@ |
306 | 296 | $expecting = 'word'; |
307 | 297 | continue; |
308 | 298 | } |
309 | | - if($boom[$i] == ')') |
| 299 | + if ( $boom[$i] == ')' ) |
310 | 300 | { |
311 | 301 | // Go one level down |
312 | 302 | $depth--; |
313 | | - if($depth < 0) |
| 303 | + if ( $depth < 0 ) |
314 | 304 | // More ) than ( |
315 | | - return wfMsg('advancedsearch-parse-error-2', |
316 | | - htmlspecialchars(@$boom[$i - 1]), |
317 | | - htmlspecialchars($boom[$i]), |
318 | | - htmlspecialchars(@$boom[$i + 1])); |
319 | | - array_pop($indices); |
320 | | - array_pop($indices); |
| 305 | + return wfMsg( 'advancedsearch-parse-error-2', |
| 306 | + htmlspecialchars( @$boom[$i - 1] ), |
| 307 | + htmlspecialchars( $boom[$i] ), |
| 308 | + htmlspecialchars( @$boom[$i + 1] ) ); |
| 309 | + array_pop( $indices ); |
| 310 | + array_pop( $indices ); |
321 | 311 | $expecting = 'token'; |
322 | 312 | continue; |
323 | 313 | } |
324 | 314 | // Parse quotes |
325 | | - if(substr($boom[$i], 0, 1) == '"') |
| 315 | + if ( substr( $boom[$i], 0, 1 ) == '"' ) |
326 | 316 | { |
327 | 317 | $word = $boom[$i]; |
328 | | - while(substr($word, -1) !== '"') |
| 318 | + while ( substr( $word, - 1 ) !== '"' ) |
329 | 319 | { |
330 | 320 | $i++; |
331 | | - if(!isset($boom[$i])) |
332 | | - return wfMsg('advancedsearch-parse-error-4'); |
333 | | - $word .= ' '. $boom[$i]; |
| 321 | + if ( !isset( $boom[$i] ) ) |
| 322 | + return wfMsg( 'advancedsearch-parse-error-4' ); |
| 323 | + $word .= ' ' . $boom[$i]; |
334 | 324 | } |
335 | 325 | # Strip the quotes |
336 | | - $word = substr($word, 1, -1); |
| 326 | + $word = substr( $word, 1, - 1 ); |
337 | 327 | } |
338 | 328 | else |
339 | 329 | $word = $boom[$i]; |
340 | 330 | // Put this word in the array |
341 | | - $lastAdded = self::getFromArray($arr, $indices); |
342 | | - if(empty($lastAdded)) |
| 331 | + $lastAdded = self::getFromArray( $arr, $indices ); |
| 332 | + if ( empty( $lastAdded ) ) |
343 | 333 | { |
344 | | - if($parseSpaces || in_array(@$boom[$i + 1], $tokens)) |
345 | | - { |
| 334 | + if ( $parseSpaces || in_array( @$boom[$i + 1], $tokens ) ) |
| 335 | + { |
346 | 336 | # We got a single word. Check that it's not too |
347 | 337 | # short or a stop word |
348 | | - if(strlen($word) <= 3 && $word != '') |
349 | | - return wfMsg('advancedsearch-parse-error-5', $word); |
350 | | - if(in_array($word, self::$stopWords)) |
351 | | - return wfMsg('advancedsearch-parse-error-6', $word); |
| 338 | + if ( strlen( $word ) <= 3 && $word != '' ) |
| 339 | + return wfMsg( 'advancedsearch-parse-error-5', $word ); |
| 340 | + if ( in_array( $word, self::$stopWords ) ) |
| 341 | + return wfMsg( 'advancedsearch-parse-error-6', $word ); |
352 | 342 | } |
353 | | - self::setInArray($word, $arr, $indices); |
| 343 | + self::setInArray( $word, $arr, $indices ); |
354 | 344 | } |
355 | 345 | else |
356 | | - self::setInArray("$lastAdded $word", $arr, $indices); |
| 346 | + self::setInArray( "$lastAdded $word", $arr, $indices ); |
357 | 347 | $expecting = 'token'; |
358 | 348 | } |
359 | 349 | // Check if all ( were closed |
360 | | - if($depth != 0) |
361 | | - return wfMsg('advancedsearch-parse-error-3'); |
| 350 | + if ( $depth != 0 ) |
| 351 | + return wfMsg( 'advancedsearch-parse-error-3' ); |
362 | 352 | return $arr; |
363 | 353 | } |
364 | | - |
| 354 | + |
365 | 355 | /** |
366 | 356 | * Is an array really empty? Also checks for nested emptiness, e.g. |
367 | 357 | * array(array('')) |
368 | 358 | * @param $arr array |
369 | 359 | * @return bool |
370 | 360 | */ |
371 | | - static function isEmpty($arr) |
372 | | - { |
373 | | - if(empty($arr)) |
| 361 | + static function isEmpty( $arr ) { |
| 362 | + if ( empty( $arr ) ) |
374 | 363 | return true; |
375 | | - if(!is_array($arr)) |
| 364 | + if ( !is_array( $arr ) ) |
376 | 365 | return false; |
377 | | - foreach($arr as $a) |
378 | | - if(!self::isEmpty($a)) |
| 366 | + foreach ( $arr as $a ) |
| 367 | + if ( !self::isEmpty( $a ) ) |
379 | 368 | return false; |
380 | 369 | return true; |
381 | | - } |
| 370 | + } |
382 | 371 | |
383 | 372 | /** |
384 | 373 | * Generate a MATCH condition |
385 | 374 | * @param $arr array $m{Incl,Excl}{Text,Cats} |
386 | 375 | * @return string A MATCH condition |
387 | 376 | */ |
388 | | - protected function getMatchString($arr) |
389 | | - { |
| 377 | + protected function getMatchString( $arr ) { |
390 | 378 | $conds = array(); |
391 | 379 | $searchEngine = SearchEngine::create(); |
392 | | - foreach($arr as $a) |
| 380 | + foreach ( $arr as $a ) |
393 | 381 | { |
394 | 382 | $subconds = array(); |
395 | | - foreach((array)$a as $b) |
| 383 | + foreach ( (array)$a as $b ) |
396 | 384 | { |
397 | | - if(is_array($b)) |
| 385 | + if ( is_array( $b ) ) |
398 | 386 | { |
399 | | - $m = $this->getMatchString($b); |
400 | | - if(!empty($m)) |
| 387 | + $m = $this->getMatchString( $b ); |
| 388 | + if ( !empty( $m ) ) |
401 | 389 | $subconds[] = "+($m)"; |
402 | 390 | } |
403 | 391 | else |
404 | 392 | { |
405 | 393 | global $wgContLang; |
406 | | - $s = $wgContLang->normalizeForSearch($b); |
407 | | - $s = $searchEngine->normalizeText($s); |
408 | | - $s = $this->mDb->strencode($s); |
| 394 | + $s = $wgContLang->normalizeForSearch( $b ); |
| 395 | + $s = $searchEngine->normalizeText( $s ); |
| 396 | + $s = $this->mDb->strencode( $s ); |
409 | 397 | # If $s contains spaces or ( ) :, quote it |
410 | | - if(strpos($s, ' ') !== false |
411 | | - || strpos($s, '(') !== false |
412 | | - || strpos($s, ')') !== false |
413 | | - || strpos($s, ':') !== false) |
| 398 | + if ( strpos( $s, ' ' ) !== false |
| 399 | + || strpos( $s, '(' ) !== false |
| 400 | + || strpos( $s, ')' ) !== false |
| 401 | + || strpos( $s, ':' ) !== false ) |
414 | 402 | $s = "\"$s\""; |
415 | | - if(!empty($s)) |
| 403 | + if ( !empty( $s ) ) |
416 | 404 | $subconds[] = "+$s"; |
417 | 405 | } |
418 | 406 | } |
419 | | - $sc = implode(' ', $subconds); |
420 | | - if(!empty($sc)) |
| 407 | + $sc = implode( ' ', $subconds ); |
| 408 | + if ( !empty( $sc ) ) |
421 | 409 | $conds[] = "($sc)"; |
422 | 410 | } |
423 | | - return implode(' ', $conds); |
| 411 | + return implode( ' ', $conds ); |
424 | 412 | } |
425 | | - |
| 413 | + |
426 | 414 | /** |
427 | 415 | * Get the DB key for a category |
428 | 416 | * @param $c string Category name |
429 | 417 | */ |
430 | | - public static function categoryKey(&$c) |
431 | | - { |
432 | | - $t = Title::makeTitleSafe(NS_CATEGORY, $c); |
433 | | - if(!$t) |
| 418 | + public static function categoryKey( &$c ) { |
| 419 | + $t = Title::makeTitleSafe( NS_CATEGORY, $c ); |
| 420 | + if ( !$t ) |
434 | 421 | return false; |
435 | 422 | $c = $t->getDBkey(); |
436 | 423 | } |
437 | 424 | |
438 | | - public function getQueryInfo() |
439 | | - { |
| 425 | + public function getQueryInfo() { |
440 | 426 | $db = $this->mDb; |
441 | 427 | $retval = array(); |
442 | 428 | |
443 | | - $incltext = $db->strencode($this->getMatchString($this->mInclText)); |
444 | | - $excltext = $db->strencode($this->getMatchString($this->mExclText)); |
445 | | - array_walk_recursive($this->mInclCats, array(__CLASS__, 'categoryKey')); |
446 | | - array_walk_recursive($this->mExclCats, array(__CLASS__, 'categoryKey')); |
447 | | - $inclcats = $db->strencode($this->getMatchString($this->mInclCats)); |
448 | | - $exclcats = $db->strencode($this->getMatchString($this->mExclCats)); |
449 | | - |
| 429 | + $incltext = $db->strencode( $this->getMatchString( $this->mInclText ) ); |
| 430 | + $excltext = $db->strencode( $this->getMatchString( $this->mExclText ) ); |
| 431 | + array_walk_recursive( $this->mInclCats, array( __CLASS__, 'categoryKey' ) ); |
| 432 | + array_walk_recursive( $this->mExclCats, array( __CLASS__, 'categoryKey' ) ); |
| 433 | + $inclcats = $db->strencode( $this->getMatchString( $this->mInclCats ) ); |
| 434 | + $exclcats = $db->strencode( $this->getMatchString( $this->mExclCats ) ); |
| 435 | + |
450 | 436 | $retval['tables'][] = 'page'; |
451 | | - if(!self::isEmpty($this->mInclText) || !self::isEmpty($this->mExclText)) |
| 437 | + if ( !self::isEmpty( $this->mInclText ) || !self::isEmpty( $this->mExclText ) ) |
452 | 438 | { |
453 | 439 | $retval['tables'][] = 'searchindex'; |
454 | 440 | $retval['conds'][] = 'page_id=si_page'; |
455 | | - if(!self::isEmpty($this->mInclText)) |
| 441 | + if ( !self::isEmpty( $this->mInclText ) ) |
456 | 442 | { |
457 | 443 | $titlecond = $contentcond = $cond = ''; |
458 | | - if($this->mSearchTitle) |
| 444 | + if ( $this->mSearchTitle ) |
459 | 445 | $titlecond = "MATCH (si_title) AGAINST ('$incltext' IN BOOLEAN MODE)"; |
460 | | - if($this->mSearchContent) |
| 446 | + if ( $this->mSearchContent ) |
461 | 447 | $contentcond = "MATCH (si_text) AGAINST ('$incltext' IN BOOLEAN MODE)"; |
462 | | - if(!empty($titlecond) && !empty($contentcond)) |
| 448 | + if ( !empty( $titlecond ) && !empty( $contentcond ) ) |
463 | 449 | $cond = "$titlecond OR $contentcond"; |
464 | 450 | else |
465 | 451 | $cond = $titlecond . $contentcond; |
466 | | - if(!empty($cond)) |
| 452 | + if ( !empty( $cond ) ) |
467 | 453 | $retval['conds'][] = $cond; |
468 | 454 | } |
469 | | - if(!self::isEmpty($this->mExclText)) |
| 455 | + if ( !self::isEmpty( $this->mExclText ) ) |
470 | 456 | { |
471 | 457 | $titlecond = $contentcond = $cond = ''; |
472 | | - if($this->mSearchTitle) |
| 458 | + if ( $this->mSearchTitle ) |
473 | 459 | $titlecond = "NOT MATCH (si_title) AGAINST ('$excltext' IN BOOLEAN MODE)"; |
474 | | - if($this->mSearchContent) |
| 460 | + if ( $this->mSearchContent ) |
475 | 461 | $contentcond = "NOT MATCH (si_text) AGAINST ('$excltext' IN BOOLEAN MODE)"; |
476 | | - if(!empty($titlecond) && !empty($contentcond)) |
| 462 | + if ( !empty( $titlecond ) && !empty( $contentcond ) ) |
477 | 463 | $cond = "$titlecond OR $contentcond"; |
478 | 464 | else |
479 | 465 | $cond = $titlecond . $contentcond; |
480 | | - if(!empty($cond)) |
| 466 | + if ( !empty( $cond ) ) |
481 | 467 | $retval['conds'][] = $cond; |
482 | 468 | } |
483 | 469 | } |
484 | | - if(!self::isEmpty($this->mInclCats) || !self::isEmpty($this->mExclCats)) |
| 470 | + if ( !self::isEmpty( $this->mInclCats ) || !self::isEmpty( $this->mExclCats ) ) |
485 | 471 | { |
486 | 472 | $retval['tables'][] = 'categorysearch'; |
487 | 473 | $retval['conds'][] = 'page_id=cs_page'; |
488 | | - if(!self::isEmpty($this->mInclCats)) |
| 474 | + if ( !self::isEmpty( $this->mInclCats ) ) |
489 | 475 | $retval['conds'][] = "MATCH (cs_categories) AGAINST ('$inclcats' IN BOOLEAN MODE)"; |
490 | | - if(!self::isEmpty($this->mExclCats)) |
| 476 | + if ( !self::isEmpty( $this->mExclCats ) ) |
491 | 477 | $retval['conds'][] = "NOT MATCH (cs_categories) AGAINST ('$exclcats' IN BOOLEAN MODE)"; |
492 | 478 | } |
493 | | - if(!empty($this->mNamespaces)) |
| 479 | + if ( !empty( $this->mNamespaces ) ) |
494 | 480 | $retval['conds']['page_namespace'] = $this->mNamespaces; |
495 | | - |
496 | | - $retval['fields'] = array('page_namespace', 'page_title'); |
| 481 | + |
| 482 | + $retval['fields'] = array( 'page_namespace', 'page_title' ); |
497 | 483 | return $retval; |
498 | 484 | } |
499 | 485 | |
500 | | - public function reallyDoQuery() |
501 | | - { |
502 | | - if(isset($this->mResult)) |
| 486 | + public function reallyDoQuery() { |
| 487 | + if ( isset( $this->mResult ) ) |
503 | 488 | return $this->mResult; |
504 | 489 | global $wgRequest; |
505 | | - list($this->mLimit, $this->mOffset) = $wgRequest->getLimitOffset(50, 'limit'); |
| 490 | + list( $this->mLimit, $this->mOffset ) = $wgRequest->getLimitOffset( 50, 'limit' ); |
506 | 491 | $info = $this->getQueryInfo(); |
507 | 492 | $tables = $info['tables']; |
508 | 493 | $fields = $info['fields']; |
509 | | - $conds = isset($info['conds']) ? $info['conds'] : array(); |
510 | | - $options = isset($info['options']) ? $info['options'] : array(); |
511 | | - $join_conds = isset($info['join_conds']) ? $info['join_conds'] : array(); |
512 | | - if($this->mOffset != '') |
513 | | - $options['OFFSET'] = intval($this->mOffset); |
514 | | - $options['LIMIT'] = intval($this->mLimit); |
515 | | - $this->mResult = $this->mDb->select($tables, $fields, $conds, __METHOD__, $options, $join_conds); |
516 | | - return new ResultWrapper($this->mDb, $this->mResult); |
| 494 | + $conds = isset( $info['conds'] ) ? $info['conds'] : array(); |
| 495 | + $options = isset( $info['options'] ) ? $info['options'] : array(); |
| 496 | + $join_conds = isset( $info['join_conds'] ) ? $info['join_conds'] : array(); |
| 497 | + if ( $this->mOffset != '' ) |
| 498 | + $options['OFFSET'] = intval( $this->mOffset ); |
| 499 | + $options['LIMIT'] = intval( $this->mLimit ); |
| 500 | + $this->mResult = $this->mDb->select( $tables, $fields, $conds, __METHOD__, $options, $join_conds ); |
| 501 | + return new ResultWrapper( $this->mDb, $this->mResult ); |
517 | 502 | } |
518 | | - |
519 | | - public function getNumRows() |
520 | | - { |
521 | | - if(!isset($this->mResult)) |
| 503 | + |
| 504 | + public function getNumRows() { |
| 505 | + if ( !isset( $this->mResult ) ) |
522 | 506 | $this->reallyDoQuery(); |
523 | 507 | return $this->mResult->numRows(); |
524 | | - } |
| 508 | + } |
525 | 509 | |
526 | | - public function preprocessResults($result) |
527 | | - { |
| 510 | + public function preprocessResults( $result ) { |
528 | 511 | # Run a LinkBatch query |
529 | 512 | $lb = new LinkBatch; |
530 | 513 | $result->rewind(); |
531 | | - while(($row = $result->fetchObject())) |
532 | | - $lb->add($row->page_namespace, $row->page_title); |
| 514 | + while ( ( $row = $result->fetchObject() ) ) { |
| 515 | + $lb->add( $row->page_namespace, $row->page_title ); |
| 516 | + } |
533 | 517 | $lb->execute(); |
534 | 518 | $result->rewind(); |
535 | 519 | } |
536 | 520 | |
537 | | - public function getStartBody() |
538 | | - { |
539 | | - return Xml::openElement('table') . Xml::openElement('tr'); |
| 521 | + public function getStartBody() { |
| 522 | + return Xml::openElement( 'table' ) . Xml::openElement( 'tr' ); |
540 | 523 | } |
541 | 524 | |
542 | | - public function getEndBody() |
543 | | - { |
544 | | - return Xml::closeElement('tr') . Xml::closeElement('table'); |
| 525 | + public function getEndBody() { |
| 526 | + return Xml::closeElement( 'tr' ) . Xml::closeElement( 'table' ); |
545 | 527 | } |
546 | 528 | |
547 | | - public function formatRow($row) |
548 | | - { |
| 529 | + public function formatRow( $row ) { |
549 | 530 | global $wgUser; |
550 | 531 | static $i = 0; |
551 | | - $open = Xml::openElement('td', array('valign' => 'top')) . Xml::openElement('ul'); |
552 | | - $close = Xml::closeElement('ul') . Xml::closeElement('td'); |
| 532 | + $open = Xml::openElement( 'td', array( 'valign' => 'top' ) ) . Xml::openElement( 'ul' ); |
| 533 | + $close = Xml::closeElement( 'ul' ) . Xml::closeElement( 'td' ); |
553 | 534 | $tdb = $tdf = ''; |
554 | | - if($i == 0) |
| 535 | + if ( $i == 0 ) |
555 | 536 | $tdb = $open; |
556 | | - else if($i == ceil($this->mLimit / 2)) |
| 537 | + else if ( $i == ceil( $this->mLimit / 2 ) ) |
557 | 538 | $tdb = $close . $open; |
558 | | - else if($i == $this->mLimit - 1) |
| 539 | + else if ( $i == $this->mLimit - 1 ) |
559 | 540 | $tdf = $close; |
560 | | - $i++; |
561 | | - $title = Title::makeTitle($row->page_namespace, $row->page_title); |
562 | | - $link = $wgUser->getSkin()->makeLinkObj($title, htmlspecialchars($title->getPrefixedText())); |
563 | | - return $tdb . Xml::tags('li', null, $link) . $tdf . "\n"; |
| 541 | + $i++; |
| 542 | + $title = Title::makeTitle( $row->page_namespace, $row->page_title ); |
| 543 | + $link = $wgUser->getSkin()->makeLinkObj( $title, htmlspecialchars( $title->getPrefixedText() ) ); |
| 544 | + return $tdb . Xml::tags( 'li', null, $link ) . $tdf . "\n"; |
564 | 545 | } |
565 | | - |
566 | | - protected function getDefaultQuery() |
567 | | - { |
| 546 | + |
| 547 | + protected function getDefaultQuery() { |
568 | 548 | $retval = $_GET; |
569 | | - unset($retval['offset']); |
570 | | - unset($retval['limit']); |
571 | | - unset($retval['title']); |
| 549 | + unset( $retval['offset'] ); |
| 550 | + unset( $retval['limit'] ); |
| 551 | + unset( $retval['title'] ); |
572 | 552 | return $retval; |
573 | 553 | } |
574 | | - |
575 | | - public function getBody() |
576 | | - { |
| 554 | + |
| 555 | + public function getBody() { |
577 | 556 | $res = $this->reallyDoQuery(); |
578 | | - $this->preprocessResults($res); |
579 | | - $prevnext = wfViewPrevNext($this->mOffset, $this->mLimit, |
580 | | - SpecialPage::getTitleFor('AdvancedSearch'), |
581 | | - wfArrayToCGI($this->getDefaultQuery()), |
582 | | - ($this->getNumRows() < $this->mLimit)); |
| 557 | + $this->preprocessResults( $res ); |
| 558 | + $prevnext = wfViewPrevNext( $this->mOffset, $this->mLimit, |
| 559 | + SpecialPage::getTitleFor( 'AdvancedSearch' ), |
| 560 | + wfArrayToCGI( $this->getDefaultQuery() ), |
| 561 | + ( $this->getNumRows() < $this->mLimit ) ); |
583 | 562 | $retval = $this->getStartBody(); |
584 | | - while(($row = $res->fetchObject())) |
585 | | - $retval .= $this->formatRow($row); |
| 563 | + while ( ( $row = $res->fetchObject() ) ) |
| 564 | + $retval .= $this->formatRow( $row ); |
586 | 565 | $retval .= $this->getEndBody(); |
587 | 566 | return $prevnext . $retval . $prevnext; |
588 | 567 | } |
Index: trunk/extensions/AdvancedSearch/AdvancedSearchCategoryIntersector.php |
— | — | @@ -6,7 +6,7 @@ |
7 | 7 | * (at your option) any later version. |
8 | 8 | * |
9 | 9 | * @author Roan Kattouw <roan.kattouw@home.nl> |
10 | | - * @copyright Copyright (C) 2008 Roan Kattouw |
| 10 | + * @copyright Copyright (C) 2008 Roan Kattouw |
11 | 11 | * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License |
12 | 12 | * |
13 | 13 | * An extension that allows for searching inside categories |
— | — | @@ -15,19 +15,18 @@ |
16 | 16 | * |
17 | 17 | */ |
18 | 18 | # Alert the user that this is not a valid entry point to MediaWiki if they try to access the extension file directly. |
19 | | -if (!defined('MEDIAWIKI')) { |
| 19 | +if ( !defined( 'MEDIAWIKI' ) ) { |
20 | 20 | echo <<<EOT |
21 | 21 | To install the AdvancedSearch extension, put the following line in LocalSettings.php: |
22 | 22 | require_once( "\$IP/extensions/AdvancedSearch/AdvancedSearch.setup.php" ); |
23 | 23 | EOT; |
24 | | - exit(1); |
| 24 | + exit( 1 ); |
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
28 | 28 | * A class that does category intersections using the categorysearch table |
29 | 29 | */ |
30 | | -class AdvancedSearchCategoryIntersector |
31 | | -{ |
| 30 | +class AdvancedSearchCategoryIntersector { |
32 | 31 | private static $searchEngine; |
33 | 32 | |
34 | 33 | /** |
— | — | @@ -35,45 +34,41 @@ |
36 | 35 | * @param $pageid int Page ID |
37 | 36 | * @param $categories array Array of categories (DB keys) |
38 | 37 | */ |
39 | | - static function update($pageid, $categories) |
40 | | - { |
| 38 | + static function update( $pageid, $categories ) { |
41 | 39 | global $wgContLang; |
42 | | - $ctext = $wgContLang->normalizeForSearch(implode(' ', $categories)); |
43 | | - $ctext = self::getSearchEngine()->normalizeText($ctext); |
44 | | - $dbw = wfGetDb(DB_MASTER); |
45 | | - $dbw->replace('categorysearch', 'cs_page', |
46 | | - array('cs_page' => $pageid, 'cs_categories' => $ctext), |
47 | | - __METHOD__); |
| 40 | + $ctext = $wgContLang->normalizeForSearch( implode( ' ', $categories ) ); |
| 41 | + $ctext = self::getSearchEngine()->normalizeText( $ctext ); |
| 42 | + $dbw = wfGetDb( DB_MASTER ); |
| 43 | + $dbw->replace( 'categorysearch', 'cs_page', |
| 44 | + array( 'cs_page' => $pageid, 'cs_categories' => $ctext ), |
| 45 | + __METHOD__ ); |
48 | 46 | } |
49 | | - |
| 47 | + |
50 | 48 | /** |
51 | 49 | * Remove the entry for a page |
52 | 50 | * @param $pageid int Page ID |
53 | 51 | */ |
54 | | - static function remove($pageid) |
55 | | - { |
56 | | - $dbw = wfGetDb(DB_MASTER); |
57 | | - $dbw->delete('categorysearch', array('cs_page' => $pageid), __METHOD__); |
| 52 | + static function remove( $pageid ) { |
| 53 | + $dbw = wfGetDb( DB_MASTER ); |
| 54 | + $dbw->delete( 'categorysearch', array( 'cs_page' => $pageid ), __METHOD__ ); |
58 | 55 | } |
59 | | - |
| 56 | + |
60 | 57 | /** |
61 | 58 | * Hook function for 'LinksUpdate' hook |
62 | 59 | * @param $lu LinksUpdate |
63 | 60 | */ |
64 | | - static function LinksUpdate(&$lu) |
65 | | - { |
66 | | - self::update($lu->mId, array_keys($lu->mCategories)); |
| 61 | + static function LinksUpdate( &$lu ) { |
| 62 | + self::update( $lu->mId, array_keys( $lu->mCategories ) ); |
67 | 63 | return true; |
68 | 64 | } |
69 | | - |
70 | | - static function ArticleDeleteComplete(&$article, &$user, $reason, $id) |
71 | | - { |
72 | | - self::remove($article->getID()); |
| 65 | + |
| 66 | + static function ArticleDeleteComplete( &$article, &$user, $reason, $id ) { |
| 67 | + self::remove( $article->getID() ); |
73 | 68 | return true; |
74 | 69 | } |
75 | 70 | |
76 | 71 | static function getSearchEngine() { |
77 | | - if (!self::$searchEngine) { |
| 72 | + if ( !self::$searchEngine ) { |
78 | 73 | self::$searchEngine = SearchEngine::create(); |
79 | 74 | } |
80 | 75 | return self::$searchEngine; |
Index: trunk/extensions/AdvancedSearch/categorysearch.sql |
— | — | @@ -7,7 +7,7 @@ |
8 | 8 | CREATE TABLE /*$wgDBprefix*/categorysearch ( |
9 | 9 | -- Key to page_id |
10 | 10 | cs_page int unsigned NOT NULL, |
11 | | - |
| 11 | + |
12 | 12 | -- Munged version of categories |
13 | 13 | -- E.g.: "Foo Living_people Bar" |
14 | 14 | cs_categories mediumtext NOT NULL, |
Index: trunk/extensions/AdvancedSearch/populateCategorySearch.php |
— | — | @@ -6,20 +6,20 @@ |
7 | 7 | |
8 | 8 | $optionsWithArgs = array( 'begin', 'max-slave-lag', 'throttle' ); |
9 | 9 | |
10 | | -$commandLineInc = dirname(__FILE__) . "/../../maintenance/commandLine.inc"; |
11 | | -if(!file_exists($commandLineInc)) |
12 | | - die("Can't find commandLine.inc\nPlease copy it to " . |
13 | | - realpath(dirname(__FILE__) . "/../../") . "maintenance or make a symlink."); |
| 10 | +$commandLineInc = dirname( __FILE__ ) . "/../../maintenance/commandLine.inc"; |
| 11 | +if ( !file_exists( $commandLineInc ) ) |
| 12 | + die( "Can't find commandLine.inc\nPlease copy it to " . |
| 13 | + realpath( dirname( __FILE__ ) . "/../../" ) . "maintenance or make a symlink." ); |
14 | 14 | require_once $commandLineInc; |
15 | 15 | require_once "populateCategorySearch.inc"; |
16 | 16 | |
17 | | -if( isset( $options['help'] ) ) { |
| 17 | +if ( isset( $options['help'] ) ) { |
18 | 18 | echo <<<TEXT |
19 | 19 | This script will populate the categorysearch table, added by the |
20 | 20 | CategorySearch extension. It will print out progress indicators every |
21 | 21 | 1000 pages it adds to the table. The script is perfectly safe to run on large, |
22 | 22 | live wikis, and running it multiple times is harmless. You may want to use the |
23 | | -throttling options if it's causing too much load; they will not affect |
| 23 | +throttling options if it is causing too much load; they will not affect |
24 | 24 | correctness. |
25 | 25 | |
26 | 26 | If the script is stopped and later resumed, you can use the --begin option with |
— | — | @@ -39,7 +39,7 @@ |
40 | 40 | --max-slave-lag: If slave lag exceeds this many seconds, wait until it |
41 | 41 | drops before continuing. Default: 10. |
42 | 42 | --throttle: Wait this many milliseconds after each page. Default: 0. |
43 | | - --force: Run regardless of whether the database says it's been run already. |
| 43 | + --force: Run regardless of whether the database says it has been run already. |
44 | 44 | TEXT; |
45 | 45 | exit( 0 ); |
46 | 46 | } |
— | — | @@ -50,6 +50,7 @@ |
51 | 51 | 'throttle' => 0, |
52 | 52 | 'force' => false |
53 | 53 | ); |
| 54 | + |
54 | 55 | $options = array_merge( $defaults, $options ); |
55 | 56 | |
56 | 57 | populateCategorySearch( $options['begin'], $options['max-slave-lag'], |
Index: trunk/extensions/AdvancedSearch/populateCategorySearch.inc |
— | — | @@ -48,7 +48,7 @@ |
49 | 49 | break; |
50 | 50 | $pageid = intval($row->page_id); |
51 | 51 | $where = 'page_id > ' . $pageid; |
52 | | - |
| 52 | + |
53 | 53 | # Get all categories this page is in |
54 | 54 | $res = $dbw->select( |
55 | 55 | 'categorylinks', |
Index: trunk/extensions/AdvancedSearch/AdvancedSearch.body.php |
— | — | @@ -6,7 +6,7 @@ |
7 | 7 | * (at your option) any later version. |
8 | 8 | * |
9 | 9 | * @author Roan Kattouw <roan.kattouw@home.nl> |
10 | | - * @copyright Copyright (C) 2008 Roan Kattouw |
| 10 | + * @copyright Copyright (C) 2008 Roan Kattouw |
11 | 11 | * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License |
12 | 12 | * |
13 | 13 | * An extension that allows for searching inside categories |
— | — | @@ -15,181 +15,172 @@ |
16 | 16 | * |
17 | 17 | */ |
18 | 18 | # Alert the user that this is not a valid entry point to MediaWiki if they try to access the extension file directly. |
19 | | -if (!defined('MEDIAWIKI')) { |
| 19 | +if ( !defined( 'MEDIAWIKI' ) ) { |
20 | 20 | echo <<<EOT |
21 | 21 | To install the AdvancedSearch extension, put the following line in LocalSettings.php: |
22 | 22 | require_once( "\$IP/extensions/AdvancedSearch/AdvancedSearch.setup.php" ); |
23 | 23 | EOT; |
24 | | - exit(1); |
| 24 | + exit( 1 ); |
25 | 25 | } |
26 | 26 | |
27 | | -class AdvancedSearch extends SpecialPage |
28 | | -{ |
29 | | - public function __construct() |
30 | | - { |
31 | | - parent::__construct('AdvancedSearch'); |
| 27 | +class AdvancedSearch extends SpecialPage { |
| 28 | + public function __construct() { |
| 29 | + parent::__construct( 'AdvancedSearch' ); |
32 | 30 | } |
33 | 31 | |
34 | | - public function execute($par) |
35 | | - { |
| 32 | + public function execute( $par ) { |
36 | 33 | global $wgOut, $wgRequest; |
37 | | - wfLoadExtensionMessages('AdvancedSearch'); |
| 34 | + wfLoadExtensionMessages( 'AdvancedSearch' ); |
38 | 35 | $this->setHeaders(); |
39 | | - $wgOut->setPageTitle(wfMsg('advancedsearch-title')); |
40 | | - if($wgRequest->getVal('do') == 'search' || !is_null($par)) |
41 | | - $wgOut->addHTML($this->showResults($par)); |
| 36 | + $wgOut->setPageTitle( wfMsg( 'advancedsearch-title' ) ); |
| 37 | + if ( $wgRequest->getVal( 'do' ) == 'search' || !is_null( $par ) ) |
| 38 | + $wgOut->addHTML( $this->showResults( $par ) ); |
42 | 39 | else |
43 | | - $wgOut->addHTML($this->buildForm()); |
| 40 | + $wgOut->addHTML( $this->buildForm() ); |
44 | 41 | } |
45 | | - |
| 42 | + |
46 | 43 | /** |
47 | 44 | * Generate the HTML for the permanent link to this search result |
48 | 45 | * @param $pager AdvancedSearchPager |
49 | 46 | */ |
50 | | - protected function permaLink($pager) |
51 | | - { |
| 47 | + protected function permaLink( $pager ) { |
52 | 48 | global $wgUser; |
53 | 49 | $key = $pager->cacheQuery(); |
54 | | - return wfMsg('advancedsearch-permalink', |
| 50 | + return wfMsg( 'advancedsearch-permalink', |
55 | 51 | $wgUser->getSkin()->makeLinkObj( |
56 | | - SpecialPage::getTitleFor("AdvancedSearch/$key"), |
57 | | - wfMsg('advancedsearch-permalink-text'))); |
| 52 | + SpecialPage::getTitleFor( "AdvancedSearch/$key" ), |
| 53 | + wfMsg( 'advancedsearch-permalink-text' ) ) ); |
58 | 54 | } |
59 | | - |
60 | | - protected function showResults($par) |
61 | | - { |
| 55 | + |
| 56 | + protected function showResults( $par ) { |
62 | 57 | global $wgRequest; |
63 | | - $key = $wgRequest->getVal('key', null); |
64 | | - if(is_null($key)) |
| 58 | + $key = $wgRequest->getVal( 'key', null ); |
| 59 | + if ( is_null( $key ) ) |
65 | 60 | $key = $par; |
66 | 61 | $searchTitle = $searchContent = true; |
67 | | - if(!is_null($key)) |
68 | | - { |
69 | | - $pager = AdvancedSearchPager::newFromKey($key); |
70 | | - if($pager instanceof AdvancedSearchPager) |
| 62 | + if ( !is_null( $key ) ) { |
| 63 | + $pager = AdvancedSearchPager::newFromKey( $key ); |
| 64 | + if ( $pager instanceof AdvancedSearchPager ) |
71 | 65 | { |
72 | 66 | $searchTitle = $pager->getSearchTitle(); |
73 | 67 | $searchContent = $pager->getSearchContent(); |
74 | 68 | } |
75 | | - } |
76 | | - else |
77 | | - { |
78 | | - $searchTitle = $wgRequest->getCheck('searchtitle'); |
79 | | - $searchContent = $wgRequest->getCheck('searchcontent'); |
| 69 | + } else { |
| 70 | + $searchTitle = $wgRequest->getCheck( 'searchtitle' ); |
| 71 | + $searchContent = $wgRequest->getCheck( 'searchcontent' ); |
80 | 72 | $pager = new AdvancedSearchPager( |
81 | | - $wgRequest->getVal('content-incl'), |
82 | | - $wgRequest->getVal('content-excl'), |
83 | | - $wgRequest->getVal('cat-incl'), |
84 | | - $wgRequest->getVal('cat-excl'), |
85 | | - $wgRequest->getArray('speedcats', array()), |
86 | | - $wgRequest->getVal('scdd'), |
87 | | - $wgRequest->getArray('namespaces', array()), |
| 73 | + $wgRequest->getVal( 'content-incl' ), |
| 74 | + $wgRequest->getVal( 'content-excl' ), |
| 75 | + $wgRequest->getVal( 'cat-incl' ), |
| 76 | + $wgRequest->getVal( 'cat-excl' ), |
| 77 | + $wgRequest->getArray( 'speedcats', array() ), |
| 78 | + $wgRequest->getVal( 'scdd' ), |
| 79 | + $wgRequest->getArray( 'namespaces', array() ), |
88 | 80 | $searchTitle, |
89 | | - $searchContent); |
| 81 | + $searchContent ); |
90 | 82 | } |
91 | 83 | $permalink = $body = ''; |
92 | | - $errors = array(false, false, false, false); |
93 | | - if(!$pager instanceof AdvancedSearchPager) |
94 | | - { |
95 | | - $body = Xml::element('div', array('class' => 'errorbox'), |
96 | | - wfMsg('advancedsearch-permalink-invalid')); |
97 | | - } |
98 | | - else |
99 | | - { |
| 84 | + $errors = array( false, false, false, false ); |
| 85 | + if ( !$pager instanceof AdvancedSearchPager ) { |
| 86 | + $body = Xml::element( 'div', array( 'class' => 'errorbox' ), |
| 87 | + wfMsg( 'advancedsearch-permalink-invalid' ) ); |
| 88 | + } else { |
100 | 89 | $errors = $pager->getParseErrors(); |
101 | | - if($errors !== array(false, false, false, false)) |
102 | | - return $this->buildForm($errors, $searchTitle, $searchContent); |
| 90 | + if ( $errors !== array( false, false, false, false ) ) { |
| 91 | + return $this->buildForm( $errors, $searchTitle, $searchContent ); |
| 92 | + } |
103 | 93 | |
104 | | - if($wgRequest->getBool('permalink')) |
105 | | - $permalink = $this->permaLink($pager); |
106 | | - if($pager->getNumRows() > 0) |
| 94 | + if ( $wgRequest->getBool( 'permalink' ) ) { |
| 95 | + $permalink = $this->permaLink( $pager ); |
| 96 | + } |
| 97 | + |
| 98 | + if ( $pager->getNumRows() > 0 ) { |
107 | 99 | $body = $pager->getBody(); |
108 | | - else |
109 | | - $body = Xml::element('div', array('class' => 'errorbox'), |
110 | | - wfMsg('advancedsearch-empty-result')); |
| 100 | + } else { |
| 101 | + $body = Xml::element( 'div', array( 'class' => 'errorbox' ), |
| 102 | + wfMsg( 'advancedsearch-empty-result' ) ); |
| 103 | + } |
111 | 104 | } |
112 | 105 | return $body . |
113 | | - Xml::element('br', array('clear' => 'both')) . |
114 | | - $permalink . |
115 | | - $this->buildForm($errors, $searchTitle, $searchContent); |
| 106 | + Xml::element( 'br', array( 'clear' => 'both' ) ) . |
| 107 | + $permalink . |
| 108 | + $this->buildForm( $errors, $searchTitle, $searchContent ); |
116 | 109 | } |
117 | 110 | |
118 | | - protected function inputRow($name) |
119 | | - { |
| 111 | + protected function inputRow( $name ) { |
120 | 112 | global $wgRequest; |
121 | | - return Xml::openElement('tr') . |
122 | | - Xml::openElement('td') . |
123 | | - Xml::input($name, 50, $wgRequest->getVal($name, false)) . |
124 | | - Xml::closeElement('td') . |
125 | | - Xml::closeElement('tr'); |
| 113 | + return Xml::openElement( 'tr' ) . |
| 114 | + Xml::openElement( 'td' ) . |
| 115 | + Xml::input( $name, 50, $wgRequest->getVal( $name, false ) ) . |
| 116 | + Xml::closeElement( 'td' ) . |
| 117 | + Xml::closeElement( 'tr' ); |
126 | 118 | } |
127 | 119 | |
128 | | - protected function errorRow($msg) |
129 | | - { |
130 | | - return Xml::openElement('tr') . |
131 | | - Xml::openElement('td') . |
132 | | - Xml::openElement('span', array('class' => 'error')) . |
| 120 | + protected function errorRow( $msg ) { |
| 121 | + return Xml::openElement( 'tr' ) . |
| 122 | + Xml::openElement( 'td' ) . |
| 123 | + Xml::openElement( 'span', array( 'class' => 'error' ) ) . |
133 | 124 | $msg . |
134 | | - Xml::closeElement('span') . |
135 | | - Xml::closeElement('td') . |
136 | | - Xml::closeElement('tr'); |
| 125 | + Xml::closeElement( 'span' ) . |
| 126 | + Xml::closeElement( 'td' ) . |
| 127 | + Xml::closeElement( 'tr' ); |
137 | 128 | } |
138 | 129 | |
139 | | - protected function speedCatTable() |
140 | | - { |
| 130 | + protected function speedCatTable() { |
141 | 131 | global $wgAdvancedSearchSpeedCats, $wgRequest; |
142 | 132 | $i = $j = $n = 0; |
143 | 133 | $cols = 3; |
144 | | - $scarr = $wgRequest->getArray('speedcats', array()); |
145 | | - $retval = Xml::openElement('table'); |
146 | | - foreach(@$wgAdvancedSearchSpeedCats as $name => $display) |
147 | | - { |
| 134 | + $scarr = $wgRequest->getArray( 'speedcats', array() ); |
| 135 | + $retval = Xml::openElement( 'table' ); |
| 136 | + foreach ( @$wgAdvancedSearchSpeedCats as $name => $display ) { |
148 | 137 | $close = false; |
149 | | - if($i == 0) |
150 | | - $retval .= Xml::openElement('tr'); |
151 | | - if($i == $cols - 1) |
152 | | - { |
| 138 | + if ( $i == 0 ) |
| 139 | + $retval .= Xml::openElement( 'tr' ); |
| 140 | + if ( $i == $cols - 1 ) { |
153 | 141 | $i = 0; |
154 | 142 | $j++; |
155 | 143 | $close = true; |
156 | | - } |
157 | | - else |
| 144 | + } else { |
158 | 145 | $i++; |
| 146 | + } |
159 | 147 | $n++; |
160 | 148 | |
161 | | - $retval .= Xml::openElement('td'); |
| 149 | + $retval .= Xml::openElement( 'td' ); |
162 | 150 | $checked = false; |
163 | | - if(in_array($name, $scarr)) |
| 151 | + if ( in_array( $name, $scarr ) ) |
164 | 152 | $checked = true; |
165 | | - $retval .= Xml::checkLabel($display, 'speedcats[]', "speedcats-$n", $checked, array('value' => $name)); |
166 | | - $retval .= Xml::closeElement('td'); |
167 | | - if($close) |
168 | | - $retval .= Xml::closeElement('tr'); |
| 153 | + $retval .= Xml::checkLabel( $display, 'speedcats[]', "speedcats-$n", $checked, array( 'value' => $name ) ); |
| 154 | + $retval .= Xml::closeElement( 'td' ); |
| 155 | + if ( $close ) |
| 156 | + $retval .= Xml::closeElement( 'tr' ); |
169 | 157 | } |
170 | | - if(!$close) |
171 | | - $retval .= Xml::closeElement('tr'); |
172 | | - $retval .= Xml::openElement('tr'); |
173 | | - $retval .= Xml::openElement('td', array('colspan' => 2)); |
174 | | - $retval .= Xml::element('a', array('href' => 'javascript:caSpeedcats(\'all\');'), wfMsg('advancedsearch-selectall')); |
| 158 | + |
| 159 | + if ( !$close ) { |
| 160 | + $retval .= Xml::closeElement( 'tr' ); |
| 161 | + } |
| 162 | + |
| 163 | + $retval .= Xml::openElement( 'tr' ); |
| 164 | + $retval .= Xml::openElement( 'td', array( 'colspan' => 2 ) ); |
| 165 | + $retval .= Xml::element( 'a', array( 'href' => 'javascript:caSpeedcats(\'all\');' ), wfMsg( 'advancedsearch-selectall' ) ); |
175 | 166 | $retval .= ' / '; |
176 | | - $retval .= Xml::element('a', array('href' => 'javascript:caSpeedcats(\'none\');'), wfMsg('advancedsearch-selectnone')); |
| 167 | + $retval .= Xml::element( 'a', array( 'href' => 'javascript:caSpeedcats(\'none\');' ), wfMsg( 'advancedsearch-selectnone' ) ); |
177 | 168 | $retval .= ' / '; |
178 | | - $retval .= Xml::element('a', array('href' => 'javascript:caSpeedcats(\'invert\');'), wfMsg('advancedsearch-invertselection')); |
179 | | - $retval .= Xml::closeElement('td'); |
180 | | - $retval .= Xml::closeElement('tr'); |
| 169 | + $retval .= Xml::element( 'a', array( 'href' => 'javascript:caSpeedcats(\'invert\');' ), wfMsg( 'advancedsearch-invertselection' ) ); |
| 170 | + $retval .= Xml::closeElement( 'td' ); |
| 171 | + $retval .= Xml::closeElement( 'tr' ); |
181 | 172 | $retval .= $this->speedcatDropdownRows(); |
182 | | - $retval .= Xml::closeElement('table'); |
| 173 | + $retval .= Xml::closeElement( 'table' ); |
| 174 | + |
183 | 175 | return $retval; |
184 | 176 | } |
185 | | - |
186 | | - protected function speedcatCheckboxes() |
187 | | - { |
| 177 | + |
| 178 | + protected function speedcatCheckboxes() { |
188 | 179 | global $wgAdvancedSearchSpeedCats; |
189 | | - if(!isset($wgAdvancedSearchSpeedCats) || empty($wgAdvancedSearchSpeedCats)) |
| 180 | + if ( !isset( $wgAdvancedSearchSpeedCats ) || empty( $wgAdvancedSearchSpeedCats ) ) |
190 | 181 | return array(); |
191 | 182 | $retval = array(); |
192 | 183 | $i = 1; |
193 | | - foreach(@$wgAdvancedSearchSpeedCats as $name => $display) |
| 184 | + foreach ( @$wgAdvancedSearchSpeedCats as $name => $display ) |
194 | 185 | { |
195 | 186 | $retval[] = "speedcats-{$i}"; |
196 | 187 | $i++; |
— | — | @@ -197,53 +188,55 @@ |
198 | 189 | return $retval; |
199 | 190 | } |
200 | 191 | |
201 | | - protected function speedcatDropdownRows() |
202 | | - { |
| 192 | + protected function speedcatDropdownRows() { |
203 | 193 | global $wgAdvancedSearchSpeedCatDropdown, $wgRequest; |
204 | | - if(!isset($wgAdvancedSearchSpeedCatDropdown) || empty($wgAdvancedSearchSpeedCatDropdown)) |
| 194 | + |
| 195 | + if ( !isset( $wgAdvancedSearchSpeedCatDropdown ) || empty( $wgAdvancedSearchSpeedCatDropdown ) ) { |
205 | 196 | return ''; |
206 | | - $sel = $wgRequest->getVal('scdd'); |
207 | | - $retval = Xml::openElement('tr'); |
208 | | - $retval .= Xml::openElement('td', array('colspan' => 3)); |
209 | | - $retval .= wfMsg('advancedsearch-speedcat-dropdown'); |
210 | | - $retval .= Xml::openElement('select', array('name' => 'scdd')); |
211 | | - $retval .= Xml::option('', '', is_null($sel)); |
212 | | - foreach(@$wgAdvancedSearchSpeedCatDropdown as $key => $value) |
213 | | - { |
214 | | - if(is_int($key)) |
| 197 | + } |
| 198 | + |
| 199 | + $sel = $wgRequest->getVal( 'scdd' ); |
| 200 | + $retval = Xml::openElement( 'tr' ); |
| 201 | + $retval .= Xml::openElement( 'td', array( 'colspan' => 3 ) ); |
| 202 | + $retval .= wfMsg( 'advancedsearch-speedcat-dropdown' ); |
| 203 | + $retval .= Xml::openElement( 'select', array( 'name' => 'scdd' ) ); |
| 204 | + $retval .= Xml::option( '', '', is_null( $sel ) ); |
| 205 | + |
| 206 | + foreach ( @$wgAdvancedSearchSpeedCatDropdown as $key => $value ) { |
| 207 | + if ( is_int( $key ) ) |
215 | 208 | $key = $value; |
216 | | - $retval .= Xml::option($key, $value, $sel == $value); |
| 209 | + $retval .= Xml::option( $key, $value, $sel == $value ); |
217 | 210 | } |
218 | | - $retval .= Xml::closeElement('select'); |
219 | | - $retval .= Xml::closeElement('td'); |
220 | | - $retval .= Xml::closeElement('tr'); |
| 211 | + |
| 212 | + $retval .= Xml::closeElement( 'select' ); |
| 213 | + $retval .= Xml::closeElement( 'td' ); |
| 214 | + $retval .= Xml::closeElement( 'tr' ); |
| 215 | + |
221 | 216 | return $retval; |
222 | 217 | } |
223 | | - |
224 | | - public static function searchableNamespaces() |
225 | | - { |
| 218 | + |
| 219 | + public static function searchableNamespaces() { |
226 | 220 | global $wgContLang; |
227 | 221 | $retval = array(); |
228 | | - foreach($wgContLang->getFormattedNamespaces() as $ns => $value) |
229 | | - if($ns >= NS_MAIN) |
| 222 | + foreach ( $wgContLang->getFormattedNamespaces() as $ns => $value ) |
| 223 | + if ( $ns >= NS_MAIN ) |
230 | 224 | $retval[$ns] = $value; |
231 | 225 | return $retval; |
232 | 226 | } |
233 | 227 | |
234 | | - protected function namespaceTable() |
235 | | - { |
| 228 | + protected function namespaceTable() { |
236 | 229 | global $wgRequest, $wgUser; |
237 | 230 | $i = 0; |
238 | 231 | $j = 0; |
239 | 232 | $cols = 2; |
240 | | - $retval = Xml::openElement('table'); |
241 | | - $nsarr = $wgRequest->getArray('namespaces', array()); |
242 | | - foreach(self::searchableNamespaces() as $ns => $display) |
| 233 | + $retval = Xml::openElement( 'table' ); |
| 234 | + $nsarr = $wgRequest->getArray( 'namespaces', array() ); |
| 235 | + foreach ( self::searchableNamespaces() as $ns => $display ) |
243 | 236 | { |
244 | 237 | $close = false; |
245 | | - if($i == 0) |
246 | | - $retval .= Xml::openElement('tr'); |
247 | | - if($i == $cols - 1) |
| 238 | + if ( $i == 0 ) |
| 239 | + $retval .= Xml::openElement( 'tr' ); |
| 240 | + if ( $i == $cols - 1 ) |
248 | 241 | { |
249 | 242 | $i = 0; |
250 | 243 | $j++; |
— | — | @@ -251,58 +244,54 @@ |
252 | 245 | } |
253 | 246 | else |
254 | 247 | $i++; |
255 | | - $retval .= Xml::openElement('td'); |
256 | | - if($display == '') |
257 | | - $display = wfMsg('blanknamespace'); |
| 248 | + $retval .= Xml::openElement( 'td' ); |
| 249 | + if ( $display == '' ) |
| 250 | + $display = wfMsg( 'blanknamespace' ); |
258 | 251 | $checked = false; |
259 | | - if(in_array($ns, $nsarr)) |
| 252 | + if ( in_array( $ns, $nsarr ) ) |
260 | 253 | $checked = true; |
261 | | - else if(empty($nsarr)) |
262 | | - $checked = $wgUser->getOption("searchNs$ns"); |
263 | | - $retval .= Xml::checkLabel($display, 'namespaces[]', "namespaces-$ns", |
264 | | - $checked, array('value' => $ns)); |
265 | | - $retval .= Xml::closeElement('td'); |
266 | | - if($close) |
267 | | - $retval .= Xml::closeElement('tr'); |
| 254 | + else if ( empty( $nsarr ) ) |
| 255 | + $checked = $wgUser->getOption( "searchNs$ns" ); |
| 256 | + $retval .= Xml::checkLabel( $display, 'namespaces[]', "namespaces-$ns", |
| 257 | + $checked, array( 'value' => $ns ) ); |
| 258 | + $retval .= Xml::closeElement( 'td' ); |
| 259 | + if ( $close ) |
| 260 | + $retval .= Xml::closeElement( 'tr' ); |
268 | 261 | } |
269 | | - if(!$close) |
270 | | - $retval .= Xml::closeElement('tr'); |
271 | | - $retval .= Xml::openElement('tr'); |
272 | | - $retval .= Xml::openElement('td', array('colspan' => 2)); |
273 | | - $retval .= Xml::element('a', array('href' => 'javascript:caNamespaces(\'all\');'), wfMsg('advancedsearch-selectall')); |
| 262 | + if ( !$close ) |
| 263 | + $retval .= Xml::closeElement( 'tr' ); |
| 264 | + $retval .= Xml::openElement( 'tr' ); |
| 265 | + $retval .= Xml::openElement( 'td', array( 'colspan' => 2 ) ); |
| 266 | + $retval .= Xml::element( 'a', array( 'href' => 'javascript:caNamespaces(\'all\');' ), wfMsg( 'advancedsearch-selectall' ) ); |
274 | 267 | $retval .= ' / '; |
275 | | - $retval .= Xml::element('a', array('href' => 'javascript:caNamespaces(\'none\');'), wfMsg('advancedsearch-selectnone')); |
| 268 | + $retval .= Xml::element( 'a', array( 'href' => 'javascript:caNamespaces(\'none\');' ), wfMsg( 'advancedsearch-selectnone' ) ); |
276 | 269 | $retval .= ' / '; |
277 | | - $retval .= Xml::element('a', array('href' => 'javascript:caNamespaces(\'invert\');'), wfMsg('advancedsearch-invertselection')); |
278 | | - $retval .= Xml::closeElement('td'); |
279 | | - $retval .= Xml::closeElement('tr'); |
| 270 | + $retval .= Xml::element( 'a', array( 'href' => 'javascript:caNamespaces(\'invert\');' ), wfMsg( 'advancedsearch-invertselection' ) ); |
| 271 | + $retval .= Xml::closeElement( 'td' ); |
| 272 | + $retval .= Xml::closeElement( 'tr' ); |
280 | 273 | |
281 | | - $retval .= Xml::closeElement('table'); |
| 274 | + $retval .= Xml::closeElement( 'table' ); |
282 | 275 | return $retval; |
283 | 276 | } |
284 | | - |
285 | | - protected function namespaceCheckboxes() |
286 | | - { |
| 277 | + |
| 278 | + protected function namespaceCheckboxes() { |
287 | 279 | $retval = array(); |
288 | | - foreach(self::searchableNamespaces() as $ns => $unused) |
| 280 | + foreach ( self::searchableNamespaces() as $ns => $unused ) |
289 | 281 | $retval[] = "namespaces-$ns"; |
290 | 282 | return $retval; |
291 | 283 | } |
292 | 284 | |
293 | | - protected function invertJS($func, $checkboxes) |
294 | | - { |
| 285 | + protected function invertJS( $func, $checkboxes ) { |
295 | 286 | $retval = "function $func(action)\n{"; |
296 | | - foreach($checkboxes as $c) |
| 287 | + foreach ( $checkboxes as $c ) |
297 | 288 | $retval .= "checkboxAction('$c', action);\n"; |
298 | 289 | $retval .= "}\n"; |
299 | 290 | return $retval; |
300 | 291 | } |
301 | | - |
302 | | - protected function checkboxActionJS() |
303 | | - { |
| 292 | + |
| 293 | + protected function checkboxActionJS() { |
304 | 294 | return <<<ENDOFLINE |
305 | | -function checkboxAction(c, action) |
306 | | -{ |
| 295 | +function checkboxAction(c, action) { |
307 | 296 | var obj = document.getElementById(c); |
308 | 297 | switch(action) |
309 | 298 | { |
— | — | @@ -319,141 +308,140 @@ |
320 | 309 | ENDOFLINE; |
321 | 310 | } |
322 | 311 | |
323 | | - protected function buildForm($parseErrors = null, $searchTitle = true, $searchContent = true) |
324 | | - { |
| 312 | + protected function buildForm( $parseErrors = null, $searchTitle = true, $searchContent = true ) { |
325 | 313 | global $wgScript, $wgOut; |
326 | 314 | $wgOut->addInlineScript( |
327 | 315 | $this->checkboxActionJS() . |
328 | | - $this->invertJS('caNamespaces', $this->namespaceCheckboxes()) . |
329 | | - $this->invertJS('caSpeedcats', $this->speedcatCheckboxes())); |
330 | | - $retval = wfMsgExt('advancedsearch-toptext', array('parse')); |
331 | | - $retval .= Xml::openElement('form', array('method' => 'GET', 'action' => $wgScript)); |
332 | | - $retval .= Xml::hidden('title', $this->getTitle()->getPrefixedDbKey()); |
333 | | - $retval .= Xml::hidden('do', 'search'); |
334 | | - |
| 316 | + $this->invertJS( 'caNamespaces', $this->namespaceCheckboxes() ) . |
| 317 | + $this->invertJS( 'caSpeedcats', $this->speedcatCheckboxes() ) ); |
| 318 | + $retval = wfMsgExt( 'advancedsearch-toptext', array( 'parse' ) ); |
| 319 | + $retval .= Xml::openElement( 'form', array( 'method' => 'GET', 'action' => $wgScript ) ); |
| 320 | + $retval .= Xml::hidden( 'title', $this->getTitle()->getPrefixedDbKey() ); |
| 321 | + $retval .= Xml::hidden( 'do', 'search' ); |
| 322 | + |
335 | 323 | // The big table everything is in |
336 | | - $retval .= Xml::openElement('table'); |
337 | | - |
| 324 | + $retval .= Xml::openElement( 'table' ); |
| 325 | + |
338 | 326 | // The fieldset+table for searching page content |
339 | | - $retval .= Xml::openElement('tr'); |
340 | | - $retval .= Xml::openElement('td', array('valign' => 'top')); |
341 | | - $retval .= Xml::openElement('fieldset', array('class' => 'nested')); |
342 | | - $retval .= Xml::element('legend', array('class' => 'advancedsearchLegend'), wfMsg('advancedsearch-contentsearch')); |
343 | | - $retval .= Xml::openElement('table'); |
| 327 | + $retval .= Xml::openElement( 'tr' ); |
| 328 | + $retval .= Xml::openElement( 'td', array( 'valign' => 'top' ) ); |
| 329 | + $retval .= Xml::openElement( 'fieldset', array( 'class' => 'nested' ) ); |
| 330 | + $retval .= Xml::element( 'legend', array( 'class' => 'advancedsearchLegend' ), wfMsg( 'advancedsearch-contentsearch' ) ); |
| 331 | + $retval .= Xml::openElement( 'table' ); |
344 | 332 | |
345 | 333 | // title/content checkboxes |
346 | | - $retval .= Xml::openElement('tr'); |
347 | | - $retval .= Xml::openElement('td'); |
348 | | - $retval .= wfMsg('advancedsearch-searchin'); |
349 | | - $retval .= Xml::checkLabel(wfMsg('advancedsearch-searchin-title'), 'searchtitle', |
350 | | - 'searchtitle', $searchTitle); |
351 | | - $retval .= Xml::checkLabel(wfMsg('advancedsearch-searchin-content'), 'searchcontent', |
352 | | - 'searchcontent', $searchContent); |
353 | | - $retval .= Xml::closeElement('td'); |
354 | | - $retval .= Xml::closeElement('tr'); |
| 334 | + $retval .= Xml::openElement( 'tr' ); |
| 335 | + $retval .= Xml::openElement( 'td' ); |
| 336 | + $retval .= wfMsg( 'advancedsearch-searchin' ); |
| 337 | + $retval .= Xml::checkLabel( wfMsg( 'advancedsearch-searchin-title' ), 'searchtitle', |
| 338 | + 'searchtitle', $searchTitle ); |
| 339 | + $retval .= Xml::checkLabel( wfMsg( 'advancedsearch-searchin-content' ), 'searchcontent', |
| 340 | + 'searchcontent', $searchContent ); |
| 341 | + $retval .= Xml::closeElement( 'td' ); |
| 342 | + $retval .= Xml::closeElement( 'tr' ); |
355 | 343 | |
356 | 344 | // Include fieldset |
357 | | - $retval .= Xml::openElement('tr'); |
358 | | - $retval .= Xml::openElement('td', array('valign' => 'top')); |
359 | | - $retval .= Xml::openElement('fieldset', array('class' => 'nested')); |
360 | | - $retval .= Xml::element('legend', array('class' => 'advancedsearchLegend'), wfMsg('advancedsearch-content-include')); |
361 | | - $retval .= Xml::openElement('table'); |
362 | | - $retval .= $this->inputRow('content-incl'); |
363 | | - if(is_array($parseErrors) && $parseErrors[0] !== false) |
364 | | - $retval .= $this->errorRow($parseErrors[0]); |
365 | | - $retval .= Xml::closeElement('table'); |
366 | | - $retval .= Xml::closeElement('fieldset'); |
367 | | - $retval .= Xml::closeElement('td'); |
368 | | - $retval .= Xml::closeElement('tr'); |
369 | | - |
| 345 | + $retval .= Xml::openElement( 'tr' ); |
| 346 | + $retval .= Xml::openElement( 'td', array( 'valign' => 'top' ) ); |
| 347 | + $retval .= Xml::openElement( 'fieldset', array( 'class' => 'nested' ) ); |
| 348 | + $retval .= Xml::element( 'legend', array( 'class' => 'advancedsearchLegend' ), wfMsg( 'advancedsearch-content-include' ) ); |
| 349 | + $retval .= Xml::openElement( 'table' ); |
| 350 | + $retval .= $this->inputRow( 'content-incl' ); |
| 351 | + if ( is_array( $parseErrors ) && $parseErrors[0] !== false ) |
| 352 | + $retval .= $this->errorRow( $parseErrors[0] ); |
| 353 | + $retval .= Xml::closeElement( 'table' ); |
| 354 | + $retval .= Xml::closeElement( 'fieldset' ); |
| 355 | + $retval .= Xml::closeElement( 'td' ); |
| 356 | + $retval .= Xml::closeElement( 'tr' ); |
| 357 | + |
370 | 358 | // Exclude fieldset |
371 | | - $retval .= Xml::openElement('tr'); |
372 | | - $retval .= Xml::openElement('td', array('valign' => 'top')); |
373 | | - $retval .= Xml::openElement('fieldset', array('class' => 'nested')); |
374 | | - $retval .= Xml::element('legend', array('class' => 'advancedsearchLegend'), wfMsg('advancedsearch-content-exclude')); |
375 | | - $retval .= Xml::openElement('table'); |
376 | | - $retval .= $this->inputRow('content-excl'); |
377 | | - if(is_array($parseErrors) && $parseErrors[1] !== false) |
378 | | - $retval .= $this->errorRow($parseErrors[1]); |
379 | | - $retval .= Xml::closeElement('table'); |
380 | | - $retval .= Xml::closeElement('fieldset'); |
381 | | - $retval .= Xml::closeElement('td'); |
382 | | - $retval .= Xml::closeElement('tr'); |
| 359 | + $retval .= Xml::openElement( 'tr' ); |
| 360 | + $retval .= Xml::openElement( 'td', array( 'valign' => 'top' ) ); |
| 361 | + $retval .= Xml::openElement( 'fieldset', array( 'class' => 'nested' ) ); |
| 362 | + $retval .= Xml::element( 'legend', array( 'class' => 'advancedsearchLegend' ), wfMsg( 'advancedsearch-content-exclude' ) ); |
| 363 | + $retval .= Xml::openElement( 'table' ); |
| 364 | + $retval .= $this->inputRow( 'content-excl' ); |
| 365 | + if ( is_array( $parseErrors ) && $parseErrors[1] !== false ) |
| 366 | + $retval .= $this->errorRow( $parseErrors[1] ); |
| 367 | + $retval .= Xml::closeElement( 'table' ); |
| 368 | + $retval .= Xml::closeElement( 'fieldset' ); |
| 369 | + $retval .= Xml::closeElement( 'td' ); |
| 370 | + $retval .= Xml::closeElement( 'tr' ); |
383 | 371 | |
384 | | - $retval .= Xml::closeElement('table'); |
385 | | - $retval .= Xml::closeElement('fieldset'); |
386 | | - $retval .= Xml::closeElement('td'); |
387 | | - |
| 372 | + $retval .= Xml::closeElement( 'table' ); |
| 373 | + $retval .= Xml::closeElement( 'fieldset' ); |
| 374 | + $retval .= Xml::closeElement( 'td' ); |
| 375 | + |
388 | 376 | // The namespace fieldset |
389 | | - $retval .= Xml::openElement('td', array('valign' => 'top')); |
390 | | - $retval .= Xml::openElement('fieldset', array('class' => 'nested')); |
391 | | - $retval .= Xml::element('legend', array('class' => 'advancedsearchLegend'), wfMsg('advancedsearch-namespaces')); |
| 377 | + $retval .= Xml::openElement( 'td', array( 'valign' => 'top' ) ); |
| 378 | + $retval .= Xml::openElement( 'fieldset', array( 'class' => 'nested' ) ); |
| 379 | + $retval .= Xml::element( 'legend', array( 'class' => 'advancedsearchLegend' ), wfMsg( 'advancedsearch-namespaces' ) ); |
392 | 380 | $retval .= $this->namespaceTable(); |
393 | | - $retval .= Xml::closeElement('fieldset'); |
394 | | - $retval .= Xml::closeElement('td'); |
395 | | - $retval .= Xml::closeElement('tr'); |
| 381 | + $retval .= Xml::closeElement( 'fieldset' ); |
| 382 | + $retval .= Xml::closeElement( 'td' ); |
| 383 | + $retval .= Xml::closeElement( 'tr' ); |
396 | 384 | |
397 | | - // The category fieldset |
398 | | - $retval .= Xml::openElement('tr'); |
399 | | - $retval .= Xml::openElement('td', array('valign' => 'top')); |
400 | | - $retval .= Xml::openElement('fieldset', array('class' => 'nested')); |
401 | | - $retval .= Xml::element('legend', array('class' => 'advancedsearchLegend'), wfMsg('advancedsearch-categorysearch')); |
402 | | - $retval .= Xml::openElement('table'); |
403 | | - |
| 385 | + // The category fieldset |
| 386 | + $retval .= Xml::openElement( 'tr' ); |
| 387 | + $retval .= Xml::openElement( 'td', array( 'valign' => 'top' ) ); |
| 388 | + $retval .= Xml::openElement( 'fieldset', array( 'class' => 'nested' ) ); |
| 389 | + $retval .= Xml::element( 'legend', array( 'class' => 'advancedsearchLegend' ), wfMsg( 'advancedsearch-categorysearch' ) ); |
| 390 | + $retval .= Xml::openElement( 'table' ); |
| 391 | + |
404 | 392 | // The include fieldset |
405 | | - $retval .= Xml::openElement('tr'); |
406 | | - $retval .= Xml::openElement('td', array('valign' => 'top')); |
407 | | - $retval .= Xml::openElement('fieldset', array('class' => 'nested')); |
408 | | - $retval .= Xml::element('legend', array('class' => 'advancedsearchLegend'), wfMsg('advancedsearch-category-include')); |
409 | | - $retval .= Xml::openElement('table'); |
410 | | - $retval .= $this->inputRow('cat-incl'); |
411 | | - if(is_array($parseErrors) && $parseErrors[2] !== false) |
412 | | - $retval .= $this->errorRow($parseErrors[2]); |
413 | | - $retval .= Xml::closeElement('table'); |
414 | | - $retval .= Xml::closeElement('fieldset'); |
415 | | - $retval .= Xml::closeElement('td'); |
416 | | - $retval .= Xml::closeElement('tr'); |
417 | | - |
| 393 | + $retval .= Xml::openElement( 'tr' ); |
| 394 | + $retval .= Xml::openElement( 'td', array( 'valign' => 'top' ) ); |
| 395 | + $retval .= Xml::openElement( 'fieldset', array( 'class' => 'nested' ) ); |
| 396 | + $retval .= Xml::element( 'legend', array( 'class' => 'advancedsearchLegend' ), wfMsg( 'advancedsearch-category-include' ) ); |
| 397 | + $retval .= Xml::openElement( 'table' ); |
| 398 | + $retval .= $this->inputRow( 'cat-incl' ); |
| 399 | + if ( is_array( $parseErrors ) && $parseErrors[2] !== false ) |
| 400 | + $retval .= $this->errorRow( $parseErrors[2] ); |
| 401 | + $retval .= Xml::closeElement( 'table' ); |
| 402 | + $retval .= Xml::closeElement( 'fieldset' ); |
| 403 | + $retval .= Xml::closeElement( 'td' ); |
| 404 | + $retval .= Xml::closeElement( 'tr' ); |
| 405 | + |
418 | 406 | // The exclude fieldset |
419 | | - $retval .= Xml::openElement('tr'); |
420 | | - $retval .= Xml::openElement('td', array('valign' => 'top')); |
421 | | - $retval .= Xml::openElement('fieldset', array('class' => 'nested')); |
422 | | - $retval .= Xml::element('legend', array('class' => 'advancedsearchLegend'), wfMsg('advancedsearch-category-exclude')); |
423 | | - $retval .= Xml::openElement('table'); |
424 | | - $retval .= $this->inputRow('cat-excl'); |
425 | | - if(is_array($parseErrors) && $parseErrors[3] !== false) |
426 | | - $retval .= $this->errorRow($parseErrors[3]); |
427 | | - $retval .= Xml::closeElement('table'); |
428 | | - $retval .= Xml::closeElement('fieldset'); |
429 | | - $retval .= Xml::closeElement('td'); |
430 | | - $retval .= Xml::closeElement('tr'); |
431 | | - |
432 | | - $retval .= Xml::closeElement('table'); |
433 | | - $retval .= Xml::closeElement('fieldset'); |
434 | | - $retval .= Xml::closeElement('td'); |
435 | | - $retval .= Xml::openElement('td', array('valign' => 'top')); |
436 | | - $retval .= Xml::openElement('table'); |
| 407 | + $retval .= Xml::openElement( 'tr' ); |
| 408 | + $retval .= Xml::openElement( 'td', array( 'valign' => 'top' ) ); |
| 409 | + $retval .= Xml::openElement( 'fieldset', array( 'class' => 'nested' ) ); |
| 410 | + $retval .= Xml::element( 'legend', array( 'class' => 'advancedsearchLegend' ), wfMsg( 'advancedsearch-category-exclude' ) ); |
| 411 | + $retval .= Xml::openElement( 'table' ); |
| 412 | + $retval .= $this->inputRow( 'cat-excl' ); |
| 413 | + if ( is_array( $parseErrors ) && $parseErrors[3] !== false ) |
| 414 | + $retval .= $this->errorRow( $parseErrors[3] ); |
| 415 | + $retval .= Xml::closeElement( 'table' ); |
| 416 | + $retval .= Xml::closeElement( 'fieldset' ); |
| 417 | + $retval .= Xml::closeElement( 'td' ); |
| 418 | + $retval .= Xml::closeElement( 'tr' ); |
437 | 419 | |
| 420 | + $retval .= Xml::closeElement( 'table' ); |
| 421 | + $retval .= Xml::closeElement( 'fieldset' ); |
| 422 | + $retval .= Xml::closeElement( 'td' ); |
| 423 | + $retval .= Xml::openElement( 'td', array( 'valign' => 'top' ) ); |
| 424 | + $retval .= Xml::openElement( 'table' ); |
| 425 | + |
438 | 426 | // The speedcat fieldset |
439 | 427 | global $wgAdvancedSearchSpeedCats; |
440 | | - if(!empty($wgAdvancedSearchSpeedCats)) |
441 | | - { |
442 | | - $retval .= Xml::openElement('td', array('valign' => 'top')); |
443 | | - $retval .= Xml::openElement('fieldset', array('class' => 'nested')); |
444 | | - $retval .= Xml::element('legend', array('class' => 'advancedsearchLegend'), wfMsg('advancedsearch-speedcats')); |
| 428 | + if ( !empty( $wgAdvancedSearchSpeedCats ) ) { |
| 429 | + $retval .= Xml::openElement( 'td', array( 'valign' => 'top' ) ); |
| 430 | + $retval .= Xml::openElement( 'fieldset', array( 'class' => 'nested' ) ); |
| 431 | + $retval .= Xml::element( 'legend', array( 'class' => 'advancedsearchLegend' ), wfMsg( 'advancedsearch-speedcats' ) ); |
445 | 432 | $retval .= $this->speedCatTable(); |
446 | | - $retval .= Xml::closeElement('fieldset'); |
447 | | - $retval .= Xml::closeElement('td'); |
| 433 | + $retval .= Xml::closeElement( 'fieldset' ); |
| 434 | + $retval .= Xml::closeElement( 'td' ); |
448 | 435 | } |
449 | 436 | |
450 | | - $retval .= Xml::closeElement('table'); |
451 | | - $retval .= Xml::closeElement('td'); |
452 | | - $retval .= Xml::closeElement('tr'); |
453 | | - $retval .= Xml::closeElement('table'); |
454 | | - $retval .= Xml::checkLabel(wfMsg('advancedsearch-permalink-check'), 'permalink', 'permalink'); |
455 | | - $retval .= Xml::element('br'); |
456 | | - $retval .= Xml::submitButton(wfMsg('advancedsearch-submit')); |
457 | | - $retval .= Xml::closeElement('form'); |
| 437 | + $retval .= Xml::closeElement( 'table' ); |
| 438 | + $retval .= Xml::closeElement( 'td' ); |
| 439 | + $retval .= Xml::closeElement( 'tr' ); |
| 440 | + $retval .= Xml::closeElement( 'table' ); |
| 441 | + $retval .= Xml::checkLabel( wfMsg( 'advancedsearch-permalink-check' ), 'permalink', 'permalink' ); |
| 442 | + $retval .= Xml::element( 'br' ); |
| 443 | + $retval .= Xml::submitButton( wfMsg( 'advancedsearch-submit' ) ); |
| 444 | + $retval .= Xml::closeElement( 'form' ); |
| 445 | + |
458 | 446 | return $retval; |
459 | 447 | } |
460 | 448 | } |