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    function getMenuSort() { return 501; }
18    function forAdminOnly() { return true; }
19
20    function getMenuText($language) {
21        return "Simple Meta Data Editor";
22    }
23
24    function handle() {
25        if(!isset($_REQUEST['d']) || !is_array($_REQUEST['d']) || !checkSecurityToken()) return;
26
27    }
28
29    function recurseTree($ns) {
30        global $conf;
31        $out = '';
32        $list = array();
33        $opts = array(
34            'depth' => 1,
35            'listfiles' => true,
36            'listdirs'  => true,
37            'pagesonly' => true,
38            'firsthead' => true,
39            'sneakyacl' => $conf['sneaky_index'],
40        );
41        search($list,$conf['datadir'],'search_universal',$opts,$ns);
42        foreach($list as $item)
43        {
44          if($item['type'] == 'f' || $item['type'] == 'd')
45          {
46            if($item['type'] == 'd')
47            {
48              $out .= '<li>'.$item['id'];
49              $out .= '<ul>'.$this->recurseTree(str_replace(':', '/', $item['id'])).'</ul>';
50            }
51            else
52            {
53              $out .= '<li data-jstree=\'{"icon":"'.DOKU_URL.'/lib/images/page.png"}\'>'.$item['id'];
54            }
55            $out .= '</li>';
56          }
57        }
58        return $out;
59    }
60
61    function html() {
62        echo '<h1>Meta Data Editor</h1>';
63        echo '<table>';
64        echo '<tr><th width="30\%">Page</th><th width="30\%">Meta Data</th><th width="30\%">Value</th></tr>';
65        echo '<tr>';
66        echo '<td><div id="fileTree" data-sectok="'.getSecurityToken().'">';
67        echo '<ul>'.$this->recurseTree('/').'</ul>';
68        echo '</div></td>';
69        echo '<td><div id="metaTree"></div></td>';
70        echo '<td><div id="event_path"></div><br><div id="event_result">';
71        echo '<input type="text" id="event_value" value="..."><br>';
72        echo '<input type="submit" id="event_save" value="Save">';
73        echo '</div></td>';
74        echo '</tr></table>';
75    }
76
77}
78
79// vim:ts=4:sw=4:et:enc=utf-8:
80