Skip to content

Commit

Permalink
added custom footer per namespace feature
Browse files Browse the repository at this point in the history
darcs-hash:20071018131502-23886-6440ef748d71158acebf45845a315f0747a6173b.gz
  • Loading branch information
Michael Klier committed Oct 18, 2007
1 parent 4b17117 commit 3237a0c
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 30 deletions.
5 changes: 3 additions & 2 deletions conf/default.php
Expand Up @@ -6,6 +6,7 @@
* @author: Michael Klier <chi@chimeric.de>
*/

$conf['pagename'] = 'navigation'; // the pagename for the navigation pages
$conf['closedwiki'] = false; // set to true if you run a closed wiki
$conf['sb_pagename'] = 'navigation'; // the pagename for the navigation pages
$conf['ft_pagename'] = 'footer'; // the pagename for the footer page
$conf['closedwiki'] = false; // set to true if you run a closed wiki
?>
5 changes: 3 additions & 2 deletions conf/metadata.php
Expand Up @@ -6,6 +6,7 @@
* @author: Michael Klier <chi@chimeric.de>
*/

$meta['pagename'] = array('string', '_pattern' => '#[a-z]*');
$meta['closedwiki'] = array('onoff');
$meta['sb_pagename'] = array('string', '_pattern' => '#[a-z]*');
$meta['ft_pagename'] = array('string', '_pattern' => '#[a-z]*');
$meta['closedwiki'] = array('onoff');
?>
11 changes: 10 additions & 1 deletion dokubook_design.css
Expand Up @@ -131,7 +131,7 @@ div.dokuwiki div#sidebar h5 {
border: none;
}

/* -------------- dokucument ---------------------- */
/* -------------- document ---------------------- */
div.dokuwiki div.page {
line-height: 160%;
margin: 0;
Expand All @@ -140,6 +140,10 @@ div.dokuwiki div.page {
background: __background__;
}

div.dokuwiki h3 {
font-weight: normal;
}

div.dokuwiki div.breadcrumbs {
margin-bottom: 10px;
clear: both;
Expand Down Expand Up @@ -176,6 +180,11 @@ div.dokuwiki div#footer {
margin: 10px 0 1em 0;
background: __background__;
border: 1px solid __border__;
text-align: center;
}

div.dokuwiki div#footer input.button {
float: none;
}

