r62435 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r62434‎ | r62435 | r62436 >
Date:14:50, 13 February 2010
Author:siebrand
Status:deferred
Tags:
Comment:
Update code formatting, run stylize.php, whitespace updates
Modified paths:
  • /trunk/extensions/AdvancedSearch/AdvancedSearch.body.php (modified) (history)
  • /trunk/extensions/AdvancedSearch/AdvancedSearch.i18n.php (modified) (history)
  • /trunk/extensions/AdvancedSearch/AdvancedSearch.setup.php (modified) (history)
  • /trunk/extensions/AdvancedSearch/AdvancedSearchCategoryIntersector.php (modified) (history)
  • /trunk/extensions/AdvancedSearch/AdvancedSearchPager.php (modified) (history)
  • /trunk/extensions/AdvancedSearch/categorysearch.sql (modified) (history)
  • /trunk/extensions/AdvancedSearch/populateCategorySearch.inc (modified) (history)
  • /trunk/extensions/AdvancedSearch/populateCategorySearch.php (modified) (history)

Diff [purge]

Index: trunk/extensions/AdvancedSearch/AdvancedSearch.i18n.php
@@ -6,7 +6,7 @@
77 * (at your option) any later version.
88 *
99 * @author Roan Kattouw <roan.kattouw@home.nl>
10 - * @copyright Copyright (C) 2008 Roan Kattouw
 10+ * @copyright Copyright (C) 2008 Roan Kattouw
1111 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
1212 *
1313 * An extension that allows for searching inside categories
@@ -14,49 +14,41 @@
1515 * For information how to install and use this extension, see the README file.
1616 *
1717 */
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 -}
2618
2719 $messages = array();
2820
2921 $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',
6355 );
Index: trunk/extensions/AdvancedSearch/AdvancedSearch.setup.php
@@ -6,7 +6,7 @@
77 * (at your option) any later version.
88 *
99 * @author Roan Kattouw <roan.kattouw@home.nl>
10 - * @copyright Copyright (C) 2008 Roan Kattouw
 10+ * @copyright Copyright (C) 2008 Roan Kattouw
1111 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
1212 *
1313 * An extension that allows for searching inside categories
@@ -15,12 +15,12 @@
1616 *
1717 */
1818 # 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' ) ) {
2020 echo <<<EOT
2121 To install the AdvancedSearch extension, put the following line in LocalSettings.php:
2222 require_once( "\$IP/extensions/AdvancedSearch/AdvancedSearch.setup.php" );
2323 EOT;
24 - exit(1);
 24+ exit( 1 );
2525 }
2626
2727 $wgExtensionCredits['specialpage'][] = array(
@@ -33,7 +33,7 @@
3434 'descriptionmsg' => 'advancedsearch-desc',
3535 );
3636
37 -$dir = dirname(__FILE__) . '/';
 37+$dir = dirname( __FILE__ ) . '/';
3838 $wgExtensionMessagesFiles['AdvancedSearch'] = $dir . 'AdvancedSearch.i18n.php';
3939 $wgAutoloadClasses['AdvancedSearch'] = $dir . 'AdvancedSearch.body.php';
4040 $wgAutoloadClasses['AdvancedSearchPager'] = $dir . 'AdvancedSearchPager.php';
@@ -45,20 +45,18 @@
4646 $wgHooks['LinksUpdate'][] = 'AdvancedSearchCategoryIntersector::LinksUpdate';
4747 $wgHooks['ArticleDeleteComplete'][] = 'AdvancedSearchCategoryIntersector::ArticleDeleteComplete';
4848
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' );
5352
54 - $title = Title::newFromText($text);
 53+ $title = Title::newFromText( $text );
