Пример #1
0
 /**
  * Retrieve the category list
  * with category description for one product
  *
  * @param int $productId
  * @param int $languageId
  * @return array Where the keys are the cateogory id
  */
 public function getCategoriesByProductId($productId, $languageId = null)
 {
     if (null === $languageId) {
         $languageId = Axis_Locale::getLanguageId();
     }
     return $this->select('*')->joinLeft('catalog_category_description', 'ccd.category_id = cpc.category_id AND ccd.language_id = ' . $languageId, '*')->where('cpc.product_id = ?', $productId)->fetchAssoc();
 }
Пример #2
0
 private function _initSeoParams($keywords)
 {
     if (!sizeof($keywords)) {
         return array();
     }
     $rowset = Axis::single('catalog/hurl')->select()->where('key_word IN (?)', $keywords)->where('site_id = ?', Axis::getSiteId())->fetchAssoc();
     foreach ($rowset as $row) {
         switch ($row['key_type']) {
             case 'c':
                 $this->_params['cat']['value'] = $row['key_id'];
                 if (empty($this->_params['cat']['seo'])) {
                     $this->_params['cat']['seo'] = $row['key_word'];
                 } else {
                     $this->_params['cat']['seo'] .= '/' . $row['key_word'];
                 }
                 break;
             case 'p':
                 $this->_params['product']['value'] = $row['key_id'];
                 $this->_params['product']['seo'] = $row['key_word'];
                 $this->getRequest()->setParam('product', $row['key_id']);
                 break;
             case 'm':
                 $mDescription = Axis::single('catalog/product_manufacturer_description')->select(array('title', 'description'))->where('manufacturer_id = ?', $row['key_id'])->where('language_id = ?', Axis_Locale::getLanguageId())->fetchRow();
                 $this->_params['manufacturer'] = array('value' => $row['key_id'], 'seo' => $row['key_word'], 'title' => $mDescription->title, 'description' => $mDescription->description);
                 break;
             default:
                 break;
         }
     }
 }
Пример #3
0
 /**
  * Adds product_name column to select
  *
  * @param integer $languageId [optional]
  * @return Axis_Tag_Model_Customer_Select
  */
 public function addProductDescription($languageId = null)
 {
     if (null === $languageId) {
         $languageId = Axis_Locale::getLanguageId();
     }
     return $this->joinLeft('catalog_product_description', 'tp.product_id = cpd.product_id AND cpd.language_id = ' . $languageId, array('product_name' => 'name'));
 }
Пример #4
0
 /**
  *
  * @param int $valueSetId
  * @param int $languageId
  * @return array
  */
 public function getCustomValues($valueSetId, $languageId = null)
 {
     if (null === $languageId) {
         $languageId = Axis_Locale::getLanguageId();
     }
     return $this->select('id')->join('account_customer_valueset_value_label', 'acvvl.valueset_value_id = acvv.id', 'label')->where('acvv.is_active = 1')->where('acvv.customer_valueset_id = ?', $valueSetId)->where('acvvl.language_id = ?', $languageId)->order('acvv.sort_order')->fetchPairs();
 }
Пример #5
0
 public function getCacheKey()
 {
     if (null === $this->_cacheKey) {
         $this->_cacheKey = md5('admin_navigation' . Axis::session()->roleId . Axis_Locale::getLocale()->toString());
     }
     return $this->_cacheKey;
 }
