"; private $_head_items = Array(); private $_body = ""; private $_content = ""; private $_foot_items = Array(); private $view = false; //SINGLETON============================================== private function __construct() { } private static function newObj() { if (!isset(self::$_instance)) { self::$_instance = new Output(); } return self::$_instance; } public function getInstance() { if (!isset(self::$_instance)) { return self::newObj(); } return self::$_instance; } public static function load_view($name, $values = null, $location = null) { if (!$location) { $segments = explode('/', debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS)[0]['file']); array_pop($segments); $location = implode('/', $segments) . '/views/'; } if (is_array($values) && count($values) > 0) { extract($values, EXTR_PREFIX_SAME, 'data'); } $location .= $name; if (strpos('.php', $location) == 0) { $location .= '.php'; } if (!file_exists($location)) { //return require_once GENERAL_VIEW_FOLDER . 'errors/404.php'; } return require_once( $location ); } private function render_view() { if (is_array($this->view['values']) && count($this->view['values']) > 0) { extract($this->view['values'], EXTR_PREFIX_SAME, 'data'); } return require_once( $this->view['location'] ); } public function set_view($name, $values = null, $location = null) { if (!$location) { $segments = explode('/', debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS)[0]['file']); array_pop($segments); $location = implode('/', $segments) . '/views/'; } $location .= $name; if (strpos('.php', $location) == 0) { $location .= '.php'; } $this->view = Array(); $this->view['location'] = $location; $this->view['values'] = $values; } public function render() { if (is_ajax_request()) { echo $this->_content; if ($this->view) { $this->render_view(); } return; } global $DROPDOWN, $SIDEBAR; $this->_head_items[] = ''; $this->_head_items[] = ''; $this->_head_items[] = ''; $this->_head_items[] = ''; $this->_head_items[] = ''; $this->_head_items[] = ''; $this->_head_items[] = ''; $this->_head_items[] = ''; $this->_head_items[] = ''; $this->_head_items[] = ''; $this->_head_items[] = ''; $this->_head_items[] = ''; $this->_head_items[] = ''; $this->_head_items[] = ''; $this->_head_items[] = ''; $this->_foot_items[] = ''; $head = "
"; foreach ($this->_head_items as $head_item) { $head .= $head_item . "\n"; } $head .= ""; $foot = ""; foreach ($this->_foot_items as $foot_item) { $foot .= $foot_item; } $header = str_replace("{{usermenu}}", "", file_get_contents(__DIR__ . '/views/header.html')); $sidebar = str_replace("{{elements}}", $SIDEBAR->render(), file_get_contents(__DIR__ . '/views/sidebar.html')); $body_first = file_get_contents(__DIR__ . "/views/body.html"); $body_first = str_replace("{{header}}", $header, $body_first); $body_first = str_replace("{{sidebar}}", $sidebar, $body_first); $body_first .= $this->_content; $foot .= '