示例#1
0
 /**
  * Set request params
  * @param array $request
  */
 protected function _setRequest($request)
 {
     $r = new Axis_Object();
     $r->service = implode(',', $this->_config->allowedTypes->toArray());
     $r->account = $this->_config->account;
     $r->dropoff = $this->_config->dropoff;
     $r->package = $this->_config->package;
     $r->measure = $this->_config->measure;
     // Set Origin detail
     $r->originPostalCode = Axis::config()->core->store->zip;
     $r->origStateOrProvinceCode = Axis::single('location/zone')->getCode(Axis::config()->core->store->zone);
     $r->originCountryCode = Axis::single('location/country')->find(Axis::config()->core->store->country)->current()->iso_code_2;
     // Set Destination information
     if ($request['country']['iso_code_2'] == 'US') {
         $r->destPostalCode = substr(str_replace(' ', '', $request['postcode']), 0, 5);
     } else {
         $r->destPostalCode = substr(str_replace(' ', '', $request['postcode']), 0, 6);
     }
     $r->destCountryCode = $request['country']['iso_code_2'];
     $r->weight = $request['weight'];
     $r->value = Axis::single('locale/currency')->to($request['price'], 'USD');
     $r->currency = 'USD';
     //$request['currency'];
     $this->_request = $r;
     return $this->_request;
 }
示例#2
0
 /**
  *
  * @param Axis_Address $address
  * @param string $EOL
  * @return string
  */
 public function address(Axis_Address $address, $EOL = '<br/>')
 {
     //        $template = '{{firstname}} {{lastname}}EOL' .
     //        '{{if company}}{{company}}EOL{{/if}}' .
     //        '{{street_address}}EOL' .
     //        '{{if suburb}}{{suburb}}EOL{{/if}}'.
     //        '{{city}} {{if zone.name}}{{zone.name}} {{/if}}{{postcode}}EOL' .
     //        '{{country.name}}EOL' .
     //        'T: {{phone}}EOL' .
     //        '{{if fax}}F: {{fax}}EOL{{/if}}'
     //        ;
     $address = $address->toArray();
     $addressFormatId = !empty($address['address_format_id']) ? $address['address_format_id'] : Axis::config('locale/main/addressFormat');
     if (empty($this->_addressFormats[$addressFormatId])) {
         throw new Axis_Exception(Axis::translate('location')->__('Not correct address format id'));
     }
     $template = $this->_addressFormats[$addressFormatId]['address_format'];
     if (isset($address['zone']['id']) && 0 == $address['zone']['id']) {
         unset($address['zone']);
     }
     $matches = array();
     preg_match_all('/{{if (.+)(?:\\.(.+))?}}(.+){{\\/if}}/U', $template, $matches);
     foreach ($matches[0] as $key => $condition) {
         $replaced = empty($matches[2][$key]) ? empty($address[$matches[1][$key]]) ? '' : $matches[3][$key] : (empty($address[$matches[1][$key]][$matches[2][$key]]) ? '' : $matches[3][$key]);
         $template = str_replace($condition, $replaced, $template);
     }
     preg_match_all('/{{(.+)(?:\\.(.+))?}}/U', $template, $matches);
     foreach ($matches[0] as $key => $condition) {
         $replaced = empty($matches[2][$key]) ? $address[$matches[1][$key]] : $address[$matches[1][$key]][$matches[2][$key]];
         $template = str_replace($condition, $this->view->escape($replaced), $template);
     }
     return str_replace('EOL', $EOL, $template);
 }
