Index: branches/RL2/extensions/Gadgets/GadgetHooks.php |
— | — | @@ -226,7 +226,7 @@ |
227 | 227 | $options = array(); // array( desc1 => gadget1, category1 => array( desc2 => gadget2 ) ) |
228 | 228 | foreach ( $categories as $category => $gadgets ) { |
229 | 229 | if ( $category !== '' ) { |
230 | | - $categoryMsg = htmlspecialchars( GadgetRepo::getCategoryTitle( $category ) ); |
| 230 | + $categoryMsg = htmlspecialchars( $repo->getCategoryTitle( $category ) ); |
231 | 231 | $options[$categoryMsg] = $gadgets; |
232 | 232 | } else { |
233 | 233 | $options += $gadgets; |
Index: branches/RL2/extensions/Gadgets/backend/LocalGadgetRepo.php |
— | — | @@ -158,7 +158,32 @@ |
159 | 159 | return wfGetDB( DB_SLAVE ); |
160 | 160 | } |
161 | 161 | |
| 162 | + /*** Public methods ***/ |
162 | 163 | |
| 164 | + /** |
| 165 | + * Get the localized title for a given category in a given language. |
| 166 | + * |
| 167 | + * The "gadgetcategory-$category" message is used, if it exists. |
| 168 | + * If it doesn't exist, ucfirst( $category ) is returned. |
| 169 | + * |
| 170 | + * @param $category string Category ID |
| 171 | + * @param $lang string Language code. If null, $wgLang is used |
| 172 | + * @return string Localized category title |
| 173 | + */ |
| 174 | + public function getCategoryTitle( $category, $lang = null ) { |
| 175 | + $msg = wfMessage( "gadgetcategory-$category" ); |
| 176 | + if ( $lang !== null ) { |
| 177 | + $msg = $msg->inLanguage( $lang ); |
| 178 | + } |
| 179 | + if ( !$msg->exists() ) { |
| 180 | + global $wgLang; |
| 181 | + $langObj = $lang === null ? $wgLang : Language::factory( $lang ); |
| 182 | + return $langObj->ucfirst( $category ); |
| 183 | + } |
| 184 | + return $msg->plain(); |
| 185 | + } |
| 186 | + |
| 187 | + |
163 | 188 | /*** Protected methods ***/ |
164 | 189 | |
165 | 190 | /** |
Index: branches/RL2/extensions/Gadgets/backend/GadgetRepo.php |
— | — | @@ -90,29 +90,6 @@ |
91 | 91 | /*** Public static methods ***/ |
92 | 92 | |
93 | 93 | /** |
94 | | - * Get the localized title for a given category in a given language. |
95 | | - * |
96 | | - * The "gadgetcategory-$category" message is used, if it exists. |
97 | | - * If it doesn't exist, ucfirst( $category ) is returned. |
98 | | - * |
99 | | - * @param $category string Category ID |
100 | | - * @param $lang string Language code. If null, $wgLang is used |
101 | | - * @return string Localized category title |
102 | | - */ |
103 | | - public static function getCategoryTitle( $category, $lang = null ) { |
104 | | - $msg = wfMessage( "gadgetcategory-$category" ); |
105 | | - if ( $lang !== null ) { |
106 | | - $msg = $msg->inLanguage( $lang ); |
107 | | - } |
108 | | - if ( !$msg->exists() ) { |
109 | | - global $wgLang; |
110 | | - $langObj = $lang === null ? $wgLang : Language::factory( $lang ); |
111 | | - return $langObj->ucfirst( $category ); |
112 | | - } |
113 | | - return $msg->plain(); |
114 | | - } |
115 | | - |
116 | | - /** |
117 | 94 | * Get all gadget repositories. Returns the LocalGadgetRepo singleton and any |
118 | 95 | * repositories configured in $wgGadgetRepositories |
119 | 96 | * @return array of GadgetRepo objects |
Index: branches/RL2/extensions/Gadgets/api/ApiQueryGadgetCategories.php |
— | — | @@ -56,7 +56,7 @@ |
57 | 57 | if ( $category === '' ) { |
58 | 58 | $row['title'] = wfMessage( 'gadgetmanager-uncategorized' )->plain(); |
59 | 59 | } else { |
60 | | - $row['title'] = GadgetRepo::getCategoryTitle( $category, $this->language ); |
| 60 | + $row['title'] = $repo->getCategoryTitle( $category, $this->language ); |
61 | 61 | } |
62 | 62 | } |
63 | 63 | if ( isset( $this->props['members'] ) ) { |
Index: branches/RL2/extensions/Gadgets/SpecialGadgetManager.php |
— | — | @@ -68,7 +68,7 @@ |
69 | 69 | // Avoid broken or empty headings. Fallback to a special message |
70 | 70 | // for uncategorized gadgets (e.g. gadgets with category '' ). |
71 | 71 | if ( $category !== '' ) { |
72 | | - $categoryTitle = GadgetRepo::getCategoryTitle( $category ); |
| 72 | + $categoryTitle = $repo->getCategoryTitle( $category ); |
73 | 73 | } else { |
74 | 74 | $categoryTitle = wfMessage( 'gadgetmanager-uncategorized' )->plain(); |
75 | 75 | } |