Index: trunk/phase3/includes/api/ApiParse.php |
— | — | @@ -373,9 +373,9 @@ |
374 | 374 | } |
375 | 375 | |
376 | 376 | private function categoriesHtml( $categories ) { |
377 | | - global $wgOut, $wgUser; |
378 | | - $wgOut->addCategoryLinks( $categories ); |
379 | | - return $wgUser->getSkin()->getCategories(); |
| 377 | + $context = $this->createContext(); |
| 378 | + $context->getOutput()->addCategoryLinks( $categories ); |
| 379 | + return $context->getSkin()->getCategories(); |
380 | 380 | } |
381 | 381 | |
382 | 382 | /** |
Index: trunk/phase3/includes/api/ApiBase.php |
— | — | @@ -174,6 +174,24 @@ |
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
| 178 | + * Create a new RequestContext object to use e.g. for calls to other parts |
| 179 | + * the software. |
| 180 | + * The object will have the WebRequest and the User object set to the ones |
| 181 | + * used in this instance. |
| 182 | + * |
| 183 | + * @return RequestContext |
| 184 | + */ |
| 185 | + public function createContext() { |
| 186 | + global $wgUser; |
| 187 | + |
| 188 | + $context = new RequestContext; |
| 189 | + $context->setRequest( $this->getMain()->getRequest() ); |
| 190 | + $context->setUser( $wgUser ); /// @todo FIXME: we should store the User object |
| 191 | + |
| 192 | + return $context; |
| 193 | + } |
| 194 | + |
| 195 | + /** |
178 | 196 | * Set warning section for this module. Users should monitor this |
179 | 197 | * section to notice any changes in API. Multiple calls to this |
180 | 198 | * function will result in the warning messages being separated by |