Skip to content
Snippets Groups Projects
Select Git revision
  • 960f450fd5b70ff25cb014c33cc0fa3e058f4737
  • master default
  • method_check
  • custom_prefix
  • package
  • cookies
  • v2.1.1
  • v2.1.0
  • v2.1.0-rc5
  • v2.1.0-rc4
  • v2.1.0-rc3
  • v2.1.0-rc2
  • v2.1.0-rc1
  • v2.0.7
  • v2.0.6
  • v2.0.5
  • v2.0.4
  • v2.0.3
  • v2.0.2
  • v2.0.1
  • v2.0.0
  • v1.2.8
  • v1.2.7
  • v1.2.6
  • v1.2.5
  • v1.2.4
26 results

session.go

Blame
  • ViewHelper.php 1.18 KiB
    <?php
    
    namespace QuasselRestSearch;
    
    class ViewHelper {
        protected $template_dir;
        protected $translation;
        protected $vars = [];
    
        public function __construct($translation, $vars = null) {
            $this->translation = $translation;
            $this->setPath('../../templates/');
            if ($vars !== null) {
                $this->vars = $vars;
            }
        }
    
        public function setPath(string $path) {
            $this->template_dir = realpath(dirname(__FILE__) . '/' . $path);
        }
    
        public function render($template_file) {
            $translation = $this->translation;
            $t = function ($path) use ($translation) {
                $arr = explode(".", $path);
                $var = $translation;
                foreach ($arr as $key)
                    $var = $var[$key];
                echo $var;
            };
    
            $path = $this->template_dir . '/' . $template_file . '.phtml';
            if (file_exists($path)) {
                include $path;
            } else {
                throw new \Exception('Template ' . $path . ' not found ');
            }
        }
    
        public function __get($name) {
            return $this->vars[$name];
        }
    
        public function __set($name, $value) {
            $this->vars[$name] = $value;
        }
    }