From cad2e674423f1c3a46761f737a36e1dd04069565 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Tue, 28 Mar 2017 16:55:26 +0200 Subject: [PATCH] support the tplinc plugin This is a first commit to generally support the plugin and make the page footer use it. More includes should be added at other places. --- Template.php | 31 +++++++++++++++++++++++++++++++ main.php | 25 +++++++++---------------- 2 files changed, 40 insertions(+), 16 deletions(-) diff --git a/Template.php b/Template.php index f1f71f4..b10d973 100644 --- a/Template.php +++ b/Template.php @@ -35,6 +35,36 @@ class Template { */ protected function __construct() { $this->initializePlugins(); + + /** @var \Doku_Event_Handler */ + global $EVENT_HANDLER; + $EVENT_HANDLER->register_hook('PLUGIN_TPLINC_LOCATIONS_SET', 'BEFORE', $this, 'registerIncludes'); + } + + /** + * Makes include position info available to the tplinc plugin + * + * @param \Doku_Event $event + */ + public function registerIncludes(\Doku_Event $event) { + $event->data['footer'] = 'Footer below the page content'; + } + + /** + * Get the content to include from the tplinc plugin + * + * prefix and postfix are only added when there actually is any content + * + * @param string $location + * @param string $pre prepend this before the content + * @param string $post append this to the content + * @return string + */ + public function getInclude($location, $pre = '', $post = '') { + if(!$this->plugins['tplinc']) return ''; + $content = $this->plugins['tplinc']->renderIncludes($location); + if($content === '') return ''; + return $pre . $content . $post; } /** @@ -45,6 +75,7 @@ class Template { if($this->plugins['sqlite']) { $this->plugins['tagging'] = plugin_load('helper', 'tagging'); } + $this->plugins['tplinc'] = plugin_load('helper', 'tplinc'); } /** diff --git a/main.php b/main.php index 2934e3f..e0f96e4 100755 --- a/main.php +++ b/main.php @@ -9,14 +9,13 @@ * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) */ +use dokuwiki\template\sprintdoc\Template; + if (!defined('DOKU_INC')) die(); /* must be run from within DokuWiki */ header('X-UA-Compatible: IE=edge,chrome=1'); $showTools = !tpl_getConf('hideTools') || ( tpl_getConf('hideTools') && !empty($_SERVER['REMOTE_USER']) ); $showSidebar = true; /* */ -$hasFooter = page_findnearest('pagefooter'); -$showFooter = $hasFooter && ($ACT === 'show'); - ?> @@ -277,19 +276,13 @@ $classWideContent = ($ACT === "show") ? "": "wide-content "; tpl_content(false); /* the main content */ ?>
- -
-
- -
-
- + getInclude( + 'footer', + '

', + '
' + ); + ?>