示例#3
0
 public function collect(Axis_Checkout_Model_Total $total)
 {
     $checkout = Axis::single('checkout/checkout');
     if (null === $checkout->shipping()) {
         return false;
     }
     if (!($taxClassId = $checkout->shipping()->config()->taxClass)) {
         if (!($taxClassId = Axis::config()->tax->shipping->taxClass)) {
             return false;
         }
     }
     if (!($taxBasis = $checkout->shipping()->config()->taxBasis)) {
         if (!($taxBasis = Axis::config()->tax->shipping->taxBasis)) {
             return false;
         }
     }
     $address = $checkout->getStorage()->{$taxBasis};
     if (!$address || !$address->hasCountry()) {
         return false;
     }
     $countryId = $address->country->id;
     $zoneId = $address->hasZone() && $address->zone->hasId() ? $address->zone->id : null;
     $geozoneIds = Axis::single('location/geozone')->getIds($countryId, $zoneId);
     if (!count($geozoneIds)) {
         return false;
     }
     $customerGroupId = Axis::single('account/customer')->getGroupId();
     if (!$customerGroupId) {
         return false;
     }
     $type = $checkout->shipping()->getType($checkout->getShippingRequest(), $checkout->getShippingMethodCode());
     $tax = Axis::single('tax/rate')->calculateByPrice($type['price'], $taxClassId, $geozoneIds, $customerGroupId);
     $total->addCollect(array('code' => $this->getCode(), 'title' => $this->getTitle(), 'total' => $tax, 'sortOrder' => $this->_config->sortOrder));
 }
示例#4
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;
 }
示例#5
0
 protected function _initConfig()
 {
     $this->bootstrap('Loader');
     $config = Zend_Registry::get('config');
     Zend_Registry::set('config', new Axis_Config($config, true));
     return Axis::config();
 }
示例#6
0
 public function log($observer)
 {
     if (!Axis::config('log/main/enabled')) {
         return false;
     }
     /**
      * @var $request Zend_Controller_Request_Abstract
      */
     $request = $observer->getController()->getRequest();
     $url = $request->getScheme() . '://' . $request->getHttpHost() . $request->getRequestUri();
     $refer = $request->getServer('HTTP_REFERER', '');
     $timestamp = Axis_Date::now()->toSQLString();
     $siteId = Axis::getSiteId();
     // add new url request
     $modelUrlInfo = Axis::single('log/url_info');
     $rowUrlInfo = $modelUrlInfo->select()->where('url = ?', $url)->where('refer = ?', $refer)->fetchRow();
     if (!$rowUrlInfo) {
         $rowUrlInfo = $modelUrlInfo->createRow(array('url' => $url, 'refer' => $refer));
         $rowUrlInfo->save();
     }
     //add/update visitor
     $visitor = Axis::single('log/visitor')->getVisitor();
     //add/update visitor info
     Axis::single('log/visitor_info')->getRow(array('visitor_id' => $visitor->id, 'user_agent' => $request->getServer('HTTP_USER_AGENT', ''), 'http_accept_charset' => $request->getServer('HTTP_ACCEPT_CHARSET', ''), 'http_accept_language' => $request->getServer('HTTP_ACCEPT_LANGUAGE', ''), 'server_addr' => $request->getServer('SERVER_ADDR', ''), 'remote_addr' => $request->getServer('REMOTE_ADDR', '')))->save();
     Axis::single('log/url')->insert(array('url_id' => $rowUrlInfo->id, 'visitor_id' => $visitor->id, 'visit_at' => $timestamp, 'site_id' => $siteId));
 }
