/** * Load a wiki with default content * This is largely Help pages * * @param string $option Component name * @return string */ public function scribe($option) { $pages = $this->_defaultPages(); if (count($pages) <= 0) { return Lang::txt('No default pages found'); } $p = Parser::getInstance(); foreach ($pages as $f => $c) { $f = str_replace('_', ':', $f); // Instantiate a new page $page = new Tables\Page($this->_db); $page->pagename = $f; $page->title = $page->getTitle(); $page->access = 0; if ($this->_scope != '__site__') { $page->group_cn = $this->_scope; $page->scope = $this->_scope . '/wiki'; } if ($this->_scope == '__site__' && $page->pagename == 'MainPage') { $page->params = 'mode=static' . "\n"; } else { $page->params = 'mode=wiki' . "\n"; } // Check content if (!$page->check()) { throw new Exception($page->getError(), 500); } // Store content if (!$page->store()) { throw new Exception($page->getError(), 500); } // Ensure we have a page ID if (!$page->id) { $page->id = $this->_db->insertid(); } // Instantiate a new revision $revision = new Tables\Revision($this->_db); $revision->pageid = $page->id; $revision->minor_edit = 0; $revision->version = 1; $revision->pagetext = $c; $revision->approved = 1; $wikiconfig = array('option' => $option, 'scope' => $page->scope, 'pagename' => $page->pagename, 'pageid' => $page->id, 'filepath' => '', 'domain' => $page->group_cn); // Transform the wikitext to HTML if ($page->pagename != 'Help:WikiMath') { $revision->pagehtml = $p->parse($revision->pagetext, $wikiconfig, true, true); } // Check content if (!$revision->check()) { throw new Exception($revision->getError(), 500); } // Store content if (!$revision->store()) { throw new Exception($revision->getError(), 500); } $page->version_id = $revision->id; $page->modified = $revision->created; if (!$page->store()) { // This really shouldn't happen. throw new Exception($page->getError(), 500); } } return null; }