/** * @param $templateName * @return mixed */ public function parseTemplateName($templateName) { return DiverseFunction::parseTemplateName($templateName); }
/** * @param $field * @return array */ private function findWidgetAndSet($field) { // get widget $widget = array(); // widget if ($field['type'] == 'widget') { $tplName = $field['widgetTemplate']; $tpl = ''; if (!$tplName) { $tplNameType = explode('.', $field['widget_type'])[0]; $tplNameArr = $this->getTemplateGroup('fm_field_' . $tplNameType); $tpl = current($tplNameArr); $tpl = DiverseFunction::parseTemplateName($tpl); } $widget['fieldID'] = $field['fieldID']; $widget['widgetType'] = $field['widget_type']; $widget['widgetTemplate'] = $field['widgetTemplate'] ? $field['widgetTemplate'] : $tpl; } return $widget; }
/** * @param $rowField * @return array */ public static function setGoogleMap($rowField) { $template = DiverseFunction::parseTemplateName($rowField['mapTemplate']); $zoom = $rowField['mapZoom'] ? $rowField['mapZoom'] : 15; $scrollWheel = $rowField['mapScrollWheel'] ? 'true' : 'false'; $mapType = $rowField['mapType'] ? $rowField['mapType'] : 'ROADMAP'; $styles = $rowField['mapStyle'] ? $rowField['mapStyle'] : ''; $mapSettings = array('fieldID' => $rowField['fieldID'], 'title' => mb_convert_encoding($rowField['title'], 'UTF-8'), 'description' => mb_convert_encoding($rowField['description'], 'UTF-8'), 'template' => $template, 'mapScrollWheel' => $scrollWheel, 'mapZoom' => $zoom, 'mapType' => $mapType, 'mapStyle' => $styles, 'mapMarker' => $rowField['mapMarker'], 'mapInfoBox' => $rowField['mapInfoBox']); return $mapSettings; }
/** * @return string */ public function generate() { $allowedDCA = array('tl_module', 'tl_page'); $doNotSetByType = array('wrapper_field', 'legend_start', 'legend_end', 'widget', 'fulltext_search', 'map_field', 'geo_locator'); $doNotSetByID = array('orderBy', 'sorting_fields', 'pagination', 'auto_item', 'auto_page'); if (!in_array($this->strTable, $allowedDCA)) { return 'Taxonomy field is not allowed to used in ' . $this->strTable; } // contao if (!is_array($this->varValue)) { $this->varValue = array(array('')); } $this->import('Database'); $moduleDB = null; if ($this->strTable == 'tl_module') { $moduleDB = $this->Database->prepare("SELECT f_select_module, f_select_wrapper FROM tl_module WHERE id = ?")->execute($this->currentRecord)->row(); } $modulename = $moduleDB ? $moduleDB['f_select_module'] : ''; $wrapperID = $moduleDB ? $moduleDB['f_select_wrapper'] : ''; if ($this->strTable == 'tl_module' && (!$modulename || !$wrapperID)) { return '<p>Please select Backend Modul</p>'; } if ($this->strTable == 'tl_module' && !$this->Database->tableExists($modulename)) { return '<p>' . $modulename . ' do not exist! </p>'; } $modeSettingsDB = null; // if ($this->strTable == 'tl_module') { $modeSettingsDB = $this->Database->prepare('SELECT tl_fmodules.tablename, tl_fmodules.id AS fmoduleID, tl_fmodules_filters.* FROM tl_fmodules JOIN tl_fmodules_filters ON tl_fmodules.id = tl_fmodules_filters.pid WHERE tablename = ? ORDER BY sorting')->execute($modulename); $this->arrWrapper = $this->Database->prepare('SELECT * FROM ' . $modulename . ' WHERE id = ?')->execute($wrapperID)->row(); } // if ($this->strTable == 'tl_page') { $modeSettingsDB = $this->Database->prepare('SELECT tl_fmodules.tablename, tl_fmodules.id AS fmoduleID, tl_fmodules_filters.* FROM tl_fmodules JOIN tl_fmodules_filters ON tl_fmodules.id = tl_fmodules_filters.pid ORDER BY sorting')->execute(); } // if ($this->arrWrapper == null && $this->strTable == 'tl_page') { $options = array(); while ($modeSettingsDB->next()) { if (in_array($modeSettingsDB->fieldID, $doNotSetByID)) { continue; } if (in_array($modeSettingsDB->type, $doNotSetByType)) { continue; } $options[$modeSettingsDB->fieldID] = $this->Database->prepare('SELECT ' . $modeSettingsDB->fieldID . ' FROM ' . $modeSettingsDB->tablename . '')->execute()->row()[$modeSettingsDB->fieldID]; } $this->arrWrapper = $options; $modeSettingsDB->reset(); } $savedValues = $this->varValue; $defaultSet = array('filterValue' => '', 'overwrite' => '0'); if ($modeSettingsDB->count() < 1) { return 'no fields found'; } $input = array(); foreach ($savedValues as $fid => $savedValue) { $input[$fid] = $savedValue; } while ($modeSettingsDB->next()) { if ($modeSettingsDB->dataFromTaxonomy == '1' && $this->strTable == 'tl_page') { continue; } if ($modeSettingsDB->reactToTaxonomy == '1' && $this->strTable == 'tl_page') { continue; } if (in_array($modeSettingsDB->fieldID, $doNotSetByID)) { continue; } if (in_array($modeSettingsDB->type, $doNotSetByType)) { continue; } $options = $this->arrWrapper[$modeSettingsDB->fieldID]; $viewObject = array("active" => $input[$modeSettingsDB->fieldID]['active'] ? '1' : '0', "fieldID" => $modeSettingsDB->fieldID, "type" => $modeSettingsDB->type, "title" => $modeSettingsDB->title, "negate" => $modeSettingsDB->negate, "description" => $modeSettingsDB->description, 'dataFromTable' => $modeSettingsDB->dataFromTable, "fieldAppearance" => $modeSettingsDB->fieldAppearance, "isInteger" => $modeSettingsDB->isInteger, "addTime" => $modeSettingsDB->addTime, "dataFromTaxonomy" => $modeSettingsDB->dataFromTaxonomy, "reactToTaxonomy" => $modeSettingsDB->reactToTaxonomy, "reactToField" => $modeSettingsDB->reactToField, "options" => !deserialize($options) ? array() : deserialize($options), "set" => $input[$modeSettingsDB->fieldID]['set'] ? $input[$modeSettingsDB->fieldID]['set'] : $defaultSet); if ($viewObject['fieldID'] == 'address_country') { $countries = $this->getCountries(); $viewObject['options'] = DiverseFunction::conformOptionsArray($countries); } $this->modeViewObject[] = $viewObject; } $return = '<div> <div> <div id="ctrl_' . $this->strId . '"> ' . $this->setModeBlocks() . ' </div> </div> </div>'; return $return; }