示例#7
0
 public function postProcess(Axis_Sales_Model_Order_Row $order)
 {
     $number = $this->getCreditCard()->getCcNumber();
     switch (Axis::config("payment/{$order->payment_method_code}/saveCCAction")) {
         case 'last_four':
             $number = str_repeat('X', strlen($number) - 4) . substr($number, -4);
             break;
         case 'first_last_four':
             $number = substr($number, 0, 4) . str_repeat('X', strlen($number) - 8) . substr($number, -4);
             break;
         case 'partial_email':
             $number = substr($number, 0, 4) . str_repeat('X', strlen($number) - 8) . substr($number, -4);
             try {
                 $mail = new Axis_Mail();
                 $mail->setLocale(Axis::config('locale/main/language_admin'));
                 $mail->setConfig(array('subject' => Axis::translate('sales')->__('Order #%s. Credit card number'), 'data' => array('text' => Axis::translate('sales')->__('Order #%s, Credit card middle digits: %s', $order->number, substr($number, 4, strlen($number) - 8))), 'to' => Axis_Collect_MailBoxes::getName(Axis::config('sales/order/email'))));
                 $mail->send();
             } catch (Zend_Mail_Transport_Exception $e) {
             }
             break;
         case 'complete':
             $number = $number;
             break;
         default:
             return true;
     }
     $crypt = Axis_Crypt::factory();
     $data = array('order_id' => $order->id, 'cc_type' => $crypt->encrypt($card->getCcType()), 'cc_owner' => $crypt->encrypt($card->getCcOwner()), 'cc_number' => $crypt->encrypt($number), 'cc_expires_year' => $crypt->encrypt($card->getCcExpiresYear()), 'cc_expires_month' => $crypt->encrypt($card->getCcExpiresMonth()), 'cc_cvv' => Axis::config()->payment->{$order->payment_method_code}->saveCvv ? $crypt->encrypt($card->getCcCvv()) : '', 'cc_issue_year' => $crypt->encrypt($card->getCcIssueYear()), 'cc_issue_month' => $crypt->encrypt($card->getCcIssueMonth()));
     Axis::single('sales/order_creditcard')->save($data);
 }
示例#8
0
 /**
  * Retrieve singleton instance of Axis_HumanUri_Adapter
  *
  * @static
  * @return Axis_HumanUri_Adapter_Abstact
  */
 public static function getInstance()
 {
     if (null === self::$_instance) {
         self::$_instance = Axis_HumanUri::factory(Axis::config()->front->humanUrlAdapter);
     }
     return self::$_instance;
 }
示例#9
0
 public function removeAction()
 {
     $customerGroupIds = Zend_Json::decode($this->_getParam('data'));
     $isValid = true;
     if (in_array(Axis_Account_Model_Customer_Group::GROUP_GUEST_ID, $customerGroupIds)) {
         $isValid = false;
         Axis::message()->addError(Axis::translate('admin')->__("Your can't delete default Guest group id: %s ", Axis_Account_Model_Customer_Group));
     }
     if (in_array(Axis_Account_Model_Customer_Group::GROUP_ALL_ID, $customerGroupIds)) {
         $isValid = false;
         Axis::message()->addError(Axis::translate('admin')->__("Your can't delete default All group id: %s ", Axis_Account_Model_Customer_Group::GROUP_ALL_ID));
     }
     if (true === in_array(Axis::config()->account->main->defaultCustomerGroup, $customerGroupIds)) {
         $isValid = false;
         Axis::message()->addError(Axis::translate('admin')->__("Your can't delete default customer group id: %s ", $id));
     }
     if (!sizeof($customerGroupIds)) {
         $isValid = false;
         Axis::message()->addError(Axis::translate('admin')->__('No data to delete'));
     }
     if ($isValid) {
         Axis::single('account/customer_group')->delete($this->db->quoteInto('id IN(?)', $customerGroupIds));
         Axis::message()->addSuccess(Axis::translate('admin')->__('Group was deleted successfully'));
     }
     $this->_helper->json->sendJson(array('success' => $isValid));
 }
示例#10
0
 /**
  *
  * @return array
  */
 protected function _loadCollection()
 {
     if (empty($this->_collection)) {
         $themes = Axis::model('core/option_theme');
         $layouts = array();
         $designPath = Axis::config('system/path') . '/app/design/front';
         foreach ($themes as $theme) {
             $path = $designPath . '/' . $theme . '/layouts';
             if (!file_exists($path)) {
                 continue;
             }
             $dir = opendir($path);
             while ($file = readdir($dir)) {
                 if (is_dir($path . '/' . $file) || substr($file, 0, 7) != 'layout_') {
                     continue;
                 }
                 $layout = substr($file, 0, -6);
                 if (isset($layouts[$layout])) {
                     $layouts[$layout]['themes'][] = $theme;
                     continue;
                 }
                 $layouts[$layout] = array('name' => $layout, 'themes' => array($theme));
             }
         }
         $collection = array();
         foreach ($layouts as $key => $layout) {
             $collection[$key] = $layout['name'] . ' (' . implode(', ', $layout['themes']) . ')';
         }
         $this->_collection = $collection;
     }
     return $this->_collection;
 }
