Esempio n. 1
0
 public function getCacheKey()
 {
     if (null === $this->_cacheKey) {
         $this->_cacheKey = md5('admin_navigation' . Axis::session()->roleId . Axis_Locale::getLocale()->toString());
     }
     return $this->_cacheKey;
 }
Esempio n. 2
0
 /**
  * Constructor
  * @param  string|integer|Zend_Date|array  $date    OPTIONAL Date value or value of date part to set
  *                                                 ,depending on $part. If null the actual time is set
  * @param  string                          $part    OPTIONAL Defines the input format of $date
  * @param  string|Zend_Locale              $locale  OPTIONAL Locale for parsing input
  * @return Axis_Date
  * @throws Zend_Date_Exception
  */
 public function __construct($date = null, $part = null, $locale = null)
 {
     if (null === $locale) {
         $locale = Axis_Locale::getLocale();
     }
     // supress notice about PCRE without UTF8 support
     @parent::__construct($date, $part, $locale);
 }
Esempio n. 3
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 . ')';
 }
Esempio n. 4
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;
 }
Esempio n. 5
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 . ')';
 }
Esempio n. 6
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;
 }
 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');
     }
 }
Esempio n. 8
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 . ')';
 }
Esempio n. 9
0
 /**
  *
  * @return array
  */
 protected function _loadCollection()
 {
     $options = array();
     $locale = Axis_Locale::getLocale();
     $zones = $locale->getTranslationList('WindowsToTimezone', $locale);
     if (!$zones) {
         $zones = $locale->getTranslationList('WindowsToTimezone', Axis_Locale::DEFAULT_LOCALE);
     }
     asort($zones);
     foreach ($zones as $code => $name) {
         $name = trim($name);
         $options[$code] = empty($name) ? $code : $name . ' (' . $code . ')';
     }
     return $options;
 }
Esempio n. 10
0
 /**
  *
  * @param array $data
  * @return type 
  */
 public function create(array $data)
 {
     $row = $this->createRow($data);
     if (empty($row->password)) {
         $row->password = $this->generatePassword();
     }
     $password = $row->password;
     $row->password = md5($password);
     $row->modified_at = Axis_Date::now()->toSQLString();
     if (empty($row->created_at)) {
         $row->created_at = $row->modified_at;
     }
     if (empty($row->locale)) {
         $row->locale = Axis_Locale::getLocale()->toString();
     }
     $row->save();
     return array($row, $password);
 }
Esempio n. 11
0
 /**
  * 
  * @return array
  */
 protected function _loadCollection()
 {
     $options = array();
     $locale = Axis_Locale::getLocale();
     $locales = $locale->getLocaleList();
     // error  here
     $languages = $locale->getTranslationList('language', $locale);
     $countries = $locale->getTranslationList('territory', $locale, 2);
     if (!$languages || !$countries) {
         $languages = $locale->getTranslationList('language', Axis_Locale::DEFAULT_LOCALE);
         $countries = $locale->getTranslationList('territory', Axis_Locale::DEFAULT_LOCALE, 2);
     }
     foreach ($locales as $code => $isActive) {
         if (!strstr($code, '_')) {
             continue;
         }
         list($languageCode, $countryCode) = explode('_', $code);
         if (!isset($languages[$languageCode]) || !isset($countries[$countryCode])) {
             continue;
         }
         $options[$code] = ucfirst($languages[$languageCode]) . ' (' . $countries[$countryCode] . ')';
     }
     return $options;
 }
Esempio n. 12
0
 /**
  * Return Zend_Currency object
  *
  * @param string $code
  * @return Zend_Currency
  */
 public function getCurrency($code = '')
 {
     if (empty($code)) {
         $code = $this->getCode();
     }
     if (!isset($this->_currency[$code])) {
         $options = $this->_getCurrencyOptions($code);
         Zend_Currency::setCache(Axis::cache());
         try {
             $currency = new Zend_Currency($options['currency'], $options['format'] === null ? Axis_Locale::getLocale() : $options['format']);
         } catch (Zend_Currency_Exception $e) {
             Axis::message()->addError($e->getMessage() . ": " . Axis::translate('locale')->__("Try to change the format of this currency to English (United States) - en_US"));
             $options = $this->_getSystemSafeCurrencyOptions();
             $currency = new Zend_Currency($options['currency'], $options['format']);
         }
         $currency->setFormat($options);
         $this->_currency[$code] = $currency;
     }
     return $this->_currency[$code];
 }
