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 mailto($to, $subject, $body) { 50 return 'mailto:'.$to.'?subject='.rawurlencode($subject).'&body='.rawurlencode($body); 51 } 52 53// public function get_dummy_of($name) { 54// return $this->action->get_model_of($name)->get_dummy_object(); 55// } 56 57 public function static_acl($table, $field) { 58 return $this->action->get_model()->acl->check_static_field($table, $field); 59 } 60 61 /*users info function for shorten the code*/ 62 public function user_name($login=NULL) { 63 $name = $this->action->get_model()->userFactory->get_user_full_name($login); 64 if ($name === '') { 65 return $login; 66 } 67 return $name; 68 } 69 70 public function user_email($login=NULL) { 71 return $this->action->get_model()->userFactory->get_user_email($login); 72 } 73 /*end users info functions*/ 74 75 public function prevent_rendering() { 76 77 } 78 79 public function set($id, $value) { 80 $this->variables[$id] = $value; 81 } 82 83 public function get($id) { 84 return $this->variables[$id]; 85 } 86 87 public function set_values($values) { 88 foreach ($values as $name => $value) { 89 $this->values[$name] = $value; 90 } 91 } 92 93 public function value($name) { 94 return (isset($this->values[$name]) ? $this->values[$name] : ''); 95 } 96 97 public function getLang($id) { 98 return $this->action->getLang($id); 99 } 100} 101