示例#11
0
 /**
  *
  * @static
  * @return array
  */
 public static function collect()
 {
     if (null === self::$_collection) {
         $themes = Axis_Collect_Theme::collect();
         $layouts = array();
         $designPath = Axis::config('system/path') . '/app/design/front';
         foreach ($themes as $theme) {
             $path = $designPath . '/' . $theme . '/layouts';
             if (!file_exists($path)) {
                 continue;
             }
             $dir = opendir($path);
             while ($file = readdir($dir)) {
                 if (is_dir($path . '/' . $file) || substr($file, 0, 7) != 'layout_') {
                     continue;
                 }
                 $layout = substr($file, 0, -6);
                 if (isset($layouts[$layout])) {
                     $layouts[$layout]['themes'][] = $theme;
                     continue;
                 }
                 $layouts[$layout] = array('name' => $layout, 'themes' => array($theme));
             }
         }
         $collection = array();
         foreach ($layouts as $key => $layout) {
             $collection[$key] = $layout['name'] . ' (' . implode(', ', $layout['themes']) . ')';
         }
         self::$_collection = $collection;
     }
     return self::$_collection;
 }
示例#12
0
 function _calculateShippingTax($price, Axis_Method_Shipping_Model_Abstract $shipping, array $params)
 {
     $customerGroupId = $params['customer_group_id'];
     if (!($taxClassId = $shipping->config()->taxClass)) {
         if (!($taxClassId = Axis::config()->tax->shipping->taxClass)) {
             return 0;
         }
     }
     if (!($taxBasis = $shipping->config()->taxBasis)) {
         if (!($taxBasis = Axis::config()->tax->shipping->taxBasis)) {
             return 0;
         }
     }
     if ('billing' === $taxBasis) {
         $countryId = $params['billing_country_id'];
         $zoneId = $params['billing_zone_id'];
     } else {
         $countryId = $params['delivery_country_id'];
         $zoneId = $params['delivery_zone_id'];
     }
     if (empty($zoneId)) {
         $zoneId = null;
     }
     $geozoneIds = Axis::single('location/geozone')->getIds($countryId, $zoneId);
     if (empty($geozoneIds)) {
         return 0;
     }
     return Axis::single('tax/rate')->calculateByPrice($price, $taxClassId, $geozoneIds, $customerGroupId);
 }
 /**
  *
  * @param mixed $value
  * @return mixed
  */
 public static function getSaveValue($value)
 {
     if (!is_array($value)) {
         return $value;
     }
     function remove_quotes(&$str)
     {
         $str = str_replace(array('"', "'"), '', $str);
     }
     $filename = Axis::config()->system->path . '/var/export/' . current($value);
     if (@(!($fp = fopen($filename, 'r')))) {
         Axis::message()->addError(Axis::translate('core')->__("Can't open file : %s", $filename));
         return current($value);
     }
     $titles = fgetcsv($fp, 2048, ',', "'");
     array_walk($titles, 'remove_quotes');
     $rowSize = count($titles);
     Axis::table('shippingtable_rate')->delete("site_id = " . $value['siteId']);
     while (!feof($fp)) {
         $data = fgetcsv($fp, 2048, ',', "'");
         if (!is_array($data)) {
             continue;
         }
         $data = array_pad($data, $rowSize, '');
         array_walk($data, 'remove_quotes');
         $data = array_combine($titles, $data);
         Axis::table('shippingtable_rate')->insert(array('site_id' => $value['siteId'], 'country_id' => Axis::single('location/country')->getIdByIsoCode3($data['Country']), 'zone_id' => Axis::single('location/zone')->getIdByCode($data['Region/State']), 'zip' => $data['Zip'], 'value' => $data['Value'], 'price' => $data['Price']));
     }
     return current($value);
 }
