/** * Retrieves code for embedding widget in current view. * * @throws http_exception on trying to access missing page * @return string code embeddable in view */ public function getCode() { if ($this->mayEdit && $this->wantEdit) { return markup::h2(\de\toxa\txf\_L('Edit Page')) . $this->getEditor()->render(); } else { $page = $this->getPage(); if (!$page) { if ($this->mayEdit) { return markup::block(markup::emphasize(\de\toxa\txf\_L('Selected page does not exist, yet!')), 'missing-page-content') . ($this->editorUrl ? $this->getLinkToEditor() : ''); } throw new http_exception(404); } $content = markup::block($page->content, 'page-content'); if ($this->editorUrl && $this->mayEdit) { $content .= $this->getLinkToEditor(); } return $content; } }