/**
 * Erstellt den nötigen HTML Code um ein Formular zu erweitern
 *
 * @param $sqlFields rex_sql-objekt, dass die zu verarbeitenden Felder enthält
 * @param $activeItem objekt, dass mit getValue() die Werte des akuellen Eintrags zurückgibt
 * @param $formatCallback callback, dem die infos als Array übergeben werden und den formatierten HTML Text zurückgibt
 */
function rex_a62_metaFields($sqlFields, $activeItem, $formatCallback, $epParams)
{
    global $I18N;
    $s = '';
    // Startwert für MEDIABUTTON, MEDIALIST, LINKLIST zähler
    $media_id = 1;
    $mlist_id = 1;
    $link_id = 1;
    $llist_id = 1;
    $sqlFields->reset();
    for ($i = 0; $i < $sqlFields->getRows(); $i++) {
        // Umschliessendes Tag von Label und Formularelement
        $tag = 'p';
        $tag_attr = '';
        $name = $sqlFields->getValue('name');
        $title = $sqlFields->getValue('title');
        $params = $sqlFields->getValue('params');
        $typeLabel = $sqlFields->getValue('label');
        $attr = $sqlFields->getValue('attributes');
        $dblength = $sqlFields->getValue('dblength');
        $dbvalues = array(htmlspecialchars($sqlFields->getValue('default')));
        $dbvalues_esc = $dbvalues;
        if ($activeItem) {
            $itemValue = $activeItem->getValue($name);
            if (strpos($itemValue, '|+|') !== false) {
                // Alte notation mit |+| als Trenner
                $dbvalues = explode('|+|', $activeItem->getValue($name));
            } else {
                // Neue Notation mit | als Trenner
                $dbvalues = explode('|', $activeItem->getValue($name));
            }
            $dbvalues_esc = array_map('htmlspecialchars', $dbvalues);
        }
        if ($title != '') {
            $label = htmlspecialchars(rex_translate($title));
        } else {
            $label = htmlspecialchars($name);
        }
        $id = preg_replace('/[^a-zA-Z\\-0-9_]/', '_', $label);
        $attr .= rex_tabindex();
        $labelIt = true;
        $field = '';
        switch ($typeLabel) {
            case 'text':
                $field = '<input type="' . $typeLabel . '" name="' . $name . '" value="' . $dbvalues_esc[0] . '" id="' . $id . ' "maxlength="' . $dblength . '" ' . $attr . ' />';
                break;
            case 'checkbox':
                $name .= '[]';
            case 'radio':
                $values = array();
                if (rex_sql::getQueryType($params) == 'SELECT') {
                    $sql = new rex_sql();
                    $value_groups = $sql->getDBArray($params, MYSQL_NUM);
                    foreach ($value_groups as $value_group) {
                        if (isset($value_group[1])) {
                            $values[$value_group[1]] = $value_group[0];
                        } else {
                            $values[$value_group[0]] = $value_group[0];
                        }
                    }
                } else {
                    $value_groups = explode('|', $params);
                    foreach ($value_groups as $value_group) {
                        if (strpos($value_group, ':') !== false) {
                            $temp = explode(':', $value_group);
                            $values[$temp[0]] = $temp[1];
                        } else {
                            $values[$value_group] = $value_group;
                        }
                    }
                }
                $class = $typeLabel == 'radio' ? 'rex-rdo' : 'rex-chckbx';
                $oneValue = count($values) == 1;
                if (!$oneValue) {
                    $tag = '';
                    $labelIt = false;
                    $tag = 'div';
                    $tag_attr = ' class="rex-chckbxs rex-ptag"';
                    $field .= '<p>' . $label . '</p>';
                }
                foreach ($values as $key => $value) {
                    $id = preg_replace('/[^a-zA-Z\\-0-9_]/', '_', $id . $key);
                    $key = htmlspecialchars($key);
                    // wenn man keine Werte angibt (Boolean Chkbox/Radio)
                    // Dummy Wert annehmen, damit an/aus unterscheidung funktioniert
                    if ($oneValue && $key == '') {
                        $key = 'true';
                    }
                    $selected = '';
                    if (in_array($key, $dbvalues_esc)) {
                        $selected = ' checked="checked"';
                    }
                    if ($oneValue) {
                        $tag_attr = ' class="' . $class . '"';
                        $field .= '<input type="' . $typeLabel . '" name="' . $name . '" value="' . $key . '" id="' . $id . '" ' . $attr . $selected . ' />' . "\n";
                    } else {
                        $field .= '<p class="' . $class . '">' . "\n";
                        $field .= '<label for="' . $id . '"><span>' . htmlspecialchars($value) . '</span></label>';
                        $field .= '<input type="' . $typeLabel . '" name="' . $name . '" value="' . $key . '" id="' . $id . '" ' . $attr . $selected . ' />' . "\n";
                        $field .= '</p>' . "\n";
                    }
                }
                break;
            case 'select':
                $select = new rex_select();
                $select->setName($name);
                $select->setId($id);
                // hier mit den "raw"-values arbeiten, da die rex_select klasse selbst escaped
                $select->setSelected($dbvalues);
                foreach (rex_split_string($attr) as $attr_name => $attr_value) {
                    if (empty($attr_name)) {
                        continue;
                    }
                    $select->setAttribute($attr_name, $attr_value);
                    if ($attr_name == 'multiple') {
                        $select->setName($name . '[]');
                    }
                }
                if (rex_sql::getQueryType($params) == 'SELECT') {
                    // Werte via SQL Laden
                    $select->addDBSqlOptions($params);
                } else {
                    // Optionen mit | separiert
                    // eine einzelne Option kann mit key:value separiert werden
                    $values = array();
                    $value_groups = explode('|', $params);
                    foreach ($value_groups as $value_group) {
                        if (strpos($value_group, ':') !== false) {
                            $temp = explode(':', $value_group);
                            $values[$temp[0]] = $temp[1];
                        } else {
                            $values[$value_group] = $value_group;
                        }
                    }
                    $select->addOptions($values);
                }
                $field .= $select->get();
                break;
            case 'datetime':
            case 'date':
                if ($dbvalues_esc[0] == '') {
                    $dbvalues_esc[0] = time();
                }
                $style = 'class="rex-fdate"';
                $yearStyle = 'class="rex-fdatey"';
                $yearSelect = new rex_select();
                $yearSelect->addOptions(range(2005, date('Y') + 10), true);
                $yearSelect->setName($name . '[year]');
                $yearSelect->setSize(1);
                $yearSelect->setId($id);
                $yearSelect->setStyle($yearStyle);
                $yearSelect->setSelected(date('Y', $dbvalues_esc[0]));
                $monthSelect = new rex_select();
                $monthSelect->addOptions(range(1, 12), true);
                $monthSelect->setName($name . '[month]');
                $monthSelect->setSize(1);
                $monthSelect->setStyle($style);
                $monthSelect->setSelected(date('m', $dbvalues_esc[0]));
                $daySelect = new rex_select();
                $daySelect->addOptions(range(1, 31), true);
                $daySelect->setName($name . '[day]');
                $daySelect->setSize(1);
                $daySelect->setStyle($style);
                $daySelect->setSelected(date('j', $dbvalues_esc[0]));
                if ($typeLabel == 'datetime') {
                    $hourSelect = new rex_select();
                    $hourSelect->addOptions(range(1, 23), true);
                    $hourSelect->setName($name . '[hour]');
                    $hourSelect->setSize(1);
                    $hourSelect->setStyle($style);
                    $hourSelect->setSelected(date('G', $dbvalues_esc[0]));
                    $minuteSelect = new rex_select();
                    $minuteSelect->addOptions(range(0, 59), true);
                    $minuteSelect->setName($name . '[minute]');
                    $minuteSelect->setSize(1);
                    $minuteSelect->setStyle($style);
                    $minuteSelect->setSelected(date('i', $dbvalues_esc[0]));
                    $field = $daySelect->get() . $monthSelect->get() . $yearSelect->get() . '-' . $hourSelect->get() . $minuteSelect->get();
                } else {
                    $field = $daySelect->get() . $monthSelect->get() . $yearSelect->get();
                }
                break;
            case 'textarea':
                $field = '<textarea name="' . $name . '" id="' . $id . '" cols="50" rows="6" ' . $attr . '>' . $dbvalues_esc[0] . '</textarea>';
                break;
            case 'REX_MEDIA_BUTTON':
                $tag = 'div';
                $tag_attr = ' class="rex-ptag"';
                $field = rex_var_media::getMediaButton($media_id);
                $field = str_replace('REX_MEDIA[' . $media_id . ']', $dbvalues_esc[0], $field);
                $field = str_replace('MEDIA[' . $media_id . ']', $name, $field);
                $id = 'REX_MEDIA_' . $media_id;
                $media_id++;
                break;
            case 'REX_MEDIALIST_BUTTON':
                $tag = 'div';
                $tag_attr = ' class="rex-ptag"';
                $name .= '[]';
                $field = rex_var_media::getMediaListButton($mlist_id, implode(',', $dbvalues_esc));
                $field = str_replace('MEDIALIST[' . $mlist_id . ']', $name, $field);
                $id = 'REX_MEDIALIST_' . $mlist_id;
                $mlist_id++;
                break;
            case 'REX_LINK_BUTTON':
                $tag = 'div';
                $tag_attr = ' class="rex-ptag"';
                $category = '';
                if ($activeItem) {
                    $category = $activeItem->getValue('category_id');
                }
                $field = rex_var_link::getLinkButton($link_id, $dbvalues_esc[0], $category);
                $field = str_replace('LINK[' . $link_id . ']', $name, $field);
                $id = 'LINK_' . $link_id;
                $link_id++;
                break;
            case 'REX_LINKLIST_BUTTON':
                $tag = 'div';
                $tag_attr = ' class="rex-ptag"';
                $category = '';
                if ($activeItem) {
                    $category = $activeItem->getValue('category_id');
                }
                $name .= '[]';
                $field = rex_var_link::getLinklistButton($llist_id, implode(',', $dbvalues), $category);
                $field = str_replace('LINKLIST[' . $llist_id . ']', $name, $field);
                $id = 'REX_LINKLIST_' . $llist_id;
                $llist_id++;
                break;
            default:
                // ----- EXTENSION POINT
                list($field, $tag, $tag_attr, $id, $label, $labelIt) = rex_register_extension_point('A62_CUSTOM_FIELD', array($field, $tag, $tag_attr, $id, $label, $labelIt, 'type' => $typeLabel, 'sql' => $sqlFields));
        }
        $s .= rex_call_func($formatCallback, array($field, $tag, $tag_attr, $id, $label, $labelIt), false);
        $sqlFields->next();
    }
    return $s;
}
/**
 * Erstellt den nötigen HTML Code um ein Formular zu erweitern
 *
 * @param $sqlFields rex_sql-objekt, dass die zu verarbeitenden Felder enthält
 * @param $activeItem objekt, dass mit getValue() die Werte des akuellen Eintrags zurückgibt
 * @param $formatCallback callback, dem die infos als Array übergeben werden und den formatierten HTML Text zurückgibt
 */
