Ejemplo n.º 1
0
 /**
  *
  */
 protected function compile()
 {
     global $objPage;
     $strFormTemplate = $this->f_form_template;
     $strDateFormat = $objPage->dateFormat;
     $arrPageTaxonomy = $this->getPageTaxonomy($objPage->page_taxonomy);
     $arrFEFields = $this->f_form_fields ? deserialize($this->f_form_fields) : array();
     $arrFields = array();
     $arrWidgets = array();
     $strWidget = '';
     $arrActiveOptions = $this->f_active_options ? deserialize($this->f_active_options) : array();
     $objAutoComplete = new AutoCompletion();
     // model information
     $strListViewID = $this->f_list_field;
     $objModule = $this->Database->prepare('SELECT * FROM tl_module WHERE id = ?')->execute($strListViewID)->row();
     $strModuleTableName = $objModule['f_select_module'];
     $strWrapperID = $objModule['f_select_wrapper'];
     $arrModeSettings = deserialize($objModule['f_display_mode']);
     $arrModeSettings = is_array($arrModeSettings) ? array_values($arrModeSettings) : array();
     if (!$strModuleTableName || !$strWrapperID) {
         return;
     }
     // set fields from db
     if (is_array($arrFEFields)) {
         $arrIDs = array();
         foreach ($arrFEFields as $strID => $arrFEField) {
             $arrIDs[] = $strID;
         }
         $strPlaceholder = implode(',', array_fill(0, count($arrIDs), '?'));
         $objFields = $this->Database->prepare('SELECT * FROM tl_fmodules_filters WHERE id IN (' . $strPlaceholder . ')')->execute($arrIDs);
         if ($objFields->count()) {
             while ($objFields->next()) {
                 $arrField = $objFields->row();
                 $arrFields[$arrField['id']] = $arrField;
             }
         }
         // merge field from fe and fields from db
         $_arrFields = array();
         foreach ($arrFEFields as $strID => $arrFEField) {
             // do not display if field has dependency on other field
             if ($arrFEField['dependsOn']) {
                 if (!\Input::get($arrFEField['dependsOn'])) {
                     continue;
                 }
             }
             $_arrFields[$arrFEField['fieldID']] = $arrFEField;
             if (is_array($arrFields[$strID])) {
                 foreach ($arrFields[$strID] as $strKey => $strValue) {
                     $_arrFields[$arrFEField['fieldID']][$strKey] = $strValue;
                 }
             }
         }
         // replace fields array
         $arrFields = $_arrFields;
     }
     // generate action attribute
     $strAction = \Environment::get('request');
     if ($this->fm_redirect_source) {
         $type = $this->fm_redirect_source;
         if ($type == 'siteID') {
             $id = $this->fm_redirect_jumpTo;
             if ($id) {
                 $pageDB = $this->Database->prepare('SELECT * FROM tl_page WHERE id = ?')->execute($id)->row();
             }
             if (!empty($pageDB)) {
                 $strAction = $this->generateFrontendUrl($pageDB);
             }
         }
         if ($type == 'siteURL') {
             $url = $this->fm_redirect_url;
             if ($url) {
                 $strAction = $this->replaceInsertTags($url);
             }
         }
     }
     // get field values
     $arrActiveFields = array();
     $blnStartPoint = true;
     $arrNotRelateAbleFields = array('orderBy', 'sorting_fields', 'pagination');
     foreach ($arrFields as $strFieldID => $arrField) {
         $strValue = \Input::get($strFieldID) ? \Input::get($strFieldID) : '';
         $arrFields[$strFieldID]['value'] = $strValue;
         $arrFields[$strFieldID]['enable'] = false;
         $blnIsValue = QueryModel::isValue($strValue);
         // set labels
         $arrLabel = $this->setLabels($arrField);
         $arrFields[$strFieldID]['title'] = $arrLabel[0];
         $arrFields[$strFieldID]['description'] = $arrLabel[1];
         // set enable
         if ($blnIsValue) {
             $arrFields[$strFieldID]['enable'] = true;
         }
         // do not set start point
         if ($this->fm_related_start_point && $blnStartPoint) {
             $blnStartPoint = false;
             continue;
         }
         // do not set
         if (in_array($arrField['fieldID'], $arrNotRelateAbleFields)) {
             continue;
         }
         $arrActiveFields[] = $strFieldID;
     }
     unset($blnStartPoint);
     $arrFilteredOptions = array();
     if ($this->fm_related_options) {
         // get only active options
         $arrQueryData = HelperModel::generateSQLQueryFromFilterArray($arrFields);
         $strQuery = $arrQueryData['qStr'];
         $qTextSearch = $arrQueryData['isFulltextSearch'] ? $arrQueryData['$qTextSearch'] : '';
         //get text search results
         $textSearchResults = array();
         if ($qTextSearch) {
             $textSearchResults = QueryModel::getTextSearchResult($qTextSearch, $strModuleTableName, $strWrapperID, $arrQueryData['searchSettings']);
         }
         // get only published items
         $qProtectedStr = ' AND published = "1"';
         // preview mode
         if (HelperModel::previewMode()) {
             $qProtectedStr = '';
         }
         // get all items
         $objList = $this->Database->prepare('SELECT * FROM ' . $strModuleTableName . '_data WHERE pid = ' . $strWrapperID . $qProtectedStr . $strQuery)->query();
         // filtered options
         $_arrFilteredOptions = array();
         while ($objList->next()) {
             $arrListItem = $objList->row();
             if ($qTextSearch) {
                 if (!$textSearchResults[$arrListItem['id']]) {
                     continue;
                 }
             }
             foreach ($arrActiveFields as $strActiveField) {
                 $arrFilteredOptions[$strActiveField] = array();
                 $arrValues = explode(',', $arrListItem[$strActiveField]);
                 $_arrFilteredOptions[$strActiveField][] = array_values($arrValues);
             }
         }
         // pluck values
         foreach ($_arrFilteredOptions as $strFieldID => $arrFilteredOption) {
             $arrFilteredOption = call_user_func_array('array_merge', $arrFilteredOption);
             $arrFilteredOption = array_unique($arrFilteredOption);
             $arrFilteredOptions[$strFieldID] = $arrFilteredOption;
         }
     }
     // set options
     $objWrapper = $this->Database->prepare('SELECT * FROM ' . $strModuleTableName . ' WHERE id = ?')->execute($strWrapperID)->row();
     foreach ($arrFields as $strFieldID => $arrField) {
         if ($arrField['type'] == 'multi_choice' || $arrField['type'] == 'simple_choice') {
             $arrWrapperOptions = $objWrapper[$strFieldID] ? deserialize($objWrapper[$strFieldID]) : array();
             if ($arrField['dataFromTaxonomy'] == '1') {
                 $arrWrapperOptions = $this->getDataFromTaxonomy($objWrapper['select_taxonomy_' . $strFieldID]);
             }
             if ($arrField['reactToTaxonomy'] == '1') {
                 $arrWrapperOptions = $this->getDataFromTaxonomyTags($arrField['reactToField'], $objWrapper);
             }
             if ($arrWrapperOptions['table'] && !in_array($strFieldID, $arrActiveOptions)) {
                 $arrFields[$strFieldID]['options'] = $this->getDataFromTable($objWrapper[$strFieldID]);
             }
             if (is_null($arrWrapperOptions['table']) && !in_array($strFieldID, $arrActiveOptions)) {
                 $arrFields[$strFieldID]['options'] = $arrWrapperOptions;
             }
         }
         // set countries
         if ($arrField['fieldID'] == 'address_country') {
             $arrCountries = $this->getCountries();
             $arrFields[$strFieldID]['options'] = DiverseFunction::conformOptionsArray($arrCountries);
         }
         // geo locator
         if ($arrField['type'] == 'geo_locator') {
             if ($arrField['locatorType'] == 'geo_distance') {
                 $arrFields[$strFieldID]['geoDistanceOptions'] = $this->generateGeoDistanceOptions($arrField['geoDistanceOptions']);
             }
         }
         // get options
         if ($strFieldID && in_array($strFieldID, $arrActiveOptions)) {
             $results = $objAutoComplete->getAutoCompletion($strModuleTableName, $strWrapperID, $strFieldID, $objPage->dateFormat, $objPage->timeFormat);
             // taxonomy tags
             if ($arrField['reactToTaxonomy'] == '1') {
                 $tempResults = array();
                 $arrValues = $this->getDataFromTaxonomyTags($arrField['reactToField'], $arrField, true);
                 foreach ($results as $result) {
                     if (!in_array($result['value'], $arrValues)) {
                         continue;
                     }
                     $tempResults[] = $result;
                 }
                 $results = $tempResults;
                 unset($tempResults);
             }
             $arrFields[$strFieldID]['options'] = is_array($results) ? $results : array();
         }
         if ($this->fm_related_options && is_array($arrFields[$strFieldID]['options'])) {
             $arrNewOptions = array();
             foreach ($arrFields[$strFieldID]['options'] as $intIndex => $arrKeyValue) {
                 if (is_array($arrFilteredOptions[$strFieldID]) && !in_array($arrKeyValue['value'], $arrFilteredOptions[$strFieldID])) {
                     continue;
                 }
                 $arrNewOptions[] = $arrKeyValue;
             }
             $arrFields[$strFieldID]['options'] = $arrNewOptions;
         }
         // set table name
         $arrFields[$strFieldID]['tablename'] = !strpos($strModuleTableName, '_data') ? $strModuleTableName . '_data' : $strModuleTableName;
         // date field
         if ($arrField['type'] == 'date_field') {
             $format = $arrField['addTime'] ? $objPage->datimFormat : $strDateFormat;
             $arrFields[$strFieldID]['format'] = $format;
             $arrFields[$strFieldID]['operator'] = $this->getOperator();
             $arrFields[$strFieldID]['selected_operator'] = \Input::get($strFieldID . '_int');
         }
         // search field (int)
         if ($arrField['type'] == 'search_field' && $arrField['isInteger'] == '1') {
             $arrFields[$strFieldID]['operator'] = $this->getOperator();
             $arrFields[$strFieldID]['selected_operator'] = \Input::get($strFieldID . '_int');
         }
         // search field
         if ($arrField['type'] == 'search_field') {
             //backwards compatible
             $arrFields[$strFieldID]['auto_complete'] = $arrFields[$strFieldID]['options'];
         }
         if ($arrField['type'] == 'toggle_field') {
             $arrFields[$strFieldID]['showLabel'] = $GLOBALS['TL_LANG']['MSC']['fm_highlight_show'];
             $arrFields[$strFieldID]['ignoreLabel'] = $GLOBALS['TL_LANG']['MSC']['fm_highlight_ignore'];
         }
         $arrFields[$strFieldID]['wrapperID'] = $strWrapperID;
         $arrFields[$strFieldID]['selected'] = $arrFields[$strFieldID]['value'];
         //
         if ($arrField['type'] == 'search_field' && $arrField['isInteger'] == '1') {
             if (!$arrFields[$strFieldID]['selected'] && !is_null(\Input::get($arrField['fieldID']))) {
                 $arrFields[$strFieldID]['selected'] = '';
             }
         }
         //
         if ($arrField['type'] == 'toggle_field' && !$arrFields[$strFieldID]['value']) {
             $arrFields[$strFieldID]['selected'] = '';
         }
         // set templates
         $strTemplateName = $this->parseTemplateName($arrField['used_templates']);
         $arrWidgets[$strFieldID] = array('data' => $arrFields[$strFieldID], 'tpl' => $strTemplateName);
     }
     foreach ($arrWidgets as $strFieldID => $arrWidget) {
         if ($arrWidget['data']['type'] == 'wrapper_field' && $arrWidget['data']['from_field'] && $arrWidget['data']['to_field']) {
             if ($arrWidget['data']['from_field'] == $arrWidget['data']['to_field']) {
                 $fromFieldData = $arrWidgets[$arrWidget['data']['from_field']]['data'];
                 $arrWidget['data']['title'] = $fromFieldData['title'];
                 $arrWidget['data']['description'] = $fromFieldData['description'];
                 $fromFieldData['operator'] = array('gte' => $GLOBALS['TL_LANG']['MSC']['f_gte']);
                 $fromFieldData['title'] = $GLOBALS['TL_LANG']['MSC']['fm_from_label'];
                 $fromFieldData['description'] = '';
                 $fromTemplateObj = new \FrontendTemplate($arrWidgets[$arrWidget['data']['from_field']]['tpl']);
                 $fromTemplateObj->setData($fromFieldData);
                 $from_template = $fromTemplateObj->parse();
                 $arrWidget['data']['from_template'] = $from_template;
                 //to
                 $toFieldData = $arrWidgets[$arrWidget['data']['to_field']]['data'];
                 $toFieldData['fieldID'] = $toFieldData['fieldID'] . '_btw';
                 $toFieldData['title'] = $GLOBALS['TL_LANG']['MSC']['fm_to_label'];
                 $toFieldData['description'] = '';
                 $selectValue = \Input::get($toFieldData['fieldID']);
                 if (!is_null($selectValue) && !$selectValue && $toFieldData['type'] != 'date_field') {
                     $selectValue = '';
                 }
                 $toFieldData['selected'] = $selectValue;
                 $toFieldData['operator'] = array('lte' => $GLOBALS['TL_LANG']['MSC']['f_lte']);
                 $toTemplateObj = new \FrontendTemplate($arrWidgets[$arrWidget['data']['to_field']]['tpl']);
                 $toTemplateObj->setData($toFieldData);
                 $to_template = $toTemplateObj->parse();
                 $arrWidget['data']['to_template'] = $to_template;
             } else {
                 // generate from field tpl
                 $fromFieldData = $arrWidgets[$arrWidget['data']['from_field']]['data'];
                 $fromFieldData['operator'] = array('gte' => $GLOBALS['TL_LANG']['MSC']['f_gte']);
                 $fromTemplateObj = new \FrontendTemplate($arrWidgets[$arrWidget['data']['from_field']]['tpl']);
                 $fromTemplateObj->setData($fromFieldData);
                 $from_template = $fromTemplateObj->parse();
                 $arrWidget['data']['from_template'] = $from_template;
                 // generate to field tpl
                 $toFieldData = $arrWidgets[$arrWidget['data']['to_field']]['data'];
                 $toFieldData['operator'] = array('lte' => $GLOBALS['TL_LANG']['MSC']['f_lte']);
                 $toTemplateObj = new \FrontendTemplate($arrWidgets[$arrWidget['data']['to_field']]['tpl']);
                 $toTemplateObj->setData($toFieldData);
                 $to_template = $toTemplateObj->parse();
                 $arrWidget['data']['to_template'] = $to_template;
             }
         }
         // sort out fixed field
         if ($this->sortOutFixedField($strFieldID, $arrModeSettings)) {
             continue;
         }
         // disable inactive fields
         if (!$arrWidget['data']['active']) {
             continue;
         }
         //
         if ($arrWidget['data']['overwrite'] == '1') {
             continue;
         }
         //
         if ($arrPageTaxonomy[$strFieldID] && $arrPageTaxonomy[$strFieldID]['set']['overwrite'] == '1') {
             continue;
         }
         $strWidgetTemplate = new \FrontendTemplate($arrWidget['tpl']);
         $strWidgetTemplate->setData($arrWidget['data']);
         $strWidget .= $strWidgetTemplate->parse();
     }
     $strResult = '';
     $objTemplate = new \FrontendTemplate($strFormTemplate);
     $objTemplate->setData(array('widgets' => $strWidget, 'filter' => $GLOBALS['TL_LANG']['MSC']['widget_submit'], 'enableSubmit' => $this->fm_disable_submit));
     $strResult .= $objTemplate->parse();
     $this->Template->action = $strAction;
     $this->Template->reset = $GLOBALS['TL_LANG']['MSC']['fm_ff_reset'];
     $this->Template->cssID = $this->cssID;
     $this->Template->fields = $strResult;
 }
