xref: /plugin/bez/meta/Tpl.php (revision fe5d6d1ebd253c129098b67fff8cf438a54d8650)
1<?php
2
3namespace dokuwiki\plugin\bez\meta;
4
5class Tpl {
6
7    /** @var \action_plugin_bez */
8    private $action;
9
10    private $conf;
11
12    private $variables = array();
13
14    //form values from $_POST or from database
15    private $values = array();
16
17    public function __construct(\action_plugin_bez_default $action, $conf) {
18
19        $this->action = $action;
20        $this->conf = $conf;
21
22        //constas
23        $this->set('client', $this->model->user_nick);
24
25        $info = $action->getInfo();
26        $this->set('version', $info['date']);
27
28        //common one
29        $this->set('users', $this->action->get_model()->userFactory->get_all());
30        $this->set('groups', $this->action->get_model()->userFactory->get_groups());
31    }
32
33    public function action($default=null) {
34        $action = $this->action->get_action();
35        if ($action == '' && !is_null($default)) {
36            return $default;
37        }
38        return $action;
39    }
40
41    public function param($id) {
42        return $this->action->get_param($id);
43    }
44
45    public function url() {
46        return call_user_func_array(array($this->action, 'url'), func_get_args());
47    }
48
49//    public function get_dummy_of($name) {
50//        return $this->action->get_model_of($name)->get_dummy_object();
51//    }
52
53    public function static_acl($table, $field) {
54        return $this->action->get_model()->acl->check_static_field($table, $field);
55    }
56
57    /*users info function for shorten the code*/
58    public function user_name($login=NULL) {
59        $name = $this->action->get_model()->userFactory->get_user_full_name($login);
60        if ($name === '') {
61            return $login;
62        }
63        return $name;
64    }
65
66    public function user_email($login=NULL) {
67        return $this->action->get_model()->get_user_email($login);
68    }
69    /*end users info functions*/
70
71    public function prevent_rendering() {
72
73    }
74
75    public function set($id, $value) {
76        $this->variables[$id] = $value;
77    }
78
79    public function get($id) {
80        return $this->variables[$id];
81    }
82
83    public function set_values($values) {
84        foreach ($values as $name => $value) {
85            $this->values[$name] = $value;
86        }
87    }
88
89    public function value($name) {
90        return (isset($this->values[$name]) ? $this->values[$name] : '');
91    }
92
93    public function getLang($id) {
94        return $this->action->getLang($id);
95    }
96}
97