Пример #6
0
 protected function _initCategory($id)
 {
     $categoryRow = Axis::single('catalog/category')->find($id)->current();
     if (!$categoryRow || $categoryRow->status != 'enabled') {
         return false;
     }
     $parentItems = $categoryRow->cache()->getParentItems();
     foreach ($parentItems as $_category) {
         if ($_category['status'] != 'enabled') {
             return false;
         }
         $_uri = $this->view->hurl(array('cat' => array('value' => $_category['id'], 'seo' => $_category['key_word'])));
         $this->_helper->breadcrumbs(array('label' => $_category['name'], 'uri' => $_uri));
     }
     $categoryDescriptionRow = Axis::single('catalog/category_description')->find($id, Axis_Locale::getLanguageId())->current();
     if (!$categoryDescriptionRow) {
         return false;
     } else {
         $this->view->category = array_merge($categoryRow->toArray(), $categoryDescriptionRow->toArray());
         $this->view->pageTitle = $categoryDescriptionRow->name;
         $this->view->meta()->setDescription($categoryDescriptionRow->meta_description)->setTitle($categoryDescriptionRow->meta_title)->setKeywords($categoryDescriptionRow->meta_keyword);
     }
     Zend_Registry::set('catalog/current_category', $categoryRow);
     return $this->view->category;
 }
Пример #7
0
 public function indexAction()
 {
     $this->view->pageTitle = Axis::translate('account')->__('Manage Customers');
     if ($this->_hasParam('customerId')) {
         $this->view->customerId = $this->_getParam('customerId');
     }
     $this->view->userForm = array();
     $this->view->valueSet = array();
     $modelCustomerValueSetValue = Axis::model('account/Customer_ValueSet_Value');
     $modelCustomerFields = Axis::model('account/customer_field');
     $fieldGroups = Axis::single('account/Customer_FieldGroup')->getGroups(Axis_Locale::getLanguageId());
     foreach ($fieldGroups as $fieldGroup) {
         //getting all fields
         $this->view->userForm[$fieldGroup['id']]['title'] = $fieldGroup['title'];
         $this->view->userForm[$fieldGroup['id']]['is_active'] = $fieldGroup['is_active'];
         $this->view->userForm[$fieldGroup['id']]['fields'] = $modelCustomerFields->getFieldsByGroup($fieldGroup['id']);
         //getting only used valuesets
         foreach ($this->view->userForm[$fieldGroup['id']]['fields'] as $fd) {
             if (!isset($fd['customer_valueset_id'])) {
                 continue;
             }
             $this->view->valueSet[$fd['customer_valueset_id']]['values'] = $modelCustomerValueSetValue->getValues($fd['customer_valueset_id']);
         }
     }
     $this->render();
 }
Пример #8
0
 /**
  * Construct, create index
  *
  * @param string $indexPath[optional]
  * @param string $encoding[optional]
  * @throws Axis_Exception
  */
 public function __construct(array $params)
 {
     $encoding = $this->_encoding;
     $indexPath = array_shift($params);
     if (count($params)) {
         $encoding = array_shift($params);
     }
     if (null === $indexPath) {
         $site = Axis::getSite()->id;
         $locale = Axis::single('locale/language')->find(Axis_Locale::getLanguageId())->current()->locale;
         $indexPath = Axis::config()->system->path . '/var/index/' . $site . '/' . $locale;
     }
     if (!is_readable($indexPath)) {
         throw new Axis_Exception(Axis::translate('search')->__('Please, update search indexes, to enable search functionality'));
     }
     /*
     $mySimilarity = new Axis_Similarity();
     Zend_Search_Lucene_Search_Similarity::setDefault($mySimilarity);
     */
     Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding($encoding);
     // add filter by words
     $stopWords = array('a', 'an', 'at', 'the', 'and', 'or', 'is', 'am');
     $stopWordsFilter = new Zend_Search_Lucene_Analysis_TokenFilter_StopWords($stopWords);
     $analyzer = new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive();
     $analyzer->addFilter($stopWordsFilter);
     Zend_Search_Lucene_Analysis_Analyzer::setDefault($analyzer);
     $this->_index = Zend_Search_Lucene::open($indexPath);
     $this->_encoding = $encoding;
 }
