Server IP : 172.67.158.161 / Your IP : 18.119.121.88 Web Server : LiteSpeed System : Linux business53.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64 User : giankuin ( 1871) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /proc/self/root/proc/thread-self/root/proc/self/root/proc/self/cwd/dup-installer/classes/utilities/template/ |
Upload File : |
<?php /** * Search and reaplace manager * * Standard: PSR-2 * @link http://www.php-fig.org/psr/psr-2 Full Documentation * * @package SC\DUPX\U * */ defined('ABSPATH') || defined('DUPXABSPATH') || exit; require_once(DUPX_INIT.'/classes/utilities/template/class.u.template.item.php'); final class DUPX_Template { /** * * @var DUPX_Template */ private static $instance = null; /** * * @var DUPX_TemplateItem[] */ private $templates = array(); /** * * @var string */ private $currentTemplate = null; /** * * @return DUPX_Template */ public static function getInstance() { if (is_null(self::$instance)) { self::$instance = new self(); } return self::$instance; } private function __construct() { } /** * * @param string $name * @return boolean * @throws Exception */ public function setTemplate($name) { if (!isset($this->templates[$name])) { throw new Exception('The template '.$name.' don\'t exists'); } $this->currentTemplate = $name; return true; } /** * * @param string $name * @param srring $mainFolder * @param string $parentName * @return boolean * @throws Exception */ public function addTemplate($name, $mainFolder, $parentName = null) { if (isset($this->templates[$name])) { throw new Exception('The template "'.$name.'" already exists'); } if (is_null($parentName)) { $parent = null; } else if (isset($this->templates[$parentName])) { $parent = $this->templates[$parentName]; } else { throw new Exception('The parent template "'.$parentName.'" don\'t exists'); } $this->templates[$name] = new DUPX_TemplateItem($name, $mainFolder, $parent); return true; } /** * * @param string $fileTpl // template file is a relative path from root template folder * @param array $args // array key / val where key is the var name in template * @param bool $echo // if false return template in string * * @return void|string */ public function render($fileTpl, $args = array(), $echo = true) { return $this->templates[$this->currentTemplate]->render($fileTpl, $args, $echo); } private function __clone() { } private function __wakeup() { } } /** * * @param string $fileTpl // template file is a relative path from root template folder * @param array $args // array key / val where key is the var name in template * @param bool $echo // if false return template in string * * @return void|string */ function dupxTplRender($fileTpl, $args = array(), $echo = true) { static $tplMng = null; if (is_null($tplMng)) { $tplMng = DUPX_Template::getInstance(); } return $tplMng->render($fileTpl, $args, $echo); }