diff --git a/Template.php b/Template.php new file mode 100644 index 0000000..e9106e8 --- /dev/null +++ b/Template.php @@ -0,0 +1,83 @@ + null, + 'tagging' => null, + ); + + /** + * Get the singleton instance + * + * @return Template + */ + public static function getInstance() { + static $instance = null; + if($instance === null) $instance = new Template(); + return $instance; + } + + + /** + * Template constructor. + */ + protected function __construct() { + $this->initializePlugins(); + } + + /** + * Load all the plugins we support directly + */ + protected function initializePlugins() { + $this->plugins['sqlite'] = plugin_load('helper', 'sqlite'); + if($this->plugins['sqlite']) { + $this->plugins['tagging'] = plugin_load('helper', 'tagging'); + } + } + + /** + * Get all the tabs to display + * + * @return array + */ + public function getMetaBoxTabs() { + global $lang; + $tabs = array(); + + $toc = tpl_toc(true); + if($toc) { + $tabs[] = array( + 'id' => 'spr__tab-toc', + 'label' => $lang['toc'], + 'tab' => $toc, + 'count' => null, + ); + } + + if($this->plugins['tagging']) { + $tabs[] = array( + 'id' => 'spr__tab-tags', + 'label' => tpl_getLang('tab_tags'), + 'tab' => $this->plugins['tagging']->tpl_tags(false), + 'count' => null, // FIXME + ); + } + + // fixme add magicmatcher info + + return $tabs; + } +} diff --git a/tpl/nav-meta-box.php b/tpl/nav-meta-box.php index 8dd7f06..7b8db90 100755 --- a/tpl/nav-meta-box.php +++ b/tpl/nav-meta-box.php @@ -1,31 +1,7 @@ 'spr__tab-toc', - 'label' => $lang['toc'], - 'tab' => $toc, - 'count' => null, - ); -} - -/** @var helper_plugin_tagging $tags */ -$tags = plugin_load('helper', 'tagging'); -if($tags) { - $tabs[] = array( - 'id' => 'spr__tab-tags', - 'label' => tpl_getLang('tab_tags'), - 'tab' => $tags->tpl_tags(false), - 'count' => null, // FIXME - ); -} - -// fixme add magicmatcher info +$tabs = \dokuwiki\template\sprintdoc\Template::getInstance()->getMetaBoxTabs(); ?>