r97755 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97754‎ | r97755 | r97756 >
Date:19:22, 21 September 2011
Author:siebrand
Status:ok
Tags:
Comment:
stylize.php and other whitespace updates.
Modified paths:
  • /trunk/extensions/IndexFunction/IndexAbstracts.php (modified) (history)
  • /trunk/extensions/IndexFunction/IndexFunction.i18n.php (modified) (history)
  • /trunk/extensions/IndexFunction/IndexFunction.php (modified) (history)
  • /trunk/extensions/IndexFunction/IndexFunction_body.php (modified) (history)
  • /trunk/extensions/IndexFunction/SpecialIndex.php (modified) (history)
  • /trunk/extensions/IndexFunction/indexes.sql (modified) (history)
  • /trunk/extensions/IndexFunction/specialindex.js (modified) (history)

Diff [purge]

Index: trunk/extensions/IndexFunction/IndexFunction_body.php
@@ -1,5 +1,4 @@
22 <?php
3 -
43 /* TODO:
54 * Memcached
65 * Warnings for API edit
@@ -7,7 +6,6 @@
87 */
98
109 class IndexFunction {
11 -
1210 var $mTo = array(); // An array of titles for pages being indexed
1311 var $mFrom = null; // A title object representing the index-title
1412
@@ -18,20 +16,26 @@
1917 $ns = $indextitle->getNamespace();
2018 $t = $indextitle->getDBkey();
2119 $dbr = wfGetDB( DB_SLAVE );
22 - $res = $dbr->select( 'indexes', 'in_from',
 20+
 21+ $res = $dbr->select( 'indexes', 'in_from',
2322 array( 'in_namespace' => $ns, 'in_title' => $t ),
2423 __METHOD__
2524 );
 25+
2626 if ( !$res->numRows() ) {
2727 return null;
2828 }
 29+
2930 $ind = new IndexFunction();
3031 $ids = array();
 32+
3133 foreach ( $res as $row ) {
3234 $ids[] = $row->in_from;
3335 }
 36+
3437 $ind->mTo = Title::newFromIDs( $ids );
3538 $ind->mFrom = $indextitle;
 39+
3640 return $ind;
3741 }
3842
@@ -39,16 +43,20 @@
4044 public static function newFromTarget( Title $target ) {
4145 $pageid = $target->getArticleID();
4246 $dbr = wfGetDB( DB_SLAVE );
43 - $res = $dbr->select( 'indexes', array('in_namespace', 'in_title'),
 47+
 48+ $res = $dbr->select( 'indexes', array( 'in_namespace', 'in_title' ),
4449 array( 'in_from' => $pageid ),
4550 __METHOD__
4651 );
 52+
4753 if ( !$res->numRows() ) {
4854 return null;
4955 }
 56+
5057 $ind = new IndexFunction();
5158 $row = $res->fetchRow();
5259 $ind->mFrom = Title::makeTitle( $row->in_namespace, $row->in_title );
 60+
5361 return $ind;
5462 }
5563
@@ -60,32 +68,42 @@
6169 if ( $this->mTo ) {
6270 return $this->mTo;
6371 }
 72+
6473 $dbr = wfGetDB( DB_SLAVE );
6574 $ns = $this->mFrom->getNamespace();
6675 $t = $this->mFrom->getDBkey();
67 - $res = $dbr->select( 'indexes', 'in_from',
 76+
 77+ $res = $dbr->select( 'indexes', 'in_from',
6878 array( 'in_namespace' => $ns, 'in_title' => $t ),
6979 __METHOD__
7080 );
 81+
7182 $ids = array();
 83+
7284 foreach ( $res as $row ) {
7385 $ids[] = $row->in_from;
7486 }
 87+
7588 $this->mTo = Title::newFromIDs( $ids );
 89+
7690 return $this->mTo;
7791 }
78 -
 92+
7993 // Makes an HTML <ul> list of targets
8094 public function makeTargetList() {
8195 global $wgUser;
 96+
8297 $sk = $wgUser->getSkin();
8398 $targets = $this->getTargets();
8499 $list = Xml::openElement( 'ul' );
85 - foreach( $targets as $t ) {
86 - $link = $sk->link( $t, $t->getPrefixedText(), array(), array(), array('known', 'noclasses') );
87 - $list.= Xml::tags( 'li', null, $link );
 100+
 101+ foreach ( $targets as $t ) {
 102+ $link = $sk->link( $t, $t->getPrefixedText(), array(), array(), array( 'known', 'noclasses' ) );
 103+ $list .= Xml::tags( 'li', null, $link );
88104 }
 105+
89106 $list .= Xml::CloseElement( 'ul' );
 107+
90108 return $list;
91109 }
92110
@@ -95,105 +113,131 @@
96114 if ( !$this->mTo ) {
97115 $this->getTargets();
98116 }
99 - return count( $this->mTo) > 1;
 117+
 118+ return count( $this->mTo ) > 1;
100119 }
101120 }
102121
103122 class IndexFunctionHooks {
104 -
105123 // Makes "Go" searches for an index title go directly to their target
106124 static function redirectSearch( $term, &$title ) {
107125 $title = Title::newFromText( $term );
108 - if ( is_null($title) ) {
 126+
 127+ if ( is_null( $title ) ) {
109128 return true;
110129 }
 130+
111131 $index = IndexFunction::newFromTitle( $title );
 132+
112133 if ( !$index ) {
113134 return true;
114135 } elseif ( $index->useSpecialPage() ) {
115136 global $wgOut;
 137+
116138 $title = SpecialPage::getTitleFor( 'Index', $title->getPrefixedText() );
117139 $wgOut->redirect( $title->getLocalURL() );
 140+
118141 return true;
119142 }
 143+
120144 $targets = $index->getTargets();
121145 $title = $targets[0];
 146+
122147 return false;
123148 }
124149
125150 // Make indexes work like redirects
126 - static function doRedirect( &$title, &$request,& $ignoreRedirect, &$target, &$article ) {
 151+ static function doRedirect( &$title, &$request, & $ignoreRedirect, &$target, &$article ) {
127152 if ( $article->exists() ) {
128153 return true;
129154 }
 155+
130156 $index = IndexFunction::newFromTitle( $title );
 157+
131158 if ( !$index ) {
132159 return true;
133 - } elseif ($index->useSpecialPage() ) {
 160+ } elseif ( $index->useSpecialPage() ) {
134161 global $wgOut;
 162+
135163 $t = SpecialPage::getTitleFor( 'Index', $title->getPrefixedText() );
136164 $wgOut->redirect( $t->getLocalURL() );
 165+
137166 return true;
138 - }
 167+ }
 168+
139169 $targets = $index->getTargets();
140170 $target = $targets[0];
141171 $article->mIsRedirect = true;
142172 $ignoreRedirect = false;
 173+
143174 return true;
144175 }
145 -
 176+
146177 // Turn links to indexes into blue links
147178 static function blueLinkIndexes( $skin, $target, $options, &$text, &$attribs, &$ret ) {
148179 if ( in_array( 'known', $options ) ) {
149180 return true;
150181 }
 182+
151183 $index = IndexFunction::newFromTitle( $target );
 184+
152185 if ( !$index ) {
153186 return true;
154187 }
 188+
155189 $attribs['class'] = str_replace( 'new', 'mw-index', $attribs['class'] );
156190 $attribs['href'] = $target->getLinkUrl();
157191 $attribs['title'] = $target->getEscapedText();
 192+
158193 return true;
159194 }
160195
161196 // Register the function name
162197 static function addIndexFunction( &$magicWords, $langCode ) {
163198 $magicWords['index-func'] = array( 0, 'index' );
 199+
164200 return true;
165201 }
166 -
 202+
167203 // Function called to render the parser function
168204 // Output is an empty string unless there are errors
169205 static function indexRender( &$parser ) {
170 - if ( !isset($parser->mOutput->mIndexes) ) {
 206+ if ( !isset( $parser->mOutput->mIndexes ) ) {
171207 $parser->mOutput->mIndexes = array();
172 - }
173 -
 208+ }
 209+
174210 static $indexCount = 0;
175211 static $indexes = array();
 212+
176213 $args = func_get_args();
177214 unset( $args[0] );
 215+
178216 if ( $parser->mOptions->getIsPreview() ) {
179217 # This is kind of hacky, but it seems that we only
180218 # know if its a preview during parse, not when its
181219 # done, which is when it matters for this
182220 $parser->mOutput->setProperty( 'preview', 1 );
183221 }
 222+
184223 $errors = array();
185224 $pageid = $parser->mTitle->getArticleID();
 225+
186226 foreach ( $args as $name ) {
187227 $t = Title::newFromText( $name );
188 - if( is_null( $t ) ) {
 228+
 229+ if ( is_null( $t ) ) {
189230 $errors[] = wfMsg( 'indexfunc-badtitle', $name );
190231 continue;
191232 }
 233+
192234 $ns = $t->getNamespace();
193235 $dbkey = $t->getDBkey();
194236 $entry = array( $ns, $dbkey );
 237+
195238 if ( in_array( $entry, $indexes ) ) {
196239 continue;
197 - }
 240+ }
 241+
198242 if ( $t->exists() ) {
199243 $errors[] = wfMsg( 'indexfunc-index-exists', $name );
200244 continue;
@@ -201,58 +245,77 @@
202246 $indexCount++;
203247 $parser->mOutput->mIndexes[$indexCount] = $entry;
204248 }
 249+
205250 if ( !$errors ) {
206251 return '';
207252 }
208 - $out = Xml::openElement( 'ul', array( 'class'=>'error' ) );
209 - foreach( $errors as $e ) {
 253+
 254+ $out = Xml::openElement( 'ul', array( 'class' => 'error' ) );
 255+
 256+ foreach ( $errors as $e ) {
210257 $out .= Xml::element( 'li', null, $e );
211258 }
 259+
212260 $out .= Xml::closeElement( 'ul' );
 261+
213262 return $out;
214263 }
215264
216265 // Called after parse, updates the index table
217266 static function doIndexes( $out, $parseroutput ) {
218 - if ( !isset($parseroutput->mIndexes) ) {
 267+ if ( !isset( $parseroutput->mIndexes ) ) {
219268 $parseroutput->mIndexes = array();
220269 }
 270+
221271 if ( $parseroutput->getProperty( 'preview' ) ) {
222272 return true;
223273 }
 274+
224275 $pageid = $out->getTitle()->getArticleID();
225276 $dbw = wfGetDB( DB_MASTER );
226 - $res = $dbw->select( 'indexes',
 277+
 278+ $res = $dbw->select( 'indexes',
227279 array( 'in_namespace', 'in_title' ),
228280 array( 'in_from' => $pageid ),
229281 __METHOD__
230282 );
 283+
231284 $current = array();
232 - foreach( $res as $row ) {
 285+
 286+ foreach ( $res as $row ) {
233287 $current[] = array( $row->in_namespace, $row->in_title );
234288 }
 289+
235290 $toAdd = wfArrayDiff2( $parseroutput->mIndexes, $current );
236291 $toRem = wfArrayDiff2( $current, $parseroutput->mIndexes );
 292+
237293 if ( $toAdd || $toRem ) {
238294 $dbw->begin( __METHOD__ );
 295+
239296 if ( $toRem ) {
240297 $delCond = "in_from = $pageid AND (";
241 - $parts = array();
 298+ $parts = array();
 299+
242300 # Looking at Database::delete, it seems to turn arrays into AND statements
243301 # but we need to chain together groups of ANDs with ORs
244302 foreach ( $toRem as $entry ) {
245 - $parts[] = "(in_namespace = " . $entry[0] . " AND in_title = " . $dbw->addQuotes($entry[1]) . ")";
 303+ $parts[] = "(in_namespace = " . $entry[0] . " AND in_title = " . $dbw->addQuotes( $entry[1] ) . ")";
246304 }
 305+
247306 $delCond .= implode( ' OR ', $parts ) . ")";
248 - $dbw->delete( 'indexes', array($delCond), __METHOD__ );
 307+ $dbw->delete( 'indexes', array( $delCond ), __METHOD__ );
249308 }
 309+
250310 if ( $toAdd ) {
251311 $ins = array();
 312+
252313 foreach ( $toAdd as $entry ) {
253314 $ins[] = array( 'in_from' => $pageid, 'in_namespace' => $entry[0], 'in_title' => $entry[1] );
254315 }
 316+
255317 $dbw->insert( 'indexes', $ins, __METHOD__ );
256318 }
 319+
257320 $dbw->commit( __METHOD__ );
258321 }
259322 return true;
@@ -261,7 +324,8 @@
262325 // When deleting a page, delete all rows from the index table that point to it
263326 static function onDelete( &$article, &$user, $reason, $id ) {
264327 $dbw = wfGetDB( DB_MASTER );
265 - $dbw->delete( 'indexes', array( 'in_from'=>$id ), __METHOD__ );
 328+ $dbw->delete( 'indexes', array( 'in_from' => $id ), __METHOD__ );
 329+
266330 return true;
267331 }
268332
@@ -271,10 +335,12 @@
272336 $ns = $t->getNamespace();
273337 $dbkey = $t->getDBkey();
274338 $dbw = wfGetDB( DB_MASTER );
275 - $dbw->delete( 'indexes',
276 - array( 'in_namespace'=>$ns, 'in_title'=>$dbkey ),
277 - __METHOD__
 339+
 340+ $dbw->delete( 'indexes',
 341+ array( 'in_namespace' => $ns, 'in_title' => $dbkey ),
 342+ __METHOD__
278343 );
 344+
279345 return true;
280346 }
281347
@@ -282,37 +348,44 @@
283349 static function editWarning( $editpage ) {
284350 $t = $editpage->mTitle;
285351 $index = IndexFunction::newFromTitle( $t );
286 - if (!$index) {
 352+
 353+ if ( !$index ) {
287354 return true;
288355 }
289 -
 356+
290357 $list = $index->makeTargetList();
291358 $c = count( $index->getTargets() );
292359 $warn = wfMsgExt( 'indexfunc-editwarning', array( 'parsemag' ), $list, $c );
293360 $editpage->editFormTextTop .= "<span class='error'>$warn</span>";
 361+
294362 return true;
295363 }
296364
297365 static function afterMove( &$form, &$orig, &$new ) {
298366 global $wgOut;
 367+
299368 $index = IndexFunction::newFromTitle( $new );
 369+
300370 if ( !$index ) {
301371 return true;
302372 }
 373+
303374 $c = count( $index->getTargets() );
304375 $list = $index->makeTargetList();
305376 $newns = $new->getNamespace();
306377 $newdbk = $new->getDBkey();
307378 $dbw = wfGetDB( DB_MASTER );
308 - $dbw->delete( 'indexes',
309 - array( 'in_namespace'=>$newns, 'in_title'=>$newdbk ),
310 - __METHOD__
 379+
 380+ $dbw->delete( 'indexes',
 381+ array( 'in_namespace' => $newns, 'in_title' => $newdbk ),
 382+ __METHOD__
311383 );
 384+
312385 $msg = wfMsgExt( 'indexfunc-movewarn', array( 'parsemag' ), $new->getPrefixedText(), $list, $c );
313386 $msg = "<span class='error'>$msg</span>";
 387+
314388 $wgOut->addHTML( $msg );
 389+
315390 return true;
316391 }
317 -
318392 }
319 -
Index: trunk/extensions/IndexFunction/IndexFunction.i18n.php
@@ -32,9 +32,9 @@
3333 'index-emptylist' => 'There are no pages associated with "$1"',
3434 'index-expand-detail' => 'Show pages indexed under this title',
3535 'index-hide-detail' => 'Hide the list of pages',
36 - 'index-no-results' => 'The search returned no results',
37 - 'index-search-explain' => 'This page uses a prefix search.
38 -
 36+ 'index-no-results' => 'The search returned no results',
 37+ 'index-search-explain' => 'This page uses a prefix search.
 38+
3939 Type the first few characters and press the submit button to search for page titles and index entries that start with the search string',
4040 'index-details-explain' => 'Entries with arrows are index entries.
4141 Click the arrow to show all pages indexed under that title.',
@@ -213,7 +213,7 @@
214214 'index-search-explain' => 'Ober a ra ar bajenn-mañ gant ur rakger klask.
215215
216216 Merkit an nebeud arouezennoù kentañ ha pouezit war ar bouton klask evit kavout titloù ar pajennoù a grog gant an neudennad klask-se',
217 - 'index-details-explain' => 'Monedoù meneger eo ar monedoù gant biroù.
 217+ 'index-details-explain' => 'Monedoù meneger eo ar monedoù gant biroù.
218218 Klikit war ar bir evit gwelet an holl bajennoù menegeret dindan an titl-se.',
219219 );
220220
@@ -439,13 +439,13 @@
440440 $messages['fi'] = array(
441441 'indexfunc-desc' => 'Jäsenninfunktio automaattisten ohjauksien ja täsmennyssivujen luomiseen.',
442442 'indexfunc-badtitle' => 'Epäkelpo otsikko: ”$1”',
443 - 'indexfunc-editwarning' => 'Varoitus:
 443+ 'indexfunc-editwarning' => 'Varoitus:
444444 Tämä otsikko on indeksiotsikko {{PLURAL:$2|seuraavalle sivulle|seuraaville sivuille}}:
445445 $1
446446 Tarkista ettei sivua, jota olet luomassa ole jo olemassa toisella otsikolla.
447447 Jos luot tämän sivun, poista otsikko <nowiki>{{#index:}}</nowiki>-tagista {{PLURAL:$2|yllä olevalla sivulla|yllä olevilla sivuilla}}.',
448448 'indexfunc-index-exists' => 'Sivu ”$1” on jo olemassa',
449 - 'indexfunc-movewarn' => 'Virhe:
 449+ 'indexfunc-movewarn' => 'Virhe:
450450 ”$1” on indeksiotsikko {{PLURAL:$3|seuraavalle sivulle|seuraaville sivuille}}:
451451 $2
452452 Poista ”$1” <nowiki>{{#index:}}</nowiki>-tagista {{PLURAL:$3|yllä olevilla sivuilla|yllä olevalla sivulla}}.',
@@ -461,7 +461,7 @@
462462 'index-search-explain' => 'Tämä sivu käyttää etuliitehakua.
463463
464464 Kirjoita pari ensimmäistä kirjainta ja napsauta lähetä-nappia hakeaksesi sivujen otsikoista ja indeksimerkinnöistä, jotka alkavat hakusanalla.',
465 - 'index-details-explain' => 'Nuolin varustetut merkinnät ovat indeksimerkintöjä.
 465+ 'index-details-explain' => 'Nuolin varustetut merkinnät ovat indeksimerkintöjä.
466466 Napsauta nuolta näyttääksesi kaikki sivut, jotka on indeksoitu otsikon alle.',
467467 );
468468
@@ -538,7 +538,7 @@
539539 'index-expand-detail' => 'Mostrar as páxinas indexadas baixo este título',
540540 'index-hide-detail' => 'Agochar a lista de páxinas',
541541 'index-no-results' => 'A procura non devolveu resultados',
542 - 'index-search-explain' => 'Esta páxina usa unha procura por prefixos.
 542+ 'index-search-explain' => 'Esta páxina usa unha procura por prefixos.
543543
544544 Insira os primeiros caracteres e prema o botón "Enviar" para buscar títulos de páxinas e entradas de índice que comezan coa secuencia de procura',
545545 'index-details-explain' => 'As entradas con frechas son entradas de índice.
@@ -576,7 +576,7 @@
577577 'index-expand-detail' => 'Syte aazeige, wu unter däm Titel ufglischtet sin',
578578 'index-hide-detail' => 'D Sytelischt verstecke',
579579 'index-no-results' => 'D Suechi het kei Ergebnis brocht',
580 - 'index-search-explain' => 'Die Syte verwändet e Präfixsuechi.
 580+ 'index-search-explain' => 'Die Syte verwändet e Präfixsuechi.
581581
582582 Tipp di erschte paar Buehcstabe yy un druck dr „Abschicke“-Chnopf go Sytetitel un Verzeichnisyytreg suech, wu mit däre Zeichechette aafange',
583583 'index-details-explain' => 'Yytreg mit Bege sin Verzeichnisyytreg.
@@ -720,12 +720,12 @@
721721 'indexfunc-badtitle' => 'Judul tidak sah: "$1"',
722722 'indexfunc-editwarning' => 'Peringatan:
723723 Judul ini adalah judul indeks {{PLURAL:$2|halaman|halaman}} berikut :
724 -$1
725 -Pastikan halaman yang akan Anda buat tidak ada pada judul yang berbeda.
 724+$1
 725+Pastikan halaman yang akan Anda buat tidak ada pada judul yang berbeda.
726726 Jika Anda membuat halaman ini, hapus halaman ini dari <nowiki>{{#index:}}</nowiki> di atas {{PLURAL:$2|halaman|halaman}}.',
727727 'indexfunc-index-exists' => 'Halaman "$1" sudah ada',
728728 'indexfunc-movewarn' => 'Peringatan:
729 -"$1" adalah judul indeks {{PLURAL:$3|halaman|halaman}} berikut :
 729+"$1" adalah judul indeks {{PLURAL:$3|halaman|halaman}} berikut :
730730 $2
731731 Hapus "$1" dari <nowiki>{{#index:}}</nowiki> di atas {{PLURAL:$3|halaman|halaman}}.',
732732 'index' => 'Indeks',
@@ -1056,7 +1056,7 @@
10571057 'indexfunc-editwarning' => 'Uwaga.
10581058 Ten tytuł jest tytułem indeksu {{PLURAL:$2|strony|następujących stron:}}
10591059 $1
1060 -Upewnij się, że strona, którą chcesz utworzyć nie istnieje pod inną nazwą.
 1060+Upewnij się, że strona, którą chcesz utworzyć nie istnieje pod inną nazwą.
10611061 Jeśli utworzysz tę stronę, usuń tytułu z <nowiki>{{#index:}}</nowiki> dla {{PLURAL:$2|powyższej strony|powyższych stron}}.',
10621062 'indexfunc-index-exists' => 'Strona „$1” już istnieje',
10631063 'indexfunc-movewarn' => 'Uwaga.
Index: trunk/extensions/IndexFunction/IndexFunction.php
@@ -3,20 +3,20 @@
44 $wgExtensionCredits['other'][] = array(
55 'path' => __FILE__,
66 'name' => 'IndexFunction',
7 - 'author' =>'Alex Zaddach',
8 - 'url' => 'http://www.mediawiki.org/wiki/Extension:IndexFunction',
 7+ 'author' => 'Alex Zaddach',
 8+ 'url' => 'http://www.mediawiki.org/wiki/Extension:IndexFunction',
99 'descriptionmsg' => 'indexfunc-desc',
1010 );
1111
12 -$dir = dirname(__FILE__) . '/';
 12+$dir = dirname( __FILE__ ) . '/';
1313
14 -# Register function
 14+# Register function
1515 $wgHooks['ParserFirstCallInit'][] = 'efIndexSetup';
1616 $wgHooks['LanguageGetMagic'][] = 'IndexFunctionHooks::addIndexFunction';
1717 # Add to database
18 -$wgHooks['OutputPageParserOutput'][] = 'IndexFunctionHooks::doIndexes';
 18+$wgHooks['OutputPageParserOutput'][] = 'IndexFunctionHooks::doIndexes';
1919 # Make links to indexes blue
20 -$wgHooks['LinkEnd'][] = 'IndexFunctionHooks::blueLinkIndexes';
 20+$wgHooks['LinkEnd'][] = 'IndexFunctionHooks::blueLinkIndexes';
2121 # Make links to indexes redirect
2222 $wgHooks['InitializeArticleMaybeRedirect'][] = 'IndexFunctionHooks::doRedirect';
2323 # Make "go" searches for indexes redirect
@@ -53,9 +53,10 @@
5454 * Can be 1 of 2 options:
5555 * 'extract' (default) - Show an extract from the start of the article
5656 * 'categories' - Show a comma-separated list of categories the article is in
57 -*/
 57+ */
5858 $wgSpecialIndexContext = 'extract';
5959
 60+// @todo FIXME: put these methods in a separate class and file.
6061 function efIndexSetup( &$parser ) {
6162 $parser->setFunctionHook( 'index-func', array( 'IndexFunctionHooks', 'indexRender' ) );
6263 return true;
@@ -69,9 +70,12 @@
7071 $updater->addExtensionUpdate( array( 'addTable', 'indexes',
7172 dirname( __FILE__ ) . '/indexes.sql', true ) );
7273 }
 74+
7375 return true;
7476 }
 77+
7578 function efParserTestTables( &$tables ) {
7679 $tables[] = 'indexes';
 80+
7781 return true;
7882 }
Index: trunk/extensions/IndexFunction/specialindex.js
@@ -13,12 +13,12 @@
1414 '}'+
1515 '#use-js-note {'+
1616 ' display: block !important;'+
17 - '}'
 17+ '}'
1818 );
1919
2020 /*
2121 * Switch details between hidden/shown
22 -*/
 22+ */
2323 function toggleVisibility(idNumber) {
2424 var openarrow = document.getElementById("mw-index-open-"+idNumber);
2525 var closearrow = document.getElementById("mw-index-close-"+idNumber);
Index: trunk/extensions/IndexFunction/IndexAbstracts.php
@@ -3,8 +3,7 @@
44 /*
55 * Class to extract the first bit of text from an article
66 * Adapted from the OpenSearchXML extension, by Brion Vibber
7 -*/
8 -
 7+ */
98 class IndexAbstracts {
109 /**
1110 * Strip markup to show plaintext
@@ -14,14 +13,14 @@
1514 */
1615 function _stripMarkup( $text ) {
1716 global $wgContLang;
18 -
 17+
1918 $text = substr( $text, 0, 4096 ); // don't bother with long text...
20 -
 19+
2120 $text = str_replace( "'''", "", $text );
2221 $text = str_replace( "''", "", $text );
23 -
 22+
2423 $text = preg_replace( '#__[a-z0-9_]+__#i', '', $text ); // magic words
25 -
 24+
2625 $cleanChar = "[^|\[\]]";
2726 $subLink = "\[\[$cleanChar*(?:\|$cleanChar*)*\]\]";
2827 $pipeContents = "(?:$cleanChar|$subLink)*";
@@ -32,7 +31,7 @@
3332 (?:\|$pipeContents)*
3433 \]\]
3534 #six", array( $this, '_stripLink' ), $text );
36 -
 35+
3736 $protocols = wfUrlProtocols();
3837 $text = preg_replace( '#\\[(?:$protocols).*? (.*?)\\]#s', '$1', $text ); // URL links
3938 $text = preg_replace( '#</?[a-z0-9]+.*?>#s', '', $text ); // HTML-style tags
@@ -40,21 +39,24 @@
4140
4241 $text = preg_replace( '#^:.*$#m', '', $text ); // indented lines near start are usually disambigs or notices
4342 $text = Sanitizer::decodeCharReferences( $text );
 43+
4444 return trim( $text );
4545 }
46 -
 46+
4747 function _stripLink( $matches ) {
4848 $target = trim( $matches[1] );
49 - if( isset( $matches[2] ) ) {
 49+
 50+ if ( isset( $matches[2] ) ) {
5051 $text = trim( $matches[2] );
5152 } else {
5253 $text = $target;
5354 }
54 -
 55+
5556 $title = Title::newFromText( $target );
56 - if( $title ) {
 57+
 58+ if ( $title ) {
5759 $ns = $title->getNamespace();
58 - if( $title->getInterwiki() || $ns == NS_IMAGE || $ns == NS_CATEGORY ) {
 60+ if ( $title->getInterwiki() || $ns == NS_IMAGE || $ns == NS_CATEGORY ) {
5961 return "";
6062 } else {
6163 return $text;
@@ -63,7 +65,7 @@
6466 return $matches[0];
6567 }
6668 }
67 -
 69+
6870 /**
6971 * Extract the first two sentences, if detectable, from the text.
7072 * @param string $text
@@ -77,63 +79,69 @@
7880 '.', '!', '?', // double-width roman forms
7981 '。', // half-width ideographic full stop
8082 );
81 -
 83+
8284 $endgroup = implode( '|', $endchars );
8385 $end = "(?:$endgroup)";
8486 $sentence = ".*?$end+";
8587 $firstone = "/^($sentence)/u";
86 - if( preg_match( $firstone, $text, $matches ) ) {
 88+
 89+ if ( preg_match( $firstone, $text, $matches ) ) {
8790 return $matches[1];
8891 } else {
8992 // Just return the first line
9093 $lines = explode( "\n", $text );
 94+
9195 return trim( $lines[0] );
9296 }
9397 }
94 -
95 - public function getExtract( $title, $chars=50 ) {
 98+
 99+ public function getExtract( $title, $chars = 50 ) {
96100 $rev = Revision::newFromTitle( $title );
97 - if( $rev ) {
 101+
 102+ if ( $rev ) {
98103 $text = substr( $rev->getText(), 0, 16384 );
99 -
 104+
100105 // Ok, first note this is a TERRIBLE HACK. :D
101106 //
102107 // First, we use the system preprocessor to break down the text
103108 // into text, templates, extensions, and comments:
104109 global $wgParser;
 110+
105111 $wgParser->mOptions = new ParserOptions();
106112 $wgParser->clearState();
 113+
107114 $frame = $wgParser->getPreprocessor()->newFrame();
108115 $dom = $wgParser->preprocessToDom( $text );
109 -
 116+
110117 $imageArgs = array(
111118 'image',
112119 'image_skyline',
113120 'img',
114121 'Img',
115122 );
116 -
 123+
117124 // Now, we strip out everything that's not text.
118125 // This works with both DOM and Hash parsers, but feels fragile.
119126 $node = $dom->getFirstChild();
120127 $out = '';
121 - while( $node ) {
122 - if( $node->getName() == '#text' ) {
 128+
 129+ while ( $node ) {
 130+ if ( $node->getName() == '#text' ) {
123131 $out .= $frame->expand( $node, PPFrame::RECOVER_ORIG );
124132 }
125133 $node = $node->getNextSibling();
126134 }
127 -
 135+
128136 // The remaining text may still contain wiki and HTML markup.
129137 // We'll use our shitty hand parser to strip most of those from
130138 // the beginning of the text.
131139 $stripped = $this->_stripMarkup( $out );
132 -
 140+
133141 // And now, we'll grab just the first sentence as text, and
134142 // also try to rip out a badge image.
135143 return $this->_extractStart( $stripped );
136144 }
 145+
137146 return '';
138147 }
139 -
140148 }
Index: trunk/extensions/IndexFunction/indexes.sql
@@ -1,7 +1,7 @@
22 CREATE TABLE /*$wgDBprefix*/indexes (
33 -- The pageid of the page containing the parser function
44 in_from int unsigned NOT NULL default 0,
5 -
 5+
66 -- The NS/title that should redirect to the page
77 in_namespace int NOT NULL default 0,
88 in_title varchar(255) binary NOT NULL default '',
Index: trunk/extensions/IndexFunction/SpecialIndex.php
@@ -1,19 +1,19 @@
22 <?php
33
44 class SpecialIndexPager extends AlphabeticPager {
5 -
65 public $mSearchTitle;
76 private $mJSid = 0;
87
98 function __construct( $search ) {
109 $this->mSearchTitle = $search;
11 - parent::__construct();
 10+ parent::__construct();
1211 // This can potentially be a lot of data, set a lower max limit
1312 $this->mLimit = $this->mLimit > 1000 ? 1000 : $this->mLimit;
1413 }
1514
1615 function formatRow( $row ) {
1716 $sk = $this->getSkin();
 17+
1818 if ( $row->type == 'page' ) {
1919 $title = Title::makeTitle( $row->ns, $row->title );
2020 $ret = Xml::openElement( 'tr' );
@@ -23,52 +23,62 @@
2424 $ret .= Xml::tags( 'td', null, $link );
2525 $ret .= Xml::tags( 'td', null, '&#160;' );
2626 $ret .= Xml::closeElement( 'tr' );
 27+
2728 return $ret;
2829 } else {
2930 $ret = Xml::openElement( 'tr' );
3031 $targettitle = Title::makeTitle( $row->ns, $row->title );
3132 $title = SpecialPage::getTitleFor( 'Index', $row->title );
32 - $link = $sk->link( $title, $targettitle->getPrefixedText(), array( 'class'=>'mw-index' ), array(), array( 'known', 'noclasses' ) );
33 -
 33+ $link = $sk->link( $title, $targettitle->getPrefixedText(), array( 'class' => 'mw-index' ), array(), array( 'known', 'noclasses' ) );
 34+
3435 $jsid = $this->mJSid;
3536 $expandTitle = wfMsgHtml( 'index-expand-detail' );
3637 $closeTitle = wfMsgHtml( 'index-hide-detail' );
3738 $toggleLink = "onclick='toggleVisibility($jsid); return false'";
3839 $tl = "<span id='mw-index-open-$jsid' class='mw-index-expanded' style='visibility:hidden' ><a href='#' $toggleLink title='$expandTitle'>" . $this->sideArrow() . "</a></span>";
3940 $tl .= "<span id='mw-index-close-$jsid' class='mw-index-hidden' style='display:none'><a href='#' $toggleLink title='$closeTitle'>" . $this->downArrow() . "</a></span>";
40 -
 41+
4142 $ret .= Xml::tags( 'td', array( 'style' => 'vertical-align:top' ), $tl . '&nbsp' );
4243 $ret .= Xml::tags( 'td', array( 'style' => 'vertical-align:top' ), $link );
4344 $ret .= Xml::openElement( 'td' );
44 - $ret .= Xml::openElement( 'ul',
45 - array( 'style' => 'margin-top:1em', 'class'=>'mw-index-hidden', 'id'=>"mw-index-inner-$jsid" )
46 - );
 45+ $ret .= Xml::openElement( 'ul',
 46+ array( 'style' => 'margin-top:1em', 'class' => 'mw-index-hidden', 'id' => "mw-index-inner-$jsid" )
 47+ );
 48+
4749 $pages = explode( '|', $row->extra );
48 - foreach( $pages as $page ) {
 50+
 51+ foreach ( $pages as $page ) {
4952 $bits = explode( ':', $page, 2 );
5053 $t = Title::makeTitle( $bits[0], $bits[1] );
5154 $ln = $sk->link( $t, null, array(), array(), array( 'known', 'noclasses' ) );
52 - $ret .= Xml::tags( 'li', null, $ln );
 55+ $ret .= Xml::tags( 'li', null, $ln );
5356 }
 57+
5458 $ret .= Xml::closeElement( 'ul' );
5559 $ret .= Xml::closeElement( 'td' );
5660 $ret .= Xml::closeElement( 'tr' );
 61+
5762 $this->mJSid++;
58 - return $ret;
 63+
 64+ return $ret;
5965 }
6066 }
61 -
62 - protected function arrow( $dir, $alt='', $title='' ) {
 67+
 68+ protected function arrow( $dir, $alt = '', $title = '' ) {
6369 global $wgStylePath;
 70+
6471 $encUrl = htmlspecialchars( $wgStylePath . '/common/images/Arr_' . $dir . '.png' );
6572 $encAlt = htmlspecialchars( $alt );
6673 $encTitle = htmlspecialchars( $title );
 74+
6775 return "<img src=\"$encUrl\" width=\"12\" height=\"12\" alt=\"$encAlt\" title=\"$encTitle\" />";
6876 }
6977
7078 protected function sideArrow() {
7179 global $wgContLang;
 80+
7281 $dir = $wgContLang->isRTL() ? 'l' : 'r';
 82+
7383 return $this->arrow( $dir, '+', wfMsg( 'index-expand-detail' ) );
7484 }
7585
@@ -80,250 +90,277 @@
8191 return $this->arrow( '', codepointToUtf8( 0xa0 ) ); // non-breaking space
8292 }
8393
84 -
85 -
8694 // Since we're overriding reallyDoQuery, we don't really need this
8795 // its easier to just do it all in one function
8896 function getQueryInfo() { }
89 -
 97+
9098 function getIndexField() {
91 - return 'title';
 99+ return 'title';
92100 }
93 -
 101+
94102 function getEmptyBody() {
95 - return "<tr><td class='errorbox'>" . wfMsgHtml( 'index-no-results' ) ."</td></tr>";
 103+ return "<tr><td class='errorbox'>" . wfMsgHtml( 'index-no-results' ) . "</td></tr>";
96104 }
97 -
 105+
98106 // Need to override reallyDoQuery() to do the UNION
99 - function reallyDoQuery( $offset, $limit, $descending ) {
 107+ function reallyDoQuery( $offset, $limit, $descending ) {
100108 $limit = ' LIMIT ' . intval( $limit );
101 - $order = " ORDER BY {$this->mIndexField}";
 109+ $order = " ORDER BY {$this->mIndexField}";
 110+
102111 if ( $descending ) {
103112 $operator = '>';
104113 } else {
105114 $order .= ' DESC';
106115 $operator = '<';
107 - }
108 -
 116+ }
 117+
109118 $pageconds = array();
110119 $indexconds = array();
 120+
111121 if ( $offset != '' ) {
112122 $pageconds[] = 'page_title' . $operator . $this->mDb->addQuotes( $offset );
113123 $indexconds[] = 'in_title' . $operator . $this->mDb->addQuotes( $offset );
114 - }
 124+ }
 125+
115126 $ns = $this->mSearchTitle->getNamespace();
116127
117128 $like = $this->mDb->buildLike( $this->mSearchTitle->getDBkey(), $this->mDb->anyString() );
118 -
 129+
119130 $pageconds[] = "page_namespace = $ns";
120131 $pageconds[] = "page_title " . $like;
121132 $indexconds[] = "in_namespace = $ns";
122133 $indexconds[] = "in_title " . $like;
123 -
124 -
125 - $pagequery = $this->mDb->selectSQLText( 'page',
 134+
 135+ $pagequery = $this->mDb->selectSQLText( 'page',
126136 "page_title AS title, page_namespace AS ns, 'page' AS type, NULL AS extra",
127137 $pageconds,
128138 ''
129139 );
130 - $indexquery = $this->mDb->selectSQLText( array('indexes', 'page'),
131 - "in_title AS title, in_namespace AS ns, 'index' AS type,
 140+
 141+ $indexquery = $this->mDb->selectSQLText( array( 'indexes', 'page' ),
 142+ "in_title AS title, in_namespace AS ns, 'index' AS type,
132143 GROUP_CONCAT(page_namespace,':',page_title SEPARATOR '|') AS extra",
133144 $indexconds,
134145 '',
135146 array( 'GROUP BY' => 'in_namespace, in_title' ),
136 - array( 'page' => array('JOIN','page_id=in_from') )
 147+ array( 'page' => array( 'JOIN', 'page_id=in_from' ) )
137148 );
138 -
 149+
139150 $union = $this->mDb->unionQueries( array( $pagequery, $indexquery ), false );
140 - $union .= $order . $limit;
 151+ $union .= $order . $limit;
141152
142153 $res = $this->mDb->query( $union, __METHOD__ );
143154 return new ResultWrapper( $this->mDb, $res );
144155 }
145 -
146156 }
147157
148158 class SpecialIndex extends SpecialPage {
149159 function __construct() {
150 -
151160 parent::__construct( 'Index' );
152161 }
153 -
154 - function execute( $par ) {
155 -
 162+
 163+ function execute( $par ) {
 164+
156165 $this->setHeaders();
157 - if ($par) {
 166+ if ( $par ) {
158167 $t1 = Title::newFromText( $par );
159168 $this->showDabPage( $t1 );
160 - } else {
161 - $this->showSearchForm();
 169+ } else {
 170+ $this->showSearchForm();
162171 }
 172+ }
163173
164 - }
165 -
166174 function showSearchForm() {
167175 global $wgOut, $wgRequest, $wgScript, $wgExtensionAssetsPath;
168176 $search = $wgRequest->getText( 'searchtext' );
169177 $wgOut->addScriptFile( "$wgExtensionAssetsPath/IndexFunction/specialindex.js" );
170178 $wgOut->addWikiMsg( 'index-search-explain' );
171 - $form = Xml::openElement( 'fieldset', array( 'style'=>'line-height:200%' ) ) .
172 - Xml::element( 'legend', array(), wfMsgHtml( 'index-legend' ) ) .
173 - Xml::openElement( 'form', array( 'method'=>'GET', 'action'=>$wgScript ) ) .
 179+ $form = Xml::openElement( 'fieldset', array( 'style' => 'line-height:200%' ) ) .
 180+ Xml::element( 'legend', array(), wfMsgHtml( 'index-legend' ) ) .
 181+ Xml::openElement( 'form', array( 'method' => 'GET', 'action' => $wgScript ) ) .
174182 Html::Hidden( 'title', $this->getTitle()->getPrefixedDbKey() ) .
175183
176184 Xml::label( wfMsg( 'index-search' ), 'mw-index-searchtext' ) .
177 - Xml::input( 'searchtext', 100, $search, array( 'id' => 'mw-index-searchtext' ) ) .
178 - '<br />' .
 185+ Xml::input( 'searchtext', 100, $search, array( 'id' => 'mw-index-searchtext' ) ) .
 186+ '<br />' .
179187 Xml::submitButton( wfMsg( 'index-submit' ) ) .
180188
181 - Xml::closeElement( 'form' ) .
182 - Xml::closeElement( 'fieldset' );
 189+ Xml::closeElement( 'form' ) .
 190+ Xml::closeElement( 'fieldset' );
183191
184192 $wgOut->addHTML( $form );
185 -
 193+
186194 $t = Title::newFromText( $search );
187 -
188 - if ( !is_null( $t) ) {
 195+
 196+ if ( !is_null( $t ) ) {
189197 $t = Title::newFromText( $wgRequest->getVal( 'searchtext' ) );
190198 $pager = new SpecialIndexPager( $t );
191 - $out = Xml::openElement( 'div', array( 'id'=>'mw-index-searchresults' ) ) .
 199+ $out = Xml::openElement( 'div', array( 'id' => 'mw-index-searchresults' ) ) .
192200 '<div id="use-js-note" style="display:none">' . wfMsgExt( 'index-details-explain' , array( 'parse' ) ) . '</div>' .
193201 $pager->getNavigationBar() .
194 - Xml::openElement( 'table' ) .
195 - $pager->getBody() .
 202+ Xml::openElement( 'table' ) .
 203+ $pager->getBody() .
196204 Xml::closeElement( 'table' ) .
197205 $pager->getNavigationBar() .
198206 Xml::closeElement( 'div' );
199207 $wgOut->addHtml( $out );
200 -
 208+
201209 }
202 -
203210 }
204 -
 211+
205212 function showDabPage( Title $t1 ) {
206213 global $wgOut, $wgUser, $wgSpecialIndexContext;
207214 $sk = $wgUser->getSkin();
208215 $wgOut->setPagetitle( $t1->getPrefixedText() );
209216 $dbr = wfGetDB( DB_SLAVE );
210 - $pages = $dbr->select( array('page', 'indexes'),
 217+ $pages = $dbr->select( array( 'page', 'indexes' ),
211218 array( 'page_id', 'page_namespace', 'page_title' ),
212 - array( 'in_namespace'=>$t1->getNamespace(), 'in_title'=>$t1->getDBkey() ),
213 - __METHOD__,
214 - array('ORDER BY'=> 'page_namespace, page_title'),
215 - array( 'indexes' => array('JOIN', 'in_from=page_id') )
 219+ array( 'in_namespace' => $t1->getNamespace(), 'in_title' => $t1->getDBkey() ),
 220+ __METHOD__,
 221+ array( 'ORDER BY' => 'page_namespace, page_title' ),
 222+ array( 'indexes' => array( 'JOIN', 'in_from=page_id' ) )
216223 );
217 -
 224+
218225 $list = array();
219 - foreach( $pages as $row ) {
 226+
 227+ foreach ( $pages as $row ) {
220228 $t = Title::newFromRow( $row );
221 - $list[strval($row->page_id)] = array( 'title' => $t, 'cats' => array() );
 229+ $list[strval( $row->page_id )] = array( 'title' => $t, 'cats' => array() );
222230 }
223 - if (count($list) == 0) {
 231+
 232+ if ( count( $list ) == 0 ) {
224233 $wgOut->addWikiMsg( 'index-emptylist', $t1->getPrefixedText() );
 234+
225235 return;
226 - } elseif (count($list) == 1) {
 236+ } elseif ( count( $list ) == 1 ) {
227237 $target = reset( $list );
228238 $wgOut->redirect( $target['title']->getLocalURL() );
229 - }
 239+ }
 240+
230241 $wgOut->addWikiMsg( 'index-disambig-start', $t1->getPrefixedText() );
231242 $keys = array_keys( $list );
232 - $set = '(' . implode(',', $keys) . ')';
233 -
234 - $exclude = wfMsg('index-exclude-categories');
 243+ $set = '(' . implode( ',', $keys ) . ')';
 244+
 245+ $exclude = wfMsg( 'index-exclude-categories' );
235246 $excludecats = array();
236 - if ($exclude) {
 247+
 248+ if ( $exclude ) {
237249 $exclude = explode( '\n', $exclude );
238 - foreach( $exclude as $cat ) {
239 - if (!$cat) {
 250+
 251+ foreach ( $exclude as $cat ) {
 252+ if ( !$cat ) {
240253 continue;
241254 }
 255+
242256 $cat = Title::newFromText( $cat, NS_CATEGORY );
243 - if ( !is_null($cat) ) {
 257+
 258+ if ( !is_null( $cat ) ) {
244259 $excludecats[] = $dbr->addQuotes( $cat->getDBkey() );
245260 }
246261 }
247 - $excludecats = 'AND cl_to NOT IN (' . implode(',', $excludecats) . ')';
 262+
 263+ $excludecats = 'AND cl_to NOT IN (' . implode( ',', $excludecats ) . ')';
248264 } else {
249265 $excludecats = '';
250266 }
251 -
 267+
252268 $categories = $dbr->select( 'categorylinks',
253 - array('cl_from', 'cl_to'),
 269+ array( 'cl_from', 'cl_to' ),
254270 "cl_from IN $set $excludecats",
255271 __METHOD__,
256 - array('ORDER BY' => 'cl_from')
 272+ array( 'ORDER BY' => 'cl_from' )
257273 );
 274+
258275 $groups = array();
259276 $catlist = array();
260 - foreach( $categories as $row ) {
 277+
 278+ foreach ( $categories as $row ) {
261279 $ct = Title::newFromText( $row->cl_to, NS_CATEGORY );
262280 $textform = $ct->getText();
263 - $list[strval($row->cl_from)]['cats'][] = $textform;
 281+ $list[strval( $row->cl_from )]['cats'][] = $textform;
 282+
264283 if ( array_key_exists( $textform, $catlist ) ) {
265 - $catlist[$textform][] = strval($row->cl_from);
 284+ $catlist[$textform][] = strval( $row->cl_from );
266285 } else {
267 - $catlist[$textform] = array ( strval($row->cl_from) );
 286+ $catlist[$textform] = array ( strval( $row->cl_from ) );
268287 }
269288 }
270 - if (count($catlist) > 2) {
271 - while (true) {
272 - arsort($catlist);
 289+
 290+ if ( count( $catlist ) > 2 ) {
 291+ while ( true ) {
 292+ arsort( $catlist );
273293 $group = reset( $catlist );
274 - if (count($group) == 0) {
 294+
 295+ if ( count( $group ) == 0 ) {
275296 break;
276297 }
277 - $keys = array_keys($catlist, $group);
 298+
 299+ $keys = array_keys( $catlist, $group );
278300 $heading = $keys[0];
279 - $grouphtml = Xml::element('h2', null, $heading);
 301+ $grouphtml = Xml::element( 'h2', null, $heading );
280302 $grouphtml .= Xml::openElement( 'ul' );
281 - foreach( $group as $pageid ) {
 303+
 304+ foreach ( $group as $pageid ) {
282305 $t = $list[$pageid]['title'];
283 - $cats = $list[$pageid]['cats'];
284 - $grouphtml .= $this->makeContextLine( $t, $cats );
 306+ $cats = $list[$pageid]['cats'];
 307+ $grouphtml .= $this->makeContextLine( $t, $cats );
 308+
285309 unset( $list[$pageid] );
286 - ksort($list);
287 - foreach($catlist as $remaining) {
 310+ ksort( $list );
 311+
 312+ foreach ( $catlist as $remaining ) {
288313 $key = array_search( $pageid, $remaining );
 314+
289315 if ( $key !== false ) {
290 - $masterkeys = array_keys($catlist, $remaining);
 316+ $masterkeys = array_keys( $catlist, $remaining );
291317 $heading = $masterkeys[0];
292 - unset($catlist[$heading][$key]);
293 - sort($catlist[$heading]);
 318+ unset( $catlist[$heading][$key] );
 319+ sort( $catlist[$heading] );
294320 }
295321 }
296322 }
 323+
297324 $grouphtml .= Xml::closeElement( 'ul' );
298325 $groups[] = $grouphtml;
 326+
299327 unset( $catlist[$heading] );
300 - if (count($catlist) == 0) {
 328+
 329+ if ( count( $catlist ) == 0 ) {
301330 break;
302 - }
 331+ }
303332 }
304 - if (count($list) != 0) { //Pages w/ no cats
 333+
 334+ if ( count( $list ) != 0 ) { // Pages w/ no cats
305335 $grouphtml = Xml::openElement( 'ul' );
306 - foreach( $list as $pageid => $info ) {
 336+
 337+ foreach ( $list as $pageid => $info ) {
307338 $grouphtml .= $this->makeContextLine( $info['title'], array() );
308339 }
309 - $grouphtml .= Xml::closeElement('ul');
310 - $groups = array_merge( array($grouphtml), $groups);
 340+
 341+ $grouphtml .= Xml::closeElement( 'ul' );
 342+ $groups = array_merge( array( $grouphtml ), $groups );
311343 }
 344+
312345 $out = implode( "\n", $groups );
313346 } else {
314347 $out = Xml::openElement( 'ul' );
315 - foreach( $list as $pageid => $info ) {
 348+
 349+ foreach ( $list as $pageid => $info ) {
316350 $out .= $this->makeContextLine( $info['title'], $info['cats'] );
317351 }
318 - $out .= Xml::closeElement('ul');
 352+
 353+ $out .= Xml::closeElement( 'ul' );
319354 }
320 -
321 - $wgOut->addHtml($out);
 355+
 356+ $wgOut->addHtml( $out );
322357 }
323 -
 358+
324359 private function makeContextLine( $title, $cats ) {
325360 global $wgUser, $wgSpecialIndexContext;
 361+
326362 $sk = $wgUser->getSkin();
327363 $link = $sk->link( $title, null, array(), array(), array( 'known', 'noclasses' ) );
 364+
328365 if ( $wgSpecialIndexContext == 'extract' ) {
329366 $extracter = new IndexAbstracts();
330367 $text = $extracter->getExtract( $title );
@@ -337,6 +374,7 @@
338375 } else {
339376 $line = $link;
340377 }
 378+
341379 $line = Xml::tags( 'li', array(), $line );
342380 } elseif ( $wgSpecialIndexContext == 'categories' ) {
343381 if ( $cats ) {
@@ -350,6 +388,4 @@
351389 }
352390 return $line;
353391 }
354 -
355392 }
356 -

Status & tagging log