Пример #1
0
 /**
  * Creates array representation
  *
  * @return array
  */
 protected static function transformArray($array, ARSchema $schema)
 {
     if (!empty($array['serializedData'])) {
         $array['serializedData'] = unserialize($array['serializedData']);
     }
     return parent::transformArray($array, $schema);
 }
Пример #2
0
 public static function transformArray($array, ARSchema $schema)
 {
     $array = parent::transformArray($array, $schema);
     $array['countryName'] = self::getApplication()->getLocale()->info()->getCountryName($array['countryID']);
     $array['fullName'] = $array['firstName'] . ' ' . $array['lastName'];
     if (!empty($array['State']) && is_array($array['State'])) {
         $array['stateName'] = $array['State']['name'];
     }
     $array['compact'] = self::getAddressString($array, ', ');
     $array['compactAddressOnly'] = self::getAddressString(array_diff_key($array, array_flip(array('fullName', 'firstName', 'lastName'))), ', ');
     if (!isset($array['stateID']) && isset($array['State']) && is_array($array['State']) && array_key_exists('ID', $array['State'])) {
         $array['stateID'] = $array['State']['ID'];
     }
     return $array;
 }
Пример #3
0
 public static function transformArray($array, ARSchema $schema)
 {
     $array = parent::transformArray($array, $schema);
     $array['fullName'] = $array['firstName'] . ' ' . $array['lastName'];
     return $array;
 }
Пример #4
0
 public static function transformArray($array, ARSchema $schema)
 {
     $array = parent::transformArray($array, $schema);
     $array['name'] = self::getApplication()->getLocale()->info()->getCurrencyName($array['ID']);
     $array['format'] = $array['pricePrefix'] . '%d.' . $array['decimalCount'] . 'f' . $array['priceSuffix'];
     $array['rounding'] = unserialize($array['rounding']);
     return $array;
 }
Пример #5
0
 public static function transformArray($array, ARSchema $schema)
 {
     $array = parent::transformArray($array, $schema);
     try {
         $array['formattedAmount'] = Currency::getInstanceByID($array['Currency']['ID'])->getFormattedPrice($array['amount']);
         $array['formattedRealAmount'] = Currency::getInstanceByID($array['RealCurrency']['ID'])->getFormattedPrice($array['realAmount']);
     } catch (ARNotFoundException $e) {
     }
     $array['methodName'] = self::getApplication()->getLocale()->translator()->translate($array['method']);
     $array['serializedData'] = unserialize($array['serializedData']);
     $array['ccLastDigits'] = self::decrypt($array['ccLastDigits']);
     if (strlen($array['ccCVV']) > 0) {
         $array['ccCVV'] = self::decrypt($array['ccCVV']);
     }
     return $array;
 }
Пример #6
0
 public static function transformArray($array, ARSchema $schema)
 {
     $array = parent::transformArray($array, $schema);
     $currency = Currency::getInstanceByID($array['currencyID']);
     $array['serializedRules'] = unserialize($array['serializedRules']);
     if ($array['serializedRules'] && !is_array($array['serializedRules'])) {
         $array['serializedRules'] = array();
     }
     if ($array['serializedRules'] && is_array($array['serializedRules'])) {
         $ruleController = self::getApplication()->getBusinessRuleController();
         $quantities = array_keys($array['serializedRules']);
         $nextQuant = array();
         foreach ($quantities as $key => $quant) {
             $nextQuant[$quant] = isset($quantities[$key + 1]) ? $quantities[$key + 1] - 1 : null;
         }
         foreach ($array['serializedRules'] as $quantity => $prices) {
             foreach ($prices as $group => $price) {
                 $originalPrice = $currency->roundPrice($price);
                 $product = isset($array['Product']) ? $array['Product'] : Product::getInstanceByID($array['productID']);
                 $price = $ruleController->getProductPrice($product, $originalPrice);
                 $array['quantityPrices'][$group][$quantity] = array('originalPrice' => $originalPrice, 'price' => $price, 'originalFormattedPrice' => $currency->getFormattedPrice($originalPrice), 'formattedPrice' => $currency->getFormattedPrice($price), 'from' => $quantity, 'to' => $nextQuant[$quantity]);
             }
         }
     }
     return $array;
 }
Пример #7
0
 public static function transformArray($array, ARSchema $schema)
 {
     $array = parent::transformArray($array, $schema);
     $array['formattedPrice'] = '';
     if (!empty($array['OrderedItem']['customerOrderID'])) {
         $order = CustomerOrder::getInstanceByID($array['OrderedItem']['customerOrderID']);
         $currency = $order->getCurrency();
         $array['formattedPrice'] = $currency->getFormattedPrice($array['priceDiff']);
     }
     // get uploaded file name
     if (!empty($array['optionText']) && strpos($array['optionText'], '___')) {
         $array['fileName'] = self::getFileName($array['optionText']);
         $array = array_merge($array, self::getImagePaths($array['optionText']));
     }
     return $array;
 }
Пример #8
0
 /**
  * Tranforms object data to data array in the following format:
  *
  * simpleField => value,
  * multilingualField_langCode => value,
  * multilingualField2_langCode => otherValue, and etc.
  *
  * @param array $array
  * @todo cleanup
  * @return array
  */
 public static function transformArray($array, ARSchema $schema)
 {
     $array = parent::transformArray($array, $schema);
     foreach ($schema->getArrayFieldList() as $fieldName) {
         if (!empty($array[$fieldName])) {
             $data = $array[$fieldName];
             $array[$fieldName . 'Data'] = $data;
             if (!is_array($data)) {
                 continue;
             }
             if (!self::$defaultLanguageCode) {
                 self::loadLanguageCodes();
             }
             foreach ($data as $lang => $value) {
                 $array[$fieldName . '_' . $lang] = $value;
             }
             $array[$fieldName] = !empty($data[self::$defaultLanguageCode]) ? $data[self::$defaultLanguageCode] : '';
             reset($data);
             $array[$fieldName . '_lang'] = !empty($data[self::$currentLanguageCode]) ? $data[self::$currentLanguageCode] : (!empty($array[$fieldName]) ? $array[$fieldName] : $data[key($data)]);
             /* use data from any language if the default language is empty */
         }
     }
     return $array;
 }