/** * Generating view file. * * @param $file * @param null $data */ public function __construct($file, $data = null) { //Set path to the view file $file_location = VIEWS_DIR . $file . '.' . $this->view_extension; $this->path = realpath($file_location); //Check if file is exist if (!is_file($this->path)) { throw new Aries_Exception($file_location . ' didn\'t exist'); } //Extracting data to content $content = ''; ob_start(); //Get language file. include_once $this->language_folder . $_SESSION[Config::$lang_session] . '.' . $this->language_ext; //Sent data to view $data[$this->base_url] = Config::getConfig(Config::$base); $data[$this->current_year] = Controller::getCurrentYear(); extract($data); extract($lang); require_once $this->path; $content .= ob_get_clean(); //Extracting the data to template ob_start(); //Process auto combine and autoload if (Config::getPlugins(Config::$combineCss) == 'true' && Config::isAutoloadExist(Config::$autoload_css)) { Controller::combineCss(); $t[$this->css] = '<link href="' . Config::getConfig(Config::$base) . $this->caches_folder . $this->combined_css_filename . '" type="text/css" rel="stylesheet"/>'; } else { if (Config::isAutoloadExist(Config::$autoload_css)) { $t[$this->css] = Controller::cssBuilder(); } else { $t[$this->css] = ''; } } //Process auto combine and autoload if (Config::getPlugins(Config::$combineJs) == 'true' && Config::isAutoloadExist(Config::$autoload_js)) { Controller::combineJs(); $t[$this->js] = '<script src="' . Config::getConfig(Config::$base) . $this->caches_folder . $this->combined_js_filename . '" type="text/javascript"></script>'; } else { if (Config::isAutoloadExist(Config::$autoload_js)) { $t[$this->js] = Controller::jsBuilder(); } else { $t[$this->js] = ''; } } //Insert content into template $t[$this->content] = $content; //Inject variable into template extract($data); extract($lang); extract($t); //Load template require_once realpath(VIEWS_DIR . DIRECTORY_SEPARATOR . $this->template_name . '.' . $this->template_ext); $text = ob_get_clean(); //Compressing html page before send it to browser if (Config::getPlugins(Config::$htmlCompress) == 'true') { $this->result = Controller::htmlCompressor($text); } else { $this->result = $text; } }