示例#1
0
文件: Worldpay.php 项目: Aziz-JH/core
 /**
  * Return the checkout form.
  * @param   IsotopeProductCollection    The order being places
  * @param   Module                      The checkout module instance
  * @return string
  */
 public function checkoutForm(IsotopeProductCollection $objOrder, \Module $objModule)
 {
     global $objPage;
     $objAddress = $objOrder->getBillingAddress();
     $arrData['instId'] = $this->worldpay_instId;
     $arrData['cartId'] = $objOrder->id;
     $arrData['amount'] = number_format($objOrder->getTotal(), 2);
     $arrData['currency'] = $objOrder->currency;
     $arrData['description'] = Translation::get($this->worldpay_description);
     $arrData['name'] = substr($objAddress->firstname . ' ' . $objAddress->lastname, 0, 40);
     if ($objAddress->company != '') {
         $arrData['address1'] = substr($objAddress->company, 0, 84);
         $arrData['address2'] = substr($objAddress->street_1, 0, 84);
         $arrData['address3'] = substr($objAddress->street_2, 0, 84);
     } else {
         $arrData['address1'] = substr($objAddress->street_1, 0, 84);
         $arrData['address2'] = substr($objAddress->street_2, 0, 84);
         $arrData['address3'] = substr($objAddress->street_3, 0, 84);
     }
     $arrData['town'] = substr($objAddress->city, 0, 30);
     $arrData['region'] = substr($objAddress->subdivision, 0, 30);
     $arrData['postcode'] = substr($objAddress->postal, 0, 12);
     $arrData['country'] = strtoupper($objAddress->country);
     $arrData['tel'] = substr($objAddress->phone, 0, 30);
     $arrData['email'] = substr($objAddress->email, 0, 80);
     // Generate MD5 secret hash
     $arrData['signature'] = md5($this->worldpay_md5secret . ':' . implode(':', array_intersect_key($arrData, array_flip(trimsplit(':', $this->worldpay_signatureFields)))));
     $objTemplate = new \Isotope\Template('iso_payment_worldpay');
     $objTemplate->setData($arrData);
     $objTemplate->id = $this->id;
     $objTemplate->pageId = $objPage->id;
     $objTemplate->debug = $this->debug;
     $objTemplate->action = $this->debug ? 'https://secure-test.worldpay.com/wcc/purchase' : 'https://secure.worldpay.com/wcc/purchase';
     return $objTemplate->parse();
 }
 /**
  * Get options for the frontend product filter widget
  *
  * @param array $arrValues
  *
  * @return array
  */
 public function getOptionsForProductFilter(array $arrValues)
 {
     switch ($this->optionsSource) {
         // @deprecated remove in Isotope 3.0
         case 'attribute':
             $arrOptions = array();
             $options = deserialize($this->options);
             if (!empty($options) && is_array($options)) {
                 foreach ($options as $option) {
                     if (in_array($option['value'], $arrValues)) {
                         $option['label'] = Translation::get($option['label']);
                         $arrOptions[] = $option;
                     }
                 }
             }
             return $arrOptions;
             break;
         case 'foreignKey':
             list($table, $field) = explode('.', $this->foreignKey, 2);
             $result = \Database::getInstance()->execute("SELECT id AS value, {$field} AS label FROM {$table}");
             return $result->fetchAllAssoc();
             break;
         case 'table':
         case 'product':
             /** @type \Isotope\Collection\AttributeOption $objOptions */
             $objOptions = AttributeOption::findPublishedByIds($arrValues);
             return null === $objOptions ? array() : $objOptions->getArrayForFrontendWidget(null, false);
             break;
         default:
             throw new \UnexpectedValueException('Invalid options source "' . $this->optionsSource . '" for ' . static::$strTable . '.' . $this->field_name);
     }
 }
