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 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; }
private static function setCacheValue($key, $value, $path = null) { $key .= '.' . self::$locale; if ($path) { $key .= '.' . md5($path); } $key = md5($key); if (class_exists('waSerializeCache')) { $cacher = new waSerializeCache($key, self::$cache_ttl, 'installer'); $cacher->set($value); } return $value; }
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; }
public function execute() { $this->init(); try { $updater = new waInstaller(waInstaller::LOG_TRACE); $state = $updater->getState(); if (!isset($state['stage_status']) || $state['stage_name'] != waInstaller::STAGE_NONE && $state['heartbeat'] > waInstaller::TIMEOUT_RESUME + 5 || $state['stage_name'] == waInstaller::STAGE_UPDATE && $state['heartbeat'] || $state['stage_status'] == waInstaller::STATE_ERROR && $state['heartbeat'] || $state['stage_name'] == waInstaller::STAGE_NONE && $state['heartbeat'] === false) { $updater->setState(); $state = $updater->getState(); $apps = installerHelper::getInstaller(); $items = $apps->getUpdates(null, $this->getItemsList()); $queue_apps = array(); $execute_actions = array(waInstallerApps::ACTION_INSTALL, waInstallerApps::ACTION_CRITICAL_UPDATE, waInstallerApps::ACTION_UPDATE); foreach ($items as $app_id => $info) { if (!empty($info['download_url']) && in_array($info['action'], $execute_actions)) { $info['subject'] = 'app'; if ($app_id == 'installer') { foreach ($info['download_url'] as $target => $url) { $_info = $info; $_info['download_url'] = $url; $_info['name'] = _w('Webasyst Framework') . ' (' . $target . ')'; $this->add($target, $_info); $queue_apps[$target] = $_info; unset($_info); } } else { $target = 'wa-apps/' . $app_id; $this->add($target, $info, $app_id); $queue_apps[$target] = $info; } } foreach (array('themes', 'plugins') as $type) { if (!empty($info[$type]) && is_array($info[$type])) { foreach ($info[$type] as $extra_id => $extras_info) { if (!empty($extras_info['download_url']) && in_array($extras_info['action'], $execute_actions)) { $extras_info['subject'] = 'app_' . $type; if ($type == 'themes' && is_array($extras_info['download_url'])) { foreach ($extras_info['download_url'] as $target => $url) { $__info = $extras_info; $__info['download_url'] = $url; $__info['slug'] = preg_replace('@^wa-apps/@', '', $target); $__info['app'] = preg_replace('@^wa-apps/([^/]+)/.+$@', '$1', $target); if (!isset($queue_apps[$target])) { if ($__info['app'] == $app_id || empty($items[$__info['app']][$type][$extra_id])) { if (!empty($items[$__info['app']][$type][$extra_id]['name'])) { $__info['name'] .= " ({$info['name']})"; } elseif ($app_info = wa()->getAppInfo($__info['app'])) { $__info['name'] .= " ({$app_info['name']})"; } else { $__info['name'] .= " ({$__info['app']})"; } $this->add($target, $__info); $queue_apps[$target] = $__info; } } } } else { if (!empty($info['name'])) { $extras_info['name'] .= " ({$info['name']})"; } if (strpos($app_id, '/')) { //system plugins $target = $app_id . '/' . $extra_id; } else { $target = 'wa-apps/' . $app_id . '/' . $type . '/' . $extra_id; } $this->add($target, $extras_info, $target); $queue_apps[$target] = $extras_info; } } } } } unset($info); } if (!$queue_apps) { throw new waException(_w('Please select items for update')); } if (!waRequest::get('_')) { $this->setLayout(new installerBackendLayout()); $this->getLayout()->assign('no_ajax', true); } $this->view->assign('action', 'update'); $this->view->assign('queue_apps', $queue_apps); $install = waRequest::request('install'); $this->view->assign('install', !empty($install) ? 'install' : ''); $this->view->assign('title', _w('Updates')); $this->view->assign('thread_id', $state['thread_id']); $this->view->assign('return_url', waRequest::post('return_url')); $cache = new waSerializeCache($this->getApp() . '.' . $state['thread_id']); $cache->set($this->urls); } else { $msg = _w('Update is already in progress. Please wait while previous update session is finished before starting update session again.'); $this->redirect(array('module' => $this->module, 'msg' => installerMessage::getInstance()->raiseMessage($msg, installerMessage::R_FAIL))); } } catch (Exception $ex) { $this->redirect(array('module' => $this->module, 'msg' => installerMessage::getInstance()->raiseMessage($ex->getMessage(), installerMessage::R_FAIL))); } }
private static function setCacheValue($path, $value) { $key = __CLASS__ . '.' . md5($path); if (class_exists('waSerializeCache')) { $cache = new waSerializeCache($key, self::$cache_ttl, 'installer'); $cache->set($value); } return $value; }
public function execute() { if ($this->getRequest()->param('blog_id') === false) { throw new waException(_w('Blog not found'), 404); } $this->view->getHelper()->globals($this->getRequest()->param()); $posts_per_page = max(1, intval($this->getConfig()->getOption('posts_per_page'))); $post_model = new blogPostModel(); $options = array(); if (!$this->appSettings('show_comments', true)) { $options['comments'] = false; } $options['params'] = true; $options['text'] = 'cut'; $options['escape'] = true; $is_search = false; if (isset($this->search_params["search"])) { $plugin = $this->search_params["search"]; if (!isset($this->search_params["plugin"])) { $this->search_params["plugin"] = array(); } if (isset($this->search_params[$plugin])) { $this->search_params["plugin"][$plugin] = $this->search_params[$plugin]; $is_search = true; } } $query = $this->getRequest()->get('query', '', waRequest::TYPE_STRING_TRIM); if ($query) { $this->search_params['text'] = urldecode($query); $options['highlighted'] = true; } $blogs = blogHelper::getAvailable(); $posts = $post_model->search($this->search_params, $options, array('blog' => $blogs))->fetchSearchPage($this->page, $posts_per_page); $stream_title = false; if (isset($this->search_params['contact_id'])) { if (count($posts)) { reset($posts); $post = current($posts); $name = $post['user']['name']; $is_search = true; } else { if ($contact = blogHelper::getContactInfo($this->search_params['contact_id'])) { $name = htmlentities($contact['name'], ENT_QUOTES, 'utf-8'); $is_search = true; } else { throw new waException(_w('Blog not found'), 404); } } $stream_title = sprintf(_w('Posts by %s'), $name); $this->getResponse()->setTitle($stream_title); } elseif ($is_search) { $stream_title = $this->getResponse()->getTitle(); } elseif (isset($this->search_params['year'])) { $stream_title = ''; if (isset($this->search_params['day'])) { $stream_title .= intval($this->search_params['day']) . ' '; } if (isset($this->search_params['month'])) { $stream_title .= _ws(date("F", gmmktime(0, 0, 0, intval($this->search_params['month']), 1))) . ' '; } $stream_title .= $this->search_params['year'] . ' — ' . $this->getResponse()->getTitle(); $this->getResponse()->setTitle($stream_title); } else { if (!empty($this->search_params['text'])) { $stream_title = urldecode($this->search_params['text']); $this->getResponse()->setTitle($stream_title); $is_search = true; } } $this->view->assign('stream_title', $stream_title); $pages = $post_model->pageCount(); $url = wa()->getRouteUrl('blog/frontend', $this->search_params, true); if ($pages && $pages < $this->page) { $page = min($pages, $this->page); $redirect = $url . ($page > 1 ? "?page={$page}" : ''); $this->getResponse()->redirect($redirect, 302); } if ($layout = $this->getLayout()) { $links = array(); if ($pages > $this->page) { $page = $this->page + 1; $links['next'] = "{$url}?page={$page}"; } if ($this->page > 1) { $page = $this->page - 1; $links['prev'] = $url . ($page > 1 ? "?page={$page}" : ''); } $layout->assign('links', $links); if (!$is_search) { /* * @deprecated fix assigning sidebar_timeline for next version of blog * */ $layout->assign('sidebar_timeline', $post_model->getTimeline($this->search_params['blog_id'], $blogs, $this->search_params)); } if (isset($this->search_params['contact_id'])) { $layout->assign('action_info', array('search' => array('contact_id' => $this->search_params['contact_id']))); } $layout->assign('is_search', $is_search); } $this->view->assign('is_search', $is_search); $this->view->assign('page', $this->page); $this->view->assign('is_lazyloading', $this->is_lazyloading); $this->view->assign('pages', $pages); $this->view->assign('post_count', $post_model->searchCount()); $this->view->assign('show_comments', !isset($options['comments']) || $options['comments']); $this->view->assign('posts_per_page', $posts_per_page); $this->view->assign('blog_query', $query); /** * Backward compatibility with older themes * @deprecated */ $this->view->assign('is_concrete_blog', waRequest::param('blog_url') ? true : false); $this->view->assign('layout_type', $this->is_lazyloading ? 'lazyloading' : ($this->page > 1 ? 'page' : 'default')); if ($this->getConfig()->getOption('can_use_smarty')) { foreach ($posts as &$post) { try { $post['text'] = $this->view->fetch("string:{$post['text']}", $this->cache_id); } catch (SmartyException $ex) { $post['text'] = blogPost::handleTemplateException($ex, $post); } } unset($post); } $this->view->assign('posts', $posts); if ($this->cache_time && false) { $this->cache->set(array_keys($posts)); } }
public function set($value) { return $this->cache->set($value); }