5554 $specialPageArray['AdvancedSearch'][] = $title->getDBkey();
5655 return true;
5756 }
5857
59 -function AdvancedSearchSchemaUpdate()
60 -{
 58+function AdvancedSearchSchemaUpdate() {
6159 global $wgExtNewTables;
62 - $dir = dirname(__FILE__) . '/';
63 - $wgExtNewTables[] = array('categorysearch', $dir . 'categorysearch.sql');
 60+ $dir = dirname( __FILE__ ) . '/';
 61+ $wgExtNewTables[] = array( 'categorysearch', $dir . 'categorysearch.sql' );
6462 return true;
6563 }
Index: trunk/extensions/AdvancedSearch/AdvancedSearchPager.php
@@ -6,7 +6,7 @@
77 * (at your option) any later version.
88 *
99 * @author Roan Kattouw <roan.kattouw@home.nl>
10 - * @copyright Copyright (C) 2008 Roan Kattouw
 10+ * @copyright Copyright (C) 2008 Roan Kattouw
1111 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
1212 *
1313 * An extension that allows for searching inside categories
@@ -15,26 +15,25 @@
1616 *
1717 */
1818 # 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' ) ) {
2020 echo <<<EOT
2121 To install the AdvancedSearch extension, put the following line in LocalSettings.php:
2222 require_once( "\$IP/extensions/AdvancedSearch/AdvancedSearch.setup.php" );
2323 EOT;
24 - exit(1);
 24+ exit( 1 );
2525 }
2626
2727 /**
2828 * Class that pages search results
29 - *
 29+ *
3030 * FIXME: Only works with MySQL, not with PostGreSQL or Oracle
3131 */
32 -class AdvancedSearchPager
33 -{
 32+class AdvancedSearchPager {
3433 // array(array('foo', bar'), array('baz')) means
3534 // foo AND bar OR baz
3635 protected $mInclText, $mExclText, $mInclCats, $mExclCats, $mNamespaces;
3736 protected $mSearchTitle, $mSearchContent, $mKey;
38 -
 37+
3938 /** A list of stop words ignored by the MySQL fulltext search */
4039 static $stopWords = array(
4140 'a\'s', 'able', 'about', 'above', 'according', 'accordingly',
@@ -61,7 +60,7 @@
6261 'elsewhere', 'enough', 'entirely', 'especially', 'et', 'etc',
6362 'even', 'ever', 'every', 'everybody', 'everyone', 'everything',
6463 'everywhere', 'ex', 'exactly', 'example', 'except', 'far',
65 - 'few', 'fifth', 'first', 'five', 'followed', 'following',
 64+ 'few', 'fifth', 'first', 'five', 'followed', 'following',
6665 'follows', 'for', 'former', 'formerly', 'forth', 'four',
6766 'from', 'further', 'furthermore', 'get', 'gets', 'getting',
6867 'given', 'gives', 'go', 'goes', 'going', 'gone', 'got',
@@ -124,7 +123,7 @@
125124 'whose', 'why', 'will', 'willing', 'wish', 'with', 'within',
126125 'without', 'won\'t', 'wonder', 'would', 'would', 'wouldn\'t',
127126 'yes', 'yet', 'you', 'you\'d', 'you\'ll', 'you\'re', 'you\'ve',
128 - 'your', 'yours', 'yourself', 'yourselves', 'zero');
 127+ 'your', 'yours', 'yourself', 'yourselves', 'zero' );
129128
130129 /**
131130 * Constructor
@@ -136,54 +135,49 @@
137136 * @param $namespaces array Array of NS_* constants
138137 * @param $permalink bool If true, cache this query longer
139138 */
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 );
144142
145 - $sc = implode(' ' . wfMsg('advancedsearch-keyword-or') . ' ', $speedcats);
 143+ $sc = implode( ' ' . wfMsg( 'advancedsearch-keyword-or' ) . ' ', $speedcats );
146144 $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 );
149147 $this->mNamespaces = $namespaces;
150148 $this->mSearchTitle = $searchTitle;
151149 $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 ),
154152 $searchTitle ? 1 : 0,
155 - $searchContent ? 1 : 0)));
 153+ $searchContent ? 1 : 0 ) ) );
156154
157155 # Check whether all namespace boxes were checked
158156 # If so, save some work
159 - if($this->mNamespaces == array_keys(AdvancedSearch::searchableNamespaces()))
 157+ if ( $this->mNamespaces == array_keys( AdvancedSearch::searchableNamespaces() ) )
160158 $this->mNamespaces = array();
161 - $this->mDb = wfGetDb(DB_SLAVE);
 159+ $this->mDb = wfGetDb( DB_SLAVE );