div.dokuwiki div.footerinc {
Expand Down
5 changes: 3 additions & 2 deletions lang/en/settings.php
Expand Up @@ -5,6 +5,7 @@
* @author: Michael Klier <chi@chimeric.de>
*/

$lang['pagename'] = "Pagename to use for the navigation";
$lang['closedwiki'] = "Closed Wiki (Navigation shows only the login form if not logged in)";
$lang['sb_pagename'] = "Pagename to use for the navigation";
$lang['ft_pagename'] = "Pagename to use for the footer";
$lang['closedwiki'] = "Closed Wiki (Navigation shows only the login form if not logged in)";
?>
2 changes: 2 additions & 0 deletions main.php
Expand Up @@ -118,6 +118,8 @@

<div class="clearer"></div>

<?php tpl_footer() ?>

<div class="stylefoot">
<?php /*old includehook*/ @include(dirname(__FILE__).'/pagefooter.html')?>
</div>
Expand Down
83 changes: 60 additions & 23 deletions tpl_functions.php
Expand Up @@ -5,8 +5,9 @@
* @license: GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author: Michael Klier <chi@chimeric.de>
*/

if(!defined('DW_LF')) define('DW_LF',"\n");
// must be run within DokuWiki
if(!defined('DOKU_INC')) die();
if(!defined('DOKU_LF')) define('DOKU_LF', "\n");

// load language files
require_once(DOKU_TPLINC.'lang/en/lang.php');
Expand Down Expand Up @@ -41,7 +42,7 @@ function tpl_logo() {
}

$out .= '<a href="' . DOKU_BASE . '" name="dokuwiki__top" id="dokuwiki__top" accesskey="h" title="[ALT+H]">';
$out .= ' <img class="logo" src="' . $logo . '" alt="' . $conf['title'] . '" /></a>' . DW_LF;
$out .= ' <img class="logo" src="' . $logo . '" alt="' . $conf['title'] . '" /></a>' . DOKU_LF;

print ($out);
}
Expand All @@ -57,22 +58,22 @@ function tpl_sidebar() {
global $INFO;

$svID = cleanID($ID);
$navpn = tpl_getConf('pagename');
$navpn = tpl_getConf('sb_pagename');
$path = explode(':',$svID);
$found = false;
$sb = '';

if(tpl_getConf('closedwiki') && empty($INFO['userinfo'])) {
print '<span class="sb_label">' . $lang['toolbox'] . '</span>' . DW_LF;
print '<div id="toolbox" class="sidebar_box">' . DW_LF;
print '<span class="sb_label">' . $lang['toolbox'] . '</span>' . DOKU_LF;
print '<div id="toolbox" class="sidebar_box">' . DOKU_LF;
tpl_actionlink('login');
print '</div>' . DW_LF;
print '</div>' . DOKU_LF;
return;
}

// main navigation
print '<span class="sb_label">' . $lang['navigation'] . '</span>' . DW_LF;
print '<div id="navigation" class="sidebar_box">' . DW_LF;
print '<span class="sb_label">' . $lang['navigation'] . '</span>' . DOKU_LF;
print '<div id="navigation" class="sidebar_box">' . DOKU_LF;

while(!$found && count($path) > 0) {
$sb = implode(':', $path) . ':' . $navpn;
Expand All @@ -83,45 +84,81 @@ function tpl_sidebar() {
if(!$found && @file_exists(wikiFN($navpn))) $sb = $navpn;

if(@file_exists(wikiFN($sb)) && auth_quickaclcheck($sb) >= AUTH_READ) {
print p_sidebar_xhtml($sb);
print p_dokubook_xhtml($sb);
} else {
print p_index_xhtml(cleanID($svID));
}

print '</div>' . DW_LF;
print '</div>' . DOKU_LF;

// generate the searchbox
print '<span class="sb_label">' . strtolower($lang['btn_search']) . '</span>' . DW_LF;
print '<div id="search">' . DW_LF;
print '<span class="sb_label">' . strtolower($lang['btn_search']) . '</span>' . DOKU_LF;
print '<div id="search">' . DOKU_LF;
tpl_searchform();
print '</div>' . DW_LF;
print '</div>' . DOKU_LF;

// generate the toolbox
print '<span class="sb_label">' . $lang['toolbox'] . '</span>' . DW_LF;
print '<div id="toolbox" class="sidebar_box">' . DW_LF;
print '<span class="sb_label">' . $lang['toolbox'] . '</span>' . DOKU_LF;
print '<div id="toolbox" class="sidebar_box">' . DOKU_LF;
tpl_actionlink('admin');
tpl_actionlink('index');
tpl_actionlink('recent');
tpl_actionlink('backlink');
tpl_actionlink('profile');
tpl_actionlink('login');
print '</div>' . DW_LF;
print '</div>' . DOKU_LF;

// restore ID just in case
$Id = $svID;
}

/**
* prints a custom page footer
*
* @author Michael Klier <chi@chimeric.de>
*/
function tpl_footer() {
global $ID;

$svID = $ID;
$ftpn = tpl_getConf('ft_pagename');
$path = explode(':',$svID);
$found = false;
$ft = '';

while(!$found && count($path) > 0) {
$ft = implode(':', $path) . ':' . $ftpn;
$found = @file_exists(wikiFN($ft));
array_pop($path);
}

if(!$found && @file_exists(wikiFN($ftpn))) $ft = $ftpn;

if(@file_exists(wikiFN($ft)) && auth_quickaclcheck($ft) >= AUTH_READ) {
print '<div id="footer">' . DOKU_LF;
print p_dokubook_xhtml($ft);
print '</div>' . DOKU_LF;
}

// restore ID just in case
$ID = $svID;
}

/**
* removes the TOC of the sidebar-pages and shows a edit-button if user has enough rights
* removes the TOC of the sidebar-pages and shows
* a edit-button if user has enough rights
*
* @author Michael Klier <chi@chimeric.de>
*/
function p_sidebar_xhtml($sb) {
$data = p_wiki_xhtml($sb,'',false);
if(auth_quickaclcheck($sb) >= AUTH_EDIT) {
$data .= '<div class="secedit">' . html_btn('secedit',$sb,'',array('do'=>'edit','rev'=>'','post')) . '</div>';
function p_dokubook_xhtml($wp) {
$data = p_wiki_xhtml($wp,'',false);
if(auth_quickaclcheck($wp) >= AUTH_EDIT) {
$data .= '<div class="secedit">' . html_btn('secedit',$wp,'',array('do'=>'edit','rev'=>'','post')) . '</div>';
}
// strip TOC
$data = preg_replace('/<div class="toc">.*?(<\/div>\n<\/div>)/s', '', $data);
// replace headline ids for XHTML compliance
$data = preg_replace('/(<h.*?><a.*?id=")(.*?)(">.*?<\/a><\/h.*?>)/','\1sb_'.$pos.'_\2\3', $data);
$data = preg_replace('/(<h.*?><a.*?id=")(.*?)(">.*?<\/a><\/h.*?>)/','\1sb_\2\3', $data);
return ($data);
}

Expand Down

0 comments on commit 3237a0c

Please sign in to comment.