Dies ist eine alte Version des Dokuments!
DokuWiki
Plugin sidebar
Keine störende Sidebar in Admin und Edit
Die neue action.php:
<?php /** * Sidebar Action Plugin * * @license GPLv3 (http://www.gnu.org/licenses/gpl.html) * @link http://www.dokuwiki.org/plugin:sidebar * @author Markus Birth <markus@birth-online.de> * @author Christopher Smith <chris@jalakai.co.uk> */ if(!defined('DOKU_INC')) die(); if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); require_once(DOKU_PLUGIN.'action.php'); class action_plugin_sidebar extends DokuWiki_Action_Plugin { protected static $done = false; /** * return some info */ function getInfo(){ return confToHash(dirname(__FILE__).'/INFO.txt'); } /** * plugin should use this method to register its handlers with the dokuwiki's event controller */ public function register(dokuwiki\Extension\EventHandler $controller) { $controller->register_hook('TPL_ACT_RENDER', 'AFTER', $this, '_output'); } function _debug(&$event, $param) { ptln($param); ptln(''); } function _output(&$event, $param) { // ### ANPASSUNG START ### // Verhindert die Anzeige der Sidebar im Admin-Bereich, beim Editieren UND in der Vorschau global $ACT; if ($ACT == 'admin' || $ACT == 'edit' || $ACT == 'preview') return; // ### ANPASSUNG ENDE ### if (!$this->getConf('enable') || self::$done) return; self::$done = true; // prevent recursive calls when doing tpl_content() later on $bodyClass = 'sidebar sidebar_' . $this->getConf('layout') . '_' . $this->getConf('orientation'); ptln('</div>', 2); // close the main content area ptln('<script type="text/javascript">', 2); ptln('var body = document.getElementsByTagName(\'BODY\')[0].className = \'' . $bodyClass . '\';', 4); ptln('</script>', 2); ptln('<style type="text/css" media="print">', 2); ptln('#sidebar { display: none; }', 4); ptln('</style>', 2); ptln('<div id="sidebar">', 2); ptln('<div id="sidebartop">', 4); $this->tpl_sidebar_editbtn(); ptln('</div>', 4); ptln('<div id="sidebar_content">', 4); $this->tpl_sidebar_content(); ptln('</div>', 4); // the </div> for closing the "sidebar"-div will be provided by DokuWiki main template } // recursive function to establish best sidebar file to be used function getSidebarFN($ns, $file) { // check for wiki page = $ns:$file (or $file where no namespace) $nsFile = ($ns) ? "$ns:$file" : $file; if (file_exists(wikiFN($nsFile)) && auth_quickaclcheck($nsFile)) return $nsFile; // no namespace left, exit with no file found if (!$ns) return ''; // remove deepest namespace level and call function recursively $i = strrpos($ns, ":"); $ns = ($i) ? substr($ns, 0, $i) : false; return $this->getSidebarFN($ns, $file); } // print a sidebar edit button - if appropriate function tpl_sidebar_editbtn() { global $ID; // check sidebar configuration if (!$this->getConf('showeditbtn') || !$this->getConf('page')) return; // check sidebar page exists $fileSidebar = $this->getSidebarFN(getNS($ID), $this->getConf('page')); if (!$fileSidebar) return; // check user has edit permission for the sidebar page if (auth_quickaclcheck($fileSidebar) < AUTH_EDIT) return; ptln('<div class="secedit">', 6); ptln('<form class="button" method="post" action="' . wl($fileSidebar, 'do=edit') . '" onsubmit="return svchk()">', 8); ptln('<input type="hidden" name="do" value="edit" />', 10); ptln('<input type="hidden" name="rev" value="" />', 10); ptln('<input type="hidden" name="id" value="' . $fileSidebar . '" />', 10); ptln('<input type="submit" value="' . $this->getConf('editbtntxt') . '" class="button" />', 10); ptln('</form>', 8); ptln('</div>', 6); } // display the sidebar function tpl_sidebar_content() { global $ID, $REV, $ACT, $conf; // save globals $saveID = $ID; $saveREV = $REV; $saveACT = $ACT; // discover file to be displayed in navigation sidebar $fileSidebar = ''; if ($this->getConf('page')) { $fileSidebar = $this->getSidebarFN(getNS($ID), $this->getConf('page')); } // determine what to display if ($fileSidebar) { $ID = $fileSidebar; $REV = ''; $ACT = 'show'; // ptln(p_wiki_xhtml($ID, $REV, false)); tpl_content(); } else { # global $IDX; # html_index($IDX); # $ID = getNS($ID); $REV = ''; $ACT = 'index'; tpl_content(); } // restore globals $ID = $saveID; $REV = $saveREV; $ACT = $saveACT; } }
Sidebar positionieren
die neue style.css:
/** * Extra styles for sidebar template * * @author Christopher Smith <chris@jalakai.co.uk> */ /* dokuwiki containers & styles */ /* sidebar orientation and position */ #sidebar { width:8%; margin:0; padding:0; position: relative; } #sidebartop { position: absolute; top: -17em; width: 100%; height: 1.2em; background: __background_neu__; } .sidebar_inside_left #sidebar { float:left; } .sidebar_inside_right #sidebar { float:right; } .sidebar_inside_left .dokuwiki div.breadcrumbs { float: right; width: 78%; padding: 0 1% 0 0.9%; } .sidebar_inside_left .dokuwiki .page, .sidebar_inside_left .dokuwiki .meta { float:right; width:77%; /* also see IE Win fix below */ margin-right: 1%; margin-left:0; } .sidebar_inside_right .dokuwiki .page, .sidebar_inside_right .dokuwiki .meta, .sidebar_inside_right .dokuwiki div.breadcrumbs { float:left; width:77%; margin-left: 1%; margin-right: 0; } .sidebar_outside_left #sidebar { position:absolute; top:11em; left:30em; } .sidebar_outside_right #sidebar { position:absolute; top:0; right:0; } .sidebar_outside_left .dokuwiki { padding-left:21%; } .sidebar_outside_right .dokuwiki { padding-right:21%; } .sidebar_outside_left .footerinc { padding-left: 21%; } .sidebar_outside_right .footerinc { padding-right: 21%; } /* sidebar presentation */ /* the following three styles use a faux-column image to place a separating line between the sidebar and dokuwiku */ .sidebar_outside_left .dokuwiki, .sidebar_inside_left .dokuwiki { background: url(images/sidebar-border.gif) repeat-y 20%; } .sidebar_outside_right .dokuwiki, .sidebar_inside_right .dokuwiki { background: url(images/sidebar-border.gif) repeat-y 80%; } /* hide the line where it passes through .stylehead */ .stylehead { background: __background__; } /* sidebar contents */ #sidebar { font-size:10px; } #sidebar a { color: __existing__; } #sidebar a.wikilink2 { color: __text_neu__; } #sidebar a.wikilink2:hover { text-decoration:none; cursor:default; } #sidebar h1 { font-size:140%; margin-left: 0px; padding-left: 2px; font-weight:bold; padding-bottom:0; background-color: __background_alt__; } #sidebar h2 { font-size:120%; margin-left: 4px; font-weight:bold; padding-bottom:0; } #sidebar h3 { font-size:120%; margin-left: 8px; font-weight:normal; padding-bottom:0; } #sidebar h4 { font-size:100%; margin-left: 12px; font-weight:bold; padding-bottom:0; } #sidebar h5 { font-size:100%; margin-left: 16px; font-weight:normal; padding-bottom:0; } #sidebar .toc { display:none; } #sidebar .secedit { } /* reduced section indentation */ #sidebar div.level1 {margin-left: 2px;} #sidebar div.level2 {margin-left: 6px;} #sidebar div.level3 {margin-left: 10px;} #sidebar div.level4 {margin-left: 14px;} #sidebar div.level5 {margin-left: 18px;} /* IE fixes (hide from IE Mac) \*/ * html .page .toc {height:1px} /* General Dokuwiki fix. IE needs this to always display TOC contents \*/ * html pre {width:95%;} /* General Dokuwiki fix - very important for Sidebar. IE needs this to get the overflow:auto style to kick in \*/ * html .stylehead {height:1px;} /* Get IE in hasLayout mode to ensure the background covers the whole element \*/ * html .sidebar_inside_left .page, * html .sidebar_inside_right .page, * html .sidebar_inside_left .meta, * html .sidebar_inside_right .meta { width: 77%; /* IE needs extra gap to ensure #sidebar & .page float next to each other \*/ overflow-x: auto; /* IE proprietary property to prevent wide images in wiki page forcing sidebar down below wiki page \*/ /* 'overflow-x:auto;' maybe replaced by 'overflow:auto;' to ensure template passes w3c validation \*/ } /* (end IE Mac hiding) */ /* duplicate standard DW styles with increased specificity to counter some sidebar styles */ .sidebar_outside_left .insitu-footnote, .sidebar_inside_left .insitu-footnote { background-color: __background_other__; } /* counteract some inappropriate DW styling */ .sidebar div.dokuwiki #bar__bottom { margin-bottom: 0; } .sidebar div.dokuwiki p.license { background-color: __background_other__; padding-top: 3px; }
