* @link http://andreas-haerter.com/projects/dokuwiki-template-monobook * @link http://www.dokuwiki.org/template:monobook * @link http://www.dokuwiki.org/devel:templates * @link http://www.dokuwiki.org/devel:coding_style * @link http://www.dokuwiki.org/devel:environment * @link http://www.dokuwiki.org/devel:action_modes */ //check if we are running within the DokuWiki environment if (!defined("DOKU_INC")){ die(); } // Hardcode these paths, as this template will be loaded via SkinLoader if(!defined('GSMONO_TPL')) { define('GSMONO_TPL', DOKU_BASE.'lib/tpl/greenstone-monobook/'); } if(!defined('GSMONO_TPLINC')) { define('GSMONO_TPLINC', DOKU_INC.'lib/tpl/greenstone-monobook/'); } /** Override some config options - regardless of what is set in dokuwiki */ $conf['youarehere'] = true; $conf['breadcrumbs'] = false; $conf['toptoclevel'] = 2; /** * Stores the template wide action * * Different DokuWiki actions requiring some template logic. Therefore the * template has to know, what we are doing right now - and that is what this * var is for. * * Please have a look at the "detail.php" file in the same folder, it is also * influencing the var's value. * * @var string * @author Andreas Haerter */ $monobook_action = "article"; //note: I used $_REQUEST before (cause DokuWiki controls and fills it. Normally, // using $_REQUEST is a possible security threat. For details, see // // and ), but it did not work as // expected by me (maybe it is a reference and setting $monobook_action // also changed the contents of $_REQUEST?!). That is why I switched back, // checking $_GET and $_POST like I did it before. if (!empty($_GET["mddo"])){ $monobook_action = (string)$_GET["mddo"]; }elseif (!empty($_POST["mddo"])){ $monobook_action = (string)$_POST["mddo"]; } if (!empty($monobook_action) && $monobook_action !== "article" && $monobook_action !== "print" && $monobook_action !== "detail" && $monobook_action !== "cite"){ //ignore unknown values $monobook_action = "article"; } /** * Stores the template wide context * * This template offers discussion pages via common articles, which should be * marked as "special". DokuWiki does not know any "special" articles, therefore * we have to take care about detecting if the current page is a discussion * page or not. * * @var string * @author Andreas Haerter */ $monobook_context = "article"; if (preg_match("/^".tpl_getConf("monobook_discuss_ns")."?$|^".tpl_getConf("monobook_discuss_ns").".*?$/i", ":".getNS(getID()))){ $monobook_context = "discuss"; } /** * Stores the name the current client used to login * * @var string * @author Andreas Haerter */ $loginname = ""; if (!empty($conf["useacl"])){ if (isset($_SERVER["REMOTE_USER"]) && //no empty() but isset(): "0" may be a valid username... $_SERVER["REMOTE_USER"] !== ""){ $loginname = $_SERVER["REMOTE_USER"]; //$INFO["client"] would not work here (-> e.g. if //current IP differs from the one used to login) } } //get needed language array include GSMONO_TPLINC."lang/en/lang.php"; //overwrite English language values with available translations if (!empty($conf["lang"]) && $conf["lang"] !== "en" && file_exists(GSMONO_TPLINC."/lang/".$conf["lang"]."/lang.php")){ //get language file (partially translated language files are no problem //cause non translated stuff is still existing as English array value) include GSMONO_TPLINC."/lang/".$conf["lang"]."/lang.php"; } //detect revision $rev = (int)$INFO["rev"]; //$INFO comes from the DokuWiki core if ($rev < 1){ $rev = (int)$INFO["lastmod"]; } //get tab config include GSMONO_TPLINC."/conf/tabs.php"; //default if (file_exists(GSMONO_TPLINC."/user/tabs.php")){ include GSMONO_TPLINC."/user/tabs.php"; //user defined } //get boxes config include GSMONO_TPLINC."/conf/boxes.php"; //default if (file_exists(GSMONO_TPLINC."/user/boxes.php")){ include GSMONO_TPLINC."/user/boxes.php"; //user defined } //get button config include GSMONO_TPLINC."/conf/buttons.php"; //default if (file_exists(GSMONO_TPLINC."/user/buttons.php")){ include GSMONO_TPLINC."/user/buttons.php"; //user defined } /** * Helper to render the tabs (like a dynamic XHTML snippet) * * * NOTE: This function is heavily inspired by "writeMBPortlet(), context.php" of * the "Monobook for Dokuwiki" template by Terence J. Grant. * * @param array The tab data to render within the snippet. Each element * is represented through a subarray: * $array = array("tab1" => array("text" => "hello world!", * "href" => "http://www.example.com" * "nofollow" => true), * "tab2" => array("text" => "I did it again", * "href" => DOKU_BASE."doku.php?id=foobar", * "class" => "foobar-css"), * "tab3" => array("text" => "I did it again and again", * "href" => wl("start", false, false, "&"), * "class" => "foobar-css"), * "tab4" => array("text" => "Home", * "wiki" => ":start" * "accesskey" => "H")); * Available keys within the subarrays: * - "text" (mandatory) * The text/label of the element. * - "href" (optional) * URL the element should point to (as link). Please submit raw, * unencoded URLs, the encoding will be done by this function for * security reasons. If the URL is not relative * (= starts with http(s)://), the URL will be treated as external * (=a special style will be used if "class" is not set). * - "wiki" (optional) * ID of a WikiPage to link (like ":start" or ":wiki:foobar"). * - "class" (optional) * Name of an additional CSS class to use for the element content. * Works only in combination with "text" or "href", NOT with "wiki" * (will be ignored in this case). * - "nofollow" (optional) * If set to TRUE, rel="nofollow" will be added to the link if "href" * is set (otherwise this flag will do nothing). * - "accesskey" (optional) * accesskey="" will be added to the link if "href" is set * (otherwise this option will do nothing). * @author Andreas Haerter * @see _monobook_renderButtons() * @see _monobook_renderBoxes() * @link http://www.wikipedia.org/wiki/Nofollow * @link http://de.selfhtml.org/html/verweise/tastatur.htm#kuerzel * @link http://www.dokuwiki.org/devel:environment * @link http://www.dokuwiki.org/devel:coding_style */ function _monobook_renderTabs($arr) { //is there something useful? if (empty($arr) || !is_array($arr)){ return false; //nope, break operation } //array to store the created tabs into $elements = array(); //handle the tab data foreach($arr as $li_id => $element){ //basic check if (empty($element) || !is_array($element) || !isset($element["text"])){ continue; //ignore invalid stuff and go on } $li_created = true; //flag to control if we created any list element $interim = ""; //do we have an external link? if (!empty($element["href"])){ //add URL $interim = ""; //internal wiki link }else if (!empty($element["wiki"])){ //add special css class? if (!empty($element["class"])){ $interim = "".html_wikilink($element["wiki"], hsc($element["text"])).""; }else{ $interim = html_wikilink($element["wiki"], hsc($element["text"])); } /* Following works, but I think it is too heavy... //use a wiki page as content } elseif ($element["wiki_include"]){ //we have to show a wiki page. get the rendered content of the //defined wiki article to use as content. $interim = tpl_include_page($element["wiki_include"], false); if ($interim === "" || $interim === false){ //show creation/edit link if the defined page got no content $interim = "[ ".html_wikilink($element["wiki_include"], hsc($lang["monobook_fillplaceholder"]." (".hsc($element["wiki_include"]).")"))." ]
"; }*/ //text only }else{ $interim = ""; } //store it $elements[] = "
  • ".$interim."
  • \n"; } //show everything created if (!empty($elements)){ echo "\n" ."
    \n" //don't touch the id, it is needed as css selector ."
      \n"; foreach ($elements as $element){ echo $element; } echo "
    \n" ."
    \n"; } return true; } /** * Helper to render the boxes (like a dynamic XHTML snippet) * * * NOTE: This function is heavily inspired by "writeMBPortlet(), context.php" of * the "Monobook for Dokuwiki" template by Terence J. Grant. * * @param array The box data to render within the snippet. Each box is * represented through a subarray: * $array = array("box-id1" => array("headline" => "hello world!", * "xhtml" => "I am here.")); * Available keys within the subarrays: * - "xhtml" (mandatory) * The content of the Box you want to show as XHTML. Attention: YOU * HAVE TO TAKE CARE ABOUT FILTER EVENTUALLY USED INPUT/SECURITY. Be * aware of XSS and stuff. * - "headline" (optional) * Headline to show above the box. Leave empty/do not set for none. * @author Andreas Haerter * @see _monobook_renderButtons() * @see _monobook_renderTabs() * @link http://www.wikipedia.org/wiki/Nofollow * @link http://www.wikipedia.org/wiki/Cross-site_scripting * @link http://www.dokuwiki.org/devel:coding_style */ function _monobook_renderBoxes($arr) { //is there something useful? if (empty($arr) || !is_array($arr)){ return false; //nope, break operation } //array to store the created boxes into $boxes = array(); $search_handled = false; //handle the box data foreach($arr as $div_id => $contents){ //basic check if (empty($contents) || !is_array($contents) || !isset($contents["xhtml"])){ continue; //ignore invalid stuff and go on } $interim = "
    \n"; if (isset($contents["headline"]) && $contents["headline"] !== ""){ //hack for search box if ($search_handled === true || $div_id !== "p-search") { $interim .= "
    ".hsc($contents["headline"])."
    \n"; } else { $interim .= "
    \n"; } } $interim .= "
    \n" ."
    \n" //dokuwiki CSS class needed cause we might have to show rendered page content .$contents["xhtml"]."\n" ."
    \n" ."
    \n" ."
    \n"; //hack for search box if ($search_handled === false && $div_id === "p-search") { $interim .= "
    \n"; //set flag $search_handled = true; } //store it $boxes[] = $interim; } //show everything created if (!empty($boxes)){ echo "\n"; foreach ($boxes as $box){ echo $box; } echo "\n"; } return true; } /** * Helper to render the footer buttons (like a dynamic XHTML snippet) * * @param array The button data to render within the snippet. Each element * is represented through a subarray: * $array = array("btn1" => array("img" => GSMONO_TPL."static/img/button-monobook.png", * "href" => "http://andreas-haerter.com/projects/dokuwiki-template-monobook", * "width" => 80, * "height" => 15, * "title" => "monobook for DokuWiki", * "nofollow" => false), * "btn2" => array("img" => GSMONO_TPL."user/mybutton1.png", * "href" => wl("start", false, false, "&")), * "btn3" => array("img" => GSMONO_TPL."user/mybutton2.png", * "href" => "http://www.example.com"); * Available keys within the subarrays: * - "img" (mandatory) * The relative or full path of an image/button to show. Users may * place own images within the /user/ dir of this template. * - "href" (mandatory) * URL the element should point to (as link). Please submit raw, * unencoded URLs, the encoding will be done by this function for * security reasons. * - "width" (optional) * width="" will be added to the image tag if both "width" and * "height" are set (otherwise, this will be ignored). * - "height" (optional) * height="" will be added to the image tag if both "height" and * "width" are set (otherwise, this will be ignored). * - "nofollow" (optional) * If set to TRUE, rel="nofollow" will be added to the link. * - "title" (optional) * title="" will be added to the link and image if "title" * is set + alt="". * @author Andreas Haerter * @see _monobook_renderButtons() * @see _monobook_renderBoxes() * @link http://www.wikipedia.org/wiki/Nofollow * @link http://www.dokuwiki.org/devel:coding_style */ function _monobook_renderButtons($arr) { //array to store the created buttons into $elements = array(); //handle the button data foreach($arr as $li_id => $element){ //basic check if (empty($element) || !is_array($element) || !isset($element["img"]) || !isset($element["href"])){ continue; //ignore invalid stuff and go on } $interim = ""; //add URL $interim = "
    "; //store it $elements[] = " ".$interim."\n"; } //show everything created if (!empty($elements)){ echo "\n"; foreach ($elements as $element){ echo $element; } } return true; } //workaround for the "jumping textarea" IE bug. CSS only fix not possible cause //some DokuWiki JavaScript is triggering this bug, too. See the following for //info: //- //- if ($ACT === "edit" && !headers_sent()){ header("X-UA-Compatible: IE=EmulateIE7"); } ?> " lang="" dir=""> <?php tpl_pagetitle(); echo " - ".hsc($conf["title"]); ?> "; //manually load needed CSS? this is a workaround for PHP Bug #49642. In some //version/os combinations PHP is not able to parse INI-file entries if there //are slashes "/" used for the keynames (see bugreport for more information: //). to trigger this workaround, simply //delete/rename monobook's style.ini. if (!file_exists(GSMONO_TPLINC."style.ini")){ echo "\n"; //var comes from DokuWiki core } //include default or userdefined favicon // //note: since 2011-04-22 "Rincewind RC1", there is a core function named // "tpl_getFavicon()". But its functionality is not really fitting the // behaviour of this template, therefore I don't use it here. if (file_exists(GSMONO_TPLINC."user/favicon.ico")){ //user defined - you might find http://tools.dynamicdrive.com/favicon/ //useful to generate one echo "\n\n"; }elseif (file_exists(GSMONO_TPLINC."user/favicon.png")){ //note: I do NOT recommend PNG for favicons (cause it is not supported by //all browsers), but some users requested this feature. echo "\n\n"; }else{ //default echo "\n\n"; } //include default or userdefined Apple Touch Icon (see for //details) if (file_exists(GSMONO_TPLINC."user/apple-touch-icon.png")){ echo "\n"; }else{ //default echo "\n"; } //load userdefined js? if (tpl_getConf("monobook_loaduserjs")){ echo "\n"; } //show printable version? if ($monobook_action === "print"){ //note: this is just a workaround for people searching for a print version. // don't forget to update the styles.ini, this is the really important // thing! BTW: good text about this: http://is.gd/5MyG5 echo "\n" ."\n" ."\n"; } //load language specific css hacks? if (file_exists(GSMONO_TPLINC."lang/".$conf["lang"]."/style.css")){ $interim = trim(file_get_contents(GSMONO_TPLINC."lang/".$conf["lang"]."/style.css")); if (!empty($interim)){ echo "\n"; } } ?> ">
    = AUTH_READ){ //current user got access? echo "\n
    \n"; //get the rendered content of the defined wiki article to use as //custom sitenotice. $interim = tpl_include_page(tpl_getConf("monobook_sitenotice_location"), false); if ($interim === "" || $interim === false){ //show creation/edit link if the defined page got no content echo "[ "; tpl_pagelink(tpl_getConf("monobook_sitenotice_location"), hsc($lang["monobook_fillplaceholder"]." (".tpl_getConf("monobook_sitenotice_location").")")); echo " ]
    "; }else{ //show the rendered page content echo $interim; } echo "\n
    \n"; } } //show breadcrumps if enabled and positioned on top if ($conf["breadcrumbs"] == true && $ACT !== "media" && //var comes from DokuWiki (empty($conf["useacl"]) || //are there any users? $loginname !== "" || //user is logged in? !tpl_getConf("monobook_closedwiki")) && tpl_getConf("monobook_breadcrumbs_position") === "top"){ echo "\n \n"; } //show hierarchical breadcrumps if enabled and positioned on top if ($conf["youarehere"] == true && $ACT !== "media" && //var comes from DokuWiki (empty($conf["useacl"]) || //are there any users? $loginname !== "" || //user is logged in? !tpl_getConf("monobook_closedwiki"))){// && // tpl_getConf("monobook_youarehere_position") === "top"){ echo "\n \n"; } ?>

    \n "; tpl_breadcrumbs(); echo "\n

    \n"; } //show hierarchical breadcrumps if enabled and positioned on bottom if ($conf["youarehere"] == true && $ACT !== "media" && //var comes from DokuWiki (empty($conf["useacl"]) || //are there any users? $loginname !== "" || //user is logged in? !tpl_getConf("monobook_closedwiki"))){ // && // tpl_getConf("monobook_youarehere_position") === "bottom"){ echo "\n \n"; } ?>
    \n" ."
    \n" ." \n" ."
    \n" ."
    \n"; } //show boxes, see monobook/user/boxes.php to configure them if (!empty($_monobook_boxes) && is_array($_monobook_boxes)){ _monobook_renderBoxes($_monobook_boxes); } ?>
    "recent"));?>" accesskey="r" style="visibility:hidden;" rel="nofollow">