public function executeIndex() { //fb#1090 $this->response->setVal('showMenu', $this->wg->User->isAllowed('read') && !($this->wg->IsPrivateWiki && $this->wg->User->isAnon())); $model = new NavigationModel(); $this->response->setVal('wikiMenuNodes', $model->getWiki($this->request->getVal('msgName', false), $this->request->getVal('wikitext', ''))); // report wiki nav parse errors (BugId:15240) $this->response->setVal('parseErrors', $model->getErrors()); }
/** * Fetches wiki navigation * * @responseParam array $navigation Wiki Navigation * * @example */ public function getData() { $model = new NavigationModel(); $nav = $model->getWiki(); $ret = array(); foreach ($nav as $type => $list) { $ret[$type] = $this->getChildren($list); } $this->setResponseData(['navigation' => $ret], ['urlFields' => 'href'], NavigationModel::CACHE_TTL); $errors = $model->getErrors(); if (!empty($errors)) { throw new InvalidDataApiException(implode(', ', array_keys($errors))); } }
/** * @group Slow * @slowExecutionTime 0.03666 ms * @group UsingDB */ function testParseErrors() { $model = new NavigationModel(); $this->assertEmpty($model->getErrors()); // magic words are not allowed on level #1 $nodes = $model->parseText("*#category1"); $this->assertTrue($model->getErrors()[NavigationModel::ERR_MAGIC_WORD_IN_LEVEL_1]); // magic words are allowed on level #2 $nodes = $model->parseText("*foo\n**#category1"); $this->assertEmpty($model->getErrors()); }