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 getDomainsSettings() { $cache = new waSerializeCache('shopPricePlugin'); if ($cache && $cache->isCached()) { $domains_settings = $cache->get(); } else { $app_settings_model = new waAppSettingsModel(); $routing = wa()->getRouting(); $domains_routes = $routing->getByApp('shop'); $app_settings_model->get(shopPricePlugin::$plugin_id, 'domains_settings'); $domains_settings = json_decode($app_settings_model->get(shopPricePlugin::$plugin_id, 'domains_settings'), true); if (empty($domains_settings)) { $domains_settings = array(); } foreach ($domains_routes as $domain => $routes) { foreach ($routes as $route) { $domain_route = md5($domain . '/' . $route['url']); if (empty($domains_settings[$domain_route])) { $domains_settings[$domain_route] = shopPricePlugin::$default_settings; } } if ($domains_settings && $cache) { $cache->set($domains_settings); } } } return $domains_settings; }
public function execute() { if ($this->thread_id = waRequest::get('thread_id', false)) { $cache = new waSerializeCache($this->getApp() . '.' . $this->thread_id); $this->urls = $cache->get(); $cache->delete(); } if ($this->urls) { wa()->getStorage()->close(); ob_start(); try { $this->model = new waAppSettingsModel(); $log_level = waSystemConfig::isDebug() ? waInstaller::LOG_DEBUG : waInstaller::LOG_WARNING; $updater = new waInstaller($log_level, $this->thread_id); $this->getStorage()->close(); $updater->init(); $this->model->ping(); $storage = wa()->getStorage(); $storage->close(); $this->urls = $updater->update($this->urls); if (waRequest::request('install')) { $this->install(); } $this->response['sources'] = $this->getResult(); $this->response['current_state'] = $updater->getState(); $this->response['state'] = $updater->getFullState(waRequest::get('mode', 'apps')); //cleanup cache $this->cleanup(); //update themes foreach ($this->urls as $url) { if (preg_match('@(wa-apps/)?(.+)/themes/(.+)@', $url['slug'], $matches)) { try { $theme = new waTheme($matches[3], $matches[2]); $theme->update(); } catch (Exception $ex) { waLog::log(sprintf('Error during theme %s@%s update: %s', $matches[3], $matches[2], $ex->getMessage())); } } } //and again cleanup $this->cleanup(); $this->getConfig()->setCount(false); $response = $this->getResponse(); $response->addHeader('Content-Type', 'application/json; charset=utf-8'); $response->sendHeaders(); } catch (Exception $ex) { $this->setError($ex->getMessage()); } if ($ob = ob_get_clean()) { $this->response['warning'] = $ob; waLog::log('Output at ' . __METHOD__ . ': ' . $ob); } } else { throw new Exception('nothing to update'); } }
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 getDomainsSettings() { $cache = new waSerializeCache('shopOnestepPlugin'); if ($cache && $cache->isCached()) { $domains_settings = $cache->get(); } else { $app_settings_model = new waAppSettingsModel(); $routing = wa()->getRouting(); $domains_routes = $routing->getByApp('shop'); $app_settings_model->get(shopOnestepPlugin::$plugin_id, 'domains_settings'); $domains_settings = json_decode($app_settings_model->get(shopOnestepPlugin::$plugin_id, 'domains_settings'), true); if (empty($domains_settings)) { $domains_settings = array(); } foreach ($domains_routes as $domain => $routes) { foreach ($routes as $route) { $domain_route = md5($domain . '/' . $route['url']); if (empty($domains_settings[$domain_route])) { $domains_settings[$domain_route] = shopOnestepPlugin::$default_settings; } foreach (shopOnestepPlugin::$default_settings['templates'] as $tpl_name => $tpl) { $domains_settings[$domain_route]['templates'][$tpl_name] = $tpl; $tpl_full_path = $tpl['tpl_path'] . $domain_route . '_' . $tpl['tpl_name'] . '.' . $tpl['tpl_ext']; $domains_settings[$domain_route]['templates'][$tpl_name]['tpl_full_path'] = $tpl_full_path; $template_path = wa()->getDataPath($tpl_full_path, $tpl['public'], 'shop', true); if (file_exists($template_path)) { $domains_settings[$domain_route]['templates'][$tpl_name]['template_path'] = $template_path; $domains_settings[$domain_route]['templates'][$tpl_name]['template'] = file_get_contents($template_path); $domains_settings[$domain_route]['templates'][$tpl_name]['change_tpl'] = 1; } else { $domains_settings[$domain_route]['templates'][$tpl_name]['tpl_full_path'] = $tpl['tpl_path'] . $tpl['tpl_name'] . '.' . $tpl['tpl_ext']; $template_path = wa()->getAppPath($tpl['tpl_path'] . $tpl['tpl_name'] . '.' . $tpl['tpl_ext'], 'shop'); $domains_settings[$domain_route]['templates'][$tpl_name]['template_path'] = $template_path; $domains_settings[$domain_route]['templates'][$tpl_name]['template'] = file_get_contents($template_path); $domains_settings[$domain_route]['templates'][$tpl_name]['change_tpl'] = 0; } } } if ($domains_settings && $cache) { $cache->set($domains_settings); } } } return $domains_settings; }
public function allowedAddress() { $cache = new waSerializeCache(__CLASS__ . __FUNCTION__, 86400, 'webasyst'); if (!($addresses = $cache->get())) { $addresses = array(); /* countries */ $countries = $this->request('ems.get.locations', array('type' => 'countries')); $country_model = new waCountryModel(); $map = $country_model->getAll('iso2letter'); $address = array('country' => array()); foreach ($countries['locations'] as $country) { if (ifset($country['type']) == 'countries' && ($value = strtolower(ifset($country['value']))) && isset($map[$value])) { $address['country'][] = $map[$value]['iso3letter']; } } $addresses[] = $address; /* regions */ $region_model = new waRegionModel(); $address = array('country' => 'rus', 'region' => array()); $map = $region_model->getByCountry('rus'); foreach ($map as $region) { if ($this->findTo(array('country' => 'rus', 'region_name' => $region['name']))) { $address['region'][] = $region['code']; } } $addresses[] = $address; $cache->set($addresses); } return $addresses; }
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 get() { return $this->cache->get(); }