예제 #1
0
 /**
  * @param        $key
  * @param null   $default
  * @param string $group
  * @return mixed
  */
 public function get($key, $default = null, $group = 'default')
 {
     $group = $this->_clean($group);
     $group = empty($group) ? 'default' : $group;
     $key = $this->_clean($key);
     return $this->_configs->get($group . '.' . $key, $default);
 }
예제 #2
0
 /**
  * Get all currency values and cache in memory
  */
 public function init()
 {
     // optimize
     if (!empty(self::$curList)) {
         return self::$curList;
     }
     $this->app->jbdebug->mark('jbmoney::init::start');
     $curParams = $this->_config->getGroup('cart.currency')->get('list');
     $ttl = (int) $this->_config->get('currency_ttl', 1440, 'cart.config');
     $cacheKey = $this->_jbcache->hash(array('params' => (array) $curParams, 'date' => date('d-m-Y'), 'ttl' => $ttl));
     self::$curList = $this->_jbcache->get($cacheKey, 'currency', true, array('ttl' => $ttl));
     if (empty(self::$curList)) {
         $elements = $this->app->jbcartposition->loadElements('currency');
         self::$curList = array(JBCartValue::DEFAULT_CODE => array('code' => JBCartValue::DEFAULT_CODE, 'value' => 1, 'name' => JText::_('JBZOO_CURRENCY_DEFAULT_CODE'), 'format' => $this->_defaultFormat), self::PERCENT => array('code' => self::PERCENT, 'value' => 1, 'name' => JText::_('JBZOO_CART_CURRENCY_PERCENT'), 'format' => array_merge($this->_defaultFormat, array('symbol' => self::PERCENT))));
         $noCache = null;
         // fallback flag
         /** @type JBCartElementCurrency $element */
         foreach ($elements as $element) {
             $code = $element->getCode();
             if (empty($code)) {
                 continue;
             }
             try {
                 if ($noCache) {
                     // speedup if fatal errors have appeared
                     $value = $element->getFallbackValue();
                 } else {
                     $value = $element->getValue($code);
                 }
             } catch (JBCartElementCurrencyException $e) {
                 $noCache = time();
                 $value = $element->getFallbackValue();
                 if (JDEBUG || !$this->app->jbenv->isSite()) {
                     $this->app->jbnotify->warning($e->getMessage());
                 }
             }
             if ($code && $value > 0) {
                 self::$curList[$code] = array('code' => $code, 'value' => $value, 'name' => $element->getName(), 'format' => $element->getFormat());
             }
         }
         if (count(self::$curList) == 2 || !isset(self::$curList['eur'])) {
             self::$curList['eur'] = self::$curList[JBCartValue::DEFAULT_CODE];
         }
         if (!$noCache) {
             $this->_jbcache->set($cacheKey, self::$curList, 'currency', true, array('ttl' => $ttl));
         }
     }
     $this->app->jbdebug->mark('jbmoney::init::finish');
     return self::$curList;
 }
예제 #3
0
 /**
  * Get key field value
  * @param array  $row
  * @param string $lineKey
  * @return Item
  */
 protected function _getCategoryByKey($row, $lineKey = null)
 {
     $category = null;
     if ($this->_data->key != self::KEY_NONE) {
         foreach ($this->_data->assign as $csvKey => $fieldName) {
             if ($this->_data->key == self::KEY_ID && $fieldName == 'id') {
                 $category = JBModelCategory::model()->getById(JString::trim($row[$csvKey]), $this->_data->appid);
                 break;
             } else {
                 if ($this->_data->key == self::KEY_NAME && $fieldName == 'name') {
                     $category = JBModelCategory::model()->getByName(JString::trim($row[$csvKey]), $this->_data->appid);
                     break;
                 } else {
                     if ($this->_data->key == self::KEY_ALIAS && $fieldName == 'alias') {
                         $category = JBModelCategory::model()->getByAlias(JString::trim($row[$csvKey]), $this->_data->appid);
                         break;
                     }
                 }
             }
         }
     }
     $isCreateNew = (int) $this->_data->get('create', 0);
     if (!$category && $isCreateNew) {
         $category = JBModelCategory::model()->createEmpty($this->_data->appid, $lineKey);
     }
     return $category;
 }
