1<?php
2/**
3 * DokuWiki Plugin metaeditor (Admin Component)
4 *
5 * Simple Meta Data Editor, heavily AJAX/jQuery based.
6 *
7 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
8 * @author  Andreas Gohr <gohr@cosmocode.de>
9 */
10
11// must be run within Dokuwiki
12if (!defined('DOKU_INC')) die();
13require_once(DOKU_PLUGIN.'admin.php');
14
15class admin_plugin_metaeditor_editor extends DokuWiki_Admin_Plugin {
16
17    /**
18     * Constructor. Load helper plugin
19     */
20    function admin_plugin_metaeditor_editor(){
21
22    }
23
24    function getMenuSort() { return 501; }
25    function forAdminOnly() { return true; }
26
27    function getMenuText($language) {
28        return "Simple Meta Data Editor";
29    }
30
31    function handle() {
32        if(!is_array($_REQUEST['d']) || !checkSecurityToken()) return;
33
34    }
35
36    function recurseTree($ns) {
37        global $conf;
38        $out = '';
39        $list = array();
40        $opts = array(
41            'depth' => 1,
42            'listfiles' => true,
43            'listdirs'  => true,
44            'pagesonly' => true,
45            'firsthead' => true,
46            'sneakyacl' => $conf['sneaky_index'],
47        );
48        search($list,$conf['datadir'],'search_universal',$opts,$ns);
49        foreach($list as $item)
50        {
51          if($item['type'] == 'f' || $item['type'] == 'd')
52          {
53            if($item['type'] == 'd')
54            {
55              $out .= '<li>'.$item['id'];
56              $out .= '<ul>'.$this->recurseTree(str_replace(':', '/', $item['id'])).'</ul>';
57            }
58            else
59            {
60              $out .= '<li data-jstree=\'{"icon":"'.DOKU_URL.'/lib/images/page.png"}\'>'.$item['id'];
61            }
62            $out .= '</li>';
63          }
64        }
65        return $out;
66    }
67
68    function html() {
69        echo '<h1>Meta Data Editor</h1>';
70        echo '<table>';
71        echo '<tr><th width="30\%">Page</th><th width="30\%">Meta Data</th><th width="30\%">Value</th></tr>';
72        echo '<tr>';
73        echo '<td><div id="fileTree" data-sectok="'.getSecurityToken().'">';
74        echo '<ul>'.$this->recurseTree('/').'</ul>';
75        echo '</div></td>';
76        echo '<td><div id="metaTree"></div></td>';
77        echo '<td><div id="event_path"></div><br><div id="event_result">';
78        echo '<input type="text" id="event_value" value="..."><br>';
79        echo '<input type="submit" id="event_save" value="Save">';
80        echo '</div></td>';
81        echo '</tr></table>';
82    }
83
84}
85
86// vim:ts=4:sw=4:et:enc=utf-8:
87