Пример #9
0
 protected function _beforeRender()
 {
     $modelQuestion = Axis::single('poll/question');
     if ($this->hasQuestionId()) {
         $this->_questionId = $this->getQuestionId();
         $this->setQuestionId(null);
     } else {
         $this->_questionId = $modelQuestion->getOneNotVotedQuestionIdByCookie();
     }
     if (!$this->_questionId) {
         return false;
     }
     $question = $modelQuestion->getQuestionWithAnswers($this->_questionId, Axis_Locale::getLanguageId());
     if (!$question) {
         return false;
     }
     $results = array();
     $totalVoteCount = 0;
     $this->_showResult = (bool) $this->getShowResult();
     $this->setShowResult(null);
     if ($this->_showResult) {
         $questionRow = Axis::single('poll/question')->find($this->_questionId)->current();
         $results = $questionRow->getResults();
         $totalVoteCount = $questionRow->getTotalVoteCount();
     }
     $this->setFromArray(array('question' => $question, 'answers' => $question['answers'], 'results' => $results, 'status' => $this->_showResult, 'total_count' => $totalVoteCount));
     return true;
 }
Пример #10
0
 public function indexAction()
 {
     $this->setCanonicalUrl($this->view->url(array(), 'cms', true));
     $this->setTitle(Axis::translate('cms')->__('Pages'), null, false);
     $categories = Axis::single('cms/category')->select(array('id', 'parent_id'))->addCategoryContentTable()->columns(array('ccc.link', 'ccc.title'))->addActiveFilter()->addSiteFilter(Axis::getSiteId())->addLanguageIdFilter(Axis_Locale::getLanguageId())->order('cc.parent_id')->where('ccc.link IS NOT NULL')->fetchAssoc();
     $pages = Axis::single('cms/page')->select(array('id', 'name'))->join(array('cpca' => 'cms_page_category'), 'cp.id = cpca.cms_page_id', 'cms_category_id')->join('cms_page_content', 'cp.id = cpc.cms_page_id', array('link', 'title'))->where('cp.is_active = 1')->where('cpc.language_id = ?', Axis_Locale::getLanguageId())->where('cpca.cms_category_id IN (?)', array_keys($categories))->order('cpca.cms_category_id')->fetchAssoc();
     $menu = new Zend_Navigation();
     foreach ($categories as $_category) {
         $title = empty($_category['title']) ? $_category['link'] : $_category['title'];
         $page = new Zend_Navigation_Page_Mvc(array('category_id' => $_category['id'], 'label' => $title, 'title' => $title, 'route' => 'cms_category', 'params' => array('cat' => $_category['link']), 'class' => 'icon-folder'));
         $_container = $menu->findBy('category_id', $_category['parent_id']);
         if (null === $_container) {
             $_container = $menu;
         }
         $_container->addPage($page);
     }
     foreach ($pages as $_page) {
         $title = empty($_page['title']) ? $_page['link'] : $_page['title'];
         $page = new Zend_Navigation_Page_Mvc(array('label' => $title, 'title' => $title, 'route' => 'cms_page', 'params' => array('page' => $_page['link']), 'class' => 'icon-page'));
         $_container = $menu->findBy('category_id', $_page['cms_category_id']);
         $_container->addPage($page);
     }
     $this->view->menu = $menu;
     $this->render();
 }
Пример #11
0
 public function init()
 {
     $categories = Axis::single('catalog/category')->select('*')->addName(Axis_Locale::getLanguageId())->addKeyWord()->order('cc.lft')->addSiteFilter(Axis::getSiteId())->addDisabledFilter()->fetchAll();
     if (!is_array($this->_activeCategories)) {
         $this->_activeCategories = array();
         if (Zend_Registry::isRegistered('catalog/current_category')) {
             $this->_activeCategories = array_keys(Zend_Registry::get('catalog/current_category')->cache()->getParentItems());
         }
     }
     $container = $_container = new Zend_Navigation();
     $lvl = 0;
     $view = $this->getView();
     foreach ($categories as $_category) {
         $uri = $view->hurl(array('cat' => array('value' => $_category['id'], 'seo' => $_category['key_word']), 'controller' => 'catalog', 'action' => 'view'), false, true);
         $class = 'nav-' . str_replace('.', '-', $_category['key_word']);
         $page = new Zend_Navigation_Page_Uri(array('label' => $_category['name'], 'title' => $_category['name'], 'uri' => $uri, 'order' => $_category['lft'], 'class' => $class, 'visible' => 'enabled' === $_category['status'] ? true : false, 'active' => in_array($_category['id'], $this->_activeCategories)));
         $lvl = $lvl - $_category['lvl'] + 1;
         for ($i = 0; $i < $lvl; $i++) {
             $_container = $_container->getParent();
         }
         $lvl = $_category['lvl'];
         $_container->addPage($page);
         $_container = $page;
     }
     $this->setData('menu', $container);
     return true;
 }