Esempio n. 13
0
 /**
  * Retrieve the code of current Axis locale
  *
  * @return string
  */
 public function getLocale()
 {
     return Axis_Locale::getLocale()->toString();
 }
Esempio n. 14
0
 /**
  * Set the locale to be used for email template and subject
  * Locale will be automatically switched back after calling the send method
  *
  * @param string $locale Locale code
  */
 public function setLocale($locale)
 {
     $this->_locale = Axis_Locale::getLocale()->toString();
     Axis_Locale::setLocale($locale);
 }
Esempio n. 15
0
 /**
  * Retrieve the list of available admin intrerface tranlations
  *
  * @static
  * @return array
  */
 public static function getAdminLocales()
 {
     if (!($locales = Axis::cache()->load('locales_list'))) {
         $path = Axis::config()->system->path . '/app/locale';
         try {
             $locales_dir = new DirectoryIterator($path);
         } catch (Exception $e) {
             throw new Axis_Exception("Directory {$path} not readable");
         }
         $locale = Axis_Locale::getLocale();
         $locales = array();
         foreach ($locales_dir as $localeDir) {
             $localeCode = $localeDir->getFilename();
             if ($localeCode[0] == '.' || !strstr($localeCode, '_')) {
                 continue;
             }
             list($language, $country) = explode('_', $localeCode, 2);
             $language = $locale->getTranslation($language, 'language', $localeCode);
             $country = $locale->getTranslation($country, 'country', $localeCode);
             if (!$language) {
                 $language = $locale->getTranslation($language, 'language', Axis_Locale::DEFAULT_LOCALE);
             }
             if (!$country) {
                 $country = $locale->getTranslation($country, 'country', Axis_Locale::DEFAULT_LOCALE);
             }
             $locales[$localeCode] = ucfirst($language) . ' (' . $country . ')';
         }
         ksort($locales);
         Axis::cache()->save($locales, 'locales_list', array('locales'));
     }
     return $locales;
 }
