public function __construct($params = null) { parent::__construct($params); $this->page = max(1, $this->getRequest()->get('page', 1, waRequest::TYPE_INT)); $this->search_params = $this->getRequest()->param(); $layout = $this->getRequest()->get('layout', 'default', waRequest::TYPE_STRING_TRIM); if ($layout == 'lazyloading' && $this->page > 1) { $this->is_lazyloading = true; } if (false && ($this->cache_time = $this->getConfig()->getOption('cache_time'))) { $params = $this->search_params; $params['page'] = $this->page; $this->cache_id = blogHelper::buildCacheKey($params); /** * @todo enable partial caching wait for Smarty 3.2.x * @link http://www.smarty.net/forums/viewtopic.php?p=75251 */ $this->cache = new waSerializeCache($this->cache_id, $this->cache_time); if ($this->cache->isCached()) { if ($post_ids = $this->cache->get()) { //get comments count per post $posts = array_fill_keys($post_ids, array()); blogHelper::extendPostComments($posts); $this->view->assign('posts', $posts); } } } if (!$this->is_lazyloading) { $this->setLayout(new blogFrontendLayout()); } $this->setThemeTemplate('stream.html'); return $this; }
public static function saveDomainsSettings($domains_settings) { $app_settings_model = new waAppSettingsModel(); $routing = wa()->getRouting(); $domains_routes = $routing->getByApp('shop'); $app_settings_model->set(shopPricePlugin::$plugin_id, 'domains_settings', json_encode($domains_settings)); $cache = new waSerializeCache('shopPricePlugin'); if ($cache && $cache->isCached()) { $cache->delete(); } }
private static function getCacheValue($key, $default = null, $path = null) { //TODO use $path as max actual time $key .= '.' . self::$locale; if ($path) { $key .= '.' . $path; } $key = md5($key); $value = $default; if (!self::$force && self::$cache_ttl && class_exists('waSerializeCache')) { $cacher = new waSerializeCache($key, self::$cache_ttl, 'installer'); if ($cacher->isCached()) { $value = $cacher->get(); } } return $value; }
public static function saveDomainsSettings($domains_settings) { $app_settings_model = new waAppSettingsModel(); $routing = wa()->getRouting(); $domains_routes = $routing->getByApp('shop'); foreach ($domains_routes as $domain => $routes) { foreach ($routes as $route) { $domain_route = md5($domain . '/' . $route['url']); foreach (shopOnestepPlugin::$default_settings['templates'] as $id => $template) { $tpl_full_path = $template['tpl_path'] . $domain_route . '_' . $template['tpl_name'] . '.' . $template['tpl_ext']; $template_path = wa()->getDataPath($tpl_full_path, $template['public'], 'shop', true); @unlink($template_path); if (empty($domains_settings[$domain_route]['templates'][$id]['reset_tpl'])) { $source_path = wa()->getAppPath($template['tpl_path'] . $template['tpl_name'] . '.' . $template['tpl_ext'], 'shop'); $source_content = file_get_contents($source_path); if (!isset($domains_settings[$domain_route]['templates'][$id]['template'])) { continue; } $post_template = $domains_settings[$domain_route]['templates'][$id]['template']; if (preg_replace('/\\s/', '', $source_content) != preg_replace('/\\s/', '', $post_template)) { $f = fopen($template_path, 'w'); if (!$f) { throw new waException('Не удаётся сохранить шаблон. Проверьте права на запись ' . $template_path); } fwrite($f, $post_template); fclose($f); } } } unset($domains_settings[$domain_route]['templates']); } } $app_settings_model->set(shopOnestepPlugin::$plugin_id, 'domains_settings', json_encode($domains_settings)); $cache = new waSerializeCache('shopOnestepPlugin'); if ($cache && $cache->isCached()) { $cache->delete(); } }
private static function getCacheValue($path, $default = null) { $key = __CLASS__ . '.' . md5($path); $value = $default; if (self::$cache_ttl && class_exists('waSerializeCache')) { $cache = new waSerializeCache($key, self::$cache_ttl, 'installer'); if ($cache->isCached()) { $value = $cache->get(); } } return $value; }
public function isCached() { return $this->cache->isCached(); }