Пример #12
0
 public function indexAction()
 {
     $this->setTitle(Axis::translate('poll')->__('Polls'));
     $languageId = Axis_Locale::getLanguageId();
     $questionIds = array();
     if ($this->_hasParam('questionId')) {
         $questionIds[] = array('id' => $this->_getParam('questionId'));
     }
     $modelVote = Axis::single('poll/vote');
     $modelAnswer = Axis::single('poll/answer');
     $questions = Axis::single('poll/question')->getQuestions($languageId, $questionIds);
     $answers = array();
     foreach ($modelAnswer->getAnswers($languageId) as $answer) {
         $answers[$answer['question_id']][] = $answer;
     }
     $votes = $modelVote->getVoteCount();
     $customerVotes = $modelVote->getVoteCount(Axis::getCustomerId());
     $results = $modelVote->getResults();
     $cookieVotedQuestionIds = $modelVote->getQuestionIdsFromCookie();
     $showResult = (bool) $this->_getParam('showResult', false);
     foreach ($questions as &$question) {
         $question['answer'] = isset($answers[$question['id']]) ? $answers[$question['id']] : array();
         $isVoted = $showResult || in_array($question['id'], $cookieVotedQuestionIds) || isset($customerVotes[$question['id']]) && 0 < $customerVotes[$question['id']];
         $question['status'] = false;
         if ($isVoted) {
             $question['results'] = isset($results[$question['id']]) ? $results[$question['id']] : array();
             $question['totalCount'] = $votes[$question['id']];
             $question['status'] = true;
         }
     }
     $this->view->questions = $questions;
     $this->render('all');
 }
Пример #13
0
 /**
  * Add all columns from cms_page_content table to select
  *
  * @param int $languageId [optional]
  * @return  Axis_Admin_Model_Cms_Page_Select
  */
 public function addContent($languageId = null)
 {
     if (null === $languageId) {
         $languageId = Axis_Locale::getLanguageId();
     }
     $this->joinLeft('cms_page_content', $this->getAdapter()->quoteInto('cp.id = cpc.cms_page_id AND cpc.language_id = ?', $languageId), '*');
     return $this;
 }
Пример #14
0
 public function __construct($options = null)
 {
     $default = array('id' => 'form-contacts', 'action' => Zend_Controller_Front::getInstance()->getBaseUrl() . Axis_Locale::getLanguageUrl() . '/contacts');
     if (is_array($options)) {
         $default = array_merge($default, $options);
     }
     parent::__construct($default);
 }
Пример #15
0
 public function getPages($languageId = null)
 {
     if (null == $languageId) {
         $languageId = Axis_Locale::getLanguageId();
     }
     /*get pages*/
     return Axis::single('cms/page_content')->select(array('link', 'title'))->joinInner(array('cpca' => 'cms_page_category'), 'cpc.cms_page_id = cpca.cms_page_id')->joinInner('cms_page', 'cp.id = cpc.cms_page_id')->where('cpca.cms_category_id = ?', $this->id)->where('cpc.language_id = ?', $languageId)->where('cp.is_active = 1')->where('cpc.link IS NOT NULL')->fetchAll();
 }
Пример #16
0
 /**
  * @param array $options[productId => int]
  */
 function __construct($options = null)
 {
     $product = $options['productId'];
     $default = array('id' => 'form-review', 'action' => Zend_Controller_Front::getInstance()->getBaseUrl() . Axis_Locale::getLanguageUrl() . '/review/add/product/' . $product);
     if (is_array($options)) {
         $default = array_merge($default, $options);
     }
     parent::__construct($default);
 }