예제 #4
0
 /**
  * Get elements xml meta data
  * @param null $key
  * @return bool
  */
 public function getMetaData($key = null)
 {
     if (!isset($this->_metaData)) {
         $data = array();
         $xml = $this->loadXML();
         if (!$xml) {
             return false;
         }
         $data['type'] = $xml->attributes()->type ? (string) $xml->attributes()->type : 'Unknown';
         $data['group'] = $xml->attributes()->group ? (string) $xml->attributes()->group : 'Unknown';
         $data['hidden'] = $xml->attributes()->hidden ? (string) $xml->attributes()->hidden : 'false';
         $data['core'] = $xml->attributes()->core ? (string) $xml->attributes()->core : 'false';
         $data['system-tmpl'] = $xml->attributes()->{'system-tmpl'} ? (string) $xml->attributes()->{'system-tmpl'} : 'false';
         $data['trusted'] = $xml->attributes()->trusted ? (string) $xml->attributes()->trusted : 'false';
         $data['orderable'] = $xml->attributes()->orderable ? (string) $xml->attributes()->orderable : 'false';
         $data['name'] = JText::_((string) $xml->name);
         $data['creationdate'] = $xml->creationDate ? (string) $xml->creationDate : 'Unknown';
         $data['author'] = $xml->author ? (string) $xml->author : 'Unknown';
         $data['copyright'] = (string) $xml->copyright;
         $data['authorEmail'] = (string) $xml->authorEmail;
         $data['authorUrl'] = (string) $xml->authorUrl;
         $data['version'] = (string) $xml->version;
         $data['description'] = JText::_((string) $xml->description);
         $this->_metaData = $this->app->data->create($data);
     }
     return $key == null ? $this->_metaData : $this->_metaData->get($key);
 }
예제 #5
0
 /**
  * Get the informations about an image resource
  *
  * @param string $name The name of the image parameter
  *
  * @return array The list of informations about the image ('path', 'src', 'mime', 'width', 'height', 'width_height')
  *
  * @since 2.0
  */
 public function getImage($name)
 {
     if ($image = $this->params->get($name)) {
         return $this->app->html->_('zoo.image', $image, $this->params->get($name . '_width'), $this->params->get($name . '_height'));
     }
     return null;
 }
예제 #6
0
 /**
  * Get config from options
  * @return mixed|null
  */
 protected function _getConfigValues()
 {
     $options = $this->_config->get('spin', array());
     foreach ($options as $key => $option) {
         $options[$key]['count'] = null;
     }
     return $options;
 }
예제 #7
0
 public function maskCardNumber($default = null)
 {
     $cc = parent::get('cardNumber');
     $len = strlen($cc) - 4;
     if ($len > 0) {
         return str_repeat('X', $len) . substr($cc, -4);
     }
     return $default;
 }
예제 #8
0
 /**
  * Action for robot from payment system
  * Validate and check order as success
  * @throws AppException
  */
 public function paymentCallback()
 {
     $this->_init();
     $this->app->jbevent->fire($this->order, 'basket:paymentCallback');
     $this->app->jbdoc->rawOutput();
     $cart = JBCart::getInstance();
     /** @type JBCartElementPayment $payment */
     $payment = $this->order->getPayment();
     // check payment element
     if (empty($payment)) {
         $this->_error('Saved without payment element');
     }
     // payment is exists
     if (!$this->_orderInfo->get('type')) {
         $this->_error('Undefined payment system');
     }
     // check payment type
     if ($payment->getType() != $this->_orderInfo->get('type')) {
         $this->_error('Payment type is not correct');
     }
     // current status is not completed
     if ($payment->getStatus() == $cart->getPaymentSuccess()) {
         $this->_error('Payment status is "' . $payment->getStatus()->getCode() . '" already');
     }
     // check sum
     $realSum = $payment->getOrderSumm();
     $requestSum = $payment->getRequestOrderSum();
     if ($realSum->compare($requestSum, '!=', 5)) {
         $this->_error('Not correct amount');
     }
     // check if sum was empty
     if ($realSum->compare(0, '<=')) {
         $this->_error('Amount less or equal zero');
     }
     // checking of payment element
     if ($payment->isValid()) {
         $payment->setSuccess();
         $this->app->event->dispatcher->notify($this->app->event->create($this->order, 'basket:paymentSuccess'));
         $payment->renderResponse();
     } else {
         $this->_error('No valid request');
     }
 }
