function getFieldPage() { global $REX, $I18N; // ********************************************* FIELD ADD/EDIT/LIST $func = rex_request('func', 'string', 'list'); $page = rex_request('page', 'string', ''); $subpage = rex_request('subpage', 'string', ''); $tripage = rex_request('tripage', 'string', ''); $type_id = rex_request('type_id', 'string'); $type_name = rex_request('type_name', 'string'); $field_id = rex_request('field_id', 'int'); $show_list = true; $link_vars = ''; foreach ($this->getLinkVars() as $k => $v) { $link_vars .= '&' . urlencode($k) . '=' . urlencode($v); } $TYPE = array('value' => $I18N->msg('xform_values'), 'validate' => $I18N->msg('xform_validates'), 'action' => $I18N->msg('xform_action')); // ********************************** TABELLE HOLEN $table = $this->table; $table_info = '<b>' . rex_translate($table->getName()) . ' [' . $table->getTableName() . ']</b> '; echo rex_content_block($table_info); // ********************************************* Missing Fields $mfields = $table->getMissingFields(); // ksort($mfields); $type_real_field = rex_request('type_real_field', 'string'); if ($type_real_field != '' && !array_key_exists($type_real_field, $mfields)) { $type_real_field = ''; } if ($type_real_field != '') { ?> <div class="rex-addon-output"><h2 class="rex-hl2">Folgendes Feld wird verwendet: <?php echo $type_real_field; ?> </h2><div class="rex-addon-content"><p class="rex-tx1"><?php $rfields = $this->table->getColumns(); foreach ($rfields[$type_real_field] as $k => $v) { echo '<b>' . $k . ':</b> ' . $v . '<br />'; } ?> </p></div></div><?php } // ********************************************* CHOOSE FIELD $types = rex_xform::getTypeArray(); if ($func == 'choosenadd') { // type and choose !! $link = 'index.php?' . $link_vars . '&table_name=' . $table->getTableName() . '&func=add&'; if (!$table->hasId()) { ?> <div class="rex-addon-output" id="xform-choosenadd"><h2 class="rex-hl2"><?php echo $I18N->msg('xform_id_is_missing'); ?> </h2><div class="rex-addon-content"> <p class="rex-tx1"><?php echo $I18N->msg('xform_id_missing_info'); ?> </p> </div></div> <?php } else { ?> <div class="rex-addon-output" id="xform-choosenadd"><h2 class="rex-hl2"><?php echo $I18N->msg('xform_choosenadd'); ?> </h2><div class="rex-addon-content"> <p class="rex-tx1"><?php echo $I18N->msg('xform_choosenadd_description'); ?> </p> </div></div> <?php if ($type_real_field == '' && count($mfields) > 0) { ?> <div class="rex-addon-output"><h2 class="rex-hl2">Es gibt noch Felder in der Tabelle welche nicht zugewiesen sind.</h2><div class="rex-addon-content"> <?php $d = 0; foreach ($mfields as $k => $v) { $d++; $l = 'index.php?' . $link_vars . '&table_name=' . $table->getTableName() . '&func=choosenadd&type_real_field=' . $k . '&type_layout=t'; echo '<a href="' . $l . '">' . $k . '</a>, '; } ?> </div></div> <?php } ?> <div class="rex-addon-output xform-table_field"> <div class="rex-area-col-2"> <div class="rex-area-col-a"> <h3 class="rex-hl2">beliebte <?php echo $TYPE['value']; ?> </h3> <div class="rex-area-content"><p class="rex-tx1"><?php if (isset($types['value'])) { ksort($types['value']); foreach ($types['value'] as $k => $v) { if (isset($v['famous']) && $v['famous']) { echo '<p class="rex-button"><a class="rex-button" href="' . $link . 'type_id=value&type_name=' . $k . '&type_real_field=' . $type_real_field . '">' . $k . '</a> <span>' . $v['description'] . '</span></p>'; } } } ?> </p></div></div> <div class="rex-area-col-b"><h3 class="rex-hl2">beliebte <?php echo $TYPE['validate']; ?> </h3><div class="rex-area-content"><p class="rex-tx1"><?php if (isset($types['validate'])) { ksort($types['validate']); foreach ($types['validate'] as $k => $v) { if (isset($v['famous']) && $v['famous']) { echo '<p class="rex-button"><a class="rex-button" href="' . $link . 'type_id=validate&type_name=' . $k . '">' . $k . '</a> <span>' . $v['description'] . '</span></p>'; } } } ?> </p></div></div> </div></div> <div class="rex-addon-output xform-table_field"> <div class="rex-area-col-2"> <div class="rex-area-col-a"><h3 class="rex-hl2"><?php echo $TYPE['value']; ?> </h3><div class="rex-area-content"><p class="rex-tx1"><?php if (isset($types['value'])) { ksort($types['value']); foreach ($types['value'] as $k => $v) { if (!isset($v['famous']) || $v['famous'] !== true) { echo '<p class="rex-button"><a class="rex-button" href="' . $link . 'type_id=value&type_name=' . $k . '&type_real_field=' . $type_real_field . '">' . $k . '</a> <span>' . $v['description'] . '</span></p>'; } } } ?> </p></div></div> <div class="rex-area-col-b"><h3 class="rex-hl2"><?php echo $TYPE['validate']; ?> </h3><div class="rex-area-content"><p class="rex-tx1"><?php if (isset($types['validate'])) { ksort($types['validate']); foreach ($types['validate'] as $k => $v) { if (!isset($v['famous']) || $v['famous'] !== true) { echo '<p class="rex-button"><a class="rex-button" href="' . $link . 'type_id=validate&type_name=' . $k . '">' . $k . '</a> <span>' . $v['description'] . '</span></p>'; } } } ?> </p></div></div> </div></div> <!-- <div class="rex-addon-output"> <h2 class="rex-hl2"><?php echo $TYPE['action']; ?> </h2> <div class="rex-addon-content"> <p class="rex-tx1"><?php if (isset($types['action'])) { ksort($types['action']); foreach ($types['action'] as $k => $v) { echo '<p class="rex-button">"<a href="' . $link . 'type_id=action&type_name=' . $k . '">' . $k . '</a>" - ' . $v['description'] . '</p>'; } } ?> </p> </div> </div> --> <?php } $table_echo = '<a href="index.php?' . $link_vars . '&table_name=' . $table->getTableName() . '"><b>« ' . $I18N->msg('xform_back_to_overview') . '</b></a>'; echo rex_content_block($table_echo); } // ********************************************* FORMULAR if (($func == 'add' || $func == 'edit') && isset($types[$type_id][$type_name])) { $xform = new rex_xform(); $xform->setDebug(false); foreach ($this->getLinkVars() as $k => $v) { $xform->setHiddenField($k, $v); } $xform->setHiddenField('func', $func); $xform->setHiddenField('table_name', $table->getTableName()); $xform->setHiddenField('type_real_field', $type_real_field); $xform->setHiddenField('list', rex_request('list', 'string')); $xform->setHiddenField('sort', rex_request('sort', 'string')); $xform->setHiddenField('sorttype', rex_request('sorttype', 'string')); $xform->setHiddenField('start', rex_request('start', 'string')); $xform->setValueField('hidden', array('table_name', $table->getTableName())); $xform->setValueField('hidden', array('type_name', $type_name, 'REQUEST')); $xform->setValueField('hidden', array('type_id', $type_id, 'REQUEST')); $xform->setValueField('prio', array('prio', 'Prioritaet', array('name', 'type_id', 'type_name'), array('table_name'))); $selectFields = array(); $i = 1; foreach ($types[$type_id][$type_name]['values'] as $k => $v) { $field = $this->getFieldName($k, $type_id); $selectFields['f' . $i] = $field; $i++; switch ($v['type']) { case 'name': if ($func == 'edit') { $xform->setValueField('showvalue', array($field, 'Name')); } else { if (!isset($v['value']) && $type_real_field != '') { $v['value'] = $type_real_field; } elseif (!isset($v['value'])) { $v['value'] = ''; } $xform->setValueField('text', array($field, 'Name', $v['value'])); $xform->setValidateField('notEmpty', array($field, $I18N->msg('xform_validatenamenotempty'))); $xform->setValidateField('preg_match', array($field, "/(([a-zA-Z])+([a-zA-Z0-9\\_])*)/", $I18N->msg('xform_validatenamepregmatch'))); $xform->setValidateField('customfunction', array($field, 'rex_xform_manager_checkField', array('table_name' => $table->getTableName()), $I18N->msg('xform_validatenamecheck'))); } break; case 'no_db': if (!isset($v['default']) || $v['default'] != 1) { $v['default'] = 0; } $xform->setValueField('checkbox', array($field, $I18N->msg('xform_donotsaveindb'), 'no_db', $v['default'])); break; case 'boolean': // checkbox|check_design|Bezeichnung|Value|1/0|[no_db] if (!isset($v['default'])) { $v['default'] = ''; } $xform->setValueField('checkbox', array($field, $v['label'], '', $v['default'])); break; case 'select': // select|gender|Geschlecht *|Frau=w;Herr=m|[no_db]|defaultwert|multiple=1 $xform->setValueField('select', array($field, $v['label'], $v['options'], '', $v['default'], 0)); break; case 'table': // ist fest eingetragen, damit keine Dinge durcheinandergehen if ($func == 'edit') { $xform->setValueField('showvalue', array($field, $v['label'])); } else { $_tables = rex_xform_manager_table::getAll(); $_options = array(); if (isset($v['empty_option']) && $v['empty_option']) { $_options[0] = '–='; } foreach ($_tables as $_table) { $_options[$_table['table_name']] = str_replace('=', '-', rex_translate($_table['name']) . ' [' . $_table['table_name'] . ']') . '=' . $_table['table_name']; $_options[$_table['table_name']] = str_replace(',', '.', $_options[$_table['table_name']]); } if (!isset($v['default'])) { $v['default'] = ''; } $xform->setValueField('select', array($field, $v['label'], implode(',', $_options), '', $v['default'], 0)); } break; case 'textarea': $xform->setValueField('textarea', array($field, $v['label'])); break; case 'table.field': // Todo: // Todo: case 'select_name': $_fields = array(); foreach ($table->getValueFields() as $_k => $_v) { $_fields[] = $_k; } $xform->setValueField('select', array($field, $v['label'], implode(',', $_fields), '', '', 0)); break; case 'select_names': $_fields = array(); foreach ($table->getValueFields() as $_k => $_v) { $_fields[] = $_k; } $xform->setValueField('select', array($field, $v['label'], implode(',', $_fields), '', '', 1, 5)); break; default: // nur beim "Bezeichnungsfeld" if ($field == 'label' && $type_real_field != '' && !isset($v['value'])) { $v['value'] = $type_real_field; } elseif (!isset($v['value'])) { $v['value'] = ''; } $xform->setValueField('text', array($field, $v['label'], $v['value'])); } } $xform->setActionField('showtext', array('', '<p>' . $I18N->msg('xform_thankyouforentry') . '</p>')); $xform->setObjectparams('main_table', rex_xform_manager_field::table()); if ($func == 'edit') { $xform->setObjectparams('submit_btn_label', $I18N->msg('xform_save')); $xform->setHiddenField('field_id', $field_id); $xform->setActionField('manage_db', array(rex_xform_manager_field::table(), "id={$field_id}")); $xform->setObjectparams('main_id', $field_id); $xform->setObjectparams('main_where', "id={$field_id}"); $sql = rex_sql::factory(); $sql->setQuery('SELECT * FROM ' . rex_xform_manager_field::table() . " WHERE id={$field_id}"); foreach ($selectFields as $alias => $field) { if ($alias != $field) { if ((!$sql->hasValue($field) || null === $sql->getValue($field) || '' === $sql->getValue($field)) && $sql->hasValue($alias)) { $sql->setValue($field, $sql->getValue($alias)); } $xform->setValueField('hidden', array($alias, '')); } } $xform->setObjectparams('sql_object', $sql); $xform->setObjectparams('getdata', true); } elseif ($func == 'add') { $xform->setObjectparams('submit_btn_label', $I18N->msg('xform_add')); $xform->setActionField('manage_db', array(rex_xform_manager_field::table())); } if ($type_id == 'value') { $xform->setValueField('checkbox', array('list_hidden', $I18N->msg('xform_hideinlist'), 1, '1')); $xform->setValueField('checkbox', array('search', $I18N->msg('xform_useassearchfieldalidatenamenotempty'), 1, '1')); } elseif ($type_id == 'validate') { $xform->setValueField('hidden', array('list_hidden', 1)); } $form = $xform->getForm(); if ($xform->objparams['form_show']) { if ($func == 'add') { echo '<div class="rex-addon-output"><h3 class="rex-hl2">' . $I18N->msg('xform_addfield') . ' "' . $type_name . '"</h3><div class="rex-addon-content">'; } else { echo '<div class="rex-addon-output"><h3 class="rex-hl2">' . $I18N->msg('xform_editfield') . ' "' . $type_name . '"</h3><div class="rex-addon-content">'; } echo $form; echo '</div></div>'; $table_echo = '<a href="index.php?' . $link_vars . '&table_name=' . $table->getTableName() . '"><b>« ' . $I18N->msg('xform_back_to_overview') . '</b></a>'; echo rex_content_block($table_echo); $func = ''; } else { if ($func == 'edit') { $this->generateAll(); echo rex_info($I18N->msg('xform_thankyouforupdate')); } elseif ($func == 'add') { $this->generateAll(); echo rex_info($I18N->msg('xform_thankyouforentry')); } $func = 'list'; } } // ********************************************* LOESCHEN if ($func == 'delete') { $sf = new rex_sql(); $sf->debugsql = self::$debug; $sf->setQuery('select * from ' . rex_xform_manager_field::table() . ' where table_name="' . $table->getTableName() . '" and id=' . $field_id); $sfa = $sf->getArray(); if (count($sfa) == 1) { $query = 'delete from ' . rex_xform_manager_field::table() . ' where table_name="' . $table->getTableName() . '" and id=' . $field_id; $delsql = new rex_sql(); $delsql->debugsql = self::$debug; $delsql->setQuery($query); echo rex_info($I18N->msg('xform_tablefielddeleted')); $this->generateAll(); } else { echo rex_warning($I18N->msg('xform_tablefieldnotfound')); } $func = 'list'; } // ********************************************* CREATE/UPDATE FIELDS if ($func == 'updatetable') { $this->generateAll(); echo rex_info($I18N->msg('xform_tablesupdated')); $func = 'list'; } if ($func == 'updatetablewithdelete') { $this->generateAll(array('delete_fields' => true)); echo rex_info($I18N->msg('xform_tablesupdated')); $func = 'list'; } if ($func == 'show_form_notation') { $formbuilder_fields = $table->getFields(); $notation_php = ''; $notation_pipe = ''; $notation_email = ''; $notation_php_pre = array('$xform = new rex_xform();', '$xform->setObjectparams(\'form_skin\', \'default\');', '$xform->setObjectparams(\'form_showformafterupdate\', 0);', '$xform->setObjectparams(\'real_field_names\', true);'); $notation_php .= implode("\n", $notation_php_pre) . "\n"; $notation_pipe_pre = array('objparams|form_skin|default', 'objparams|form_showformafterupdate|0', 'objparams|real_field_names|true'); $notation_pipe .= implode("\n", $notation_pipe_pre) . "\n"; foreach ($formbuilder_fields as $field) { $classname = rex_xform::includeClass($field['type_id'], $field['type_name']); $cl = new $classname(); $definitions = $cl->getDefinitions(); $values = array(); $i = 1; foreach ($definitions['values'] as $key => $_) { $key = $this->getFieldName($key, $field['type_id']); if (isset($field[$key])) { $values[] = $field[$key]; } elseif (isset($field['f' . $i])) { $values[] = $field['f' . $i]; } else { $values[] = ''; } $i++; } if ($field['type_id'] == 'value') { $notation_php .= "\n" . '$xform->setValueField(\'' . $field['type_name'] . '\', array("' . rtrim(implode('","', $values), '","') . '"));'; $notation_pipe .= "\n" . $field['type_name'] . '|' . rtrim(implode('|', $values), '|') . '|'; $notation_email .= "\n" . $field['label'] . ': ###' . $field['name'] . '###'; } elseif ($field['type_id'] == 'validate') { $notation_php .= "\n" . '$xform->setValidateField(\'' . $field['type_name'] . '\', array("' . rtrim(implode('","', $values), '","') . '"));'; $notation_pipe .= "\n" . $field['type_id'] . '|' . $field['type_name'] . '|' . rtrim(implode('|', $values), '|') . '|'; } elseif ($field['type_id'] == 'action') { $notation_php .= "\n" . '$xform->setActionField(\'' . $field['type_name'] . '\', array("' . rtrim(implode('","', $values), '","') . '"));'; $notation_pipe .= "\n" . $field['type_id'] . '|' . $field['type_name'] . '|' . rtrim(implode('|', $values), '|') . '|'; } } $notation_php .= "\n\n" . '$xform->setActionField(\'db2email\', array(\'emailtemplate\', \'emaillabel\', \'email@domain.de\'));'; $notation_php .= "\n" . 'echo $xform->getForm();'; $notation_pipe .= "\n\n" . 'action|db2email|emailtemplate|emaillabel|email@domain.de'; echo '<div class="rex-addon-output">'; echo '<h2 class="rex-hl2">PHP</h2>'; echo '<div class="rex-addon-content">'; echo '<pre class="rex-code"><code>' . $notation_php . '</code></pre>'; echo '</div></div>'; echo '<div class="rex-addon-output">'; echo '<h2 class="rex-hl2">Pipe</h2>'; echo '<div class="rex-addon-content">'; echo '<pre class="rex-code"><code>' . $notation_pipe . '</code></pre>'; echo '</div></div>'; echo '<div class="rex-addon-output">'; echo '<h2 class="rex-hl2">E-Mail</h2>'; echo '<div class="rex-addon-content">'; echo '<pre class="rex-code"><code>' . $notation_email . '</code></pre>'; echo '</div></div>'; $func = 'list'; } // ********************************************* LIST if ($func == 'list') { // ****** EP XFORM_MANAGER_TABLE_FIELD_FUNC $show_list = true; $show_list = rex_register_extension_point('XFORM_MANAGER_TABLE_FIELD_FUNC', $show_list, array('table' => $table, 'link_vars' => $this->getLinkVars())); if ($show_list) { function rex_xform_list_format($p, $value = '') { if ($value != '') { $p['value'] = $value; } switch ($p['list']->getValue('type_id')) { case 'validate': $style = 'color:#aaa;'; // background-color:#cfd9d9; break; case 'action': $style = 'background-color:#cfd9d9;'; break; default: $style = 'background-color:#eff9f9;'; break; } return '<td style="' . $style . '">' . $p['value'] . '</td>'; } function rex_xform_list_edit_format($p) { global $REX, $I18N; return rex_xform_list_format($p, $p['list']->getColumnLink($I18N->msg('xform_edit'), $I18N->msg('xform_edit'))); } function rex_xform_list_delete_format($p) { global $REX, $I18N; return rex_xform_list_format($p, $p['list']->getColumnLink($I18N->msg('xform_delete'), $I18N->msg('xform_delete'))); } $table_echo = ' <div class="rex-area-col-2"> <div class="rex-area-col-a"> <a href="index.php?' . $link_vars . '&table_name=' . $table->getTableName() . '&func=choosenadd"><b>+ ' . $I18N->msg('xform_addtablefield') . '</b></a> </div> <div class="rex-area-col-b rex-algn-rght"> <ul class="rex-navi-piped"> <li><a href="index.php?' . $link_vars . '&table_name=' . $table->getTableName() . '&func=show_form_notation">' . $I18N->msg('xform_manager_show_form_notation') . '</a></li><li><a href="index.php?' . $link_vars . '&table_name=' . $table->getTableName() . '&func=updatetable">' . $I18N->msg('xform_updatetable') . '</a></li><li><a href="index.php?' . $link_vars . '&table_name=' . $table->getTableName() . '&func=updatetablewithdelete" onclick="return confirm(\'' . $I18N->msg('xform_updatetable_with_delete_confirm') . '\')">' . $I18N->msg('xform_updatetable_with_delete') . '</a></li> </ul> </div> </div> <div class="rex-clearer"></div> '; echo rex_content_block($table_echo); $sql = 'select id, prio, type_id, type_name, name from ' . rex_xform_manager_field::table() . ' where table_name="' . $table->getTableName() . '" order by prio'; $list = rex_list::factory($sql, 30); // $list->debug = 1; $list->setColumnFormat('id', 'Id'); foreach ($this->getLinkVars() as $k => $v) { $list->addParam($k, $v); } $list->addParam('start', rex_request('start', 'int')); $list->addParam('table_name', $table->getTableName()); $list->removeColumn('id'); $list->setColumnLabel('prio', $I18N->msg('xform_manager_table_prio_short')); $list->setColumnLabel('type_id', $I18N->msg('xform_manager_type_id')); $list->setColumnLabel('type_name', $I18N->msg('xform_manager_type_name')); $list->setColumnLabel('name', $I18N->msg('xform_manager_name')); $list->setColumnLayout('prio', array('<th>###VALUE###</th>', '###VALUE###')); $list->setColumnFormat('prio', 'custom', 'rex_xform_list_format'); $list->setColumnLayout('type_id', array('<th>###VALUE###</th>', '###VALUE###')); $list->setColumnFormat('type_id', 'custom', 'rex_xform_list_format'); $list->setColumnLayout('type_name', array('<th>###VALUE###</th>', '###VALUE###')); $list->setColumnFormat('type_name', 'custom', 'rex_xform_list_format'); $list->setColumnLayout('name', array('<th>###VALUE###</th>', '###VALUE###')); // ###VALUE### $list->setColumnFormat('name', 'custom', 'rex_xform_list_format'); $list->addColumn($I18N->msg('xform_edit'), $I18N->msg('xform_edit')); $list->setColumnParams($I18N->msg('xform_edit'), array('field_id' => '###id###', 'func' => 'edit', 'type_name' => '###type_name###', 'type_id' => '###type_id###')); $list->setColumnLayout($I18N->msg('xform_edit'), array('<th>###VALUE###</th>', '###VALUE###')); $list->setColumnFormat($I18N->msg('xform_edit'), 'custom', 'rex_xform_list_edit_format'); $list->addColumn($I18N->msg('xform_delete'), $I18N->msg('xform_delete')); $list->setColumnParams($I18N->msg('xform_delete'), array('field_id' => '###id###', 'func' => 'delete')); $list->setColumnLayout($I18N->msg('xform_delete'), array('<th>###VALUE###</th>', '###VALUE###')); $list->setColumnFormat($I18N->msg('xform_delete'), 'custom', 'rex_xform_list_delete_format'); $list->addLinkAttribute($I18N->msg('xform_delete'), 'onclick', 'return confirm(\' [###type_id###, ###type_name###, ###name###] ' . $I18N->msg('xform_delete') . ' ?\')'); echo $list->get(); } } }
$func = rex_request("func", "string", ""); $page = rex_request("page", "string", ""); $subpage = rex_request("subpage", "string", ""); $table_id = rex_request("table_id", "int"); $show_list = TRUE; // ********************************************* FORMULAR if ($func == "add" || $func == "edit") { $xform = new rex_xform(); // $xform->setDebug(TRUE); $xform->setHiddenField("page", $page); $xform->setHiddenField("subpage", $subpage); $xform->setHiddenField("func", $func); $xform->setActionField("showtext", array("", "Vielen Dank fuer die Eintragung")); $xform->setObjectparams("main_table", $table); // für db speicherungen und unique abfragen $xform->setValueField("text", array("prio", "Priorität")); if ($func == "edit") { $xform->setValueField("showvalue", array("table_name", "Name")); $xform->setHiddenField("table_id", $table_id); $xform->setActionField("db", array($table, "id={$table_id}")); $xform->setObjectparams("main_id", $table_id); $xform->setObjectparams("main_where", "id={$table_id}"); $xform->setObjectparams('getdata', true); // Datein vorher auslesen } elseif ($func == "add") { $xform->setValueField("text", array("table_name", "Name")); $xform->setValidateField("notEmpty", array("table_name", "Bitte tragen Sie den Tabellenname ein")); $xform->setValidateField("preg_match", array("table_name", "/([a-z\\_])*/", "Bitte tragen Sie beim Tabellenname nur Buchstaben ein")); $xform->setValidateField("customfunction", array("table_name", "rex_xform_manage_checkLabelInTable", "", "Dieser Tabellenname ist bereits vorhanden")); $xform->setActionField("wrapper_value", array('table_name', 'rex_em_data_###value###')); $xform->setActionField("db", array($table));
function getFieldPage() { global $REX, $I18N; // TODO: function rex_xform_manager_checkField // ********************************************* FIELD ADD/EDIT/LIST $func = rex_request('func', 'string', 'list'); $page = rex_request('page', 'string', ''); $subpage = rex_request('subpage', 'string', ''); $tripage = rex_request('tripage', 'string', ''); $type_id = rex_request('type_id', 'string'); $type_name = rex_request('type_name', 'string'); $field_id = rex_request('field_id', 'int'); $show_list = true; $link_vars = ''; foreach ($this->getLinkVars() as $k => $v) { $link_vars .= '&' . urlencode($k) . '=' . urlencode($v); } $TYPE = array('value' => $I18N->msg('values'), 'validate' => $I18N->msg('validates'), 'action' => $I18N->msg('action')); // ********************************** TABELLE HOLEN unset($table); $tables = $this->getTables(); if (!isset($table)) { if (count($tables) > 0) { $table = current($tables); } else { echo 'Keine Tabelle gefunden'; exit; } } foreach ($tables as $t) { if ($t['table_name'] == rex_request('table_name')) { $table = $t; break; } } $table_echo = ''; //echo '<table cellpadding="5" class="rex-table" id="xform-alltables">'; //echo '<tr><td>'; foreach ($tables as $t) { if ($t['table_name'] == $table['table_name']) { $table_echo .= '<b>' . rex_translate($t['name']) . ' [' . $t['table_name'] . ']</b> '; } else { $table_echo .= ' <a href="index.php?' . $link_vars . '&table_name=' . $t['table_name'] . '">' . rex_translate($t['name']) . ' [' . $t['table_name'] . ']</a> '; } } //echo '</td></tr>'; //echo ''; if ($table['description'] != '') { //echo "<tr><td>".$table["description"].'</td></tr>'; $table_echo .= '<p>' . $table['description'] . '</p>'; } // if($rex_em_opener_info != "") { echo ' - '.$I18N->msg("openerinfo").': '.$rex_em_opener_info; } //echo '</table><br />'; echo rex_content_block($table_echo); $table['fields'] = $this->getTableFields($table['table_name']); // ********************************************* Missing Fields $mfields = rex_xform_manager_table::getMissingFields($table['table_name']); // ksort($mfields); $type_real_field = rex_request('type_real_field', 'string'); if ($type_real_field != '' && !array_key_exists($type_real_field, $mfields)) { $type_real_field = ''; } if ($type_real_field != '') { ?> <div class="rex-addon-output"><h2 class="rex-hl2">Folgendes Feld wird verwendet: <?php echo $type_real_field; ?> </h2><div class="rex-addon-content"><p class="rex-tx1"><?php $rfields = rex_xform_manager_table::getFields($table['table_name']); foreach ($rfields[$type_real_field] as $k => $v) { echo '<b>' . $k . ':</b> ' . $v . '<br />'; } ?> </p></div></div><?php } // ********************************************* CHOOSE FIELD $types = rex_xform::getTypeArray(); if ($func == 'choosenadd') { // type and choose !! $link = 'index.php?' . $link_vars . '&table_name=' . $table['table_name'] . '&func=add&'; if (!rex_xform_manager_table::hasId($table['table_name'])) { ?> <div class="rex-addon-output" id="xform-choosenadd"><h2 class="rex-hl2"><?php echo $I18N->msg('xform_id_is_missing'); ?> </h2><div class="rex-addon-content"> <p class="rex-tx1"><?php echo $I18N->msg('xform_id_missing_info'); ?> </p> </div></div> <?php } else { ?> <div class="rex-addon-output" id="xform-choosenadd"><h2 class="rex-hl2"><?php echo $I18N->msg('choosenadd'); ?> </h2><div class="rex-addon-content"> <p class="rex-tx1"><?php echo $I18N->msg('choosenadd_description'); ?> </p> </div></div> <?php if ($type_real_field == '' && count($mfields) > 0) { ?> <div class="rex-addon-output"><h2 class="rex-hl2">Es gibt noch Felder in der Tabelle welche nicht zugewiesen sind.</h2><div class="rex-addon-content"> <?php $d = 0; foreach ($mfields as $k => $v) { $d++; $l = 'index.php?' . $link_vars . '&table_name=' . $table['table_name'] . '&func=choosenadd&type_real_field=' . $k . '&type_layout=t'; echo '<a href="' . $l . '">' . $k . '</a>, '; } ?> </div></div> <?php } ?> <div class="rex-addon-output xform-table_field"> <div class="rex-area-col-2"> <div class="rex-area-col-a"> <h3 class="rex-hl2">beliebte <?php echo $TYPE['value']; ?> </h3> <div class="rex-area-content"><p class="rex-tx1"><?php if (isset($types['value'])) { ksort($types['value']); foreach ($types['value'] as $k => $v) { if (isset($v['famous']) && $v['famous']) { echo '<p class="rex-button"><a class="rex-button" href="' . $link . 'type_id=value&type_name=' . $k . '&type_real_field=' . $type_real_field . '">' . $k . '</a> <span>' . $v['description'] . '</span></p>'; } } } ?> </p></div></div> <div class="rex-area-col-b"><h3 class="rex-hl2">beliebte <?php echo $TYPE['validate']; ?> </h3><div class="rex-area-content"><p class="rex-tx1"><?php if (isset($types['validate'])) { ksort($types['validate']); foreach ($types['validate'] as $k => $v) { if (isset($v['famous']) && $v['famous']) { echo '<p class="rex-button"><a class="rex-button" href="' . $link . 'type_id=validate&type_name=' . $k . '">' . $k . '</a> <span>' . $v['description'] . '</span></p>'; } } } ?> </p></div></div> </div></div> <div class="rex-addon-output xform-table_field"> <div class="rex-area-col-2"> <div class="rex-area-col-a"><h3 class="rex-hl2"><?php echo $TYPE['value']; ?> </h3><div class="rex-area-content"><p class="rex-tx1"><?php if (isset($types['value'])) { ksort($types['value']); foreach ($types['value'] as $k => $v) { if (!isset($v['famous']) || $v['famous'] !== true) { echo '<p class="rex-button"><a class="rex-button" href="' . $link . 'type_id=value&type_name=' . $k . '&type_real_field=' . $type_real_field . '">' . $k . '</a> <span>' . $v['description'] . '</span></p>'; } } } ?> </p></div></div> <div class="rex-area-col-b"><h3 class="rex-hl2"><?php echo $TYPE['validate']; ?> </h3><div class="rex-area-content"><p class="rex-tx1"><?php if (isset($types['validate'])) { ksort($types['validate']); foreach ($types['validate'] as $k => $v) { if (!isset($v['famous']) || $v['famous'] !== true) { echo '<p class="rex-button"><a class="rex-button" href="' . $link . 'type_id=validate&type_name=' . $k . '">' . $k . '</a> <span>' . $v['description'] . '</span></p>'; } } } ?> </p></div></div> </div></div> <!-- <div class="rex-addon-output"> <h2 class="rex-hl2"><?php echo $TYPE['action']; ?> </h2> <div class="rex-addon-content"> <p class="rex-tx1"><?php if (isset($types['action'])) { ksort($types['action']); foreach ($types['action'] as $k => $v) { echo '<p class="rex-button">"<a href="' . $link . 'type_id=action&type_name=' . $k . '">' . $k . '</a>" - ' . $v['description'] . '</p>'; } } ?> </p> </div> </div> --> <?php } $table_echo = '<a href="index.php?' . $link_vars . '&table_name=' . $table['table_name'] . '"><b>« ' . $I18N->msg('back_to_overview') . '</b></a>'; echo rex_content_block($table_echo); } // ********************************************* FORMULAR if (($func == 'add' || $func == 'edit') && isset($types[$type_id][$type_name])) { $xform = new rex_xform(); $xform->setDebug(false); foreach ($this->getLinkVars() as $k => $v) { $xform->setHiddenField($k, $v); } $xform->setHiddenField('func', $func); $xform->setHiddenField('table_name', $table['table_name']); $xform->setHiddenField('type_real_field', $type_real_field); $xform->setValueField('hidden', array('table_name', $table['table_name'])); $xform->setValueField('hidden', array('type_name', $type_name, 'REQUEST')); $xform->setValueField('hidden', array('type_id', $type_id, 'REQUEST')); $xform->setValueField('text', array('prio', 'Prioritaet', rex_xform_manager_table::getMaximumPrio($table['table_name']) + 10)); $selectFields = array(); $i = 1; foreach ($types[$type_id][$type_name]['values'] as $k => $v) { $field = $this->getFieldName($k, $type_id); $selectFields['f' . $i] = $field; $i++; switch ($v['type']) { case 'name': if ($func == 'edit') { $xform->setValueField('showvalue', array($field, 'Name')); } else { if (!isset($v['value']) && $type_real_field != '') { $v['value'] = $type_real_field; } elseif (!isset($v['value'])) { $v['value'] = ''; } $xform->setValueField('text', array($field, 'Name', $v['value'])); $xform->setValidateField('notEmpty', array($field, $I18N->msg('validatenamenotempty'))); $xform->setValidateField('preg_match', array($field, "/(([a-zA-Z])+([a-zA-Z0-9\\_])*)/", $I18N->msg('validatenamepregmatch'))); $xform->setValidateField('customfunction', array($field, 'rex_xform_manager_checkField', array('table_name' => $table['table_name']), $I18N->msg('validatenamecheck'))); } break; case 'no_db': // ToDo: Default Wert beachten $xform->setValueField('checkbox', array($field, $I18N->msg('donotsaveindb'), 'no_db', $v['default'])); break; case 'boolean': // checkbox|check_design|Bezeichnung|Value|1/0|[no_db] if (!isset($v['default'])) { $v['default'] = ''; } $xform->setValueField('checkbox', array($field, $v['label'], '', $v['default'])); break; case 'select': // select|gender|Geschlecht *|Frau=w;Herr=m|[no_db]|defaultwert|multiple=1 $xform->setValueField('select', array($field, $v['label'], $v['definition'], '', $v['default'], 0)); break; case 'table': // ist fest eingetragen, damit keine Dinge durcheinandergehen if ($func == 'edit') { $xform->setValueField('showvalue', array($field, $v['label'])); } else { $_tables = rex_xform_manager_table::getTables(); $_options = array(); foreach ($_tables as $_table) { $_options[$_table->getTableName()] = str_replace('=', '-', $_table->getName() . ' [' . $_table->getTableName() . ']') . '=' . $_table->getTableName(); $_options[$_table->getTableName()] = str_replace(',', '.', $_options[$_table->getTableName()]); } if (!isset($v['default'])) { $v['default'] = ''; } $xform->setValueField('select', array($field, $v['label'], implode(',', $_options), '', $v['default'], 0)); } break; case 'textarea': $xform->setValueField('textarea', array($field, $v['label'])); break; case 'table.field': // Todo: // Todo: case 'select_name': $_fields = array(); foreach (rex_xform_manager_table::getXFormFieldsByType($table['table_name']) as $_k => $_v) { $_fields[] = $_k; } $xform->setValueField('select', array($field, $v['label'], implode(',', $_fields), '', '', 0)); break; case 'select_names': // Todo: Mehrere Namen aus denanderen Federn ziehen und als multiselectbox anbieten $_fields = array(); foreach (rex_xform_manager_table::getXFormFieldsByType($table['table_name']) as $_k => $_v) { $_fields[] = $_k; } $xform->setValueField('select', array($field, $v['label'], implode(',', $_fields), '', '', 1, 5)); break; default: // nur beim "Bezeichnungsfeld" if ($field == 'label' && $type_real_field != '' && !isset($v['value'])) { $v['value'] = $type_real_field; } elseif (!isset($v['value'])) { $v['value'] = ''; } $xform->setValueField('text', array($field, $v['label'], $v['value'])); } } $xform->setActionField('showtext', array('', '<p>' . $I18N->msg('thankyouforentry') . '</p>')); $xform->setObjectparams('main_table', $REX['TABLE_PREFIX'] . 'xform_field'); // f�r db speicherungen und unique abfragen if ($func == 'edit') { $xform->setObjectparams('submit_btn_label', $I18N->msg('save')); $xform->setHiddenField('field_id', $field_id); $xform->setActionField('manage_db', array($REX['TABLE_PREFIX'] . 'xform_field', "id={$field_id}")); $xform->setObjectparams('main_id', $field_id); $xform->setObjectparams('main_where', "id={$field_id}"); $sql = rex_sql::factory(); $sql->setQuery("SELECT * FROM " . $REX['TABLE_PREFIX'] . "xform_field WHERE id={$field_id}"); foreach ($selectFields as $alias => $field) { if ($alias != $field) { if ((!$sql->hasValue($field) || !$sql->getValue($field)) && $sql->hasValue($alias)) { $sql->setValue($field, $sql->getValue($alias)); } $xform->setValueField('hidden', array($alias, '')); } } $xform->setObjectparams('sql_object', $sql); $xform->setObjectparams('getdata', true); } elseif ($func == 'add') { $xform->setObjectparams('submit_btn_label', $I18N->msg('add')); $xform->setActionField('manage_db', array($REX['TABLE_PREFIX'] . 'xform_field')); } if ($type_id == 'value') { $xform->setValueField('checkbox', array('list_hidden', $I18N->msg('hideinlist'), 1, '1')); $xform->setValueField('checkbox', array('search', $I18N->msg('useassearchfieldalidatenamenotempty'), 1, '1')); } elseif ($type_id == 'validate') { $xform->setValueField('hidden', array('list_hidden', 1)); } $form = $xform->getForm(); if ($xform->objparams['form_show']) { if ($func == 'add') { echo '<div class="rex-addon-output"><h3 class="rex-hl2">' . $I18N->msg('addfield') . ' "' . $type_name . '"</h3><div class="rex-addon-content">'; } else { echo '<div class="rex-addon-output"><h3 class="rex-hl2">' . $I18N->msg('editfield') . ' "' . $type_name . '"</h3><div class="rex-addon-content">'; } echo $form; echo '</div></div>'; $table_echo = '<a href="index.php?' . $link_vars . '&table_name=' . $table['table_name'] . '"><b>« ' . $I18N->msg('back_to_overview') . '</b></a>'; echo rex_content_block($table_echo); $func = ''; } else { if ($func == 'edit') { $this->generateAll(); echo rex_info($I18N->msg('thankyouforupdate')); } elseif ($func == 'add') { $this->generateAll(); echo rex_info($I18N->msg('thankyouforentry')); } $func = 'list'; } } // ********************************************* LOESCHEN if ($func == 'delete') { $sf = new rex_sql(); // $sf->debugsql = 1; $sf->setQuery('select * from ' . $REX['TABLE_PREFIX'] . 'xform_field where table_name="' . $table['table_name'] . '" and id=' . $field_id); $sfa = $sf->getArray(); if (count($sfa) == 1) { $query = 'delete from ' . $REX['TABLE_PREFIX'] . 'xform_field where table_name="' . $table['table_name'] . '" and id=' . $field_id; $delsql = new rex_sql(); // $delsql->debugsql=1; $delsql->setQuery($query); echo rex_info($I18N->msg('tablefielddeleted')); $this->generateAll(); } else { echo rex_warning($I18N->msg('tablefieldnotfound')); } $func = 'list'; } // ********************************************* CREATE/UPDATE FIELDS if ($func == 'updatetable') { $this->generateAll(); echo rex_info($I18N->msg('tablesupdated')); $func = 'list'; } if ($func == 'updatetablewithdelete') { $this->generateAll(array('delete_fields' => true)); echo rex_info($I18N->msg('tablesupdated')); $func = 'list'; } // ********************************************* LIST if ($func == 'list') { // ****** EP XFORM_MANAGER_TABLE_FIELD_FUNC $show_list = true; $show_list = rex_register_extension_point('XFORM_MANAGER_TABLE_FIELD_FUNC', $show_list, array('table' => $t, 'link_vars' => $this->getLinkVars())); if ($show_list) { function rex_xform_list_format($p, $value = '') { if ($value != '') { $p['value'] = $value; } switch ($p['list']->getValue('type_id')) { case 'validate': $style = 'color:#aaa;'; // background-color:#cfd9d9; break; case 'action': $style = 'background-color:#cfd9d9;'; break; default: $style = 'background-color:#eff9f9;'; break; } return '<td style="' . $style . '">' . $p['value'] . '</td>'; } function rex_xform_list_edit_format($p) { global $REX, $I18N; return rex_xform_list_format($p, $p['list']->getColumnLink($I18N->msg('edit'), $I18N->msg('edit'))); } function rex_xform_list_delete_format($p) { global $REX, $I18N; return rex_xform_list_format($p, $p['list']->getColumnLink($I18N->msg('delete'), $I18N->msg('delete'))); } $table_echo = ' <div class="rex-area-col-2"> <div class="rex-area-col-a"> <a href="index.php?' . $link_vars . '&table_name=' . $table['table_name'] . '&func=choosenadd"><b>+ ' . $I18N->msg('addtablefield') . '</b></a> </div> <div class="rex-area-col-b rex-algn-rght"> <a href="index.php?' . $link_vars . '&table_name=' . $table['table_name'] . '&func=updatetable"><b>o ' . $I18N->msg('updatetable') . '</b></a> <a href="index.php?' . $link_vars . '&table_name=' . $table['table_name'] . '&func=updatetablewithdelete" onclick="return confirm(\'' . $I18N->msg('updatetable_with_delete_confirm') . '\')"><b>o ' . $I18N->msg('updatetable_with_delete') . '</b></a> </div> </div> <div class="rex-clearer"></div> '; echo rex_content_block($table_echo); $sql = 'select id, prio, type_id, type_name, name from ' . $REX['TABLE_PREFIX'] . 'xform_field where table_name="' . $table['table_name'] . '" order by prio'; $list = rex_list::factory($sql, 30); // $list->debug = 1; $list->setColumnFormat('id', 'Id'); foreach ($this->getLinkVars() as $k => $v) { $list->addParam($k, $v); } $list->addParam('table_name', $table['table_name']); $list->removeColumn('id'); $list->setColumnLayout('prio', array('<th>###VALUE###</th>', '###VALUE###')); $list->setColumnFormat('prio', 'custom', 'rex_xform_list_format'); $list->setColumnLayout('type_id', array('<th>###VALUE###</th>', '###VALUE###')); $list->setColumnFormat('type_id', 'custom', 'rex_xform_list_format'); $list->setColumnLayout('type_name', array('<th>###VALUE###</th>', '###VALUE###')); $list->setColumnFormat('type_name', 'custom', 'rex_xform_list_format'); $list->setColumnLayout('name', array('<th>###VALUE###</th>', '###VALUE###')); // ###VALUE### $list->setColumnFormat('name', 'custom', 'rex_xform_list_format'); $list->addColumn($I18N->msg('edit'), $I18N->msg('edit')); $list->setColumnParams($I18N->msg('edit'), array('field_id' => '###id###', 'func' => 'edit', 'type_name' => '###type_name###', 'type_id' => '###type_id###')); $list->setColumnLayout($I18N->msg('edit'), array('<th>###VALUE###</th>', '###VALUE###')); $list->setColumnFormat($I18N->msg('edit'), 'custom', 'rex_xform_list_edit_format'); $list->addColumn($I18N->msg('delete'), $I18N->msg('delete')); $list->setColumnParams($I18N->msg('delete'), array('field_id' => '###id###', 'func' => 'delete')); $list->setColumnLayout($I18N->msg('delete'), array('<th>###VALUE###</th>', '###VALUE###')); $list->setColumnFormat($I18N->msg('delete'), 'custom', 'rex_xform_list_delete_format'); $list->addLinkAttribute($I18N->msg('delete'), 'onclick', 'return confirm(\' [###type_id###, ###type_name###, ###name###] ' . $I18N->msg('delete') . ' ?\')'); echo $list->get(); } } }
</p> </div> </div> <?php } // ********************************************* FORMULAR if (($func == "add" || $func == "edit") && isset($types[$type_id][$type_name])) { $xform = new rex_xform(); // $xform->setDebug(TRUE); foreach ($this->getLinkVars() as $k => $v) { $xform->setHiddenField($k, $v); } $xform->setHiddenField("func", $func); $xform->setHiddenField("table_name", $table["table_name"]); $xform->setValueField("hidden", array("table_name", $table["table_name"])); $xform->setValueField("hidden", array("type_name", $type_name, "REQUEST")); $xform->setValueField("hidden", array("type_id", $type_id, "REQUEST")); $xform->setValueField("text", array("prio", "Prioritaet")); $i = 0; foreach ($types[$type_id][$type_name]['values'] as $v) { $i++; switch ($v['type']) { case "name": if ($func == "edit") { $xform->setValueField("showvalue", array("f" . $i, "Name")); } else { if (!isset($v["value"])) { $v["value"] = ""; } $xform->setValueField("text", array("f" . $i, "Name", $v["value"]));
$table_field = $REX['TABLE_PREFIX'] . 'xform_field'; $func = rex_request('func', 'string', ''); $page = rex_request('page', 'string', ''); $subpage = rex_request('subpage', 'string', ''); $table_id = rex_request('table_id', 'int'); $show_list = true; // ********************************************* FORMULAR if (($func == 'add' || $func == 'edit') && $REX['USER']->isAdmin()) { $xform = new rex_xform(); // $xform->setDebug(TRUE); $xform->setHiddenField('page', $page); $xform->setHiddenField('subpage', $subpage); $xform->setHiddenField('func', $func); $xform->setActionField('showtext', array('', $I18N->msg('xform_manager_table_entry_saved'))); $xform->setObjectparams('main_table', $table); $xform->setValueField('text', array('prio', $I18N->msg('xform_manager_table_prio'))); if ($func == 'edit') { $xform->setObjectparams('submit_btn_label', $I18N->msg('save')); $xform->setValueField('showvalue', array('table_name', $I18N->msg('xform_manager_table_name'))); $xform->setHiddenField('table_id', $table_id); $xform->setActionField('db', array($table, "id={$table_id}")); $xform->setObjectparams('main_id', $table_id); $xform->setObjectparams('main_where', "id={$table_id}"); $xform->setObjectparams('getdata', true); // Datein vorher auslesen } elseif ($func == 'add') { $xform->setObjectparams('submit_btn_label', $I18N->msg('add')); $xform->setValueField('text', array('table_name', $I18N->msg('xform_manager_table_name'), $REX['TABLE_PREFIX'])); $xform->setValidateField('empty', array('table_name', $I18N->msg('xform_manager_table_enter_name'))); $xform->setValidateField('customfunction', array('table_name', '!rex_xform_manager_table::xform_checkTableName', '', $I18N->msg('xform_manager_table_enter_specialchars'))); $xform->setValidateField('customfunction', array('table_name', 'rex_xform_manager_table::xform_existTableName', '', $I18N->msg('xform_manager_table_exists')));
} echo '<br /><table cellpadding="5" class="rex-table"><tr><td> <a href="index.php?' . $link_vars . '&table_name=' . $table["table_name"] . '"><b>« ' . $I18N->msg('back_to_overview') . '</b></a> </td></tr></table>'; } // ********************************************* FORMULAR if (($func == "add" || $func == "edit") && isset($types[$type_id][$type_name])) { $xform = new rex_xform(); $xform->setDebug(FALSE); foreach ($this->getLinkVars() as $k => $v) { $xform->setHiddenField($k, $v); } $xform->setHiddenField("func", $func); $xform->setHiddenField("table_name", $table["table_name"]); $xform->setHiddenField("type_real_field", $type_real_field); $xform->setValueField("hidden", array("table_name", $table["table_name"])); $xform->setValueField("hidden", array("type_name", $type_name, "REQUEST")); $xform->setValueField("hidden", array("type_id", $type_id, "REQUEST")); $xform->setValueField("text", array("prio", "Prioritaet", rex_xform_manager_table::getMaximumPrio($table["table_name"]) + 10)); $i = 0; foreach ($types[$type_id][$type_name]['values'] as $v) { $i++; switch ($v['type']) { case "name": if ($func == "edit") { $xform->setValueField("showvalue", array("f" . $i, "Name")); } else { if (!isset($v["value"]) && $type_real_field != "") { $v["value"] = $type_real_field; } elseif (!isset($v["value"])) { $v["value"] = "";
} } } else { if (($func == 'add' || $func == 'edit') && $REX['USER']->isAdmin()) { $xform = new rex_xform(); // $xform->setDebug(TRUE); $xform->setHiddenField('page', $page); $xform->setHiddenField('subpage', $subpage); $xform->setHiddenField('func', $func); $xform->setHiddenField('list', rex_request('list', 'string')); $xform->setHiddenField('sort', rex_request('sort', 'string')); $xform->setHiddenField('sorttype', rex_request('sorttype', 'string')); $xform->setHiddenField('start', rex_request('start', 'string')); $xform->setActionField('showtext', array('', $I18N->msg('xform_manager_table_entry_saved'))); $xform->setObjectparams('main_table', rex_xform_manager_table::table()); $xform->setValueField('prio', array('prio', $I18N->msg('xform_manager_table_prio'), 'name')); if ($func == 'edit') { $xform->setObjectparams('submit_btn_label', $I18N->msg('xform_save')); $xform->setValueField('showvalue', array('table_name', $I18N->msg('xform_manager_table_name'))); $xform->setHiddenField('table_id', $table_id); $xform->setActionField('db', array(rex_xform_manager_table::table(), "id={$table_id}")); $xform->setObjectparams('main_id', $table_id); $xform->setObjectparams('main_where', "id={$table_id}"); $xform->setObjectparams('getdata', true); // Datein vorher auslesen } elseif ($func == 'add') { $xform->setObjectparams('submit_btn_label', $I18N->msg('xform_add')); $xform->setValueField('text', array('table_name', $I18N->msg('xform_manager_table_name'), $REX['TABLE_PREFIX'])); $xform->setValidateField('empty', array('table_name', $I18N->msg('xform_manager_table_enter_name'))); $xform->setValidateField('customfunction', array('table_name', function ($label = '', $table = '', $params = '') { preg_match("/([a-z])+([0-9a-z\\_])*/", $table, $matches);
$t = new rex_xform_manager(); $t->generateAll(); echo rex_info($I18N->msg("xform_manager_table_updated")); $func = ""; } // ********************************************* FORMULAR if (($func == "add" || $func == "edit") && $REX['USER']->isAdmin()) { $xform = new rex_xform(); // $xform->setDebug(TRUE); $xform->setHiddenField("page", $page); $xform->setHiddenField("subpage", $subpage); $xform->setHiddenField("func", $func); $xform->setActionField("showtext", array("", $I18N->msg("xform_manager_table_entry_saved"))); $xform->setObjectparams("main_table", $table); // fŸr db speicherungen und unique abfragen $xform->setValueField("text", array("prio", $I18N->msg("xform_manager_table_prio"))); if ($func == "edit") { $xform->setValueField("showvalue", array("table_name", "Name")); $xform->setHiddenField("table_id", $table_id); $xform->setActionField("db", array($table, "id={$table_id}")); $xform->setObjectparams("main_id", $table_id); $xform->setObjectparams("main_where", "id={$table_id}"); $xform->setObjectparams('getdata', true); // Datein vorher auslesen } elseif ($func == "add") { $xform->setValueField("text", array("table_name", $I18N->msg("xform_manager_table_name"))); $xform->setValidateField("notEmpty", array("table_name", $I18N->msg("xform_manager_table_enter_name"))); $xform->setValidateField("preg_match", array("table_name", "/([a-z\\_])*/", $I18N->msg("xform_manager_table_enter_specialchars"))); $xform->setValidateField("customfunction", array("table_name", "rex_xform_manage_checkLabelInTable", "", $I18N->msg("xform_manager_table_exists"))); $xform->setActionField("wrapper_value", array('table_name', '###value###')); // Tablename
$xform->setHiddenField('sort', rex_request('sort', 'string')); $xform->setHiddenField('sorttype', rex_request('sorttype', 'string')); $xform->setHiddenField('start', rex_request('start', 'string')); foreach ($fields as $field) { $type_name = $field["type_name"]; $type_id = $field["type_id"]; $values = array(); for ($i = 1; $i < 10; $i++) { $values[$i] = $field["f" . $i]; } if ($type_id == "value") { if (in_array($values[1], $this->getFilterFields())) { // Feld vorhanden -> ignorieren -> hidden feld machen // TODO: Feld trotzdem noch aufnehmen, damit validierungen etc noch funktionieren } else { $xform->setValueField($field["type_name"], $values); } } elseif ($type_id == "validate") { $xform->setValidateField($field["type_name"], $values); } elseif ($type_id == "action") { $xform->setActionField($field["type_name"], $values); } } // ***** START // Textblock gibt den formalarblock als text aus, um diesen in das xform modul einsetzen zu können. /* $text_block = ''; foreach($fields as $field) { $values = array(); for($i=1;$i<10;$i++){ $values[] = $field["f".$i]; } if($field["type_id"] == "value") { $text_block .= "\n".'$xform->setValueField("'.$field["type_name"].'",array("'.implode('","',$values).'"));'; }elseif($field["type_id"] == "validate") { $text_block .= "\n".'$xform->setValidateField("'.$field["type_name"].'",array("'.implode('","',$values).'"));';