function rex_a62_metaFields($sqlFields, $activeItem, $formatCallback, $epParams)
{
    global $I18N, $REX;
    $s = '';
    // Startwert für MEDIABUTTON, MEDIALIST, LINKLIST zähler
    $media_id = 1;
    $mlist_id = 1;
    $link_id = 1;
    $llist_id = 1;
    $sqlFields->reset();
    for ($i = 0; $i < $sqlFields->getRows(); $i++, $sqlFields->next()) {
        // Umschliessendes Tag von Label und Formularelement
        $tag = 'p';
        $tag_attr = '';
        $name = $sqlFields->getValue('name');
        $title = $sqlFields->getValue('title');
        $params = $sqlFields->getValue('params');
        $typeLabel = $sqlFields->getValue('label');
        $attr = $sqlFields->getValue('attributes');
        $dblength = $sqlFields->getValue('dblength');
        $restrictions = $sqlFields->getValue('restrictions');
        $attr .= rex_tabindex();
        $attrArray = rex_split_string($attr);
        if (isset($attrArray['perm'])) {
            if (!$REX['USER']->hasPerm($attrArray['perm'])) {
                continue;
            }
            unset($attrArray['perm']);
        }
        $defaultValue = $sqlFields->getValue('default');
        if ($activeItem) {
            $itemValue = $activeItem->getValue($name);
            if (strpos($itemValue, '|+|') !== false) {
                // Alte notation mit |+| als Trenner
                $dbvalues = explode('|+|', $activeItem->getValue($name));
            } else {
                // Neue Notation mit | als Trenner
                $dbvalues = explode('|', $activeItem->getValue($name));
            }
        } else {
            $dbvalues = (array) $sqlFields->getValue('default');
        }
        if ($title != '') {
            $label = rex_translate($title);
        } else {
            $label = htmlspecialchars($name);
        }
        $id = preg_replace('/[^a-zA-Z\\-0-9_]/', '_', $label);
        $labelIt = true;
        $field = '';
        switch ($typeLabel) {
            case 'text':
                $tag_attr = ' class="rex-form-text"';
                $rexInput = rex_input::factory($typeLabel);
                $rexInput->addAttributes($attrArray);
                $rexInput->setAttribute('id', $id);
                $rexInput->setAttribute('name', $name);
                if ($dblength > 0) {
                    $rexInput->setAttribute('maxlength', $dblength);
                }
                if ($activeItem) {
                    $rexInput->setValue($activeItem->getValue($name));
                } else {
                    $rexInput->setValue($defaultValue);
                }
                $field = $rexInput->getHtml();
                break;
            case 'checkbox':
                // Beachte auch default values in multiple fields bei ADD.
                // Im EDIT wurde dies bereits vorher gehandelt
                if (!$activeItem) {
                    $defaultValue = explode('|', $defaultValue);
                }
                $name .= '[]';
            case 'radio':
                $values = array();
                if (rex_sql::getQueryType($params) == 'SELECT') {
                    $sql = rex_sql::factory();
                    $value_groups = $sql->getDBArray($params, MYSQL_NUM);
                    foreach ($value_groups as $value_group) {
                        if (isset($value_group[1])) {
                            $values[$value_group[1]] = $value_group[0];
                        } else {
                            $values[$value_group[0]] = $value_group[0];
                        }
                    }
                } else {
                    $value_groups = explode('|', $params);
                    foreach ($value_groups as $value_group) {
                        // check ob key:value paar
                        // und der wert beginnt nicht mit "translate:"
                        if (strpos($value_group, ':') !== false && strpos($value_group, 'translate:') !== 0) {
                            $temp = explode(':', $value_group, 2);
                            $values[$temp[0]] = rex_translate($temp[1]);
                        } else {
                            $values[$value_group] = rex_translate($value_group);
                        }
                    }
                }
                $class_s = $typeLabel;
                $class_p = $typeLabel == 'radio' ? 'radios' : 'checkboxes';
                $oneValue = count($values) == 1;
                if (!$oneValue) {
                    $labelIt = false;
                    $tag = 'div';
                    $tag_attr = ' class="rex-form-col-a rex-form-' . $class_p . '"';
                    $field .= '<p class="rex-form-label">' . $label . '</p><div class="rex-form-' . $class_p . '-wrapper">';
                }
                $attrStr = '';
                $classAdd = '';
                foreach ($attrArray as $key => $value) {
                    if ($key == 'class') {
                        $classAdd = ' ' . $value;
                    } else {
                        $attrStr = ' ' . $key . '="' . $value . '"';
                    }
                }
                if (!$activeItem) {
                    $dbvalues = (array) $defaultValue;
                }
                foreach ($values as $key => $value) {
                    $id = preg_replace('/[^a-zA-Z\\-0-9_]/', '_', $id . $key);
                    // wenn man keine Werte angibt (Boolean Chkbox/Radio)
                    // Dummy Wert annehmen, damit an/aus unterscheidung funktioniert
                    if ($oneValue && $key == '') {
                        $key = 'true';
                    }
                    $selected = '';
                    if (in_array($key, $dbvalues)) {
                        $selected = ' checked="checked"';
                    }
                    if ($oneValue) {
                        $tag_attr = ' class="rex-form-col-a rex-form-' . $class_s . $classAdd . '"';
                        $field .= '<input class="rex-form-' . $class_s . '" type="' . $typeLabel . '" name="' . $name . '" value="' . htmlspecialchars($key) . '" id="' . $id . '" ' . $attrStr . $selected . ' />' . "\n";
                    } else {
                        $field .= '<p class="rex-form-' . $class_s . ' rex-form-label-right' . $classAdd . '">' . "\n";
                        $field .= '<input class="rex-form-' . $class_s . '" type="' . $typeLabel . '" name="' . $name . '" value="' . htmlspecialchars($key) . '" id="' . $id . '" ' . $attrStr . $selected . ' />' . "\n";
                        $field .= '<label for="' . $id . '">' . htmlspecialchars($value) . '</label>';
                        $field .= '</p>' . "\n";
                    }
                }
                if (!$oneValue) {
                    $field .= '</div>';
                }
                break;
            case 'select':
                $tag_attr = ' class="rex-form-select"';
                $select = new rex_select();
                $select->setStyle('class="rex-form-select"');
                $select->setName($name);
                $select->setId($id);
                $multiple = false;
                foreach ($attrArray as $attr_name => $attr_value) {
                    if (empty($attr_name)) {
                        continue;
                    }
                    $select->setAttribute($attr_name, $attr_value);
                    if ($attr_name == 'multiple') {
                        $multiple = true;
                        $select->setName($name . '[]');
                    }
                }
                // Beachte auch default values in multiple fields bei ADD.
                // Im EDIT wurde dies bereits vorher gehandelt
                if ($multiple && !$activeItem) {
                    $dbvalues = explode('|', $defaultValue);
                }
                // hier mit den "raw"-values arbeiten, da die rex_select klasse selbst escaped
                $select->setSelected($dbvalues);
                if (!$multiple) {
                    $select->setSize(1);
                }
                if (rex_sql::getQueryType($params) == 'SELECT') {
                    // Werte via SQL Laden
                    $select->addDBSqlOptions($params);
                } else {
                    // Optionen mit | separiert
                    // eine einzelne Option kann mit key:value separiert werden
                    $values = array();
                    $value_groups = explode('|', $params);
                    foreach ($value_groups as $value_group) {
                        // check ob key:value paar
                        // und der wert beginnt nicht mit "translate:"
                        if (strpos($value_group, ':') !== false && strpos($value_group, 'translate:') !== 0) {
                            $temp = explode(':', $value_group, 2);
                            $values[$temp[0]] = rex_translate($temp[1]);
                        } else {
                            $values[$value_group] = rex_translate($value_group);
                        }
                    }
                    $select->addOptions($values);
                }
                $field .= $select->get();
                break;
            case 'date':
            case 'time':
            case 'datetime':
                $tag_attr = ' class="rex-form-select-date"';
                $active = $dbvalues[0] != 0;
                if ($dbvalues[0] == '') {
                    $dbvalues[0] = time();
                }
                $inputValue = array();
                $inputValue['year'] = date('Y', $dbvalues[0]);
                $inputValue['month'] = date('m', $dbvalues[0]);
                $inputValue['day'] = date('j', $dbvalues[0]);
                $inputValue['hour'] = date('G', $dbvalues[0]);
                $inputValue['minute'] = date('i', $dbvalues[0]);
                $rexInput = rex_input::factory($typeLabel);
                $rexInput->addAttributes($attrArray);
                $rexInput->setAttribute('id', $id);
                $rexInput->setAttribute('name', $name);
                $rexInput->setValue($inputValue);
                $field = $rexInput->getHtml();
                $checked = $active ? ' checked="checked"' : '';
                $field .= '<input class="rex-form-select-checkbox rex-metainfo-checkbox" type="checkbox" name="' . $name . '[active]" value="1"' . $checked . ' />';
                break;
            case 'textarea':
                $tag_attr = ' class="rex-form-textarea"';
                $rexInput = rex_input::factory($typeLabel);
                $rexInput->addAttributes($attrArray);
                $rexInput->setAttribute('id', $id);
                $rexInput->setAttribute('name', $name);
                if ($activeItem) {
                    $rexInput->setValue($activeItem->getValue($name));
                } else {
                    $rexInput->setValue($defaultValue);
                }
                $field = $rexInput->getHtml();
                break;
            case 'legend':
                $tag = '';
                $tag_attr = '';
                $labelIt = false;
                // tabindex entfernen, macht bei einer legend wenig sinn
                $attr = preg_replace('@tabindex="[^"]*"@', '', $attr);
                $field = '</div></fieldset><fieldset class="rex-form-col-1"><legend id="' . $id . '"' . $attr . '>' . $label . '</legend><div class="rex-form-wrapper">';
                break;
            case 'REX_MEDIA_BUTTON':
                $tag = 'div';
                $tag_attr = ' class="rex-form-widget"';
                $paramArray = rex_split_string($params);
                $rexInput = rex_input::factory('mediabutton');
                $rexInput->addAttributes($attrArray);
                $rexInput->setButtonId($media_id);
                $rexInput->setAttribute('name', $name);
                $rexInput->setValue($dbvalues[0]);
                if (isset($paramArray['category'])) {
                    $rexInput->setCategoryId($paramArray['category']);
                }
                if (isset($paramArray['types'])) {
                    $rexInput->setTypes($paramArray['types']);
                }
                if (isset($paramArray['preview'])) {
                    $rexInput->setPreview($paramArray['preview']);
                }
                $id = $rexInput->getAttribute('id');
                $field = $rexInput->getHtml();
                $media_id++;
                break;
            case 'REX_MEDIALIST_BUTTON':
                $tag = 'div';
                $tag_attr = ' class="rex-form-widget"';
                $paramArray = rex_split_string($params);
                $name .= '[]';
                $rexInput = rex_input::factory('medialistbutton');
                $rexInput->addAttributes($attrArray);
                $rexInput->setButtonId($mlist_id);
                $rexInput->setAttribute('name', $name);
                $rexInput->setValue($dbvalues[0]);
                if (isset($paramArray['category'])) {
                    $rexInput->setCategoryId($paramArray['category']);
                }
                if (isset($paramArray['types'])) {
                    $rexInput->setTypes($paramArray['types']);
                }
                if (isset($paramArray['preview'])) {
                    $rexInput->setPreview($paramArray['preview']);
                }
                $id = $rexInput->getAttribute('id');
                $field = $rexInput->getHtml();
                $mlist_id++;
                break;
            case 'REX_LINK_BUTTON':
                $tag = 'div';
                $tag_attr = ' class="rex-form-widget"';
                $paramArray = rex_split_string($params);
                $category = '';
                if (isset($paramArray['category'])) {
                    $category = $paramArray['category'];
                } elseif ($activeItem) {
                    $category = $activeItem->getValue('category_id');
                }
                $rexInput = rex_input::factory('linkbutton');
                $rexInput->addAttributes($attrArray);
                $rexInput->setButtonId($link_id);
                $rexInput->setCategoryId($category);
                $rexInput->setAttribute('name', $name);
                $rexInput->setValue($dbvalues[0]);
                $id = $rexInput->getAttribute('id');
                $field = $rexInput->getHtml();
                $link_id++;
                break;
            case 'REX_LINKLIST_BUTTON':
                $tag = 'div';
                $tag_attr = ' class="rex-form-widget"';
                $paramArray = rex_split_string($params);
                $category = '';
                if (isset($paramArray['category'])) {
                    $category = $paramArray['category'];
                } elseif ($activeItem) {
                    $category = $activeItem->getValue('category_id');
                }
                $name .= '[]';
                $rexInput = rex_input::factory('linklistbutton');
                $rexInput->addAttributes($attrArray);
                $rexInput->setButtonId($llist_id);
                $rexInput->setCategoryId($category);
                $rexInput->setAttribute('name', $name);
                $rexInput->setValue(implode(',', $dbvalues));
                $id = $rexInput->getAttribute('id');
                $field = $rexInput->getHtml();
                $llist_id++;
                break;
            default:
                // ----- EXTENSION POINT
                list($field, $tag, $tag_attr, $id, $label, $labelIt) = rex_register_extension_point('A62_CUSTOM_FIELD', array($field, $tag, $tag_attr, $id, $label, $labelIt, 'values' => $dbvalues, 'rawvalues' => $dbvalues, 'type' => $typeLabel, 'sql' => $sqlFields));
        }
        $s .= rex_call_func($formatCallback, array($field, $tag, $tag_attr, $id, $label, $labelIt, $typeLabel), false);
    }
    return $s;
}
Example #3
0
 /**
  * Erstellt den nötigen HTML Code um ein Formular zu erweitern.
  *
  * @param rex_sql $sqlFields rex_sql-objekt, dass die zu verarbeitenden Felder enthält
  * @param array   $epParams  Array of all EP parameters
  *
  * @return string
  */
 public function renderMetaFields(rex_sql $sqlFields, array $epParams)
 {
     $s = '';
     // Startwert für MEDIABUTTON, MEDIALIST, LINKLIST zähler
     $media_id = 1;
     $mlist_id = 1;
     $link_id = 1;
     $llist_id = 1;
     $activeItem = isset($epParams['activeItem']) ? $epParams['activeItem'] : null;
     $sqlFields->reset();
     for ($i = 0; $i < $sqlFields->getRows(); $i++, $sqlFields->next()) {
         // Umschliessendes Tag von Label und Formularelement
         $tag = 'p';
         $tag_attr = '';
         $name = $sqlFields->getValue('name');
         $title = $sqlFields->getValue('title');
         $params = $sqlFields->getValue('params');
         $typeLabel = $sqlFields->getValue('label');
         $attr = $sqlFields->getValue('attributes');
         $dblength = $sqlFields->getValue('dblength');
         $attrArray = rex_string::split($attr);
         if (isset($attrArray['perm'])) {
             if (!rex::getUser()->hasPerm($attrArray['perm'])) {
                 continue;
             }
             unset($attrArray['perm']);
         }
         $defaultValue = $sqlFields->getValue('default');
         if ($activeItem) {
             $itemValue = $activeItem->getValue($name);
             if (strpos($itemValue, '|+|') !== false) {
                 // Alte notation mit |+| als Trenner
                 $dbvalues = explode('|+|', $activeItem->getValue($name));
             } else {
                 // Neue Notation mit | als Trenner
                 $dbvalues = explode('|', $activeItem->getValue($name));
             }
         } else {
             $dbvalues = (array) $sqlFields->getValue('default');
         }
         if ($title != '') {
             $label = rex_i18n::translate($title);
         } else {
             $label = htmlspecialchars($name);
         }
         $id = preg_replace('/[^a-zA-Z\\-0-9_]/', '_', $label);
         $labelIt = true;
         $label = '<label for="' . $id . '">' . $label . '</label>';
         $field = '';
         switch ($typeLabel) {
             case 'text':
                 $tag_attr = ' class="form-control"';
                 $rexInput = rex_input::factory($typeLabel);
                 $rexInput->addAttributes($attrArray);
                 $rexInput->setAttribute('id', $id);
                 $rexInput->setAttribute('name', $name);
                 if ($dblength > 0) {
                     $rexInput->setAttribute('maxlength', $dblength);
                 }
                 if ($activeItem) {
                     $rexInput->setValue($activeItem->getValue($name));
                 } else {
                     $rexInput->setValue($defaultValue);
                 }
                 $field = $rexInput->getHtml();
                 $e = [];
                 $e['label'] = $label;
                 $e['field'] = $field;
                 $fragment = new rex_fragment();
                 $fragment->setVar('elements', [$e], false);
                 $field = $fragment->parse('core/form/form.php');
                 break;
             case 'checkbox':
                 // Beachte auch default values in multiple fields bei ADD.
                 // Im EDIT wurde dies bereits vorher gehandelt
                 if (!$activeItem) {
                     $defaultValue = explode('|', $defaultValue);
                 }
                 $name .= '[]';
             case 'radio':
                 $formElements = [];
                 $values = [];
                 if (rex_sql::getQueryType($params) == 'SELECT') {
                     $sql = rex_sql::factory();
                     $value_groups = $sql->getDBArray($params, [], PDO::FETCH_NUM);
                     foreach ($value_groups as $value_group) {
                         if (isset($value_group[1])) {
                             $values[$value_group[1]] = $value_group[0];
                         } else {
                             $values[$value_group[0]] = $value_group[0];
                         }
                     }
                 } else {
                     $value_groups = explode('|', $params);
                     foreach ($value_groups as $value_group) {
                         // check ob key:value paar
                         // und der wert beginnt nicht mit "translate:"
                         if (strpos($value_group, ':') !== false && strpos($value_group, 'translate:') !== 0) {
                             $temp = explode(':', $value_group, 2);
                             $values[$temp[0]] = rex_i18n::translate($temp[1]);
                         } else {
                             $values[$value_group] = rex_i18n::translate($value_group);
                         }
                     }
                 }
                 $oneValue = count($values) == 1;
                 $attrStr = '';
                 $classAdd = '';
                 $inline = false;
                 if (false !== ($key = array_search('inline', $attrArray))) {
                     $inline = true;
                     unset($attrArray[$key]);
                 }
                 foreach ($attrArray as $key => $value) {
                     if ($key == 'class') {
                         $classAdd = ' ' . $value;
                     } else {
                         $attrStr = ' ' . $key . '="' . $value . '"';
                     }
                 }
                 if (!$activeItem) {
                     $dbvalues = (array) $defaultValue;
                 }
                 foreach ($values as $key => $value) {
                     $id = preg_replace('/[^a-zA-Z\\-0-9_]/', '_', $id . $key);
                     // wenn man keine Werte angibt (Boolean Chkbox/Radio)
                     // Dummy Wert annehmen, damit an/aus unterscheidung funktioniert
                     if ($oneValue && $key == '') {
                         $key = 'true';
                     }
                     $selected = '';
                     if (in_array($key, $dbvalues)) {
                         $selected = ' checked="checked"';
                     }
                     $e = [];
                     if ($oneValue) {
                         $e['label'] = $label;
                     } else {
                         $e['label'] = '<label for="' . $id . '">' . htmlspecialchars($value) . '</label>';
                     }
                     $e['field'] = '<input type="' . $typeLabel . '" name="' . $name . '" value="' . htmlspecialchars($key) . '" id="' . $id . '" ' . $attrStr . $selected . ' />';
                     $formElements[] = $e;
                 }
                 $fragment = new rex_fragment();
                 $fragment->setVar('elements', $formElements, false);
                 $fragment->setVar('inline', $inline);
                 if ($typeLabel == 'radio') {
                     $field = $fragment->parse('core/form/radio.php');
                 } else {
                     if (!$oneValue) {
                         $fragment->setVar('grouped', true);
                     }
                     $field = $fragment->parse('core/form/checkbox.php');
                 }
                 if (!$oneValue) {
                     $e = [];
                     $e['label'] = $label;
                     $e['field'] = $field;
                     $fragment = new rex_fragment();
                     $fragment->setVar('elements', [$e], false);
                     $field = $fragment->parse('core/form/form.php');
                 }
                 break;
             case 'select':
                 $tag_attr = ' class="form-control"';
                 $select = new rex_select();
                 $select->setStyle('class="form-control"');
                 $select->setName($name);
                 $select->setId($id);
                 $multiple = false;
                 foreach ($attrArray as $attr_name => $attr_value) {
                     if (empty($attr_name)) {
                         continue;
                     }
                     $select->setAttribute($attr_name, $attr_value);
                     if ($attr_name == 'multiple') {
                         $multiple = true;
                         $select->setName($name . '[]');
                         $select->setMultiple();
                     }
                 }
                 // Beachte auch default values in multiple fields bei ADD.
                 // Im EDIT wurde dies bereits vorher gehandelt
                 if ($multiple && !$activeItem) {
                     $dbvalues = explode('|', $defaultValue);
                 }
                 // hier mit den "raw"-values arbeiten, da die rex_select klasse selbst escaped
                 $select->setSelected($dbvalues);
                 if (rex_sql::getQueryType($params) == 'SELECT') {
                     // Werte via SQL Laden
                     $select->addDBSqlOptions($params);
                 } else {
                     // Optionen mit | separiert
                     // eine einzelne Option kann mit key:value separiert werden
                     $values = [];
                     $value_groups = explode('|', $params);
                     foreach ($value_groups as $value_group) {
                         // check ob key:value paar
                         // und der wert beginnt nicht mit "translate:"
                         if (strpos($value_group, ':') !== false && strpos($value_group, 'translate:') !== 0) {
                             $temp = explode(':', $value_group, 2);
                             $values[$temp[0]] = rex_i18n::translate($temp[1]);
                         } else {
                             $values[$value_group] = rex_i18n::translate($value_group);
                         }
                     }
                     $select->addOptions($values);
                 }
                 $field .= $select->get();
                 $e = [];
                 $e['label'] = $label;
                 $e['field'] = $field;
                 $fragment = new rex_fragment();
                 $fragment->setVar('elements', [$e], false);
                 $field = $fragment->parse('core/form/form.php');
                 break;
             case 'date':
             case 'time':
             case 'datetime':
                 $tag_attr = ' class="form-control-date"';
                 $active = $dbvalues[0] != 0;
                 if ($dbvalues[0] == '') {
                     $dbvalues[0] = time();
                 }
                 $inputValue = [];
                 $inputValue['year'] = date('Y', $dbvalues[0]);
                 $inputValue['month'] = date('n', $dbvalues[0]);
                 $inputValue['day'] = date('j', $dbvalues[0]);
                 $inputValue['hour'] = date('G', $dbvalues[0]);
                 $inputValue['minute'] = date('i', $dbvalues[0]);
                 $rexInput = rex_input::factory($typeLabel);
                 $rexInput->addAttributes($attrArray);
                 $rexInput->setAttribute('id', $id);
                 $rexInput->setAttribute('name', $name);
                 $rexInput->setValue($inputValue);
                 $field = $rexInput->getHtml();
                 $checked = $active ? ' checked="checked"' : '';
                 $field .= '<input class="rex-metainfo-checkbox" type="checkbox" name="' . $name . '[active]" value="1"' . $checked . ' />';
                 $e = [];
                 $e['label'] = $label;
                 $e['field'] = $field;
                 $fragment = new rex_fragment();
                 $fragment->setVar('elements', [$e], false);
                 $field = $fragment->parse('core/form/form.php');
                 break;
             case 'textarea':
                 $tag_attr = ' class="form-control"';
                 $rexInput = rex_input::factory($typeLabel);
                 $rexInput->addAttributes($attrArray);
                 $rexInput->setAttribute('id', $id);
                 $rexInput->setAttribute('name', $name);
                 if ($activeItem) {
                     $rexInput->setValue($activeItem->getValue($name));
                 } else {
                     $rexInput->setValue($defaultValue);
                 }
                 $field = $rexInput->getHtml();
                 $e = [];
                 $e['label'] = $label;
                 $e['field'] = $field;
                 $fragment = new rex_fragment();
                 $fragment->setVar('elements', [$e], false);
                 $field = $fragment->parse('core/form/form.php');
                 break;
             case 'legend':
                 $tag = '';
                 $tag_attr = '';
                 $labelIt = false;
                 // tabindex entfernen, macht bei einer legend wenig sinn
                 $attr = preg_replace('@tabindex="[^"]*"@', '', $attr);
                 $field = '</fieldset><fieldset><legend id="' . $id . '"' . $attr . '>' . $label . '</legend>';
                 break;
             case 'REX_MEDIA_WIDGET':
                 $tag = 'div';
                 $tag_attr = ' class="rex-form-widget"';
                 $paramArray = rex_string::split($params);
                 $rexInput = rex_input::factory('mediabutton');
                 $rexInput->addAttributes($attrArray);
                 $rexInput->setButtonId($media_id);
                 $rexInput->setAttribute('name', $name);
                 $rexInput->setValue($dbvalues[0]);
                 if (isset($paramArray['category'])) {
                     $rexInput->setCategoryId($paramArray['category']);
                 }
                 if (isset($paramArray['types'])) {
                     $rexInput->setTypes($paramArray['types']);
                 }
                 if (isset($paramArray['preview'])) {
                     $rexInput->setPreview($paramArray['preview']);
                 }
                 $id = $rexInput->getAttribute('id');
                 $field = $rexInput->getHtml();
                 $e = [];
                 $e['label'] = $label;
                 $e['field'] = $field;
                 $fragment = new rex_fragment();
                 $fragment->setVar('elements', [$e], false);
                 $field = $fragment->parse('core/form/form.php');
                 ++$media_id;
                 break;
             case 'REX_MEDIALIST_WIDGET':
                 $tag = 'div';
                 $tag_attr = ' class="rex-form-widget"';
                 $paramArray = rex_string::split($params);
                 $name .= '[]';
                 $rexInput = rex_input::factory('medialistbutton');
                 $rexInput->addAttributes($attrArray);
                 $rexInput->setButtonId($mlist_id);
                 $rexInput->setAttribute('name', $name);
                 $rexInput->setValue($dbvalues[0]);
                 if (isset($paramArray['category'])) {
                     $rexInput->setCategoryId($paramArray['category']);
                 }
                 if (isset($paramArray['types'])) {
                     $rexInput->setTypes($paramArray['types']);
                 }
                 if (isset($paramArray['preview'])) {
                     $rexInput->setPreview($paramArray['preview']);
                 }
                 $id = $rexInput->getAttribute('id');
                 $field = $rexInput->getHtml();
                 $e = [];
                 $e['label'] = $label;
                 $e['field'] = $field;
                 $fragment = new rex_fragment();
                 $fragment->setVar('elements', [$e], false);
                 $field = $fragment->parse('core/form/form.php');
                 ++$mlist_id;
                 break;
             case 'REX_LINK_WIDGET':
                 $tag = 'div';
                 $tag_attr = ' class="rex-form-widget"';
                 $paramArray = rex_string::split($params);
                 $category = '';
                 if (isset($paramArray['category'])) {
                     $category = $paramArray['category'];
                 } elseif ($activeItem) {
                     $category = $activeItem->getValue('category_id');
                 }
                 $rexInput = rex_input::factory('linkbutton');
                 $rexInput->addAttributes($attrArray);
                 $rexInput->setButtonId($link_id);
                 $rexInput->setCategoryId($category);
                 $rexInput->setAttribute('name', $name);
                 $rexInput->setValue($dbvalues[0]);
                 $id = $rexInput->getAttribute('id');
                 $field = $rexInput->getHtml();
                 $e = [];
                 $e['label'] = $label;
                 $e['field'] = $field;
                 $fragment = new rex_fragment();
                 $fragment->setVar('elements', [$e], false);
                 $field = $fragment->parse('core/form/form.php');
                 ++$link_id;
                 break;
             case 'REX_LINKLIST_WIDGET':
                 $tag = 'div';
                 $tag_attr = ' class="rex-form-widget"';
                 $paramArray = rex_string::split($params);
                 $category = '';
                 if (isset($paramArray['category'])) {
                     $category = $paramArray['category'];
                 } elseif ($activeItem) {
                     $category = $activeItem->getValue('category_id');
                 }
                 $name .= '[]';
                 $rexInput = rex_input::factory('linklistbutton');
                 $rexInput->addAttributes($attrArray);
                 $rexInput->setButtonId($llist_id);
                 $rexInput->setCategoryId($category);
                 $rexInput->setAttribute('name', $name);
                 $rexInput->setValue(implode(',', $dbvalues));
                 $id = $rexInput->getAttribute('id');
                 $field = $rexInput->getHtml();
                 $e = [];
                 $e['label'] = $label;
                 $e['field'] = $field;
                 $fragment = new rex_fragment();
                 $fragment->setVar('elements', [$e], false);
                 $field = $fragment->parse('core/form/form.php');
                 ++$llist_id;
                 break;
             default:
                 // ----- EXTENSION POINT
                 list($field, $tag, $tag_attr, $id, $label, $labelIt) = rex_extension::registerPoint(new rex_extension_point('METAINFO_CUSTOM_FIELD', [$field, $tag, $tag_attr, $id, $label, $labelIt, 'values' => $dbvalues, 'rawvalues' => $dbvalues, 'type' => $typeLabel, 'sql' => $sqlFields]));
         }
         $s .= $this->renderFormItem($field, $tag, $tag_attr, $id, $label, $labelIt, $typeLabel);
     }
     return $s;
 }