示例#14
0
 public function init()
 {
     parent::init();
     $this->view->languages = Axis::model('locale/option_language')->toArray();
     $this->view->sites = Axis::model('core/option_site')->toArray();
     $this->view->locales = Axis::single('locale/language')->select()->fetchAssoc();
     $this->view->adminUrl = '/' . trim(Axis::config('core/backend/route'), '/ ');
 }
示例#15
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);
 }
示例#16
0
 public function init()
 {
     $this->addElement('hidden', 'id', array('validators' => array(new Axis_Account_Model_Form_Validate_AddressId())));
     $configOptions = Axis::config('account/address_form')->toArray();
     $this->_fieldConfig = array_merge(array('firstname_sort_order' => -20, 'firstname_status' => 'required', 'lastname_sort_order' => -19, 'lastname_status' => 'required'), $configOptions);
     $countries = Axis_Collect_Country::collect();
     if (isset($countries['0']) && 'ALL WORLD COUNTRY' === $countries['0']) {
         unset($countries['0']);
     }
     $allowedCountries = $configOptions['country_id_allow'];
     if (!in_array(0, $allowedCountries)) {
         // ALL WORLD COUNTRIES is not selected
         $countries = array_intersect_key($countries, array_flip($allowedCountries));
     }
     $countryIds = array_keys($countries);
     $defaultCountry = current($countryIds);
     $zones = Axis_Collect_Zone::collect();
     $this->_zones = $zones;
     foreach ($this->_fields as $name => $values) {
         $status = $this->_fieldConfig[$name . '_status'];
         if ('disabled' == $status) {
             continue;
         }
         $fieldOptions = array('required' => 'required' === $status, 'label' => $values['label'], 'class' => $values['class'] . ('required' === $status ? ' required' : ''));
         if (isset($this->_fieldConfig[$name . '_sort_order'])) {
             $fieldOptions['order'] = $this->_fieldConfig[$name . '_sort_order'];
         }
         if ('country_id' == $name) {
             $fieldOptions['validators'] = array(new Zend_Validate_InArray(array_keys($countries)));
             $values['type'] = new Zend_Form_Element_Select($name, $fieldOptions);
             $values['type']->removeDecorator('HtmlTag')->addDecorator('HtmlTag', array('tag' => 'li', 'id' => "{$name}-row", 'class' => 'element-row'));
             $values['type']->options = $countries;
         } else {
             if ('zone_id' == $name) {
                 $values['type'] = new Zend_Form_Element_Select($name, $fieldOptions);
                 $values['type']->removeDecorator('HtmlTag')->addDecorator('HtmlTag', array('tag' => 'li', 'id' => "{$name}-row", 'class' => 'element-row'));
                 if (isset($zones[$defaultCountry]) && count($countries)) {
                     $values['type']->options = $zones[$defaultCountry];
                 }
                 // zone name field
                 $zoneNameOptions = $fieldOptions;
                 $zoneNameOptions['order']++;
                 $zoneNameOptions['class'] .= ' input-text';
                 $this->addElement('text', 'state', $zoneNameOptions);
             }
         }
         $this->addElement($values['type'], $name, $fieldOptions);
     }
     $this->addDisplayGroup($this->getElements(), 'address', array('legend' => 'Address'));
     $this->addElement('checkbox', 'default_billing', array('label' => 'Use as my default billing address', 'class' => 'input-checkbox'));
     $element = $this->getElement('default_billing');
     $this->addElement('checkbox', 'default_shipping', array('label' => 'Use as my default shipping address', 'class' => 'input-checkbox'));
     $element = $this->getElement('default_shipping');
     $this->addElement('button', 'submit', array('type' => 'submit', 'class' => 'button', 'label' => 'Save'));
     $this->addActionBar(array('submit'));
 }
