/** * Show message while we are waiting for server-to-server order confirmation * @param IsotopeProductCollection The order being places * @param Module The checkout module instance * @return boolean */ public function processPayment(IsotopeProductCollection $objOrder, \Module $objModule) { if ($objOrder->order_status > 0) { unset($_SESSION['POSTSALE_TIMEOUT']); return true; } if (!isset($_SESSION['POSTSALE_TIMEOUT'])) { $_SESSION['POSTSALE_TIMEOUT'] = 12; } else { $_SESSION['POSTSALE_TIMEOUT'] = $_SESSION['POSTSALE_TIMEOUT'] - 1; } if ($_SESSION['POSTSALE_TIMEOUT'] > 0) { // Reload page every 5 seconds $GLOBALS['TL_HEAD'][] = '<meta http-equiv="refresh" content="5,' . \Environment::get('base') . \Environment::get('request') . '">'; // Do not index or cache the page global $objPage; $objPage->noSearch = 1; $objPage->cache = 0; $objTemplate = new \Isotope\Template('mod_message'); $objTemplate->type = 'processing'; $objTemplate->message = $GLOBALS['TL_LANG']['MSC']['payment_processing']; return $objTemplate->parse(); } unset($_SESSION['POSTSALE_TIMEOUT']); \System::log('Payment could not be processed.', __METHOD__, TL_ERROR); return false; }
/** * Generate the checkout step * @return string */ public function generate() { $objTemplate = new \Isotope\Template('iso_checkout_order_info'); $objTemplate->headline = $GLOBALS['TL_LANG']['MSC']['order_review']; $objTemplate->message = $GLOBALS['TL_LANG']['MSC']['order_review_message']; $objTemplate->summary = $GLOBALS['TL_LANG']['MSC']['cartSummary']; $objTemplate->info = $this->objModule->getCheckoutInfo(); $objTemplate->edit_info = $GLOBALS['TL_LANG']['MSC']['changeCheckoutInfo']; return $objTemplate->parse(); }
/** * Generate the submit form for datatrans and if javascript is enabled redirect automaticly * @param IsotopeProductCollection The order being places * @param Module The checkout module instance * @return string */ public function checkoutForm(IsotopeProductCollection $objOrder, \Module $objModule) { $objAddress = $objOrder->getBillingAddress(); $arrParams = array('merchantId' => $this->datatrans_id, 'amount' => round($objOrder->getTotal() * 100), 'currency' => $objOrder->currency, 'refno' => $objOrder->id, 'language' => $objOrder->language, 'reqtype' => $this->trans_type == 'auth' ? 'NOA' : 'CAA', 'uppCustomerDetails' => 'yes', 'uppCustomerTitle' => $objAddress->salutation, 'uppCustomerFirstName' => $objAddress->firstname, 'uppCustomerLastName' => $objAddress->lastname, 'uppCustomerStreet' => $objAddress->street_1, 'uppCustomerStreet2' => $objAddress->street_2, 'uppCustomerCity' => $objAddress->city, 'uppCustomerCountry' => $objAddress->country, 'uppCustomerZipCode' => $objAddress->postal, 'uppCustomerPhone' => $objAddress->phone, 'uppCustomerEmail' => $objAddress->email, 'successUrl' => ampersand(\Environment::get('base') . $objModule->generateUrlForStep('complete', $objOrder)), 'errorUrl' => ampersand(\Environment::get('base') . $objModule->generateUrlForStep('failed')), 'cancelUrl' => ampersand(\Environment::get('base') . $objModule->generateUrlForStep('failed')), 'mod' => 'pay', 'id' => $this->id); // Security signature (see Security Level 2) $arrParams['sign'] = hash_hmac('md5', $arrParams['merchantId'] . $arrParams['amount'] . $arrParams['currency'] . $arrParams['refno'], $this->datatrans_sign); $objTemplate = new \Isotope\Template('iso_payment_datatrans'); $objTemplate->id = $this->id; $objTemplate->action = 'https://' . ($this->debug ? 'pilot' : 'payment') . '.datatrans.biz/upp/jsp/upStart.jsp'; $objTemplate->params = $arrParams; $objTemplate->headline = $GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][0]; $objTemplate->message = $GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][1]; $objTemplate->slabel = specialchars($GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][2]); return $objTemplate->parse(); }
/** * Return the payment form * * @param IsotopeProductCollection|Order $objOrder * @param \Module|\Isotope\Module\Checkout $objModule * * @return string */ public function checkoutForm(IsotopeProductCollection $objOrder, \Module $objModule) { $objTemplate = new \Isotope\Template('iso_payment_quickpay'); $objTemplate->setData($this->arrData); $params = array('version' => 'v10', 'merchant_id' => $this->quickpay_merchantId, 'agreement_id' => $this->quickpay_agreementId, 'order_id' => str_pad($objOrder->id, 4, '0', STR_PAD_LEFT), 'language' => substr($GLOBALS['TL_LANGUAGE'], 0, 2), 'amount' => Currency::getAmountInMinorUnits($objOrder->getTotal(), $objOrder->currency), 'currency' => $objOrder->currency, 'continueurl' => \Environment::get('base') . $objModule->generateUrlForStep('complete', $objOrder), 'cancelurl' => \Environment::get('base') . $objModule->generateUrlForStep('failed'), 'callbackurl' => \Environment::get('base') . 'system/modules/isotope/postsale.php?mod=pay&id=' . $this->id, 'autocapture' => $this->trans_type == 'capture' ? '1' : '0'); if ('' !== $this->quickpay_paymentMethods) { $params['payment_methods'] = $this->quickpay_paymentMethods; } $apiKey = $this->quickpay_apiKey; $objTemplate->params = $params; $objTemplate->calculateHash = function ($params) use($apiKey) { ksort($params); return hash_hmac("sha256", implode(" ", $params), $apiKey); }; return $objTemplate->parse(); }
/** * Return the PayPal form. * * @param IsotopeProductCollection|Order $objOrder The order being places * @param \Module|Checkout $objModule The checkout module instance * * @return string */ public function checkoutForm(IsotopeProductCollection $objOrder, \Module $objModule) { $arrData = array(); $fltDiscount = 0; $i = 0; foreach ($objOrder->getItems() as $objItem) { // Set the active product for insert tags replacement if ($objItem->hasProduct()) { Product::setActive($objItem->getProduct()); } $strConfig = ''; $arrConfig = $objItem->getConfiguration(); if (!empty($arrConfig)) { array_walk($arrConfig, function (&$option) { $option = $option['label'] . ': ' . (string) $option; }); $strConfig = ' (' . implode(', ', $arrConfig) . ')'; } $arrData['item_number_' . ++$i] = $objItem->getSku(); $arrData['item_name_' . $i] = \StringUtil::restoreBasicEntities($objItem->getName() . $strConfig); $arrData['amount_' . $i] = $objItem->getPrice(); $arrData['quantity_' . $i] = $objItem->quantity; } foreach ($objOrder->getSurcharges() as $objSurcharge) { if (!$objSurcharge->addToTotal) { continue; } // PayPal does only support one single discount item if ($objSurcharge->total_price < 0) { $fltDiscount -= $objSurcharge->total_price; continue; } $arrData['item_name_' . ++$i] = $objSurcharge->label; $arrData['amount_' . $i] = $objSurcharge->total_price; } $objTemplate = new \Isotope\Template('iso_payment_paypal'); $objTemplate->setData($this->arrData); $objTemplate->id = $this->id; $objTemplate->action = 'https://www.' . ($this->debug ? 'sandbox.' : '') . 'paypal.com/cgi-bin/webscr'; $objTemplate->invoice = $objOrder->id; $objTemplate->data = array_map('specialchars', $arrData); $objTemplate->discount = $fltDiscount; $objTemplate->address = $objOrder->getBillingAddress(); $objTemplate->currency = $objOrder->currency; $objTemplate->return = \Environment::get('base') . $objModule->generateUrlForStep('complete', $objOrder); $objTemplate->cancel_return = \Environment::get('base') . $objModule->generateUrlForStep('failed'); $objTemplate->notify_url = \Environment::get('base') . 'system/modules/isotope/postsale.php?mod=pay&id=' . $this->id; $objTemplate->headline = specialchars($GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][0]); $objTemplate->message = specialchars($GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][1]); $objTemplate->slabel = specialchars($GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][2]); $objTemplate->noscript = specialchars($GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][3]); return $objTemplate->parse(); }
/** * Returns a rule form if needed * @access public * @param object $objModule * @return string */ public function getCouponForm($objModule) { $arrCoupons = deserialize(Isotope::getCart()->coupons); if (!is_array($arrCoupons)) { $arrCoupons = array(); } $strCoupon = \Input::get('coupon_' . $objModule->id); if ($strCoupon == '') { $strCoupon = \Input::get('coupon'); } if ($strCoupon != '') { $objRule = Rule::findOneByCouponCode($strCoupon, Isotope::getCart()->getItems()); if (null === $objRule) { $_SESSION['COUPON_FAILED'][$objModule->id] = sprintf($GLOBALS['TL_LANG']['MSC']['couponInvalid'], $strCoupon); } else { if (in_array(strtolower($strCoupon), array_map('strtolower', $arrCoupons))) { $_SESSION['COUPON_FAILED'][$objModule->id] = sprintf($GLOBALS['TL_LANG']['MSC']['couponDuplicate'], $strCoupon); } else { $arrCoupons[] = $objRule->code; Isotope::getCart()->coupons = serialize($arrCoupons); Isotope::getCart()->save(); $_SESSION['COUPON_SUCCESS'][$objModule->id] = sprintf($GLOBALS['TL_LANG']['MSC']['couponApplied'], $objRule->code); } } \Controller::redirect(preg_replace('@[?&]coupon(_[0-9]+)?=[^&]*@', '', \Environment::get('request'))); } $objRules = Rule::findForCartWithCoupons(); if (null === $objRules) { return ''; } //build template $objTemplate = new \Isotope\Template('iso_coupons'); $objTemplate->id = $objModule->id; $objTemplate->action = \Environment::get('request'); $objTemplate->headline = $GLOBALS['TL_LANG']['MSC']['couponHeadline']; $objTemplate->inputLabel = $GLOBALS['TL_LANG']['MSC']['couponLabel']; $objTemplate->sLabel = $GLOBALS['TL_LANG']['MSC']['couponApply']; $objTemplate->usedCoupons = $arrCoupons; $objTemplate->rules = $objRules; if ($_SESSION['COUPON_FAILED'][$objModule->id] != '') { $objTemplate->message = $_SESSION['COUPON_FAILED'][$objModule->id]; $objTemplate->mclass = 'failed'; unset($_SESSION['COUPON_FAILED']); } elseif ($_SESSION['COUPON_SUCCESS'][$objModule->id] != '') { $objTemplate->message = $_SESSION['COUPON_SUCCESS'][$objModule->id]; $objTemplate->mclass = 'success'; unset($_SESSION['COUPON_SUCCESS']); } return $objTemplate->parse(); }
/** * HTML form for checkout * * @param IsotopeProductCollection|Order $objOrder The order being places * @param \Module|Checkout $objModule The checkout module instance * * @return mixed */ public function checkoutForm(IsotopeProductCollection $objOrder, \Module $objModule) { $i = 0; $arrData = array('aid' => $this->payone_aid, 'portalid' => $this->payone_portalid, 'mode' => $this->debug ? 'test' : 'live', 'request' => $this->trans_type == 'auth' ? 'preauthorization' : 'authorization', 'encoding' => 'UTF-8', 'clearingtype' => $this->payone_clearingtype, 'reference' => $objOrder->id, 'display_name' => 'no', 'display_address' => 'no', 'successurl' => \Environment::get('base') . $objModule->generateUrlForStep('complete', $objOrder), 'backurl' => \Environment::get('base') . $objModule->generateUrlForStep('failed'), 'amount' => $objOrder->getTotal() * 100, 'currency' => $objOrder->currency, 'param' => 'paymentMethodPayone' . $this->id); foreach ($objOrder->getItems() as $objItem) { // Set the active product for insert tags replacement if ($objItem->hasProduct()) { Product::setActive($objItem->getProduct()); } $strConfig = ''; $arrConfig = $objItem->getConfiguration(); if (!empty($arrConfig)) { array_walk($arrConfig, function (&$option) { $option = $option['label'] . ': ' . (string) $option; }); $strConfig = ' (' . implode(', ', $arrConfig) . ')'; } $arrData['id[' . ++$i . ']'] = $objItem->getSku(); $arrData['pr[' . $i . ']'] = round($objItem->getPrice(), 2) * 100; $arrData['no[' . $i . ']'] = $objItem->quantity; $arrData['de[' . $i . ']'] = specialchars(\StringUtil::restoreBasicEntities($objItem->getName() . $strConfig), true); } foreach ($objOrder->getSurcharges() as $k => $objSurcharge) { if (!$objSurcharge->addToTotal) { continue; } $arrData['id[' . ++$i . ']'] = 'surcharge' . $k; $arrData['pr[' . $i . ']'] = $objSurcharge->total_price * 100; $arrData['no[' . $i . ']'] = '1'; $arrData['de[' . $i . ']'] = $objSurcharge->label; } ksort($arrData); // Do not urlencode values because Payone does not properly decode POST values (whatever...) $strHash = md5(implode('', $arrData) . $this->payone_key); $objTemplate = new \Isotope\Template('iso_payment_payone'); $objTemplate->id = $this->id; $objTemplate->data = $arrData; $objTemplate->hash = $strHash; $objTemplate->billing_address = $objOrder->getBillingAddress()->row(); $objTemplate->headline = specialchars($GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][0]); $objTemplate->message = specialchars($GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][1]); $objTemplate->slabel = specialchars($GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][2]); $objTemplate->noscript = specialchars($GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][3]); return $objTemplate->parse(); }
/** * Generate and return document template * @return string */ protected function generateTemplate(IsotopeProductCollection $objCollection, array $arrTokens) { $objTemplate = new \Isotope\Template($this->documentTpl); $objTemplate->setData($this->arrData); $objTemplate->title = \String::parseSimpleTokens($this->documentTitle, $arrTokens); $objTemplate->collection = $objCollection; // Render the collection $objCollectionTemplate = new \Isotope\Template($this->collectionTpl); $objCollection->addToTemplate($objCollectionTemplate, array('gallery' => $this->gallery, 'sorting' => $objCollection->getItemsSortingCallable($this->orderCollectionBy))); $objTemplate->products = $objCollectionTemplate->parse(); // Generate template and fix PDF issues, see Contao's ModuleArticle $strBuffer = Haste::getInstance()->call('replaceInsertTags', array($objTemplate->parse(), false)); $strBuffer = html_entity_decode($strBuffer, ENT_QUOTES, $GLOBALS['TL_CONFIG']['characterSet']); $strBuffer = \Controller::convertRelativeUrls($strBuffer, '', true); // Remove form elements and JavaScript links $arrSearch = array('@<form.*</form>@Us', '@<a [^>]*href="[^"]*javascript:[^>]+>.*</a>@Us'); $strBuffer = preg_replace($arrSearch, '', $strBuffer); // URL decode image paths (see contao/core#6411) // Make image paths absolute $strBuffer = preg_replace_callback('@(src=")([^"]+)(")@', function ($args) { if (preg_match('@^(http://|https://)@', $args[2])) { return $args[2]; } return $args[1] . TL_ROOT . '/' . rawurldecode($args[2]) . $args[3]; }, $strBuffer); // Handle line breaks in preformatted text $strBuffer = preg_replace_callback('@(<pre.*</pre>)@Us', 'nl2br_callback', $strBuffer); // Default PDF export using TCPDF $arrSearch = array('@<span style="text-decoration: ?underline;?">(.*)</span>@Us', '@(<img[^>]+>)@', '@(<div[^>]+block[^>]+>)@', '@[\\n\\r\\t]+@', '@<br( /)?><div class="mod_article@', '@href="([^"]+)(pdf=[0-9]*(&|&)?)([^"]*)"@'); $arrReplace = array('<u>$1</u>', '<br>$1', '<br>$1', ' ', '<div class="mod_article', 'href="$1$4"'); $strBuffer = preg_replace($arrSearch, $arrReplace, $strBuffer); return $strBuffer; }
/** * Generate main image and return it as HTML string * @return string */ public function generateMainImage() { if (!count($this->arrFiles)) { return ''; } $arrFile = reset($this->arrFiles); $objTemplate = new \Isotope\Template($this->strTemplate); $this->addImageToTemplate($objTemplate, 'main', $arrFile); $objTemplate->javascript = ''; if (\Environment::get('isAjaxRequest')) { $strScripts = ''; $arrTemplates = deserialize($this->lightbox_template); if (!empty($arrTemplates) && is_array($arrTemplates)) { foreach ($arrTemplates as $strTemplate) { $objScript = new \Isotope\Template($strTemplate); $strScripts .= $objScript->parse(); } } $objTemplate->javascript = $strScripts; } return $objTemplate->parse(); }
/** * HTML form for checkout * @param object * @param object * @return string */ public function checkoutForm(IsotopeProductCollection $objOrder, \Module $objModule) { $strPrice = number_format(round($objOrder->getTotal(), 2), 2, '.', ''); $objTemplate = new \Isotope\Template('iso_payment_transferujpl'); $objTemplate->setData($this->arrData); $objTemplate->id = $this->id; $objTemplate->order_id = $objOrder->id; $objTemplate->amount = $strPrice; $objTemplate->products = specialchars(sprintf($GLOBALS['TL_LANG']['MSC']['transferujpl_order'], $objOrder->uniqid)); $objTemplate->hash = md5($this->transferujpl_id . $strPrice . $objOrder->id . $this->transferujpl_code); $objTemplate->postsaleUrl = \Environment::get('base') . 'system/modules/isotope/postsale.php?mod=pay&id=' . $this->id; $objTemplate->successUrl = \Environment::get('base') . $objModule->generateUrlForStep('complete', $objOrder); $objTemplate->errorUrl = \Environment::get('base') . $objModule->generateUrlForStep('failed'); $objTemplate->language = $GLOBALS['TL_LANGUAGE']; $objTemplate->address = $objOrder->getBillingAddress(); $objTemplate->headline = $GLOBALS['TL_LANG']['MSC']['pay_with_transferujpl'][0]; $objTemplate->message = $GLOBALS['TL_LANG']['MSC']['pay_with_transferujpl'][1]; $objTemplate->slabel = specialchars($GLOBALS['TL_LANG']['MSC']['pay_with_transferujpl'][2]); return $objTemplate->parse(); }
/** * 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'; $objTemplate->headline = specialchars($GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][0]); $objTemplate->message = specialchars($GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][1]); $objTemplate->slabel = specialchars($GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][2]); $objTemplate->noscript = specialchars($GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][3]); return $objTemplate->parse(); }
/** * Generate download attributes * @param IsotopeProduct * @return string */ public function generate(IsotopeProduct $objProduct, array $arrOptions = array()) { global $objPage; $arrFiles = deserialize($objProduct->{$this->field_name}); // Return if there are no files if (empty($arrFiles) || !is_array($arrFiles)) { return ''; } // Get the file entries from the database $objFiles = \FilesModel::findMultipleByIds($arrFiles); if (null === $objFiles) { return ''; } $file = \Input::get('file', true); // Send the file to the browser and do not send a 404 header (see #4632) if ($file != '' && !preg_match('/^meta(_[a-z]{2})?\\.txt$/', basename($file))) { while ($objFiles->next()) { if ($file == $objFiles->path || dirname($file) == $objFiles->path) { \Controller::sendFileToBrowser($file); } } $objFiles->reset(); } $files = array(); $auxDate = array(); $allowedDownload = trimsplit(',', strtolower($GLOBALS['TL_CONFIG']['allowedDownload'])); // Get all files while ($objFiles->next()) { // Continue if the files has been processed or does not exist if (isset($files[$objFiles->path]) || !file_exists(TL_ROOT . '/' . $objFiles->path)) { continue; } // Single files if ($objFiles->type == 'file') { $objFile = new \File($objFiles->path, true); if (!in_array($objFile->extension, $allowedDownload) || preg_match('/^meta(_[a-z]{2})?\\.txt$/', $objFile->basename)) { continue; } $arrMeta = \Frontend::getMetaData($objFiles->meta, $objPage->language); // Use the file name as title if none is given if ($arrMeta['title'] == '') { $arrMeta['title'] = specialchars(str_replace('_', ' ', preg_replace('/^[0-9]+_/', '', $objFile->filename))); } $strHref = \Environment::get('request'); // Remove an existing file parameter (see #5683) if (preg_match('/(&(amp;)?|\\?)file=/', $strHref)) { $strHref = preg_replace('/(&(amp;)?|\\?)file=[^&]+/', '', $strHref); } $strHref .= ($GLOBALS['TL_CONFIG']['disableAlias'] || strpos($strHref, '?') !== false ? '&' : '?') . 'file=' . \System::urlEncode($objFiles->path); // Add the image $files[$objFiles->path] = array('id' => $objFiles->id, 'uuid' => $objFiles->uuid, 'name' => $objFile->basename, 'title' => $arrMeta['title'], 'link' => $arrMeta['title'], 'caption' => $arrMeta['caption'], 'href' => $strHref, 'filesize' => \System::getReadableSize($objFile->filesize, 1), 'icon' => TL_ASSETS_URL . 'assets/contao/images/' . $objFile->icon, 'mime' => $objFile->mime, 'meta' => $arrMeta, 'extension' => $objFile->extension, 'path' => $objFile->dirname); $auxDate[] = $objFile->mtime; } else { $objSubfiles = \FilesModel::findByPid($objFiles->id); if ($objSubfiles === null) { continue; } while ($objSubfiles->next()) { // Skip subfolders if ($objSubfiles->type == 'folder') { continue; } $objFile = new \File($objSubfiles->path, true); if (!in_array($objFile->extension, $allowedDownload) || preg_match('/^meta(_[a-z]{2})?\\.txt$/', $objFile->basename)) { continue; } $arrMeta = \Frontend::getMetaData($objSubfiles->meta, $objPage->language); // Use the file name as title if none is given if ($arrMeta['title'] == '') { $arrMeta['title'] = specialchars(str_replace('_', ' ', preg_replace('/^[0-9]+_/', '', $objFile->filename))); } $strHref = \Environment::get('request'); // Remove an existing file parameter (see #5683) if (preg_match('/(&(amp;)?|\\?)file=/', $strHref)) { $strHref = preg_replace('/(&(amp;)?|\\?)file=[^&]+/', '', $strHref); } $strHref .= ($GLOBALS['TL_CONFIG']['disableAlias'] || strpos($strHref, '?') !== false ? '&' : '?') . 'file=' . \System::urlEncode($objSubfiles->path); // Add the image $files[$objSubfiles->path] = array('id' => $objSubfiles->id, 'uuid' => $objSubfiles->uuid, 'name' => $objFile->basename, 'title' => $arrMeta['title'], 'link' => $arrMeta['title'], 'caption' => $arrMeta['caption'], 'href' => $strHref, 'filesize' => \System::getReadableSize($objFile->filesize, 1), 'icon' => TL_ASSETS_URL . 'assets/contao/images/' . $objFile->icon, 'mime' => $objFile->mime, 'meta' => $arrMeta, 'extension' => $objFile->extension, 'path' => $objFile->dirname); $auxDate[] = $objFile->mtime; } } } // Sort array $sortBy = $arrOptions['sortBy'] ?: $this->sortBy; switch ($sortBy) { default: case 'name_asc': uksort($files, 'basename_natcasecmp'); break; case 'name_desc': uksort($files, 'basename_natcasercmp'); break; case 'date_asc': array_multisort($files, SORT_NUMERIC, $auxDate, SORT_ASC); break; case 'date_desc': array_multisort($files, SORT_NUMERIC, $auxDate, SORT_DESC); break; case 'custom': if ($objProduct->{$this->field_name . '_order'} != '') { $tmp = deserialize($objProduct->{$this->field_name . '_order'}); if (!empty($tmp) && is_array($tmp)) { // Remove all values $arrOrder = array_map(function () { }, array_flip($tmp)); // Move the matching elements to their position in $arrOrder foreach ($files as $k => $v) { if (array_key_exists($v['uuid'], $arrOrder)) { $arrOrder[$v['uuid']] = $v; unset($files[$k]); } } // Append the left-over files at the end if (!empty($files)) { $arrOrder = array_merge($arrOrder, array_values($files)); } // Remove empty (unreplaced) entries $files = array_values(array_filter($arrOrder)); unset($arrOrder); } } break; case 'random': shuffle($files); break; } $objTemplate = new \Isotope\Template('ce_downloads'); $objTemplate->class = $this->field_name; $objTemplate->files = array_values($files); return $objTemplate->parse(); }
/** * 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) { $arrParams = $this->preparePSPParams($objOrder, $objModule); // SHA-1 must be generated on alphabetically sorted keys. // Use the natural order algorithm so ITEM10 gets listed after ITEM2 // We can only use ksort($arrParams, SORT_NATURAL) as of PHP 5.4 uksort($arrParams, 'strnatcasecmp'); $strSHASign = ''; foreach ($arrParams as $k => $v) { if ($v == '') { continue; } $strSHASign .= $k . '=' . htmlspecialchars_decode($v) . $this->psp_hash_in; } $arrParams['SHASIGN'] = strtoupper(hash($this->psp_hash_method, $strSHASign)); $objTemplate = new \Isotope\Template($this->strTemplate); $objTemplate->setData($this->arrData); $objTemplate->params = $arrParams; $objTemplate->headline = $GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][0]; $objTemplate->message = $GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][1]; $objTemplate->slabel = $GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][2]; return $objTemplate->parse(); }