Example #4
0
 $content = '';
 $submit_message = rex_i18n::msg('setup_410');
 if (count($error_array) > 0) {
     $submit_message = rex_i18n::msg('setup_414');
 }
 $content .= '
         <fieldset>
             <input type="hidden" name="page" value="setup" />
             <input type="hidden" name="step" value="5" />
             <input type="hidden" name="lang" value="' . $lang . '" />';
 $timezone_sel = new rex_select();
 $timezone_sel->setId('rex-form-timezone');
 $timezone_sel->setStyle('class="form-control"');
 $timezone_sel->setName('timezone');
 $timezone_sel->setSize(1);
 $timezone_sel->addOptions(DateTimeZone::listIdentifiers(), true);
 $timezone_sel->setSelected($config['timezone']);
 $db_create_checked = rex_post('redaxo_db_create', 'boolean') ? ' checked="checked"' : '';
 $content .= '<legend>' . rex_i18n::msg('setup_402') . '</legend>';
 $formElements = [];
 $n = [];
 $n['label'] = '<label for="rex-form-serveraddress">' . rex_i18n::msg('server') . '</label>';
 $n['field'] = '<input class="form-control" type="text" id="rex-form-serveraddress" name="serveraddress" value="' . $config['server'] . '" autofocus />';
 $formElements[] = $n;
 $n = [];
 $n['label'] = '<label for="rex-form-servername">' . rex_i18n::msg('servername') . '</label>';
 $n['field'] = '<input class="form-control" type="text" id="rex-form-servername" name="servername" value="' . $config['servername'] . '" />';
 $formElements[] = $n;
 $n = [];
 $n['label'] = '<label for="rex-form-error-email">' . rex_i18n::msg('error_email') . '</label>';
 $n['field'] = '<input class="form-control" type="text" id="rex-form-error-email" name="error_email" value="' . $config['error_email'] . '" />';