예제 #9
0
파일: jbcsv.php 프로젝트: alexmixaylov/real
 /**
  * From file
  * @param          $file
  * @param JSONData $options
  * @param int      $start
  * @param int      $step
  * @return array
  */
 public function getLinesfromFile($file, $options, $start, $step)
 {
     $lines = array();
     $finish = (int) $start + (int) $step;
     $i = 0;
     if (($handle = fopen($file, "r")) !== false) {
         while (($data = fgetcsv($handle, 0, $options->get('separator', ','), $options->get('enclosure', '"'))) !== false) {
             $i++;
             if ($i > $finish) {
                 break;
             }
             if ($start >= $i) {
                 continue;
             }
             $lines[] = $data;
         }
         fclose($handle);
     }
     return $lines;
 }
예제 #10
0
 /**
  * @return array
  */
 protected function _isOrderValidByStd()
 {
     $errorMessages = array();
     if ($this->getItems()->count() == 0) {
         $errorMessages[] = 'JBZOO_CART_VALIDATOR_EMPTY';
     }
     if (!$this->_config->get('config.freeorder', 0) && $this->getTotalSum()->isEmpty()) {
         $errorMessages[] = 'JBZOO_CART_VALIDATOR_ZERO_SUM';
     }
     $cart = JBCart::getInstance()->checkItems();
     if ($cart->getErrors()) {
         $errorMessages[] = $cart->getErrors();
     }
     return $errorMessages;
 }
예제 #11
0
 /**
  * @param JSONData $data
  * @return string
  */
 protected function _getLocation($data)
 {
     $location = null;
     if ($data->get('cities')) {
         $location = $data->get('cities');
     } else {
         if ($data->get('countries')) {
             $location = $data->get('countries');
         } else {
             if ($data->get('regions')) {
                 $location = $data->get('regions');
             } else {
                 if ($data->get('russia')) {
                     $location = $data->get('russia');
                 }
             }
         }
     }
     return $location;
 }
예제 #12
0
 /**
  * @return array
  */
 public function getShipping()
 {
     $session = $this->_getSession();
     if (isset($session['shipping']) && isset($session['shipping']['_shipping_id'])) {
         $currentId = $session['shipping']['_shipping_id'];
     } else {
         $currentId = $this->_config->get('default_shipping');
     }
     $shippingList = JBModelConfig::model()->get(JBCart::DEFAULT_POSITION, array(), 'cart.' . JBCart::CONFIG_SHIPPINGS);
     if (empty($currentId) || !isset($shippingList[$currentId])) {
         reset($shippingList);
         $currentId = key($shippingList);
     }
     $shipping = array('_shipping_id' => $currentId);
     if (isset($session['shipping']) && isset($session['shipping'][$currentId])) {
         $shipping = $session['shipping'][$currentId];
     }
     return $shipping;
 }
예제 #13
0
 /**
  * Returns a configuration property of the object or the default value if the property is not set.
  *
  * @param string $property The name of the property
  * @param mixed $default The default value
  *
  * @return mixed The value of the property
  *
  * @since 1.0.0
  */
 public function get($property, $default = null)
 {
     return $this->_params->get($property, $default);
 }
예제 #14
0
 /**
  * Get search data from item
  * @param Item $item
  * @param JSONData $params
  * @return array
  */
 protected function _getSearchData(Item $item, $params)
 {
     // get related categories
     $itemCategories = array();
     $checkCategory = (int) $params->get('check_category', 1);
     if ($checkCategory == 1) {
         $itemCategories[] = $item->getPrimaryCategoryId();
     } else {
         if ($checkCategory == 2) {
             $itemCategories = $item->getRelatedCategoryIds();
         }
     }
     // get manualy conditions
     $conds = array();
     $tmpConds = $params->get('conditions', array());
     foreach ($tmpConds as $cond) {
         if (isset($cond['key']) && !empty($cond['key'])) {
             $key = preg_replace('#[^0-9a-z\\_\\-]#i', '', $cond['key']);
             $value = $cond['value'];
             if (strpos($value, '[') !== false && strpos($value, ']') !== false) {
                 $value = json_decode($value, true);
             }
             if (!empty($value) && !empty($key)) {
                 $conds[$key] = $value;
             }
         }
     }
     // get search data
     $tmpResult = array('_itemfrontpage' => (int) in_array(0, $itemCategories), '_itemcategory' => $itemCategories, '_itemname' => $item->name, '_itemtag' => $item->getTags());
     $elements = $item->getElements();
     foreach ($elements as $element) {
         if ($data = $element->getSearchData()) {
             $tmpResult[$element->identifier] = JString::trim($data);
         }
     }
     $tmpResult = array_merge($tmpResult, $conds);
     // build result
     $checkedFields = $params->get('check_fields', array());
     $checkedFields[] = '_itemtype';
     $result = array();
     foreach ($tmpResult as $id => $values) {
         if (count($checkedFields) > 1 && !in_array($id, $checkedFields, true)) {
             continue;
         }
         $result[$this->_jbtables->getFieldName($id)] = $values;
     }
     return $result;
 }