Пример #17
0
 /**
  * 
  * @return array
  */
 protected function _loadCollection()
 {
     $locale = Axis_Locale::getLocale();
     $currencies = $locale->getTranslationList('NameToCurrency', $locale);
     if (!$currencies) {
         $currencies = $locale->getTranslationList('NameToCurrency', Axis_Locale::DEFAULT_LOCALE);
     }
     return $currencies;
 }
Пример #18
0
 public function hurl(array $options = array(), $ssl = false, $reset = false)
 {
     $baseUrl = $ssl && $this->_enabledSsl ? $this->view->secureUrl : $this->view->baseUrl;
     $locale = isset($options['locale']) ? $options['locale'] : Axis_Locale::getLanguageUrl();
     if (!empty($locale)) {
         $locale = '/' . $locale;
     }
     return $baseUrl . $locale . '/' . Axis::config('catalog/main/route') . $this->_hurl->url($options, $reset);
 }
Пример #19
0
 /**
  * Generates an url given the name of a route.
  *
  * @access public
  *
  * @param  array $urlOptions Options passed to the assemble method of the Route object.
  * @param  mixed $name The name of a Route to use. If null it will use the current Route
  * @param  bool $reset Whether or not to reset the route defaults with those provided
  * @return string Url for the link href attribute.
  */
 public function url(array $urlOptions = array(), $name = null, $reset = false, $encode = true)
 {
     $locale = trim(Axis_Locale::getLanguageUrl(), '/ ');
     if (!empty($locale)) {
         $urlOptions = array_merge(array('locale' => $locale), $urlOptions);
     }
     $urlOptions = array_merge($_GET, $urlOptions);
     return parent::url($urlOptions, $name, $reset, $encode);
 }
Пример #20
0
 public function __construct($options = null)
 {
     $page = $options['pageId'];
     $default = array('id' => 'form-page-comment', 'action' => Zend_Controller_Front::getInstance()->getBaseUrl() . Axis_Locale::getLanguageUrl() . '/cms/comment/add/page/' . $page . '#form-page-comment');
     if (is_array($options)) {
         $default = array_merge($default, $options);
     }
     parent::__construct($default);
 }
Пример #21
0
 /**
  *
  * @return array
  */
 protected function _loadCollection()
 {
     $locale = Axis_Locale::getLocale();
     $countries = $locale->getTranslationList('territory', $locale, 2);
     if (!$countries) {
         $countries = $locale->getTranslationList('territory', Axis_Locale::DEFAULT_LOCALE, 2);
     }
     return $countries;
 }
Пример #22
0
 /**
  *
  * @static
  * @param string $id
  * @return mixed string|void
  */
 public static function getName($id)
 {
     if (empty($id)) {
         return;
     }
     $locale = Axis_Locale::getLocale();
     $name = $locale->getTranslation($id, 'NameToCurrency', $locale);
     return empty($name) ? $id : $name . ' (' . $id . ')';
 }
Пример #23
0
 /**
  *
  * @static
  * @param string $id
  * @return mixed string|void
  */
 public static function getName($id)
 {
     if (empty($id)) {
         return;
     }
     $locale = Axis_Locale::getLocale();
     $name = $locale->getTranslation($id, 'WindowsToTimezone', $locale);
     return empty($name) ? $id : $name . ' (' . $id . ')';
 }
Пример #24
0
 /**
  * Redirect to another URL
  *
  * @param string $url [optional]
  * @param bool $addLanguage [optional]
  * @param array $options Options to be used when redirecting
  * @return void
  */
 protected function _redirect($url, array $options = array(), $addLanguage = true)
 {
     $httpReferer = $this->getRequest()->getServer('HTTP_REFERER');
     if ($httpReferer && $url == $httpReferer || !$addLanguage) {
         parent::_redirect($url, $options);
         return;
     }
     parent::_redirect(rtrim(Axis_Locale::getLanguageUrl(), '/') . '/' . ltrim($url, '/'), $options);
 }