162160 }
163 -
164 - public function getSearchTitle()
165 - {
 161+
 162+ public function getSearchTitle() {
166163 return $this->mSearchTitle;
167164 }
168 -
169 - public function getSearchContent()
170 - {
 165+
 166+ public function getSearchContent() {
171167 return $this->mSearchContent;
172168 }
173 -
174 - public function cacheQuery()
175 - {
 169+
 170+ public function cacheQuery() {
176171 global $wgMemc;
177 - $key = wfMemcKey('advancedsearch', $this->mKey);
178 - $wgMemc->set($key, $this);
 172+ $key = wfMemcKey( 'advancedsearch', $this->mKey );
 173+ $wgMemc->set( $key, $this );
179174 return $this->mKey;
180175 }
181 -
182 - public static function newFromKey($key)
183 - {
 176+
 177+ public static function newFromKey( $key ) {
184178 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 );
188182 return $retval;
189183 }
190184
@@ -191,13 +185,12 @@
192186 * Find out whether any errors occurred when parsing the search strings
193187 * @return array Array of errors, which are either strings or false (no error)
194188 */
195 - public function getParseErrors()
196 - {
 189+ public function getParseErrors() {
197190 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 )
202195 );
203196 }
204197
@@ -207,12 +200,11 @@
208201 * @param $indices array Array of indices, i.e. array(1,2,3) gets $arr[1][2][3]
209202 * @return mixed
210203 */
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 ) )
215207 return @$arr[$i];
216 - return self::getFromArray(@$arr[$i], $indices);
 208+ return self::getFromArray( @$arr[$i], $indices );
217209 }
218210
219211 /**
@@ -221,13 +213,12 @@
222214 * @param $arr array Array to work on
223215 * @param $indices array See getFromArray()
224216 */
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 ) )
229220 $arr[$i] = $value;
230221 else
231 - self::setInArray($value, $arr[$i], $indices);
 222+ self::setInArray( $value, $arr[$i], $indices );
232223 }
233224
234225 /**
@@ -236,67 +227,66 @@
237228 * @param $parseSpaces bool If true, parse spaces as ANDs
238229 * @return mixed Array, or error message (string) if $text is invalid
239230 */
240 - protected function parse($text, $parseSpaces)
241 - {
 231+ protected function parse( $text, $parseSpaces ) {
242232 $arr = array();
243 - $boom = explode(' ', $text);
 233+ $boom = explode( ' ', $text );
244234 // Keep track of where we are in $arr
245 - $indices = array(0, 0);
 235+ $indices = array( 0, 0 );
246236 $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+ '(', ')', '' );
250240 // We can expect two things:
251241 // 'token': we expect AND, OR, ) or a continuation
252242 // 'word': we expect ( or text
253243 $expecting = 'word';
254 - for($i = 0; $i < count($boom); $i++)
 244+ for ( $i = 0; $i < count( $boom ); $i++ )
255245 {
256 - if($expecting == 'token')
 246+ if ( $expecting == 'token' )
257247 {
258 - if($boom[$i] == wfMsg('advancedsearch-keyword-and'))
 248+ if ( $boom[$i] == wfMsg( 'advancedsearch-keyword-and' ) )
259249 {
260250 // Increment the last index
261 - end($indices);
262 - $indices[key($indices)]++;
 251+ end( $indices );
 252+ $indices[key( $indices )]++;
263253 $expecting = 'word';
264254 continue;
265255 }
266 - if($boom[$i] == wfMsg('advancedsearch-keyword-or'))
 256+ if ( $boom[$i] == wfMsg( 'advancedsearch-keyword-or' ) )
267257 {
268258 // Increment the second-to-last index
269259 // 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 )]++;
274264 $expecting = 'word';
275265 continue;
276266 }
277267 // ( 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] ) );
283273 // We found a word, so it's a continuation
284 - if($parseSpaces && $boom[$i] != ')')
 274+ if ( $parseSpaces && $boom[$i] != ')' )
285275 {
286276 // Increment the last index
287 - end($indices);
288 - $indices[key($indices)]++;
 277+ end( $indices );
 278+ $indices[key( $indices )]++;
289279 }
290280 }
291281 // We're expecting a word
292282 // 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] ) );
299289 // See if it's ( or )
300 - if($boom[$i] == '(')
 290+ if ( $boom[$i] == '(' )
301291 {
302292 // Go one level deeper
303293 $indices[] = 0;
@@ -305,283 +295,272 @@
306296 $expecting = 'word';
307297 continue;
308298 }
309 - if($boom[$i] == ')')
 299+ if ( $boom[$i] == ')' )
310300 {
311301 // Go one level down
312302 $depth--;
313 - if($depth < 0)
 303+ if ( $depth < 0 )
314304 // 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 );
321311 $expecting = 'token';
322312 continue;
323313 }
324314 // Parse quotes
325 - if(substr($boom[$i], 0, 1) == '"')
 315+ if ( substr( $boom[$i], 0, 1 ) == '"' )
326316 {
327317 $word = $boom[$i];
328 - while(substr($word, -1) !== '"')
 318+ while ( substr( $word, - 1 ) !== '"' )
329319 {
330320 $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];
334324 }
335325 # Strip the quotes
336 - $word = substr($word, 1, -1);
 326+ $word = substr( $word, 1, - 1 );
337327 }
338328 else
339329 $word = $boom[$i];
340330 // 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 ) )
343333 {
344 - if($parseSpaces || in_array(@$boom[$i + 1], $tokens))
345 - {
 334+ if ( $parseSpaces || in_array( @$boom[$i + 1], $tokens ) )
 335+ {
346336 # We got a single word. Check that it's not too
347337 # 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 );
352342 }
353 - self::setInArray($word, $arr, $indices);
 343+ self::setInArray( $word, $arr, $indices );
354344 }
355345 else
356 - self::setInArray("$lastAdded $word", $arr, $indices);
 346+ self::setInArray( "$lastAdded $word", $arr, $indices );
357347 $expecting = 'token';
358348 }
359349 // 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' );
362352 return $arr;
363353 }
364 -
 354+