示例#17
0
 protected function _beforeRender()
 {
     $date = new Axis_Date();
     $date = $date->addDay(-1)->toString('YYYY-MM-dd');
     $mailCount = Axis::single('contacts/message')->select()->where('created_at > ?', $date)->count();
     $orderTotal = (double) Axis::single('sales/order')->select('SUM(order_total)')->where('date_purchased_on > ?', $date)->fetchOne();
     $orderTotal = Axis::single('locale/currency')->getCurrency(Axis::config()->locale->main->currency)->toCurrency($orderTotal ? $orderTotal : 0);
     $orderCount = Axis::single('sales/order')->select()->where('date_purchased_on > ?', $date)->count();
     $userId = Zend_Auth::getInstance()->getIdentity();
     $this->setFromArray(array('mail_count' => $mailCount, 'order_total' => $orderTotal, 'order_count' => $orderCount, 'user_info' => Axis::single('admin/user')->find($userId)->current()));
 }
示例#18
0
 /**
  *
  * @param Axis_Sales_Model_Order_Row $order
  * @return bool
  */
 public function notifyAdminNewOrder(Axis_Sales_Model_Order_Row $order)
 {
     try {
         $mail = new Axis_Mail();
         $mail->setLocale(Axis::config('locale/main/language_admin'));
         $mail->setConfig(array('event' => 'order_new-owner', 'subject' => Axis::translate('sales')->__('Order created'), 'data' => array('order' => $order), 'to' => Axis_Collect_MailBoxes::getName(Axis::config('sales/order/email'))));
         $mail->send();
         return true;
     } catch (Zend_Mail_Exception $e) {
         return false;
     }
 }
示例#19
0
 protected function _getQuotes()
 {
     $r = $this->_request;
     $request = array('WebAuthenticationDetail' => array('UserCredential' => array('Key' => $r->key, 'Password' => $r->password)), 'ClientDetail' => array('AccountNumber' => $r->accountNumber, 'MeterNumber' => $r->meterNumber), 'Version' => array('ServiceId' => 'crs', 'Major' => '10', 'Intermediate' => '0', 'Minor' => '0'), 'RequestedShipment' => array('DropoffType' => $r->dropoffType, 'ShipTimestamp' => date('c'), 'PackagingType' => $r->packaging, 'TotalInsuredValue' => array('Ammount' => $r->value, 'Currency' => $r->currencyCode), 'Shipper' => array('Address' => array('PostalCode' => $r->originPostalCode, 'CountryCode' => $r->originCountryCode)), 'Recipient' => array('Address' => array('PostalCode' => $r->destPostalCode, 'CountryCode' => $r->destCountryCode, 'Residential' => (bool) $this->_config->residenceDelivery)), 'ShippingChargesPayment' => array('PaymentType' => 'SENDER', 'Payor' => array('AccountNumber' => $r->accountNumber, 'CountryCode' => $r->originCountryCode)), 'RateRequestTypes' => 'LIST', 'PackageCount' => '1', 'PackageDetail' => 'INDIVIDUAL_PACKAGES', 'RequestedPackageLineItems' => array(array('GroupPackageCount' => 1, 'Weight' => array('Value' => $r->weight, 'Units' => 'LB')))));
     $pathToWsdl = Axis::config('system/path') . "/app/code/Axis/ShippingFedex/etc/RateService_v10.wsdl";
     $client = new SoapClient($pathToWsdl);
     //        production : https://gateway.fedex.com:443/GatewayDC
     //        test       : https://wsbeta.fedex.com:443/web-services
     $client->__setLocation($this->_config->gateway);
     $response = $client->getRates($request);
     return $this->_parseResponse($response);
 }
示例#20
0
 /**
  * Removes layout to page assignments
  * 
  * @param string $layout
  * @param string $page
  * @param int $templateId
  * @return Axis_Core_Model_Template_Page Provides fluent interface
  */
 public function remove($layout, $page, $templateId = null)
 {
     if (null === $templateId) {
         $templateId = Axis::config('design/main/frontTemplateId');
     }
     $pageId = Axis::single('core/page')->getIdByPage($page);
     if (!$pageId) {
         return $this;
     }
     $this->delete("template_id = {$templateId} AND page_id = {$pageId} AND layout = '{$layout}'");
     return $this;
 }
