/** * Render banner into template * @access public * @param int $id is id entity (brand, category, product, page) .... for main id = 0 * @param string $group * @return boolean * @author L.Andriy <*****@*****.**> * @copyright (c) 2013, ImageCMS */ public function render($id = 0, $group = 0) { if ($this->no_install === false) { return false; } $type = $this->core->core_data['data_type']; $lang = $this->get_main_lang('identif'); $painting = $type . '_' . (int) $id; $hash = 'baners' . $type . $id . \CI_Controller::get_instance()->config->item('template'); if ($cache = Cache_html::get_html($hash)) { \CMSFactory\assetManager::create()->registerScript('jquery.cycle.all.min'); echo $cache; } else { $banners = $this->banner_model->get_all_banner($lang, $group); foreach ($banners as $banner) { $data = unserialize($banner['where_show']); if ((in_array($painting, $data) || in_array($type . '_0', $data)) && $banner['active'] && (time() < $banner['active_to'] or $banner['active_to'] == '-1')) { $ban[] = $banner; } } if (count($ban) > 0) { $tpl = $this->banner_model->get_settings_tpl() ? $type . '_slider' : 'slider'; ob_start(); \CMSFactory\assetManager::create()->registerStyle('style')->registerScript('jquery.cycle.all.min')->setData(array('banners' => $ban))->render($tpl, TRUE); $baners_view = ob_get_clean(); Cache_html::set_html($baners_view, $hash); echo $baners_view; } else { return FALSE; } } }
public static function get_html($file) { self::$path = PUBPATH . 'system/cache/templates_c/HTML/'; if (!\CI_Controller::get_instance()->config->item('tpl_force_compile')) { $file = $file . MY_Controller::getCurrentLocale(); $file = self::$path . md5($file) . '.html'; if (file_exists($file)) { if (time() - filemtime($file) > \CI_Controller::get_instance()->config->item('tpl_compiled_ttl')) { @unlink($file); return false; } else { return file_get_contents($file); } } else { return false; } } else { return false; } }