Example #5
0
// ----- welche startseite
$sel_startpage = new rex_select();
$sel_startpage->setSize(1);
$sel_startpage->setName('userperm_startpage');
$sel_startpage->setId('rex-user-perm-startpage');
$sel_startpage->setAttribute('class', 'form-control');
$sel_startpage->addOption('default', '');
$startpages = [];
foreach (rex_be_controller::getPages() as $page => $pageObj) {
    /* @var $pageObj rex_be_page */
    if ($pageObj->hasNavigation() && !$pageObj->isHidden()) {
        $startpages[$page] = $pageObj->getTitle();
    }
}
asort($startpages);
$sel_startpage->addOptions($startpages);
$userperm_startpage = rex_request('userperm_startpage', 'string');
// --------------------------------- Title
// --------------------------------- FUNCTIONS
$FUNC_UPDATE = '';
$FUNC_APPLY = '';
$FUNC_DELETE = '';
if ($user_id != 0 && (rex::getUser()->isAdmin() || !$sql->getValue('admin'))) {
    $FUNC_UPDATE = rex_request('FUNC_UPDATE', 'string');
    $FUNC_APPLY = rex_request('FUNC_APPLY', 'string');
    $FUNC_DELETE = rex_request('FUNC_DELETE', 'string');
} else {
    $user_id = 0;
}
$FUNC_ADD = rex_request('FUNC_ADD', 'string');
$save = rex_request('save', 'int');
/**
 * Erstellt den nötigen HTML Code um ein Formular zu erweitern
 *
 * @param $sqlFields rex_sql-objekt, dass die zu verarbeitenden Felder enthält
 * @param $activeItem objekt, dass mit getValue() die Werte des akuellen Eintrags zurückgibt
 * @param $formatCallback callback, dem die infos als Array übergeben werden und den formatierten HTML Text zurückgibt
 */