示例#21
0
 /**
  *
  * @static
  * @return array
  */
 public static function collect()
 {
     $path = Axis::config('system/path') . '/app/design/front';
     $dh = opendir($path);
     $themes = array();
     while ($file = readdir($dh)) {
         if ($file[0] == '.') {
             continue;
         }
         $themes[$file] = $file;
     }
     closedir($dh);
     return $themes;
 }
示例#22
0
 /**
  * Construct shipping class method
  *
  * @param string $type
  */
 public function __construct($type = null)
 {
     parent::__construct();
     //fix  single call
     if (is_array($type) && !count($type)) {
         $type = null;
     }
     $this->_type = $type;
     try {
         $writer = new Zend_Log_Writer_Stream(Axis::config('system/path') . Axis::config('log/main/shipping'));
         $this->_logger = new Zend_Log($writer);
     } catch (Exception $e) {
     }
 }
示例#23
0
 public function preDispatch()
 {
     $return = Axis_Area::isBackend() && Axis::config('core/backend/ssl') || $this->getActionController() instanceof Axis_Core_Controller_Front_Secure && Axis::config('core/frontend/ssl');
     if (!$return) {
         return;
     }
     $request = $this->getRequest();
     if ($request->isSecure()) {
         return;
     }
     $url = Zend_Controller_Request_Http::SCHEME_HTTPS . "://" . $request->getServer('HTTP_HOST') . $request->getRequestUri();
     $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
     $redirector->setGoToUrl($url);
     $redirector->redirectAndExit();
 }
示例#24
0
 protected function _postDelete()
 {
     if (!empty($this->path)) {
         $productDir = realpath(Axis::config()->system->path . '/media/product');
         $path = realpath($productDir . $this->path);
         if (!$path) {
             return;
         }
         /* check are we in 'ROOT/media/product' */
         if (0 !== strpos($path, $productDir) || strlen($path) <= strlen($productDir)) {
             return;
         }
         @unlink($path);
     }
 }
示例#25
0
 /**
  * Retrieve template info by id
  * 
  * @param int $id
  * @return array
  */
 public function getInfo($id)
 {
     if (!is_numeric($id) || !($info = $this->find($id)->current())) {
         Axis::message()->addError(Axis::translate('core')->__('Template not found'));
         return array();
     }
     $info = $info->toArray();
     $templates = Axis_Collect_MailTemplate::collect();
     $file = Axis::config()->system->path . '/app/design/mail/' . $templates[$info['template']] . '_' . $info['type'] . '.phtml';
     $content = '';
     if (is_readable($file)) {
         $content = @file_get_contents($file);
     }
     $info['content'] = $content;
     return $info;
 }
 private function _collect($collectName, $assigned = '', $notUseFullClassName = true)
 {
     if ($notUseFullClassName) {
         $collectName = 'Axis_Collect_' . $collectName;
     }
     if (!empty($assigned)) {
         list($sec, $subsec, $key) = explode('/', $assigned);
         if (isset(Axis::config()->{$sec}->{$subsec}->{$key})) {
             $parameter = Axis::config()->{$sec}->{$subsec}->{$key};
             $values = call_user_func(array($collectName, 'collect'), $parameter);
         }
     } else {
         $values = call_user_func(array($collectName, 'collect'));
     }
     return $values;
 }
示例#27
0
 /**
  *
  * @return array
  */
 protected function _loadCollection()
 {
     $path = Axis::config()->system->path . '/app/design/mail';
     $templates = array();
     if (!file_exists($path)) {
         return false;
     }
     $dh = opendir($path);
     while ($file = readdir($dh)) {
         if (!is_dir($path . '/' . $file) && substr($file, -11) == '_html.phtml' && is_file($path . '/' . substr($file, 0, -11) . '_txt.phtml')) {
             $templates[substr($file, 0, -11)] = substr($file, 0, -11);
         }
     }
     closedir($dh);
     return $templates;
 }