365355 /**
366356 * Is an array really empty? Also checks for nested emptiness, e.g.
367357 * array(array(''))
368358 * @param $arr array
369359 * @return bool
370360 */
371 - static function isEmpty($arr)
372 - {
373 - if(empty($arr))
 361+ static function isEmpty( $arr ) {
 362+ if ( empty( $arr ) )
374363 return true;
375 - if(!is_array($arr))
 364+ if ( !is_array( $arr ) )
376365 return false;
377 - foreach($arr as $a)
378 - if(!self::isEmpty($a))
 366+ foreach ( $arr as $a )
 367+ if ( !self::isEmpty( $a ) )
379368 return false;
380369 return true;
381 - }
 370+ }
382371
383372 /**
384373 * Generate a MATCH condition
385374 * @param $arr array $m{Incl,Excl}{Text,Cats}
386375 * @return string A MATCH condition
387376 */
388 - protected function getMatchString($arr)
389 - {
 377+ protected function getMatchString( $arr ) {
390378 $conds = array();
391379 $searchEngine = SearchEngine::create();
392 - foreach($arr as $a)
 380+ foreach ( $arr as $a )
393381 {
394382 $subconds = array();
395 - foreach((array)$a as $b)
 383+ foreach ( (array)$a as $b )
396384 {
397 - if(is_array($b))
 385+ if ( is_array( $b ) )
398386 {
399 - $m = $this->getMatchString($b);
400 - if(!empty($m))
 387+ $m = $this->getMatchString( $b );
 388+ if ( !empty( $m ) )
401389 $subconds[] = "+($m)";
402390 }
403391 else
404392 {
405393 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 );
409397 # 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 )
414402 $s = "\"$s\"";
415 - if(!empty($s))
 403+ if ( !empty( $s ) )
416404 $subconds[] = "+$s";
417405 }
418406 }
419 - $sc = implode(' ', $subconds);
420 - if(!empty($sc))
 407+ $sc = implode( ' ', $subconds );
 408+ if ( !empty( $sc ) )
421409 $conds[] = "($sc)";
422410 }
423 - return implode(' ', $conds);
 411+ return implode( ' ', $conds );
424412 }
425 -
 413+
