Index: branches/REL1_19/extensions/LiquidThreads/lqt.css |
— | — | @@ -222,7 +222,6 @@ |
223 | 223 | |
224 | 224 | .lqt-command-icon { |
225 | 225 | height: 1.25em; |
226 | | - line-height: 1.25em; |
227 | 226 | background-position: center left; |
228 | 227 | background-repeat: no-repeat; |
229 | 228 | display: inline; |
Property changes on: branches/REL1_19/extensions/LiquidThreads |
___________________________________________________________________ |
Modified: svn:mergeinfo |
230 | 229 | Merged /trunk/extensions/LiquidThreads:r112660,112687,112751,112770-112771,112775,112849,112851,112856,112859,112903,112925,112993 |
Index: branches/REL1_19/extensions/ProofreadPage/proofread.js |
— | — | @@ -749,18 +749,18 @@ |
750 | 750 | return; |
751 | 751 | } |
752 | 752 | var f = text.parentNode; |
753 | | - var new_text = f.removeChild( text ); |
754 | 753 | |
755 | 754 | if( proofreadPageIsEdit ) { |
756 | | - pr_make_edit_area( self.text_container, new_text.value ); |
757 | | - var copywarn = document.getElementById( 'editpage-copywarn' ); |
758 | | - f.insertBefore( table, copywarn ); |
| 755 | + pr_make_edit_area( self.text_container, text.value ); |
| 756 | + f.insertBefore( table, text.nextSibling ); // Inserts table after text |
| 757 | + f.removeChild( text ); |
759 | 758 | if ( !self.proofreadpage_show_headers ) { |
760 | 759 | hookEvent( 'load', pr_toggle_visibility ); |
761 | 760 | } else { |
762 | 761 | hookEvent( 'load', pr_reset_size ); |
763 | 762 | } |
764 | 763 | } else { |
| 764 | + var new_text = f.removeChild( text ); |
765 | 765 | self.text_container.appendChild( new_text ); |
766 | 766 | f.appendChild( self.table ); |
767 | 767 | } |
Index: branches/REL1_19/extensions/CentralAuth/CentralAuth.php |
— | — | @@ -281,7 +281,6 @@ |
282 | 282 | $wgAutoloadClasses['CentralAuthAntiSpoofHooks'] = "$caBase/AntiSpoof/CentralAuthAntiSpoofHooks.php"; |
283 | 283 | |
284 | 284 | $wgHooks['AbortNewAccount'][] = 'CentralAuthAntiSpoofHooks::asAbortNewAccountHook'; |
285 | | - $wgHooks['UserCreateForm'][] = 'CentralAuthAntiSpoofHooks::asUserCreateFormHook'; |
286 | 285 | $wgHooks['AddNewAccount'][] = 'CentralAuthAntiSpoofHooks::asAddNewAccountHook'; |
287 | 286 | $wgHooks['RenameUserComplete'][] = 'CentralAuthAntiSpoofHooks::asAddRenameUserHook'; |
288 | 287 | } |
Index: branches/REL1_19/extensions/CentralAuth/specials/SpecialCentralAuth.php |
— | — | @@ -706,7 +706,7 @@ |
707 | 707 | foreach ( array( 'primary', 'new', 'empty', 'password', 'mail', 'admin', 'login' ) as $method ) { |
708 | 708 | $short = Xml::encodeJsVar( $this->getLanguage()->ucfirst( wfMsgHtml( "centralauth-merge-method-{$method}" ) ) ); |
709 | 709 | $desc = Xml::encodeJsVar( wfMsgWikiHtml( "centralauth-merge-method-{$method}-desc" ) ); |
710 | | - $js .= "\t'{$method}' : { 'short' : {$short}, 'desc' : {$desc} },\n"; |
| 710 | + $js .= "\t'{$method}' : { 'short' : {$short}, 'desc' : {$desc} }\n"; |
711 | 711 | } |
712 | 712 | $js .= "}"; |
713 | 713 | $this->getOutput()->addInlineScript( $js ); |
Index: branches/REL1_19/extensions/CentralAuth/specials/SpecialWikiSets.php |
— | — | @@ -131,13 +131,13 @@ |
132 | 132 | } else { |
133 | 133 | $usage = wfMsgExt( 'centralauth-editset-nouse', 'parse' ); |
134 | 134 | } |
| 135 | + $sortedWikis = $set->getWikisRaw(); |
| 136 | + sort( $sortedWikis ); |
135 | 137 | } else { |
136 | 138 | $usage = ''; |
| 139 | + $sortedWikis = array(); |
137 | 140 | } |
138 | 141 | |
139 | | - $sortedWikis = $set->getWikisRaw(); |
140 | | - sort( $sortedWikis ); |
141 | | - |
142 | 142 | # Make an array of the opposite list of wikis |
143 | 143 | # (all databases *excluding* the defined ones) |
144 | 144 | $restWikis = array(); |
Property changes on: branches/REL1_19/extensions/CentralAuth/specials/SpecialWikiSets.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
145 | 145 | Merged /trunk/extensions/CentralAuth/specials/SpecialWikiSets.php:r112993 |
Index: branches/REL1_19/extensions/Collection/Collection.body.php |
— | — | @@ -810,7 +810,7 @@ |
811 | 811 | * @return bool |
812 | 812 | */ |
813 | 813 | function saveCollection( $title, $forceOverwrite = false ) { |
814 | | - global $wgUser; |
| 814 | + global $wgRequest, $wgUser; |
815 | 815 | |
816 | 816 | $article = new Article( $title ); |
817 | 817 | if ( $article->exists() && !$forceOverwrite ) { |
— | — | @@ -857,12 +857,14 @@ |
858 | 858 | } |
859 | 859 | } |
860 | 860 | |
861 | | - $req = new FauxRequest( array( |
862 | | - 'action' => 'edit', |
863 | | - 'title' => $title->getPrefixedText(), |
864 | | - 'text' => $articleText, |
865 | | - 'token' => $wgUser->editToken(), |
866 | | - ), true, $_SESSION ); |
| 861 | + $req = new DerivativeRequest( |
| 862 | + $wgRequest, |
| 863 | + array( |
| 864 | + 'action' => 'edit', |
| 865 | + 'title' => $title->getPrefixedText(), |
| 866 | + 'text' => $articleText, |
| 867 | + 'token' => $wgUser->editToken(), |
| 868 | + ), true); |
867 | 869 | $api = new ApiMain( $req, true ); |
868 | 870 | $api->execute(); |
869 | 871 | return true; |
Index: branches/REL1_19/extensions/GlobalUsage/GlobalUsage_body.php |
— | — | @@ -2,6 +2,10 @@ |
3 | 3 | |
4 | 4 | class GlobalUsage { |
5 | 5 | private $interwiki; |
| 6 | + |
| 7 | + /** |
| 8 | + * @var DatabaseBase |
| 9 | + */ |
6 | 10 | private $db; |
7 | 11 | |
8 | 12 | /** |
— | — | @@ -127,7 +131,7 @@ |
128 | 132 | array( |
129 | 133 | 'gil_page_namespace_id' => $title->getNamespace(), |
130 | 134 | 'gil_page_namespace' => $title->getNsText(), |
131 | | - 'gil_page_title' => $title->getText() |
| 135 | + 'gil_page_title' => $title->getDBkey() |
132 | 136 | ), |
133 | 137 | array( |
134 | 138 | 'gil_wiki' => $this->interwiki, |
Index: branches/REL1_19/extensions/MoodBar/ApiFeedbackDashboardResponse.php |
— | — | @@ -47,18 +47,21 @@ |
48 | 48 | $this->disableUserTalkEmailNotification(); |
49 | 49 | |
50 | 50 | $id = intval( $item->getProperty( 'id' ) ); |
51 | | - $api = new ApiMain( new FauxRequest( array( |
52 | | - 'action' => 'edit', |
53 | | - 'title' => $talkPage->getFullText(), |
54 | | - 'appendtext' => ( $talkPage->exists() ? "\n\n" : '' ) . |
55 | | - $feedback_link . "\n" . |
56 | | - '<span id="feedback-dashboard-response-' . $id . '"></span>' . "\n\n" . |
57 | | - $response . "\n\n~~~~\n\n" . |
58 | | - '<span class="markashelpful-mbresponse-' . $id . '"> </span>', |
59 | | - 'token' => $params['token'], |
60 | | - 'summary' => $summary, |
61 | | - 'notminor' => true, |
62 | | - ), true, array( 'wsEditToken' => $wgRequest->getSessionData( 'wsEditToken' ) ) ), true ); |
| 51 | + $api = new ApiMain( new DerivativeRequest( |
| 52 | + $wgRequest, |
| 53 | + array( |
| 54 | + 'action' => 'edit', |
| 55 | + 'title' => $talkPage->getFullText(), |
| 56 | + 'appendtext' => ( $talkPage->exists() ? "\n\n" : '' ) . |
| 57 | + $feedback_link . "\n" . |
| 58 | + '<span id="feedback-dashboard-response-' . $id . '"></span>' . "\n\n" . |
| 59 | + $response . "\n\n~~~~\n\n" . |
| 60 | + '<span class="markashelpful-mbresponse-' . $id . '"> </span>', |
| 61 | + 'token' => $params['token'], |
| 62 | + 'summary' => $summary, |
| 63 | + 'notminor' => true, |
| 64 | + ), true), |
| 65 | + true ); |
63 | 66 | |
64 | 67 | $api->execute(); |
65 | 68 | |
Index: branches/REL1_19/extensions/CategoryTree/CategoryPageSubclass.php |
— | — | @@ -7,11 +7,21 @@ |
8 | 8 | class CategoryTreeCategoryViewer extends CategoryViewer { |
9 | 9 | var $child_cats; |
10 | 10 | |
| 11 | + /** |
| 12 | + * @var CategoryTree |
| 13 | + */ |
| 14 | + var $categorytree; |
| 15 | + |
| 16 | + /** |
| 17 | + * @return CategoryTree |
| 18 | + */ |
11 | 19 | function getCategoryTree() { |
12 | 20 | global $wgOut, $wgCategoryTreeCategoryPageOptions, $wgCategoryTreeForceHeaders; |
13 | 21 | |
14 | | - if ( ! isset( $this->categorytree ) ) { |
15 | | - if ( !$wgCategoryTreeForceHeaders ) CategoryTree::setHeaders( $wgOut ); |
| 22 | + if ( !isset( $this->categorytree ) ) { |
| 23 | + if ( !$wgCategoryTreeForceHeaders ) { |
| 24 | + CategoryTree::setHeaders( $wgOut ); |
| 25 | + } |
16 | 26 | |
17 | 27 | $this->categorytree = new CategoryTree( $wgCategoryTreeCategoryPageOptions ); |
18 | 28 | } |
— | — | @@ -21,6 +31,10 @@ |
22 | 32 | |
23 | 33 | /** |
24 | 34 | * Add a subcategory to the internal lists |
| 35 | + * @param $cat Category |
| 36 | + * @param $sortkey |
| 37 | + * @param $pageLength |
| 38 | + * @return |
25 | 39 | */ |
26 | 40 | function addSubcategoryObject( Category $cat, $sortkey, $pageLength ) { |
27 | 41 | global $wgRequest; |
— | — | @@ -28,7 +42,8 @@ |
29 | 43 | $title = $cat->getTitle(); |
30 | 44 | |
31 | 45 | if ( $wgRequest->getCheck( 'notree' ) ) { |
32 | | - return parent::addSubcategoryObject( $cat, $sortkey, $pageLength ); |
| 46 | + parent::addSubcategoryObject( $cat, $sortkey, $pageLength ); |
| 47 | + return; |
33 | 48 | } |
34 | 49 | |
35 | 50 | $tree = $this->getCategoryTree(); |
Index: branches/REL1_19/extensions/CategoryTree/CategoryTreePage.php |
— | — | @@ -19,13 +19,14 @@ |
20 | 20 | var $target = ''; |
21 | 21 | var $tree = null; |
22 | 22 | |
23 | | - /** |
24 | | - * Constructor |
25 | | - */ |
26 | 23 | function __construct() { |
27 | 24 | parent::__construct( 'CategoryTree', '', true ); |
28 | 25 | } |
29 | 26 | |
| 27 | + /** |
| 28 | + * @param $name |
| 29 | + * @return mixed |
| 30 | + */ |
30 | 31 | function getOption( $name ) { |
31 | 32 | global $wgCategoryTreeDefaultOptions; |
32 | 33 | |
— | — | @@ -38,16 +39,19 @@ |
39 | 40 | |
40 | 41 | /** |
41 | 42 | * Main execution function |
42 | | - * @param $par Parameters passed to the page |
| 43 | + * @param $par array Parameters passed to the page |
43 | 44 | */ |
44 | 45 | function execute( $par ) { |
45 | | - global $wgRequest, $wgOut, $wgCategoryTreeDefaultOptions, $wgCategoryTreeSpecialPageOptions, $wgCategoryTreeForceHeaders; |
| 46 | + global $wgCategoryTreeDefaultOptions, $wgCategoryTreeSpecialPageOptions, $wgCategoryTreeForceHeaders; |
46 | 47 | |
47 | 48 | $this->setHeaders(); |
| 49 | + $request = $this->getRequest(); |
| 50 | + if ( $par ) { |
| 51 | + $this->target = $par; |
| 52 | + } else { |
| 53 | + $this->target = $request->getVal( 'target', wfMsg( 'rootcategory' ) ); |
| 54 | + } |
48 | 55 | |
49 | | - if ( $par ) $this->target = $par; |
50 | | - else $this->target = $wgRequest->getVal( 'target', wfMsg( 'rootcategory' ) ); |
51 | | - |
52 | 56 | $this->target = trim( $this->target ); |
53 | 57 | |
54 | 58 | # HACK for undefined root category |
— | — | @@ -59,47 +63,50 @@ |
60 | 64 | |
61 | 65 | # grab all known options from the request. Normalization is done by the CategoryTree class |
62 | 66 | foreach ( $wgCategoryTreeDefaultOptions as $option => $default ) { |
63 | | - if ( isset( $wgCategoryTreeSpecialPageOptions[$option] ) ) |
| 67 | + if ( isset( $wgCategoryTreeSpecialPageOptions[$option] ) ) { |
64 | 68 | $default = $wgCategoryTreeSpecialPageOptions[$option]; |
| 69 | + } |
65 | 70 | |
66 | | - $options[$option] = $wgRequest->getVal( $option, $default ); |
| 71 | + $options[$option] = $request->getVal( $option, $default ); |
67 | 72 | } |
68 | 73 | |
69 | 74 | $this->tree = new CategoryTree( $options ); |
70 | 75 | |
71 | | - $wgOut->addWikiMsg( 'categorytree-header' ); |
| 76 | + $output = $this->getOutput(); |
| 77 | + $output->addWikiMsg( 'categorytree-header' ); |
72 | 78 | |
73 | 79 | $this->executeInputForm(); |
74 | 80 | |
75 | 81 | if ( $this->target !== '' && $this->target !== null ) { |
76 | | - if ( !$wgCategoryTreeForceHeaders ) CategoryTree::setHeaders( $wgOut ); |
| 82 | + if ( !$wgCategoryTreeForceHeaders ) { |
| 83 | + CategoryTree::setHeaders( $output ); |
| 84 | + } |
77 | 85 | |
78 | 86 | $title = CategoryTree::makeTitle( $this->target ); |
79 | 87 | |
80 | 88 | if ( $title && $title->getArticleID() ) { |
81 | | - $wgOut->addHTML( Xml::openElement( 'div', array( 'class' => 'CategoryTreeParents' ) ) ); |
82 | | - $wgOut->addHTML( wfMsgExt( 'categorytree-parents', 'parseinline' ) ); |
83 | | - $wgOut->addHTML( wfMsg( 'colon-separator' ) ); |
| 89 | + $output->addHTML( Xml::openElement( 'div', array( 'class' => 'CategoryTreeParents' ) ) ); |
| 90 | + $output->addHTML( wfMsgExt( 'categorytree-parents', 'parseinline' ) ); |
| 91 | + $output->addHTML( wfMsg( 'colon-separator' ) ); |
84 | 92 | |
85 | 93 | $parents = $this->tree->renderParents( $title ); |
86 | 94 | |
87 | 95 | if ( $parents == '' ) { |
88 | | - $wgOut->addHTML( wfMsgExt( 'categorytree-no-parent-categories', 'parseinline' ) ); |
| 96 | + $output->addHTML( wfMsgExt( 'categorytree-no-parent-categories', 'parseinline' ) ); |
89 | 97 | } else { |
90 | | - $wgOut->addHTML( $parents ); |
| 98 | + $output->addHTML( $parents ); |
91 | 99 | } |
92 | 100 | |
93 | | - $wgOut->addHTML( Xml::closeElement( 'div' ) ); |
| 101 | + $output->addHTML( Xml::closeElement( 'div' ) ); |
94 | 102 | |
95 | | - $wgOut->addHTML( Xml::openElement( 'div', array( 'class' => 'CategoryTreeResult' ) ) ); |
96 | | - $wgOut->addHTML( $this->tree->renderNode( $title, 1 ) ); |
97 | | - $wgOut->addHTML( Xml::closeElement( 'div' ) ); |
| 103 | + $output->addHTML( Xml::openElement( 'div', array( 'class' => 'CategoryTreeResult' ) ) ); |
| 104 | + $output->addHTML( $this->tree->renderNode( $title, 1 ) ); |
| 105 | + $output->addHTML( Xml::closeElement( 'div' ) ); |
| 106 | + } else { |
| 107 | + $output->addHTML( Xml::openElement( 'div', array( 'class' => 'CategoryTreeNotice' ) ) ); |
| 108 | + $output->addHTML( wfMsgExt( 'categorytree-not-found', 'parseinline' , $this->target ) ); |
| 109 | + $output->addHTML( Xml::closeElement( 'div' ) ); |
98 | 110 | } |
99 | | - else { |
100 | | - $wgOut->addHTML( Xml::openElement( 'div', array( 'class' => 'CategoryTreeNotice' ) ) ); |
101 | | - $wgOut->addHTML( wfMsgExt( 'categorytree-not-found', 'parseinline' , $this->target ) ); |
102 | | - $wgOut->addHTML( Xml::closeElement( 'div' ) ); |
103 | | - } |
104 | 111 | } |
105 | 112 | } |
106 | 113 | |
— | — | @@ -107,22 +114,23 @@ |
108 | 115 | * Input form for entering a category |
109 | 116 | */ |
110 | 117 | function executeInputForm() { |
111 | | - global $wgScript, $wgOut; |
| 118 | + global $wgScript; |
112 | 119 | $thisTitle = SpecialPage::getTitleFor( $this->getName() ); |
113 | 120 | $mode = $this->getOption( 'mode' ); |
114 | 121 | |
115 | | - $wgOut->addHTML( Xml::openElement( 'form', array( 'name' => 'categorytree', 'method' => 'get', 'action' => $wgScript, 'id' => 'mw-categorytree-form' ) ) ); |
116 | | - $wgOut->addHTML( Xml::openElement( 'fieldset' ) ); |
117 | | - $wgOut->addHTML( Xml::element( 'legend', null, wfMsgNoTrans( 'categorytree-legend' ) ) ); |
118 | | - $wgOut->addHTML( Html::Hidden( 'title', $thisTitle->getPrefixedDbKey() ) ); |
119 | | - $wgOut->addHTML( Xml::inputLabel( wfMsgNoTrans( 'categorytree-category' ), 'target', 'target', 20, $this->target ) . ' ' ); |
120 | | - $wgOut->addHTML( Xml::openElement( 'select', array( 'name' => 'mode' ) ) ); |
121 | | - $wgOut->addHTML( Xml::option( wfMsgNoTrans( 'categorytree-mode-categories' ), 'categories', $mode == CT_MODE_CATEGORIES ? true : false ) ); |
122 | | - $wgOut->addHTML( Xml::option( wfMsgNoTrans( 'categorytree-mode-pages' ), 'pages', $mode == CT_MODE_PAGES ? true : false ) ); |
123 | | - $wgOut->addHTML( Xml::option( wfMsgNoTrans( 'categorytree-mode-all' ), 'all', $mode == CT_MODE_ALL ? true : false ) ); |
124 | | - $wgOut->addHTML( Xml::closeElement( 'select' ) . ' ' ); |
125 | | - $wgOut->addHTML( Xml::submitButton( wfMsgNoTrans( 'categorytree-go' ), array( 'name' => 'dotree' ) ) ); |
126 | | - $wgOut->addHTML( Xml::closeElement( 'fieldset' ) ); |
127 | | - $wgOut->addHTML( Xml::closeElement( 'form' ) ); |
| 122 | + $output = $this->getOutput(); |
| 123 | + $output->addHTML( Xml::openElement( 'form', array( 'name' => 'categorytree', 'method' => 'get', 'action' => $wgScript, 'id' => 'mw-categorytree-form' ) ) ); |
| 124 | + $output->addHTML( Xml::openElement( 'fieldset' ) ); |
| 125 | + $output->addHTML( Xml::element( 'legend', null, wfMsgNoTrans( 'categorytree-legend' ) ) ); |
| 126 | + $output->addHTML( Html::Hidden( 'title', $thisTitle->getPrefixedDbKey() ) ); |
| 127 | + $output->addHTML( Xml::inputLabel( wfMsgNoTrans( 'categorytree-category' ), 'target', 'target', 20, $this->target ) . ' ' ); |
| 128 | + $output->addHTML( Xml::openElement( 'select', array( 'name' => 'mode' ) ) ); |
| 129 | + $output->addHTML( Xml::option( wfMsgNoTrans( 'categorytree-mode-categories' ), 'categories', $mode == CT_MODE_CATEGORIES ) ); |
| 130 | + $output->addHTML( Xml::option( wfMsgNoTrans( 'categorytree-mode-pages' ), 'pages', $mode == CT_MODE_PAGES ) ); |
| 131 | + $output->addHTML( Xml::option( wfMsgNoTrans( 'categorytree-mode-all' ), 'all', $mode == CT_MODE_ALL ) ); |
| 132 | + $output->addHTML( Xml::closeElement( 'select' ) . ' ' ); |
| 133 | + $output->addHTML( Xml::submitButton( wfMsgNoTrans( 'categorytree-go' ), array( 'name' => 'dotree' ) ) ); |
| 134 | + $output->addHTML( Xml::closeElement( 'fieldset' ) ); |
| 135 | + $output->addHTML( Xml::closeElement( 'form' ) ); |
128 | 136 | } |
129 | 137 | } |
Index: branches/REL1_19/extensions/CategoryTree/CategoryTree.php |
— | — | @@ -217,6 +217,10 @@ |
218 | 218 | $wgHooks['MakeGlobalVariablesScript'][] = 'efCategoryTreeGetConfigVars'; |
219 | 219 | } |
220 | 220 | |
| 221 | +/** |
| 222 | + * @param $parser Parser |
| 223 | + * @return bool |
| 224 | + */ |
221 | 225 | function efCategoryTreeSetHooks( $parser ) { |
222 | 226 | $parser->setHook( 'categorytree' , 'efCategoryTreeParserHook' ); |
223 | 227 | $parser->setFunctionHook( 'categorytree' , 'efCategoryTreeParserFunction' ); |
— | — | @@ -229,6 +233,10 @@ |
230 | 234 | * If $enc is not given, '' is asumed, which simulates the old call interface, |
231 | 235 | * namely, only providing the mode name or number. |
232 | 236 | * This loads CategoryTreeFunctions.php and calls CategoryTree::ajax() |
| 237 | + * @param $category |
| 238 | + * @param $options array |
| 239 | + * @param $enc string |
| 240 | + * @return AjaxResponse|bool |
233 | 241 | */ |
234 | 242 | function efCategoryTreeAjaxWrapper( $category, $options = array(), $enc = '' ) { |
235 | 243 | global $wgCategoryTreeHTTPCache, $wgSquidMaxage, $wgUseSquid; |
— | — | @@ -254,8 +262,10 @@ |
255 | 263 | |
256 | 264 | /** |
257 | 265 | * Internal function to cap depth |
| 266 | + * @param $mode |
| 267 | + * @param $depth |
| 268 | + * @return int|mixed |
258 | 269 | */ |
259 | | - |
260 | 270 | function efCategoryTreeCapDepth( $mode, $depth ) { |
261 | 271 | global $wgCategoryTreeMaxDepth; |
262 | 272 | |
— | — | @@ -280,6 +290,8 @@ |
281 | 291 | /** |
282 | 292 | * Entry point for the {{#categorytree}} tag parser function. |
283 | 293 | * This is a wrapper around efCategoryTreeParserHook |
| 294 | + * @param $parser Parser |
| 295 | + * @return array|string |
284 | 296 | */ |
285 | 297 | function efCategoryTreeParserFunction( $parser ) { |
286 | 298 | $params = func_get_args(); |
— | — | @@ -297,8 +309,7 @@ |
298 | 310 | if ( preg_match( '/^\s*(\S.*?)\s*=\s*(.*?)\s*$/', $p, $m ) ) { |
299 | 311 | $k = $m[1]; |
300 | 312 | $v = preg_replace( '/^"\s*(.*?)\s*"$/', '$1', $m[2] ); // strip any quotes enclusing the value |
301 | | - } |
302 | | - else { |
| 313 | + } else { |
303 | 314 | $k = trim( $p ); |
304 | 315 | $v = true; |
305 | 316 | } |
— | — | @@ -314,13 +325,16 @@ |
315 | 326 | /** |
316 | 327 | * Hook implementation for injecting a category tree into the sidebar. |
317 | 328 | * Registered automatically if $wgCategoryTreeSidebarRoot is set to a category name. |
| 329 | + * @param $skin |
| 330 | + * @param $tpl SkinTemplate |
| 331 | + * @return bool |
318 | 332 | */ |
319 | 333 | function efCategoryTreeSkinTemplateOutputPageBeforeExec( $skin, $tpl ) { |
320 | 334 | global $wgCategoryTreeSidebarRoot, $wgCategoryTreeSidebarOptions; |
321 | 335 | |
322 | 336 | $html = efCategoryTreeParserHook( $wgCategoryTreeSidebarRoot, $wgCategoryTreeSidebarOptions ); |
323 | 337 | if ( $html ) { |
324 | | - $tpl->data['sidebar']['categorytree-portlet'] = $html; // requires MW 1.13, r36917 |
| 338 | + $tpl->data['sidebar']['categorytree-portlet'] = $html; |
325 | 339 | } |
326 | 340 | |
327 | 341 | return true; |
— | — | @@ -329,6 +343,11 @@ |
330 | 344 | /** |
331 | 345 | * Entry point for the <categorytree> tag parser hook. |
332 | 346 | * This loads CategoryTreeFunctions.php and calls CategoryTree::getTag() |
| 347 | + * @param $cat |
| 348 | + * @param $argv |
| 349 | + * @param $parser Parser |
| 350 | + * @param $allowMissing bool |
| 351 | + * @return bool|string |
333 | 352 | */ |
334 | 353 | function efCategoryTreeParserHook( $cat, $argv, $parser = null, $allowMissing = false ) { |
335 | 354 | global $wgOut; |
— | — | @@ -356,9 +375,12 @@ |
357 | 376 | } |
358 | 377 | |
359 | 378 | /** |
360 | | -* Hook callback that injects messages and things into the <head> tag |
361 | | -* Does nothing if $parserOutput->mCategoryTreeTag is not set |
362 | | -*/ |
| 379 | + * Hook callback that injects messages and things into the <head> tag |
| 380 | + * Does nothing if $parserOutput->mCategoryTreeTag is not set |
| 381 | + * @param $outputPage OutputPage |
| 382 | + * @param $parserOutput ParserOutput |
| 383 | + * @return bool |
| 384 | + */ |
363 | 385 | function efCategoryTreeParserOutput( $outputPage, $parserOutput ) { |
364 | 386 | if ( !empty( $parserOutput->mCategoryTreeTag ) ) { |
365 | 387 | CategoryTree::setHeaders( $outputPage ); |
— | — | @@ -371,6 +393,7 @@ |
372 | 394 | * |
373 | 395 | * @param $title Title |
374 | 396 | * @param $article Article |
| 397 | + * @return bool |
375 | 398 | */ |
376 | 399 | function efCategoryTreeArticleFromTitle( $title, &$article ) { |
377 | 400 | if ( $title->getNamespace() == NS_CATEGORY ) { |
— | — | @@ -381,6 +404,10 @@ |
382 | 405 | |
383 | 406 | /** |
384 | 407 | * OutputPageMakeCategoryLinks hook, override category links |
| 408 | + * @param $out |
| 409 | + * @param $categories |
| 410 | + * @param $links |
| 411 | + * @return bool |
385 | 412 | */ |
386 | 413 | function efCategoryTreeOutputPageMakeCategoryLinks( $out, &$categories, &$links ) { |
387 | 414 | global $wgCategoryTreePageCategoryOptions; |
— | — | @@ -392,6 +419,12 @@ |
393 | 420 | return false; |
394 | 421 | } |
395 | 422 | |
| 423 | +/** |
| 424 | + * @param $skin |
| 425 | + * @param $links |
| 426 | + * @param $result |
| 427 | + * @return bool |
| 428 | + */ |
396 | 429 | function efCategoryTreeSkinJoinCategoryLinks( $skin, &$links, &$result ) { |
397 | 430 | $embed = '<div class="CategoryTreeCategoryBarItem">'; |
398 | 431 | $pop = '</div>'; |
— | — | @@ -402,6 +435,10 @@ |
403 | 436 | return false; |
404 | 437 | } |
405 | 438 | |
| 439 | +/** |
| 440 | + * @param $vars |
| 441 | + * @return bool |
| 442 | + */ |
406 | 443 | function efCategoryTreeGetConfigVars( &$vars ) { |
407 | 444 | global $wgCategoryTreeCategoryPageOptions; |
408 | 445 | |
— | — | @@ -409,4 +446,4 @@ |
410 | 447 | $ct = new CategoryTree( $wgCategoryTreeCategoryPageOptions ); |
411 | 448 | $vars['wgCategoryTreePageCategoryOptions'] = $ct->getOptionsAsJsStructure(); |
412 | 449 | return true; |
413 | | -} |
\ No newline at end of file |
| 450 | +} |
Index: branches/REL1_19/extensions/CategoryTree/modules/ext.categoryTree.js |
— | — | @@ -27,7 +27,7 @@ |
28 | 28 | */ |
29 | 29 | handleNode: function( e ) { |
30 | 30 | var $link = $( this ); |
31 | | - if ( $link.data( 'ctState' ) === 'collapsed' ) { |
| 31 | + if ( $link.data( 'ct-state' ) === 'collapsed' ) { |
32 | 32 | categoryTree.expandNode( $link ); |
33 | 33 | } else { |
34 | 34 | categoryTree.collapseNode( $link ); |
— | — | @@ -48,9 +48,9 @@ |
49 | 49 | $link |
50 | 50 | .html( mw.msg( 'categorytree-collapse-bullet' ) ) |
51 | 51 | .attr( 'title', mw.msg( 'categorytree-collapse' ) ) |
52 | | - .data( 'ctState', 'expanded' ); |
| 52 | + .data( 'ct-state', 'expanded' ); |
53 | 53 | |
54 | | - if ( !$link.data( 'ctLoaded' ) ) { |
| 54 | + if ( !$link.data( 'ct-loaded' ) ) { |
55 | 55 | categoryTree.loadChildren( $link, $children ); |
56 | 56 | } |
57 | 57 | }, |
— | — | @@ -68,7 +68,7 @@ |
69 | 69 | $link |
70 | 70 | .html( mw.msg( 'categorytree-expand-bullet' ) ) |
71 | 71 | .attr( 'title', mw.msg( 'categorytree-expand' ) ) |
72 | | - .data( 'ctState', 'collapsed' ); |
| 72 | + .data( 'ct-state', 'collapsed' ); |
73 | 73 | }, |
74 | 74 | |
75 | 75 | /** |
— | — | @@ -78,26 +78,55 @@ |
79 | 79 | * @param {jQuery} $children |
80 | 80 | */ |
81 | 81 | loadChildren: function( $link, $children ) { |
82 | | - $link.data( 'ctLoaded', true ); |
| 82 | + var $linkParentCTTag, ctTitle, ctMode, ctOptions; |
| 83 | + |
| 84 | + /** |
| 85 | + * Error callback |
| 86 | + */ |
| 87 | + function error() { |
| 88 | + var $retryLink; |
| 89 | + |
| 90 | + $retryLink = $( '<a>' ) |
| 91 | + .text( mw.msg( 'categorytree-retry' ) ) |
| 92 | + .attr( 'href', '#' ) |
| 93 | + .click( function ( e ) { |
| 94 | + e.preventDefault(); |
| 95 | + categoryTree.loadChildren( $link, $children ); |
| 96 | + } ); |
| 97 | + |
| 98 | + $children |
| 99 | + .text( mw.msg( 'categorytree-error' ) + ' ' ) |
| 100 | + .append( $retryLink ); |
| 101 | + } |
| 102 | + |
| 103 | + $link.data( 'ct-loaded', true ); |
| 104 | + |
83 | 105 | $children.html( |
84 | 106 | $( '<i class="CategoryTreeNotice"></i>' ) |
85 | 107 | .text( mw.msg( 'categorytree-loading' ) ) |
86 | 108 | ); |
87 | 109 | |
88 | | - var $parentTag = $link.parents( '.CategoryTreeTag' ); |
| 110 | + $linkParentCTTag = $link.parents( '.CategoryTreeTag' ); |
89 | 111 | |
90 | | - if ( $parentTag.length === 0 ) { |
91 | | - // Probably a CategoryPage |
92 | | - $parentTag = $( '<div />' ) |
93 | | - .hide() |
94 | | - .data( 'ctOptions', mw.config.get( 'wgCategoryTreePageCategoryOptions' ) ); |
| 112 | + // Element may not have a .CategoryTreeTag parent, fallback to defauls |
| 113 | + // Probably a CategoryPage (@todo: based on what?) |
| 114 | + ctTitle = $link.data( 'ct-title' ); |
| 115 | + ctMode = $linkParentCTTag.data( 'ct-mode' ); |
| 116 | + ctMode = typeof ctMode === 'number' ? ctMode : undefined; |
| 117 | + ctOptions = $linkParentCTTag.data( 'ct-options' ) || mw.config.get( 'wgCategoryTreePageCategoryOptions' ); |
| 118 | + |
| 119 | + // Mode and options have defaults or fallbacks, title does not. |
| 120 | + // Don't make a request if there is no title. |
| 121 | + if ( typeof ctTitle !== 'string' ) { |
| 122 | + error(); |
| 123 | + return; |
95 | 124 | } |
96 | 125 | |
97 | 126 | $.get( |
98 | 127 | mw.util.wikiScript(), { |
99 | 128 | action: 'ajax', |
100 | 129 | rs: 'efCategoryTreeAjaxWrapper', |
101 | | - rsargs: [$link.data( 'ctTitle' ), $parentTag.data( 'ctOptions' ), 'json'] // becomes &rsargs[]=arg1&rsargs[]=arg2... |
| 130 | + rsargs: [ctTitle, ctOptions, 'json'] // becomes &rsargs[]=arg1&rsargs[]=arg2... |
102 | 131 | } |
103 | 132 | ) |
104 | 133 | .success( function ( data ) { |
— | — | @@ -105,16 +134,20 @@ |
106 | 135 | data = data.replace(/##LOAD##/g, mw.msg( 'categorytree-expand' ) ); |
107 | 136 | |
108 | 137 | if ( data === '' ) { |
109 | | - switch ( $parentTag.data( 'ctMode' ) ) { |
| 138 | + switch ( ctMode ) { |
| 139 | + // CT_MODE_CATEGORIES = 0 |
110 | 140 | case 0: |
111 | 141 | data = mw.msg( 'categorytree-no-subcategories' ); |
112 | 142 | break; |
| 143 | + // CT_MODE_PAGES = 10 |
113 | 144 | case 10: |
114 | 145 | data = mw.msg( 'categorytree-no-pages' ); |
115 | 146 | break; |
| 147 | + // CT_MODE_PARENTS = 100 |
116 | 148 | case 100: |
117 | 149 | data = mw.msg( 'categorytree-no-parent-categories' ); |
118 | 150 | break; |
| 151 | + // CT_MODE_ALL = 20 |
119 | 152 | default: |
120 | 153 | data = mw.msg( 'categorytree-nothing-found' ); |
121 | 154 | } |
— | — | @@ -126,17 +159,10 @@ |
127 | 160 | .html( data ) |
128 | 161 | .find( '.CategoryTreeToggle' ) |
129 | 162 | .click( categoryTree.handleNode ); |
| 163 | + |
130 | 164 | categoryTree.showToggles(); |
131 | 165 | } ) |
132 | | - .error( function() { |
133 | | - var $retryLink = $( '<a />' ) |
134 | | - .text( mw.msg( 'categorytree-retry' ) ) |
135 | | - .attr( 'href', '#' ) |
136 | | - .click( function() { categoryTree.loadChildren( $link, $children ); } ); |
137 | | - $children |
138 | | - .text( mw.msg( 'categorytree-error' ) ) |
139 | | - .append( $retryLink ); |
140 | | - } ); |
| 166 | + .error( error ); |
141 | 167 | } |
142 | 168 | }; |
143 | 169 | |
Index: branches/REL1_19/extensions/CategoryTree/CategoryTreeFunctions.php |
— | — | @@ -19,6 +19,10 @@ |
20 | 20 | var $mIsAjaxRequest = false; |
21 | 21 | var $mOptions = array(); |
22 | 22 | |
| 23 | + /** |
| 24 | + * @param $options array |
| 25 | + * @param $ajax bool |
| 26 | + */ |
23 | 27 | function __construct( $options, $ajax = false ) { |
24 | 28 | global $wgCategoryTreeDefaultOptions; |
25 | 29 | |
— | — | @@ -56,38 +60,56 @@ |
57 | 61 | } |
58 | 62 | } |
59 | 63 | |
| 64 | + /** |
| 65 | + * @param $name string |
| 66 | + * @return mixed |
| 67 | + */ |
60 | 68 | function getOption( $name ) { |
61 | 69 | return $this->mOptions[$name]; |
62 | 70 | } |
63 | 71 | |
| 72 | + /** |
| 73 | + * @return bool |
| 74 | + */ |
64 | 75 | function isInverse( ) { |
65 | 76 | return $this->getOption( 'mode' ) == CT_MODE_PARENTS; |
66 | 77 | } |
67 | 78 | |
| 79 | + /** |
| 80 | + * @param $nn |
| 81 | + * @return array|bool |
| 82 | + */ |
68 | 83 | static function decodeNamespaces( $nn ) { |
69 | 84 | global $wgContLang; |
70 | 85 | |
71 | | - if ( !$nn ) |
| 86 | + if ( !$nn ) { |
72 | 87 | return false; |
| 88 | + } |
73 | 89 | |
74 | | - if ( !is_array( $nn ) ) |
| 90 | + if ( !is_array( $nn ) ) { |
75 | 91 | $nn = preg_split( '![\s#:|]+!', $nn ); |
| 92 | + } |
76 | 93 | |
77 | 94 | $namespaces = array(); |
78 | 95 | |
79 | 96 | foreach ( $nn as $n ) { |
80 | 97 | if ( is_int( $n ) ) { |
81 | 98 | $ns = $n; |
82 | | - } |
83 | | - else { |
| 99 | + } else { |
84 | 100 | $n = trim( $n ); |
85 | | - if ( $n === '' ) continue; |
| 101 | + if ( $n === '' ) { |
| 102 | + continue; |
| 103 | + } |
86 | 104 | |
87 | 105 | $lower = strtolower( $n ); |
88 | 106 | |
89 | | - if ( is_numeric( $n ) ) $ns = (int)$n; |
90 | | - elseif ( $n == '-' || $n == '_' || $n == '*' || $lower == 'main' ) $ns = NS_MAIN; |
91 | | - else $ns = $wgContLang->getNsIndex( $n ); |
| 107 | + if ( is_numeric( $n ) ) { |
| 108 | + $ns = (int)$n; |
| 109 | + } elseif ( $n == '-' || $n == '_' || $n == '*' || $lower == 'main' ) { |
| 110 | + $ns = NS_MAIN; |
| 111 | + } else { |
| 112 | + $ns = $wgContLang->getNsIndex( $n ); |
| 113 | + } |
92 | 114 | } |
93 | 115 | |
94 | 116 | if ( is_int( $ns ) ) { |
— | — | @@ -99,61 +121,111 @@ |
100 | 122 | return $namespaces; |
101 | 123 | } |
102 | 124 | |
| 125 | + /** |
| 126 | + * @param $mode |
| 127 | + * @return int|string |
| 128 | + */ |
103 | 129 | static function decodeMode( $mode ) { |
104 | 130 | global $wgCategoryTreeDefaultOptions; |
105 | 131 | |
106 | | - if ( is_null( $mode ) ) return $wgCategoryTreeDefaultOptions['mode']; |
107 | | - if ( is_int( $mode ) ) return $mode; |
| 132 | + if ( is_null( $mode ) ) { |
| 133 | + return $wgCategoryTreeDefaultOptions['mode']; |
| 134 | + } |
| 135 | + if ( is_int( $mode ) ) { |
| 136 | + return $mode; |
| 137 | + } |
108 | 138 | |
109 | 139 | $mode = trim( strtolower( $mode ) ); |
110 | 140 | |
111 | | - if ( is_numeric( $mode ) ) return (int)$mode; |
| 141 | + if ( is_numeric( $mode ) ) { |
| 142 | + return (int)$mode; |
| 143 | + } |
112 | 144 | |
113 | | - if ( $mode == 'all' ) $mode = CT_MODE_ALL; |
114 | | - elseif ( $mode == 'pages' ) $mode = CT_MODE_PAGES; |
115 | | - elseif ( $mode == 'categories' || $mode == 'sub' ) $mode = CT_MODE_CATEGORIES; |
116 | | - elseif ( $mode == 'parents' || $mode == 'super' || $mode == 'inverse' ) $mode = CT_MODE_PARENTS; |
117 | | - elseif ( $mode == 'default' ) $mode = $wgCategoryTreeDefaultOptions['mode']; |
| 145 | + if ( $mode == 'all' ) { |
| 146 | + $mode = CT_MODE_ALL; |
| 147 | + } elseif ( $mode == 'pages' ) { |
| 148 | + $mode = CT_MODE_PAGES; |
| 149 | + } elseif ( $mode == 'categories' || $mode == 'sub' ) { |
| 150 | + $mode = CT_MODE_CATEGORIES; |
| 151 | + } elseif ( $mode == 'parents' || $mode == 'super' || $mode == 'inverse' ) { |
| 152 | + $mode = CT_MODE_PARENTS; |
| 153 | + } elseif ( $mode == 'default' ) { |
| 154 | + $mode = $wgCategoryTreeDefaultOptions['mode']; |
| 155 | + } |
118 | 156 | |
119 | 157 | return (int)$mode; |
120 | 158 | } |
121 | 159 | |
122 | 160 | /** |
123 | | - * Helper function to convert a string to a boolean value. |
124 | | - * Perhaps make this a global function in MediaWiki proper |
125 | | - */ |
| 161 | + * Helper function to convert a string to a boolean value. |
| 162 | + * Perhaps make this a global function in MediaWiki proper |
| 163 | + * @param $value |
| 164 | + * @return bool|null|string |
| 165 | + */ |
126 | 166 | static function decodeBoolean( $value ) { |
127 | | - if ( is_null( $value ) ) return null; |
128 | | - if ( is_bool( $value ) ) return $value; |
129 | | - if ( is_int( $value ) ) return ( $value > 0 ); |
| 167 | + if ( is_null( $value ) ) { |
| 168 | + return null; |
| 169 | + } |
| 170 | + if ( is_bool( $value ) ) { |
| 171 | + return $value; |
| 172 | + } |
| 173 | + if ( is_int( $value ) ) { |
| 174 | + return ( $value > 0 ); |
| 175 | + } |
130 | 176 | |
131 | 177 | $value = trim( strtolower( $value ) ); |
132 | | - if ( is_numeric( $value ) ) return ( (int)$value > 0 ); |
| 178 | + if ( is_numeric( $value ) ) { |
| 179 | + return ( (int)$value > 0 ); |
| 180 | + } |
133 | 181 | |
134 | | - if ( $value == 'yes' || $value == 'y' || $value == 'true' || $value == 't' || $value == 'on' ) return true; |
135 | | - elseif ( $value == 'no' || $value == 'n' || $value == 'false' || $value == 'f' || $value == 'off' ) return false; |
136 | | - elseif ( $value == 'null' || $value == 'default' || $value == 'none' || $value == 'x' ) return null; |
137 | | - else return false; |
| 182 | + if ( $value == 'yes' || $value == 'y' || $value == 'true' || $value == 't' || $value == 'on' ) { |
| 183 | + return true; |
| 184 | + } elseif ( $value == 'no' || $value == 'n' || $value == 'false' || $value == 'f' || $value == 'off' ) { |
| 185 | + return false; |
| 186 | + } elseif ( $value == 'null' || $value == 'default' || $value == 'none' || $value == 'x' ) { |
| 187 | + return null; |
| 188 | + } else { |
| 189 | + return false; |
| 190 | + } |
138 | 191 | } |
139 | 192 | |
| 193 | + /** |
| 194 | + * @param $value |
| 195 | + * @return int|string |
| 196 | + */ |
140 | 197 | static function decodeHidePrefix( $value ) { |
141 | 198 | global $wgCategoryTreeDefaultOptions; |
142 | 199 | |
143 | | - if ( is_null( $value ) ) return $wgCategoryTreeDefaultOptions['hideprefix']; |
144 | | - if ( is_int( $value ) ) return $value; |
145 | | - if ( $value === true ) return CT_HIDEPREFIX_ALWAYS; |
146 | | - if ( $value === false ) return CT_HIDEPREFIX_NEVER; |
| 200 | + if ( is_null( $value ) ) { |
| 201 | + return $wgCategoryTreeDefaultOptions['hideprefix']; |
| 202 | + } |
| 203 | + if ( is_int( $value ) ) { |
| 204 | + return $value; |
| 205 | + } |
| 206 | + if ( $value === true ) { |
| 207 | + return CT_HIDEPREFIX_ALWAYS; |
| 208 | + } |
| 209 | + if ( $value === false ) { |
| 210 | + return CT_HIDEPREFIX_NEVER; |
| 211 | + } |
147 | 212 | |
148 | 213 | $value = trim( strtolower( $value ) ); |
149 | 214 | |
150 | | - if ( $value == 'yes' || $value == 'y' || $value == 'true' || $value == 't' || $value == 'on' ) return CT_HIDEPREFIX_ALWAYS; |
151 | | - elseif ( $value == 'no' || $value == 'n' || $value == 'false' || $value == 'f' || $value == 'off' ) return CT_HIDEPREFIX_NEVER; |
152 | | - // elseif ( $value == 'null' || $value == 'default' || $value == 'none' || $value == 'x' ) return $wgCategoryTreeDefaultOptions['hideprefix']; |
153 | | - elseif ( $value == 'always' ) return CT_HIDEPREFIX_ALWAYS; |
154 | | - elseif ( $value == 'never' ) return CT_HIDEPREFIX_NEVER; |
155 | | - elseif ( $value == 'auto' ) return CT_HIDEPREFIX_AUTO; |
156 | | - elseif ( $value == 'categories' || $value == 'category' || $value == 'smart' ) return CT_HIDEPREFIX_CATEGORIES; |
157 | | - else return $wgCategoryTreeDefaultOptions['hideprefix']; |
| 215 | + if ( $value == 'yes' || $value == 'y' || $value == 'true' || $value == 't' || $value == 'on' ) { |
| 216 | + return CT_HIDEPREFIX_ALWAYS; |
| 217 | + } elseif ( $value == 'no' || $value == 'n' || $value == 'false' || $value == 'f' || $value == 'off' ) { |
| 218 | + return CT_HIDEPREFIX_NEVER; |
| 219 | + } elseif ( $value == 'always' ) { |
| 220 | + return CT_HIDEPREFIX_ALWAYS; |
| 221 | + } elseif ( $value == 'never' ) { |
| 222 | + return CT_HIDEPREFIX_NEVER; |
| 223 | + } elseif ( $value == 'auto' ) { |
| 224 | + return CT_HIDEPREFIX_AUTO; |
| 225 | + } elseif ( $value == 'categories' || $value == 'category' || $value == 'smart' ) { |
| 226 | + return CT_HIDEPREFIX_CATEGORIES; |
| 227 | + } else { |
| 228 | + return $wgCategoryTreeDefaultOptions['hideprefix']; |
| 229 | + } |
158 | 230 | } |
159 | 231 | |
160 | 232 | /** |
— | — | @@ -167,24 +239,16 @@ |
168 | 240 | } |
169 | 241 | |
170 | 242 | /** |
171 | | - * @return Services_JSON |
| 243 | + * @param $options |
| 244 | + * @param $enc |
| 245 | + * @return mixed |
| 246 | + * @throws MWException |
172 | 247 | */ |
173 | | - static function getJsonCodec() { |
174 | | - static $json = null; |
175 | | - |
176 | | - if ( !$json ) { |
177 | | - $json = new Services_JSON(); # recycle API's JSON codec implementation |
178 | | - } |
179 | | - |
180 | | - return $json; |
181 | | - } |
182 | | - |
183 | 248 | static function encodeOptions( $options, $enc ) { |
184 | 249 | if ( $enc == 'mode' || $enc == '' ) { |
185 | 250 | $opt = $options['mode']; |
186 | 251 | } elseif ( $enc == 'json' ) { |
187 | | - $json = self::getJsonCodec(); // XXX: this may be a bit heavy... |
188 | | - $opt = $json->encode( $options ); |
| 252 | + $opt = FormatJson::encode( $options ); |
189 | 253 | } else { |
190 | 254 | throw new MWException( 'Unknown encoding for CategoryTree options: ' . $enc ); |
191 | 255 | } |
— | — | @@ -192,12 +256,17 @@ |
193 | 257 | return $opt; |
194 | 258 | } |
195 | 259 | |
| 260 | + /** |
| 261 | + * @param $options |
| 262 | + * @param $enc |
| 263 | + * @return array|mixed |
| 264 | + * @throws MWException |
| 265 | + */ |
196 | 266 | static function decodeOptions( $options, $enc ) { |
197 | 267 | if ( $enc == 'mode' || $enc == '' ) { |
198 | 268 | $opt = array( "mode" => $options ); |
199 | 269 | } elseif ( $enc == 'json' ) { |
200 | | - $json = self::getJsonCodec(); // XXX: this may be a bit heavy... |
201 | | - $opt = $json->decode( $options ); |
| 270 | + $opt = FormatJson::decode( $options ); |
202 | 271 | $opt = get_object_vars( $opt ); |
203 | 272 | } else { |
204 | 273 | throw new MWException( 'Unknown encoding for CategoryTree options: ' . $enc ); |
— | — | @@ -206,6 +275,10 @@ |
207 | 276 | return $opt; |
208 | 277 | } |
209 | 278 | |
| 279 | + /** |
| 280 | + * @param $depth null |
| 281 | + * @return string |
| 282 | + */ |
210 | 283 | function getOptionsAsCacheKey( $depth = null ) { |
211 | 284 | $key = ""; |
212 | 285 | |
— | — | @@ -214,10 +287,16 @@ |
215 | 288 | $key .= $k . ':' . $v . ';'; |
216 | 289 | } |
217 | 290 | |
218 | | - if ( !is_null( $depth ) ) $key .= ";depth=" . $depth; |
| 291 | + if ( !is_null( $depth ) ) { |
| 292 | + $key .= ";depth=" . $depth; |
| 293 | + } |
219 | 294 | return $key; |
220 | 295 | } |
221 | 296 | |
| 297 | + /** |
| 298 | + * @param $depthnull |
| 299 | + * @return mixed |
| 300 | + */ |
222 | 301 | function getOptionsAsJsStructure( $depth = null ) { |
223 | 302 | if ( !is_null( $depth ) ) { |
224 | 303 | $opt = $this->mOptions; |
— | — | @@ -230,10 +309,17 @@ |
231 | 310 | return $s; |
232 | 311 | } |
233 | 312 | |
234 | | - function getOptionsAsJsString( $depth = NULL ) { |
| 313 | + /** |
| 314 | + * @param $depth null |
| 315 | + * @return String |
| 316 | + */ |
| 317 | + function getOptionsAsJsString( $depth = null ) { |
235 | 318 | return Xml::escapeJsString( $this->getOptionsAsJsStructure( $depth ) ); |
236 | 319 | } |
237 | 320 | |
| 321 | + /** |
| 322 | + * @return string |
| 323 | + */ |
238 | 324 | function getOptionsAsUrlParameters() { |
239 | 325 | $u = ''; |
240 | 326 | |
— | — | @@ -246,9 +332,12 @@ |
247 | 333 | } |
248 | 334 | |
249 | 335 | /** |
250 | | - * Ajax call. This is called by efCategoryTreeAjaxWrapper, which is used to |
251 | | - * load CategoryTreeFunctions.php on demand. |
252 | | - */ |
| 336 | + * Ajax call. This is called by efCategoryTreeAjaxWrapper, which is used to |
| 337 | + * load CategoryTreeFunctions.php on demand. |
| 338 | + * @param $category |
| 339 | + * @param $depth int |
| 340 | + * @return AjaxResponse|bool |
| 341 | + */ |
253 | 342 | function ajax( $category, $depth = 1 ) { |
254 | 343 | global $wgLang, $wgContLang, $wgRenderHashAppend; |
255 | 344 | $title = self::makeTitle( $category ); |
— | — | @@ -266,7 +355,12 @@ |
267 | 356 | 'page_title' => $dbkey, |
268 | 357 | ), __METHOD__ ); |
269 | 358 | |
270 | | - $mckey = wfMemcKey( "categorytree(" . $this->getOptionsAsCacheKey( $depth ) . ")", $dbkey, $wgLang->getCode(), $wgContLang->getExtraHashOptions(), $wgRenderHashAppend ); |
| 359 | + $mckey = wfMemcKey( |
| 360 | + "categorytree(" . $this->getOptionsAsCacheKey( $depth ) . ")", |
| 361 | + $dbkey, $wgLang->getCode(), |
| 362 | + $wgContLang->getExtraHashOptions(), |
| 363 | + $wgRenderHashAppend |
| 364 | + ); |
271 | 365 | |
272 | 366 | $response = new AjaxResponse(); |
273 | 367 | |
— | — | @@ -330,19 +424,19 @@ |
331 | 425 | } |
332 | 426 | |
333 | 427 | $attr['data-ct-mode'] = $this->mOptions['mode']; |
334 | | - $attr['data-ct-options'] = Xml::escapeTagsOnly( $this->getOptionsAsJsStructure() ); |
| 428 | + $attr['data-ct-options'] = $this->getOptionsAsJsStructure(); |
335 | 429 | |
336 | 430 | $html = ''; |
337 | | - $html .= Xml::openElement( 'div', $attr ); |
| 431 | + $html .= Html::openElement( 'div', $attr ); |
338 | 432 | |
339 | 433 | if ( !$allowMissing && !$title->getArticleID() ) { |
340 | | - $html .= Xml::openElement( 'span', array( 'class' => 'CategoryTreeNotice' ) ); |
| 434 | + $html .= Html::openElement( 'span', array( 'class' => 'CategoryTreeNotice' ) ); |
341 | 435 | if ( $parser ) { |
342 | 436 | $html .= $parser->recursiveTagParse( wfMsgNoTrans( 'categorytree-not-found', $category ) ); |
343 | 437 | } else { |
344 | 438 | $html .= wfMsgExt( 'categorytree-not-found', 'parseinline', htmlspecialchars( $category ) ); |
345 | 439 | } |
346 | | - $html .= Xml::closeElement( 'span' ); |
| 440 | + $html .= Html::closeElement( 'span' ); |
347 | 441 | } |
348 | 442 | else { |
349 | 443 | if ( !$hideroot ) { |
— | — | @@ -368,9 +462,11 @@ |
369 | 463 | } |
370 | 464 | |
371 | 465 | /** |
372 | | - * Returns a string with an HTML representation of the children of the given category. |
373 | | - * @param $title Title |
374 | | - */ |
| 466 | + * Returns a string with an HTML representation of the children of the given category. |
| 467 | + * @param $title Title |
| 468 | + * @param $depth int |
| 469 | + * @return string |
| 470 | + */ |
375 | 471 | function renderChildren( $title, $depth = 1 ) { |
376 | 472 | global $wgCategoryTreeMaxChildren, $wgCategoryTreeUseCategoryTable; |
377 | 473 | |
— | — | @@ -459,9 +555,10 @@ |
460 | 556 | } |
461 | 557 | |
462 | 558 | /** |
463 | | - * Returns a string with an HTML representation of the parents of the given category. |
464 | | - * @var $title Title |
465 | | - */ |
| 559 | + * Returns a string with an HTML representation of the parents of the given category. |
| 560 | + * @param $title Title |
| 561 | + * @return string |
| 562 | + */ |
466 | 563 | function renderParents( $title ) { |
467 | 564 | global $wgCategoryTreeMaxChildren; |
468 | 565 | |
— | — | @@ -513,9 +610,12 @@ |
514 | 611 | } |
515 | 612 | |
516 | 613 | /** |
517 | | - * Returns a string with a HTML represenation of the given page. |
518 | | - * $title must be a Title object |
519 | | - */ |
| 614 | + * Returns a string with a HTML represenation of the given page. |
| 615 | + * @param $title Title |
| 616 | + * @param int $children |
| 617 | + * @param bool $loadchildren |
| 618 | + * @return string |
| 619 | + */ |
520 | 620 | function renderNode( $title, $children = 0, $loadchildren = false ) { |
521 | 621 | global $wgCategoryTreeUseCategoryTable; |
522 | 622 | |
— | — | @@ -529,9 +629,14 @@ |
530 | 630 | } |
531 | 631 | |
532 | 632 | /** |
533 | | - * Returns a string with a HTML represenation of the given page. |
534 | | - * $info must be an associative array, containing at least a Title object under the 'title' key. |
535 | | - */ |
| 633 | + * Returns a string with a HTML represenation of the given page. |
| 634 | + * $info must be an associative array, containing at least a Title object under the 'title' key. |
| 635 | + * @param $title Title |
| 636 | + * @param $cat Category |
| 637 | + * @param $children int |
| 638 | + * @param $loadchildren bool |
| 639 | + * @return string |
| 640 | + */ |
536 | 641 | function renderNodeInfo( $title, $cat, $children = 0, $loadchildren = false ) { |
537 | 642 | static $uniq = 0; |
538 | 643 | |
— | — | @@ -739,8 +844,10 @@ |
740 | 845 | } |
741 | 846 | |
742 | 847 | /** |
743 | | - * Creates a Title object from a user provided (and thus unsafe) string |
744 | | - */ |
| 848 | + * Creates a Title object from a user provided (and thus unsafe) string |
| 849 | + * @param $title string |
| 850 | + * @return null|Title |
| 851 | + */ |
745 | 852 | static function makeTitle( $title ) { |
746 | 853 | $title = trim( $title ); |
747 | 854 | |
Property changes on: branches/REL1_19/extensions/CategoryTree/CategoryTreeFunctions.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
748 | 855 | Merged /trunk/extensions/CategoryTree/CategoryTreeFunctions.php:r111011,111218,112520,112524,112660,112687,112751,112770-112771,112775,112849,112851,112856,112859,112903,112925,112993 |
Property changes on: branches/REL1_19/extensions |
___________________________________________________________________ |
Modified: svn:mergeinfo |
749 | 856 | Merged /trunk/extensions:r111011,112520,112524,112660,112687,112751,112770-112771,112775,112849,112851,112856,112859,112903,112925,112993 |