Esempio n. 16
0
 /**
  * Create order, and clears shopping cart after that
  *
  * @return Axis_Sales_Model_Order_Row
  * @throws Axis_Exception
  */
 public function createFromCheckout()
 {
     /**
      * @var Axis_Checkout_Model_Checkout  $checkout
      */
     $checkout = Axis::single('checkout/checkout');
     if (!$checkout->getCart()->validateContent()) {
         throw new Axis_Exception();
     }
     $orderRow = $this->createRow();
     $storage = $checkout->getStorage();
     if ($customer = Axis::getCustomer()) {
         $orderRow->customer_id = $customer->id;
         $orderRow->customer_email = $customer->email;
     } else {
         $orderRow->customer_email = $checkout->getBilling()->email;
     }
     $orderRow->site_id = Axis::getSiteId();
     $orderRow->payment_method = $checkout->payment()->getTitle();
     $orderRow->payment_method_code = $checkout->payment()->getCode();
     $orderRow->shipping_method = $checkout->shipping()->getTitle();
     $orderRow->shipping_method_code = $checkout->shipping()->getCode();
     $orderRow->date_purchased_on = Axis_Date::now()->toSQLString();
     $orderRow->currency = Axis::single('locale/currency')->getCode();
     $orderRow->currency_rate = Axis::single('locale/currency')->getData($orderRow->currency, 'rate');
     $orderRow->order_total = $checkout->getTotal()->getTotal();
     $orderRow->txn_id = 0;
     //@todo
     $orderRow->order_status_id = 0;
     $orderRow->ip_address = $_SERVER['REMOTE_ADDR'];
     $orderRow->customer_comment = $storage->customer_comment;
     $orderRow->locale = Axis_Locale::getLocale()->toString();
     /* build delivery & billing arrays */
     $addressFormatId = Axis::config('core/store/addressFormat');
     $delivery = $checkout->getDelivery()->toArray();
     $delivery['country'] = isset($delivery['country']['name']) ? $delivery['country']['name'] : '';
     if (isset($delivery['zone']['name'])) {
         $delivery['state'] = $delivery['zone']['name'];
     }
     $delivery['address_format_id'] = $addressFormatId;
     $billing = $checkout->getBilling()->toArray();
     $billing['country'] = isset($billing['country']['name']) ? $billing['country']['name'] : '';
     if (isset($billing['zone']['name'])) {
         $billing['state'] = $billing['zone']['name'];
     }
     $billing['address_format_id'] = $addressFormatId;
     unset($billing['id'], $delivery['id']);
     foreach ($delivery as $key => $value) {
         $delivery['delivery_' . $key] = $value;
     }
     foreach ($billing as $key => $value) {
         $billing['billing_' . $key] = $value;
     }
     $orderRow->setFromArray($delivery);
     $orderRow->setFromArray($billing);
     /* Save order (auto generate number ) */
     $orderRow->save();
     /* Add products to order and change quantity */
     $modelOrderProduct = Axis::single('sales/order_product');
     foreach ($checkout->getCart()->getProducts() as $product) {
         $modelOrderProduct->add($product, $orderRow->id);
     }
     /* Add total info */
     $total = $checkout->getTotal();
     $orderTotal = Axis::single('sales/order_total');
     foreach ($total->getCollects() as $collect) {
         $orderTotal->insert(array('order_id' => $orderRow->id, 'code' => $collect['code'], 'title' => $collect['title'], 'value' => $collect['total']));
     }
     // update product stock
     $orderRow->setStatus('pending');
     return $orderRow;
 }