426414 /**
427415 * Get the DB key for a category
428416 * @param $c string Category name
429417 */
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 )
434421 return false;
435422 $c = $t->getDBkey();
436423 }
437424
438 - public function getQueryInfo()
439 - {
 425+ public function getQueryInfo() {
440426 $db = $this->mDb;
441427 $retval = array();
442428
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+
450436 $retval['tables'][] = 'page';
451 - if(!self::isEmpty($this->mInclText) || !self::isEmpty($this->mExclText))
 437+ if ( !self::isEmpty( $this->mInclText ) || !self::isEmpty( $this->mExclText ) )
452438 {
453439 $retval['tables'][] = 'searchindex';
454440 $retval['conds'][] = 'page_id=si_page';
455 - if(!self::isEmpty($this->mInclText))
 441+ if ( !self::isEmpty( $this->mInclText ) )
456442 {
457443 $titlecond = $contentcond = $cond = '';
458 - if($this->mSearchTitle)
 444+ if ( $this->mSearchTitle )
459445 $titlecond = "MATCH (si_title) AGAINST ('$incltext' IN BOOLEAN MODE)";
460 - if($this->mSearchContent)
 446+ if ( $this->mSearchContent )
461447 $contentcond = "MATCH (si_text) AGAINST ('$incltext' IN BOOLEAN MODE)";
462 - if(!empty($titlecond) && !empty($contentcond))
 448+ if ( !empty( $titlecond ) && !empty( $contentcond ) )
463449 $cond = "$titlecond OR $contentcond";
464450 else
465451 $cond = $titlecond . $contentcond;
466 - if(!empty($cond))
 452+ if ( !empty( $cond ) )
467453 $retval['conds'][] = $cond;
468454 }
469 - if(!self::isEmpty($this->mExclText))
 455+ if ( !self::isEmpty( $this->mExclText ) )
470456 {
471457 $titlecond = $contentcond = $cond = '';
472 - if($this->mSearchTitle)
 458+ if ( $this->mSearchTitle )
473459 $titlecond = "NOT MATCH (si_title) AGAINST ('$excltext' IN BOOLEAN MODE)";
474 - if($this->mSearchContent)
 460+ if ( $this->mSearchContent )
475461 $contentcond = "NOT MATCH (si_text) AGAINST ('$excltext' IN BOOLEAN MODE)";
476 - if(!empty($titlecond) && !empty($contentcond))
 462+ if ( !empty( $titlecond ) && !empty( $contentcond ) )
477463 $cond = "$titlecond OR $contentcond";
478464 else
479465 $cond = $titlecond . $contentcond;
480 - if(!empty($cond))
 466+ if ( !empty( $cond ) )
481467 $retval['conds'][] = $cond;
482468 }
483469 }
484 - if(!self::isEmpty($this->mInclCats) || !self::isEmpty($this->mExclCats))
 470+ if ( !self::isEmpty( $this->mInclCats ) || !self::isEmpty( $this->mExclCats ) )
485471 {
486472 $retval['tables'][] = 'categorysearch';
487473 $retval['conds'][] = 'page_id=cs_page';
488 - if(!self::isEmpty($this->mInclCats))
 474+ if ( !self::isEmpty( $this->mInclCats ) )
489475 $retval['conds'][] = "MATCH (cs_categories) AGAINST ('$inclcats' IN BOOLEAN MODE)";
490 - if(!self::isEmpty($this->mExclCats))
 476+ if ( !self::isEmpty( $this->mExclCats ) )
491477 $retval['conds'][] = "NOT MATCH (cs_categories) AGAINST ('$exclcats' IN BOOLEAN MODE)";
492478 }
493 - if(!empty($this->mNamespaces))
 479+ if ( !empty( $this->mNamespaces ) )
494480 $retval['conds']['page_namespace'] = $this->mNamespaces;
495 -
496 - $retval['fields'] = array('page_namespace', 'page_title');
 481+
 482+ $retval['fields'] = array( 'page_namespace', 'page_title' );
497483 return $retval;
498484 }
499485
500 - public function reallyDoQuery()
501 - {
502 - if(isset($this->mResult))
 486+ public function reallyDoQuery() {
 487+ if ( isset( $this->mResult ) )
503488 return $this->mResult;
504489 global $wgRequest;
505 - list($this->mLimit, $this->mOffset) = $wgRequest->getLimitOffset(50, 'limit');
 490+ list( $this->mLimit, $this->mOffset ) = $wgRequest->getLimitOffset( 50, 'limit' );
506491 $info = $this->getQueryInfo();
507492 $tables = $info['tables'];
508493 $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 );
517502 }
518 -
519 - public function getNumRows()
520 - {
521 - if(!isset($this->mResult))
 503+
 504+ public function getNumRows() {
 505+ if ( !isset( $this->mResult ) )
522506 $this->reallyDoQuery();
523507 return $this->mResult->numRows();
524 - }
 508+ }
525509
526 - public function preprocessResults($result)
527 - {
 510+ public function preprocessResults( $result ) {
528511 # Run a LinkBatch query
529512 $lb = new LinkBatch;
530513 $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+ }
533517 $lb->execute();
534518 $result->rewind();
535519 }
536520
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' );
540523 }
541524
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' );
545527 }
546528
547 - public function formatRow($row)
548 - {
 529+ public function formatRow( $row ) {
549530 global $wgUser;
550531 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' );
553534 $tdb = $tdf = '';
554 - if($i == 0)
 535+ if ( $i == 0 )
555536 $tdb = $open;
556 - else if($i == ceil($this->mLimit / 2))
 537+ else if ( $i == ceil( $this->mLimit / 2 ) )
557538 $tdb = $close . $open;
558 - else if($i == $this->mLimit - 1)
 539+ else if ( $i == $this->mLimit - 1 )
559540 $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";
564545 }
565 -
566 - protected function getDefaultQuery()
567 - {
 546+
 547+ protected function getDefaultQuery() {
568548 $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'] );
572552 return $retval;
573553 }
574 -
575 - public function getBody()
576 - {
 554+
 555+ public function getBody() {
577556 $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 ) );
583562 $retval = $this->getStartBody();
584 - while(($row = $res->fetchObject()))
585 - $retval .= $this->formatRow($row);
 563+ while ( ( $row = $res->fetchObject() ) )
 564+ $retval .= $this->formatRow( $row );
586565 $retval .= $this->getEndBody();
587566 return $prevnext . $retval . $prevnext;
588567 }
Index: trunk/extensions/AdvancedSearch/AdvancedSearchCategoryIntersector.php
@@ -6,7 +6,7 @@
77 * (at your option) any later version.
88 *
99 * @author Roan Kattouw <roan.kattouw@home.nl>
10 - * @copyright Copyright (C) 2008 Roan Kattouw
 10+ * @copyright Copyright (C) 2008 Roan Kattouw
1111 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
1212 *
1313 * An extension that allows for searching inside categories
@@ -15,19 +15,18 @@
1616 *
1717 */
1818 # 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' ) ) {
2020 echo <<<EOT
2121 To install the AdvancedSearch extension, put the following line in LocalSettings.php:
2222 require_once( "\$IP/extensions/AdvancedSearch/AdvancedSearch.setup.php" );
2323 EOT;
24 - exit(1);
 24+ exit( 1 );
2525 }
2626
2727 /**
2828 * A class that does category intersections using the categorysearch table
2929 */
30 -class AdvancedSearchCategoryIntersector
31 -{
 30+class AdvancedSearchCategoryIntersector {
3231 private static $searchEngine;
3332
3433 /**
@@ -35,45 +34,41 @@
3635 * @param $pageid int Page ID
3736 * @param $categories array Array of categories (DB keys)
3837 */
39 - static function update($pageid, $categories)
40 - {
 38+ static function update( $pageid, $categories ) {
4139 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__ );
4846 }
49 -
 47+
5048 /**
5149 * Remove the entry for a page
5250 * @param $pageid int Page ID
5351 */
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__ );
5855 }
59 -
 56+
