Ejemplo n.º 1
0
 /**
  * @return array
  */
 public function getDataProperties()
 {
     // set variables here
     $return = array();
     $dataContainer = \FModule\ViewContainer::getInstance();
     $arrFields = $dataContainer->dcaDataFields();
     $doNotSet = array('id', 'pid', 'tstamp', 'alias', 'author', 'size', 'source', 'url', 'jumpTo', 'target', 'protected', 'groups', 'guests', 'cssID', 'published');
     if (is_array($arrFields)) {
         foreach ($arrFields as $name => $field) {
             if (in_array($name, $doNotSet)) {
                 continue;
             }
             $return[$name] = $field['label'] ? $field['label'][0] : $name;
         }
     }
     return $return;
 }
Ejemplo n.º 2
0
 /**
  * @param $values
  * @param \DataContainer $dc
  * @return mixed
  * @throws Exception
  */
 public function create_cols($values, \DataContainer $dc)
 {
     $pid = $dc->activeRecord->pid;
     $tempVal = $dc->activeRecord->fieldID;
     $type = $dc->activeRecord->type;
     if (!$values) {
         throw new \Exception(sprintf($GLOBALS['TL_LANG']['tl_fmodules_filters']['fieldIDEmpty'], $values));
     }
     $tablename = $this->Database->prepare("SELECT tablename FROM tl_fmodules WHERE id = ?")->execute($pid)->row()['tablename'];
     $dataTable = $tablename . '_data';
     // blocked colNames
     $notAllowedCols = array('alter', 'key', 'type', 'date', 'primary', 'auto_increment', 'data', 'insert', 'delete', 'update', 'options', 'max', 'min', 'drop', 'date', 'time', 'fmodule', 'fmodules', 'fmodulesfilters', 'fmodulesfeed', 'sourcePalette', 'protectedPalette', 'expertPalette', 'publishPalette', 'generalPalette', 'geoPalette', 'geoAddressPalette', 'markerPalette');
     if (in_array(mb_strtolower($values), $notAllowedCols)) {
         throw new \Exception(sprintf($GLOBALS['TL_LANG']['tl_fmodules_filters']['notAllowed'], $values));
     }
     $viewContainer = new ViewContainer();
     $dcaDataArr = $viewContainer->dcaDataFields();
     $dcaSettingsArr = $viewContainer->dcaSettingField();
     $dcaData = array_keys($dcaDataArr);
     $dcaSettings = array_keys($dcaSettingsArr);
     if (in_array($values, $dcaData) || in_array($values, $dcaSettings)) {
         throw new \Exception(sprintf($GLOBALS['TL_LANG']['tl_fmodules_filters']['notAllowed'], $values));
     }
     if ($values == $tempVal) {
         return $tempVal;
     }
     $filtersDB = $this->Database->prepare('SELECT fieldID FROM tl_fmodules_filters WHERE pid = ? AND fieldID = ?')->execute($pid, $values);
     if ($filtersDB->numRows >= 1) {
         if ($values == 'auto_item' || $values == 'auto_page') {
             throw new \Exception(sprintf($GLOBALS['TL_LANG']['tl_fmodules_filters']['autoAttributeExist'], $values));
         }
         throw new \Exception(sprintf($GLOBALS['TL_LANG']['tl_fmodules_filters']['fieldIDExist'], $values));
     }
     if (!$this->Database->fieldExists($values, $tablename)) {
         // create
         if (!$tempVal || $values == $tempVal) {
             //parent
             SqlData::insertColFilterInput($tablename, $values);
             //child
             if ($type == 'search_field' || $type == 'widget') {
                 SqlData::insertColSearchField($dataTable, $values);
             }
             if ($type == 'date_field') {
                 SqlData::insertColDateField($dataTable, $values);
             }
             if ($type == 'simple_choice' || $type == 'multi_choice') {
                 SqlData::insertColSelectOptions($dataTable, $values);
             }
             if ($type == 'toggle_field') {
                 SqlData::insertColTogglefield($dataTable, $values);
             }
         } else {
             // rename
             if ($this->Database->fieldExists($tempVal, $tablename)) {
                 //parent
                 SqlData::renameColFilterInput($tablename, $tempVal, $values);
                 //child
                 if ($type == 'search_field' || $type == 'widget') {
                     SqlData::renameColSearchField($dataTable, $tempVal, $values);
                 }
                 if ($type == 'date_field') {
                     SqlData::renameColDateField($dataTable, $tempVal, $values);
                 }
                 if ($type == 'simple_choice' || $type == 'multi_choice') {
                     SqlData::renameColSelectOptions($dataTable, $tempVal, $values);
                 }
                 if ($type == 'toggle_field') {
                     SqlData::renameColTogglefield($dataTable, $tempVal, $values);
                 }
             }
         }
     }
     return $values;
 }