function rex_a62_metaFields($sqlFields, $activeItem, $formatCallback, $epParams)
{
    global $I18N;
    $s = '';
    // Startwert für MEDIABUTTON, MEDIALIST, LINKLIST
    $media_id = 1;
    $mlist_id = 1;
    $link_id = 1;
    $sqlFields->reset();
    for ($i = 0; $i < $sqlFields->getRows(); $i++) {
        // Umschliessendes Tag von Label und Formularelement
        $tag = 'p';
        $tag_attr = '';
        $name = $sqlFields->getValue('name');
        $title = $sqlFields->getValue('title');
        $params = $sqlFields->getValue('params');
        $typeLabel = $sqlFields->getValue('label');
        $attr = $sqlFields->getValue('attributes');
        $dbvalues = array('');
        if ($activeItem) {
            $dbvalues = explode('|+|', $activeItem->getValue($name));
        }
        if ($title != '') {
            $label = rex_translate($title);
        } else {
            $label = htmlspecialchars($name);
        }
        $id = preg_replace('/[^a-zA-Z\\-0-9_]/', '_', $label);
        $attr .= rex_tabindex();
        $labelIt = true;
        $field = '';
        switch ($typeLabel) {
            case 'text':
                $field = '<input type="' . $sqlFields->getValue('label') . '" name="' . $name . '" value="' . $dbvalues[0] . '" id="' . $id . '" ' . $attr . ' />';
                break;
            case 'checkbox':
                $name .= '[]';
            case 'radio':
                $values = array();
                if (rex_sql::getQueryType($params) == 'SELECT') {
                    $sql = new rex_sql();
                    $value_groups = $sql->getDBArray($params, MYSQL_NUM);
                    foreach ($value_groups as $value_group) {
                        if (isset($value_group[1])) {
                            $values[$value_group[1]] = $value_group[0];
                        } else {
                            $values[$value_group[0]] = $value_group[0];
                        }
                    }
                } else {
                    $value_groups = explode('|', $params);
                    foreach ($value_groups as $value_group) {
                        if (strpos($value_group, ':') !== false) {
                            $temp = explode(':', $value_group);
                            $values[$temp[0]] = $temp[1];
                        } else {
                            $values[$value_group] = $value_group;
                        }
                    }
                }
                //        if($epParams['extension_point'] != 'CAT_META_FORM_EDIT')
                //          $field .= '<span>'. $label .'</span>';
                $class = $typeLabel == 'radio' ? 'rex-rdo' : 'rex-chckbx';
                $oneValue = count($values) == 1;
                if (!$oneValue) {
                    $tag = '';
                    $labelIt = false;
                    $tag = 'div';
                    $tag_attr = ' class="rex-chckbxs rex-ptag"';
                    $field .= '<p>' . $label . '</p>';
                }
                foreach ($values as $key => $value) {
                    $id = preg_replace('/[^a-zA-Z\\-0-9_]/', '_', $id . $key);
                    // wenn man keine Werte angibt (Boolean Chkbox/Radio)
                    // Dummy Wert annehmen, damit an/aus unterscheidung funktioniert
                    if ($oneValue && $key == '') {
                        $key = 'true';
                    }
                    $selected = '';
                    if (in_array($key, $dbvalues)) {
                        $selected = ' checked="checked"';
                    }
                    if ($oneValue) {
                        $tag_attr = ' class="' . $class . '"';
                        $field .= '<input type="' . $typeLabel . '" name="' . $name . '" value="' . $key . '" id="' . $id . '" ' . $attr . $selected . ' />' . "\n";
                    } else {
                        $field .= '<p class="' . $class . '">' . "\n";
                        $field .= '<label for="' . $id . '"><span>' . htmlspecialchars($value) . '</span></label>';
                        $field .= '<input type="' . $typeLabel . '" name="' . $name . '" value="' . $key . '" id="' . $id . '" ' . $attr . $selected . ' />' . "\n";
                        $field .= '</p>' . "\n";
                    }
                }
                break;
            case 'select':
                $select = new rex_select();
                $select->setName($name);
                $select->setId($id);
                $select->setSelected($dbvalues);
                foreach (explode(' ', $attr) as $pair) {
                    if (strpos($pair, '=') === false) {
                        continue;
                    }
                    $temp = explode('=', $pair);
                    $select->setAttribute($temp[0], str_replace(array('"', "'"), '', $temp[1]));
                    if ($temp[0] == 'multiple') {
                        $select->setName($name . '[]');
                    }
                }
                if (rex_sql::getQueryType($params) == 'SELECT') {
                    $select->addDBSqlOptions($params);
                } else {
                    $values = array();
                    $value_groups = explode('|', $params);
                    foreach ($value_groups as $value_group) {
                        if (strpos($value_group, ':') !== false) {
                            $temp = explode(':', $value_group);
                            $values[$temp[0]] = $temp[1];
                        } else {
                            $values[$value_group] = $value_group;
                        }
                    }
                    $select->addOptions($values);
                }
                $field .= $select->get();
                break;
            case 'datetime':
            case 'date':
                if ($dbvalues[0] == '') {
                    $dbvalues[0] = time();
                }
                $style = 'class="rex-fdate"';
                $yearStyle = 'class="rex-fdatey"';
                $yearSelect = new rex_select();
                $yearSelect->addOptions(range(2005, date('Y') + 2), true);
                $yearSelect->setName($name . '[year]');
                $yearSelect->setSize(1);
                $yearSelect->setId($id);
                $yearSelect->setStyle($yearStyle);
                $yearSelect->setSelected(date('Y', $dbvalues[0]));
                $monthSelect = new rex_select();
                $monthSelect->addOptions(range(1, 12), true);
                $monthSelect->setName($name . '[month]');
                $monthSelect->setSize(1);
                $monthSelect->setStyle($style);
                $monthSelect->setSelected(date('m', $dbvalues[0]));
                $daySelect = new rex_select();
                $daySelect->addOptions(range(1, 31), true);
                $daySelect->setName($name . '[day]');
                $daySelect->setSize(1);
                $daySelect->setStyle($style);
                $daySelect->setSelected(date('j', $dbvalues[0]));
                if ($typeLabel == 'datetime') {
                    $hourSelect = new rex_select();
                    $hourSelect->addOptions(range(1, 23), true);
                    $hourSelect->setName($name . '[hour]');
                    $hourSelect->setSize(1);
                    $hourSelect->setStyle($style);
                    $hourSelect->setSelected(date('G', $dbvalues[0]));
                    $minuteSelect = new rex_select();
                    $minuteSelect->addOptions(range(0, 59), true);
                    $minuteSelect->setName($name . '[minute]');
                    $minuteSelect->setSize(1);
                    $minuteSelect->setStyle($style);
                    $minuteSelect->setSelected(date('i', $dbvalues[0]));
                    $field = $daySelect->get() . $monthSelect->get() . $yearSelect->get() . '-' . $hourSelect->get() . $minuteSelect->get();
                } else {
                    $field = $daySelect->get() . $monthSelect->get() . $yearSelect->get();
                }
                break;
            case 'textarea':
                $field = '<textarea name="' . $name . '" id="' . $id . '" ' . $attr . ' cols="50" rows="6">' . $dbvalues[0] . '</textarea>';
                break;
            case 'REX_MEDIA_BUTTON':
                $tag = 'div';
                $tag_attr = ' class="rex-ptag"';
                $field = rex_var_media::getMediaButton($media_id);
                $field = str_replace('REX_MEDIA[' . $media_id . ']', $dbvalues[0], $field);
                $field = str_replace('MEDIA[' . $media_id . ']', $name, $field);
                $id = 'REX_MEDIA_' . $media_id;
                $media_id++;
                break;
            case 'REX_MEDIALIST_BUTTON':
                $tag = 'div';
                $tag_attr = ' class="rex-ptag"';
                $name .= '[]';
                $field = rex_var_media::getMediaListButton($mlist_id, implode(',', $dbvalues));
                $field = str_replace('MEDIALIST[' . $mlist_id . ']', $name, $field);
                $id = 'REX_MEDIALIST_' . $mlist_id;
                $mlist_id++;
                break;
            case 'REX_LINK_BUTTON':
                $tag = 'div';
                $tag_attr = ' class="rex-ptag"';
                $category = '';
                if ($activeItem) {
                    $category = $activeItem->getValue('category_id');
                }
                $field = rex_var_link::getLinkButton($link_id, $dbvalues[0], $category);
                $field = str_replace('LINK[' . $link_id . ']', $name, $field);
                $id = 'LINK_' . $link_id;
                $link_id++;
                break;
        }
        $s .= rex_call_func($formatCallback, array($field, $tag, $tag_attr, $id, $label, $labelIt), false);
        $sqlFields->next();
    }
    return $s;
}
    $bildposition->addOptions(array('oben' => 'über dem Text', 'unten' => 'unter dem Text', 'nachueberschrift' => 'unter der Überschrift', 'nachteaser' => 'unter dem Teasertext'));
    $bildanpassen = new rex_select();
    $bildanpassen->setName('REX_INPUT_VALUE[' . $i . '][bildanpassen]');
    $bildanpassen->setSelected(isset($values[$i]['bildanpassen']) ? $values[$i]['bildanpassen'] : '');
    $bildanpassen->setSize(1);
    $bildanpassen->addOptions(array('ja' => 'ja', 'nein' => 'nein'));
    $ueberschriftlink = new rex_select();
    $ueberschriftlink->setName('REX_INPUT_VALUE[' . $i . '][ueberschriftlink]');
    $ueberschriftlink->setSelected(isset($values[$i]['ueberschriftlink']) ? $values[$i]['ueberschriftlink'] : '');
    $ueberschriftlink->setSize(1);
    $ueberschriftlink->addOptions(array('nein' => 'nein', 'ja' => 'ja'));
    $bildlink = new rex_select();
    $bildlink->setName('REX_INPUT_VALUE[' . $i . '][bildlink]');
    $bildlink->setSelected(isset($values[$i]['bildlink']) ? $values[$i]['bildlink'] : '');
    $bildlink->setSize(1);
    $bildlink->addOptions(array('nein' => 'nein', 'ja' => 'ja'));
    echo '