6057 /**
6158 * Hook function for 'LinksUpdate' hook
6259 * @param $lu LinksUpdate
6360 */
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 ) );
6763 return true;
6864 }
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() );
7368 return true;
7469 }
7570
7671 static function getSearchEngine() {
77 - if (!self::$searchEngine) {
 72+ if ( !self::$searchEngine ) {
7873 self::$searchEngine = SearchEngine::create();
7974 }
8075 return self::$searchEngine;
Index: trunk/extensions/AdvancedSearch/categorysearch.sql
@@ -7,7 +7,7 @@
88 CREATE TABLE /*$wgDBprefix*/categorysearch (
99 -- Key to page_id
1010 cs_page int unsigned NOT NULL,
11 -
 11+
1212 -- Munged version of categories
1313 -- E.g.: "Foo Living_people Bar"
1414 cs_categories mediumtext NOT NULL,
Index: trunk/extensions/AdvancedSearch/populateCategorySearch.php
@@ -6,20 +6,20 @@
77
88 $optionsWithArgs = array( 'begin', 'max-slave-lag', 'throttle' );
99
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." );
1414 require_once $commandLineInc;
1515 require_once "populateCategorySearch.inc";
1616
17 -if( isset( $options['help'] ) ) {
 17+if ( isset( $options['help'] ) ) {
1818 echo <<<TEXT
1919 This script will populate the categorysearch table, added by the
2020 CategorySearch extension. It will print out progress indicators every
2121 1000 pages it adds to the table. The script is perfectly safe to run on large,
2222 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
2424 correctness.
2525
2626 If the script is stopped and later resumed, you can use the --begin option with
@@ -39,7 +39,7 @@
4040 --max-slave-lag: If slave lag exceeds this many seconds, wait until it
4141 drops before continuing. Default: 10.
4242 --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.
4444 TEXT;
4545 exit( 0 );
4646 }
@@ -50,6 +50,7 @@
5151 'throttle' => 0,
5252 'force' => false
5353 );
 54+
5455 $options = array_merge( $defaults, $options );
5556
5657 populateCategorySearch( $options['begin'], $options['max-slave-lag'],
Index: trunk/extensions/AdvancedSearch/populateCategorySearch.inc
@@ -48,7 +48,7 @@
4949 break;
5050 $pageid = intval($row->page_id);
5151 $where = 'page_id > ' . $pageid;
52 -
 52+
5353 # Get all categories this page is in
5454 $res = $dbw->select(
5555 'categorylinks',
Index: trunk/extensions/AdvancedSearch/AdvancedSearch.body.php
@@ -6,7 +6,7 @@
77 * (at your option) any later version.
88 *
99 * @author Roan Kattouw <roan.kattouw@home.nl>
10 - * @copyright Copyright (C) 2008 Roan Kattouw
 10+ * @copyright Copyright (C) 2008 Roan Kattouw
1111 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
1212 *
1313 * An extension that allows for searching inside categories
@@ -15,181 +15,172 @@
1616 *
1717 */
1818 # 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' ) ) {
2020 echo <<<EOT
2121 To install the AdvancedSearch extension, put the following line in LocalSettings.php:
2222 require_once( "\$IP/extensions/AdvancedSearch/AdvancedSearch.setup.php" );
2323 EOT;
24 - exit(1);
 24+ exit( 1 );
2525 }
2626
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' );
3230 }
3331
34 - public function execute($par)
35 - {
 32+ public function execute( $par ) {
3633 global $wgOut, $wgRequest;
37 - wfLoadExtensionMessages('AdvancedSearch');
 34+ wfLoadExtensionMessages( 'AdvancedSearch' );
3835 $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 ) );
4239 else
43 - $wgOut->addHTML($this->buildForm());
 40+ $wgOut->addHTML( $this->buildForm() );
4441 }
45 -
 42+
4643 /**
4744 * Generate the HTML for the permanent link to this search result
4845 * @param $pager AdvancedSearchPager
4946 */
50 - protected function permaLink($pager)
51 - {
 47+ protected function permaLink( $pager ) {
5248 global $wgUser;
5349 $key = $pager->cacheQuery();
54 - return wfMsg('advancedsearch-permalink',
 50+ return wfMsg( 'advancedsearch-permalink',
5551 $wgUser->getSkin()->makeLinkObj(
56 - SpecialPage::getTitleFor("AdvancedSearch/$key"),
57 - wfMsg('advancedsearch-permalink-text')));
 52+ SpecialPage::getTitleFor( "AdvancedSearch/$key" ),
 53+ wfMsg( 'advancedsearch-permalink-text' ) ) );
5854 }
59 -
60 - protected function showResults($par)
61 - {
 55+
 56+ protected function showResults( $par ) {
6257 global $wgRequest;
63 - $key = $wgRequest->getVal('key', null);
64 - if(is_null($key))
 58+ $key = $wgRequest->getVal( 'key', null );
 59+ if ( is_null( $key ) )
6560 $key = $par;
6661 $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 )
7165 {
7266 $searchTitle = $pager->getSearchTitle();
7367 $searchContent = $pager->getSearchContent();
7468 }
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' );
8072 $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() ),
8880 $searchTitle,
89 - $searchContent);
 81+ $searchContent );