示例#3
0
 /**
  * Save attribute configuration into the given DCA array
  * @param    array
  */
 public function saveToDCA(array &$arrData)
 {
     // Keep field settings made through DCA code
     $arrField = is_array($arrData['fields'][$this->field_name]) ? $arrData['fields'][$this->field_name] : array();
     $arrField['label'] = Translation::get(array($this->name, $this->description));
     $arrField['exclude'] = true;
     $arrField['inputType'] = '';
     $arrField['attributes'] = $this->row();
     $arrField['attributes']['variant_option'] = $this->isVariantOption();
     $arrField['attributes']['customer_defined'] = $this->isCustomerDefined();
     $arrField['eval'] = is_array($arrField['eval']) ? array_merge($arrField['eval'], $arrField['attributes']) : $arrField['attributes'];
     if (!$this->isCustomerDefined()) {
         $arrField['inputType'] = (string) array_search($this->getBackendWidget(), $GLOBALS['BE_FFL']);
     }
     // Support numeric paths (fileTree)
     unset($arrField['eval']['path']);
     if ($this->path != '' && ($objFile = \FilesModel::findByPk($this->path)) !== null) {
         $arrField['eval']['path'] = $objFile->path;
     }
     // Contao tries to load an empty tinyMCE config otherwise (see #1111)
     if ($this->rte == '') {
         unset($arrField['eval']['rte']);
     }
     if ($this->be_filter) {
         $arrField['filter'] = true;
     }
     if ($this->be_search) {
         $arrField['search'] = true;
     }
     // Variant selection is always mandatory
     if ($this->isVariantOption()) {
         $arrField['eval']['mandatory'] = true;
     }
     if ($this->blankOptionLabel != '') {
         $arrField['eval']['blankOptionLabel'] = Translation::get($this->blankOptionLabel);
     }
     // Prepare options
     if ($this->optionsSource == 'foreignKey' && !$this->isVariantOption()) {
         $arrField['foreignKey'] = $this->parseForeignKey($this->foreignKey, $GLOBALS['TL_LANGUAGE']);
         unset($arrField['options']);
         unset($arrField['reference']);
     } else {
         $arrOptions = null;
         switch ($this->optionsSource) {
             case 'attribute':
                 $arrOptions = deserialize($this->options);
                 break;
             case 'foreignKey':
                 $arrKey = explode('.', $this->foreignKey, 2);
                 $arrOptions = \Database::getInstance()->execute("SELECT id AS value, {$arrKey[1]} AS label FROM {$arrKey[0]} ORDER BY label")->fetchAllAssoc();
                 break;
             case 'table':
                 $query = new \DC_Multilingual_Query(AttributeOption::getTable());
                 $arrOptions = $query->addField('t1.id AS value')->addOrder('t1.label')->addWhere('t1.pid = ?')->getStatement()->execute($this->id)->fetchAllAssoc();
                 break;
             case 'product':
                 $query = new \DC_Multilingual_Query(AttributeOption::getTable());
                 $arrOptions = $query->addField('t1.id AS value')->addOrder('t1.label')->addWhere('t1.field_name = ?')->getStatement()->execute($this->field_name)->fetchAllAssoc();
                 break;
             default:
                 if ($this instanceof IsotopeAttributeWithOptions) {
                     unset($arrField['options']);
                     unset($arrField['reference']);
                 }
         }
         if (!empty($arrOptions) && is_array($arrOptions)) {
             $arrField['default'] = array();
             $arrField['options'] = array();
             $arrField['eval']['isAssociative'] = true;
             unset($arrField['reference']);
             $strGroup = '';
             foreach ($arrOptions as $option) {
                 if ($option['group']) {
                     $strGroup = Translation::get($option['label']);
                     continue;
                 }
                 if ($strGroup != '') {
                     $arrField['options'][$strGroup][$option['value']] = Translation::get($option['label']);
                 } else {
                     $arrField['options'][$option['value']] = Translation::get($option['label']);
                 }
                 if ($option['default']) {
                     $arrField['default'][] = $option['value'];
                 }
             }
         }
     }
     unset($arrField['eval']['foreignKey']);
     unset($arrField['eval']['options']);
     // Add field to the current DCA table
     $arrData['fields'][$this->field_name] = $arrField;
 }