예제 #15
0
 /**
  * Validate submission
  * @param JSONData $value
  * @param array    $params
  * @return array
  */
 public function _validateSubmission($value, $params)
 {
     $this->_getValuesList();
     $result = array();
     for ($i = 0; $i <= $this->_maxLevel; $i++) {
         $validator = $this->app->validator->create('string', array('required' => $params->get('required')));
         $tmpVal = $value->get('list-' . $i);
         $result['list-' . $i] = $validator->clean($tmpVal);
     }
     return $result;
 }
예제 #16
0
 /**
  * Validate submission
  * @param JSONData $value
  * @param array    $params
  * @return array
  * @throws AppValidatorException
  */
 public function _validateSubmission($value, $params)
 {
     $selectInfo = $this->_getSelectInfo();
     $result = array();
     if ($params->get('mode') == self::VALIDATE_MODE_ANY) {
         for ($i = 0; $i <= $selectInfo['maxLevel']; $i++) {
             $result['list-' . $i] = $value->get('list-' . $i);
         }
         $resultCheck = array_filter($result);
         if (empty($resultCheck) && $params->get('required')) {
             throw new AppValidatorException('This field is required', AppValidator::ERROR_CODE_REQUIRED);
         }
     } else {
         $val = $value->flattenRecursive();
         for ($i = 0; $i < count($val); $i++) {
             $result['list-' . $i] = $this->app->validator->create('string', array('required' => $params->get('required')))->clean($value->get('list-' . $i));
         }
     }
     return $result;
 }
예제 #17
0
 /**
  * Magic method to get a configuration value
  *
  * @param  string $name The configuration key
  *
  * @return mixed       The configuration value
  *
  * @since 2.0
  */
 public function __get($name)
 {
     return $this->config->get($name);
 }
예제 #18
0
 /**
  * Get default image
  * @param JSONData $params
  * @return null|object
  */
 protected function getDefaultImage($params)
 {
     // init vars
     $width = (int) $params->get('width', 0);
     $height = (int) $params->get('height', 0);
     $defaultImage = $this->config->get('default_image');
     $defaultEnable = (int) $this->config->get('default_enable', 0);
     $result = null;
     if ($defaultEnable && $defaultImage) {
         if (strpos($defaultImage, 'http') !== false) {
             return (object) array('width' => $width, 'height' => $height, 'path' => $defaultImage, 'orig' => $defaultImage, 'origUrl' => $defaultImage, 'url' => $defaultImage, 'rel' => $defaultImage);
         } else {
             return $this->_jbimagegallery->resize($defaultImage, $width, $height);
         }
     }
     return null;
 }
예제 #19
0
 /**
  * Validate submission
  * @param JSONData $value
  * @param JSONData $params
  * @return array
  * @throws AppValidatorException
  */
 public function validateSubmission($value, $params)
 {
     $folder = $value->get('value');
     $directory = $this->app->path->path('root:' . trim($this->config->get('directory'), '/\\') . '/' . trim($folder, '/\\'));
     if (!$directory) {
         throw new AppValidatorException('This directory does not exist');
     }
     return $value;
 }
예제 #20
0
 /**
  * @param JSONData $options
  * @return JHttp
  */
 protected function _getClient($options)
 {
     $clientParams = array();
     if ($options->get('certpath')) {
         $clientParams['curl'] = array('certpath' => $options->get('certpath'));
     }
     if ($options->get('follow') !== null) {
         $clientParams['follow_location'] = (bool) $options->get('follow');
     }
     if (class_exists('JRegistry')) {
         // Old Joomla (2.5.x)
         $clientParams = new JRegistry($clientParams);
     } else {
         if (class_exists('Joomla\\Registry\\Registry')) {
             // Joomla 3.x
             $clientParams = new Joomla\Registry\Registry($clientParams);
         }
     }
     $httpClient = JHttpFactory::getHttp($clientParams, $options->get('driver'));
     return $httpClient;
 }