$template_id = rex_request('template_id', 'int'); $content = ''; $show_list = true; if ($func == 'edit' || $func == 'add') { echo rex_view::info(rex_i18n::rawMsg('yform_email_info_text')); $form_data = []; $form_data[] = 'text|name|translate:yform_email_key'; $form_data[] = 'validate|empty|name|Bitte key eintragen'; $form_data[] = 'text|mail_from|translate:yform_email_from'; $form_data[] = 'text|mail_from_name|translate:yform_email_from_name'; $form_data[] = 'text|subject|translate:yform_email_subject'; $form_data[] = 'textarea|body|translate:yform_email_body'; $form_data[] = 'textarea|body_html|translate:yform_email_body_html'; $form_data[] = 'be_medialist|attachments|translate:yform_email_attachments'; $form_data[] = 'action|showtext|Vielen Dank|||1'; $yform = rex_yform::factory(); $yform->setObjectparams('form_action', 'index.php?page=yform/email/index&func=' . $func); $yform->setFormData(implode("\n", $form_data)); if ($func == 'edit') { $yform->setObjectparams('submit_btn_label', rex_i18n::msg('yform_save')); $yform->setHiddenField('template_id', $template_id); $yform->setActionField('db', array($table, "id={$template_id}")); $yform->setObjectparams('main_id', $template_id); $yform->setObjectparams('main_table', $table); $yform->setObjectparams('main_where', "id={$template_id}"); $yform->setObjectparams('getdata', true); $title = rex_i18n::msg('yform_email_update'); } else { $yform->setObjectparams('submit_btn_label', rex_i18n::msg('yform_add')); $yform->setActionField('db', array($table)); $title = rex_i18n::msg('yform_email_create');
<?php /** * YREWRITE Addon. * * @author jan.kristinus@yakamara.de * * @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();
$form = $fragment->parse('core/page/section.php'); echo $form; echo rex_view::info('<a href="index.php?page=' . $page . '"><b>« ' . rex_i18n::msg('yform_back_to_overview') . '</b></a>'); $show_list = false; } else { try { $content = file_get_contents($yform->objparams['value_pool']['email']['importfile']); rex_yform_manager_table_api::importTablesets($content); echo rex_view::info(rex_i18n::msg('yform_manager_table_import_success')); } catch (Exception $e) { 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}"));
$clang = $params['clang']; $ctype = $params['ctype']; $select_priority = []; $select_priority[] = rex_i18n::msg('yrewrite_priority_auto') . '='; foreach (rex_yrewrite_seo::$priority as $priority) { $select_priority[] = rex_i18n::msg('yrewrite_priority_' . str_replace('.', '_', $priority)) . '=' . $priority; } $select_changefreq = []; foreach (rex_yrewrite_seo::$changefreq as $changefreq) { $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]);
<?php rex_yform::addTemplatePath(rex_path::addon('yform', 'ytemplates'));
case 'm': $qty *= 1024; case 'k': $qty *= 1024; case 'b': $qty = $qty; } return $qty; } } } //### Achtung! Hinter <<< End darf kein Leerzeichen stehen. $rex_form_data = <<<End REX_VALUE[id=3] End; $rex_form_data = trim(str_replace("<br />", "", rex_yform::unhtmlentities($rex_form_data))); //### Achtung! Hinter <<< End darf kein Leerzeichen stehen. $mailbody = <<<End End; $responsemail = <<<End REX_VALUE[5] End; if (isset($_POST['eingabe'])) { $eingabe = $_POST['eingabe']; } $FORM = rex_request::post('FORM', 'array'); $formoutput = array(); $warning = array(); $warning_set = 0; // wird zu 1, wenn ein Fehler auftritt $form_elements = array();
<?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();
$article_id = $params['article_id']; $clang = $params['clang']; $ctype = $params['ctype']; // $yrewrite_url = stripslashes(rex_request('yrewrite_url')); $domain = rex_yrewrite::getDomainByArticleId($article_id, $clang); $isStartarticle = rex_yrewrite::isDomainStartArticle($article_id, $clang); $autoUrl = rex_getUrl(); if (0 === strpos($autoUrl, $domain->getUrl())) { $autoUrl = substr($autoUrl, strlen($domain->getUrl())); } else { $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;
<?php /** * YREWRITE Addon. * * @author jan.kristinus@yakamara.de * * @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', '']);
/** * YREWRITE Addon. * * @author jan.kristinus@yakamara.de * * @package redaxo\yrewrite * * @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')]);
static function generateTablesAndFields($delete_old = false) { rex_yform_manager_table::reload(); $types = rex_yform::getTypeArray(); foreach (rex_yform_manager_table::getAll() as $table) { $c = rex_sql::factory(); $c->debugsql = self::$debug; $c->setQuery('CREATE TABLE IF NOT EXISTS `' . $table['table_name'] . '` ( `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY )'); // remember fields, create and in case delete $c->setQuery('SHOW COLUMNS FROM `' . $table['table_name'] . '`'); $saved_columns = $c->getArray(); foreach ($table->getFields() as $field) { $type_name = $field['type_name']; $type_id = $field['type_id']; if ($type_id == 'value') { $type_label = $field['name']; $dbtype = $types[$type_id][$type_name]['dbtype']; if ($dbtype != 'none' && $dbtype != '') { if (isset($types[$type_id][$type_name]['hooks']['preCreate'])) { $result = call_user_func($types[$type_id][$type_name]['hooks']['preCreate'], $field); if (false === $result) { continue; } elseif (is_string($result)) { $dbtype = $result; } } $add_column = true; foreach ($saved_columns as $uu => $vv) { if ($vv['Field'] == $type_label) { $add_column = false; unset($saved_columns[$uu]); break; } } if ($add_column) { $null = isset($types[$type_id][$type_name]['null']) && $types[$type_id][$type_name]['null']; $null = $null ? '' : ' NOT NULL'; $c->setQuery('ALTER TABLE `' . $table['table_name'] . '` ADD `' . $type_label . '` ' . $dbtype . $null); } } } } if ($delete_old === true) { foreach ($saved_columns as $uu => $vv) { if ($vv['Field'] != 'id') { $c->setQuery('ALTER TABLE `' . $table['table_name'] . '` DROP `' . $vv['Field'] . '` '); } } } } }
function getQueryFilterArray() { if (!$this->table->isSearchable()) { return array(); } $queryFilter = array(); $vars = $this->getSearchVars(); foreach ($this->table->getFields() as $field) { if (array_key_exists($field->getName(), $vars['rex_yform_searchvars']) && $field->getType() == 'value' && $field->isSearchable()) { rex_yform::includeClass($field->getType(), $field->getTypeName()); if (method_exists('rex_yform_' . $field->getTypeName(), 'getSearchFilter')) { $qf = call_user_func('rex_yform_' . $field->getTypeName() . '::getSearchFilter', array('field' => $field, 'fields' => $this->table->getFields(), 'value' => $vars['rex_yform_searchvars'][$field->getName()])); if ($qf != '') { $queryFilter[] = $qf; } } } } return $queryFilter; }
<?php /** * yform * @author jan.kristinus[at]redaxo[dot]org Jan Kristinus * @author <a href="http://www.yakamara.de">www.yakamara.de</a> * * @var rex_plugin $this */ rex_yform::addTemplatePath(rex_path::plugin('yform', 'manager', 'ytemplates')); if (rex::isBackend() && rex::getUser()) { rex_view::addJsFile($this->getAssetsUrl('manager.js')); $tables = rex_yform_manager_table::getAll(); $pages = []; foreach ($tables as $table) { $table_perm = 'yform[table:' . $table['table_name'] . ']'; if ($table['status'] == 1 && $table['hidden'] != 1) { $be_page = new rex_be_page_main('yform_tables', $table['table_name'], $table['name']); $be_page->setHref('index.php?page=yform/manager/data_edit&table_name=' . $table['table_name']); $be_page->setIcon('rex-icon rex-icon-module'); $be_page->setRequiredPermissions([$table_perm]); if (rex_request('page', 'string') == 'yform/manager/data_edit' && rex_request('table_name', 'string') == $table['table_name']) { $be_page->setIsActive(); $main_page = $this->getAddon()->getProperty('page'); $main_page['isActive'] = false; $this->getAddon()->setProperty('page', $main_page); } $pages[] = $be_page; // TODO rechte noch verfügbar machen } }
/** * 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_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");
<?php echo rex_view::title('yform'); $fragment = new rex_fragment(); $fragment->setVar('class', 'info'); $fragment->setVar('title', rex_i18n::msg('yform_description_title'), false); $fragment->setVar('body', rex_i18n::rawMsg('yform_description_all', false) . rex_yform::showHelp(true, true), false); echo $fragment->parse('core/page/section.php');
$mi->update(); echo rex_view::success('Modul "' . $module_name . '" wurde aktualisiert'); } else { $mi->setValue('name', $yform_module_name); $mi->insert(); $module_id = (int) $mi->getLastId(); $module_name = $yform_module_name; echo rex_view::success('yform Modul wurde angelegt unter "' . $yform_module_name . '"'); } } $content .= '<p>' . $this->i18n('install_modul_description') . '<br /><br />'; if ($module_id > 0) { $content .= '<p><a class="btn btn-primary" href="index.php?page=yform/overview&install=1&module_id=' . $module_id . '" class="rex-button">' . $this->i18n('install_update_module', htmlspecialchars($module_name)) . '</a></p>'; } else { $content .= '<p><a class="btn btn-primary" href="index.php?page=yform/overview&install=1" class="rex-button">' . $this->i18n('install_yform_modul', $yform_module_name) . '</a></p>'; } $content .= '</p>'; $fragment = new rex_fragment(); $fragment->setVar('title', $this->i18n('install_modul'), false); $fragment->setVar('body', $content, false); echo $fragment->parse('core/page/section.php'); } $content = rex_i18n::rawMsg('yform_description_all', false); $fragment = new rex_fragment(); $fragment->setVar('title', $this->i18n('description'), false); $fragment->setVar('body', $content, false); echo $fragment->parse('core/page/section.php'); $fragment = new rex_fragment(); $fragment->setVar('title', $this->i18n('description_type_heading'), false); $fragment->setVar('content', rex_yform::showHelp(true, true), false); echo $fragment->parse('core/page/section.php');
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; } } }
} $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(); 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);