示例#4
0
文件: TaxClass.php 项目: Aziz-JH/core
 /**
  * Get label
  * @return  string
  */
 public function getLabel()
 {
     return Translation::get($this->label ?: $this->name);
 }
示例#5
0
 /**
  * Save attribute configuration into the given DCA array
  * @param    array
  */
 public function saveToDCA(array &$arrData)
 {
     // Keep field settings made through DCA code
     $arrField = is_array($arrData['fields'][$this->field_name]) ? $arrData['fields'][$this->field_name] : array();
     $arrField['label'] = Translation::get(array($this->name, $this->description));
     $arrField['exclude'] = true;
     $arrField['inputType'] = array_search($this->getBackendWidget(), $GLOBALS['BE_FFL']);
     $arrField['attributes'] = $this->row();
     $arrField['attributes']['variant_option'] = $this->isVariantOption();
     $arrField['attributes']['customer_defined'] = $this->isCustomerDefined();
     $arrField['eval'] = is_array($arrField['eval']) ? array_merge($arrField['eval'], $arrField['attributes']) : $arrField['attributes'];
     // Support numeric paths (fileTree)
     unset($arrField['eval']['path']);
     if ($this->path != '' && ($objFile = \FilesModel::findByPk($this->path)) !== null) {
         $arrField['eval']['path'] = $objFile->path;
     }
     // Contao tries to load an empty tinyMCE config otherwise (see #1111)
     if ($this->rte == '') {
         unset($arrField['eval']['rte']);
     }
     if ($this->be_filter) {
         $arrField['filter'] = true;
     }
     if ($this->be_search) {
         $arrField['search'] = true;
     }
     // Variant selection is always mandatory
     if ($this->isVariantOption()) {
         $arrField['eval']['mandatory'] = true;
         $this->customer_defined = false;
         $arrField['attributes']['customer_defined'] = false;
     }
     // Parse multiline/multilingual foreignKey
     $this->foreignKey = $this->parseForeignKey($this->foreignKey, $GLOBALS['TL_LANGUAGE']);
     // Prepare options
     if ($this->foreignKey != '' && !$this->isVariantOption()) {
         $arrField['foreignKey'] = $this->foreignKey;
         $arrField['eval']['includeBlankOption'] = true;
         unset($arrField['options']);
     } else {
         if ($this->foreignKey) {
             $arrKey = explode('.', $this->foreignKey, 2);
             $arrOptions = \Database::getInstance()->execute("SELECT id AS value, {$arrKey[1]} AS label FROM {$arrKey[0]} ORDER BY label")->fetchAllAssoc();
         } else {
             $arrOptions = deserialize($this->options);
         }
         if (is_array($arrOptions) && !empty($arrOptions)) {
             $arrField['default'] = array();
             $arrField['options'] = array();
             $arrField['eval']['isAssociative'] = true;
             unset($arrField['reference']);
             $strGroup = '';
             foreach ($arrOptions as $option) {
                 if ($option['value'] == '') {
                     $arrField['eval']['includeBlankOption'] = true;
                     $arrField['eval']['blankOptionLabel'] = Translation::get($option['label']);
                     continue;
                 } elseif ($option['group']) {
                     $strGroup = Translation::get($option['label']);
                     continue;
                 }
                 if ($strGroup != '') {
                     $arrField['options'][$strGroup][$option['value']] = Translation::get($option['label']);
                 } else {
                     $arrField['options'][$option['value']] = Translation::get($option['label']);
                 }
                 if ($option['default']) {
                     $arrField['default'][] = $option['value'];
                 }
             }
         }
     }
     unset($arrField['eval']['foreignKey']);
     unset($arrField['eval']['options']);
     // Add field to the current DCA table
     $arrData['fields'][$this->field_name] = $arrField;
 }
