1<?php
2
3/**
4 * DokuWiki Plugin doxycode (Helper Component)
5 *
6 * @license     GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
7 * @author      Lukas Probsthain <lukas.probsthain@gmail.com>
8 */
9
10use dokuwiki\Extension\Plugin;
11
12/**
13 * Class helper_plugin_doxycode
14 *
15 * This helper plugin implements some common functions for the doxygen plugin.
16 * Its main use is the creation of the file dependencies of XML and HTML cache files
17 * for cache validation in the other components.
18 *
19 * @author      Lukas Probsthain <lukas.probsthain@gmail.com>
20 */
21class helper_plugin_doxycode extends Plugin
22{
23    /** @var helper_plugin_doxycode_tagmanager $tagmanager */
24    protected $tagmanager;
25
26    public function __construct()
27    {
28        $this->tagmanager = plugin_load('helper', 'doxycode_tagmanager');
29    }
30
31
32    public function getXMLFileDependencies(&$dependencies, $tag_conf = null)
33    {
34
35        $this->getTagFiles($dependencies, $tag_conf);
36
37        // add the configuration file
38        $this->addDefaultDependencies($dependencies);
39
40        return $dependencies;
41    }
42
43    public function getHTMLFileDependencies(&$dependencies, $xml_cacheID, $tag_conf = null)
44    {
45
46        $this->getTagFiles($dependencies, $tag_conf);
47
48        // add the configuration file
49        $this->addDefaultDependencies($dependencies);
50
51        $xml_cache = getCacheName($xml_cacheID, '.xml');
52
53        // add the configuration file
54        $dependencies['files'][] = DOKU_PLUGIN . $this->getPluginName() . '/helper/parser.php';
55        $dependencies['files'][] = $xml_cache;
56
57        return $dependencies;
58    }
59
60    public function getTagFiles(&$dependencies, $tag_conf = null)
61    {
62        // generate the full filepaths for the $tag_conf entries
63
64        foreach ($tag_conf as $key => $conf) {
65            // TODO: should we check if the file exists?
66            $dependencies['files'][] = $this->tagmanager->getTagFileDir() . $key . '.xml';
67        }
68    }
69
70    protected function addDefaultDependencies(&$dependencies)
71    {
72        $dependencies['files'][] = $this->tagmanager->getTagFileDir() . 'tagconfig.json';
73        // add the doxygen configuration template
74        $dependencies['files'][] = DOKU_PLUGIN . $this->getPluginName()  . '/doxygen.conf';
75
76        // easy cache invalidation on code change
77        // these files affect all types - we should rebuild the doxygen snippets completetly
78        $dependencies['files'][] = DOKU_PLUGIN . $this->getPluginName() . '/syntax/snippet.php';
79        $dependencies['files'][] = DOKU_PLUGIN . $this->getPluginName() . '/helper/buildmanager.php';
80        $dependencies['files'][] = DOKU_PLUGIN . $this->getPluginName() . '/helper/tagmanager.php';
81        $dependencies['files'][] = DOKU_PLUGIN . $this->getPluginName() . '/helper.php';
82    }
83
84    public function getPHPFileDependencies(&$dependencies)
85    {
86
87        $dependencies['files'][] = $this->tagmanager->getTagFileDir() . 'tagconfig.json';
88        // add the doxygen configuration template
89        $dependencies['files'][] = DOKU_PLUGIN . $this->getPluginName()  . '/doxygen.conf';
90
91        // easy cache invalidation on code change
92        $dependencies['files'] = array_merge(
93            $dependencies['files'],
94            glob(DOKU_PLUGIN . $this->getPluginName() . '/*.php')
95        );
96        $dependencies['files'] = array_merge(
97            $dependencies['files'],
98            glob(DOKU_PLUGIN . $this->getPluginName() . '/syntax/*.php')
99        );
100        $dependencies['files'] = array_merge(
101            $dependencies['files'],
102            glob(DOKU_PLUGIN . $this->getPluginName() . '/helper/*.php')
103        );
104    }
105}
106