xref: /template/sprintdoc/Template.php (revision 2387fd467e1c56faea6a96ba632071052d8036df)
1*2387fd46SAndreas Gohr<?php
2*2387fd46SAndreas Gohr
3*2387fd46SAndreas Gohrnamespace dokuwiki\template\sprintdoc;
4*2387fd46SAndreas Gohr
5*2387fd46SAndreas Gohr/**
6*2387fd46SAndreas Gohr * Class Template
7*2387fd46SAndreas Gohr *
8*2387fd46SAndreas Gohr * provides additional logic for the sprintdoc template
9*2387fd46SAndreas Gohr *
10*2387fd46SAndreas Gohr * @package dokuwiki\template\sprintdoc
11*2387fd46SAndreas Gohr */
12*2387fd46SAndreas Gohrclass Template {
13*2387fd46SAndreas Gohr
14*2387fd46SAndreas Gohr    /**
15*2387fd46SAndreas Gohr     * @var array loaded plugins
16*2387fd46SAndreas Gohr     */
17*2387fd46SAndreas Gohr    protected $plugins = array(
18*2387fd46SAndreas Gohr        'sqlite' => null,
19*2387fd46SAndreas Gohr        'tagging' => null,
20*2387fd46SAndreas Gohr    );
21*2387fd46SAndreas Gohr
22*2387fd46SAndreas Gohr    /**
23*2387fd46SAndreas Gohr     * Get the singleton instance
24*2387fd46SAndreas Gohr     *
25*2387fd46SAndreas Gohr     * @return Template
26*2387fd46SAndreas Gohr     */
27*2387fd46SAndreas Gohr    public static function getInstance() {
28*2387fd46SAndreas Gohr        static $instance = null;
29*2387fd46SAndreas Gohr        if($instance === null) $instance = new Template();
30*2387fd46SAndreas Gohr        return $instance;
31*2387fd46SAndreas Gohr    }
32*2387fd46SAndreas Gohr
33*2387fd46SAndreas Gohr
34*2387fd46SAndreas Gohr    /**
35*2387fd46SAndreas Gohr     * Template constructor.
36*2387fd46SAndreas Gohr     */
37*2387fd46SAndreas Gohr    protected function __construct() {
38*2387fd46SAndreas Gohr        $this->initializePlugins();
39*2387fd46SAndreas Gohr    }
40*2387fd46SAndreas Gohr
41*2387fd46SAndreas Gohr    /**
42*2387fd46SAndreas Gohr     * Load all the plugins we support directly
43*2387fd46SAndreas Gohr     */
44*2387fd46SAndreas Gohr    protected function initializePlugins() {
45*2387fd46SAndreas Gohr        $this->plugins['sqlite'] = plugin_load('helper', 'sqlite');
46*2387fd46SAndreas Gohr        if($this->plugins['sqlite']) {
47*2387fd46SAndreas Gohr            $this->plugins['tagging'] = plugin_load('helper', 'tagging');
48*2387fd46SAndreas Gohr        }
49*2387fd46SAndreas Gohr    }
50*2387fd46SAndreas Gohr
51*2387fd46SAndreas Gohr    /**
52*2387fd46SAndreas Gohr     * Get all the tabs to display
53*2387fd46SAndreas Gohr     *
54*2387fd46SAndreas Gohr     * @return array
55*2387fd46SAndreas Gohr     */
56*2387fd46SAndreas Gohr    public function getMetaBoxTabs() {
57*2387fd46SAndreas Gohr        global $lang;
58*2387fd46SAndreas Gohr        $tabs = array();
59*2387fd46SAndreas Gohr
60*2387fd46SAndreas Gohr        $toc = tpl_toc(true);
61*2387fd46SAndreas Gohr        if($toc) {
62*2387fd46SAndreas Gohr            $tabs[] = array(
63*2387fd46SAndreas Gohr                'id' => 'spr__tab-toc',
64*2387fd46SAndreas Gohr                'label' => $lang['toc'],
65*2387fd46SAndreas Gohr                'tab' => $toc,
66*2387fd46SAndreas Gohr                'count' => null,
67*2387fd46SAndreas Gohr            );
68*2387fd46SAndreas Gohr        }
69*2387fd46SAndreas Gohr
70*2387fd46SAndreas Gohr        if($this->plugins['tagging']) {
71*2387fd46SAndreas Gohr            $tabs[] = array(
72*2387fd46SAndreas Gohr                'id' => 'spr__tab-tags',
73*2387fd46SAndreas Gohr                'label' => tpl_getLang('tab_tags'),
74*2387fd46SAndreas Gohr                'tab' => $this->plugins['tagging']->tpl_tags(false),
75*2387fd46SAndreas Gohr                'count' => null, // FIXME
76*2387fd46SAndreas Gohr            );
77*2387fd46SAndreas Gohr        }
78*2387fd46SAndreas Gohr
79*2387fd46SAndreas Gohr        // fixme add magicmatcher info
80*2387fd46SAndreas Gohr
81*2387fd46SAndreas Gohr        return $tabs;
82*2387fd46SAndreas Gohr    }
83*2387fd46SAndreas Gohr}
84