Пример #25
0
 public function getResults()
 {
     $languageId = Axis_Locale::getLanguageId();
     $rowset = $this->select(array('answer_id', 'cnt' => 'COUNT(*)'))->join('poll_answer', 'pa.id = pv.answer_id', 'question_id')->where('pa.language_id = ?', $languageId)->group('pv.answer_id')->order('cnt')->fetchAssoc();
     $dataset = array();
     foreach ($rowset as $row) {
         $dataset[$row['question_id']][$row['answer_id']] = $row;
     }
     return $dataset;
 }
Пример #26
0
 /**
  *
  * @param string $href
  * @param bool $ssl [optional]
  * @return string
  */
 public function href($href = '', $ssl = false)
 {
     $baseUrl = $ssl && $this->_enabledSsl ? $this->view->secureUrl : $this->view->baseUrl;
     $locale = isset($options['locale']) ? $options['locale'] : Axis_Locale::getLanguageUrl();
     $href = trim($href, '/');
     if (!empty($href)) {
         $href = '/' . $href;
     }
     return $baseUrl . $locale . $href;
 }
Пример #27
0
 /**
  *
  * @param array $fieldGroupIds
  * @param int $languageId
  * @return array
  */
 public function getCustomGroups($fieldGroupIds, $languageId = null)
 {
     if (!is_array($fieldGroupIds)) {
         $fieldGroupIds = array($fieldGroupIds);
     }
     if (null === $languageId) {
         $languageId = Axis_Locale::getLanguageId();
     }
     return $this->select(array('id', 'sort_order', 'name'))->join('account_customer_fieldgroup_label', 'acfl.customer_field_group_id = acf.id', 'group_label')->where('acf.id IN(?)', $fieldGroupIds)->where('acfl.language_id = ?', $languageId)->fetchAll();
 }
 public function addJsValidateTranslation()
 {
     if (file_exists('js/jquery/jquery-validation-1.9.01/localization/messages_' . Axis_Locale::getLocale()->toString() . '.js')) {
         $this->view->headScript()->appendFile('js/jquery/jquery-validation-1.9.0/localization/messages_' . Axis_Locale::getLocale()->toString() . '.js');
     } elseif (file_exists('js/jquery/jquery-validation-1.9.0/localization/messages_' . Axis_Locale::getLocale()->getLanguage() . '.js')) {
         $this->view->headScript()->appendFile('js/jquery/jquery-validation-1.9.0/localization/messages_' . Axis_Locale::getLocale()->getLanguage() . '.js');
     } elseif (file_exists('js/jquery/jquery-validation-1.9.0/localization/messages_' . strtolower(Axis_Locale::getLocale()->getRegion()) . '.js')) {
         $this->view->headScript()->appendFile('js/jquery/jquery-validation-1.9.0/localization/messages_' . strtolower(Axis_Locale::getLocale()->getRegion()) . '.js');
     }
 }
Пример #29
0
 /**
  *
  * @static
  * @param int $id
  * @return mixed string|void
  */
 public static function getName($id)
 {
     if (empty($id)) {
         return;
     }
     $data = explode('_', $id);
     $locale = Axis_Locale::getLocale();
     $language = $locale->getTranslation($data[0], 'language', $locale);
     $country = $locale->getTranslation($data[1], 'country', $locale);
     return ucfirst($language) . ' (' . $country . ')';
 }
Пример #30
0
 /**
  *
  * @return Axis_Cms_Model_Page_Content_Row
  */
 public function getContent()
 {
     $languageId = Axis_Locale::getLanguageId();
     $columns = array('title', 'content', 'meta_keyword', 'meta_description', 'meta_title');
     $row = Axis::model('cms/page_content')->select($columns)->joinLeft('cms_page', 'cp.id = cpc.cms_page_id', array('layout'))->where('cpc.language_id = ?', $languageId)->where('cpc.cms_page_id = ?', $this->id)->fetchRow();
     if (!$row) {
         return false;
     }
     $row->content = $row->getContent();
     return $row;
 }