9082 }
9183 $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 {
10089 $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+ }
10393
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 ) {
10799 $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+ }
111104 }
112105 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 );
116109 }
117110
118 - protected function inputRow($name)
119 - {
 111+ protected function inputRow( $name ) {
120112 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' );
126118 }
127119
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' ) ) .
133124 $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' );
137128 }
138129
139 - protected function speedCatTable()
140 - {
 130+ protected function speedCatTable() {
141131 global $wgAdvancedSearchSpeedCats, $wgRequest;
142132 $i = $j = $n = 0;
143133 $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 ) {
148137 $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 ) {
153141 $i = 0;
154142 $j++;
155143 $close = true;
156 - }
157 - else
 144+ } else {
158145 $i++;
 146+ }
159147 $n++;
160148
161 - $retval .= Xml::openElement('td');
 149+ $retval .= Xml::openElement( 'td' );
162150 $checked = false;
163 - if(in_array($name, $scarr))
 151+ if ( in_array( $name, $scarr ) )
164152 $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' );
169157 }
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' ) );
175166 $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' ) );
177168 $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' );
181172 $retval .= $this->speedcatDropdownRows();
182 - $retval .= Xml::closeElement('table');
 173+ $retval .= Xml::closeElement( 'table' );
 174+
183175 return $retval;
184176 }
185 -
186 - protected function speedcatCheckboxes()
187 - {
 177+
 178+ protected function speedcatCheckboxes() {
188179 global $wgAdvancedSearchSpeedCats;
189 - if(!isset($wgAdvancedSearchSpeedCats) || empty($wgAdvancedSearchSpeedCats))
 180+ if ( !isset( $wgAdvancedSearchSpeedCats ) || empty( $wgAdvancedSearchSpeedCats ) )
190181 return array();
191182 $retval = array();
192183 $i = 1;
193 - foreach(@$wgAdvancedSearchSpeedCats as $name => $display)
 184+ foreach ( @$wgAdvancedSearchSpeedCats as $name => $display )
194185 {
195186 $retval[] = "speedcats-{$i}";
196187 $i++;
@@ -197,53 +188,55 @@
198189 return $retval;
199190 }
200191
201 - protected function speedcatDropdownRows()
202 - {
 192+ protected function speedcatDropdownRows() {
203193 global $wgAdvancedSearchSpeedCatDropdown, $wgRequest;
204 - if(!isset($wgAdvancedSearchSpeedCatDropdown) || empty($wgAdvancedSearchSpeedCatDropdown))
 194+
 195+ if ( !isset( $wgAdvancedSearchSpeedCatDropdown ) || empty( $wgAdvancedSearchSpeedCatDropdown ) ) {
205196 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 ) )
215208 $key = $value;
216 - $retval .= Xml::option($key, $value, $sel == $value);
 209+ $retval .= Xml::option( $key, $value, $sel == $value );
217210 }
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+
221216 return $retval;
222217 }
223 -
224 - public static function searchableNamespaces()
225 - {
 218+
 219+ public static function searchableNamespaces() {
226220 global $wgContLang;
227221 $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 )
230224 $retval[$ns] = $value;
231225 return $retval;
232226 }
233227
234 - protected function namespaceTable()
235 - {
 228+ protected function namespaceTable() {
236229 global $wgRequest, $wgUser;
237230 $i = 0;
238231 $j = 0;
239232 $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 )
243236 {
244237 $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 )
248241 {
249242 $i = 0;
250243 $j++;
@@ -251,58 +244,54 @@
252245 }
253246 else
254247 $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' );
258251 $checked = false;
259 - if(in_array($ns, $nsarr))
 252+ if ( in_array( $ns, $nsarr ) )
260253 $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' );
268261 }
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' ) );
274267 $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' ) );
276269 $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' );
280273
281 - $retval .= Xml::closeElement('table');
 274+ $retval .= Xml::closeElement( 'table' );
282275 return $retval;
283276 }
284 -
285 - protected function namespaceCheckboxes()
286 - {
 277+
 278+ protected function namespaceCheckboxes() {
287279 $retval = array();
288 - foreach(self::searchableNamespaces() as $ns => $unused)
 280+ foreach ( self::searchableNamespaces() as $ns => $unused )
289281 $retval[] = "namespaces-$ns";
290282 return $retval;
291283 }
292284
293 - protected function invertJS($func, $checkboxes)
294 - {
 285+ protected function invertJS( $func, $checkboxes ) {
295286 $retval = "function $func(action)\n{";
296 - foreach($checkboxes as $c)
 287+ foreach ( $checkboxes as $c )
297288 $retval .= "checkboxAction('$c', action);\n";
298289 $retval .= "}\n";
299290 return $retval;
300291 }
301 -
302 - protected function checkboxActionJS()
303 - {
 292+
 293+ protected function checkboxActionJS() {
304294 return <<<ENDOFLINE
305 -function checkboxAction(c, action)
306 -{
 295+function checkboxAction(c, action) {
307296 var obj = document.getElementById(c);
308297 switch(action)
309298 {
@@ -319,141 +308,140 @@
320309 ENDOFLINE;
321310 }
322311
323 - protected function buildForm($parseErrors = null, $searchTitle = true, $searchContent = true)
324 - {
 312+ protected function buildForm( $parseErrors = null, $searchTitle = true, $searchContent = true ) {
325313 global $wgScript, $wgOut;
326314 $wgOut->addInlineScript(
327315 $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+
335323 // The big table everything is in
336 - $retval .= Xml::openElement('table');
337 -
 324+ $retval .= Xml::openElement( 'table' );
 325+
338326 // 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' );
344332
345333 // 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' );
355343
356344 // 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+
370358 // 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' );
383371
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+
388376 // 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' ) );
392380 $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' );
396384
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+
404392 // 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+
418406 // 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' );
437419
 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+
438426 // The speedcat fieldset
439427 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' ) );
445432 $retval .= $this->speedCatTable();
446 - $retval .= Xml::closeElement('fieldset');
447 - $retval .= Xml::closeElement('td');
 433+ $retval .= Xml::closeElement( 'fieldset' );
 434+ $retval .= Xml::closeElement( 'td' );
448435 }
449436
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+
458446 return $retval;
459447 }
460448 }

Status & tagging log