/** * Generate the checkout step * @return string */ public function generate() { // Make sure field data is available \Controller::loadDataContainer('tl_iso_product_collection'); \System::loadLanguageFile('tl_iso_product_collection'); $objTemplate = new Template($this->strTemplate); $varValue = null; $objWidget = new FormTextArea(FormTextArea::getAttributesFromDca($GLOBALS['TL_DCA'][$this->strTable]['fields'][$this->strField], $this->strField, $varValue, $this->strField, $this->strTable, $this)); $objWidget->storeValues = true; if (\Input::post('FORM_SUBMIT') == $this->strFormId) { $objWidget->validate(); $varValue = $objWidget->value; // Do not submit the field if there are errors if ($objWidget->hasErrors()) { $doNotSubmit = true; } elseif ($objWidget->submitInput()) { $objOrder = Isotope::getCart()->getDraftOrder(); // Store the form data $_SESSION['FORM_DATA'][$this->strField] = $varValue; // Set the correct empty value (see #6284, #6373) if ($varValue === '') { $varValue = $objWidget->getEmptyValue(); } // Set the new value if ($varValue !== $objOrder->{$this->strField}) { $objOrder->{$this->strField}; } } } $objTemplate->headline = $GLOBALS['TL_LANG'][$this->strTable][$this->strField][0]; $objTemplate->customerNotes = $objWidget->parse(); return $objTemplate->parse(); }
/** * Generate the checkout step * @return string */ public function generate() { $objTemplate = new Template($this->strTemplate); $arrAttributes = ['dateDirection' => 'gtToday', 'inputType' => 'calendar', 'eval' => ['required' => true, 'rgxp' => 'date', 'datepicker' => true]]; $varValue = null; $objWidget = new FormCalendarField(FormCalendarField::getAttributesFromDca($arrAttributes, $this->strField, $varValue, $this->strField, $this->strTable, $this)); $objWidget->storeValues = true; if (\Input::post('FORM_SUBMIT') == $this->strFormId) { $objWidget->validate(); $varValue = $objWidget->value; $rgxp = $arrAttributes['eval']['rgxp']; // Convert date formats into timestamps (check the eval setting first -> #3063) if ($varValue != '' && in_array($rgxp, array('date', 'time', 'datim'))) { try { $objDate = new \Date($varValue, \Date::getFormatFromRgxp($rgxp)); $varValue = $objDate->tstamp; } catch (\OutOfBoundsException $e) { $objWidget->addError(sprintf($GLOBALS['TL_LANG']['ERR']['invalidDate'], $varValue)); } } // Do not submit the field if there are errors if ($objWidget->hasErrors()) { $doNotSubmit = true; } elseif ($objWidget->submitInput()) { $objOrder = Isotope::getCart()->getDraftOrder(); // Store the form data $_SESSION['FORM_DATA'][$this->strField] = $varValue; // Set the correct empty value (see #6284, #6373) if ($varValue === '') { $varValue = $objWidget->getEmptyValue(); } // Set the new value if ($varValue !== $objOrder->{$this->strField}) { $objOrder->{$this->strField}; } } } $objTemplate->headline = $GLOBALS['TL_LANG'][$this->strTable]['date_picker'][0]; $objTemplate->datePicker = $objWidget->parse(); return $objTemplate->parse(); }
/** * @param string $attribute * @param string $queryType * @param string $countType * @param bool $showClear * * @return array|null */ protected function generateAttribute($attribute, $queryType, $countType, &$showClear) { $isActive = false; $label = $attribute; // Will be updated by getOptionsForAttribute() $options = $this->getOptionsForAttribute($attribute, $label); // Must have options to apply the filter if (empty($options)) { return null; } $arrItems = $this->generateOptions($attribute, $options, $queryType, $countType, $isActive); // Hide fields with just one option (if enabled) if (empty($arrItems) || $this->iso_filterHideSingle && count($arrItems) < 2) { return null; } $objClass = RowClass::withKey('class')->addFirstLast(); if ($isActive) { $objClass->addCustom('sibling'); $showClear = true; } $objClass->applyTo($arrItems); /** @var Template|object $objTemplate */ $objTemplate = new Template($this->navigationTpl); $objTemplate->level = 'level_2'; $objTemplate->items = $arrItems; $class = $attribute . ' query_' . strtolower($queryType) . ' count_' . $countType; if ($this->isMultiple($attribute)) { $class .= ' multiple'; } if ($isActive) { $class .= ' trail'; } return array('label' => $label, 'subitems' => $objTemplate->parse(), 'isActive' => $isActive, 'class' => $class); }
/** * Generate a product template * * @param array $arrConfig * * @return string */ public function generate(array $arrConfig) { $this->strFormId = ($arrConfig['module'] instanceof \ContentElement ? 'cte' : 'fmd') . $arrConfig['module']->id . '_product_' . $this->getProductId(); $objProduct = $this->validateVariant(); // A variant has been loaded, generate the variant if ($objProduct->id != $this->id) { return $objProduct->generate($arrConfig); } $arrGalleries = array(); /** @type Template|object $objTemplate */ $objTemplate = new Template($arrConfig['template']); $objTemplate->setData($this->arrData); $objTemplate->product = $this; $objTemplate->config = $arrConfig; $objTemplate->generateAttribute = function ($strAttribute, array $arrOptions = array()) use($objProduct) { $objAttribute = $GLOBALS['TL_DCA']['tl_iso_product']['attributes'][$strAttribute]; if (!$objAttribute instanceof IsotopeAttribute) { throw new \InvalidArgumentException($strAttribute . ' is not a valid attribute'); } return $objAttribute->generate($objProduct, $arrOptions); }; $objTemplate->generatePrice = function () use($objProduct) { $objPrice = $objProduct->getPrice(); /** @type ProductType $objType */ $objType = $objProduct->getRelated('type'); if (null === $objPrice) { return ''; } return $objPrice->generate($objType->showPriceTiers(), 1, $objProduct->getOptions()); }; $objTemplate->getGallery = function ($strAttribute) use($objProduct, $arrConfig, &$arrGalleries) { if (!isset($arrGalleries[$strAttribute])) { $arrGalleries[$strAttribute] = Gallery::createForProductAttribute($objProduct, $strAttribute, $arrConfig); } return $arrGalleries[$strAttribute]; }; $arrVariantOptions = array(); $arrProductOptions = array(); $arrAjaxOptions = array(); foreach (array_unique(array_merge($this->getAttributes(), $this->getVariantAttributes())) as $attribute) { $arrData = $GLOBALS['TL_DCA']['tl_iso_product']['fields'][$attribute]; if ($arrData['attributes']['customer_defined'] || $arrData['attributes']['variant_option']) { $strWidget = $this->generateProductOptionWidget($attribute, $arrVariantOptions, $arrAjaxOptions); if ($strWidget != '') { $arrProductOptions[$attribute] = array_merge($arrData, array('name' => $attribute, 'html' => $strWidget)); } } } $arrButtons = array(); // !HOOK: retrieve buttons if (isset($GLOBALS['ISO_HOOKS']['buttons']) && is_array($GLOBALS['ISO_HOOKS']['buttons'])) { foreach ($GLOBALS['ISO_HOOKS']['buttons'] as $callback) { $objCallback = \System::importStatic($callback[0]); $arrButtons = $objCallback->{$callback}[1]($arrButtons); } $arrButtons = array_intersect_key($arrButtons, array_flip($arrConfig['buttons'])); } if (\Input::post('FORM_SUBMIT') == $this->getFormId() && !$this->doNotSubmit) { foreach ($arrButtons as $button => $data) { if (isset($_POST[$button])) { if (isset($data['callback'])) { $objCallback = \System::importStatic($data['callback'][0]); $objCallback->{$data['callback'][1]}($this, $arrConfig); } break; } } } RowClass::withKey('rowClass')->addCustom('product_option')->addFirstLast()->addEvenOdd()->applyTo($arrProductOptions); $objTemplate->buttons = $arrButtons; $objTemplate->useQuantity = $arrConfig['useQuantity']; $objTemplate->minimum_quantity = $this->getMinimumQuantity(); $objTemplate->raw = $this->arrData; $objTemplate->raw_options = $this->getConfiguration(); $objTemplate->configuration = $this->getConfiguration(); $objTemplate->href = $this->generateUrl($arrConfig['jumpTo']); $objTemplate->label_detail = $GLOBALS['TL_LANG']['MSC']['detailLabel']; $objTemplate->options = $arrProductOptions; $objTemplate->hasOptions = !empty($arrProductOptions); $objTemplate->enctype = $this->hasUpload ? 'multipart/form-data' : 'application/x-www-form-urlencoded'; $objTemplate->formId = $this->getFormId(); $objTemplate->action = ampersand(\Environment::get('request'), true); $objTemplate->formSubmit = $this->getFormId(); $objTemplate->product_id = $this->getProductId(); $objTemplate->module_id = $arrConfig['module']->id; $GLOBALS['AJAX_PRODUCTS'][] = array('formId' => $this->getFormId(), 'attributes' => $arrAjaxOptions); // !HOOK: alter product data before output if (isset($GLOBALS['ISO_HOOKS']['generateProduct']) && is_array($GLOBALS['ISO_HOOKS']['generateProduct'])) { foreach ($GLOBALS['ISO_HOOKS']['generateProduct'] as $callback) { $objCallback = \System::importStatic($callback[0]); $objCallback->{$callback}[1]($objTemplate, $this); } } return $objTemplate->parse(); }
/** * Adjust the product groups manager view * * @param \Template $objTemplate */ public function adjustGroupsManager($objTemplate) { if (\Input::get('popup') && \Input::get('do') == 'iso_products' && \Input::get('table') == Group::getTable() && $objTemplate->getName() == 'be_main') { $objTemplate->managerHref = ampersand($this->Session->get('groupPickerRef')); $objTemplate->manager = $GLOBALS['TL_LANG']['MSC']['groupPickerHome']; } }
/** * Generate template with given file * @param object * @param string * @param array * @return string */ protected function addImageToTemplate(\Isotope\Template $objTemplate, $strType, array $arrFile) { $objTemplate->setData($this->arrData); $objTemplate->type = $strType; $objTemplate->product_id = $this->product_id; $objTemplate->file = $arrFile; $objTemplate->src = $arrFile[$strType]; $objTemplate->size = $arrFile[$strType . '_size']; $objTemplate->alt = $arrFile['alt']; $objTemplate->title = $arrFile['desc']; $objTemplate->class = trim($this->arrData['class'] . ' ' . $arrFile['class']); switch ($this->anchor) { case 'reader': $objTemplate->hasLink = $this->href != ''; $objTemplate->link = $this->href; break; case 'lightbox': list($link, $rel) = explode('|', $arrFile['link'], 2); $objTemplate->hasLink = true; $objTemplate->link = $link ?: $arrFile['lightbox']; $objTemplate->attributes = $link ? $rel ? ' data-lightbox="' . $rel . '"' : ' target="_blank"' : ' data-lightbox="product' . $this->product_id . '"'; break; default: $objTemplate->hasLink = false; break; } }
/** * Return the payment form. * @param IsotopeProductCollection The order being places * @param Module The checkout module instance * @return string */ public function checkoutForm(IsotopeProductCollection $objOrder, \Module $objModule) { global $objPage; $objTemplate = new Template('iso_payment_sparkasse'); $objTemplate->amount = number_format($objOrder->getTotal(), 2, ',', ''); $objTemplate->basketid = $objOrder->source_collection_id; $objTemplate->currency = $objOrder->currency; $objTemplate->locale = $objOrder->language; $objTemplate->orderid = $objOrder->id; $objTemplate->sessionid = $objPage->id; $objTemplate->transactiontype = $this->trans_type == 'auth' ? 'preauthorization' : 'authorization'; $objTemplate->merchantref = ''; if ($this->sparkasse_merchantref != '') { $objTemplate->merchantref = substr($this->replaceInsertTags($this->sparkasse_merchantref), 0, 30); } $objTemplate->headline = $GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][0]; $objTemplate->message = $GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][1]; $objTemplate->link = $GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][2]; // Unfortunately we can't use the class method for this // @todo change when PHP 5.4 is compulsory $objTemplate->calculateHash = function ($arrData) { ksort($arrData); return hash_hmac('sha1', implode('', $arrData), $this->sparkasse_sslpassword); }; return $objTemplate->parse(); }