Ejemplo n.º 2
0
 /**
  *
  */
 protected function compile()
 {
     global $objPage;
     $listID = $this->f_list_field;
     $strDetailTemplate = $this->f_detail_template;
     $listModuleDB = $this->Database->prepare('SELECT * FROM tl_module WHERE id = ?')->execute($listID)->row();
     $tablename = $listModuleDB['f_select_module'];
     $wrapperID = $listModuleDB['f_select_wrapper'];
     $moduleDB = $this->Database->prepare('SELECT tl_fmodules.id AS moduleID, tl_fmodules.*, tl_fmodules_filters.*  FROM tl_fmodules LEFT JOIN tl_fmodules_filters ON tl_fmodules.id = tl_fmodules_filters.pid WHERE tablename = ? ORDER BY tl_fmodules_filters.sorting')->execute($tablename);
     $alias = \Input::get('auto_item');
     $isAlias = QueryModel::isValue($alias);
     if (!$isAlias) {
         $objHandler = new $GLOBALS['TL_PTY']['error_404']();
         $objHandler->generate($objPage->id);
         exit;
     }
     $doNotSetByID = array('orderBy', 'sorting_fields', 'pagination');
     $doNotSetByType = array('legend_end', 'legend_start', 'wrapper_field');
     $fieldWidgets = array();
     $arrModules = array();
     $mapFields = array();
     $arrCleanOptions = array();
     //
     while ($moduleDB->next()) {
         $arrModule = $moduleDB->row();
         if (in_array($arrModule['fieldID'], $doNotSetByID) || in_array($arrModule['type'], $doNotSetByType)) {
             continue;
         }
         // map
         if ($arrModule['type'] == 'map_field') {
             $mapFields[] = HelperModel::setGoogleMap($arrModule);
             // set loadMapScript to true
             $this->loadMapScript = true;
             // load map libraries
             if (!$GLOBALS['loadGoogleMapLibraries']) {
                 $GLOBALS['loadGoogleMapLibraries'] = $arrModule['mapInfoBox'] ? true : false;
             }
         }
         if ($arrModule['type'] == 'widget') {
             $tplName = $arrModule['widgetTemplate'];
             $tpl = '';
             if (!$tplName) {
                 $tplNameType = explode('.', $arrModule['widget_type'])[0];
                 $tplNameArr = $this->getTemplateGroup('fm_field_' . $tplNameType);
                 $tpl = current($tplNameArr);
                 $tpl = $this->parseTemplateName($tpl);
             }
             $fieldWidgets[$arrModule['fieldID']] = array('fieldID' => $arrModule['fieldID'], 'widgetType' => $arrModule['widget_type'], 'widgetTemplate' => $arrModule['widgetTemplate'] ? $arrModule['widgetTemplate'] : $tpl);
         }
         // has options
         if ($arrModule['type'] == 'simple_choice' || $arrModule['type'] == 'multi_choice') {
             $dcaHelper = new DCAHelper();
             $arrCleanOptions[$arrModule['fieldID']] = $dcaHelper->getOptions($arrModule, $tablename, $wrapperID);
         }
         $arrModules[$arrModule['fieldID']] = $arrModule;
     }
     $qProtectedStr = ' AND published = "1"';
     if (HelperModel::previewMode()) {
         $qProtectedStr = '';
     }
     $itemDB = $this->Database->prepare('SELECT * FROM ' . $tablename . '_data WHERE pid = ? AND (alias = ? OR id = ?) ' . $qProtectedStr . '')->execute($wrapperID, $alias, (int) $alias)->row();
     $wrapperDB = $this->Database->prepare('SELECT * FROM ' . $tablename . ' WHERE id = ?')->execute($wrapperID)->row();
     $strResult = '';
     // overwrite template
     if ($itemDB['auto_detail_template'] && strcmp($itemDB['auto_detail_template'], 'fmodule_full')) {
         $strDetailTemplate = $itemDB['auto_detail_template'];
     }
     $objTemplate = new \FrontendTemplate($strDetailTemplate);
     if (count($itemDB) < 1) {
         $objHandler = new $GLOBALS['TL_PTY']['error_404']();
         $objHandler->generate($objPage->id);
         exit;
     }
     if (HelperModel::sortOutProtected($itemDB, $this->User->groups)) {
         $objHandler = new $GLOBALS['TL_PTY']['error_403']();
         $objHandler->generate($objPage->id);
         exit;
     }
     // image
     $imagePath = $this->generateSingeSrc($itemDB);
     if ($imagePath) {
         $itemDB['singleSRC'] = $imagePath;
     }
     // size
     $imgSize = false;
     // Override the default image size
     if ($this->imgSize != '') {
         $size = deserialize($this->imgSize);
         if ($size[0] > 0 || $size[1] > 0 || is_numeric($size[2])) {
             $imgSize = $this->imgSize;
         }
     }
     if ($imgSize) {
         $itemDB['size'] = $imgSize;
     }
     //set css and id
     $itemDB['cssID'] = deserialize($itemDB['cssID']);
     $itemDB['itemID'] = $itemDB['cssID'][0];
     $itemDB['itemCSS'] = $itemDB['cssID'][1] ? ' ' . $itemDB['cssID'][1] : '';
     $itemDB['cssClass'] = '';
     $objCte = \ContentModel::findPublishedByPidAndTable($itemDB['id'], $tablename . '_data');
     $detail = array();
     $teaser = array();
     if ($objCte !== null) {
         $intCount = 0;
         $intLast = $objCte->count() - 1;
         while ($objCte->next()) {
             $arrCss = array();
             $objRow = $objCte->current();
             if ($intCount == 0 || $intCount == $intLast) {
                 if ($intCount == 0) {
                     $arrCss[] = 'first';
                 }
                 if ($intCount == $intLast) {
                     $arrCss[] = 'last';
                 }
             }
             $objRow->classes = $arrCss;
             if ($objRow->fview == 'list') {
                 $teaser[] = $this->getContentElement($objRow, $this->strColumn);
             } else {
                 $detail[] = $this->getContentElement($objRow, $this->strColumn);
             }
             ++$intCount;
         }
     }
     // seo
     if ($this->fm_overwrite_seoSettings) {
         $descriptionColName = $this->fm_seoDescription ? $this->fm_seoDescription : 'description';
         $pageTitleColName = $this->fm_seoPageTitle ? $this->fm_seoPageTitle : 'title';
         $seoDescription = strip_tags($itemDB[$descriptionColName]);
         $objPage->description = $seoDescription;
         $objPage->pageTitle = $itemDB[$pageTitleColName];
         // set hreflang
         if ($this->fm_seoHrefLang) {
             $strHrefLangAttributes = HelperModel::getHrefAttributes($tablename, $alias, null, $itemDB, $wrapperDB);
             $GLOBALS['TL_HEAD'][] = $strHrefLangAttributes;
         }
     }
     // author
     $authorDB = null;
     if ($itemDB['author']) {
         $authorDB = $this->Database->prepare('SELECT * FROM tl_user WHERE id = ?')->execute($itemDB['author'])->row();
         unset($authorDB['password']);
         unset($authorDB['session']);
     }
     $itemDB['teaser'] = $teaser;
     $itemDB['detail'] = $detail;
     $itemDB['author'] = $authorDB;
     $itemDB['date'] = $itemDB['date'] ? date($objPage->dateFormat, $itemDB['date']) : '';
     $itemDB['time'] = $itemDB['time'] ? date($objPage->timeFormat, $itemDB['time']) : '';
     $itemDB['filter'] = $arrModules;
     if (!empty($fieldWidgets)) {
         $arrayAsValue = array('list.blank', 'list.keyValue', 'table.blank');
         foreach ($fieldWidgets as $widget) {
             $id = $widget['fieldID'];
             $tplName = $widget['widgetTemplate'];
             $type = $widget['widgetType'];
             $value = $itemDB[$id];
             if (in_array($type, $arrayAsValue)) {
                 $value = deserialize($value);
             }
             $objFieldTemplate = new \FrontendTemplate($tplName);
             $objFieldTemplate->setData(array('value' => $value, 'type' => $type, 'item' => $itemDB));
             $itemDB[$id] = $objFieldTemplate->parse();
         }
     }
     // add gallery
     if ($itemDB['addGallery'] && $itemDB['multiSRC']) {
         $objGallery = new GalleryGenerator();
         $objGallery->id = $itemDB['id'];
         $objGallery->sortBy = $itemDB['sortBy'];
         $objGallery->orderSRC = $itemDB['orderSRC'];
         $objGallery->metaIgnore = $itemDB['metaIgnore'];
         $objGallery->numberOfItems = $itemDB['numberOfItems'];
         $objGallery->perPage = $itemDB['perPageGallery'];
         $objGallery->perRow = $itemDB['perRow'];
         $objGallery->size = $itemDB['size'];
         $objGallery->fullsize = $itemDB['fullsize'];
         $objGallery->galleryTpl = $itemDB['galleryTpl'];
         $objGallery->getAllImages($itemDB['multiSRC']);
         $itemDB['gallery'] = $objGallery->renderGallery();
     }
     // create marker path
     if ($itemDB['addMarker'] && $itemDB['markerSRC']) {
         if ($this->markerCache[$itemDB['markerSRC']]) {
             $itemDB['markerSRC'] = $this->markerCache[$itemDB['markerSRC']];
         } else {
             $markerDB = $this->Database->prepare('SELECT * FROM tl_files WHERE uuid = ?')->execute($itemDB['markerSRC']);
             if ($markerDB->count()) {
                 $pathInfo = $markerDB->row()['path'];
                 if ($pathInfo) {
                     $this->markerCache[$itemDB['markerSRC']] = $pathInfo;
                     $itemDB['markerSRC'] = $pathInfo;
                 }
             }
         }
     }
     // map
     if (!empty($mapFields)) {
         foreach ($mapFields as $map) {
             $objMapTemplate = new \FrontendTemplate($map['template']);
             $itemDB['mapSettings'] = $map;
             $objMapTemplate->setData($itemDB);
             $itemDB[$map['fieldID']] = $objMapTemplate->parse();
         }
     }
     // set clean options
     if (!empty($arrCleanOptions)) {
         $itemDB['cleanOptions'] = $arrCleanOptions;
         // overwrite clean options
         foreach ($arrCleanOptions as $fieldID => $options) {
             if ($itemDB[$fieldID] && is_string($itemDB[$fieldID])) {
                 $arrValues = explode(',', $itemDB[$fieldID]);
                 $arrValuesAsString = array();
                 $arrValuesAsArray = array();
                 if (is_array($arrValues)) {
                     foreach ($arrValues as $val) {
                         $arrValuesAsArray[$val] = $options[$val];
                         $arrValuesAsString[] = $options[$val];
                     }
                 }
                 $itemDB[$fieldID . 'AsArray'] = $arrValuesAsArray;
                 $itemDB[$fieldID] = implode(', ', $arrValuesAsString);
             }
         }
     }
     // floating class
     $itemDB['floatClass'] = 'float_' . $itemDB['floating'];
     $objTemplate->setData($itemDB);
     $strTitle = $itemDB['title'];
     //enclosure
     $objTemplate->enclosure = array();
     if ($itemDB['addEnclosure']) {
         $this->addEnclosuresToTemplate($objTemplate, $itemDB);
     }
     //add image
     if ($itemDB['addImage']) {
         $this->addImageToTemplate($objTemplate, array('singleSRC' => $itemDB['singleSRC'], 'title' => $itemDB['imgTitle'], 'alt' => $itemDB['alt'], 'size' => $itemDB['size'], 'fullsize' => $itemDB['fullsize'], 'caption' => $itemDB['caption']));
     }
     $objTemplate->title = $strTitle;
     $objTemplate->addBefore = $itemDB['floatClass'] == 'float_below' ? false : true;
     $strResult .= $objTemplate->parse();
     $this->Template->referer = 'javascript:history.go(-1)';
     $this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack'];
     $this->Template->result = $strResult;
     //allow comments
     $this->Template->allowComments = $wrapperDB['allowComments'];
     if ($wrapperDB['allowComments']) {
         $this->import('Comments');
         $arrNotifies = array();
         if ($wrapperDB['notify'] != 'notify_author') {
             $arrNotifies[] = $GLOBALS['TL_ADMIN_EMAIL'];
         }
         if ($wrapperDB['notify'] != 'notify_admin') {
             if ($authorDB != null && $authorDB['email'] != '') {
                 $arrNotifies[] = $authorDB['email'];
             }
         }
         $objConfig = new \stdClass();
         $objConfig->perPage = $wrapperDB['perPage'];
         $objConfig->order = $wrapperDB['sortOrder'];
         $objConfig->template = $this->com_template;
         $objConfig->requireLogin = $wrapperDB['requireLogin'];
         $objConfig->disableCaptcha = $wrapperDB['disableCaptcha'];
         $objConfig->bbcode = $wrapperDB['bbcode'];
         $objConfig->moderate = $wrapperDB['moderate'];
         $this->Comments->addCommentsToTemplate($this->Template, $objConfig, $tablename . '_data', $itemDB['id'], $arrNotifies);
     }
     // set js files
     if ($this->loadMapScript) {
         $language = $objPage->language ? $objPage->language : 'en';
         $GLOBALS['TL_HEAD']['mapJS'] = DiverseFunction::setMapJs($language);
     }
 }