public static function replace($strBuffer, \HeimrichHannot\Submissions\SubmissionModel $objSubmission) { $tokens = preg_split('/\\[(([^\\[\\]]*)*)\\]/', $strBuffer, -1, PREG_SPLIT_DELIM_CAPTURE); $strBuffer = ''; for ($_rit = 0, $_cnt = count($tokens); $_rit < $_cnt; $_rit += 3) { $strBuffer .= $tokens[$_rit]; $strToken = $tokens[$_rit + 1]; // Skip empty tokens if ($tokens == '') { continue; } // Run the replacement again if there are more tags (see #4402) if (strpos($strToken, '[') !== false) { $strToken = static::replace($strToken, $objSubmission); } $arrParams = explode('::', $strToken); $strField = $arrParams[0]; $varValue = $objSubmission->{$strField}; if ($arrParams[1]) { $varValue = static::transform($varValue, $strField, array_slice($arrParams, 1, count($arrParams)), $objSubmission); } $strBuffer .= $varValue; } return \Controller::replaceInsertTags($strBuffer); }
public function generate() { global $objPage; $this->Template = new \FrontendTemplate($this->strTemplate); $this->Template->setData($this->arrData); $this->Template->title = ''; // title should be empty by default, use headline or pageTitle instead $arrClasses = array(); if ($this->objConfig->activeClass) { $arrClasses[] = $this->objConfig->activeClass; } if ($this->Template->headline == '') { $this->Template->headline = $this->headline; } if ($this->Template->hl == '') { $this->Template->hl = $this->hl; } $this->Template->class = implode(' ', $arrClasses); $this->Template->back = $this->getBackLink(); $this->Template->redirectBack = $this->getRedirectBack(); $this->compile(); // HOOK: add custom logic if (isset($GLOBALS['TL_HOOKS']['generateModal']) && is_array($GLOBALS['TL_HOOKS']['generateModal'])) { foreach ($GLOBALS['TL_HOOKS']['generateModal'] as $callback) { static::importStatic($callback[0])->{$callback[1]}($this->Template, $this->objModel, $this->objConfig, $this); } } return \Controller::replaceInsertTags($this->Template->parse()); }
/** * Replace matching inserttags * @param string InsertTag * @param bool Use cache * @return string */ protected function replaceInsertTags($strBuffer, $blnCache = false) { $this->import('Database'); $aParams = explode('::', $strBuffer); switch ($aParams[0]) { case 'store': $this->Template = new FrontendTemplate('mod_storelocator_inserttag'); // find store $objStore = NULL; $objStore = $this->Database->prepare("SELECT * FROM `tl_storelocator_stores` WHERE `id` = ? ")->limit(1)->execute($aParams[1]); $entry = NULL; $entry = $objStore->fetchAssoc(); // get opening times $entry['opening_times'] = unserialize($entry['opening_times']); $entry['opening_times'] = !empty($entry['opening_times'][0]['from']) ? $entry['opening_times'] : NULL; // set country name $aCountryNames = $this->getCountries(); $entry['country_code'] = $entry['country']; $entry['country_name'] = $aCountryNames[$entry['country']]; if (!$objStore) { return false; } $this->Template->entry = $entry; $sTemplate = $this->Template->parse(); $sTemplate = Controller::replaceInsertTags($sTemplate); return $sTemplate; break; // not our insert tag? // not our insert tag? default: return false; break; } return false; }
/** * Output the response and clean output buffer */ public function output() { ob_get_clean(); $strBuffer = json_encode($this); echo \Controller::replaceInsertTags($strBuffer, false); // do not cache inserttags exit; }
public static function replaceInsertTagsOnlineView(RenderMessageContentEvent $objEvent) { global $objPage; if ($objPage) { $strContent = $objEvent->getRenderedContent(); $strContent = str_replace(array('%7B%7B', '%7D%7D'), array('{{', '}}'), $strContent); $objEvent->setRenderedContent(\Controller::replaceInsertTags($strContent)); } }
public static function replaceInsertTags($varValue, $blnCache = true) { if (is_array($varValue)) { foreach ($varValue as $key => $value) { $varValue[$key] = static::replaceInsertTags($value, $blnCache); } return $varValue; } return \Controller::replaceInsertTags($varValue, $blnCache); }
/** * Recursively replace insert tags * * @param array|string $varValue * * @return array|string */ public static function replaceRecursively($varValue) { if (is_array($varValue)) { foreach ($varValue as $k => $v) { $varValue[$k] = static::replaceRecursively($v); } return $varValue; } elseif (is_object($varValue)) { return $varValue; } return \Controller::replaceInsertTags($varValue, false); }
/** * 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; }
/** * Should only return the field value * @return string */ public function generate() { $arrData = $GLOBALS['TL_DCA'][$this->strTable]['fields'][$this->strName]; $value = FormSubmission::prepareSpecialValueForPrint($this->varValue, $arrData, $this->strTable, $this, $this->activeRecord); switch ($this->type) { case 'multifileupload': if ($this->fieldType == 'checkbox') { $value = '<ul class="download-list">' . implode('', array_map(function ($val) { return '<li>{{download::' . str_replace(\Environment::get('url') . '/', '', $val) . '}}</li>'; }, explode(', ', $value))) . '</ul>'; break; } $value = '{{download::' . str_replace(\Environment::get('url') . '/', '', $value) . '}}'; break; } $value = class_exists('Contao\\StringUtil') ? \StringUtil::decodeEntities(\Controller::replaceInsertTags($value)) : \String::decodeEntities(\Controller::replaceInsertTags($value)); if (!$value) { $value = '-'; } return $value; }
public static function processTarget($target) { // replace insert tags for Contao 3.5.7 and up if (version_compare(VERSION . '.' . BUILD, '3.5.7', '>=')) { $target = \Controller::replaceInsertTags($target); } // check for insert tag if (stripos($target, '{{link_url::') === 0) { // get the page id $pageId = substr($target, 12, strpos($target, '}}') - 12); // get the page if (($objPage = \PageModel::findPublishedByIdOrAlias($pageId)) === null) { return; } // load details of the page $objPage->current()->loadDetails(); // generate the URL $target = \Controller::generateFrontendUrl($objPage->row(), null, $objPage->rootLanguage, true) . substr($target, strpos($target, '}}') + 2); } // return processed target return $target; }
/** * @param $strValue * @return string */ private static function _replaceInsertTags($strValue) { if (is_string($strValue)) { return \Controller::replaceInsertTags($strValue); } return $strValue; }
protected function generateField($strName, $arrData, $skipValidation = false) { $strClass = $GLOBALS['TL_FFL'][$arrData['inputType']]; // overwrite the widget in readonly mode if ($this->viewMode == FORMHYBRID_VIEW_MODE_READONLY || $this->viewMode == FORMHYBRID_VIEW_MODE_DEFAULT && $this->addReadOnly && in_array($strName, $this->arrReadOnly)) { $strClass = 'HeimrichHannot\\FormHybrid\\FormReadonlyField'; $skipValidation = true; } $strInputMethod = $this->strInputMethod; // Continue if the class is not defined if (!class_exists($strClass)) { return false; } $arrWidgetErrors = array(); // contains the load_callback! $varDefault = $this->getDefaultFieldValue($strName, $arrData); $varValue = $varDefault; if ($this->isSubmitted && !$skipValidation) { $varValue = \Input::$strInputMethod($strName) !== null ? \Input::$strInputMethod($strName) : $varValue; $varValue = FormSubmission::prepareSpecialValueForSave($varValue, $arrData, $this->strTable, $this->intId, $varDefault, $arrWidgetErrors); } // overwrite required fields if ($this->overwriteRequired) { // set mandatory to false $arrData['eval']['mandatory'] = false; // overwrite mandatory by config if (!$arrData['eval']['mandatory'] && in_array($strName, $this->arrRequired)) { $arrData['eval']['mandatory'] = true; } } // prevent name for GET and submit widget, otherwise url will have submit name in if ($this->strMethod == FORMHYBRID_METHOD_GET && $arrData['inputType'] == 'submit') { $strName = ''; } $arrData['eval']['tagTable'] = $this->strTable; // always disable validation for filter form if ($this->isFilterForm) { $arrData['eval']['mandatory'] = false; } // to make captcha form related, add the form id without entity id if ($arrData['inputType'] == 'captcha') { $strName .= '_' . $this->getFormId(false); } $this->strField = $strName; $this->strInputName = $strName; $this->varValue = is_array($varValue) ? $varValue : \Controller::replaceInsertTags($varValue); $arrWidget = \Widget::getAttributesFromDca($arrData, $strName, is_array($varValue) ? $varValue : \Controller::replaceInsertTags($varValue), $strName, $this->strTable, $this); $this->updateWidget($arrWidget, $arrData); list($blnActive, $strSubPalette, $arrFields, $arrSubPaletteFields, $blnAutoSubmit, $blnToggleSubpalette) = $this->retrieveSubpaletteWithState($strName, array_keys($this->arrFields)); // support submitOnChange as form submission if ($arrData['eval']['submitOnChange'] && $blnToggleSubpalette) { if ($blnAutoSubmit) { $arrWidget['onchange'] = $this->async ? 'FormhybridAjaxRequest.asyncSubmit(this.form);' : "this.form.submit();"; } else { $strEvent = 'onclick'; switch ($arrData['inputType']) { case 'select': $strEvent = 'onchange'; break; } $arrWidget[$strEvent] = "FormhybridAjaxRequest.toggleSubpalette(this, 'sub_" . $strName . "', '" . $strName . "', '" . AjaxAction::generateUrl(Form::FORMHYBRID_NAME, 'toggleSubpalette') . "')"; unset($arrWidget['submitOnChange']); } } else { if ($arrWidget['submitOnChange']) { $strEvent = null; if ($arrWidget['onchange']) { $strEvent = 'onchange'; } else { if ($arrWidget['onclick']) { $strEvent = 'onclick'; } } if ($strEvent !== null) { $arrWidget[$strEvent] = "FormhybridAjaxRequest.reload('" . $this->getFormId() . "', '" . AjaxAction::generateUrl(Form::FORMHYBRID_NAME, 'reload') . "')"; unset($arrWidget['submitOnChange']); } } } $objWidget = new $strClass($arrWidget); if (isset($arrData['formHybridOptions'])) { $arrFormHybridOptions = $arrData['formHybridOptions']; $this->import($arrFormHybridOptions[0]); $objWidget->options = $this->{$arrFormHybridOptions}[0]->{$arrFormHybridOptions}[1](); } if ($objWidget instanceof \uploadable) { $this->hasUpload = true; } // always xss clean the user input (also if filter, non-model submission, ...) -> done another time // FrontendWidget::validateGetAndPost() in $objWidget->value = FormHelper::xssClean($objWidget->value, $arrData['eval']['allowHtml']); if ($this->isSubmitted) { // add filter class if filter is active if ($objWidget->value && $this->isFilterForm) { $objWidget->class = 'filtered'; } // do not validate fields if not submitted or skipvalidation issset // do not submit if ajax request and group is not formhybrid, for example multifileupload (otherwise captcha fields will be validated does not match visible one) if (!($this->isSkipValidation() || $skipValidation) && Ajax::isRelated(Form::FORMHYBRID_NAME) !== false) { FrontendWidget::validateGetAndPost($objWidget, $this->strMethod, $this->getFormId(), $arrData); if (is_array($arrWidgetErrors)) { foreach ($arrWidgetErrors as $strError) { $objWidget->addError($strError); } } // Make sure unique fields are unique if ($arrData['eval']['unique'] && $varValue != '' && !\Database::getInstance()->isUniqueValue($this->strTable, $strName, $varValue, $this->intId > 0 ? $this->intId : null)) { $objWidget->addError(sprintf($GLOBALS['TL_LANG']['ERR']['unique'], $arrData['label'][0] ?: $strName)); } // trigger save_callbacks before assertion of the new value to objActiveRecord 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); } } } if ($objWidget->hasErrors()) { $this->doNotSubmit = true; $this->arrInvalidFields[] = $strName; } elseif ($arrData['inputType'] == 'tag' && in_array('tags_plus', \ModuleLoader::getActive())) { $varValue = deserialize($objWidget->value); if (!is_array($varValue)) { $varValue = array($varValue); } if ($this->intId) { \HeimrichHannot\TagsPlus\TagsPlus::saveTags($this->strTable, $this->intId, array_map('urldecode', $varValue)); } } elseif ($objWidget->submitInput()) { // save non escaped to database if (is_array($objWidget->value)) { $this->objActiveRecord->{$strName} = array_map(function ($varVal) use($arrData) { $varVal = FormSubmission::prepareSpecialValueForSave($varVal, $arrData, $this->strTable, $this->intId); if (is_array($varVal)) { foreach ($varVal as $key => $val) { $varVal[$key] = html_entity_decode($val); } } else { $varVal = html_entity_decode($varVal); } return $varVal; }, $objWidget->value); } else { $this->objActiveRecord->{$strName} = html_entity_decode(FormSubmission::prepareSpecialValueForSave($objWidget->value, $arrData, $this->strTable, $this->intId)); } } elseif ($objWidget instanceof \uploadable && $arrData['inputType'] == 'multifileupload') { $strMethod = strtolower($this->strMethod); if (\Input::$strMethod($strName)) { $arrValue = json_decode(\Input::$strMethod($strName)); if (!empty($arrValue)) { $arrValue = array_map(function ($val) { return \String::uuidToBin($val); }, $arrValue); $this->objActiveRecord->{$strName} = serialize($arrValue); } else { $this->objActiveRecord->{$strName} = serialize($arrValue); } } // delete the files scheduled for deletion $objWidget->deleteScheduledFiles(json_decode(\Input::$strMethod('deleted_' . $strName))); } elseif ($objWidget instanceof \uploadable && isset($_SESSION['FILES'][$strName]) && \Validator::isUuid($_SESSION['FILES'][$strName]['uuid'])) { $this->objActiveRecord->{$strName} = $_SESSION['FILES'][$strName]['uuid']; } } } return $objWidget; }
/** * * Add contao core tokens, as long as the cron job does not have these information * on sending mail in queue mode * * @param $arrTokens * @param $strLanguage * @return bool false if context_tokens has been set already (required by cron) */ protected function addContextTokens($objMessage, &$arrTokens, $strLanguage) { // add context tokens only once (queue will trigger this function again, and tokens might be overwritten) if (isset($arrTokens['context_tokens'])) { return false; } $arrTokens['context_tokens'] = true; // add environment variables as token $arrTokens['env_host'] = \Idna::decode(\Environment::get('host')); $arrTokens['env_http_host'] = \Idna::decode(\Environment::get('httpHost')); $arrTokens['env_url'] = \Idna::decode(\Environment::get('url')); $arrTokens['env_path'] = \Idna::decode(\Environment::get('base')); $arrTokens['env_request'] = \Idna::decode(\Environment::get('indexFreeRequest')); $arrTokens['env_ip'] = \Idna::decode(\Environment::get('ip')); $arrTokens['env_referer'] = \System::getReferer(); $arrTokens['env_files_url'] = TL_FILES_URL; $arrTokens['env_plugins_url'] = TL_ASSETS_URL; $arrTokens['env_script_url'] = TL_ASSETS_URL; // add date tokens $arrTokens['date'] = \Controller::replaceInsertTags('{{date}}'); $arrTokens['last_update'] = \Controller::replaceInsertTags('{{last_update}}'); if (TL_MODE == 'FE') { // add current page as token global $objPage; if ($objPage !== null) { foreach ($objPage->row() as $key => $value) { $arrTokens['page_' . $key] = $value; } if ($objPage->pageTitle == '') { $arrTokens['pageTitle'] = $objPage->title; } else { if ($objPage->parentPageTitle == '') { $arrTokens['parentPageTitle'] = $objPage->parentTitle; } else { if ($objPage->mainPageTitle == '') { $arrTokens['mainPageTitle'] = $objPage->mainTitle; } } } } // add user attributes as token if (FE_USER_LOGGED_IN) { $arrUserData = \FrontendUser::getInstance()->getData(); if (is_array($arrUserData)) { foreach ($arrUserData as $key => $value) { if (!is_array($value) && \Validator::isBinaryUuid($value)) { $value = \StringUtil::binToUuid($value); $objFile = \FilesModel::findByUuid($value); if ($objFile !== null) { $value = $objFile->path; } } $arrTokens['user_' . $key] = $value; } } } } }
public function testCall() { $this->assertSame(\Controller::replaceInsertTags('foobar'), 'foobar'); $this->assertSame(\Controller::generateFrontendUrl('foobar'), 'foobar'); }
/** * These functions need to be public for Models to access them */ public function replaceInsertTags($strBuffer, $blnCache = false) { return parent::replaceInsertTags($strBuffer, $blnCache); }
/** * Replace i18nl10n insert tags * * @param string $strTag * @param bool $blnCache * * @return bool|string */ public static function replaceI18nl10nInsertTags($strTag, $blnCache = true) { global $objPage; $arrArguments = explode('::', $strTag); if ($arrArguments[0] === 'i18nl10n' && $arrArguments[1] === 'link') { $objNextPage = I18nl10n::getInstance()->findL10nWithDetails($arrArguments[2], $GLOBALS['TL_LANGUAGE']); if ($objNextPage === null) { return false; } switch ($objNextPage->type) { case 'redirect': $strUrl = parent::replaceInsertTags($objNextPage->url); if (strncasecmp($strUrl, 'mailto:', 7) === 0) { $strUrl = \String::encodeEmail($strUrl); } break; case 'forward': $intForwardId = $objNextPage->jumpTo ?: \PageModel::findFirstPublishedByPid($objNextPage->id)->current()->id; $objNext = \PageModel::findWithDetails($intForwardId); if ($objNext !== null) { $strUrl = self::generateFrontendUrl($objNext->row(), null, ''); break; } // no break // no break default: $strUrl = self::generateFrontendUrl($objNextPage->row(), null, ''); break; } $strName = $objNextPage->title; $strTarget = $objNextPage->target ? $objPage->outputFormat == 'xhtml' ? LINK_NEW_WINDOW : ' target="_blank"' : ''; $strTitle = $objNextPage->pageTitle ?: $objNextPage->title; return sprintf('<a href="%s" title="%s"%s>%s</a>', $strUrl, specialchars($strTitle), $strTarget, specialchars($strName)); } return false; }
public function processFormDataHook($arrSubmitted, $arrData, $arrFiles, $arrLabels, $objForm) { $formId = $objForm->formID != '' ? 'auto_' . $objForm->formID : 'auto_form_' . $objForm->id; // Get all form fields $arrFields = array(); $objFields = \FormFieldModel::findPublishedByPid($objForm->id); // default order by sorting $strReturn = null; if ($objFields !== null) { $start = false; while ($objFields->next()) { if ($objFields->successType == 'successStart') { $start = true; } if ($start || !$objForm->hideFormOnSuccess) { $arrFields[] = $objFields->current(); } if ($objFields->successType == 'successStop') { $start = false; // hideFormOnSuccess: do not render other fields than successStart, fields inside and successStop if ($objForm->hideFormOnSuccess) { break; } } } } if (!empty($arrFields) && is_array($arrFields)) { $row = 0; $max_row = count($arrFields); foreach ($arrFields as $objField) { $strClass = $GLOBALS['TL_FFL'][$objField->type]; // Continue if the class is not defined if (!class_exists($strClass)) { continue; } $arrData = $objField->row(); $arrData['decodeEntities'] = true; $arrData['allowHtml'] = $objForm->allowTags; $arrData['rowClass'] = 'row_' . $row . ($row == 0 ? ' row_first' : ($row == $max_row - 1 ? ' row_last' : '')) . ($row % 2 == 0 ? ' even' : ' odd'); $arrData['tableless'] = $objForm->tableless; // Increase the row count if its a password field if ($objField->type == 'password') { ++$row; ++$max_row; $arrData['rowClassConfirm'] = 'row_' . $row . ($row == $max_row - 1 ? ' row_last' : '') . ($row % 2 == 0 ? ' even' : ' odd'); } // Submit buttons do not use the name attribute if ($objField->type == 'submit') { $arrData['name'] = ''; } // Unset the default value depending on the field type (see #4722) if (!empty($arrData['value'])) { if (!in_array('value', trimsplit('[,;]', $GLOBALS['TL_DCA']['tl_form_field']['palettes'][$objField->type]))) { $arrData['value'] = ''; } } $objWidget = new $strClass($arrData); $objWidget->required = $objField->mandatory ? true : false; // HOOK: load form field callback if (isset($GLOBALS['TL_HOOKS']['loadFormField']) && is_array($GLOBALS['TL_HOOKS']['loadFormField'])) { foreach ($GLOBALS['TL_HOOKS']['loadFormField'] as $callback) { $this->import($callback[0]); $objWidget = $this->{$callback}[0]->{$callback}[1]($objWidget, $formId, $arrData, $objForm); } } $strReturn .= $objWidget->parse(); ++$row; } } if ($objForm->isAjaxForm && !is_null($strReturn)) { $strReturn .= '<input type="hidden" name="FORM_SUBMIT" value="' . $formId . '">'; $strReturn .= '<input type="hidden" name="REQUEST_TOKEN" value="' . \RequestToken::get() . '">'; die(\Controller::replaceInsertTags($strReturn)); } }
protected function getData(array $arrData) { $arrData['singleCoords'] = str_replace(' ', '', $arrData['singleCoords']); $arrData['multiCoords'] = deserialize($arrData['multiCoords']); if (is_array($arrData['multiCoords'])) { $tmp1 = array(); foreach ($arrData['multiCoords'] as $coords) { $tmp2 = explode(',', $coords); $tmp1[0][] = $tmp2[0]; $tmp1[1][] = $tmp2[1]; } $arrData['windowPosition'] = array_sum($tmp1[0]) / sizeof($tmp1[0]) . ',' . array_sum($tmp1[1]) / sizeof($tmp1[1]); } $arrData['iconSize'] = deserialize($arrData['iconSize']); $arrData['iconAnchor'] = deserialize($arrData['iconAnchor']); if (!$arrData['iconAnchor'][0] || $arrData['iconAnchor'][0] == 0) { $arrData['iconAnchor'][0] = floor($arrData['iconSize'][0] / 2); } else { $arrData['iconAnchor'][0] = floor($arrData['iconSize'][0] / 2) + $arrData['iconAnchor'][0]; } if (!$arrData['iconAnchor'][1] || $arrData['iconAnchor'][1] == 0) { $arrData['iconAnchor'][1] = floor($arrData['iconSize'][1] / 2); } else { $arrData['iconAnchor'][1] = floor($arrData['iconSize'][1] / 2) + $arrData['iconAnchor'][1]; } $objFile = \FilesModel::findByPk($arrData['overlaySRC']); $arrData['overlaySRC'] = $objFile->path; $objFile = \FilesModel::findByPk($arrData['shadowSRC']); $arrData['shadowSRC'] = $objFile->path; $arrData['shadowSize'] = deserialize($arrData['shadowSize']); $arrData['strokeWeight'] = deserialize($arrData['strokeWeight']); $tmp1 = deserialize($arrData['strokeOpacity']); $arrData['strokeOpacity'] = $tmp1 / 100; $tmp1 = deserialize($arrData['fillOpacity']); $arrData['fillOpacity'] = $tmp1 / 100; $arrData['radius'] = deserialize($arrData['radius']); $arrData['bounds'] = deserialize($arrData['bounds']); $tmp1 = explode(',', $arrData['bounds'][0]); $tmp2 = explode(',', $arrData['bounds'][1]); $arrData['bounds'][2] = (trim($tmp1[0]) . trim($tmp2[0])) / 2 . ',' . (trim($tmp1[1]) . trim($tmp2[1])) / 2; // important: escape front slashes for js (/ -> \/) $arrData['infoWindow'] = preg_replace('/[\\n\\r\\t]+/i', '', str_replace('/', '\\/', addslashes(stripslashes(html_entity_decode(\Controller::replaceInsertTags($arrData['infoWindow'])))))); $arrData['infoWindowAnchor'] = deserialize($arrData['infoWindowAnchor']); $arrData['infoWindowAnchor'][0] = $arrData['infoWindowAnchor'][0] ? -1 * $arrData['infoWindowAnchor'][0] : 0; $arrData['infoWindowAnchor'][1] = $arrData['infoWindowAnchor'][1] ? -1 * $arrData['infoWindowAnchor'][1] : 0; $tmpSize = deserialize($arrData['infoWindowSize']); $arrData['infoWindowSize'] = ''; if (is_array($tmpSize) && $tmpSize[0] > 0 && $tmpSize[1] > 0) { $arrData['infoWindowSize'] = sprintf(' style="width:%spx;height:%spx;"', $tmpSize[0], $tmpSize[1]); } $arrData['routingAddress'] = str_replace('\\"', '"', addslashes(str_replace(' ', '', $arrData['routingAddress']))); $arrData['labels'] = $GLOBALS['TL_LANG']['dlh_googlemaps']['labels']; $arrData['staticMapPart'] = ''; //supporting insertags $arrData['kmlUrl'] = \Controller::replaceInsertTags($arrData['kmlUrl'], false); $objFile = \FilesModel::findByPk($arrData['kmlUrl']); $arrData['kmlUrl'] = $objFile->path; return $arrData; }
protected function fillEventArray($result, $pos) { $weekdays = array(0 => 'Sonntag', 1 => 'Montag', 2 => 'Dienstag', 3 => 'Mittwoch', 4 => 'Donnerstag', 5 => 'Freitag', 6 => 'Samstag'); $startDate = date("d.m.Y", $result->startDate); $startTime = $result->addTime ? date("H:i", $result->startTime) : date("H:i", $result->startDate); $endDate = $result->endDate ? date("d.m.Y", $result->endDate) : $startDate; $endTime = $result->addTime ? date("H:i", $result->endTime) : $startTime; $allDay = ""; if ($startDate == $endDate) { $allDay = 1; if ($startTime != "00:00" && $endTime != "00:00") { $allDay = 0; } } else { $allDay = 0; if ($startTime == $endTime) { $allDay = 1; } } $geoInfo = $this->getGeoInfo($result->strasse, $result->plz, $result->ort); $thumb = ""; if ($result->singleSRC && $result->addImage) { $thumb = $this->getFilePath($result->singleSRC); } $tmpArr = array('pos' => $pos, 'id' => $result->id, 'title' => htmlspecialchars_decode($result->title), 'post_date' => $result->tstamp, 'timestamp' => $result->tstamp, 'type' => "event", 'thumb' => $thumb, 'publish_timestamp' => $result->tstamp, 'event_id' => $result->id, 'subtitle' => "", 'start_date' => $startDate, 'end_date' => $endDate, 'start_time' => $startTime, 'end_time' => $endTime, 'start_ts' => $result->startDate, 'end_ts' => $result->endDate ? $result->endDate : $result->startDate, 'day' => $allDay, 'swd' => $weekdays[date('w', $result->startDate)], 'ewd' => $result->endDate ? $weekdays[date('w', $result->endDate)] : $weekdays[date('w', $result->startDate)], 'img' => $thumb, 'location' => $result->location ? $result->location : null, 'town' => $result->ort ? $result->ort : null, 'city' => $result->ort ? $result->ort : null, 'country' => $result->land && $result->ort ? strtoupper($result->land) : null, 'zip' => $result->plz ? $result->plz : null, 'plz' => $result->plz ? $result->plz : null, 'address' => $result->strasse ? $result->strasse : null, 'street' => $result->strasse ? $result->strasse : null, 'region' => $geoInfo['region'] ? $geoInfo['region'] : null, 'province' => $geoInfo['region'] ? $geoInfo['region'] : null, 'extra' => "", 'lat' => $geoInfo['lat'] ? $geoInfo['lat'] : 0, 'lng' => $geoInfo['lng'] ? $geoInfo['lng'] : 0, 'short_text' => htmlspecialchars_decode($result->teaser), 'sharelink' => \Environment::get('base') . \Controller::replaceInsertTags("{{event_url::" . $result->id . "}}")); return $tmpArr; }
public static function generateMultipleValueMatchSql($strField, $varValue, $blnConjunction = false) { if ($blnConjunction) { $arrResult = ''; foreach ($varValue as $strOption) { $arrResult[] = '(' . $strField . '="' . $strOption . '" OR ' . $strField . ' REGEXP ("\\"' . $strOption . '\\""))'; } $strQuery = implode(' AND ', $arrResult); } else { $arrValueIn = array_map(function ($val) { return '"' . \Controller::replaceInsertTags($val) . '"'; }, $varValue); $arrValueRegExp = array_map(function ($val) { return '\\"' . \Controller::replaceInsertTags($val) . '\\"'; }, $varValue); $strQuery = '(' . $strField . ' IN (' . implode(',', $arrValueIn) . ') OR ' . $strField . ' REGEXP ("' . implode('|', $arrValueRegExp) . '"))'; } return $strQuery; }