echo rex_view::warning(rex_i18n::msg('yform_manager_table_import_failed', '', $e->getMessage())); } } } else { if (($func == 'add' || $func == 'edit') && rex::getUser()->isAdmin()) { $yform = new rex_yform(); // $yform->setDebug(TRUE); $yform->setHiddenField('page', $page); $yform->setHiddenField('func', $func); $yform->setHiddenField('list', rex_request('list', 'string')); $yform->setHiddenField('sort', rex_request('sort', 'string')); $yform->setHiddenField('sorttype', rex_request('sorttype', 'string')); $yform->setHiddenField('start', rex_request('start', 'string')); $yform->setActionField('showtext', array('', rex_i18n::msg('yform_manager_table_entry_saved'))); $yform->setObjectparams('main_table', rex_yform_manager_table::table()); $yform->setValueField('prio', array('prio', rex_i18n::msg('yform_manager_table_prio'), 'name')); if ($func == 'edit') { $yform->setObjectparams('submit_btn_label', rex_i18n::msg('yform_save')); $yform->setValueField('showvalue', array('table_name', rex_i18n::msg('yform_manager_table_name'))); $yform->setHiddenField('table_id', $table_id); $yform->setActionField('db', array(rex_yform_manager_table::table(), "id={$table_id}")); $yform->setObjectparams('main_id', $table_id); $yform->setObjectparams('main_where', "id={$table_id}"); $yform->setObjectparams('getdata', true); // Datein vorher auslesen } elseif ($func == 'add') { $yform->setObjectparams('submit_btn_label', rex_i18n::msg('yform_add')); $yform->setValueField('text', array('table_name', rex_i18n::msg('yform_manager_table_name'), rex::getTablePrefix())); $yform->setValidateField('empty', array('table_name', rex_i18n::msg('yform_manager_table_enter_name'))); $yform->setValidateField('customfunction', array('table_name', function ($label = '', $table = '', $params = '') { preg_match("/([a-z])+([0-9a-z\\_])*/", $table, $matches);
function getFieldPage() { // ********************************************* FIELD ADD/EDIT/LIST $func = rex_request('func', 'string', 'list'); $type_id = rex_request('type_id', 'string'); $type_name = rex_request('type_name', 'string'); $field_id = rex_request('field_id', 'int'); $link_vars = ''; foreach ($this->getLinkVars() as $k => $v) { $link_vars .= '&' . urlencode($k) . '=' . urlencode($v); } $TYPE = array('value' => rex_i18n::msg('yform_values'), 'validate' => rex_i18n::msg('yform_validates'), 'action' => rex_i18n::msg('yform_action')); // ********************************** TABELLE HOLEN $table = $this->table; $table_info = '<b>' . rex_i18n::translate($table->getName()) . ' [' . $table->getTableName() . ']</b> '; echo rex_view::info($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 != '') { $panel = ''; $panel .= '<dl class="dl-horizontal text-left">'; $rfields = $this->table->getColumns(); foreach ($rfields[$type_real_field] as $k => $v) { $panel .= '<dt>' . ucfirst($k) . ':</dt><dd>' . $v . '</dd>'; } $panel .= '</dl>'; $fragment = new rex_fragment(); $fragment->setVar('class', 'info'); $fragment->setVar('title', 'Folgendes Feld wird verwendet: ' . $type_real_field); $fragment->setVar('body', $panel, false); echo $fragment->parse('core/page/section.php'); } // ********************************************* CHOOSE FIELD $types = rex_yform::getTypeArray(); if ($func == 'choosenadd') { $link = 'index.php?' . $link_vars . '&table_name=' . $table->getTableName() . '&func=add&'; $content = []; $panels = []; if (!$table->hasId()) { $content[] = rex_i18n::msg('yform_id_is_missing') . '' . rex_i18n::msg('yform_id_missing_info'); } else { if ($type_real_field == '' && count($mfields) > 0) { $tmp = ''; $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'; $tmp .= '<a class="btn btn-default" href="' . $l . '">' . $k . '</a> '; } $fragment = new rex_fragment(); $fragment->setVar('class', 'info'); $fragment->setVar('title', 'Es gibt noch Felder in der Tabelle welche nicht zugewiesen sind.'); $fragment->setVar('body', $tmp, false); echo $fragment->parse('core/page/section.php'); } $tmp = ''; if (isset($types['value'])) { ksort($types['value']); $tmp .= '<table class="table table-hover">'; foreach ($types['value'] as $k => $v) { $tmp .= '<tr><th><a class="btn btn-default btn-block" href="' . $link . 'type_id=value&type_name=' . $k . '&type_real_field=' . $type_real_field . '"><code>' . $k . '</code></a></th><td class="vertical-middle">' . $v['description'] . '</td></tr>'; } $tmp .= '</table>'; } $fragment = new rex_fragment(); $fragment->setVar('title', $TYPE['value']); $fragment->setVar('content', $tmp, false); $panels[] = $fragment->parse('core/page/section.php'); $tmp = ''; if (isset($types['validate'])) { ksort($types['validate']); $tmp .= '<table class="table table-hover">'; foreach ($types['validate'] as $k => $v) { $tmp .= '<tr><th><a class="btn btn-default btn-block" href="' . $link . 'type_id=validate&type_name=' . $k . '"><code>' . $k . '</code></a></th><td class="vertical-middle">' . $v['description'] . '</td></tr>'; } $tmp .= '</table>'; } $fragment = new rex_fragment(); $fragment->setVar('title', $TYPE['validate']); $fragment->setVar('content', $tmp, false); $panels[] = $fragment->parse('core/page/section.php'); } $fragment = new rex_fragment(); $fragment->setVar('title', rex_i18n::msg('yform_choosenadd')); $fragment->setVar('body', rex_i18n::msg('yform_choosenadd_description'), false); echo $fragment->parse('core/page/section.php'); $fragment = new rex_fragment(); $fragment->setVar('content', $panels, false); echo $fragment->parse('core/page/grid.php'); $table_echo = '<a class="btn btn-default" href="index.php?' . $link_vars . '&table_name=' . $table->getTableName() . '">' . rex_i18n::msg('yform_back_to_overview') . '</a>'; $fragment = new rex_fragment(); $fragment->setVar('footer', $table_echo, false); echo $fragment->parse('core/page/section.php'); } // ********************************************* FORMULAR if (($func == 'add' || $func == 'edit') && isset($types[$type_id][$type_name])) { $yform = new rex_yform(); $yform->setDebug(false); foreach ($this->getLinkVars() as $k => $v) { $yform->setHiddenField($k, $v); } $yform->setHiddenField('func', $func); $yform->setHiddenField('table_name', $table->getTableName()); $yform->setHiddenField('type_real_field', $type_real_field); $yform->setHiddenField('list', rex_request('list', 'string')); $yform->setHiddenField('sort', rex_request('sort', 'string')); $yform->setHiddenField('sorttype', rex_request('sorttype', 'string')); $yform->setHiddenField('start', rex_request('start', 'string')); $yform->setValueField('hidden', array('table_name', $table->getTableName())); $yform->setValueField('hidden', array('type_name', $type_name, 'REQUEST')); $yform->setValueField('hidden', array('type_id', $type_id, 'REQUEST')); $yform->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') { $yform->setValueField('showvalue', array($field, 'Name')); } else { if (!isset($v['value']) && $type_real_field != '') { $v['value'] = $type_real_field; } elseif (!isset($v['value'])) { $v['value'] = ''; } $yform->setValueField('text', array($field, 'Name', $v['value'])); $yform->setValidateField('empty', array($field, rex_i18n::msg('yform_validatenamenotempty'))); $yform->setValidateField('preg_match', array($field, "/(([a-zA-Z])+([a-zA-Z0-9\\_])*)/", rex_i18n::msg('yform_validatenamepregmatch'))); $yform->setValidateField('customfunction', array($field, 'rex_yform_manager_checkField', array('table_name' => $table->getTableName()), rex_i18n::msg('yform_validatenamecheck'))); } break; case 'no_db': if (!isset($v['default']) || $v['default'] != 1) { $v['default'] = 0; } $yform->setValueField('checkbox', array($field, rex_i18n::msg('yform_donotsaveindb'), 'no_db', $v['default'])); break; case 'boolean': // checkbox|check_design|Bezeichnung|Value|1/0|[no_db] if (!isset($v['default'])) { $v['default'] = ''; } $yform->setValueField('checkbox', array($field, $v['label'], '', $v['default'])); break; case 'select': // select|gender|Geschlecht *|Frau=w;Herr=m|[no_db]|defaultwert|multiple=1 $yform->setValueField('select', array($field, $v['label'], $v['options'], '', $v['default'], 0)); break; case 'table': // ist fest eingetragen, damit keine Dinge durcheinandergehen if ($func == 'edit') { $yform->setValueField('showvalue', array($field, $v['label'])); } else { $_tables = rex_yform_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_i18n::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'] = ''; } $yform->setValueField('select', array($field, $v['label'], implode(',', $_options), '', $v['default'], 0)); } break; case 'textarea': $yform->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; } $yform->setValueField('select', array($field, $v['label'], implode(',', $_fields), '', '', 0)); break; case 'select_names': $_fields = array(); foreach ($table->getValueFields() as $_k => $_v) { $_fields[] = $_k; } $yform->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'] = ''; } $yform->setValueField('text', array($field, $v['label'], $v['value'])); } } $yform->setActionField('showtext', array('', '<p>' . rex_i18n::msg('yform_thankyouforentry') . '</p>')); $yform->setObjectparams('main_table', rex_yform_manager_field::table()); if ($func == 'edit') { $yform->setObjectparams('submit_btn_label', rex_i18n::msg('yform_save')); $yform->setHiddenField('field_id', $field_id); $yform->setActionField('manage_db', array(rex_yform_manager_field::table(), "id={$field_id}")); $yform->setObjectparams('main_id', $field_id); $yform->setObjectparams('main_where', "id={$field_id}"); $sql = rex_sql::factory(); $sql->setQuery('SELECT * FROM ' . rex_yform_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)); } $yform->setValueField('hidden', array($alias, '')); } } $yform->setObjectparams('sql_object', $sql); $yform->setObjectparams('getdata', true); } elseif ($func == 'add') { $yform->setObjectparams('submit_btn_label', rex_i18n::msg('yform_add')); $yform->setActionField('manage_db', array(rex_yform_manager_field::table())); } if ($type_id == 'value') { $yform->setValueField('checkbox', array('list_hidden', rex_i18n::msg('yform_hideinlist'), 1, '1')); $yform->setValueField('checkbox', array('search', rex_i18n::msg('yform_useassearchfieldalidatenamenotempty'), 1, '1')); } elseif ($type_id == 'validate') { $yform->setValueField('hidden', array('list_hidden', 1)); } $form = $yform->getForm(); if ($yform->objparams['form_show']) { if ($func == 'add') { $title = rex_i18n::msg('yform_addfield') . ' "' . $type_name . '"'; } else { $title = rex_i18n::msg('yform_editfield') . ' "' . $type_name . '"'; } $fragment = new rex_fragment(); $fragment->setVar('class', 'edit', false); $fragment->setVar('title', $title); $fragment->setVar('body', $form, false); // $fragment->setVar('buttons', $buttons, false); $form = $fragment->parse('core/page/section.php'); echo $form; $table_echo = '<a class="btn btn-default" href="index.php?' . $link_vars . '&table_name=' . $table->getTableName() . '">' . rex_i18n::msg('yform_back_to_overview') . '</a>'; $fragment = new rex_fragment(); $fragment->setVar('footer', $table_echo, false); echo $fragment->parse('core/page/section.php'); $func = ''; } else { if ($func == 'edit') { $this->generateAll(); echo rex_view::success(rex_i18n::msg('yform_thankyouforupdate')); } elseif ($func == 'add') { $this->generateAll(); echo rex_view::success(rex_i18n::msg('yform_thankyouforentry')); } $func = 'list'; } } // ********************************************* LOESCHEN if ($func == 'delete') { $sf = rex_sql::factory(); $sf->debugsql = self::$debug; $sf->setQuery('select * from ' . rex_yform_manager_field::table() . ' where table_name="' . $table->getTableName() . '" and id=' . $field_id); $sfa = $sf->getArray(); if (count($sfa) == 1) { $query = 'delete from ' . rex_yform_manager_field::table() . ' where table_name="' . $table->getTableName() . '" and id=' . $field_id; $delsql = rex_sql::factory(); $delsql->debugsql = self::$debug; $delsql->setQuery($query); echo rex_view::success(rex_i18n::msg('yform_tablefielddeleted')); $this->generateAll(); } else { echo rex_view::warning(rex_i18n::msg('yform_tablefieldnotfound')); } $func = 'list'; } // ********************************************* CREATE/UPDATE FIELDS if ($func == 'updatetable') { $this->generateAll(); echo rex_view::info(rex_i18n::msg('yform_tablesupdated')); $func = 'list'; } if ($func == 'updatetablewithdelete') { $this->generateAll(array('delete_fields' => true)); echo rex_view::info(rex_i18n::msg('yform_tablesupdated')); $func = 'list'; } if ($func == 'show_form_notation') { $formbuilder_fields = $table->getFields(); $notation_php = ''; $notation_pipe = ''; $notation_email = ''; $notation_php_pre = array('$yform = new rex_yform();', '$yform->setObjectparams(\'form_skin\', \'default\');', '$yform->setObjectparams(\'form_showformafterupdate\', 0);', '$yform->setObjectparams(\'real_field_names\', true);'); $notation_php .= implode("\n", $notation_php_pre) . "\n"; $notation_pipe_pre = array('objparams|form_skin|bootstrap', 'objparams|form_showformafterupdate|0', 'objparams|real_field_names|true'); $notation_pipe .= implode("\n", $notation_pipe_pre) . "\n"; foreach ($formbuilder_fields as $field) { $class = 'rex_yform_' . $field->getType() . '_' . $field->getTypeName(); $cl = new $class(); $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" . '$yform->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" . '$yform->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" . '$yform->setActionField(\'' . $field['type_name'] . '\', array("' . rtrim(implode('","', $values), '","') . '"));'; $notation_pipe .= "\n" . $field['type_id'] . '|' . $field['type_name'] . '|' . rtrim(implode('|', $values), '|') . '|'; } } $notation_php .= "\n\n" . '$yform->setActionField(\'email\', array(\'emailtemplate\', \'emaillabel\', \'email@domain.de\'));'; $notation_php .= "\n" . 'echo $yform->getForm();'; $notation_pipe .= "\n\n" . 'action|email|emailtemplate|emaillabel|email@domain.de'; $fragment = new rex_fragment(); $fragment->setVar('title', 'PHP'); $fragment->setVar('body', '<pre class="pre-scrollable">' . $notation_php . '</pre>', false); $content = $fragment->parse('core/page/section.php'); echo $content; $fragment = new rex_fragment(); $fragment->setVar('title', 'Pipe'); $fragment->setVar('body', '<pre class="pre-scrollable">' . $notation_pipe . '</pre>', false); $content = $fragment->parse('core/page/section.php'); echo $content; $fragment = new rex_fragment(); $fragment->setVar('title', 'E-Mail'); $fragment->setVar('body', '<pre class="pre-scrollable">' . $notation_email . '</pre>', false); $content = $fragment->parse('core/page/section.php'); echo $content; $func = 'list'; } // ********************************************* LIST if ($func == 'list') { $show_list = true; $show_list = rex_extension::registerPoint(new rex_extension_point('YFORM_MANAGER_TABLE_FIELD_FUNC', $show_list, ['table' => $table, 'link_vars' => $this->getLinkVars()])); if ($show_list) { function rex_yform_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_yform_list_edit_format($p) { return rex_yform_list_format($p, $p['list']->getColumnLink(rex_i18n::msg('yform_function'), '<i class="rex-icon rex-icon-edit"></i> ' . rex_i18n::msg('yform_edit'))); } function rex_yform_list_delete_format($p) { return rex_yform_list_format($p, $p['list']->getColumnLink(rex_i18n::msg('yform_delete'), '<i class="rex-icon rex-icon-delete"></i> ' . rex_i18n::msg('yform_delete'))); } $context = new rex_context($this->getLinkVars()); $items = []; $item = []; $item['label'] = rex_i18n::msg('yform_manager_show_form_notation'); $item['url'] = $context->getUrl(['table_name' => $table->getTableName(), 'func' => 'show_form_notation']); $item['attributes']['class'][] = 'btn-default'; if (rex_request('func', 'string') == 'show_form_notation') { $item['attributes']['class'][] = 'active'; } $items[] = $item; $item = []; $item['label'] = rex_i18n::msg('yform_updatetable'); $item['url'] = $context->getUrl(['table_name' => $table->getTableName(), 'func' => 'updatetable']); $item['attributes']['class'][] = 'btn-default'; if (rex_request('func', 'string') == 'updatetable') { $item['attributes']['class'][] = 'active'; } $items[] = $item; $item = []; $item['label'] = rex_i18n::msg('yform_updatetable_with_delete'); $item['url'] = $context->getUrl(['table_name' => $table->getTableName(), 'func' => 'updatetablewithdelete']); $item['attributes']['class'][] = 'btn-default'; if (rex_request('func', 'string') == 'updatetablewithdelete') { $item['attributes']['class'][] = 'active'; } $item['attributes']['onclick'][] = 'return confirm(\'' . rex_i18n::msg('yform_updatetable_with_delete_confirm') . '\')'; $items[] = $item; $fragment = new rex_fragment(); $fragment->setVar('buttons', $items, false); $fragment->setVar('size', 'xs', false); $panel_options = $fragment->parse('core/buttons/button_group.php'); $sql = 'select id, prio, type_id, type_name, name from ' . rex_yform_manager_field::table() . ' where table_name="' . $table->getTableName() . '" order by prio'; $list = rex_list::factory($sql, 30); // $list->debug = 1; // $list->setColumnFormat('id', 'Id'); $tdIcon = '<i class="rex-icon rex-icon-table"></i>'; $thIcon = '<a href="' . $list->getUrl(['table_name' => $table->getTableName(), 'func' => 'choosenadd']) . '"' . rex::getAccesskey(rex_i18n::msg('add'), 'add') . '><i class="rex-icon rex-icon-add"></i></a>'; $list->addColumn($thIcon, $tdIcon, 0, ['<th class="rex-table-icon">###VALUE###</th>', '<td class="rex-table-icon">###VALUE###</td>']); $list->setColumnParams($thIcon, ['field_id' => '###id###', 'func' => 'edit', 'type_name' => '###type_name###', 'type_id' => '###type_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', rex_i18n::msg('yform_manager_table_prio_short')); //$list->setColumnLayout('prio', ['<th class="rex-table-priority">###VALUE###</th>', '<td class="rex-table-priority" data-title="' . rex_i18n::msg('yform_manager_table_prio_short') . '">###VALUE###</td>']); $list->setColumnLayout('prio', array('<th>###VALUE###</th>', '###VALUE###')); $list->setColumnFormat('prio', 'custom', 'rex_yform_list_format'); $list->setColumnLabel('type_id', rex_i18n::msg('yform_manager_type_id')); $list->setColumnLayout('type_id', array('<th>###VALUE###</th>', '###VALUE###')); $list->setColumnFormat('type_id', 'custom', 'rex_yform_list_format'); $list->setColumnLabel('type_name', rex_i18n::msg('yform_manager_type_name')); $list->setColumnLayout('type_name', array('<th>###VALUE###</th>', '###VALUE###')); $list->setColumnFormat('type_name', 'custom', 'rex_yform_list_format'); $list->setColumnLabel('name', rex_i18n::msg('yform_manager_name')); $list->setColumnLayout('name', array('<th>###VALUE###</th>', '###VALUE###')); // ###VALUE### $list->setColumnFormat('name', 'custom', 'rex_yform_list_format'); $list->addColumn(rex_i18n::msg('yform_function'), '<i class="rex-icon rex-icon-edit"></i> ' . rex_i18n::msg('yform_edit')); $list->setColumnParams(rex_i18n::msg('yform_function'), array('field_id' => '###id###', 'func' => 'edit', 'type_name' => '###type_name###', 'type_id' => '###type_id###')); $list->setColumnLayout(rex_i18n::msg('yform_function'), array('<th class="rex-table-action" colspan="2">###VALUE###</th>', '###VALUE###')); $list->setColumnFormat(rex_i18n::msg('yform_function'), 'custom', 'rex_yform_list_edit_format'); $list->addColumn(rex_i18n::msg('yform_delete'), '<i class="rex-icon rex-icon-delete"></i> ' . rex_i18n::msg('yform_delete')); $list->setColumnParams(rex_i18n::msg('yform_delete'), array('field_id' => '###id###', 'func' => 'delete')); $list->setColumnLayout(rex_i18n::msg('yform_delete'), array('', '###VALUE###')); $list->setColumnFormat(rex_i18n::msg('yform_delete'), 'custom', 'rex_yform_list_delete_format'); $list->addLinkAttribute(rex_i18n::msg('yform_delete'), 'onclick', 'return confirm(\' [###type_id###, ###type_name###, ###name###] ' . rex_i18n::msg('yform_delete') . ' ?\')'); $content = $list->get(); $fragment = new rex_fragment(); $fragment->setVar('title', rex_i18n::msg('yform_manager_tablefield_overview')); $fragment->setVar('options', $panel_options, false); $fragment->setVar('content', $content, false); $content = $fragment->parse('core/page/section.php'); echo $content; } } }
$select_changefreq[] = rex_i18n::msg('yrewrite_changefreq_' . $changefreq) . '=' . $changefreq; } $index_setting = []; $index_setting[] = rex_i18n::msg('yrewrite_index_status') . '=0'; $index_setting[] = rex_i18n::msg('yrewrite_index_index') . '=1'; $index_setting[] = rex_i18n::msg('yrewrite_index_noindex') . '=-1'; $yform = new rex_yform(); $yform->setObjectparams('form_action', rex_url::backendController(['page' => 'content/edit', 'article_id' => $article_id, 'clang' => $clang, 'ctype' => $ctype], false)); $yform->setObjectparams('form_id', 'yrewrite-seo'); $yform->setObjectparams('form_name', 'yrewrite-seo'); $yform->setHiddenField('yrewrite_func', 'seo'); $yform->setObjectparams('form_showformafterupdate', 1); $yform->setObjectparams('main_table', rex::getTable('article')); $yform->setObjectparams('main_id', $article_id); $yform->setObjectparams('main_where', 'id=' . $article_id . ' and clang_id=' . $clang); $yform->setObjectparams('getdata', true); $yform->setValueField('text', ['yrewrite_title', rex_i18n::msg('yrewrite_seotitle')]); $yform->setValueField('textarea', ['yrewrite_description', rex_i18n::msg('yrewrite_seodescription'), '', '', 'short']); $yform->setValueField('select', ['yrewrite_changefreq', rex_i18n::msg('yrewrite_changefreq'), implode(',', $select_changefreq), '', rex_yrewrite_seo::$changefreq_default]); $yform->setValueField('select', ['yrewrite_priority', rex_i18n::msg('yrewrite_priority'), implode(',', $select_priority), '', rex_yrewrite_seo::$priority_default]); $yform->setValueField('select', ['yrewrite_index', rex_i18n::msg('yrewrite_index'), implode(',', $index_setting), '', rex_yrewrite_seo::$index_setting_default]); $yform->setActionField('db', [rex::getTable('article'), 'id=' . $article_id . ' and clang_id=' . $clang]); $yform->setObjectparams('submit_btn_label', $addon->i18n('update_seo')); $form = $yform->getForm(); if ($yform->objparams['actions_executed']) { $form = rex_view::success(rex_i18n::msg('yrewrite_seoupdated')) . $form; rex_article_cache::delete($article_id, $clang); } else { } $form = '<section id="rex-page-sidebar-yrewrite-seo" data-pjax-container="#rex-page-sidebar-yrewrite-seo" data-pjax-no-history="1">' . $form . '</section>'; return $form;
* * @package redaxo\yrewrite * * @var rex_addon $this */ $showlist = true; $data_id = rex_request('data_id', 'int', 0); $func = rex_request('func', 'string'); if ($func != '') { $yform = new rex_yform(); // $yform->setDebug(TRUE); $yform->setHiddenField('page', 'yrewrite/alias_domains'); $yform->setHiddenField('func', $func); $yform->setHiddenField('save', '1'); $yform->setObjectparams('main_table', rex::getTable('yrewrite_domain')); $yform->setValueField('text', ['domain', $this->i18n('alias_domain_refersto')]); $yform->setValueField('select_sql', ['alias_domain', $this->i18n('domain_willbereferdto') . '', 'select domain as id,domain as name from ' . rex::getTable('yrewrite_domain') . ' where alias_domain = ""']); if (rex_clang::count() > 1) { $yform->setValueField('select_sql', ['clang_start', $this->i18n('clang_start'), 'select id,name from ' . rex::getTable('clang') . ' order by id']); } $yform->setValidateField('empty', ['domain', $this->i18n('no_domain_defined')]); $yform->setValidateField('empty', ['alias_domain', $this->i18n('no_domain_defined')]); $yform->setValidateField('unique', ['domain', $this->i18n('domain_already_defined')]); if ($func == 'delete') { $d = rex_sql::factory(); $d->setQuery('delete from ' . rex::getTable('yrewrite_domain') . ' where id=' . $data_id); echo rex_view::success($this->i18n('domain_deleted')); rex_yrewrite::deleteCache(); } elseif ($func == 'edit') { $yform->setHiddenField('data_id', $data_id); $yform->setActionField('db', [rex::getTable('yrewrite_domain'), 'id=' . $data_id]);
* * @package redaxo\yrewrite * * @var rex_addon $this */ $showlist = true; $data_id = rex_request('data_id', 'int', 0); $func = rex_request('func', 'string'); if ($func != '') { $yform = new rex_yform(); // $yform->setDebug(TRUE); $yform->setHiddenField('page', 'yrewrite/domains'); $yform->setHiddenField('func', $func); $yform->setHiddenField('save', '1'); $yform->setObjectparams('main_table', rex::getTable('yrewrite_domain')); $yform->setValueField('text', ['domain', $this->i18n('domain_info')]); $yform->setValidateField('empty', ['domain', $this->i18n('no_domain_defined')]); $yform->setValidateField('unique', ['domain', $this->i18n('domain_already_defined')]); $yform->setValueField('be_link', ['mount_id', $this->i18n('mount_id')]); $yform->setValueField('be_link', ['start_id', $this->i18n('start_id')]); $yform->setValidateField('empty', ['start_id', $this->i18n('no_start_id_defined')]); $yform->setValueField('be_link', ['notfound_id', $this->i18n('notfound_id')]); $yform->setValidateField('empty', ['notfound_id', $this->i18n('no_not_found_id_defined')]); if (rex_clang::count() == 0) { $yform->setValueField('hidden', ['clangs', '']); $yform->setValueField('hidden', ['clang_start', '']); } else { $yform->setValueField('select_sql', ['clangs', $this->i18n('clangs'), 'select id,name from ' . rex::getTable('clang'), '', 1, 0, '', 1, rex_clang::count()]); $yform->setValueField('select_sql', ['clang_start', $this->i18n('clang_start'), 'select id,name from ' . rex::getTable('clang') . ' order by id']); } function rex_yrewrite_domaincheck($field, $value, $yform)
<?php /** * yform * @author jan.kristinus[at]redaxo[dot]org Jan Kristinus * @author <a href="http://www.yakamara.de">www.yakamara.de</a> */ echo rex_view::title(rex_i18n::msg('yform')); $page = rex_request('page', 'string', ''); $yform = new rex_yform(); $yform->setHiddenField('page', $page); $yform->setObjectparams('real_field_names', true); $yform->setObjectparams('hide_top_warning_messages', true); $yform->setObjectparams('form_showformafterupdate', 1); $yform->setValueField('upload', array('name' => 'importfile', 'label' => rex_i18n::msg('yform_manager_tableset_import_jsonimportfile'), 'max_size' => '1000', 'types' => '.json', 'required' => 1, 'messages' => array(rex_i18n::msg('yform_manager_table_importset_warning_min'), rex_i18n::msg('yform_manager_table_importset_warning_max'), rex_i18n::msg('yform_manager_table_importset_warning_type'), rex_i18n::msg('yform_manager_table_importset_warning_selectfile')), 'modus' => 'no_save', 'no_db' => 'no_db')); $form = $yform->getForm(); if ($yform->objparams['actions_executed']) { try { $content = file_get_contents(rex_path::addonData('yform', 'uploads/' . $yform->objparams['value_pool']['email']['importfile'])); rex_yform_manager_table_api::importTablesets($content); echo rex_view::success(rex_i18n::msg('yform_manager_tableset_import_success')); } catch (Exception $e) { echo rex_view::warning(rex_i18n::msg('yform_manager_tableset_import_failed', '', $e->getMessage())); } rex_file::delete(rex_path::addonData('yform', 'uploads/' . $yform->objparams['value_pool']['email']['importfile'])); } else { if ($yform->objparams['send']) { echo rex_view::warning(rex_i18n::msg('yform_manager_tableset_import_warning_selectfile')); } } $fragment = new rex_fragment();
$autoUrl = substr($autoUrl, strlen($domain->getPath())); } if ($isStartarticle) { echo rex_view::warning($addon->i18n('startarticleisalways', $domain->getName())); } else { $yform = new rex_yform(); $yform->setObjectparams('form_action', rex_url::backendController(['page' => 'content/edit', 'article_id' => $article_id, 'clang' => $clang, 'ctype' => $ctype], false)); $yform->setObjectparams('form_id', 'yrewrite-url'); $yform->setObjectparams('form_name', 'yrewrite-url'); $yform->setHiddenField('yrewrite_func', 'url'); $yform->setObjectparams('form_showformafterupdate', 1); $yform->setObjectparams('main_table', rex::getTable('article')); $yform->setObjectparams('main_id', $article_id); $yform->setObjectparams('main_where', 'id=' . $article_id . ' and clang_id=' . $clang); $yform->setObjectparams('getdata', true); $yform->setValueField('text', ['yrewrite_url', $addon->i18n('customurl'), 'notice' => $autoUrl]); $yform->setValidateField('customfunction', ['name' => 'yrewrite_url', 'function' => function ($func, $yrewrite_url) { return substr($yrewrite_url, 0, 1) == '/' || substr($yrewrite_url, -1) == '/'; }, 'params' => [], 'message' => rex_i18n::msg('yrewrite_warning_noslash')]); $yform->setValidateField('customfunction', ['name' => 'yrewrite_url', 'function' => function ($func, $yrewrite_url) { return strlen($yrewrite_url) > 250; }, 'params' => [], 'message' => rex_i18n::msg('yrewrite_warning_nottolong')]); $yform->setValidateField('customfunction', ['name' => 'yrewrite_url', 'function' => function ($func, $yrewrite_url) { if ($yrewrite_url == "") { return false; } return !preg_match('/^[%_\\.+\\-\\/a-zA-Z0-9]+$/', $yrewrite_url); }, 'params' => [], 'message' => rex_i18n::msg('yrewrite_warning_chars')]); $yform->setValidateField('customfunction', ['name' => 'yrewrite_url', 'function' => function ($func, $yrewrite_url, $params, $field) { $return = ($a = rex_yrewrite::getArticleIdByUrl($params["domain"], $yrewrite_url)) && (key($a) != $params["article_id"] || current($a) != $params["clang"]); if ($return && $yrewrite_url != "") {
* * @var rex_addon $this */ $showlist = true; $data_id = rex_request('data_id', 'int', 0); $func = rex_request('func', 'string'); rex_yrewrite_forward::init(); if ($func != '') { $yform = new rex_yform(); // $yform->setDebug(TRUE); $yform->setHiddenField('page', 'yrewrite/forward'); $yform->setHiddenField('func', $func); $yform->setHiddenField('save', '1'); $yform->setObjectparams('main_table', rex::getTable('yrewrite_forward')); $yform->setObjectparams('main_table', rex::getTable('yrewrite_forward')); $yform->setValueField('select', ['status', $this->i18n('forward_status'), '' . $this->i18n('forward_active') . '=1,' . $this->i18n('forward_inactive') . '=0']); $yform->setValueField('select_sql', ['domain', $this->i18n('domain') . '', 'select domain as id,domain as name from ' . rex::getTable('yrewrite_domain') . ' where alias_domain = ""']); $yform->setValueField('text', ['url', $this->i18n('forward_url')]); //$yform->setValidateField('preg_match', array('url', '@^(?<!\/)[%_\./+\-a-zA-Z0-9]+(?!\/)$@', $this->i18n('warning_chars'))); $yform->setValidateField('preg_match', ['url', '@^([%_\\.+\\-a-zA-Z0-9]){1}[/%_\\.+\\-a-zA-Z0-9]+([%_\\.+\\-a-zA-Z0-9]){1}$@', $this->i18n('warning_chars')]); // $this->i18n('warning_noslash') $yform->setValidateField('size_range', ['url', 1, 255, $this->i18n('warning_nottolong')]); $yform->setValidateField('empty', ['url', $this->i18n('forward_enter_url')]); $yform->setValidateField('unique', ['domain,url', $this->i18n('forward_domainurl_already_defined')]); $yform->setValueField('select', ['movetype', $this->i18n('forward_move_method'), $this->i18n('forward_301') . '=301,' . $this->i18n('forward_303') . '=303,' . $this->i18n('forward_307') . '=307', '', '303']); $yform->setValueField('select', ['type', $this->i18n('forward_type'), '' . $this->i18n('forward_type_article') . '=article,' . $this->i18n('forward_type_extern') . '=extern,' . $this->i18n('forward_type_media') . '=media']); $yform->setValueField('html', ['', '<div id="rex-yrewrite-forward-article">']); $yform->setValueField('be_link', ['article_id', $this->i18n('forward_article_id')]); $yform->setValueField('select_sql', ['clang', $this->i18n('forward_clang') . '', 'select id, name from ' . rex::getTable('clang')]); $yform->setValueField('html', ['', '</div>']); $yform->setValueField('html', ['', '<div id="rex-yrewrite-forward-extern">']);
*/ echo rex_view::title(rex_i18n::msg('yform')); $page = rex_request('page', 'string', ''); $yform_tables = array(); foreach (rex_yform_manager_table::getAll() as $g_table) { $table_name = $g_table->getTableName(); if ('[translate:' . $table_name . ']' != rex_i18n::msg($table_name)) { $table_name = rex_i18n::msg($table_name); } $yform_tables[$g_table->getTableName()] = $table_name . ' [' . $g_table->getTableName() . ']'; } $yform = new rex_yform(); $yform->setHiddenField('page', $page); $yform->setObjectparams('real_field_names', true); $yform->setObjectparams('hide_top_warning_messages', true); $yform->setValueField('select', array('table_names', rex_i18n::msg('yform_manager_tables'), $yform_tables, 'multiple' => 1)); $yform->setValidateField('empty', array('table_names', '')); $form = $yform->getForm(); if ($yform->objparams['actions_executed']) { try { $table_names = rex_request("table_names"); $return = rex_yform_manager_table_api::exportTablesets($table_names); $file_name = 'yform_manager_tableset_export_tables_' . date("YmdHis") . '.json'; ob_end_clean(); header('Content-Type: application/json'); header('Charset: UTF-8'); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: private", false); header('Content-Disposition: attachment; filename="' . basename($file_name) . '"'); header('Content-Length: ' . strlen($return)); header('Pragma: public');
* * @package redaxo\yrewrite * * @var rex_addon $this */ $showlist = true; $data_id = rex_request('data_id', 'int', 0); $func = rex_request('func', 'string'); if ($func != '') { $yform = new rex_yform(); // $yform->setDebug(TRUE); $yform->setHiddenField('page', 'yrewrite/domains'); $yform->setHiddenField('func', $func); $yform->setHiddenField('save', '1'); $yform->setObjectparams('main_table', 'rex_yrewrite_domain'); $yform->setValueField('text', ['domain', $this->i18n('domain_info')]); $yform->setValidateField('empty', ['domain', $this->i18n('no_domain_defined')]); $yform->setValidateField('unique', ['domain', $this->i18n('domain_already_defined')]); $yform->setValueField('be_link', ['mount_id', $this->i18n('mount_id')]); $yform->setValueField('be_link', ['start_id', $this->i18n('start_id')]); $yform->setValidateField('empty', ['start_id', $this->i18n('no_start_id_defined')]); $yform->setValueField('be_link', ['notfound_id', $this->i18n('notfound_id')]); $yform->setValidateField('empty', ['notfound_id', $this->i18n('no_not_found_id_defined')]); if (rex_clang::count() == 0) { $yform->setValueField('hidden', ['clangs', '']); $yform->setValueField('hidden', ['clang_start', '']); } else { // TODO: // - checkbox (alle sprachen) // - multiple oder checkbox liste // - wenn mehrere angeklickt -> clang_start auswahl mit genau diesen sprachen
$yform->setObjectparams('form_showformafterupdate', 1); $yform->setHiddenField('page', $page); $yform->setValueField('select', array('table_name', rex_i18n::msg('yform_table'), $missing_tables)); $yform->setValueField('checkbox', array('convert_id', rex_i18n::msg('yform_manager_migrate_table_id_convert'))); $form = $yform->getForm(); if ($yform->objparams['actions_executed']) { $table_name = $yform->objparams['value_pool']['sql']['table_name']; $convert_id = $yform->objparams['value_pool']['sql']['convert_id']; try { rex_yform_manager_table_api::migrateTable($table_name, $convert_id); // with convert id / auto_increment finder echo rex_view::success(rex_i18n::msg('yform_manager_table_migrated_success')); unset($missing_tables[$table_name]); $yform = new rex_yform(); $yform->setObjectparams('form_showformafterupdate', 1); $yform->setHiddenField('page', $page); $yform->setValueField('select', array('table_name', rex_i18n::msg('yform_table'), $missing_tables)); $yform->setValueField('checkbox', array('convert_id', rex_i18n::msg('yform_manager_migrate_table_id_convert'))); $form = $yform->getForm(); } catch (Exception $e) { echo rex_view::warning(rex_i18n::msg('yform_manager_table_migrated_failed', $table_name, $e->getMessage())); } } echo rex_view::info(rex_i18n::msg('yform_manager_table_migrate_info')); $fragment = new rex_fragment(); $fragment->setVar('class', 'edit', false); $fragment->setVar('title', rex_i18n::msg('yform_manager_table_migrate')); $fragment->setVar('body', $form, false); // $fragment->setVar('buttons', $buttons, false); $form = $fragment->parse('core/page/section.php'); echo $form;