示例#6
0
 /**
  * Get label
  *
  * @return  string
  */
 public function getLabel()
 {
     return $this->label ? Translation::get($this->label) : '';
 }
示例#7
0
 /**
  * Return the localized order status name
  * @return  string
  */
 public function getName()
 {
     return Translation::get($this->name);
 }
示例#8
0
 /**
  * Replaces given label from values in the translation table
  *
  * @param string $label    The label to be translated
  * @param string $language Optionally accepts the desired language, uses current language if empty
  *
  * @return string
  */
 private function getValueForLabel($label, $language = null)
 {
     return Translation::get($label, $language);
 }
示例#9
0
 /**
  * Replaces Isotope specific InsertTags in Frontend
  * @param string
  * @return mixed
  */
 public function replaceIsotopeTags($strTag)
 {
     $arrTag = trimsplit('::', $strTag);
     // {{isotope::*}} and {{cache_isotope::*}} insert tags
     if ($arrTag[0] == 'isotope' || $arrTag[0] == 'cache_isotope') {
         switch ($arrTag[1]) {
             case 'cart_items':
                 return Isotope::getCart()->countItems();
                 break;
             case 'cart_quantity':
                 return Isotope::getCart()->sumItemsQuantity();
                 break;
             case 'cart_items_label':
                 $intCount = Isotope::getCart()->countItems();
                 if (!$intCount) {
                     return '';
                 }
                 return $intCount == 1 ? '(' . $GLOBALS['TL_LANG']['MSC']['productSingle'] . ')' : sprintf('(' . $GLOBALS['TL_LANG']['MSC']['productMultiple'] . ')', $intCount);
                 break;
             case 'cart_quantity_label':
                 $intCount = Isotope::getCart()->sumItemsQuantity();
                 if (!$intCount) {
                     return '';
                 }
                 return $intCount == 1 ? '(' . $GLOBALS['TL_LANG']['MSC']['productSingle'] . ')' : sprintf('(' . $GLOBALS['TL_LANG']['MSC']['productMultiple'] . ')', $intCount);
                 break;
             case 'cart_subtotal':
                 return Isotope::formatPriceWithCurrency(Isotope::getCart()->getSubtotal());
                 break;
             case 'cart_taxfree_subtotal':
                 return Isotope::formatPriceWithCurrency(Isotope::getCart()->getTaxFreeSubtotal());
                 break;
             case 'cart_total':
                 return Isotope::formatPriceWithCurrency(Isotope::getCart()->getTotal());
                 break;
             case 'cart_taxfree_total':
                 return Isotope::formatPriceWithCurrency(Isotope::getCart()->getTaxFreeTotal());
                 break;
         }
         return '';
     } elseif ($arrTag[0] == 'isolabel') {
         return Translation::get($arrTag[1], $arrTag[2]);
     } elseif ($arrTag[0] == 'order') {
         if (($objOrder = Order::findOneByUniqid(\Input::get('uid'))) !== null) {
             return $objOrder->{$arrTag[1]};
         }
         return '';
     } elseif ($arrTag[0] == 'product') {
         // 2 possible use cases:
         // {{product::attribute}}                - gets the data of the current product (Product::getActive() or GET parameter "product")
         // {{product::attribute::product_id}}    - gets the data of the specified product ID
         if (count($arrTag) == 3) {
             $objProduct = Product::findAvailableByPk($arrTag[2]);
         } else {
             if (($objProduct = Product::getActive()) === null) {
                 $objProduct = Product::findAvailableByIdOrAlias(\Haste\Input\Input::getAutoItem('product', false, true));
             }
         }
         return $objProduct !== null ? $objProduct->{$arrTag[1]} : '';
     }
     return false;
 }