register_hook('PLUGIN_STRUCT_RENDER_SCHEMA_DATA', 'AFTER', $this, 'renderBanner'); } /** * Add banner to struct data of a page * * @return bool */ public function renderBanner(Doku_Event $event) { global $ID; global $INFO; $data = $event->data; if (!$data['hasdata'] || $data['format'] !== 'xhtml') return true; /** @var Doku_Renderer_xhtml $renderer */ $renderer = $data['renderer']; $renderer->nocache(); $this->permissionsHelper = plugin_load('helper', 'structpublish_permissions'); if (!$this->permissionsHelper->isPublishable()) return true; $revision = new Revision($this->permissionsHelper->getDb(), $ID, $INFO['currentrev']); $html = $this->getBannerHtml($revision); $renderer->doc .= $html; return true; } /** * @param Revision $revision * @return string */ protected function getBannerHtml($revision) { global $ID; // FIXME use $INFO? $user = $_SERVER['REMOTE_USER']; $html = ''; if ($this->permissionsHelper->isPublisher($ID, $user)) { $actionLinks = $this->linksToHtml($this->permissionsHelper->getActionLinks($revision)); $html = sprintf( $this->getBannerTemplate(), $revision->getStatus(), $revision->getVersion(), $revision->getStatus(), $actionLinks ); } return $html; } protected function linksToHtml($links) { $html = ''; if (empty($links)) return $html; foreach ($links as $action => $link) { $html .= ''. $action .''; } return $html; } protected function getBannerTemplate() { $template = '
'; return $template; } }