Esempio n. 17
0
 public function createAction()
 {
     $filename = $this->_getParam('filename');
     $alpha = new Zend_Filter_Alnum();
     $filename = $alpha->filter($filename);
     $filename .= '.xml';
     $siteId = $this->_getParam('site_id');
     $menu = new Zend_Navigation();
     $gmDate = gmdate('Y-m-d');
     $oldLocale = Axis_Locale::getLocale();
     $locales = Axis::single('locale/language')->select(array('id', 'locale'))->fetchPairs();
     foreach ($locales as $languageId => &$_locale) {
         Axis_Locale::setLocale($_locale);
         $_locale = Axis_Locale::getLanguageUrl();
     }
     Axis_Locale::setLocale($oldLocale);
     $categories = Axis::single('catalog/category')->select('*')->addName()->addKeyWord()->order('cc.lft')->addSiteFilter($siteId)->addDisabledFilter()->fetchAll();
     $config = Axis::config()->sitemap;
     $changefreq = $config->categories->frequency;
     $priority = $config->categories->priority;
     $_container = $menu;
     $lvl = 0;
     foreach ($categories as $_category) {
         if (!isset($locales[$_category['language_id']])) {
             continue;
         }
         $uri = $this->view->hurl(array('cat' => array('value' => $_category['id'], 'seo' => $_category['key_word']), 'locale' => $locales[$_category['language_id']], 'controller' => 'catalog', 'action' => 'view'), false, true);
         $page = new Zend_Navigation_Page_Uri(array('label' => $_category['name'], 'title' => $_category['name'], 'uri' => $uri, 'order' => $_category['lft'], 'visible' => 'enabled' === $_category['status'] ? true : false, 'lastmod' => $gmDate, 'changefreq' => $changefreq, 'priority' => $priority, 'id' => $_category['id'] . $_category['language_id']));
         $lvl = $lvl - $_category['lvl'] + 1;
         for ($i = 0; $i < $lvl; $i++) {
             $_container = $_container->getParent();
         }
         $lvl = $_category['lvl'];
         $_container->addPage($page);
         $_container = $page;
     }
     $products = Axis::single('catalog/product_category')->select()->distinct()->from('catalog_product_category', array())->joinLeft('catalog_product', 'cp.id = cpc.product_id', array('id'))->addName()->addKeyWord()->addActiveFilter()->addDateAvailableFilter()->addSiteFilter($siteId)->columns(array('category_id' => 'cc.id'))->fetchAll();
     $changefreq = $config->products->frequency;
     $priority = $config->products->priority;
     foreach ($products as $_product) {
         if (!isset($locales[$_product['language_id']])) {
             continue;
         }
         $uri = $this->view->hurl(array('cat' => array('value' => $_product['id'], 'seo' => $_product['key_word']), 'locale' => $locales[$_product['language_id']], 'controller' => 'catalog', 'action' => 'view'), false, true);
         $page = new Zend_Navigation_Page_Uri(array('label' => $_product['name'], 'title' => $_product['name'], 'uri' => $uri, 'lastmod' => $gmDate, 'changefreq' => $changefreq, 'priority' => $priority));
         $_container = $menu->findBy('id', $_product['category_id'] . $_product['language_id']);
         if (null !== $_container) {
             $_container->addPage($page);
         }
     }
     $categories = Axis::single('cms/category')->select(array('id', 'parent_id'))->addCategoryContentTable()->columns(array('ccc.link', 'ccc.title', 'ccc.language_id'))->addActiveFilter()->addSiteFilter($siteId)->where('ccc.link IS NOT NULL')->fetchAll();
     $changefreq = $config->cms->frequency;
     $priority = $config->cms->priority;
     foreach ($categories as $_category) {
         if (!isset($locales[$_category['language_id']])) {
             continue;
         }
         $title = empty($_category['title']) ? $_category['link'] : $_category['title'];
         $page = new Zend_Navigation_Page_Mvc(array('label' => $title, 'title' => $title, 'route' => 'cms_category', 'params' => array('cat' => $_category['link'], 'locale' => $locales[$_category['language_id']]), 'id' => 'cms' . $_category['id'] . $_category['language_id'], 'lastmod' => $gmDate, 'changefreq' => $changefreq, 'priority' => $priority));
         $_container = $menu->findBy('id', 'cms' . $_category['parent_id'] . $_category['language_id']);
         if (null === $_container) {
             $_container = $menu;
         }
         $_container->addPage($page);
     }
     $pages = array();
     if ($config->cms->showPages && !empty($categories)) {
         $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', 'language_id'))->where('cp.is_active = 1')->where('cpca.cms_category_id IN (?)', array_keys($categories))->fetchAll();
         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'], 'locale' => $locales[$_page['language_id']]), 'lastmod' => $gmDate, 'changefreq' => $changefreq, 'priority' => $priority));
             $_container = $menu->findBy('id', 'cms' . $_page['cms_category_id'] . $_page['language_id']);
             if (null !== $_container) {
                 $_container->addPage($page);
             }
         }
     }
     $content = $this->view->navigation()->sitemap($menu)->setUseSitemapValidators(false)->render();
     $this->getResponse()->clearAllHeaders()->setHeader('Content-Description', 'File Transfer', true)->setHeader('Content-Type', 'application/octet-stream', true)->setHeader('Content-Disposition', 'attachment; filename=' . $filename, true)->setHeader('Content-Transfer-Encoding', 'binary', true)->setHeader('Expires', '0', true)->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true)->setHeader('Pragma', 'public', true);
     $this->getResponse()->setBody($content);
 }
Esempio n. 18
0
 /**
  * @return string
  */
 protected function _getCacheKey()
 {
     $keyInfo = array_merge(array('class' => get_class($this), 'template' => $this->getTemplate(), 'disable_wrapper' => $this->disable_wrapper, 'tab_container' => $this->tab_container, 'title' => $this->title, 'class' => $this->class, 'url' => $this->url, 'locale' => Axis_Locale::getLocale()->toString(), 'site_id' => Axis::getSiteId()), $this->_getCacheKeyParams());
     $keyInfo = implode(',', $keyInfo);
     return md5($keyInfo);
 }