r65346 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r65345‎ | r65346 | r65347 >
Date:22:00, 20 April 2010
Author:siebrand
Status:ok
Tags:
Comment:
* stylize.php, trailing whitespace removed, indentation updated
* removed CategoryTree::init(). Loading messages explicitly is no longer needed
* removed commented out code bits.
Modified paths:
  • /trunk/extensions/CategoryTree/CategoryPageSubclass.php (modified) (history)
  • /trunk/extensions/CategoryTree/CategoryTree.css (modified) (history)
  • /trunk/extensions/CategoryTree/CategoryTree.i18n.php (modified) (history)
  • /trunk/extensions/CategoryTree/CategoryTree.js (modified) (history)
  • /trunk/extensions/CategoryTree/CategoryTree.php (modified) (history)
  • /trunk/extensions/CategoryTree/CategoryTreeFunctions.php (modified) (history)
  • /trunk/extensions/CategoryTree/CategoryTreePage.php (modified) (history)
  • /trunk/extensions/CategoryTree/README (modified) (history)

Diff [purge]

Index: trunk/extensions/CategoryTree/CategoryPageSubclass.php
@@ -3,6 +3,7 @@
44 class CategoryTreeCategoryPage extends CategoryPage {
55 function closeShowCategory() {
66 global $wgOut, $wgRequest;
 7+
78 $from = $wgRequest->getVal( 'from' );
89 $until = $wgRequest->getVal( 'until' );
910
@@ -17,7 +18,7 @@
1819 function getCategoryTree() {
1920 global $wgOut, $wgCategoryTreeCategoryPageOptions, $wgCategoryTreeForceHeaders;
2021
21 - if ( ! isset($this->categorytree) ) {
 22+ if ( ! isset( $this->categorytree ) ) {
2223 if ( !$wgCategoryTreeForceHeaders ) CategoryTree::setHeaders( $wgOut );
2324
2425 $this->categorytree = new CategoryTree( $wgCategoryTreeCategoryPageOptions );
@@ -38,11 +39,6 @@
3940 return parent::addSubcategoryObject( $cat, $sortkey, $pageLength );
4041 }
4142
42 - /*if ( ! $GLOBALS['wgCategoryTreeUnifiedView'] ) {
43 - $this->child_cats[] = $cat;
44 - return parent::addSubcategory( $cat, $sortkey, $pageLength );
45 - }*/
46 -
4743 $tree = $this->getCategoryTree();
4844
4945 $this->children[] = $tree->renderNodeInfo( $title, $cat );
@@ -56,7 +52,7 @@
5753 }
5854
5955 function finaliseCategoryState() {
60 - if( $this->flip ) {
 56+ if ( $this->flip ) {
6157 $this->child_cats = array_reverse( $this->child_cats );
6258 }
6359 parent::finaliseCategoryState();
Index: trunk/extensions/CategoryTree/CategoryTreePage.php
@@ -9,13 +9,12 @@
1010 * @license GNU General Public Licence 2.0 or later
1111 */
1212
13 -if( !defined( 'MEDIAWIKI' ) ) {
 13+if ( !defined( 'MEDIAWIKI' ) ) {
1414 echo( "This file is part of an extension to the MediaWiki software and cannot be used standalone.\n" );
1515 die( 1 );
1616 }
1717
1818 class CategoryTreePage extends SpecialPage {
19 -
2019 var $target = '';
2120 var $tree = null;
2221
@@ -45,11 +44,11 @@
4645 $this->setHeaders();
4746
4847 if ( $par ) $this->target = $par;
49 - else $this->target = $wgRequest->getVal( 'target', wfMsg( 'rootcategory') );
 48+ else $this->target = $wgRequest->getVal( 'target', wfMsg( 'rootcategory' ) );
5049
5150 $this->target = trim( $this->target );
5251
53 - #HACK for undefined root category
 52+ # HACK for undefined root category
5453 if ( $this->target == '<rootcategory>' || $this->target == '&lt;rootcategory&gt;' ) $this->target = null;
5554
5655 $options = array();
@@ -68,7 +67,7 @@
6968
7069 $this->executeInputForm();
7170
72 - if( $this->target !== '' && $this->target !== null ) {
 71+ if ( $this->target !== '' && $this->target !== null ) {
7372 if ( !$wgCategoryTreeForceHeaders ) CategoryTree::setHeaders( $wgOut );
7473
7574 $title = CategoryTree::makeTitle( $this->target );
@@ -98,7 +97,6 @@
9998 $wgOut->addHTML( Xml::closeElement( 'div' ) );
10099 }
101100 }
102 -
103101 }
104102
105103 /**
@@ -107,7 +105,7 @@
108106 function executeInputForm() {
109107 global $wgScript, $wgOut;
110108 $thisTitle = Title::makeTitle( NS_SPECIAL, $this->getName() );
111 - $mode = $this->getOption('mode');
 109+ $mode = $this->getOption( 'mode' );
112110
113111 $wgOut->addHTML( Xml::openElement( 'form', array( 'name' => 'categorytree', 'method' => 'get', 'action' => $wgScript, 'id' => 'mw-categorytree-form' ) ) );
114112 $wgOut->addHTML( Xml::openElement( 'fieldset' ) );
Index: trunk/extensions/CategoryTree/CategoryTree.i18n.php
@@ -82,12 +82,12 @@
8383 {{Identical|All pages}}',
8484 'categorytree-collapse' => 'Tooltip for the "collapse" button',
8585 'categorytree-expand' => 'Tooltip for the "expand" button',
86 - 'categorytree-member-counts' => 'Tooltip showing a detailed summary of subcategory member counts. Parameters:
87 -* $1 = number of subcategories,
88 -* $2 = number of pages (without subcategories and files),
89 -* $3 = number of files,
90 -* $4 = total number of members,
91 -* $5 = members to be shown in the tree, depending on mode.
 86+ 'categorytree-member-counts' => 'Tooltip showing a detailed summary of subcategory member counts. Parameters:
 87+* $1 = number of subcategories,
 88+* $2 = number of pages (without subcategories and files),
 89+* $3 = number of files,
 90+* $4 = total number of members,
 91+* $5 = members to be shown in the tree, depending on mode.
9292 Use with { {PLURAL} }',
9393 'categorytree-load' => '{{Identical|Load}}
9494
@@ -143,7 +143,7 @@
144144 'categorytree' => 'የመደቦች ዛፍ',
145145 'categorytree-portlet' => 'መደቦች',
146146 'categorytree-legend' => 'የመደቦች ዛፍ ለማየት',
147 - 'categorytree-header' => "[+] ተጭነው ንዑሱ-መደብ ይዘረጋል፣ [-] ተጭነው ደግሞ ይመልሳል።
 147+ 'categorytree-header' => "[+] ተጭነው ንዑሱ-መደብ ይዘረጋል፣ [-] ተጭነው ደግሞ ይመልሳል።
148148
149149 በግራ በኩል ባለው ሳጥን ውስጥ የመደቡን ስም ዝም ብለው መጻፍ ይችላሉ። (የዚሁ ዊኪ መደብ ስሞች ለመመልከት፣ [[Special:Mostlinkedcategories|እዚህ ይጫኑ]]።) ከዚያ፥ ምን ያሕል ንዑስ-መደቦች እንዳሉበት ለማየት «ዛፉ ይታይ» የሚለውን ይጫኑ። በቀኝ በኩል ካለው ሳጥን 'all pages' ከመረጡ፥ በየመደቡ ውስጥ ያሉት መጣጥፎች በተጨማሪ ይታያሉ።
150150
@@ -516,7 +516,7 @@
517517 'categorytree-portlet' => 'Rummadoù',
518518 'categorytree-legend' => 'Gwelet gwezennadur ar rummad',
519519 'categorytree-desc' => 'Furchal a ra ent dinamek [[Special:CategoryTree|framm ar rummadoù]]',
520 - 'categorytree-header' => "Merkit anv ur rummad evit gwelet petra zo ennañ e stumm ur gwezennadur.
 520+ 'categorytree-header' => "Merkit anv ur rummad evit gwelet petra zo ennañ e stumm ur gwezennadur.
521521 Notit e rankit kaout an arc'hwelioù JavaScript araokaet anvet AJAX.
522522 M'eo kozh-mat stumm ho merdeer pe m'eo diweredekaet JavaScript ganeoc'h, ne'z aio ket en-dro.",
523523 'categorytree-category' => 'Rummad :',
@@ -693,8 +693,8 @@
694694 'categorytree-portlet' => 'Categorïau',
695695 'categorytree-legend' => 'Dangos y goeden gategori',
696696 'categorytree-desc' => "Teclyn AJAX yn arddangos [[Special:CategoryTree|adeiledd categorïau]]'r wici",
697 - 'categorytree-header' => "Teipiwch enw categori yn y blwch er mwyn gweld ei gynnwys ar lun coeden.
698 -Sylwer bod yn rhaid defnyddio offer uwch Sgript Java o'r enw AJAX er mwyn gwneud hyn.
 697+ 'categorytree-header' => "Teipiwch enw categori yn y blwch er mwyn gweld ei gynnwys ar lun coeden.
 698+Sylwer bod yn rhaid defnyddio offer uwch Sgript Java o'r enw AJAX er mwyn gwneud hyn.
699699 Ni lwydda'r gofyniad os yw'ch porwr yn hen iawn neu os nad yw Sgript Java wedi ei alluogi.",
700700 'categorytree-category' => 'Categori:',
701701 'categorytree-go' => 'Dangos y Goeden',
@@ -2137,7 +2137,7 @@
21382138 'categorytree-legend' => 'Weis Kategoriestruktur',
21392139 'categorytree-desc' => "Gadget deen op Ajax opgebaut ass fir d'[[Special:CategoryTree|Kategorie-Struktur]] vun enger Wiki duerzestellen",
21402140 'categorytree-header' => 'Gitt den Numm vun enger Kategorie an, fir hiren Inhalt als Bam-Struktur ze gesinn.
2141 -Bedenkt, datt dës Fonctioun Java Script Funktioune benotzt, déi als AJAX bekannt sinn.
 2141+Bedenkt, datt dës Fonctioun Java Script Funktioune benotzt, déi als AJAX bekannt sinn.
21422142 Wann Dir ee ganz ale Browser hutt, oder wann Dir JavaScript ausgeschalt hutt, da fonktionnéiert dëst bei Iech net.',
21432143 'categorytree-category' => 'Kategorie:',
21442144 'categorytree-go' => 'Struktur weisen',
@@ -2293,8 +2293,8 @@
22942294 'categorytree-portlet' => 'Kategorijas',
22952295 'categorytree-legend' => 'Rādīt kategoriju koku',
22962296 'categorytree-desc' => "AJAX bāzēts ''gadget'', kuru lieto lai attēlotu wiki [[Special:CategoryTree|kategoriju struktūru]]",
2297 - 'categorytree-header' => 'Ievadi kategorijas nosaukumu lai apskatītos tās saturu kā koka struktūru.
2298 -Tam ir nepieciešama JavaScript (AJAX) funkcionalitāte.
 2297+ 'categorytree-header' => 'Ievadi kategorijas nosaukumu lai apskatītos tās saturu kā koka struktūru.
 2298+Tam ir nepieciešama JavaScript (AJAX) funkcionalitāte.
22992299 Ja tev ir veca interneta pārlūkprogramma, vai arī JavaScript ir atslēgts, šitas te nedarbosies.',
23002300 'categorytree-category' => 'Kategorija:',
23012301 'categorytree-go' => 'Parādīt koku',
@@ -2547,7 +2547,7 @@
25482548 'categorytree-portlet' => 'Kattegerieën',
25492549 'categorytree-legend' => 'Laot kattegerieboom zien',
25502550 'categorytree-desc' => 'Dynamische navigasie veur de [[Special:CategoryTree|kattegeriestructuur]]',
2551 - 'categorytree-header' => 'Voer een kattegerienaam in um de inhoud in boomstructuur te bekieken.
 2551+ 'categorytree-header' => 'Voer een kattegerienaam in um de inhoud in boomstructuur te bekieken.
25522552 NB: Veur disse functie he-j de [[JavaScript]]functionaliteit, AJAX neudig. A-j een hele ouwe webkieker hemmen, of je JavaScript uut-eschakeld hemmen, dan zal disse functie neet warken.',
25532553 'categorytree-category' => 'Kattegerie:',
25542554 'categorytree-go' => 'Laojen',
@@ -3646,8 +3646,8 @@
36473647 'categorytree-portlet' => 'Kategoriýalar',
36483648 'categorytree-legend' => 'Kategoriýa agajyny görkez',
36493649 'categorytree-desc' => '[[Special:CategoryTree|Kategoriýa gurluşyny]] dinamik ýagdaýda dolandyr',
3650 - 'categorytree-header' => 'Kategoriýanyň adyny ýazyp, onuň mazmunyny agaç gurluşy hökmünde görüp bilersiňiz.
3651 -Bu aýratynlyk AJAX ady bilen tanalýan ösen JavaScript bilen işleýändir.
 3650+ 'categorytree-header' => 'Kategoriýanyň adyny ýazyp, onuň mazmunyny agaç gurluşy hökmünde görüp bilersiňiz.
 3651+Bu aýratynlyk AJAX ady bilen tanalýan ösen JavaScript bilen işleýändir.
36523652 Eger brauzeriňiz köne bolsa ýa-da JavaScript ýapyk bolsa, onda ol işlemez.',
36533653 'categorytree-category' => 'Kategoriýa:',
36543654 'categorytree-go' => 'Agajy görkez',
@@ -3937,8 +3937,8 @@
39383938 'categorytree' => 'קאַטעגאריע בוים',
39393939 'categorytree-portlet' => 'קאַטעגאריעס',
39403940 'categorytree-legend' => 'ווײַזן קאַטעגאריע בוים',
3941 - 'categorytree-header' => 'לייגט אריין א קאטעגאריע נאמען צו זען איר אינהאלט אלס א בוים סטרוקטור.
3942 -באמערקט אז דאס פארלאנגט פארגעשריטענע JavaScript מעגליכקייטן, באקאנט אלס AJAX.
 3941+ 'categorytree-header' => 'לייגט אריין א קאטעגאריע נאמען צו זען איר אינהאלט אלס א בוים סטרוקטור.
 3942+באמערקט אז דאס פארלאנגט פארגעשריטענע JavaScript מעגליכקייטן, באקאנט אלס AJAX.
39433943 אויב איר ניצט אן אלטן בלעטערער, אדער איר ערלויבט נישט קיין JavaScript, וועט דאס נישט ווירקן.',
39443944 'categorytree-category' => 'קאטעגאריע:',
39453945 'categorytree-go' => 'ווײַזן בוים',
Index: trunk/extensions/CategoryTree/CategoryTree.php
@@ -1,5 +1,4 @@
22 <?php
3 -
43 /**
54 * Setup and Hooks for the CategoryTree extension, an AJAX based gadget
65 * to display the category structure of a wiki
@@ -10,7 +9,7 @@
1110 * @license GNU General Public Licence 2.0 or later
1211 */
1312
14 -if( !defined( 'MEDIAWIKI' ) ) {
 13+if ( !defined( 'MEDIAWIKI' ) ) {
1514 echo( "This file is an extension to the MediaWiki software and cannot be used standalone.\n" );
1615 die( 1 );
1716 }
@@ -19,19 +18,19 @@
2019 * Constants for use with the mode,
2120 * defining what should be shown in the tree
2221 */
23 -define('CT_MODE_CATEGORIES', 0);
24 -define('CT_MODE_PAGES', 10);
25 -define('CT_MODE_ALL', 20);
26 -define('CT_MODE_PARENTS', 100);
 22+define( 'CT_MODE_CATEGORIES', 0 );
 23+define( 'CT_MODE_PAGES', 10 );
 24+define( 'CT_MODE_ALL', 20 );
 25+define( 'CT_MODE_PARENTS', 100 );
2726
2827 /**
2928 * Constants for use with the hideprefix option,
3029 * defining when the namespace prefix should be hidden
3130 */
32 -define('CT_HIDEPREFIX_NEVER', 0);
33 -define('CT_HIDEPREFIX_ALWAYS', 10);
34 -define('CT_HIDEPREFIX_CATEGORIES', 20);
35 -define('CT_HIDEPREFIX_AUTO', 30);
 31+define( 'CT_HIDEPREFIX_NEVER', 0 );
 32+define( 'CT_HIDEPREFIX_ALWAYS', 10 );
 33+define( 'CT_HIDEPREFIX_CATEGORIES', 20 );
 34+define( 'CT_HIDEPREFIX_AUTO', 30 );
3635
3736 /**
3837 * Options:
@@ -56,53 +55,53 @@
5756 $wgCategoryTreeDisableCache = true;
5857 $wgCategoryTreeDynamicTag = false;
5958 $wgCategoryTreeHTTPCache = false;
60 -#$wgCategoryTreeUnifiedView = true;
61 -$wgCategoryTreeMaxDepth = array(CT_MODE_PAGES => 1, CT_MODE_ALL => 1, CT_MODE_CATEGORIES => 2);
 59+# $wgCategoryTreeUnifiedView = true;
 60+$wgCategoryTreeMaxDepth = array( CT_MODE_PAGES => 1, CT_MODE_ALL => 1, CT_MODE_CATEGORIES => 2 );
6261
63 -# Set $wgCategoryTreeForceHeaders to true to force the JS and CSS headers for CategoryTree to be included on every page.
 62+# Set $wgCategoryTreeForceHeaders to true to force the JS and CSS headers for CategoryTree to be included on every page.
6463 # May be usefull for using CategoryTree from within system messages, in the sidebar, or a custom skin.
65 -$wgCategoryTreeForceHeaders = false;
 64+$wgCategoryTreeForceHeaders = false;
6665 $wgCategoryTreeSidebarRoot = null;
6766 $wgCategoryTreeHijackPageCategories = false; # EXPERIMENTAL! NOT YET FOR PRODUCTION USE! Main problem is general HTML/CSS layout cruftiness.
6867
6968 $wgCategoryTreeExtPath = '/extensions/CategoryTree';
70 -$wgCategoryTreeVersion = '5'; #NOTE: bump this when you change the CSS or JS files!
 69+$wgCategoryTreeVersion = '5'; # NOTE: bump this when you change the CSS or JS files!
7170 $wgCategoryTreeUseCategoryTable = version_compare( $wgVersion, "1.13", '>=' );
7271
7372 $wgCategoryTreeOmitNamespace = CT_HIDEPREFIX_CATEGORIES;
7473 $wgCategoryTreeDefaultMode = CT_MODE_CATEGORIES;
75 -$wgCategoryTreeDefaultOptions = array(); #Default values for most options. ADD NEW OPTIONS HERE!
 74+$wgCategoryTreeDefaultOptions = array(); # Default values for most options. ADD NEW OPTIONS HERE!
7675 $wgCategoryTreeDefaultOptions['mode'] = null; # will be set to $wgCategoryTreeDefaultMode in efCategoryTree(); compatibility quirk
7776 $wgCategoryTreeDefaultOptions['hideprefix'] = null; # will be set to $wgCategoryTreeDefaultMode in efCategoryTree(); compatibility quirk
7877 $wgCategoryTreeDefaultOptions['showcount'] = false;
7978 $wgCategoryTreeDefaultOptions['namespaces'] = false; # false means "no filter"
8079
8180 $wgCategoryTreeCategoryPageMode = CT_MODE_CATEGORIES;
82 -$wgCategoryTreeCategoryPageOptions = array(); #Options to be used for category pages
 81+$wgCategoryTreeCategoryPageOptions = array(); # Options to be used for category pages
8382 $wgCategoryTreeCategoryPageOptions['mode'] = NULL; # will be set to $wgCategoryTreeDefaultMode in efCategoryTree(); compatibility quirk
8483 $wgCategoryTreeCategoryPageOptions['showcount'] = true;
8584
86 -$wgCategoryTreeSpecialPageOptions = array(); #Options to be used for Special:CategoryTree
 85+$wgCategoryTreeSpecialPageOptions = array(); # Options to be used for Special:CategoryTree
8786 $wgCategoryTreeSpecialPageOptions['showcount'] = true;
8887
89 -$wgCategoryTreeSidebarOptions = array(); #Options to be used in the sidebar (for use with $wgCategoryTreeSidebarRoot)
 88+$wgCategoryTreeSidebarOptions = array(); # Options to be used in the sidebar (for use with $wgCategoryTreeSidebarRoot)
9089 $wgCategoryTreeSidebarOptions['mode'] = CT_MODE_CATEGORIES;
9190 $wgCategoryTreeSidebarOptions['hideprefix'] = CT_HIDEPREFIX_CATEGORIES;
9291 $wgCategoryTreeSidebarOptions['showcount'] = false;
9392 $wgCategoryTreeSidebarOptions['hideroot'] = true;
94 -$wgCategoryTreeSidebarOptions['namespaces'] = false;
 93+$wgCategoryTreeSidebarOptions['namespaces'] = false;
9594 $wgCategoryTreeSidebarOptions['depth'] = 1;
9695
97 -$wgCategoryTreePageCategoryOptions = array(); #Options to be used in the sidebar (for use with $wgCategoryTreePageCategories)
 96+$wgCategoryTreePageCategoryOptions = array(); # Options to be used in the sidebar (for use with $wgCategoryTreePageCategories)
9897 $wgCategoryTreePageCategoryOptions['mode'] = CT_MODE_PARENTS;
9998 $wgCategoryTreePageCategoryOptions['hideprefix'] = CT_HIDEPREFIX_CATEGORIES;
10099 $wgCategoryTreePageCategoryOptions['showcount'] = false;
101100 $wgCategoryTreePageCategoryOptions['hideroot'] = false;
102101 $wgCategoryTreePageCategoryOptions['namespaces'] = false;
103102 $wgCategoryTreePageCategoryOptions['depth'] = 0;
104 -#$wgCategoryTreePageCategoryOptions['class'] = 'CategoryTreeInlineNode';
 103+# $wgCategoryTreePageCategoryOptions['class'] = 'CategoryTreeInlineNode';
105104
106 -$wgExtensionAliasesFiles['CategoryTree'] = dirname(__FILE__) . '/CategoryTree.alias.php';
 105+$wgExtensionAliasesFiles['CategoryTree'] = dirname( __FILE__ ) . '/CategoryTree.alias.php';
107106
108107 /**
109108 * Register extension setup hook and credits
@@ -127,7 +126,7 @@
128127 /**
129128 * Register the special page
130129 */
131 -$dir = dirname(__FILE__) . '/';
 130+$dir = dirname( __FILE__ ) . '/';
132131
133132 if ( $wgUseAjax && $wgCategoryTreeAllowTag ) {
134133 $wgExtensionMessagesFiles['CategoryTreeMagic'] = $dir . 'CategoryTree.i18n.magic.php';
@@ -139,7 +138,7 @@
140139 $wgAutoloadClasses['CategoryTreeCategoryPage'] = $dir . 'CategoryPageSubclass.php';
141140 $wgSpecialPages['CategoryTree'] = 'CategoryTreePage';
142141 $wgSpecialPageGroups['CategoryTree'] = 'pages';
143 -#$wgHooks['SkinTemplateTabs'][] = 'efCategoryTreeInstallTabs';
 142+# $wgHooks['SkinTemplateTabs'][] = 'efCategoryTreeInstallTabs';
144143 $wgHooks['ArticleFromTitle'][] = 'efCategoryTreeArticleFromTitle';
145144
146145 /**
@@ -173,7 +172,7 @@
174173 $wgHooks['SkinJoinCategoryLinks'][] = 'efCategoryTreeSkinJoinCategoryLinks';
175174 }
176175
177 - if( $wgCategoryTreeAllowTag ) {
 176+ if ( $wgCategoryTreeAllowTag ) {
178177 $wgHooks['ParserFirstCallInit'][] = 'efCategoryTreeSetHooks';
179178 }
180179
@@ -220,13 +219,13 @@
221220 $depth = isset( $options['depth'] ) ? (int)$options['depth'] : 1;
222221
223222 $ct = new CategoryTree( $options, true );
224 - $depth = efCategoryTreeCapDepth( $ct->getOption('mode'), $depth );
 223+ $depth = efCategoryTreeCapDepth( $ct->getOption( 'mode' ), $depth );
225224 $response = $ct->ajax( $category, $depth );
226225
227226 if ( $wgCategoryTreeHTTPCache && $wgSquidMaxage && $wgUseSquid ) {
228227 $response->setCacheDuration( $wgSquidMaxage );
229 - $response->setVary( 'Accept-Encoding, Cookie' ); #cache for anons only
230 - #TODO: purge the squid cache when a category page is invalidated
 228+ $response->setVary( 'Accept-Encoding, Cookie' ); # cache for anons only
 229+ # TODO: purge the squid cache when a category page is invalidated
231230 }
232231
233232 return $response;
@@ -239,20 +238,22 @@
240239 function efCategoryTreeCapDepth( $mode, $depth ) {
241240 global $wgCategoryTreeMaxDepth;
242241
243 - if (is_numeric($depth))
244 - $depth = intval($depth);
245 - else return 1;
 242+ if ( is_numeric( $depth ) ) {
 243+ $depth = intval( $depth );
 244+ } else {
 245+ return 1;
 246+ }
246247
247 - if (is_array($wgCategoryTreeMaxDepth)) {
248 - $max = isset($wgCategoryTreeMaxDepth[$mode]) ? $wgCategoryTreeMaxDepth[$mode] : 1;
249 - } elseif (is_numeric($wgCategoryTreeMaxDepth)) {
 248+ if ( is_array( $wgCategoryTreeMaxDepth ) ) {
 249+ $max = isset( $wgCategoryTreeMaxDepth[$mode] ) ? $wgCategoryTreeMaxDepth[$mode] : 1;
 250+ } elseif ( is_numeric( $wgCategoryTreeMaxDepth ) ) {
250251 $max = $wgCategoryTreeMaxDepth;
251252 } else {
252253 wfDebug( 'efCategoryTreeCapDepth: $wgCategoryTreeMaxDepth is invalid.' );
253254 $max = 1;
254255 }
255256
256 - return min($depth, $max);
 257+ return min( $depth, $max );
257258 }
258259
259260 /**
@@ -261,28 +262,30 @@
262263 */
263264 function efCategoryTreeParserFunction( &$parser ) {
264265 $params = func_get_args();
265 - array_shift( $params ); //first is &$parser, strip it
 266+ array_shift( $params ); // first is &$parser, strip it
266267
267 - //first user-supplied parameter must be category name
268 - if ( !$params ) return ''; //no category specified, return nothing
 268+ // first user-supplied parameter must be category name
 269+ if ( !$params ) {
 270+ return ''; // no category specified, return nothing
 271+ }
269272 $cat = array_shift( $params );
270273
271 - //build associative arguments from flat parameter list
 274+ // build associative arguments from flat parameter list
272275 $argv = array();
273276 foreach ( $params as $p ) {
274 - if ( preg_match('/^\s*(\S.*?)\s*=\s*(.*?)\s*$/', $p, $m) ) {
 277+ if ( preg_match( '/^\s*(\S.*?)\s*=\s*(.*?)\s*$/', $p, $m ) ) {
275278 $k = $m[1];
276 - $v = preg_replace('/^"\s*(.*?)\s*"$/', '$1', $m[2]); //strip any quotes enclusing the value
 279+ $v = preg_replace( '/^"\s*(.*?)\s*"$/', '$1', $m[2] ); // strip any quotes enclusing the value
277280 }
278281 else {
279 - $k = trim($p);
 282+ $k = trim( $p );
280283 $v = true;
281284 }
282285
283286 $argv[$k] = $v;
284287 }
285288
286 - //now handle just like a <categorytree> tag
 289+ // now handle just like a <categorytree> tag
287290 $html = efCategoryTreeParserHook( $cat, $argv, $parser );
288291 return array( $html, 'noparse' => true, 'isHTML' => true );
289292 }
@@ -293,14 +296,15 @@
294297 */
295298 function efCategoryTreeSkinTemplateOutputPageBeforeExec( &$skin, &$tpl ) {
296299 global $wgCategoryTreeSidebarRoot, $wgCategoryTreeSidebarOptions;
297 -
 300+
298301 $html = efCategoryTreeParserHook( $wgCategoryTreeSidebarRoot, $wgCategoryTreeSidebarOptions );
299 - if ( $html ) $tpl->data['sidebar']['categorytree-portlet'] = $html; //requires MW 1.13, r36917
 302+ if ( $html ) {
 303+ $tpl->data['sidebar']['categorytree-portlet'] = $html; // requires MW 1.13, r36917
 304+ }
300305
301306 return true;
302307 }
303308
304 -
305309 /**
306310 * Entry point for the <categorytree> tag parser hook.
307311 * This loads CategoryTreeFunctions.php and calls CategoryTree::getTag()
@@ -310,8 +314,7 @@
311315
312316 if ( $parser ) {
313317 $parser->mOutput->mCategoryTreeTag = true; # flag for use by efCategoryTreeParserOutput
314 - }
315 - else {
 318+ } else {
316319 CategoryTree::setHeaders( $wgOut );
317320 }
318321
@@ -324,7 +327,9 @@
325328 $depthArg = isset( $argv[ 'depth' ] ) ? (int)$argv[ 'depth' ] : null;
326329
327330 $depth = efCategoryTreeCapDepth( $ct->getOption( 'mode' ), $depthArg );
328 - if ( $onlyroot ) $depth = 0;
 331+ if ( $onlyroot ) {
 332+ $depth = 0;
 333+ }
329334
330335 return $ct->getTag( $parser, $cat, $hideroot, $attr, $depth, $allowMissing );
331336 }
@@ -365,13 +370,11 @@
366371 return false;
367372 }
368373
369 -
370374 function efCategoryTreeSkinJoinCategoryLinks( &$skin, &$links, &$result ) {
371375 $embed = '<div class="CategoryTreePretendInlineMSIE CategoryTreeCategoryBarItem">';
372376 $pop = '</div>';
373377 $sep = ' ';
374378
375 -# $result = '<div class="CategoryTreeCatBarWrapper" style="border:1px solid blue">' . $embed . implode ( "{$pop} {$sep} {$embed}" , $links ) . $pop . '</div>';
376379 $result = $embed . implode ( "{$pop} {$sep} {$embed}" , $links ) . $pop;
377380
378381 return false;
Index: trunk/extensions/CategoryTree/CategoryTree.css
@@ -8,7 +8,7 @@
99 * @copyright © 2006 Daniel Kinzler
1010 * @licence GNU General Public Licence 2.0 or later
1111 *
12 - * NOTE: if you change this, increment $wgCategoryTreeVersion
 12+ * NOTE: if you change this, increment $wgCategoryTreeVersion
1313 * in CategoryTree.php to avoid users getting stale copies from cache.
1414 */
1515
Index: trunk/extensions/CategoryTree/CategoryTree.js
@@ -8,155 +8,155 @@
99 * @copyright © 2006 Daniel Kinzler
1010 * @licence GNU General Public Licence 2.0 or later
1111 *
12 - * NOTE: if you change this, increment $wgCategoryTreeVersion
 12+ * NOTE: if you change this, increment $wgCategoryTreeVersion
1313 * in CategoryTree.php to avoid users getting stale copies from cache.
14 -*/
 14+ */
1515
1616 // Default messages if new code loaded with old cached page
1717 var categoryTreeErrorMsg = "Problem loading data.";
1818 var categoryTreeRetryMsg = "Please wait a moment and try again.";
1919
20 - function categoryTreeNextDiv(e) {
21 - var n= e.nextSibling;
22 - while ( n && ( n.nodeType != 1 || n.nodeName != 'DIV') ) {
23 - //alert('nodeType: ' + n.nodeType + '; nodeName: ' + n.nodeName);
24 - n= n.nextSibling;
25 - }
 20+function categoryTreeNextDiv(e) {
 21+ var n= e.nextSibling;
 22+ while ( n && ( n.nodeType != 1 || n.nodeName != 'DIV') ) {
 23+ //alert('nodeType: ' + n.nodeType + '; nodeName: ' + n.nodeName);
 24+ n= n.nextSibling;
 25+ }
2626
27 - return n;
28 - }
 27+ return n;
 28+}
2929
30 - function categoryTreeExpandNode(cat, options, lnk) {
31 - var div= categoryTreeNextDiv( lnk.parentNode.parentNode );
 30+function categoryTreeExpandNode(cat, options, lnk) {
 31+ var div= categoryTreeNextDiv( lnk.parentNode.parentNode );
3232
33 - div.style.display= 'block';
34 - lnk.innerHTML= categoryTreeCollapseBulletMsg;
35 - lnk.title= categoryTreeCollapseMsg;
36 - lnk.onclick= function() { categoryTreeCollapseNode(cat, options, lnk) }
 33+ div.style.display= 'block';
 34+ lnk.innerHTML= categoryTreeCollapseBulletMsg;
 35+ lnk.title= categoryTreeCollapseMsg;
 36+ lnk.onclick= function() { categoryTreeCollapseNode(cat, options, lnk) }
3737
38 - if (!lnk.className.match(/(^| )CategoryTreeLoaded($| )/)) {
39 - categoryTreeLoadNode(cat, options, lnk, div);
40 - }
41 - }
 38+ if (!lnk.className.match(/(^| )CategoryTreeLoaded($| )/)) {
 39+ categoryTreeLoadNode(cat, options, lnk, div);
 40+ }
 41+}
4242
43 - function categoryTreeCollapseNode(cat, options, lnk) {
44 - var div= categoryTreeNextDiv( lnk.parentNode.parentNode );
 43+function categoryTreeCollapseNode(cat, options, lnk) {
 44+ var div= categoryTreeNextDiv( lnk.parentNode.parentNode );
4545
46 - div.style.display= 'none';
47 - lnk.innerHTML= categoryTreeExpandBulletMsg;
48 - lnk.title= categoryTreeExpandMsg;
49 - lnk.onclick= function() { categoryTreeExpandNode(cat, options, lnk) }
50 - }
 46+ div.style.display= 'none';
 47+ lnk.innerHTML= categoryTreeExpandBulletMsg;
 48+ lnk.title= categoryTreeExpandMsg;
 49+ lnk.onclick= function() { categoryTreeExpandNode(cat, options, lnk) }
 50+}
5151
52 - function categoryTreeLoadNode(cat, options, lnk, div) {
53 - div.style.display= 'block';
54 - lnk.className= 'CategoryTreeLoaded';
55 - lnk.innerHTML= categoryTreeCollapseBulletMsg;
56 - lnk.title= categoryTreeCollapseMsg;
57 - lnk.onclick= function() { categoryTreeCollapseNode(cat, options, lnk) }
 52+function categoryTreeLoadNode(cat, options, lnk, div) {
 53+ div.style.display= 'block';
 54+ lnk.className= 'CategoryTreeLoaded';
 55+ lnk.innerHTML= categoryTreeCollapseBulletMsg;
 56+ lnk.title= categoryTreeCollapseMsg;
 57+ lnk.onclick= function() { categoryTreeCollapseNode(cat, options, lnk) }
5858
59 - categoryTreeLoadChildren(cat, options, div)
60 - }
 59+ categoryTreeLoadChildren(cat, options, div)
 60+}
6161
62 - // FIXME Why can't this just use uneval()?
63 - function categoryTreeEncodeValue(value) {
64 - switch (typeof value) {
65 - case 'function':
66 - throw new Error("categoryTreeEncodeValue encountered a function");
67 - break;
 62+// FIXME Why can't this just use uneval()?
 63+function categoryTreeEncodeValue(value) {
 64+ switch (typeof value) {
 65+ case 'function':
 66+ throw new Error("categoryTreeEncodeValue encountered a function");
 67+ break;
 68+ case 'string':
 69+ s = '"' + value.replace(/([\\"'])/g, "\\$1") + '"';
 70+ break;
 71+ case 'number':
 72+ case 'boolean':
 73+ case 'null':
 74+ s = String(value);
 75+ break;
 76+ case 'object':
 77+ if ( !value ) {
 78+ s = 'null';
 79+ } else if (typeof value.length === 'number' && !(value.propertyIsEnumerable('length'))) {
 80+ s = '';
 81+ for (i = 0; i<value.length; i++) {
 82+ v = value[i];
 83+ if ( s!='' ) s += ', ';
 84+ s += categoryTreeEncodeValue( v );
 85+ }
 86+ s = '[' + s + ']';
 87+ } else {
 88+ s = '';
 89+ for (k in value) {
 90+ v = value[k];
 91+ if ( s!='' ) s += ', ';
 92+ s += categoryTreeEncodeValue( k );
 93+ s += ': ';
 94+ s += categoryTreeEncodeValue( v );
 95+ }
 96+ s = '{' + s + '}';
 97+ }
 98+ break;
 99+ default:
 100+ throw new Error("categoryTreeEncodeValue encountered strange variable type " + (typeof value));
 101+ }
68102
69 - case 'string':
70 - s = '"' + value.replace(/([\\"'])/g, "\\$1") + '"';
71 - break;
 103+ return s;
 104+}
72105
73 - case 'number':
74 - case 'boolean':
75 - case 'null':
76 - s = String(value);
77 - break;
 106+function categoryTreeLoadChildren(cat, options, div) {
 107+ div.innerHTML= '<i class="CategoryTreeNotice">' + categoryTreeLoadingMsg + '</i>';
78108
79 - case 'object':
80 - if ( !value ) {
81 - s = 'null';
82 - }
83 - else if (typeof value.length === 'number' && !(value.propertyIsEnumerable('length'))) {
84 - s = '';
85 - for (i = 0; i<value.length; i++) {
86 - v = value[i];
87 - if ( s!='' ) s += ', ';
88 - s += categoryTreeEncodeValue( v );
89 - }
90 - s = '[' + s + ']';
91 - }
92 - else {
93 - s = '';
94 - for (k in value) {
95 - v = value[k];
96 - if ( s!='' ) s += ', ';
97 - s += categoryTreeEncodeValue( k );
98 - s += ': ';
99 - s += categoryTreeEncodeValue( v );
100 - }
101 - s = '{' + s + '}';
102 - }
103 - break;
104 - default:
105 - throw new Error("categoryTreeEncodeValue encountered strange variable type " + (typeof value));
106 - }
 109+ if ( typeof options == "string" ) { //hack for backward compatibility
 110+ options = { mode : options };
 111+ }
107112
108 - return s;
109 - }
 113+ function f( request ) {
 114+ if (request.status != 200) {
 115+ div.innerHTML = '<i class="CategoryTreeNotice">' + categoryTreeErrorMsg + ' </i>';
 116+ var retryLink = document.createElement('a');
 117+ retryLink.innerHTML = categoryTreeRetryMsg;
 118+ retryLink.onclick = function() {
 119+ categoryTreeLoadChildren(cat, options, div, enc);
 120+ }
 121+ div.appendChild(retryLink);
 122+ return;
 123+ }
110124
111 - function categoryTreeLoadChildren(cat, options, div) {
112 - div.innerHTML= '<i class="CategoryTreeNotice">' + categoryTreeLoadingMsg + '</i>';
 125+ result= request.responseText;
 126+ result= result.replace(/^\s+|\s+$/, '');
113127
114 - if ( typeof options == "string" ) { //hack for backward compatibility
115 - options = { mode : options };
116 - }
 128+ if ( result == '' ) {
 129+ result= '<i class="CategoryTreeNotice">';
117130
118 - function f( request ) {
119 - if (request.status != 200) {
120 - div.innerHTML = '<i class="CategoryTreeNotice">' + categoryTreeErrorMsg + ' </i>';
121 - var retryLink = document.createElement('a');
122 - retryLink.innerHTML = categoryTreeRetryMsg;
123 - retryLink.onclick = function() {
124 - categoryTreeLoadChildren(cat, options, div, enc);
125 - }
126 - div.appendChild(retryLink);
127 - return;
128 - }
 131+ if ( options.mode == 0 ) {
 132+ result= categoryTreeNoSubcategoriesMsg;
 133+ } else if ( options.mode == 10 ) {
 134+ result= categoryTreeNoPagesMsg;
 135+ } else if ( options.mode == 100 ) {
 136+ result= categoryTreeNoParentCategoriesMsg;
 137+ } else {
 138+ result= categoryTreeNothingFoundMsg;
 139+ }
129140
130 - result= request.responseText;
131 - result= result.replace(/^\s+|\s+$/, '');
 141+ result+= '</i>';
 142+ }
132143
133 - if ( result == '' ) {
134 - result= '<i class="CategoryTreeNotice">';
 144+ result = result.replace(/##LOAD##/g, categoryTreeExpandMsg);
 145+ div.innerHTML= result;
135146
136 - if ( options.mode == 0 ) result= categoryTreeNoSubcategoriesMsg;
137 - else if ( options.mode == 10 ) result= categoryTreeNoPagesMsg;
138 - else if ( options.mode == 100 ) result= categoryTreeNoParentCategoriesMsg;
139 - else result= categoryTreeNothingFoundMsg;
 147+ categoryTreeShowToggles();
 148+ }
140149
141 - result+= '</i>';
142 - }
 150+ var opt = categoryTreeEncodeValue(options);
 151+ sajax_do_call( "efCategoryTreeAjaxWrapper", [cat, opt, 'json'] , f );
 152+}
143153
144 - result = result.replace(/##LOAD##/g, categoryTreeExpandMsg);
145 - div.innerHTML= result;
 154+function categoryTreeShowToggles() {
 155+ var toggles = getElementsByClassName( document, 'span', 'CategoryTreeToggle' );
146156
147 - categoryTreeShowToggles();
148 - }
 157+ for( var i = 0; i<toggles.length; ++i ) {
 158+ toggles[i].style.display = 'inline';
 159+ }
 160+}
149161
150 - var opt = categoryTreeEncodeValue(options);
151 - sajax_do_call( "efCategoryTreeAjaxWrapper", [cat, opt, 'json'] , f );
152 - }
153 -
154 - function categoryTreeShowToggles() {
155 - var toggles = getElementsByClassName( document, 'span', 'CategoryTreeToggle' );
156 -
157 - for( var i = 0; i<toggles.length; ++i ) {
158 - toggles[i].style.display = 'inline';
159 - }
160 - }
161 -
162 - // Re-show the CategoryTreeToggles
163 - addOnloadHook(categoryTreeShowToggles);
 162+// Re-show the CategoryTreeToggles
 163+addOnloadHook(categoryTreeShowToggles);
Index: trunk/extensions/CategoryTree/CategoryTreeFunctions.php
@@ -1,5 +1,4 @@
22 <?php
3 -
43 /**
54 * Core functions for the CategoryTree extension, an AJAX based gadget
65 * to display the category structure of a wiki
@@ -10,7 +9,7 @@
1110 * @license GNU General Public Licence 2.0 or later
1211 */
1312
14 -if( !defined( 'MEDIAWIKI' ) ) {
 13+if ( !defined( 'MEDIAWIKI' ) ) {
1514 echo( "This file is part of an extension to the MediaWiki software and cannot be used standalone.\n" );
1615 die( 1 );
1716 }
@@ -24,16 +23,19 @@
2524
2625 $this->mIsAjaxRequest = $ajax;
2726
28 - #ensure default values and order of options. Order may become important, it may influence the cache key!
 27+ # ensure default values and order of options. Order may become important, it may influence the cache key!
2928 foreach ( $wgCategoryTreeDefaultOptions as $option => $default ) {
30 - if ( isset( $options[$option] ) && !is_null( $options[$option] ) ) $this->mOptions[$option] = $options[$option];
31 - else $this->mOptions[$option] = $default;
 29+ if ( isset( $options[$option] ) && !is_null( $options[$option] ) ) {
 30+ $this->mOptions[$option] = $options[$option];
 31+ } else {
 32+ $this->mOptions[$option] = $default;
 33+ }
3234 }
3335
3436 $this->mOptions['mode'] = self::decodeMode( $this->mOptions['mode'] );
3537
3638 if ( $this->mOptions['mode'] == CT_MODE_PARENTS ) {
37 - $this->mOptions['namespaces'] = false; #namespace filter makes no sense with CT_MODE_PARENTS
 39+ $this->mOptions['namespaces'] = false; # namespace filter makes no sense with CT_MODE_PARENTS
3840 }
3941
4042 $this->mOptions['hideprefix'] = self::decodeHidePrefix( $this->mOptions['hideprefix'] );
@@ -42,7 +44,7 @@
4345
4446 if ( $this->mOptions['namespaces'] ) {
4547 # automatically adjust mode to match namespace filter
46 - if ( sizeof( $this->mOptions['namespaces'] ) === 1
 48+ if ( sizeof( $this->mOptions['namespaces'] ) === 1
4749 && $this->mOptions['namespaces'][0] == NS_CATEGORY ) {
4850 $this->mOptions['mode'] = CT_MODE_CATEGORIES;
4951 } else if ( !in_array( NS_IMAGE, $this->mOptions['namespaces'] ) ) {
@@ -58,7 +60,7 @@
5961 }
6062
6163 function isInverse( ) {
62 - return $this->getOption('mode') == CT_MODE_PARENTS;
 64+ return $this->getOption( 'mode' ) == CT_MODE_PARENTS;
6365 }
6466
6567 static function decodeNamespaces( $nn ) {
@@ -67,7 +69,7 @@
6870 if ( !$nn )
6971 return false;
7072
71 - if ( !is_array($nn) )
 73+ if ( !is_array( $nn ) )
7274 $nn = preg_split( '![\s#:|]+!', $nn );
7375
7476 $namespaces = array();
@@ -79,10 +81,10 @@
8082 else {
8183 $n = trim( $n );
8284 if ( $n === '' ) continue;
83 -
 85+
8486 $lower = strtolower( $n );
85 -
86 - if ( is_numeric($n) ) $ns = (int)$n;
 87+
 88+ if ( is_numeric( $n ) ) $ns = (int)$n;
8789 elseif ( $n == '-' || $n == '_' || $n == '*' || $lower == 'main' ) $ns = NS_MAIN;
8890 else $ns = $wgContLang->getNsIndex( $n );
8991 }
@@ -145,7 +147,7 @@
146148
147149 if ( $value == 'yes' || $value == 'y' || $value == 'true' || $value == 't' || $value == 'on' ) return CT_HIDEPREFIX_ALWAYS;
148150 else if ( $value == 'no' || $value == 'n' || $value == 'false' || $value == 'f' || $value == 'off' ) return CT_HIDEPREFIX_NEVER;
149 - //else if ( $value == 'null' || $value == 'default' || $value == 'none' || $value == 'x' ) return $wgCategoryTreeDefaultOptions['hideprefix'];
 151+ // else if ( $value == 'null' || $value == 'default' || $value == 'none' || $value == 'x' ) return $wgCategoryTreeDefaultOptions['hideprefix'];
150152 else if ( $value == 'always' ) return CT_HIDEPREFIX_ALWAYS;
151153 else if ( $value == 'never' ) return CT_HIDEPREFIX_NEVER;
152154 else if ( $value == 'auto' ) return CT_HIDEPREFIX_AUTO;
@@ -160,7 +162,6 @@
161163 static function setHeaders( &$outputPage ) {
162164 global $wgJsMimeType, $wgScriptPath, $wgContLang;
163165 global $wgCategoryTreeHijackPageCategories, $wgCategoryTreeExtPath, $wgCategoryTreeVersion;
164 - self::init();
165166
166167 # Register css file for CategoryTree
167168 $outputPage->addLink(
@@ -180,7 +181,7 @@
181182 }
182183
183184 # Register css RTL file for CategoryTree
184 - if( $wgContLang->isRTL() ) {
 185+ if ( $wgContLang->isRTL() ) {
185186 $outputPage->addLink(
186187 array(
187188 'rel' => 'stylesheet',
@@ -199,27 +200,27 @@
200201 # Add messages
201202 $outputPage->addScript(
202203 " <script type=\"{$wgJsMimeType}\">
203 - var categoryTreeCollapseMsg = \"".Xml::escapeJsString(wfMsgNoTrans('categorytree-collapse'))."\";
204 - var categoryTreeExpandMsg = \"".Xml::escapeJsString(wfMsgNoTrans('categorytree-expand'))."\";
205 - var categoryTreeCollapseBulletMsg = \"".Xml::escapeJsString(wfMsgNoTrans('categorytree-collapse-bullet'))."\";
206 - var categoryTreeExpandBulletMsg = \"".Xml::escapeJsString(wfMsgNoTrans('categorytree-expand-bullet'))."\";
207 - var categoryTreeLoadMsg = \"".Xml::escapeJsString(wfMsgNoTrans('categorytree-load'))."\";
208 - var categoryTreeLoadingMsg = \"".Xml::escapeJsString(wfMsgNoTrans('categorytree-loading'))."\";
209 - var categoryTreeNothingFoundMsg = \"".Xml::escapeJsString(wfMsgNoTrans('categorytree-nothing-found'))."\";
210 - var categoryTreeNoSubcategoriesMsg = \"".Xml::escapeJsString(wfMsgNoTrans('categorytree-no-subcategories'))."\";
211 - var categoryTreeNoParentCategoriesMsg = \"".Xml::escapeJsString(wfMsgNoTrans('categorytree-no-parent-categories'))."\";
212 - var categoryTreeNoPagesMsg = \"".Xml::escapeJsString(wfMsgNoTrans('categorytree-no-pages'))."\";
213 - var categoryTreeErrorMsg = \"".Xml::escapeJsString(wfMsgNoTrans('categorytree-error'))."\";
214 - var categoryTreeRetryMsg = \"".Xml::escapeJsString(wfMsgNoTrans('categorytree-retry'))."\";
215 - </script>\n"
 204+ var categoryTreeCollapseMsg = \"" . Xml::escapeJsString( wfMsgNoTrans( 'categorytree-collapse' ) ) . "\";
 205+ var categoryTreeExpandMsg = \"" . Xml::escapeJsString( wfMsgNoTrans( 'categorytree-expand' ) ) . "\";
 206+ var categoryTreeCollapseBulletMsg = \"" . Xml::escapeJsString( wfMsgNoTrans( 'categorytree-collapse-bullet' ) ) . "\";
 207+ var categoryTreeExpandBulletMsg = \"" . Xml::escapeJsString( wfMsgNoTrans( 'categorytree-expand-bullet' ) ) . "\";
 208+ var categoryTreeLoadMsg = \"" . Xml::escapeJsString( wfMsgNoTrans( 'categorytree-load' ) ) . "\";
 209+ var categoryTreeLoadingMsg = \"" . Xml::escapeJsString( wfMsgNoTrans( 'categorytree-loading' ) ) . "\";
 210+ var categoryTreeNothingFoundMsg = \"" . Xml::escapeJsString( wfMsgNoTrans( 'categorytree-nothing-found' ) ) . "\";
 211+ var categoryTreeNoSubcategoriesMsg = \"" . Xml::escapeJsString( wfMsgNoTrans( 'categorytree-no-subcategories' ) ) . "\";
 212+ var categoryTreeNoParentCategoriesMsg = \"" . Xml::escapeJsString( wfMsgNoTrans( 'categorytree-no-parent-categories' ) ) . "\";
 213+ var categoryTreeNoPagesMsg = \"" . Xml::escapeJsString( wfMsgNoTrans( 'categorytree-no-pages' ) ) . "\";
 214+ var categoryTreeErrorMsg = \"" . Xml::escapeJsString( wfMsgNoTrans( 'categorytree-error' ) ) . "\";
 215+ var categoryTreeRetryMsg = \"" . Xml::escapeJsString( wfMsgNoTrans( 'categorytree-retry' ) ) . "\";
 216+ </script>\n"
216217 );
217218 }
218219
219220 static function getJsonCodec() {
220221 static $json = null;
221222
222 - if (!$json) {
223 - $json = new Services_JSON(); #recycle API's JSON codec implementation
 223+ if ( !$json ) {
 224+ $json = new Services_JSON(); # recycle API's JSON codec implementation
224225 }
225226
226227 return $json;
@@ -227,9 +228,9 @@
228229
229230 static function encodeOptions( $options, $enc ) {
230231 if ( $enc == 'mode' || $enc == '' ) {
231 - $opt =$options['mode'];
 232+ $opt = $options['mode'];
232233 } elseif ( $enc == 'json' ) {
233 - $json = self::getJsonCodec(); //XXX: this may be a bit heavy...
 234+ $json = self::getJsonCodec(); // XXX: this may be a bit heavy...
234235 $opt = $json->encode( $options );
235236 } else {
236237 throw new MWException( 'Unknown encoding for CategoryTree options: ' . $enc );
@@ -242,21 +243,10 @@
243244 if ( $enc == 'mode' || $enc == '' ) {
244245 $opt = array( "mode" => $options );
245246 } elseif ( $enc == 'json' ) {
246 - $json = self::getJsonCodec(); //XXX: this may be a bit heavy...
 247+ $json = self::getJsonCodec(); // XXX: this may be a bit heavy...
247248 $opt = $json->decode( $options );
248249 $opt = get_object_vars( $opt );
249 - } /* elseif () {
250 - foreach ( $oo as $o ) {
251 - if ($o === "") continue;
252 -
253 - if ( preg_match( '!^(.*?)=(.*)$!', $o, $m ) {
254 - $n = $m[1];
255 - $opt[$n] = $m[2];
256 - } else {
257 - $opt[$o] = true;
258 - }
259 - }
260 - } */ else {
 250+ } else {
261251 throw new MWException( 'Unknown encoding for CategoryTree options: ' . $enc );
262252 }
263253
@@ -296,7 +286,7 @@
297287
298288 foreach ( $this->mOptions as $k => $v ) {
299289 if ( $u != '' ) $u .= '&';
300 - $u .= $k . '=' . urlencode($v) ;
 290+ $u .= $k . '=' . urlencode( $v ) ;
301291 }
302292
303293 return $u;
@@ -310,7 +300,9 @@
311301 global $wgDBname, $wgUser;
312302 $title = self::makeTitle( $category );
313303
314 - if ( ! $title ) return false; #TODO: error message?
 304+ if ( ! $title ) {
 305+ return false; # TODO: error message?
 306+ }
315307
316308 # configkey needed to take into account variant and secure options.
317309 $configkey = $wgUser->getPageRenderingHash();
@@ -336,10 +328,13 @@
337329 return $response;
338330 }
339331
340 - $html = $this->renderChildren( $title, $depth );
 332+ $html = $this->renderChildren( $title, $depth );
341333
342 - if ( $html == '' ) $html = ' '; #HACK: Safari doesn't like empty responses.
343 - #see Bug 7219 and http://bugzilla.opendarwin.org/show_bug.cgi?id=10716
 334+ if ( $html == '' ) {
 335+ # HACK: Safari doesn't like empty responses.
 336+ # see Bug 7219 and http://bugzilla.opendarwin.org/show_bug.cgi?id=10716
 337+ $html = ' ';
 338+ }
344339
345340 $response->addText( $html );
346341
@@ -352,7 +347,7 @@
353348 * Custom tag implementation. This is called by efCategoryTreeParserHook, which is used to
354349 * load CategoryTreeFunctions.php on demand.
355350 */
356 - function getTag( $parser, $category, $hideroot = false, $attr, $depth=1, $allowMissing = false ) {
 351+ function getTag( $parser, $category, $hideroot = false, $attr, $depth = 1, $allowMissing = false ) {
357352 global $wgCategoryTreeDisableCache, $wgCategoryTreeDynamicTag;
358353 static $uniq = 0;
359354
@@ -360,24 +355,29 @@
361356 if ( $category === '' ) {
362357 return false;
363358 }
 359+
364360 if ( $parser && $wgCategoryTreeDisableCache && !$wgCategoryTreeDynamicTag ) {
365361 $parser->disableCache();
366362 }
 363+
367364 $title = self::makeTitle( $category );
368365
369 - if ( $title === false || $title === null ) return false;
 366+ if ( $title === false || $title === null ) {
 367+ return false;
 368+ }
370369
371 - if ( isset( $attr['class'] ) ) $attr['class'] .= ' CategoryTreeTag';
372 - else $attr['class'] = ' CategoryTreeTag';
 370+ if ( isset( $attr['class'] ) ) {
 371+ $attr['class'] .= ' CategoryTreeTag';
 372+ } else {
 373+ $attr['class'] = ' CategoryTreeTag';
 374+ }
373375
374 - $this->init();
375 -
376376 $html = '';
377377 $html .= Xml::openElement( 'div', $attr );
378378
379379 if ( !$allowMissing && !$title->getArticleID() ) {
380380 $html .= Xml::openElement( 'span', array( 'class' => 'CategoryTreeNotice' ) );
381 - if( $parser ) {
 381+ if ( $parser ) {
382382 $html .= $parser->recursiveTagParse( wfMsgNoTrans( 'categorytree-not-found', $category ) );
383383 } else {
384384 $html .= wfMsgExt( 'categorytree-not-found', 'parseinline', htmlspecialchars( $category ) );
@@ -385,9 +385,11 @@
386386 $html .= Xml::closeElement( 'span' );
387387 }
388388 else {
389 - if ( !$hideroot ) $html .= CategoryTree::renderNode( $title, $depth, $wgCategoryTreeDynamicTag );
390 - else if ( !$wgCategoryTreeDynamicTag ) $html .= $this->renderChildren( $title, $depth );
391 - else {
 389+ if ( !$hideroot ) {
 390+ $html .= CategoryTree::renderNode( $title, $depth, $wgCategoryTreeDynamicTag );
 391+ } else if ( !$wgCategoryTreeDynamicTag ) {
 392+ $html .= $this->renderChildren( $title, $depth );
 393+ } else {
392394 $uniq += 1;
393395 $load = 'ct-' . $uniq . '-' . mt_rand( 1, 100000 );
394396
@@ -407,10 +409,10 @@
408410 * Returns a string with an HTML representation of the children of the given category.
409411 * $title must be a Title object
410412 */
411 - function renderChildren( &$title, $depth=1 ) {
 413+ function renderChildren( &$title, $depth = 1 ) {
412414 global $wgCategoryTreeMaxChildren, $wgCategoryTreeUseCategoryTable;
413415
414 - if( $title->getNamespace() != NS_CATEGORY ) {
 416+ if ( $title->getNamespace() != NS_CATEGORY ) {
415417 // Non-categories can't have children. :)
416418 return '';
417419 }
@@ -418,8 +420,8 @@
419421 $dbr = wfGetDB( DB_SLAVE );
420422
421423 $inverse = $this->isInverse();
422 - $mode = $this->getOption('mode');
423 - $namespaces = $this->getOption('namespaces');
 424+ $mode = $this->getOption( 'mode' );
 425+ $namespaces = $this->getOption( 'namespaces' );
424426
425427 if ( $inverse ) {
426428 $ctJoinCond = ' cl_to = cat.page_title AND cat.page_namespace = ' . NS_CATEGORY;
@@ -432,20 +434,27 @@
433435 $ctWhere = ' cl_to = ' . $dbr->addQuotes( $title->getDBkey() );
434436 $ctJoin = ' JOIN ';
435437
436 - #namespace filter.
 438+ # namespace filter.
437439 if ( $namespaces ) {
438 - #NOTE: we assume that the $namespaces array contains only integers! decodeNamepsaces makes it so.
439 - if ( sizeof( $namespaces ) === 1 ) $nsmatch = ' AND cat.page_namespace = ' . $namespaces[0] . ' ';
440 - else $nsmatch = ' AND cat.page_namespace IN ( ' . implode( ', ', $namespaces ) . ') ';
 440+ # NOTE: we assume that the $namespaces array contains only integers! decodeNamepsaces makes it so.
 441+ if ( sizeof( $namespaces ) === 1 ) {
 442+ $nsmatch = ' AND cat.page_namespace = ' . $namespaces[0] . ' ';
 443+ } else {
 444+ $nsmatch = ' AND cat.page_namespace IN ( ' . implode( ', ', $namespaces ) . ') ';
 445+ }
441446 }
442447 else {
443 - if ( $mode == CT_MODE_ALL ) $nsmatch = '';
444 - else if ( $mode == CT_MODE_PAGES ) $nsmatch = ' AND cat.page_namespace != ' . NS_IMAGE;
445 - else $nsmatch = ' AND cat.page_namespace = ' . NS_CATEGORY;
 448+ if ( $mode == CT_MODE_ALL ) {
 449+ $nsmatch = '';
 450+ } else if ( $mode == CT_MODE_PAGES ) {
 451+ $nsmatch = ' AND cat.page_namespace != ' . NS_IMAGE;
 452+ } else {
 453+ $nsmatch = ' AND cat.page_namespace = ' . NS_CATEGORY;
 454+ }
446455 }
447456 }
448457
449 - #additional stuff to be used if "transaltion" by interwiki-links is desired
 458+ # additional stuff to be used if "transaltion" by interwiki-links is desired
450459 $transFields = '';
451460 $transJoin = '';
452461 $transWhere = '';
@@ -475,25 +484,24 @@
476485 $countJoin
477486 WHERE $ctWhere
478487 $nsmatch
479 - "./*AND cat.page_is_redirect = 0*/"
 488+ " . /*AND cat.page_is_redirect = 0*/"
480489 $transWhere
481490 ORDER BY cl_sortkey";
482 - $sql = $dbr->limitResult($sql, (int)$wgCategoryTreeMaxChildren);
483 -
 491+ $sql = $dbr->limitResult( $sql, (int)$wgCategoryTreeMaxChildren );
 492+
484493 $res = $dbr->query( $sql, __METHOD__ );
485494
486 - #collect categories separately from other pages
487 - $categories= '';
488 - $other= '';
 495+ # collect categories separately from other pages
 496+ $categories = '';
 497+ $other = '';
489498
490499 while ( $row = $dbr->fetchObject( $res ) ) {
491 - #NOTE: in inverse mode, the page record may be null, because we use a right join.
 500+ # NOTE: in inverse mode, the page record may be null, because we use a right join.
492501 # happens for categories with no category page (red cat links)
493502 if ( $inverse && $row->page_title === null ) {
494503 $t = Title::makeTitle( NS_CATEGORY, $row->cl_to );
495 - }
496 - else {
497 - #TODO: translation support; ideally added to Title object
 504+ } else {
 505+ # TODO: translation support; ideally added to Title object
498506 $t = Title::newFromRow( $row );
499507 }
500508
@@ -503,11 +511,14 @@
504512 $cat = Category::newFromRow( $row, $t );
505513 }
506514
507 - $s = $this->renderNodeInfo( $t, $cat, $depth-1, false );
 515+ $s = $this->renderNodeInfo( $t, $cat, $depth -1, false );
508516 $s .= "\n\t\t";
509517
510 - if ($row->page_namespace == NS_CATEGORY) $categories .= $s;
511 - else $other .= $s;
 518+ if ( $row->page_namespace == NS_CATEGORY ) {
 519+ $categories .= $s;
 520+ } else {
 521+ $other .= $s;
 522+ }
512523 }
513524
514525 $dbr->freeResult( $res );
@@ -524,7 +535,7 @@
525536
526537 $dbr = wfGetDB( DB_SLAVE );
527538
528 - #additional stuff to be used if "transaltion" by interwiki-links is desired
 539+ # additional stuff to be used if "transaltion" by interwiki-links is desired
529540 $transFields = '';
530541 $transJoin = '';
531542 $transWhere = '';
@@ -537,23 +548,23 @@
538549 WHERE cl_from = " . $title->getArticleID() . "
539550 $transWhere
540551 ORDER BY cl_to";
541 - $sql = $dbr->limitResult($sql, (int)$wgCategoryTreeMaxChildren);
 552+ $sql = $dbr->limitResult( $sql, (int)$wgCategoryTreeMaxChildren );
542553
543554 $res = $dbr->query( $sql, __METHOD__ );
544555
545556 $special = Title::makeTitle( NS_SPECIAL, 'CategoryTree' );
546557
547 - $s= '';
 558+ $s = '';
548559
549560 while ( $row = $dbr->fetchObject( $res ) ) {
550 - #TODO: translation support; ideally added to Title object
 561+ # TODO: translation support; ideally added to Title object
551562 $t = Title::newFromRow( $row );
552563
553 - #$trans = $title->getLocalizedText();
554 - $trans = ''; #place holder for when translated titles are available
 564+ # $trans = $title->getLocalizedText();
 565+ $trans = ''; # place holder for when translated titles are available
555566
556567 $label = htmlspecialchars( $t->getText() );
557 - if ( $trans && $trans!=$label ) $label.= ' ' . Xml::element( 'i', array( 'class' => 'translation'), $trans );
 568+ if ( $trans && $trans != $label ) $label .= ' ' . Xml::element( 'i', array( 'class' => 'translation' ), $trans );
558569
559570 $wikiLink = $special->getLocalURL( 'target=' . $t->getPartialURL() . '&' . $this->getOptionsAsUrlParameters() );
560571
@@ -580,8 +591,9 @@
581592
582593 if ( $wgCategoryTreeUseCategoryTable && $title->getNamespace() == NS_CATEGORY && !$this->isInverse() ) {
583594 $cat = Category::newFromTitle( $title );
 595+ } else {
 596+ $cat = null;
584597 }
585 - else $cat = NULL;
586598
587599 return $this->renderNodeInfo( $title, $cat, $children, $loadchildren );
588600 }
@@ -593,9 +605,7 @@
594606 function renderNodeInfo( $title, $cat, $children = 0, $loadchildren = false ) {
595607 static $uniq = 0;
596608
597 - $this->init(); # initialize messages
598 -
599 - $mode = $this->getOption('mode');
 609+ $mode = $this->getOption( 'mode' );
600610 $load = false;
601611
602612 if ( $children > 0 && $loadchildren ) {
@@ -607,22 +617,32 @@
608618 $ns = $title->getNamespace();
609619 $key = $title->getDBkey();
610620
611 - #$trans = $title->getLocalizedText();
612 - $trans = ''; #place holder for when translated titles are available
 621+ # $trans = $title->getLocalizedText();
 622+ $trans = ''; # place holder for when translated titles are available
613623
614 - $hideprefix = $this->getOption('hideprefix');
 624+ $hideprefix = $this->getOption( 'hideprefix' );
615625
616 - if ( $hideprefix == CT_HIDEPREFIX_ALWAYS ) $hideprefix = true;
617 - else if ( $hideprefix == CT_HIDEPREFIX_AUTO ) $hideprefix = ($mode == CT_MODE_CATEGORIES);
618 - else if ( $hideprefix == CT_HIDEPREFIX_CATEGORIES ) $hideprefix = ($ns == NS_CATEGORY);
619 - else $hideprefix = true;
 626+ if ( $hideprefix == CT_HIDEPREFIX_ALWAYS ) {
 627+ $hideprefix = true;
 628+ } else if ( $hideprefix == CT_HIDEPREFIX_AUTO ) {
 629+ $hideprefix = ( $mode == CT_MODE_CATEGORIES );
 630+ } else if ( $hideprefix == CT_HIDEPREFIX_CATEGORIES ) {
 631+ $hideprefix = ( $ns == NS_CATEGORY );
 632+ } else {
 633+ $hideprefix = true;
 634+ }
620635
621 - #when showing only categories, omit namespace in label unless we explicitely defined the configuration setting
622 - #patch contributed by Manuel Schneider <manuel.schneider@wikimedia.ch>, Bug 8011
623 - if ( $hideprefix ) $label = htmlspecialchars( $title->getText() );
624 - else $label = htmlspecialchars( $title->getPrefixedText() );
 636+ # when showing only categories, omit namespace in label unless we explicitely defined the configuration setting
 637+ # patch contributed by Manuel Schneider <manuel.schneider@wikimedia.ch>, Bug 8011
 638+ if ( $hideprefix ) {
 639+ $label = htmlspecialchars( $title->getText() );
 640+ } else {
 641+ $label = htmlspecialchars( $title->getPrefixedText() );
 642+ }
625643
626 - if ( $trans && $trans!=$label ) $label.= ' ' . Xml::element( 'i', array( 'class' => 'translation'), $trans );
 644+ if ( $trans && $trans != $label ) {
 645+ $label .= ' ' . Xml::element( 'i', array( 'class' => 'translation' ), $trans );
 646+ }
627647
628648 $labelClass = 'CategoryTreeLabel ' . ' CategoryTreeLabelNs' . $ns;
629649
@@ -639,12 +659,14 @@
640660 $labelClass .= ' CategoryTreeLabelPage';
641661 }
642662
643 - if ( ( $ns % 2 ) > 0 ) $labelClass .= ' CategoryTreeLabelTalk';
 663+ if ( ( $ns % 2 ) > 0 ) {
 664+ $labelClass .= ' CategoryTreeLabelTalk';
 665+ }
644666
645667 $count = false;
646668 $s = '';
647669
648 - #NOTE: things in CategoryTree.js rely on the exact order of tags!
 670+ # NOTE: things in CategoryTree.js rely on the exact order of tags!
649671 # Specifically, the CategoryTreeChildren div must be the first
650672 # sibling with nodeName = DIV of the grandparent of the expland link.
651673
@@ -656,39 +678,44 @@
657679
658680 if ( $ns == NS_CATEGORY ) {
659681 if ( $cat ) {
660 - if ( $mode == CT_MODE_CATEGORIES ) $count = $cat->getSubcatCount();
661 - else if ( $mode == CT_MODE_PAGES ) $count = $cat->getPageCount() - $cat->getFileCount();
662 - else $count = $cat->getPageCount();
 682+ if ( $mode == CT_MODE_CATEGORIES ) {
 683+ $count = $cat->getSubcatCount();
 684+ } else if ( $mode == CT_MODE_PAGES ) {
 685+ $count = $cat->getPageCount() - $cat->getFileCount();
 686+ } else {
 687+ $count = $cat->getPageCount();
 688+ }
663689 }
664 -
665 - $linkattr= array( );
666 - if ( $load ) $linkattr[ 'id' ] = $load;
667690
 691+ $linkattr = array( );
 692+ if ( $load ) {
 693+ $linkattr[ 'id' ] = $load;
 694+ }
 695+
668696 $linkattr[ 'class' ] = "CategoryTreeToggle";
669697 $linkattr['style'] = 'display: none;'; // Unhidden by JS
670698
671 - /*if ( $count === 0 ) {
672 - $tag = 'span';
673 - $txt = wfMsgNoTrans( 'categorytree-empty-bullet' );
674 - }
675 - else*/
676699 if ( $children == 0 || $loadchildren ) {
677700 $tag = 'span';
678 - if ( $count === 0 ) $txt = wfMsgNoTrans( 'categorytree-empty-bullet' );
679 - else $txt = wfMsgNoTrans( 'categorytree-expand-bullet' );
680 - $linkattr[ 'onclick' ] = "if (this.href) this.href='javascript:void(0)'; categoryTreeExpandNode('".Xml::escapeJsString($key)."',".$this->getOptionsAsJsStructure().",this);";
 701+ if ( $count === 0 ) {
 702+ $txt = wfMsgNoTrans( 'categorytree-empty-bullet' );
 703+ } else {
 704+ $txt = wfMsgNoTrans( 'categorytree-expand-bullet' );
 705+ }
 706+ $linkattr[ 'onclick' ] = "if (this.href) this.href='javascript:void(0)'; categoryTreeExpandNode('" . Xml::escapeJsString( $key ) . "'," . $this->getOptionsAsJsStructure() . ",this);";
681707 # Don't load this message for ajax requests, so that we don't have to initialise $wgLang
682 - $linkattr[ 'title' ] = $this->mIsAjaxRequest ? '##LOAD##' : wfMsgNoTrans('categorytree-expand');
683 - }
684 - else {
 708+ $linkattr[ 'title' ] = $this->mIsAjaxRequest ? '##LOAD##' : wfMsgNoTrans( 'categorytree-expand' );
 709+ } else {
685710 $tag = 'span';
686711 $txt = wfMsgNoTrans( 'categorytree-collapse-bullet' );
687 - $linkattr[ 'onclick' ] = "if (this.href) this.href='javascript:void(0)'; categoryTreeCollapseNode('".Xml::escapeJsString($key)."',".$this->getOptionsAsJsStructure().",this);";
688 - $linkattr[ 'title' ] = wfMsgNoTrans('categorytree-collapse');
 712+ $linkattr[ 'onclick' ] = "if (this.href) this.href='javascript:void(0)'; categoryTreeCollapseNode('" . Xml::escapeJsString( $key ) . "'," . $this->getOptionsAsJsStructure() . ",this);";
 713+ $linkattr[ 'title' ] = wfMsgNoTrans( 'categorytree-collapse' );
689714 $linkattr[ 'class' ] .= ' CategoryTreeLoaded';
690715 }
691716
692 - if ( $tag == 'a' ) $linkattr[ 'href' ] = $wikiLink;
 717+ if ( $tag == 'a' ) {
 718+ $linkattr[ 'href' ] = $wikiLink;
 719+ }
693720 $s .= Xml::openElement( $tag, $linkattr ) . $txt . Xml::closeElement( $tag ) . ' ';
694721 } else {
695722 $s .= wfMsgNoTrans( 'categorytree-page-bullet' );
@@ -720,15 +747,20 @@
721748 $s .= Xml::closeElement( 'div' );
722749 $s .= "\n\t\t";
723750 $s .= Xml::openElement( 'div', array( 'class' => 'CategoryTreeChildren', 'style' => $children > 0 ? "display:block" : "display:none" ) );
724 -
725 - if ( $ns == NS_CATEGORY && $children > 0 && !$loadchildren) {
 751+
 752+ if ( $ns == NS_CATEGORY && $children > 0 && !$loadchildren ) {
726753 $children = $this->renderChildren( $title, $children );
727754 if ( $children == '' ) {
728755 $s .= Xml::openElement( 'i', array( 'class' => 'CategoryTreeNotice' ) );
729 - if ( $mode == CT_MODE_CATEGORIES ) $s .= wfMsgExt( 'categorytree-no-subcategories', 'parsemag');
730 - else if ( $mode == CT_MODE_PAGES ) $s .= wfMsgExt( 'categorytree-no-pages', 'parsemag');
731 - else if ( $mode == CT_MODE_PARENTS ) $s .= wfMsgExt( 'categorytree-no-parent-categories', 'parsemag');
732 - else $s .= wfMsgExt( 'categorytree-nothing-found', 'parsemag');
 756+ if ( $mode == CT_MODE_CATEGORIES ) {
 757+ $s .= wfMsgExt( 'categorytree-no-subcategories', 'parsemag' );
 758+ } else if ( $mode == CT_MODE_PAGES ) {
 759+ $s .= wfMsgExt( 'categorytree-no-pages', 'parsemag' );
 760+ } else if ( $mode == CT_MODE_PARENTS ) {
 761+ $s .= wfMsgExt( 'categorytree-no-parent-categories', 'parsemag' );
 762+ } else {
 763+ $s .= wfMsgExt( 'categorytree-nothing-found', 'parsemag' );
 764+ }
733765 $s .= Xml::closeElement( 'i' );
734766 } else {
735767 $s .= $children;
@@ -741,7 +773,7 @@
742774 if ( $load ) {
743775 $s .= "\n\t\t";
744776 $s .= Xml::openElement( 'script', array( 'type' => 'text/javascript' ) );
745 - $s .= 'categoryTreeExpandNode("'.Xml::escapeJsString($key).'", '.$this->getOptionsAsJsStructure($children).', document.getElementById("'.$load.'"));';
 777+ $s .= 'categoryTreeExpandNode("' . Xml::escapeJsString( $key ) . '", ' . $this->getOptionsAsJsStructure( $children ) . ', document.getElementById("' . $load . '"));';
746778 $s .= Xml::closeElement( 'script' );
747779 }
748780
@@ -756,7 +788,7 @@
757789 static function makeTitle( $title ) {
758790 global $wgContLang, $wgCanonicalNamespaceNames;
759791
760 - $title = trim($title);
 792+ $title = trim( $title );
761793
762794 if ( $title === null || $title === '' || $title === false ) {
763795 return null;
@@ -771,18 +803,4 @@
772804 }
773805 return $t;
774806 }
775 -
776 - /**
777 - * Initialize. Load messages, if not ajax request.
778 - */
779 - static function init( ) {
780 - static $initialized = false;
781 - if ( $initialized ) return;
782 - $initialized = true;
783 -
784 - #NOTE: don't load messages for ajax requests. Ajax requests are cachable and language-neutral.
785 - # Messages used in JS are defined by setHeaders
786 - if ( !isset( $this ) || !$this->mIsAjaxRequest )
787 - wfLoadExtensionMessages( 'CategoryTree' );
788 - }
789807 }
Index: trunk/extensions/CategoryTree/README
@@ -16,4 +16,3 @@
1717
1818 Instructions on installing and using this extension are available at
1919 <http://www.mediawiki.org/wiki/Extension:CategoryTree>
20 -

Status & tagging log