示例#28
0
 public function render()
 {
     if (!Axis::config('analytics/main/used')) {
         return '';
     }
     $helper = $this->getView()->GoogleAnalytics();
     $helper->_setAccount(Axis::config('analytics/main/uacct'))->_trackPageview();
     /**
      * @var $order Axis_Sales_Model_Order_Row
      */
     $order = $this->getOrder();
     if ($order instanceof Axis_Sales_Model_Order_Row) {
         $total = number_format($order->order_total, 3, '.', '');
         $tax = $order->getTax() + $order->getShippingTax();
         $tax = number_format($tax, 3, '.', '');
         $shipping = number_format($order->getShipping(), 3, '.', '');
         // add transaction
         $helper->_addTrans($order->id, null, $total, $tax, $shipping, $order->billing_city, $order->billing_state, $order->billing_country);
         $modelProduct = Axis::model('catalog/product');
         foreach ($order->getProducts() as $_product) {
             $attrs = '';
             if (isset($_product['attributes'])) {
                 $_attrs = array();
                 foreach ($_product['attributes'] as $_option) {
                     $_attrs[] = $_option['product_option'] . ':' . $_option['product_option_value'];
                 }
                 $attrs = "[" . implode(';', $_attrs) . "]";
             }
             $categories = $modelProduct->find($_product['product_id'])->current()->getCategories();
             foreach ($categories as &$_category) {
                 $_category = $_category['name'];
             }
             $price = number_format($_product['final_price'], 2, '.', '');
             // add item
             $helper->_addItem($order->id, $_product['sku'], $_product['name'] . ' ' . $attrs, implode(',', $categories), $price, $_product['quantity']);
         }
         $helper->_trackTrans();
     }
     if (!empty($this->customOption)) {
         foreach (array_filter(explode('->', $this->customOption)) as $option) {
             preg_match('/^(_.+)\\((.*)\\)/', $option, $match);
             $args = explode(',', str_replace(array(' ', "'", '"'), '', $match[2]));
             call_user_func_array(array($helper, $match[1]), $args);
         }
     }
     return $helper->toString();
 }
 /**
  *
  * @static
  * @param array $value
  * @return mixed
  */
 public static function getSaveValue($value)
 {
     if (!is_array($value)) {
         return $value;
     }
     $filename = Axis::config()->system->path . '/var/export/' . current($value);
     if (@(!($fp = fopen($filename, 'w')))) {
         Axis::message()->addError(Axis::translate('core')->__("Can't write in file: %s", $filename));
         return current($value);
     }
     $titles = explode(',', 'Country,Region/State,Zip,Value,Price');
     fputcsv($fp, $titles, ',', "'");
     foreach (Axis::table('shippingtable_rate')->fetchAll() as $row) {
         fputcsv($fp, array(Axis::single('location/country')->getIsoCode3ById($row->country_id), Axis::single('location/zone')->getCodeById($row->zone_id), $row->zip, $row->value, $row->price), ',', "'");
     }
     return current($value);
 }
示例#30
0
 /**
  * Retrieve the list of active, installed modules
  *
  * @return array code => path pairs
  */
 public function getModules()
 {
     if (Zend_Registry::isRegistered('modules')) {
         return Zend_Registry::get('modules');
     }
     if (!($modules = Axis::cache()->load('modules_list'))) {
         $list = Axis::single('core/module')->getList('is_active = 1');
         $result = array();
         foreach ($list as $moduleCode => $values) {
             list($namespace, $module) = explode('_', $moduleCode, 2);
             $modules[$moduleCode] = Axis::config()->system->path . '/app/code/' . $namespace . '/' . $module;
         }
         Axis::cache()->save($modules, 'modules_list', array('modules'));
     }
     Zend_Registry::set('modules', $modules);
     return Zend_Registry::get('modules');
 }