/** * Recursively replace simple tokens and insert tags * @param string $strText * @param array $arrTokens Array of Tokens * @param int $intTextFlags Filters the tokens and the text for a given set of options * * @return string */ public static function recursiveReplaceTokensAndTags($strText, $arrTokens, $intTextFlags = 0) { if ($intTextFlags > 0) { $arrTokens = static::convertToText($arrTokens, $intTextFlags); } // Must decode, tokens could be encoded $strText = \String::decodeEntities($strText); // Replace all opening and closing tags with a hash so they don't get stripped // by parseSimpleTokens() - this is useful e.g. for XML content $strHash = md5($strText); $strTagOpenReplacement = 'NC-TAG-OPEN-' . $strHash; $strTagCloseReplacement = 'NC-TAG-CLOSE-' . $strHash; $arrOriginal = array('<', '>'); $arrReplacement = array($strTagOpenReplacement, $strTagCloseReplacement); $strText = str_replace($arrOriginal, $arrReplacement, $strText); // first parse the tokens as they might have if-else clauses $strBuffer = \String::parseSimpleTokens($strText, $arrTokens); $strBuffer = str_replace($arrReplacement, $arrOriginal, $strBuffer); // then replace the insert tags $strBuffer = \Haste\Haste::getInstance()->call('replaceInsertTags', array($strBuffer, false)); // check if the inserttags have returned a simple token or an insert tag to parse if ((strpos($strBuffer, '##') !== false || strpos($strBuffer, '{{') !== false) && $strBuffer != $strText) { $strBuffer = static::recursiveReplaceTokensAndTags($strBuffer, $arrTokens, $intTextFlags); } $strBuffer = \String::restoreBasicEntities($strBuffer); if ($intTextFlags > 0) { $strBuffer = static::convertToText($strBuffer, $intTextFlags); } return $strBuffer; }
/** * Recursively replace simple tokens and insert tags * * @param string $strText * @param array $arrTokens Array of Tokens * * @return string */ public static function recursiveReplaceTokensAndTags($text, $tokens) { // Must decode, tokens could be encoded $text = \String::decodeEntities($text); // Replace all opening and closing tags with a hash so they don't get stripped // by parseSimpleTokens() $hash = md5($text); $openTagReplacement = 'LEADS-TAG-OPEN-' . $hash; $closeTagReplacement = 'LEADS-TAG-CLOSE-' . $hash; $original = array('<', '>'); $replacement = array($openTagReplacement, $closeTagReplacement); $text = str_replace($original, $replacement, $text); // first parse the tokens as they might have if-else clauses $buffer = \String::parseSimpleTokens($text, $tokens); // Restore tags $buffer = str_replace($replacement, $original, $buffer); // Replace the Insert Tags $buffer = \Haste\Haste::getInstance()->call('replaceInsertTags', array($buffer, false)); // Check if the Insert Tags have returned a Simple Token or an Insert Tag to parse if ((strpos($buffer, '##') !== false || strpos($buffer, '{{') !== false) && $buffer != $text) { $buffer = static::recursiveReplaceTokensAndTags($buffer, $tokens); } $buffer = \String::restoreBasicEntities($buffer); return $buffer; }
/** * @param RecipientInterface $recipient * @param array $additionalData * * @return string * @SuppressWarnings(PHPMD.Superglobals) * @SuppressWarnings(PHPMD.LongVariable) */ protected function parseContent(RecipientInterface $recipient, array $additionalData = array()) { /** @var EventDispatcher $eventDispatcher */ $eventDispatcher = $GLOBALS['container']['event-dispatcher']; $content = $this->getContent(); // dispatch a pre render event $event = new PreRenderMessageContentEvent($this->message, $this, $recipient, $additionalData, $content); $eventDispatcher->dispatch(AvisotaMessageEvents::PRE_RENDER_MESSAGE_CONTENT, $event); $content = $event->getContent(); if (is_string($content)) { $additionalData['message'] = $this->message; if (!isset($additionalData['recipient'])) { /** @var SynonymizerService $synonymizer */ $synonymizer = $GLOBALS['container']['avisota.recipient.synonymizer']; $additionalData['recipient'] = $synonymizer->expandDetailsWithSynonyms($recipient); } $additionalData['_recipient'] = $recipient; /** @var TagReplacementService $tagReplacementService */ $tagReplacementService = $GLOBALS['container']['avisota.message.tagReplacementEngine']; $content = $tagReplacementService->parse($content, $additionalData); $content = \String::restoreBasicEntities($content); } // dispatch a post render event $event = new PostRenderMessageContentEvent($this->message, $this, $recipient, $additionalData, $content); $eventDispatcher->dispatch(AvisotaMessageEvents::POST_RENDER_MESSAGE_CONTENT, $event); return $event->getContent(); }
/** * Replaces all "forbidden" characters in the given filename * * @param string $strFile * * @return string */ protected function replaceForbiddenCharacters($strFile) { $info = pathinfo($strFile); $newFilename = substr($info['filename'], 0, 32); $newFilename = standardize(\String::restoreBasicEntities($newFilename)); $newFilename = $this->replaceUnderscores($newFilename); return $info['dirname'] . '/' . $newFilename . '.' . strtolower($info['extension']); }
public function rename($varValue) { if (!$GLOBALS['TL_CONFIG']['checkFilenames']) { return $varValue; } $varValue = standardize(\String::restoreBasicEntities($varValue)); return $varValue; }
public function generateAlias($varValue, $objItem) { $t = static::$strTable; $varValue = standardize(\String::restoreBasicEntities($varValue)); $objAlias = \Database::getInstance()->prepare("SELECT id FROM {$t} WHERE alias=? AND id != ?")->execute($varValue, $objItem->id); // Add ID to alias if ($objAlias->numRows > 0) { $varValue .= '-' . $objItem->id; } return $varValue; }
public function generateAlias($varValue, DataContainer $dc) { // Generate an alias if there is none if ($varValue == '') { $varValue = standardize(String::restoreBasicEntities($dc->activeRecord->label)); } $objAlias = $this->Database->prepare("SELECT id FROM tl_metafields WHERE id=? OR alias=?")->execute($dc->id, $varValue); // Check whether the alias exists if ($objAlias->numRows > 1) { throw new Exception(sprintf($GLOBALS['TL_LANG']['ERR']['aliasExists'], $varValue)); } return $varValue; }
public function generateAlias() { $varValue = standardize(\String::restoreBasicEntities($this->title)); $objAlias = static::findBy('alias', $varValue); // Check whether the alias exists if ($objAlias !== null) { if (!$this->id) { return $this; } $varValue .= '-' . $this->id; } $this->alias = $varValue; return $this; }
/** * Recursively replace simple tokens and insert tags * * @param string $strText * @param array $arrTokens Array of Tokens * @param int $intTextFlags Filters the tokens and the text for a given set of options * * @return string */ public static function recursiveReplaceTokensAndTags($strText, $arrTokens, $intTextFlags = 0) { if ($intTextFlags > 0) { $arrTokens = static::convertToText($arrTokens, $intTextFlags); } // PHP 7 compatibility // See #309 (https://github.com/contao/core-bundle/issues/309) if (version_compare(VERSION . '.' . BUILD, '3.5.1', '>=')) { // Must decode, tokens could be encoded $strText = \StringUtil::decodeEntities($strText); } else { // Must decode, tokens could be encoded $strText = \String::decodeEntities($strText); } // Replace all opening and closing tags with a hash so they don't get stripped // by parseSimpleTokens() - this is useful e.g. for XML content $strHash = md5($strText); $strTagOpenReplacement = 'HASTE-TAG-OPEN-' . $strHash; $strTagCloseReplacement = 'HASTE-TAG-CLOSE-' . $strHash; $arrOriginal = array('<', '>'); $arrReplacement = array($strTagOpenReplacement, $strTagCloseReplacement); $strBuffer = str_replace($arrOriginal, $arrReplacement, $strText); // PHP 7 compatibility // See #309 (https://github.com/contao/core-bundle/issues/309) if (version_compare(VERSION . '.' . BUILD, '3.5.1', '>=')) { // first parse the tokens as they might have if-else clauses $strBuffer = \StringUtil::parseSimpleTokens($strBuffer, $arrTokens); } else { // first parse the tokens as they might have if-else clauses $strBuffer = \String::parseSimpleTokens($strBuffer, $arrTokens); } $strBuffer = str_replace($arrReplacement, $arrOriginal, $strBuffer); // then replace the insert tags $strBuffer = \Controller::replaceInsertTags($strBuffer, false); // check if the inserttags have returned a simple token or an insert tag to parse if ((strpos($strBuffer, '##') !== false || strpos($strBuffer, '{{') !== false) && $strBuffer != $strText) { $strBuffer = static::recursiveReplaceTokensAndTags($strBuffer, $arrTokens, $intTextFlags); } // PHP 7 compatibility // See #309 (https://github.com/contao/core-bundle/issues/309) if (version_compare(VERSION . '.' . BUILD, '3.5.1', '>=')) { $strBuffer = \StringUtil::restoreBasicEntities($strBuffer); } else { $strBuffer = \String::restoreBasicEntities($strBuffer); } if ($intTextFlags > 0) { $strBuffer = static::convertToText($strBuffer, $intTextFlags); } return $strBuffer; }
/** * HTML form for checkout * @param IsotopeProductCollection The order being places * @param Module 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(\String::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(); }
/** * Auto-generate the cookie name */ public function generateCookiesName($varValue, DataContainer $dc) { $autoAlias = false; // Generate alias if there is none if ($varValue == '') { $autoAlias = true; $varValue = standardize(String::restoreBasicEntities('tabControllCookie-' . $dc->activeRecord->id)); } $objAlias = $this->Database->prepare("SELECT id FROM tl_content WHERE tabControlCookies=?")->execute($varValue); // Check whether the cookies name alias exists if ($objAlias->numRows > 1 && !$autoAlias) { throw new Exception(sprintf($GLOBALS['TL_LANG']['ERR']['aliasExists'], $varValue)); } // Add ID to cookies name if ($objAlias->numRows && $autoAlias) { $varValue .= '-' . $dc->id; } return $varValue; }
/** * Prepare FIS params * @param Order * @return array */ private function prepareFISParams($objOrder) { $objBillingAddress = $objOrder->getBillingAddress(); $objShippingAddress = $objOrder->getShippingAddress(); $arrInvoice = array('ECOM_BILLTO_POSTAL_NAME_FIRST' => substr($objBillingAddress->firstname, 0, 50), 'ECOM_BILLTO_POSTAL_NAME_LAST' => substr($objBillingAddress->lastname, 0, 50), 'ECOM_SHIPTO_POSTAL_STREET_LINE1' => $objShippingAddress->street_1, 'ECOM_SHIPTO_POSTAL_POSTALCODE' => $objShippingAddress->postal, 'ECOM_SHIPTO_POSTAL_CITY' => $objShippingAddress->city, 'ECOM_SHIPTO_POSTAL_COUNTRYCODE' => strtoupper($objShippingAddress->country), 'ECOM_SHIPTO_DOB' => date('d/m/Y', $objShippingAddress->dateOfBirth), 'REF_CUSTOMERID' => substr('psp_' . $this->id . '_' . $objOrder->id . '_' . $objOrder->uniqid, 0, 17), 'ECOM_CONSUMER_GENDER' => $objBillingAddress->gender == 'male' ? 'M' : 'F'); $arrOrder = array(); $i = 1; // Need to take the items from the cart as they're not transferred to the order here yet // @todo this is no longer true, and the price should probably be taken from the collection item ($objItem->getPrice()) foreach (Isotope::getCart()->getItems() as $objItem) { $objPrice = $objItem->getProduct()->getPrice(); $fltVat = Isotope::roundPrice(100 / $objPrice->getNetAmount() * $objPrice->getGrossAmount() - 100, false); $arrOrder['ITEMID' . $i] = $objItem->id; $arrOrder['ITEMNAME' . $i] = substr(\String::restoreBasicEntities($objItem->getName()), 40); $arrOrder['ITEMPRICE' . $i] = $objPrice->getNetAmount(); $arrOrder['ITEMQUANT' . $i] = $objItem->quantity; $arrOrder['ITEMVATCODE' . $i] = $fltVat . '%'; $arrOrder['ITEMVAT' . $i] = Isotope::roundPrice($objPrice->getGrossAmount() - $objPrice->getNetAmount(), false); $arrOrder['FACEXCL' . $i] = $objPrice->getNetAmount(); $arrOrder['FACTOTAL' . $i] = $objPrice->getGrossAmount(); ++$i; } return array_merge($arrInvoice, $arrOrder); }
/** * Auto-generate an article alias if it has not been set yet * @param mixed * @param \DataContainer * @return string * @throws \Exception */ public function generateAlias($varValue, DataContainer $dc) { $autoAlias = false; // Generate an alias if there is none if ($varValue == '') { $autoAlias = true; //@todo make configureable for each category in dca category $varValue = $dc->activeRecord->name . '-' . $dc->activeRecord->postal . '-' . $dc->activeRecord->city; $varValue = standardize(String::restoreBasicEntities($varValue)); } $objAlias = $this->Database->prepare("SELECT id FROM tl_anystores WHERE id=? OR alias=?")->execute($dc->id, $varValue); // Check whether the page alias exists if ($objAlias->numRows > 1) { if (!$autoAlias) { throw new Exception(sprintf($GLOBALS['TL_LANG']['ERR']['aliasExists'], $varValue)); } $varValue = $dc->id . '-' . $varValue; } return $varValue; }
protected static function addCopyrightToTemplate(&$objTemplate, $objFilesModel, $objModule) { $arrCopyright = deserialize($objFilesModel->copyright, true); $arrList = array(); foreach ($arrCopyright as $strCopyright) { $strCopyright = \StringUtil::decodeEntities(\String::restoreBasicEntities($strCopyright)); if ($objModule->creditsPrefix != '') { $strPrefix = \StringUtil::decodeEntities(\String::restoreBasicEntities($objModule->creditsPrefix)); if (!($strPrefix === "" || strrpos($strCopyright, $strPrefix, -strlen($strCopyright)) !== false)) { $strCopyright = $strPrefix . trim(ltrim($strCopyright, $strPrefix)); } } $arrList[] = $strCopyright; } $objTemplate->copyright = implode(', ', $arrList); }
/** * Save the current value * @param mixed */ protected function save($varValue) { if (\Input::post('FORM_SUBMIT') != $this->strTable) { return; } $arrData = $GLOBALS['TL_DCA'][$this->strTable]['fields'][$this->strField]; // Make sure that checkbox values are boolean if ($arrData['inputType'] == 'checkbox' && !$arrData['eval']['multiple']) { $varValue = $varValue ? true : false; } // Convert date formats into timestamps if ($varValue != '' && in_array($arrData['eval']['rgxp'], array('date', 'time', 'datim'))) { $objDate = new \Date($varValue, $GLOBALS['TL_CONFIG'][$arrData['eval']['rgxp'] . 'Format']); $varValue = $objDate->tstamp; } // Handle entities if ($arrData['inputType'] == 'text' || $arrData['inputType'] == 'textarea') { $varValue = deserialize($varValue); if (!is_array($varValue)) { $varValue = \String::restoreBasicEntities($varValue); } else { foreach ($varValue as $k => $v) { $varValue[$k] = \String::restoreBasicEntities($v); } $varValue = serialize($varValue); } } // Trigger the save_callback if (is_array($arrData['save_callback'])) { foreach ($arrData['save_callback'] as $callback) { $this->import($callback[0]); $varValue = $this->{$callback}[0]->{$callback}[1]($varValue, $this); } } $strCurrent = $this->varValue; // Handle arrays and strings if (is_array($strCurrent)) { $strCurrent = serialize($strCurrent); } elseif (is_string($strCurrent)) { $strCurrent = html_entity_decode($this->varValue, ENT_QUOTES, $GLOBALS['TL_CONFIG']['characterSet']); } // Save the value if there was no error if ((strlen($varValue) || !$arrData['eval']['doNotSaveEmpty']) && $strCurrent != $varValue) { $strKey = sprintf("\$GLOBALS['TL_CONFIG']['%s']", $this->strField); $this->Config->update($strKey, $varValue); $deserialize = deserialize($varValue); $prior = is_bool($GLOBALS['TL_CONFIG'][$this->strField]) ? $GLOBALS['TL_CONFIG'][$this->strField] ? 'true' : 'false' : $GLOBALS['TL_CONFIG'][$this->strField]; // Add a log entry if (!is_array(deserialize($prior)) && !is_array($deserialize)) { if ($arrData['inputType'] == 'password' || $arrData['inputType'] == 'textStore') { $this->log('The global configuration variable "' . $this->strField . '" has been changed', 'DC_File save()', TL_CONFIGURATION); } else { $this->log('The global configuration variable "' . $this->strField . '" has been changed from "' . $prior . '" to "' . $varValue . '"', 'DC_File save()', TL_CONFIGURATION); } } // Set the new value so the input field can show it $this->varValue = $deserialize; $GLOBALS['TL_CONFIG'][$this->strField] = $deserialize; } }
/** * Auto-generate the news alias if it has not been set yet * @param mixed * @param \DataContainer * @return string * @throws \Exception */ public function generateAlias($varValue, \DataContainer $dc) { $autoAlias = false; // Generate alias if there is none if ($varValue == '') { $autoAlias = true; $varValue = standardize(\String::restoreBasicEntities($dc->activeRecord->name)); } $objAlias = $this->Database->prepare("SELECT id FROM tl_dps_placeholder WHERE alias=?")->execute($varValue); // Check whether the placeholder alias exists if ($objAlias->numRows > 1 && !$autoAlias) { throw new \Exception(sprintf($GLOBALS['TL_LANG']['ERR']['aliasExists'], $varValue)); } // Add ID to alias if ($objAlias->numRows && $autoAlias) { $varValue .= '-' . $dc->id; } return $varValue; }
if ($objCte === null) { return; } switch ($objCte->type) { case 'juiTabStart': case 'juiTabSeparator': case 'juiTabStop': Message::addInfo(sprintf($GLOBALS['TL_LANG']['tl_content']['includeTemplate'], 'j_ui_tabs')); break; } }; /* * Palettes */ $GLOBALS['TL_DCA']['tl_content']['palettes']['__selector__'][] = 'juiTabShowDropdown'; array_insert($GLOBALS['TL_DCA']['tl_content']['palettes'], 0, array('juiTabStart' => '{type_legend},type;{juiTab_legend},juiTabHeadline,juiTabAlias,juiTabShowDropdown;{template_legend:hide},customTpl;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space;{invisible_legend:hide},invisible,start,stop', 'juiTabSeparator' => '{type_legend},type;{juiTab_legend},juiTabHeadline,juiTabAlias;{template_legend:hide},customTpl;{protected_legend:hide},protected;{expert_legend:hide},guests;{invisible_legend:hide},invisible,start,stop', 'juiTabStop' => '{type_legend},type;{template_legend:hide},customTpl;{protected_legend:hide},protected;{expert_legend:hide},guests;{invisible_legend:hide},invisible,start,stop')); /* * Subpalettes */ $GLOBALS['TL_DCA']['tl_content']['subpalettes']['juiTabShowDropdown'] = 'juiTabDropdownLabel'; /* * Fields */ array_insert($GLOBALS['TL_DCA']['tl_content']['fields'], 0, array('juiTabHeadline' => array('label' => &$GLOBALS['TL_LANG']['tl_content']['juiTabHeadline'], 'exclude' => true, 'inputType' => 'inputUnit', 'options' => array('h1', 'h2', 'h3', 'h4', 'h5', 'h6'), 'eval' => array('maxlength' => 255, 'allowHtml' => true, 'mandatory' => true, 'tl_class' => 'w50'), 'sql' => "varchar(255) NOT NULL default ''"), 'juiTabAlias' => array('label' => &$GLOBALS['TL_LANG']['tl_content']['juiTabAlias'], 'exclude' => true, 'inputType' => 'text', 'eval' => array('rgxp' => 'alias', 'maxlength' => 128, 'tl_class' => 'w50'), 'save_callback' => array(function ($varValue, DataContainer $dc) { if ($varValue == '') { $arrHeadline = deserialize($dc->activeRecord->juiTabHeadline); $varValue = standardize(String::restoreBasicEntities($arrHeadline['value'])); $varValue = preg_replace('/^id-/', '', $varValue); } return $varValue; }), 'sql' => "varchar(128) NOT NULL default ''"), 'juiTabShowDropdown' => array('label' => &$GLOBALS['TL_LANG']['tl_content']['juiTabShowDropdown'], 'exclude' => true, 'inputType' => 'checkbox', 'eval' => array('submitOnChange' => true, 'tl_class' => 'w50 m12'), 'sql' => "char(1) NOT NULL default ''"), 'juiTabDropdownLabel' => array('label' => &$GLOBALS['TL_LANG']['tl_content']['juiTabDropdownLabel'], 'exclude' => true, 'inputType' => 'text', 'eval' => array('maxlength' => 256, 'allowHtml' => true, 'tl_class' => 'w50'), 'sql' => "varchar(256) NOT NULL default ''")));
/** * Replace insert tags with their values * * @param string $strBuffer The text with the tags to be replaced * @param boolean $blnCache If false, non-cacheable tags will be replaced * * @return string The text with the replaced tags */ public function replace($strBuffer, $blnCache = true) { /** @var \PageModel $objPage */ global $objPage; // Preserve insert tags if (\Config::get('disableInsertTags')) { return \String::restoreBasicEntities($strBuffer); } $tags = preg_split('/\\{\\{(([^\\{\\}]*|(?R))*)\\}\\}/', $strBuffer, -1, PREG_SPLIT_DELIM_CAPTURE); $strBuffer = ''; // Create one cache per cache setting (see #7700) static $arrItCache; $arrCache =& $arrItCache[$blnCache]; for ($_rit = 0, $_cnt = count($tags); $_rit < $_cnt; $_rit += 3) { $strBuffer .= $tags[$_rit]; $strTag = $tags[$_rit + 1]; // Skip empty tags if ($strTag == '') { continue; } // Run the replacement again if there are more tags (see #4402) if (strpos($strTag, '{{') !== false) { $strTag = $this->replace($strTag, $blnCache); } $flags = explode('|', $strTag); $tag = array_shift($flags); $elements = explode('::', $tag); // Load the value from cache if (isset($arrCache[$strTag]) && !in_array('refresh', $flags)) { $strBuffer .= $arrCache[$strTag]; continue; } // Skip certain elements if the output will be cached if ($blnCache) { if ($elements[0] == 'date' || $elements[0] == 'ua' || $elements[0] == 'post' || $elements[0] == 'file' || $elements[1] == 'back' || $elements[1] == 'referer' || $elements[0] == 'request_token' || $elements[0] == 'toggle_view' || strncmp($elements[0], 'cache_', 6) === 0 || in_array('uncached', $flags)) { $strBuffer .= '{{' . $strTag . '}}'; continue; } } $arrCache[$strTag] = ''; // Replace the tag switch (strtolower($elements[0])) { // Date case 'date': $arrCache[$strTag] = \Date::parse($elements[1] ?: \Config::get('dateFormat')); break; // Accessibility tags // Accessibility tags case 'lang': if ($elements[1] == '') { $arrCache[$strTag] = '</span>'; } elseif ($objPage->outputFormat == 'xhtml') { $arrCache[$strTag] = '<span lang="' . $elements[1] . '" xml:lang="' . $elements[1] . '">'; } else { $arrCache[$strTag] = $arrCache[$strTag] = '<span lang="' . $elements[1] . '">'; } break; // Line break // Line break case 'br': $arrCache[$strTag] = '<br' . ($objPage->outputFormat == 'xhtml' ? ' />' : '>'); break; // E-mail addresses // E-mail addresses case 'email': case 'email_open': case 'email_url': if ($elements[1] == '') { $arrCache[$strTag] = ''; break; } $strEmail = \String::encodeEmail($elements[1]); // Replace the tag switch (strtolower($elements[0])) { case 'email': $arrCache[$strTag] = '<a href="mailto:' . $strEmail . '" class="email">' . preg_replace('/\\?.*$/', '', $strEmail) . '</a>'; break; case 'email_open': $arrCache[$strTag] = '<a href="mailto:' . $strEmail . '" title="' . $strEmail . '" class="email">'; break; case 'email_url': $arrCache[$strTag] = $strEmail; break; } break; // Label tags // Label tags case 'label': $keys = explode(':', $elements[1]); if (count($keys) < 2) { $arrCache[$strTag] = ''; break; } $file = $keys[0]; // Map the key (see #7217) switch ($file) { case 'CNT': $file = 'countries'; break; case 'LNG': $file = 'languages'; break; case 'MOD': case 'FMD': $file = 'modules'; break; case 'FFL': $file = 'tl_form_field'; break; case 'CACHE': $file = 'tl_page'; break; case 'XPL': $file = 'explain'; break; case 'XPT': $file = 'exception'; break; case 'MSC': case 'ERR': case 'CTE': case 'PTY': case 'FOP': case 'CHMOD': case 'DAYS': case 'MONTHS': case 'UNITS': case 'CONFIRM': case 'DP': case 'COLS': $file = 'default'; break; } \System::loadLanguageFile($file); if (count($keys) == 2) { $arrCache[$strTag] = $GLOBALS['TL_LANG'][$keys[0]][$keys[1]]; } else { $arrCache[$strTag] = $GLOBALS['TL_LANG'][$keys[0]][$keys[1]][$keys[2]]; } break; // Front end user // Front end user case 'user': if (FE_USER_LOGGED_IN) { $this->import('FrontendUser', 'User'); $value = $this->User->{$elements}[1]; if ($value == '') { $arrCache[$strTag] = $value; break; } $this->loadDataContainer('tl_member'); if ($GLOBALS['TL_DCA']['tl_member']['fields'][$elements[1]]['inputType'] == 'password') { $arrCache[$strTag] = ''; break; } $value = deserialize($value); // Decrypt the value if ($GLOBALS['TL_DCA']['tl_member']['fields'][$elements[1]]['eval']['encrypt']) { $value = \Encryption::decrypt($value); } $rgxp = $GLOBALS['TL_DCA']['tl_member']['fields'][$elements[1]]['eval']['rgxp']; $opts = $GLOBALS['TL_DCA']['tl_member']['fields'][$elements[1]]['options']; $rfrc = $GLOBALS['TL_DCA']['tl_member']['fields'][$elements[1]]['reference']; if ($rgxp == 'date') { $arrCache[$strTag] = \Date::parse(\Config::get('dateFormat'), $value); } elseif ($rgxp == 'time') { $arrCache[$strTag] = \Date::parse(\Config::get('timeFormat'), $value); } elseif ($rgxp == 'datim') { $arrCache[$strTag] = \Date::parse(\Config::get('datimFormat'), $value); } elseif (is_array($value)) { $arrCache[$strTag] = implode(', ', $value); } elseif (is_array($opts) && array_is_assoc($opts)) { $arrCache[$strTag] = isset($opts[$value]) ? $opts[$value] : $value; } elseif (is_array($rfrc)) { $arrCache[$strTag] = isset($rfrc[$value]) ? is_array($rfrc[$value]) ? $rfrc[$value][0] : $rfrc[$value] : $value; } else { $arrCache[$strTag] = $value; } // Convert special characters (see #1890) $arrCache[$strTag] = specialchars($arrCache[$strTag]); } break; // Link // Link case 'link': case 'link_open': case 'link_url': case 'link_title': case 'link_target': case 'link_name': $strTarget = null; // Back link if ($elements[1] == 'back') { $strUrl = 'javascript:history.go(-1)'; $strTitle = $GLOBALS['TL_LANG']['MSC']['goBack']; // No language files if the page is cached if (!strlen($strTitle)) { $strTitle = 'Go back'; } $strName = $strTitle; } elseif (strncmp($elements[1], 'http://', 7) === 0 || strncmp($elements[1], 'https://', 8) === 0) { $strUrl = $elements[1]; $strTitle = $elements[1]; $strName = str_replace(array('http://', 'https://'), '', $elements[1]); } else { // User login page if ($elements[1] == 'login') { if (!FE_USER_LOGGED_IN) { break; } $this->import('FrontendUser', 'User'); $elements[1] = $this->User->loginPage; } $objNextPage = \PageModel::findByIdOrAlias($elements[1]); if ($objNextPage === null) { break; } // Page type specific settings (thanks to Andreas Schempp) switch ($objNextPage->type) { case 'redirect': $strUrl = $this->replaceInsertTags($objNextPage->url); // see #6765 if (strncasecmp($strUrl, 'mailto:', 7) === 0) { $strUrl = \String::encodeEmail($strUrl); } break; case 'forward': if ($objNextPage->jumpTo) { /** @var \PageModel $objNext */ $objNext = $objNextPage->getRelated('jumpTo'); } else { $objNext = \PageModel::findFirstPublishedRegularByPid($objNextPage->id); } if ($objNext !== null) { $strForceLang = null; $objNext->loadDetails(); // Check the target page language (see #4706) if (\Config::get('addLanguageToUrl')) { $strForceLang = $objNext->language; } $strUrl = $this->generateFrontendUrl($objNext->row(), null, $strForceLang, true); break; } // DO NOT ADD A break; STATEMENT // DO NOT ADD A break; STATEMENT default: $strForceLang = null; $objNextPage->loadDetails(); // Check the target page language (see #4706, #5465) if (\Config::get('addLanguageToUrl')) { $strForceLang = $objNextPage->language; } $strUrl = $this->generateFrontendUrl($objNextPage->row(), null, $strForceLang, true); break; } $strName = $objNextPage->title; $strTarget = $objNextPage->target ? $objPage->outputFormat == 'xhtml' ? LINK_NEW_WINDOW : ' target="_blank"' : ''; $strTitle = $objNextPage->pageTitle ?: $objNextPage->title; } // Replace the tag switch (strtolower($elements[0])) { case 'link': $arrCache[$strTag] = sprintf('<a href="%s" title="%s"%s>%s</a>', $strUrl, specialchars($strTitle), $strTarget, specialchars($strName)); break; case 'link_open': $arrCache[$strTag] = sprintf('<a href="%s" title="%s"%s>', $strUrl, specialchars($strTitle), $strTarget); break; case 'link_url': $arrCache[$strTag] = $strUrl; break; case 'link_title': $arrCache[$strTag] = specialchars($strTitle); break; case 'link_target': $arrCache[$strTag] = $strTarget; break; case 'link_name': $arrCache[$strTag] = specialchars($strName); break; } break; // Closing link tag // Closing link tag case 'link_close': $arrCache[$strTag] = '</a>'; break; // Insert article // Insert article case 'insert_article': if (($strOutput = $this->getArticle($elements[1], false, true)) !== false) { $arrCache[$strTag] = $this->replaceInsertTags(ltrim($strOutput), $blnCache); } else { $arrCache[$strTag] = '<p class="error">' . sprintf($GLOBALS['TL_LANG']['MSC']['invalidPage'], $elements[1]) . '</p>'; } break; // Insert content element // Insert content element case 'insert_content': $arrCache[$strTag] = $this->replaceInsertTags($this->getContentElement($elements[1]), $blnCache); break; // Insert module // Insert module case 'insert_module': $arrCache[$strTag] = $this->replaceInsertTags($this->getFrontendModule($elements[1]), $blnCache); break; // Insert form // Insert form case 'insert_form': $arrCache[$strTag] = $this->replaceInsertTags($this->getForm($elements[1]), $blnCache); break; // Article // Article case 'article': case 'article_open': case 'article_url': case 'article_title': if (($objArticle = \ArticleModel::findByIdOrAlias($elements[1])) === null || ($objPid = $objArticle->getRelated('pid')) === null) { break; } $strUrl = $this->generateFrontendUrl($objPid->row(), '/articles/' . (!\Config::get('disableAlias') && strlen($objArticle->alias) ? $objArticle->alias : $objArticle->id)); // Replace the tag switch (strtolower($elements[0])) { case 'article': $strLink = specialchars($objArticle->title); $arrCache[$strTag] = sprintf('<a href="%s" title="%s">%s</a>', $strUrl, $strLink, $strLink); break; case 'article_open': $arrCache[$strTag] = sprintf('<a href="%s" title="%s">', $strUrl, specialchars($objArticle->title)); break; case 'article_url': $arrCache[$strTag] = $strUrl; break; case 'article_title': $arrCache[$strTag] = specialchars($objArticle->title); break; } break; // FAQ // FAQ case 'faq': case 'faq_open': case 'faq_url': case 'faq_title': if (($objFaq = \FaqModel::findByIdOrAlias($elements[1])) === null || ($objPid = $objFaq->getRelated('pid')) === null || ($objJumpTo = $objPid->getRelated('jumpTo')) === null) { break; } $strUrl = $this->generateFrontendUrl($objJumpTo->row(), (\Config::get('useAutoItem') && !\Config::get('disableAlias') ? '/' : '/items/') . (!\Config::get('disableAlias') && $objFaq->alias != '' ? $objFaq->alias : $objFaq->id)); // Replace the tag switch (strtolower($elements[0])) { case 'faq': $strLink = specialchars($objFaq->question); $arrCache[$strTag] = sprintf('<a href="%s" title="%s">%s</a>', $strUrl, $strLink, $strLink); break; case 'faq_open': $arrCache[$strTag] = sprintf('<a href="%s" title="%s">', $strUrl, specialchars($objFaq->question)); break; case 'faq_url': $arrCache[$strTag] = $strUrl; break; case 'faq_title': $arrCache[$strTag] = specialchars($objFaq->question); break; } break; // News // News case 'news': case 'news_open': case 'news_url': case 'news_title': if (($objNews = \NewsModel::findByIdOrAlias($elements[1])) === null) { break; } $strUrl = ''; if ($objNews->source == 'external') { $strUrl = $objNews->url; } elseif ($objNews->source == 'internal') { if (($objJumpTo = $objNews->getRelated('jumpTo')) !== null) { $strUrl = $this->generateFrontendUrl($objJumpTo->row()); } } elseif ($objNews->source == 'article') { if (($objArticle = \ArticleModel::findByPk($objNews->articleId, array('eager' => true))) !== null && ($objPid = $objArticle->getRelated('pid')) !== null) { $strUrl = $this->generateFrontendUrl($objPid->row(), '/articles/' . (!\Config::get('disableAlias') && $objArticle->alias != '' ? $objArticle->alias : $objArticle->id)); } } else { if (($objArchive = $objNews->getRelated('pid')) !== null && ($objJumpTo = $objArchive->getRelated('jumpTo')) !== null) { $strUrl = $this->generateFrontendUrl($objJumpTo->row(), (\Config::get('useAutoItem') && !\Config::get('disableAlias') ? '/' : '/items/') . (!\Config::get('disableAlias') && $objNews->alias != '' ? $objNews->alias : $objNews->id)); } } // Replace the tag switch (strtolower($elements[0])) { case 'news': $strLink = specialchars($objNews->headline); $arrCache[$strTag] = sprintf('<a href="%s" title="%s">%s</a>', $strUrl, $strLink, $strLink); break; case 'news_open': $arrCache[$strTag] = sprintf('<a href="%s" title="%s">', $strUrl, specialchars($objNews->headline)); break; case 'news_url': $arrCache[$strTag] = $strUrl; break; case 'news_title': $arrCache[$strTag] = specialchars($objNews->headline); break; } break; // Events // Events case 'event': case 'event_open': case 'event_url': case 'event_title': if (($objEvent = \CalendarEventsModel::findByIdOrAlias($elements[1])) === null) { break; } $strUrl = ''; if ($objEvent->source == 'external') { $strUrl = $objEvent->url; } elseif ($objEvent->source == 'internal') { if (($objJumpTo = $objEvent->getRelated('jumpTo')) !== null) { $strUrl = $this->generateFrontendUrl($objJumpTo->row()); } } elseif ($objEvent->source == 'article') { if (($objArticle = \ArticleModel::findByPk($objEvent->articleId, array('eager' => true))) !== null && ($objPid = $objArticle->getRelated('pid')) !== null) { $strUrl = $this->generateFrontendUrl($objPid->row(), '/articles/' . (!\Config::get('disableAlias') && $objArticle->alias != '' ? $objArticle->alias : $objArticle->id)); } } else { if (($objCalendar = $objEvent->getRelated('pid')) !== null && ($objJumpTo = $objCalendar->getRelated('jumpTo')) !== null) { $strUrl = $this->generateFrontendUrl($objJumpTo->row(), (\Config::get('useAutoItem') && !\Config::get('disableAlias') ? '/' : '/events/') . (!\Config::get('disableAlias') && $objEvent->alias != '' ? $objEvent->alias : $objEvent->id)); } } // Replace the tag switch (strtolower($elements[0])) { case 'event': $strLink = specialchars($objEvent->title); $arrCache[$strTag] = sprintf('<a href="%s" title="%s">%s</a>', $strUrl, $strLink, $strLink); break; case 'event_open': $arrCache[$strTag] = sprintf('<a href="%s" title="%s">', $strUrl, specialchars($objEvent->title)); break; case 'event_url': $arrCache[$strTag] = $strUrl; break; case 'event_title': $arrCache[$strTag] = specialchars($objEvent->title); break; } break; // Article teaser // Article teaser case 'article_teaser': $objTeaser = \ArticleModel::findByIdOrAlias($elements[1]); if ($objTeaser !== null) { if ($objPage->outputFormat == 'xhtml') { $arrCache[$strTag] = \String::toXhtml($this->replaceInsertTags($objTeaser->teaser, $blnCache)); } else { $arrCache[$strTag] = \String::toHtml5($this->replaceInsertTags($objTeaser->teaser, $blnCache)); } } break; // News teaser // News teaser case 'news_teaser': $objTeaser = \NewsModel::findByIdOrAlias($elements[1]); if ($objTeaser !== null) { if ($objPage->outputFormat == 'xhtml') { $arrCache[$strTag] = \String::toXhtml($this->replaceInsertTags($objTeaser->teaser, $blnCache)); } else { $arrCache[$strTag] = \String::toHtml5($this->replaceInsertTags($objTeaser->teaser, $blnCache)); } } break; // Event teaser // Event teaser case 'event_teaser': $objTeaser = \CalendarEventsModel::findByIdOrAlias($elements[1]); if ($objTeaser !== null) { if ($objPage->outputFormat == 'xhtml') { $arrCache[$strTag] = \String::toXhtml($this->replaceInsertTags($objTeaser->teaser, $blnCache)); } else { $arrCache[$strTag] = \String::toHtml5($this->replaceInsertTags($objTeaser->teaser, $blnCache)); } } break; // News feed URL // News feed URL case 'news_feed': $objFeed = \NewsFeedModel::findByPk($elements[1]); if ($objFeed !== null) { $arrCache[$strTag] = $objFeed->feedBase . 'share/' . $objFeed->alias . '.xml'; } break; // Calendar feed URL // Calendar feed URL case 'calendar_feed': $objFeed = \CalendarFeedModel::findByPk($elements[1]); if ($objFeed !== null) { $arrCache[$strTag] = $objFeed->feedBase . 'share/' . $objFeed->alias . '.xml'; } break; // Last update // Last update case 'last_update': $strQuery = "SELECT MAX(tstamp) AS tc"; if (in_array('news', \ModuleLoader::getActive())) { $strQuery .= ", (SELECT MAX(tstamp) FROM tl_news) AS tn"; } if (in_array('calendar', \ModuleLoader::getActive())) { $strQuery .= ", (SELECT MAX(tstamp) FROM tl_calendar_events) AS te"; } $strQuery .= " FROM tl_content"; $objUpdate = \Database::getInstance()->query($strQuery); if ($objUpdate->numRows) { $arrCache[$strTag] = \Date::parse($elements[1] ?: \Config::get('datimFormat'), max($objUpdate->tc, $objUpdate->tn, $objUpdate->te)); } break; // Version // Version case 'version': $arrCache[$strTag] = VERSION . '.' . BUILD; break; // Request token // Request token case 'request_token': $arrCache[$strTag] = REQUEST_TOKEN; break; // POST data // POST data case 'post': $arrCache[$strTag] = \Input::post($elements[1]); break; // Mobile/desktop toggle (see #6469) // Mobile/desktop toggle (see #6469) case 'toggle_view': $strUrl = ampersand(\Environment::get('request')); $strGlue = strpos($strUrl, '?') === false ? '?' : '&'; if (\Input::cookie('TL_VIEW') == 'mobile' || \Environment::get('agent')->mobile && \Input::cookie('TL_VIEW') != 'desktop') { $arrCache[$strTag] = '<a href="' . $strUrl . $strGlue . 'toggle_view=desktop" class="toggle_desktop" title="' . specialchars($GLOBALS['TL_LANG']['MSC']['toggleDesktop'][1]) . '">' . $GLOBALS['TL_LANG']['MSC']['toggleDesktop'][0] . '</a>'; } else { $arrCache[$strTag] = '<a href="' . $strUrl . $strGlue . 'toggle_view=mobile" class="toggle_mobile" title="' . specialchars($GLOBALS['TL_LANG']['MSC']['toggleMobile'][1]) . '">' . $GLOBALS['TL_LANG']['MSC']['toggleMobile'][0] . '</a>'; } break; // Conditional tags (if) // Conditional tags (if) case 'iflng': if ($elements[1] != '' && $elements[1] != $objPage->language) { for (; $_rit < $_cnt; $_rit += 3) { if ($tags[$_rit + 1] == 'iflng' || $tags[$_rit + 1] == 'iflng::' . $objPage->language) { break; } } } unset($arrCache[$strTag]); break; // Conditional tags (if not) // Conditional tags (if not) case 'ifnlng': if ($elements[1] != '') { $langs = trimsplit(',', $elements[1]); if (in_array($objPage->language, $langs)) { for (; $_rit < $_cnt; $_rit += 3) { if ($tags[$_rit + 1] == 'ifnlng') { break; } } } } unset($arrCache[$strTag]); break; // Environment // Environment case 'env': switch ($elements[1]) { case 'host': $arrCache[$strTag] = \Idna::decode(\Environment::get('host')); break; case 'http_host': $arrCache[$strTag] = \Idna::decode(\Environment::get('httpHost')); break; case 'url': $arrCache[$strTag] = \Idna::decode(\Environment::get('url')); break; case 'path': $arrCache[$strTag] = \Idna::decode(\Environment::get('base')); break; case 'request': $arrCache[$strTag] = \Environment::get('indexFreeRequest'); break; case 'ip': $arrCache[$strTag] = \Environment::get('ip'); break; case 'referer': $arrCache[$strTag] = $this->getReferer(true); break; case 'files_url': $arrCache[$strTag] = TL_FILES_URL; break; case 'assets_url': case 'plugins_url': case 'script_url': $arrCache[$strTag] = TL_ASSETS_URL; break; } break; // Page // Page case 'page': if ($elements[1] == 'pageTitle' && $objPage->pageTitle == '') { $elements[1] = 'title'; } elseif ($elements[1] == 'parentPageTitle' && $objPage->parentPageTitle == '') { $elements[1] = 'parentTitle'; } elseif ($elements[1] == 'mainPageTitle' && $objPage->mainPageTitle == '') { $elements[1] = 'mainTitle'; } // Do not use specialchars() here (see #4687) $arrCache[$strTag] = $objPage->{$elements[1]}; break; // User agent // User agent case 'ua': $ua = \Environment::get('agent'); if ($elements[1] != '') { $arrCache[$strTag] = $ua->{$elements[1]}; } else { $arrCache[$strTag] = ''; } break; // Acronyms // Acronyms case 'acronym': if ($objPage->outputFormat == 'xhtml') { if ($elements[1] != '') { $arrCache[$strTag] = '<acronym title="' . $elements[1] . '">'; } else { $arrCache[$strTag] = '</acronym>'; } break; } // NO break; // Abbreviations // NO break; // Abbreviations case 'abbr': if ($elements[1] != '') { $arrCache[$strTag] = '<abbr title="' . $elements[1] . '">'; } else { $arrCache[$strTag] = '</abbr>'; } break; // Images // Images case 'image': case 'picture': $width = null; $height = null; $alt = ''; $class = ''; $rel = ''; $strFile = $elements[1]; $mode = ''; $size = null; $strTemplate = 'picture_default'; // Take arguments if (strpos($elements[1], '?') !== false) { $arrChunks = explode('?', urldecode($elements[1]), 2); $strSource = \String::decodeEntities($arrChunks[1]); $strSource = str_replace('[&]', '&', $strSource); $arrParams = explode('&', $strSource); foreach ($arrParams as $strParam) { list($key, $value) = explode('=', $strParam); switch ($key) { case 'width': $width = $value; break; case 'height': $height = $value; break; case 'alt': $alt = specialchars($value); break; case 'class': $class = $value; break; case 'rel': $rel = $value; break; case 'mode': $mode = $value; break; case 'size': $size = (int) $value; break; case 'template': $strTemplate = preg_replace('/[^a-z0-9_]/i', '', $value); break; } } $strFile = $arrChunks[0]; } if (\Validator::isUuid($strFile)) { // Handle UUIDs $objFile = \FilesModel::findByUuid($strFile); if ($objFile === null) { $arrCache[$strTag] = ''; break; } $strFile = $objFile->path; } elseif (is_numeric($strFile)) { // Handle numeric IDs (see #4805) $objFile = \FilesModel::findByPk($strFile); if ($objFile === null) { $arrCache[$strTag] = ''; break; } $strFile = $objFile->path; } else { // Check the path if (\Validator::isInsecurePath($strFile)) { throw new \RuntimeException('Invalid path ' . $strFile); } } // Check the maximum image width if (\Config::get('maxImageWidth') > 0 && $width > \Config::get('maxImageWidth')) { $width = \Config::get('maxImageWidth'); $height = null; } // Generate the thumbnail image try { // Image if (strtolower($elements[0]) == 'image') { $dimensions = ''; $imageObj = \Image::create($strFile, array($width, $height, $mode)); $src = $imageObj->executeResize()->getResizedPath(); $objFile = new \File(rawurldecode($src), true); // Add the image dimensions if (($imgSize = $objFile->imageSize) !== false) { $dimensions = ' width="' . $imgSize[0] . '" height="' . $imgSize[1] . '"'; } $arrCache[$strTag] = '<img src="' . TL_FILES_URL . $src . '" ' . $dimensions . ' alt="' . $alt . '"' . ($class != '' ? ' class="' . $class . '"' : '') . ($objPage->outputFormat == 'xhtml' ? ' />' : '>'); } else { $picture = \Picture::create($strFile, array(0, 0, $size))->getTemplateData(); $picture['alt'] = $alt; $picture['class'] = $class; $pictureTemplate = new \FrontendTemplate($strTemplate); $pictureTemplate->setData($picture); $arrCache[$strTag] = $pictureTemplate->parse(); } // Add a lightbox link if ($rel != '') { if (strncmp($rel, 'lightbox', 8) !== 0 || $objPage->outputFormat == 'xhtml') { $attribute = ' rel="' . $rel . '"'; } else { $attribute = ' data-lightbox="' . substr($rel, 8) . '"'; } $arrCache[$strTag] = '<a href="' . TL_FILES_URL . $strFile . '"' . ($alt != '' ? ' title="' . $alt . '"' : '') . $attribute . '>' . $arrCache[$strTag] . '</a>'; } } catch (\Exception $e) { $arrCache[$strTag] = ''; } break; // Files (UUID or template path) // Files (UUID or template path) case 'file': if (\Validator::isUuid($elements[1])) { $objFile = \FilesModel::findByUuid($elements[1]); if ($objFile !== null) { $arrCache[$strTag] = $objFile->path; break; } } $arrGet = $_GET; \Input::resetCache(); $strFile = $elements[1]; // Take arguments and add them to the $_GET array if (strpos($elements[1], '?') !== false) { $arrChunks = explode('?', urldecode($elements[1])); $strSource = \String::decodeEntities($arrChunks[1]); $strSource = str_replace('[&]', '&', $strSource); $arrParams = explode('&', $strSource); foreach ($arrParams as $strParam) { $arrParam = explode('=', $strParam); $_GET[$arrParam[0]] = $arrParam[1]; } $strFile = $arrChunks[0]; } // Check the path if (\Validator::isInsecurePath($strFile)) { throw new \RuntimeException('Invalid path ' . $strFile); } // Include .php, .tpl, .xhtml and .html5 files if (preg_match('/\\.(php|tpl|xhtml|html5)$/', $strFile) && file_exists(TL_ROOT . '/templates/' . $strFile)) { ob_start(); include TL_ROOT . '/templates/' . $strFile; $arrCache[$strTag] = ob_get_contents(); ob_end_clean(); } $_GET = $arrGet; \Input::resetCache(); break; // HOOK: pass unknown tags to callback functions // HOOK: pass unknown tags to callback functions default: if (isset($GLOBALS['TL_HOOKS']['replaceInsertTags']) && is_array($GLOBALS['TL_HOOKS']['replaceInsertTags'])) { foreach ($GLOBALS['TL_HOOKS']['replaceInsertTags'] as $callback) { $this->import($callback[0]); $varValue = $this->{$callback}[0]->{$callback}[1]($tag, $blnCache, $arrCache[$strTag], $flags, $tags, $arrCache, $_rit, $_cnt); // see #6672 // Replace the tag and stop the loop if ($varValue !== false) { $arrCache[$strTag] = $varValue; break; } } } if (\Config::get('debugMode')) { $GLOBALS['TL_DEBUG']['unknown_insert_tags'][] = $strTag; } break; } // Handle the flags if (!empty($flags)) { foreach ($flags as $flag) { switch ($flag) { case 'addslashes': case 'stripslashes': case 'standardize': case 'ampersand': case 'specialchars': case 'nl2br': case 'nl2br_pre': case 'strtolower': case 'utf8_strtolower': case 'strtoupper': case 'utf8_strtoupper': case 'ucfirst': case 'lcfirst': case 'ucwords': case 'trim': case 'rtrim': case 'ltrim': case 'utf8_romanize': case 'strrev': case 'urlencode': case 'rawurlencode': $arrCache[$strTag] = $flag($arrCache[$strTag]); break; case 'encodeEmail': case 'decodeEntities': $arrCache[$strTag] = \String::$flag($arrCache[$strTag]); break; case 'number_format': $arrCache[$strTag] = \System::getFormattedNumber($arrCache[$strTag], 0); break; case 'currency_format': $arrCache[$strTag] = \System::getFormattedNumber($arrCache[$strTag], 2); break; case 'readable_size': $arrCache[$strTag] = \System::getReadableSize($arrCache[$strTag]); break; // HOOK: pass unknown flags to callback functions // HOOK: pass unknown flags to callback functions default: if (isset($GLOBALS['TL_HOOKS']['insertTagFlags']) && is_array($GLOBALS['TL_HOOKS']['insertTagFlags'])) { foreach ($GLOBALS['TL_HOOKS']['insertTagFlags'] as $callback) { $this->import($callback[0]); $varValue = $this->{$callback}[0]->{$callback}[1]($flag, $tag, $arrCache[$strTag], $flags, $blnCache, $tags, $arrCache, $_rit, $_cnt); // see #5806 // Replace the tag and stop the loop if ($varValue !== false) { $arrCache[$strTag] = $varValue; break; } } } if (\Config::get('debugMode')) { $GLOBALS['TL_DEBUG']['unknown_insert_tag_flags'][] = $flag; } break; } } } $strBuffer .= $arrCache[$strTag]; } return \String::restoreBasicEntities($strBuffer); }
public function __get($strKey) { switch ($strKey) { case 'title': return standardize(\String::restoreBasicEntities(implode('-', $this->getEach('title')))); case 'addBootstrapPrint': case 'addFontAwesome': return max($this->getEach($strKey)); case 'addElegantIcons': return max($this->getEach($strKey)); case 'variablesSRC': case 'variablesOrderSRC': return $this->getEach($strKey); case 'ids': return $this->getEach('id'); // must be id // must be id case 'lastUpdate': return max($this->getEach('tstamp')); // return max tstamp from css groups } if (isset($this->arrData[$strKey])) { return $this->arrData[$strKey]; } return parent::__get($strKey); }
/** * Restore basic entities * * @param string $strBuffer The string with the tags to be replaced * * @return string The string with the original entities * * @deprecated Use String::restoreBasicEntities() instead */ public static function restoreBasicEntities($strBuffer) { return \String::restoreBasicEntities($strBuffer); }
/** * Auto-generate a page alias if it has not been set yet * * @param mixed $varValue * @param DataContainer $dc * * @return string * * @throws Exception */ public function generateAlias($varValue, DataContainer $dc) { $autoAlias = false; // Generate an alias if there is none if ($varValue == '') { $autoAlias = true; $varValue = standardize(String::restoreBasicEntities($dc->activeRecord->title)); // Generate folder URL aliases (see #4933) if (Config::get('folderUrl')) { $objPage = PageModel::findWithDetails($dc->activeRecord->id); if ($objPage->folderUrl != '') { $varValue = $objPage->folderUrl . $varValue; } } } $objAlias = $this->Database->prepare("SELECT id FROM tl_page WHERE id=? OR alias=?")->execute($dc->id, $varValue); // Check whether the page alias exists if ($objAlias->numRows > ($autoAlias ? 0 : 1)) { $arrPages = array(); $strDomain = ''; $strLanguage = ''; while ($objAlias->next()) { $objCurrentPage = PageModel::findWithDetails($objAlias->id); $domain = $objCurrentPage->domain ?: '*'; $language = !$objCurrentPage->rootIsFallback ? $objCurrentPage->rootLanguage : '*'; // Store the current page's data if ($objCurrentPage->id == $dc->id) { // Get the DNS and language settings from the POST data (see #4610) if ($objCurrentPage->type == 'root') { $strDomain = Input::post('dns'); $strLanguage = Input::post('language'); } else { $strDomain = $domain; $strLanguage = $language; } } else { // Check the domain and language or the domain only if (Config::get('addLanguageToUrl')) { $arrPages[$domain][$language][] = $objAlias->id; } else { $arrPages[$domain][] = $objAlias->id; } } } $arrCheck = Config::get('addLanguageToUrl') ? $arrPages[$strDomain][$strLanguage] : $arrPages[$strDomain]; // Check if there are multiple results for the current domain if (!empty($arrCheck)) { if ($autoAlias) { $varValue .= '-' . $dc->id; } else { throw new Exception(sprintf($GLOBALS['TL_LANG']['ERR']['aliasExists'], $varValue)); } } } return $varValue; }
/** * @param $strText * @return string * @deprecated */ protected function replaceParameters($strText) { if (is_array($this->arrParameters)) { foreach ($this->arrParameters as $key => $varValue) { $strText = str_replace('{{' . $key . '}}', $varValue, $strText); } } $strText = \String::parseSimpleTokens($strText, $this->arrParameters); $strText = \String::restoreBasicEntities($strText); return (string) $strText; }
/** * Return the PayPal form. * @param IsotopeProductCollection The order being places * @param Module 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] = \String::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(); }
public static function replaceFormDataTags($strBuffer, $arrMailData) { // Preserve insert tags if (\Config::get('disableInsertTags')) { return \String::restoreBasicEntities($strBuffer); } $tags = preg_split('/\\{\\{(([^\\{\\}]*|(?R))*)\\}\\}/', $strBuffer, -1, PREG_SPLIT_DELIM_CAPTURE); $strBuffer = ''; $runEval = false; for ($_rit = 0, $_cnt = count($tags); $_rit < $_cnt; $_rit += 3) { $strBuffer .= $tags[$_rit]; $strTag = $tags[$_rit + 1]; // Skip empty tags if ($strTag == '') { continue; } $flags = explode('|', $strTag); $tag = array_shift($flags); $elements = explode('::', $tag); // Run the replacement again if there are more tags and not if/elseif condition if (strpos($strTag, '{{') !== false) { $strTag = static::replaceFormDataTags($strTag, $arrMailData); } // Replace the tag switch (strtolower($elements[0])) { case strrpos($elements[0], 'if', -strlen($elements[0])) !== false: $strTag = preg_replace('/if (.*)/i', '<?php if ($1): ?>', $strTag); $runEval = true; break; case strrpos($elements[0], 'elseif', -strlen($elements[0])) !== false: $strTag = preg_replace('/elseif (.*)/i', '<?php elseif ($1): ?>', $strTag); $runEval = true; break; case 'else': $strTag = '<?php else: ?>'; break; case 'endif': $strTag = '<?php endif; ?>'; break; // form // form case 'form': if ($elements[1] == '' || !isset($arrMailData[$elements[1]]['output'])) { $strTag = ''; continue; } $strTag = $arrMailData[$elements[1]]['output']; break; case 'form_value': if ($elements[1] == '' || !isset($arrMailData[$elements[1]]['value'])) { $strTag = ''; continue; } $strTag = $arrMailData[$elements[1]]['value']; break; case 'form_submission': if ($elements[1] == '' || !isset($arrMailData[$elements[1]]['submission'])) { $strTag = ''; continue; } $strTag = rtrim($arrMailData[$elements[1]]['submission'], "\n"); break; // restore inserttag for \Controller::replaceInsertTags() // restore inserttag for \Controller::replaceInsertTags() default: $strTag = '{{' . $tag . '}}'; } $strBuffer .= $strTag; } if ($runEval) { $strBuffer = static::evalConditionTags($strBuffer); } return \String::restoreBasicEntities($strBuffer); }
private function replaceTitle2Link($treffer) { if ($GLOBALS['TL_CONFIG']['jumpToGlossar']) { $link = \GlossarPageModel::findByPk($GLOBALS['TL_CONFIG']['jumpToGlossar']); } if ($this->term->jumpTo) { $link = \GlossarPageModel::findByPk($this->term->jumpTo); } if ($link) { $link = $this->generateFrontendUrl($link->row(), ($GLOBALS['TL_CONFIG']['useAutoItem'] && !$GLOBALS['TL_CONFIG']['disableAlias'] ? '/' : '/items/') . standardize(\String::restoreBasicEntities($this->term->alias))); } $lang = ''; if (!empty($this->term_glossar->language)) { $lang = ' lang="' . $this->term_glossar->language . '"'; } return '<a' . $lang . ' class="glossar" data-maxwidth="' . ($this->term->maxWidth ? $this->term->maxWidth : 0) . '" data-maxheight="' . ($this->term->maxHeight ? $this->term->maxHeight : 0) . '" data-glossar="' . $this->term->id . '" href="' . $link . '">' . $treffer[2] . '</a>'; }
/** * Automatically generate the folder URL aliases * @return string */ public function addAliasButton() { if (Input::post('FORM_SUBMIT') == 'tl_select' && isset($_POST['alias'])) { $session = $this->Session->getData(); $ids = $session['CURRENT']['IDS']; foreach ($ids as $id) { $objPage = $this->getPageDetails($id); if ($objPage === null) { continue; } // Set the new alias $objPage->alias = standardize(String::restoreBasicEntities($objPage->title)); // Update the folderURL entry if (strpos($objPage->folderUrl, '/') !== false) { $objPage->folderUrl = dirname($objPage->folderUrl) . '/' . $objPage->alias; } else { $objPage->folderUrl = $objPage->alias; } // Store the new alias $this->Database->prepare("UPDATE tl_page SET alias=? WHERE id=?")->execute($GLOBALS['TL_CONFIG']['folderUrl'] ? $objPage->folderUrl : basename($objPage->alias), $id); } $this->redirect($this->getReferer()); } return '<input type="submit" name="alias" id="alias" class="tl_submit" accesskey="a" value="' . specialchars($GLOBALS['TL_LANG']['MSC']['aliasSelected']) . '"> '; }
/** * Automatically generate the folder URL aliases * @param array * @return array */ public function addAliasButton($arrButtons) { // Generate the aliases if (Input::post('FORM_SUBMIT') == 'tl_select' && isset($_POST['alias'])) { $session = $this->Session->getData(); $ids = $session['CURRENT']['IDS']; foreach ($ids as $id) { $objArticle = ArticleModel::findByPk($id); if ($objArticle === null) { continue; } // Set the new alias $strAlias = standardize(String::restoreBasicEntities($objArticle->title)); // The alias has not changed if ($strAlias == $objArticle->alias) { continue; } // Initialize the version manager $objVersions = new Versions('tl_article', $id); $objVersions->initialize(); // Store the new alias $this->Database->prepare("UPDATE tl_article SET alias=? WHERE id=?")->execute($strAlias, $id); // Create a new version $objVersions->create(); } $this->redirect($this->getReferer()); } // Add the button $arrButtons['alias'] = '<input type="submit" name="alias" id="alias" class="tl_submit" accesskey="a" value="' . specialchars($GLOBALS['TL_LANG']['MSC']['aliasSelected']) . '"> '; return $arrButtons; }
/** * Load the source editor * @return string */ public function source() { $this->isValid($this->intId); if (is_dir(TL_ROOT . '/' . $this->intId)) { $this->log('Folder "' . $this->intId . '" cannot be edited', __METHOD__, TL_ERROR); $this->redirect('contao/main.php?act=error'); } elseif (!file_exists(TL_ROOT . '/' . $this->intId)) { $this->log('File "' . $this->intId . '" does not exist', __METHOD__, TL_ERROR); $this->redirect('contao/main.php?act=error'); } $this->import('BackendUser', 'User'); // Check user permission if (!$this->User->hasAccess('f5', 'fop')) { $this->log('Not enough permissions to edit the file source of file "' . $this->intId . '"', __METHOD__, TL_ERROR); $this->redirect('contao/main.php?act=error'); } $objFile = new \File($this->intId, true); // Check whether file type is editable if (!in_array($objFile->extension, trimsplit(',', \Config::get('editableFiles')))) { $this->log('File type "' . $objFile->extension . '" (' . $this->intId . ') is not allowed to be edited', __METHOD__, TL_ERROR); $this->redirect('contao/main.php?act=error'); } // Add the versioning routines if ($this->blnIsDbAssisted) { $objMeta = \FilesModel::findByPath($objFile->value); if ($objMeta === null) { $objMeta = \Dbafs::addResource($objFile->value); } $objVersions = new \Versions($this->strTable, $objMeta->id); // Compare versions if (\Input::get('versions')) { $objVersions->compare(); } // Restore a version if (\Input::post('FORM_SUBMIT') == 'tl_version' && \Input::post('version') != '') { $objVersions->restore(\Input::post('version')); // Purge the script cache (see #7005) if ($objFile->extension == 'css' || $objFile->extension == 'scss' || $objFile->extension == 'less') { $this->import('Automator'); $this->Automator->purgeScriptCache(); } $this->reload(); } $objVersions->initialize(); } $strContent = $objFile->getContent(); // Process the request if (\Input::post('FORM_SUBMIT') == 'tl_files') { // Restore the basic entities (see #7170) $strSource = \String::restoreBasicEntities(\Input::postRaw('source')); // Save the file if (md5($strContent) != md5($strSource)) { // Write the file $objFile->write($strSource); $objFile->close(); // Update the database if ($this->blnIsDbAssisted) { $objMeta->hash = $objFile->hash; $objMeta->save(); $objVersions->create(); } // Purge the script cache (see #7005) if ($objFile->extension == 'css' || $objFile->extension == 'scss' || $objFile->extension == 'less') { $this->import('Automator'); $this->Automator->purgeScriptCache(); } } if (\Input::post('saveNclose')) { \System::setCookie('BE_PAGE_OFFSET', 0, 0); $this->redirect($this->getReferer()); } $this->reload(); } $codeEditor = ''; // Prepare the code editor if (\Config::get('useCE')) { $selector = 'ctrl_source'; $type = $objFile->extension; // Load the code editor configuration ob_start(); include TL_ROOT . '/system/config/ace.php'; $codeEditor = ob_get_contents(); ob_end_clean(); } // Versions overview if ($this->blnIsDbAssisted && $GLOBALS['TL_DCA'][$this->strTable]['config']['enableVersioning']) { $version = $objVersions->renderDropdown(); } else { $version = ''; } // Submit buttons $arrButtons = array(); $arrButtons['save'] = '<input type="submit" name="save" id="save" class="tl_submit" accesskey="s" value="' . specialchars($GLOBALS['TL_LANG']['MSC']['save']) . '">'; $arrButtons['saveNclose'] = '<input type="submit" name="saveNclose" id="saveNclose" class="tl_submit" accesskey="c" value="' . specialchars($GLOBALS['TL_LANG']['MSC']['saveNclose']) . '">'; // Call the buttons_callback (see #4691) if (is_array($GLOBALS['TL_DCA'][$this->strTable]['edit']['buttons_callback'])) { foreach ($GLOBALS['TL_DCA'][$this->strTable]['edit']['buttons_callback'] as $callback) { if (is_array($callback)) { $this->import($callback[0]); $arrButtons = $this->{$callback}[0]->{$callback}[1]($arrButtons, $this); } elseif (is_callable($callback)) { $arrButtons = $callback($arrButtons, $this); } } } // Add the form return $version . ' <div id="tl_buttons"> <a href="' . $this->getReferer(true) . '" class="header_back" title="' . specialchars($GLOBALS['TL_LANG']['MSC']['backBTTitle']) . '" accesskey="b" onclick="Backend.getScrollOffset()">' . $GLOBALS['TL_LANG']['MSC']['backBT'] . '</a> </div> <h2 class="sub_headline">' . sprintf($GLOBALS['TL_LANG']['tl_files']['editFile'], $objFile->basename) . '</h2> ' . \Message::generate() . ' <form action="' . ampersand(\Environment::get('request'), true) . '" id="tl_files" class="tl_form" method="post"> <div class="tl_formbody_edit"> <input type="hidden" name="FORM_SUBMIT" value="tl_files"> <input type="hidden" name="REQUEST_TOKEN" value="' . REQUEST_TOKEN . '"> <div class="tl_tbox"> <h3><label for="ctrl_source">' . $GLOBALS['TL_LANG']['tl_files']['editor'][0] . '</label></h3> <textarea name="source" id="ctrl_source" class="tl_textarea monospace" rows="12" cols="80" style="height:400px" onfocus="Backend.getScrollOffset()">' . "\n" . htmlspecialchars($strContent) . '</textarea>' . (\Config::get('showHelp') && strlen($GLOBALS['TL_LANG']['tl_files']['editor'][1]) ? ' <p class="tl_help tl_tip">' . $GLOBALS['TL_LANG']['tl_files']['editor'][1] . '</p>' : '') . ' </div> </div> <div class="tl_formbody_submit"> <div class="tl_submit_container"> ' . implode(' ', $arrButtons) . ' </div> </div> </form>' . "\n\n" . $codeEditor; }
/** * Save the current value * * @param mixed $varValue */ protected function save($varValue) { if (\Input::post('FORM_SUBMIT') != $this->strTable) { return; } $arrData = $GLOBALS['TL_DCA'][$this->strTable]['fields'][$this->strField]; // Make sure that checkbox values are boolean if ($arrData['inputType'] == 'checkbox' && !$arrData['eval']['multiple']) { $varValue = $varValue ? true : false; } if ($varValue != '') { // Convert binary UUIDs (see #6893) if ($arrData['inputType'] == 'fileTree') { $varValue = deserialize($varValue); if (!is_array($varValue)) { $varValue = \String::binToUuid($varValue); } else { $varValue = serialize(array_map('String::binToUuid', $varValue)); } } // Convert date formats into timestamps if ($varValue != '' && in_array($arrData['eval']['rgxp'], array('date', 'time', 'datim'))) { $objDate = new \Date($varValue, \Date::getFormatFromRgxp($arrData['eval']['rgxp'])); $varValue = $objDate->tstamp; } // Handle entities if ($arrData['inputType'] == 'text' || $arrData['inputType'] == 'textarea') { $varValue = deserialize($varValue); if (!is_array($varValue)) { $varValue = \String::restoreBasicEntities($varValue); } else { $varValue = serialize(array_map('String::restoreBasicEntities', $varValue)); } } } // Trigger the save_callback if (is_array($arrData['save_callback'])) { foreach ($arrData['save_callback'] as $callback) { if (is_array($callback)) { $this->import($callback[0]); $varValue = $this->{$callback}[0]->{$callback}[1]($varValue, $this); } elseif (is_callable($callback)) { $varValue = $callback($varValue, $this); } } } $strCurrent = $this->varValue; // Handle arrays and strings if (is_array($strCurrent)) { $strCurrent = serialize($strCurrent); } elseif (is_string($strCurrent)) { $strCurrent = html_entity_decode($this->varValue, ENT_QUOTES, \Config::get('characterSet')); } // Save the value if there was no error if ((strlen($varValue) || !$arrData['eval']['doNotSaveEmpty']) && $strCurrent != $varValue) { \Config::persist($this->strField, $varValue); $deserialize = deserialize($varValue); $prior = is_bool(\Config::get($this->strField)) ? \Config::get($this->strField) ? 'true' : 'false' : \Config::get($this->strField); // Add a log entry if (!is_array(deserialize($prior)) && !is_array($deserialize)) { if ($arrData['inputType'] == 'password' || $arrData['inputType'] == 'textStore') { $this->log('The global configuration variable "' . $this->strField . '" has been changed', __METHOD__, TL_CONFIGURATION); } else { $this->log('The global configuration variable "' . $this->strField . '" has been changed from "' . $prior . '" to "' . $varValue . '"', __METHOD__, TL_CONFIGURATION); } } // Set the new value so the input field can show it $this->varValue = $deserialize; \Config::set($this->strField, $deserialize); } }
/** * Parse an item and return it as string * @param object * @param boolean * @param string * @param integer * @param object * @return string */ public function parseSermon($objSermon, $blnAddArchive = false, $strClass = '', $intCount = 0, $objConfig) { global $objPage; $objTemplate = new \FrontendTemplate($objConfig->template); $objTemplate->setData($objSermon->row()); $objTemplate->sermonId = standardize(\String::restoreBasicEntities($objSermon->title)); $objTemplate->class = ($objSermon->cssClass != '' ? ' ' . $objSermon->cssClass : '') . $strClass; $objTemplate->count = $intCount; // see #5708 $objTemplate->date = \Date::parse($objPage->dateFormat, $objSermon->date); $objTemplate->subject = $objSermon->title; $objTemplate->speakerLabel = $GLOBALS['TL_LANG']['MSC']['preacher']; $objTemplate->moderatorLabel = $GLOBALS['TL_LANG']['MSC']['moderator']; $objTemplate->addImage = false; // Add an image if ($objSermon->addImage && $objSermon->singleSRC != '') { $objModel = \FilesModel::findByUuid($objSermon->singleSRC); if ($objModel === null) { if (!\Validator::isUuid($objSermon->singleSRC)) { $objTemplate->text = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>'; } } elseif (is_file(TL_ROOT . '/' . $objModel->path)) { // Do not override the field now that we have a model registry (see #6303) $arrSermon = $objSermon->row(); $arrSermon['singleSRC'] = $objModel->path; $this->addImageToTemplate($objTemplate, $arrSermon); } } // Add the audio file if ($objSermon->audioSingleSRC != '') { /*$this->import('getid3'); $getID3 = new \getID3(); $ThisFileInfo = $getID3->analyze($objAudioModel = \FilesModel::findByUuid($objSermon->audioSingleSRC)->path); print_r($ThisFileInfo['tags']['id3v2']);*/ $objAudio = $objSermon; $objAudio->playerSRC = serialize(array($objSermon->audioSingleSRC)); $contentPlayer = new \ContentMedia($objAudio); $objTemplate->player = $contentPlayer->generate(); } if ($objSermon->getRelated('pid')->showRssFeed) { $linkedRssFeed = \SermonFeedModel::findByPk($objSermon->getRelated('pid')->linkedRssFeed); if ($linkedRssFeed) { $objTemplate->feedHref = sprintf("%s/share/%s.xml", \Environment::get('path'), $linkedRssFeed->alias); } } $objTemplate->addReference = false; // Add an Reference switch ($objSermon->addReference) { case 'none': $objTemplate->addReference = false; break; case 'file': $objTemplate->addReference = true; $objDownload = $objSermon; $objDownload->singleSRC = $objSermon->fileSingleSRC; $contentDownload = new \ContentDownload($objDownload); $objTemplate->reference = $contentDownload->generate(); break; case 'link': $objTemplate->addReference = true; $contentHyperlink = new \ContentHyperlink($objSermon); $objTemplate->reference = $contentHyperlink->generate(); break; } //Syndication Facebook $objRedirectPage = \PageModel::findByPk($objSermon->getRelated('pid')->jumpTo); //Download Predigt $objDownload = $objSermon; $objDownload->singleSRC = $objSermon->audioSingleSRC; $objDownload->linkTitle = '<img src="files/layout/icons/download.png" width="20" height="20" alt="">'; $objDownload->titleText = $GLOBALS['TL_LANG']['sermoner']['downloadTitle']; $contentDownload = new \ContentDownload($objDownload); $objTemplate->sermonDownload = $contentDownload->generate(); $objTemplate->encUrl = rawurlencode(\Environment::get('base') . ampersand($this->generateFrontendUrl($objRedirectPage->row(), ($GLOBALS['TL_CONFIG']['useAutoItem'] && !$GLOBALS['TL_CONFIG']['disableAlias'] ? '/' : '/items/') . (!$GLOBALS['TL_CONFIG']['disableAlias'] && $objSermon->alias != '' ? $objSermon->alias : $objSermon->id)))); $objTemplate->encTitle = rawurlencode($objSermon->title); return $objTemplate->parse(); }