<div id="bereich' . $i . '" class="tab-pane fade in">
  <div class="form-horizontal">' . PHP_EOL;
    //
    // Überschriften
    //
    if ($anzeige_ueberschriften) {
        echo '
     <h3>Überschrift</h3>

     <div class="form-group">
        <label class="col-sm-3 control-label">Überschrift</label>
          <div class="col-sm-9">
            <input class="form-control" name="REX_INPUT_VALUE[' . $i . '][ueberschrift]" value="' . (isset($values[$i]['ueberschrift']) ? $values[$i]['ueberschrift'] : '') . '" type="text" />
          </div>
 } else {
     if ($this->relation['relation_type'] == 2) {
         $e['field'] = '<input class="form-control" type="text" name="yform_MANAGER_DATANAME[' . $this->getId() . ']" value="' . htmlspecialchars($valueName) . '" id="yform_MANAGER_DATANAME_' . $this->getId() . '" readonly="readonly" /><input type="hidden" name="' . $this->getFieldName() . '" id="yform_MANAGER_DATA_' . $this->getId() . '" value="' . implode(',', $this->getValue()) . '" />';
         $e['functionButtons'] = '
             <a href="javascript:void(0);" class="btn btn-popup" onclick="yform_manager_openDatalist(' . $this->getId() . ', \'' . $this->relation['source_table'] . '.' . $this->getName() . '\', \'' . $link . '\',\'0\');return false;" title="' . rex_i18n::msg('yform_relation_choose_entry') . '"><i class="rex-icon rex-icon-add"></i></a>
             <a href="javascript:void(0);" class="btn btn-popup" onclick="yform_manager_deleteDatalist(' . $this->getId() . ',\'0\');return false;" title="' . rex_i18n::msg('yform_relation_delete_entry') . '"><i class="rex-icon rex-icon-remove"></i></a>';
         $fragment = new rex_fragment();
         $fragment->setVar('elements', [$e], false);
         echo $fragment->parse('core/form/widget.php');
     } else {
         $select = new rex_select();
         $select->setStyle('class="form-control"');
         $select->setId('yform_MANAGER_DATALIST_SELECT_' . $this->getId() . '');
         $select->setName('yform_MANAGER_DATALIST_SELECT' . $this->getId() . '');
         $select->setSize($this->relation['size']);
         $select->addOptions($options);
         $e['field'] = $select->get() . '<input type="hidden" name="' . $this->getFieldName() . '" id="yform_MANAGER_DATALIST_' . $this->getId() . '" value="' . implode(',', $this->getValue()) . '" />';
         $e['moveButtons'] = '
             <a href="javascript:void(0);" class="btn btn-popup" onclick="yform_manager_moveDatalist(' . $this->getId() . ',\'top\');return false;" title="' . rex_i18n::msg('yform_relation_move_first_data') . '"><i class="rex-icon rex-icon-top"></i></a>
             <a href="javascript:void(0);" class="btn btn-popup" onclick="yform_manager_moveDatalist(' . $this->getId() . ',\'up\');return false;" title="' . rex_i18n::msg('yform_relation_move_up_data') . '>"><i class="rex-icon rex-icon-up"></i></a>
             <a href="javascript:void(0);" class="btn btn-popup" onclick="yform_manager_moveDatalist(' . $this->getId() . ',\'down\');return false;" title="' . rex_i18n::msg('yform_relation_down_first_data') . '"><i class="rex-icon rex-icon-down"></i></a>
             <a href="javascript:void(0);" class="btn btn-popup" onclick="yform_manager_moveDatalist(' . $this->getId() . ',\'bottom\');return false;" title="' . rex_i18n::msg('yform_relation_move_last_data') . '"><i class="rex-icon rex-icon-bottom"></i></a>';
         $e['functionButtons'] = '
             <a href="javascript:void(0);" class="btn btn-popup" onclick="yform_manager_openDatalist(' . $this->getId() . ', \'' . $this->relation['source_table'] . ' . ' . $this->getName() . '\', \'' . $link . '\',\'1\');return false;" title="' . rex_i18n::msg('yform_relation_choose_entry') . '"><i class="rex-icon rex-icon-add"></i></a>
             <a href="javascript:void(0);" class="btn btn-popup" onclick="yform_manager_deleteDatalist(' . $this->getId() . ',\'1\');return false;" title="' . rex_i18n::msg('yform_relation_delete_entry') . '"><i class="rex-icon rex-icon-remove"></i></a>
         ';
         $fragment = new rex_fragment();
         $fragment->setVar('elements', [$e], false);
         echo $fragment->parse('core/form/widget_list.php');
     }
 }