private function __construct() { $this->_session = Axis::session('install'); if (!isset($this->_session->step)) { $this->_session->step = self::STEP_REQUIREMENTS; } }
public function getCacheKey() { if (null === $this->_cacheKey) { $this->_cacheKey = md5('admin_navigation' . Axis::session()->roleId . Axis_Locale::getLocale()->toString()); } return $this->_cacheKey; }
public function changeAction() { $code = $this->_getParam('currency-code', 'USD'); if (Axis::single('locale/currency')->isExists($code)) { Axis::session()->currency = $code; } $this->_redirect($this->_getBackUrl()); }
public function changeAction() { $code = $this->_getParam('currency-code', 'USD'); if (Axis::single('locale/currency')->isExists($code)) { Axis::session()->currency = $code; } $this->_redirect($this->getRequest()->getServer('HTTP_REFERER')); }
public function updateAction() { $this->_helper->layout->disableLayout(); $data = $this->_getParam('quantity'); foreach ($data as $itemId => $quantity) { Axis::single('checkout/cart')->updateItem($itemId, $quantity); } Axis::session()->lastUrl = $this->_getParam('last_url'); $this->_redirect($this->getRequest()->getServer('HTTP_REFERER')); }
/** * Return visitor row * * @return Zend_Db_Table_Row_Abstract */ public function getVisitor() { if (!isset(Axis::session()->visitorId) || !($row = $this->find(Axis::session()->visitorId)->current())) { $row = $this->createRow(array('session_id' => Zend_Session::getId(), 'customer_id' => Axis::getCustomerId() ? Axis::getCustomerId() : new Zend_Db_Expr('NULL'))); $row->save(); Axis::session()->visitorId = $row->id; //unset only on logout } return $row; }
/** * * @param Zend_Controller_Request_Abstract $request * @return void */ public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request) { if (Axis_Area::isFrontend() && null !== $request->getParam('locale')) { $locale = $request->getParam('locale'); } elseif (isset(Axis::session()->locale)) { $locale = Axis::session()->locale; } else { $locale = Axis_Locale::getDefaultLocale(); } Axis_Locale::setLocale($locale); }
public function init() { $this->initView(); $layout = Zend_Layout::getMvcInstance(); $this->_session = Axis::session('install'); $this->view->baseUrl = Zend_Controller_Front::getInstance()->getBaseUrl(); $this->view->addHelperPath('app/views/helpers', 'Axis_View_Helper'); $this->view->doctype('XHTML1_STRICT'); $layout->setView($this->view)->setOptions(array('layoutPath' => 'app/views/layouts', 'layout' => 'layout')); $this->_install = Axis_Install_Model_Wizard::getInstance(); }
public function updateIndexAction() { $indexer = Axis::model('search/indexer'); $session = Axis::session('search_index'); if ($this->_getParam('reset_session', false)) { $indexer->removeAllIndexesFromFilesystem(); $session->page = 1; $session->processed = 0; $session->completeProduct = false; } $rowCount = $this->_getParam('limit', 50); if (!$session->completeProduct) { $select = Axis::model('catalog/product')->select(array('id', 'sku'))->join('catalog_product_description', 'cpd.product_id = cp.id', array('name', 'description'))->joinRight('locale_language', 'll.id = cpd.language_id', 'locale')->joinLeft('catalog_product_image', 'cpi.id = cp.image_thumbnail', array('image_thumbnail' => 'path'))->joinLeft('catalog_product_image_title', 'cpit.image_id = cpi.id', array('image_title' => 'title'))->join('catalog_product_category', 'cp.id = cpc.product_id')->join('catalog_category', 'cc.id = cpc.category_id', 'site_id')->joinLeft('catalog_hurl', "ch.key_id = cp.id AND ch.key_type='p'", 'key_word')->order('cc.site_id')->order('cpd.language_id')->group(array('cc.site_id', 'cpd.language_id', 'cp.id'))->calcFoundRows()->limitPage($session->page, $rowCount); } else { $select = Axis::model('cms/page_content')->select('*')->join('cms_page_category', 'cpc2.cms_page_id = cpc.cms_page_id')->join('cms_category', 'cc.id = cpc2.cms_category_id', 'site_id')->joinRight('locale_language', 'll.id = cpc.language_id', 'locale')->order('cc.site_id')->order('cpc.language_id')->calcFoundRows(); } $rowset = $select->fetchRowset(); $count = $select->foundRows(); $index = $path = null; foreach ($rowset as $_row) { $_path = $indexer->getIndexPath($_row->site_id . '/' . $_row->locale); //next index if ($path !== $_path) { //save prev index if ($index) { $index->optimize(); $index->commit(); } $path = $_path; $index = $indexer->getIndex($path); } $index->addDocument($indexer->getDocument($_row)); } if ($index) { $index->optimize(); $index->commit(); } $session->processed += $rowset->count(); $session->page++; Axis::message()->addSuccess(Axis::translate('search')->__("%d of %d items(s) was processed", $session->processed, $count)); $completed = false; if ($count == $session->processed) { if ($session->completeProduct) { $completed = true; $session->unsetAll(); } else { $session->page = 1; $session->processed = 0; $session->completeProduct = true; } } $this->_helper->json->sendSuccess(array('completed' => $completed)); }
protected function _initLocale() { $session = Axis::session('install'); $timezone = Axis_Locale::DEFAULT_TIMEZONE; $locale = Axis_Locale::DEFAULT_LOCALE; if (is_array($session->locale)) { $timezone = current($session->locale['timezone']); } if ($session->current_locale) { $locale = $session->current_locale; } Axis_Locale::setLocale($locale); Axis_Locale::setTimezone($timezone); }
/** * @return bool */ protected function _hasSnapshot() { return isset(Axis::session()->snapshot) && !empty(Axis::session()->snapshot); }
/** * * @param int $id * @return void */ protected function _setCartId($id) { Axis::session()->cartId = $id; $this->_cartId = $id; }
protected function _getCacheKeyParams() { return array(Axis::session()->roleId); }
public function logoutAction() { Zend_Auth::getInstance()->clearIdentity(); unset(Axis::session()->roleId); $this->_redirect('auth'); }
protected function _initSession() { $cacheDir = AXIS_ROOT . '/var/sessions'; if (!is_readable($cacheDir)) { mkdir($cacheDir, 0777); } elseif (!is_writable($cacheDir)) { chmod($cacheDir, 0777); } Zend_Session::setOptions(array('cookie_lifetime' => 864000, 'name' => 'axisid', 'strict' => 'off', 'save_path' => $cacheDir, 'cookie_httponly' => true)); try { Zend_Session::start(); } catch (Zend_Session_Exception $e) { Zend_Session::destroy(); // ZF doesn't allow to start session after destroying if (!headers_sent()) { $host = $_SERVER['HTTP_HOST']; $uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\'); header("Location: http://{$host}{$uri}/"); } exit; } return Axis::session(); }
public function importAction() { $profile_options = $this->_getParam('profile'); $general_options = $this->_getParam('general'); $language_options = array_filter($this->_getParam('language', array())); $primary_language = $this->_getParam('primary_language'); $data_options = $this->_getParam('data', array()); if (!$primary_language) { Axis::message()->addError(Axis::translate('admin')->__('Set the primary language please')); return $this->_helper->json->sendFailure(array('finalize' => true)); } if ($this->_getParam('clearSession') && !count($data_options)) { Axis::message()->addError(Axis::translate('admin')->__('Select data to import')); return $this->_helper->json->sendFailure(array('finalize' => true)); } if (!count($language_options)) { Axis::message()->addError(Axis::translate('admin')->__('At least one language should be determined')); return $this->_helper->json->sendFailure(array('finalize' => true)); } $this->_adapter = $this->_getAdapter($profile_options); if (!$this->_adapter) { Axis::message()->addError(Axis::translate('admin')->__('Cannot connect to database')); return $this->_helper->json->sendFailure(array('finalize' => true)); } if ($this->_getParam('clearSession')) { Axis::session()->import_queue = $this->_adapter->getQueue(); Axis::session()->group_iterator = 0; Axis::session()->language_iterator = 0; unset($_SESSION['processed_count']); $data_options = array_keys($data_options); Axis::session()->group_queue = array_values(array_intersect($this->_adapter->getQueue(), $data_options)); } $group_to_import = Axis::session()->group_queue[Axis::session()->group_iterator]; $data = array(); $data = $this->_adapter->import($group_to_import, $language_options, $general_options['site'], $primary_language); $data['finalize'] = false; if ($data['completed_group'] && isset(Axis::session()->group_queue[Axis::session()->group_iterator + 1])) { Axis::session()->group_iterator++; } elseif ($data['completed_group']) { $data['finalize'] = true; } return $this->_helper->json->sendSuccess(array('silent' => true, 'group' => $group_to_import, 'finalize' => $data['finalize'], 'processed' => $data['processed'], 'imported' => $data['imported'], 'messages' => $data['messages'], 'group' => $data['group'])); }
/** * * @return string */ public function getCode() { if (null !== $this->_currentCurrencyCode) { return $this->_currentCurrencyCode; } if (isset(Axis::session()->currency) && $this->isExists(Axis::session()->currency)) { $this->_currentCurrencyCode = Axis::session()->currency; } elseif (isset(Axis::config()->locale->main->currency) && $this->isExists(Axis::config()->locale->main->currency)) { $this->_currentCurrencyCode = Axis::config()->locale->main->currency; } elseif ($this->isExists(Axis_Locale::DEFAULT_CURRENCY)) { $this->_currentCurrencyCode = Axis_Locale::DEFAULT_CURRENCY; } else { $this->_currentCurrencyCode = $this->select('code')->order('id')->fetchOne(); if (!$this->_currentCurrencyCode) { throw new Axis_Exception(Axis::translate('locale')->__('No currencies found')); } } return $this->_currentCurrencyCode; }
public function updatePriceIndexAction() { $this->_helper->layout->disableLayout(); $mPriceIndex = Axis::model('catalog/product_price_index'); $session = Axis::session('price_index'); if (!$this->_getParam('skip_session', false)) { $session->page = 1; $session->processed = 0; $mPriceIndex->delete("id > 0"); } $select = Axis::model('catalog/product')->select('*')->calcFoundRows()->limitPage($session->page, $this->_getParam('limit', 50)); $products = $select->fetchAssoc(); $count = $select->foundRows(); $mPriceIndex->updateIndexesByProducts($products); $session->processed += count($products); $session->page++; Axis::message()->addSuccess(Axis::translate('catalog')->__("%d of %d product(s) was processed", $session->processed, $count)); $completed = false; if ($count == $session->processed) { $completed = true; $session->unsetAll(); } $this->_helper->json->sendSuccess(array('completed' => $completed)); }
public function logout() { unset(Axis::session()->visitorId); // ? Zend_Session::regenerateId(); }
/** * */ private function __construct() { if (!self::$_session instanceof Zend_Session_Namespace) { self::$_session = Axis::session(self::$_namespace); } }
public function exportBranchAction() { $time_start_script = time(); $this->_helper->layout->disableLayout(); $params = $this->_getAllParams(); if ($params['clearSession']) { unset(Axis::session('gbase')->last_exported); Axis::session('gbase')->processed_count = 0; Axis::session('gbase')->imported_count = 0; } $productModel = Axis::model('catalog/product'); $categoryModel = Axis::model('catalog/category'); $category = $categoryModel->find($params['catId'])->current(); if ($category->lvl == 0 || $params['recursive']) { $count = $category->getProductsCount(true); } else { $count = $category->getProductsCount(); } $time_export = 0; $last = false; while (true) { $time_start_item = time(); $product_id = $this->_getProductId($params['catId'], $params['recursive']); if (!$product_id) { $last = true; break; } $this->_insert($product_id, $params); $time_end_item = time(); $time_sript = $time_end_item - $time_start_script; $time_export_item = max($time_end_item - $time_start_item, $time_export); if ($time_sript + $time_export_item > 20) { break; } } $messages = array(); if ($last) { Axis::message()->addSuccess(Axis::translate('admin')->__('Export process has been completed. %d item(s) was exported. %d item(s) was skipped', Axis::session('gbase')->imported_count, $count - Axis::session('gbase')->imported_count)); } $this->_helper->json->sendSuccess(array('finalize' => $last, 'processed' => Axis::session('gbase')->imported_count, 'count' => $count)); }
/** * Retrieve current review listing params * order, dir, limit, page * * @return array */ private function _getListingParams() { if ($this->_hasParam('dir') && in_array($this->_getParam('dir'), array('asc', 'desc'))) { $dir = $this->_getParam('dir'); } elseif (Axis::session('review')->dir) { $dir = Axis::session('review')->dir; } else { $dir = 'desc'; } Axis::session('review')->dir = $dir; if ($this->_hasParam('order') && in_array($this->_getParam('order'), array('date', 'rating'))) { switch ($this->_getParam('order')) { case 'date': $order = 'cr.date_created'; break; case 'rating': $order = 'rating'; break; default: $order = 'cr.date_created'; break; } } elseif (Axis::session('review')->order) { $order = Axis::session('review')->order; } else { $order = 'cr.date_created'; } Axis::session('review')->order = $order; if ($this->_hasParam('limit')) { $limit = $this->_getParam('limit'); if (!is_numeric($limit) || $limit == 0) { $limit = null; } } elseif (Axis::session('review')->limit) { $limit = Axis::session('review')->limit; } elseif (is_numeric(Axis::config('community/review/perPageDefault'))) { $limit = Axis::config('community/review/perPageDefault'); } else { $limit = 10; } Axis::session('review')->limit = $limit; if ($this->_hasParam('page') && is_numeric($this->_getParam('page'))) { $page = $this->_getParam('page'); } else { $page = 1; } return array('order' => $order, 'dir' => $dir, 'limit' => $limit, 'page' => $page); }
public function resultAction() { $this->_helper->breadcrumbs(array('label' => Axis::translate('search')->__('Search'), 'route' => 'search')); if (!$this->_hasParam('q')) { return $this->_forward('not-found', 'Error', 'Axis_Core'); } $paging = array(); $queryStr = trim($this->_getParam('q', '')); $this->setTitle(Axis::translate('search')->__("Search results for '%s'", $queryStr)); $this->view->query = $queryStr; $paging['page'] = $page = (int) $this->_getParam('page', 1); if (empty($queryStr)) { $this->render(); return; } try { $lucene = Axis::single('search/lucene'); $result = array(); $query = $lucene->createFuzzyQuery($queryStr); $result = $lucene->findFuzzy($query); } catch (Exception $e) { Axis::message()->addError($e->getMessage()); $this->view->results = array(); $this->render(); return; } Axis::single('search/log')->logging(array('num_results' => count($result), 'query' => $queryStr)); if (!count($result)) { // if nothing found $this->view->results = array(); $this->render(); return; } $paging['perPage'] = array(); $perPageArray = explode(',', Axis::config('catalog/listing/perPage')); foreach ($perPageArray as $perPage) { $url = $this->view->url(array('limit' => $perPage, 'page' => null, 'q' => $queryStr)); $paging['perPage'][$url] = $perPage; } if ($this->_hasParam('limit') && in_array($this->_getParam('limit'), $perPageArray)) { $limit = (int) $this->_getParam('limit'); } elseif (Axis::session('catalog')->limit) { $limit = Axis::session('catalog')->limit; } else { $limit = Axis::config('catalog/listing/perPageDefault'); } $paging['limit'] = $limit; $paging['page'] = $page = (int) $this->_getParam('page', 1); $paging['count'] = count($result); $this->setCanonicalUrl($this->view->url(array('q' => $queryStr, 'page' => $page, 'limit' => $limit)), 'search_result', true); // Axis::session('catalog')->limit = $limit; if ('all' === $limit) { $paging['limit'] = $paging['count']; $limit = $paging['count']; } $this->view->paging = $paging; $founded = array(); for ($i = ($page - 1) * $limit, $n = $i + $limit; isset($result[$i]) && $i < $n; $i++) { $founded[] = $lucene->getDocumentData($result[$i], $query); } foreach ($founded as &$found) { $found['url'] = urlencode($found['url']); } Axis::dispatch('search_use', array('query' => $queryStr, 'result' => $founded, 'customer_id' => Axis::getCustomerId())); $this->view->results = $founded; $this->render(); }
public function hasItems() { return count(Axis::session()->compareList) > 0; }
/** * View category action (listing product) */ public function viewAction() { if (count($this->hurl->getSeoParams()) && !$this->hurl->hasParam('cat') && !$this->hurl->hasParam('manufacturer') && !$this->hurl->hasParam('product')) { return $this->_forward('not-found', 'Error', 'Axis_Core'); } $this->setCanonicalUrl($this->view->hurl($this->hurl->getParams())); if ($this->hurl->hasParam('product') || $this->getRequest()->getParam('product')) { $this->_request->setActionName('product'); return $this->productAction(); } $this->view->pageTitle = Axis::translate('catalog')->__('Catalog'); /** * @var Axis_Catalog_Model_Product_Select */ $select = Axis::model('catalog/product')->select('id'); $select->addFilterByAvailability()->joinCategory()->where('cc.site_id = ?', Axis::getSiteId()); if ($this->hurl->hasParam('cat')) { if (!($category = $this->_initCategory($this->hurl->getParamValue('cat')))) { return $this->_forward('not-found', 'Error', 'Axis_Core'); } $select->where('cc.id = ?', $category['id']); } if ($this->hurl->hasParam('manufacturer')) { $select->where('cp.manufacturer_id = ?', $this->hurl->getParamValue('manufacturer')); } // $select->addPrice(); if ($this->hurl->hasParam('price')) { $price = explode(',', $this->hurl->getParam('price')); $from = $price[0]; $to = isset($price[1]) ? $price[1] : null; $select->addFilterByFinalPrice($from, $to); } if ($this->hurl->hasParam('attributes')) { $select->addFilterByAttributes($this->hurl->getAttributeIds()); } $paging = array(); $paging['page'] = (int) $this->hurl->getParam('page', 1); if ($paging['page'] < 1) { $paging['page'] = 1; } $paging['perPage'] = array(); foreach (explode(',', Axis::config('catalog/listing/perPage')) as $perPage) { $optionValue = $this->view->hurl(array('limit' => $perPage, 'page' => null)); $paging['perPage'][$optionValue] = $perPage; } $paging['sortBy'] = array(); foreach (explode(',', Axis::config('catalog/listing/sortBy')) as $order) { $optionValue = $this->view->hurl(array('order' => strtolower($order), 'page' => null)); $optionText = Axis::translate('catalog')->__($order); $paging['sortBy'][$optionValue] = $optionText; } if ($this->hurl->hasParam('limit') && in_array($this->hurl->getParam('limit'), $paging['perPage'])) { $paging['limit'] = $this->hurl->getParam('limit'); } elseif (Axis::session('catalog')->limit) { $paging['limit'] = Axis::session('catalog')->limit; } else { $paging['limit'] = Axis::config('catalog/listing/perPageDefault'); } Axis::session('catalog')->limit = $paging['limit']; if ($this->hurl->hasParam('order') && in_array($this->hurl->getParam('order'), array('name', 'price'))) { $paging['order'] = $this->hurl->getParam('order'); } elseif (Axis::session('catalog')->order) { $paging['order'] = Axis::session('catalog')->order; } else { $paging['order'] = 'name'; } Axis::session('catalog')->order = $paging['order']; if ($this->hurl->hasParam('dir') && in_array($this->hurl->getParam('dir'), array('desc', 'asc'))) { $paging['dir'] = $this->hurl->getParam('dir'); } elseif (Axis::session('catalog')->dir) { $paging['dir'] = Axis::session('catalog')->dir; } else { $paging['dir'] = 'asc'; } Axis::session('catalog')->dir = $paging['dir']; switch ($paging['order']) { case 'name': $select->addDescription()->order('cpd.name' . ' ' . $paging['dir']); break; case 'price': $select->orderByFinalPrice($paging['dir']); break; } $productList = $select->limit($paging['limit'] == 'all' ? 0 : $paging['limit'], ($paging['page'] - 1) * ($paging['limit'] == 'all' ? 0 : $paging['limit']))->fetchList(); $paging['count'] = $productList['count']; $this->view->products = $productList['data']; $paging['pages'] = 1; if ($paging['limit'] != 'all') { $paging['pages'] = ceil($paging['count'] / $paging['limit']); } $this->view->paging = $paging; if ($this->hurl->hasParam('mode')) { $mode = $this->hurl->getParam('mode'); } elseif (Axis::session('catalog')->mode) { $mode = Axis::session('catalog')->mode; } else { $mode = Axis::config()->catalog->listing->type; } $this->view->mode = $mode; Axis::session('catalog')->mode = $mode; $this->render('listing'); }
/** * Return checkout data storage * * @return Zend_Session_Namespace */ public function getStorage() { if (null === $this->_storage) { $this->_storage = Axis::session($this->_code . '-Checkout'); $this->_storage->setExpirationSeconds(600); $this->_storage->setExpirationHops(5); } return $this->_storage; }
/** * Retrieve languageId from session; * * @static * @return int */ public static function getLanguageId() { if (!isset(Axis::session()->language)) { if (Axis_Area::isBackend()) { Axis::session()->language = Axis::config('locale/main/language_admin'); } else { Axis::session()->language = Axis::config('locale/main/language_front'); } } return Axis::session()->language; }
/** * Return checkout data storage * * @return Zend_Session_Namespace */ public function getStorage() { if (!$this->_storage instanceof Zend_Session_Namespace) { $this->_storage = Axis::session('Checkout'); } return $this->_storage; }