static function getListValue($params) { $return = array(); $new_select = new self(); $values = $new_select->getArrayFromString($params['params']['field']['options']); foreach (explode(',', $params['value']) as $k) { if (isset($values[$k])) { $return[] = rex_i18n::translate($values[$k]); } } return implode('<br />', $return); }
function enterObject() { $options[1] = rex_i18n::msg('yform_prio_top'); $scopeWhere = $this->getScopeWhere(); if (false === $scopeWhere) { $options[''] = rex_i18n::msg('yform_prio_bottom'); } else { $this->preEditScopeWhere = $scopeWhere; $sql = rex_sql::factory(); if ($this->debug) { $sql->setDebug(); } $fields = $this->getElement('fields'); if (!is_array($fields)) { $fields = array_filter(explode(',', $fields)); } if (empty($fields)) { $fields = array('id'); } $selectFields = array(); foreach ($fields as $field) { $selectFields[] = $field; } $sql->setQuery(sprintf('SELECT id, %s, %s as prio FROM %s%s ORDER BY %2$s', implode(', ', $selectFields), $this->getElement('name'), $this->params['main_table'], $scopeWhere)); $prio = 1; while ($sql->hasNext()) { if ($sql->getValue('id') != $this->params['main_id']) { $prio = $sql->getValue('prio') + 1; $label = array(); foreach ($fields as $field) { $label[] = rex_i18n::translate($sql->getValue($field)); } $options[$prio] = rex_i18n::msg('yform_prio_after', implode(' | ', $label)); } $sql->next(); } } if (!$this->params['send'] && $this->getValue() == '') { if ($this->getElement('default') == '') { $this->setValue(isset($prio) ? $prio : ''); } else { $this->setValue($this->getElement('default')); } } if (!is_array($this->getValue())) { $this->setValue(explode(',', $this->getValue())); } $this->params['form_output'][$this->getId()] = $this->parse('value.select.tpl.php', array('options' => $options, 'multiple' => false, 'size' => 1)); $this->setValue(implode(',', $this->getValue())); $this->params['value_pool']['email'][$this->getName()] = $this->getValue(); $this->params['value_pool']['sql'][$this->getName()] = $this->getValue(); }
function executeAction() { $text = $this->getElement(2); if ($text == '') { $text = $this->params['answertext']; } $text = rex_i18n::translate($text, null); if ($this->getElement(5) == '0') { $text = nl2br(htmlspecialchars($text)); } if ($this->getElement(5) == '2') { $text = htmlspecialchars_decode($text); $text = str_replace('<br />', '', $text); $text = str_replace(''', '\'', $text); $text = rex_a79_textile($text); } $text = $this->getElement(3) . $text . $this->getElement(4); foreach ($this->params['value_pool']['email'] as $search => $replace) { $text = str_replace('###' . $search . '###', $replace, $text); } $this->params['output'] = $text; }
function rex_yform_list_translate($params) { return rex_i18n::translate($params['subject']); }
/** * Returns a clang switch. * * @param rex_context $context * * @return string */ public static function clangSwitchAsDropdown(rex_context $context) { if (rex_clang::count() == 1) { return ''; } $button_label = ''; $items = []; foreach (rex_clang::getAll() as $id => $clang) { if (rex::getUser()->getComplexPerm('clang')->hasPerm($id)) { $item = []; $item['title'] = rex_i18n::translate($clang->getName()); $item['href'] = $context->getUrl(['clang' => $id]); if ($id == $context->getParam('clang')) { $item['active'] = true; $button_label = rex_i18n::translate($clang->getName()); } $items[] = $item; } } $fragment = new rex_fragment(); $fragment->setVar('class', 'rex-language'); $fragment->setVar('button_prefix', rex_i18n::msg('language')); $fragment->setVar('button_label', $button_label); $fragment->setVar('header', rex_i18n::msg('clang_select')); $fragment->setVar('items', $items, false); if (rex::getUser()->isAdmin()) { $fragment->setVar('footer', '<a href="' . rex_url::backendPage('system/lang') . '"><i class="fa fa-flag"></i> ' . rex_i18n::msg('languages_edit') . '</a>', false); } return $fragment->parse('core/dropdowns/dropdown.php'); }
if (!is_array($modules)) { $modules = []; } if (!is_array($categories)) { $categories = []; } // modules[ctype_id][module_id]; // modules[ctype_id]['all']; // Module ... $modul_select = new rex_select(); $modul_select->setMultiple(true); $modul_select->setSize(10); $modul_select->setAttribute('class', 'form-control'); $m_sql = rex_sql::factory(); foreach ($m_sql->getArray('SELECT id, name FROM ' . rex::getTablePrefix() . 'module ORDER BY name') as $m) { $modul_select->addOption(rex_i18n::translate($m['name']), $m['id']); } // Kategorien $cat_select = new rex_category_select(false, false, false, false); $cat_select->setMultiple(true); $cat_select->setSize(10); $cat_select->setName('categories[]'); $cat_select->setId('rex-id-categories-select'); $cat_select->setAttribute('class', 'form-control'); if (count($categories) > 0) { foreach ($categories as $c => $cc) { // typsicherer vergleich, weil (0 != "all") => false if ($c !== 'all') { $cat_select->setSelected($cc); } }
protected function addSlice($sliceId, $moduleIdToAdd) { $MOD = rex_sql::factory(); $MOD->setQuery('SELECT * FROM ' . rex::getTablePrefix() . 'module WHERE id="' . $moduleIdToAdd . '"'); if ($MOD->getRows() != 1) { $slice_content = rex_view::warning(rex_i18n::msg('module_doesnt_exist')); } else { $initDataSql = rex_sql::factory(); // ----- PRE VIEW ACTION [ADD] $action = new rex_article_action($moduleIdToAdd, 'add', $initDataSql); $action->setRequestValues(); $action->exec(rex_article_action::PREVIEW); // ----- / PRE VIEW ACTION $moduleInput = $this->replaceVars($initDataSql, $MOD->getValue('input')); $moduleInput = $this->getStreamOutput('module/' . $moduleIdToAdd . '/input', $moduleInput); $msg = ''; if ($this->warning != '') { $msg .= rex_view::warning($this->warning); } if ($this->info != '') { $msg .= rex_view::success($this->info); } $formElements = []; $n = []; $n['field'] = '<a class="btn btn-abort" href="' . rex_url::currentBackendPage(['article_id' => $this->article_id, 'slice_id' => $sliceId, 'clang' => $this->clang, 'ctype' => $this->ctype]) . '#slice' . $sliceId . '">' . rex_i18n::msg('form_abort') . '</a>'; $formElements[] = $n; $n = []; $n['field'] = '<button class="btn btn-save" type="submit" name="btn_save" value="1"' . rex::getAccesskey(rex_i18n::msg('add_block'), 'save') . '>' . rex_i18n::msg('add_block') . '</button>'; $formElements[] = $n; $fragment = new rex_fragment(); $fragment->setVar('elements', $formElements, false); $slice_footer = $fragment->parse('core/form/submit.php'); $panel = ' <fieldset> <legend>' . rex_i18n::msg('add_block') . '</legend> <input type="hidden" name="function" value="add" /> <input type="hidden" name="module_id" value="' . $moduleIdToAdd . '" /> <input type="hidden" name="save" value="1" /> <div class="rex-slice-input"> ' . $moduleInput . ' </div> </fieldset> '; $fragment = new rex_fragment(); $fragment->setVar('before', $msg, false); $fragment->setVar('class', 'add', false); $fragment->setVar('title', rex_i18n::msg('module') . ': ' . rex_i18n::translate($MOD->getValue('name')), false); $fragment->setVar('body', $panel, false); $fragment->setVar('footer', $slice_footer, false); $slice_content = $fragment->parse('core/page/section.php'); $slice_content = ' <li class="rex-slice rex-slice-add" id="slice' . $sliceId . '"> <form action="' . rex_url::currentBackendPage(['article_id' => $this->article_id, 'slice_id' => $sliceId, 'clang' => $this->clang, 'ctype' => $this->ctype]) . '#slice' . $sliceId . '" method="post" id="REX_FORM" enctype="multipart/form-data"> ' . $slice_content . ' </form> <script type="text/javascript"> <!-- jQuery(function($) { $(":input:visible:enabled:not([readonly]):first", $("#REX_FORM")).focus(); }); //--> </script> </li> '; } return $slice_content; }
?> <li class="el_<?php echo $k; ?> "><?php echo rex_i18n::translate($v, null, false); ?> </li> <?php } ?> <?php if ($this->objparams['unique_error'] != '') { ?> <li><?php echo rex_i18n::translate(preg_replace("~\\*|:|\\(.*\\)~Usim", '', $this->objparams['unique_error'])); ?> </li> <?php } ?> </ul> <?php if ($this->objparams['Error-occured']) { ?> </dd> </dl> <?php } }
' . $actions . ' </tbody> </table> '; $fragment = new rex_fragment(); $fragment->setVar('title', rex_i18n::msg('actions_added_caption'), false); $fragment->setVar('content', $panel, false); $content .= $fragment->parse('core/page/section.php'); } $gaa_sel = new rex_select(); $gaa_sel->setName('action_id'); $gaa_sel->setId('action_id'); $gaa_sel->setSize(1); $gaa_sel->setAttribute('class', 'form-control'); for ($i = 0; $i < $gaa->getRows(); ++$i) { $gaa_sel->addOption(rex_i18n::translate($gaa->getValue('name'), false), $gaa->getValue('id')); $gaa->next(); } $panel = ''; $panel .= '<fieldset>'; $formElements = []; $n = []; $n['label'] = '<label for="action_id">' . rex_i18n::msg('action') . '</label>'; $n['field'] = $gaa_sel->get(); $formElements[] = $n; $fragment = new rex_fragment(); $fragment->setVar('elements', $formElements, false); $panel .= $fragment->parse('core/form/form.php'); $panel .= '</fieldset>'; $formElements = []; $n = [];
static function getListValue($params) { // TODO Relation table berücksichtigen $field = $params['params']['field']; if (4 == $field['type']) { $link = 'index.php?page=yform&subpage=manager&tripage=data_edit&table_name=' . $field['table']; if (is_int($popup = rex_request('popup', 'int', null))) { $link .= '&popup=' . $popup; } elseif (!rex_request('rex_yform_filter', 'array')) { $link .= '&popup=0'; } if (isset($field['filter']) && $field['filter']) { $filter = self::getFilterArray($field['filter'], $field['table_name'], function ($key) use($params) { return $params['list']->getValue($key); }); } $filter[$field['field']] = $params['list']->getValue('id'); self::addFilterParams($link, $filter); return '<a href="' . $link . '">' . rex_i18n::translate($field['label']) . '</a>'; } $listValues = self::getListValues($field['table'], $field['field']); $return = array(); foreach (explode(',', $params['value']) as $value) { if (isset($listValues[$value])) { $return[] = $listValues[$value]; } } return implode('<br />', $return); }
$info = rex_i18n::msg('category_moved'); ob_end_clean(); rex_response::sendRedirect($context->getUrl(['page' => 'content/edit', 'info' => $info], false)); } else { $warning = rex_i18n::msg('content_error_movecategory'); } } else { $warning = rex_i18n::msg('no_rights_to_this_function'); } } // ------------------------------------------ END: MOVE CATEGORY // ------------------------------------------ START: CONTENT HEAD MENUE $editPage = rex_be_controller::getPageObject('content/edit'); $editPage->setHref($context->getUrl(['page' => 'content/edit'], false)); foreach ($ctypes as $key => $val) { $editPage->addSubpage((new rex_be_page('ctype' . $key, rex_i18n::translate($val)))->setHref(['page' => 'content/edit', 'article_id' => $article_id, 'clang' => $clang, 'ctype' => $key], false)->setIsActive($ctype == $key)); } $nav = rex_be_navigation::factory(); $nav->addPage($editPage); $blocks = $nav->getNavigation(); $navigation = current($blocks); $content_navi_left = $navigation['navigation']; $nav = rex_be_navigation::factory(); foreach (rex_be_controller::getPageObject('content')->getSubpages() as $subpage) { if ($subpage->getKey() != 'edit') { $subpage->setHref($context->getUrl(['page' => $subpage->getFullKey()], false)); $nav->addPage($subpage); } } $blocks = $nav->getNavigation(); $navigation = current($blocks);
<p class="formsubmit formsubmits <?php echo $this->getHTMLClass(); ?> "> <?php $css_classes = $this->getElement("css_classes"); if ($css_classes == "") { $css_classes = array(); } else { $css_classes = explode(",", $this->getElement("css_classes")); } $labels = explode(",", $this->getElement("labels")); foreach ($labels as $label) { $classes = array(); $classes[] = 'submit'; if ($this->getWarningClass() != "") { $classes[] = $this->getWarningClass(); } $value = htmlspecialchars(stripslashes(rex_i18n::translate($label))); $id = $this->getFieldId(); $key = array_search($label, $labels); if ($key !== FALSE && isset($css_classes[$key])) { $classes[] = $css_classes[$key]; } echo '<input type="submit" class="' . implode(" ", $classes) . '" name="' . $this->getFieldName() . '" id="' . $id . '" value="' . $label . '" />'; } ?> </p>
// --------------------------------------------- ARTIKEL LISTE $echo = ''; // --------------------- READ TEMPLATES if ($category_id > 0 || $category_id == 0 && !rex::getUser()->getComplexPerm('structure')->hasMountpoints()) { $withTemplates = $this->getPlugin('content')->isAvailable(); $tmpl_head = ''; if ($withTemplates) { $template_select = new rex_select(); $template_select->setName('template_id'); $template_select->setSize(1); $template_select->setStyle('class="form-control"'); $templates = rex_template::getTemplatesForCategory($category_id); if (count($templates) > 0) { foreach ($templates as $t_id => $t_name) { $template_select->addOption(rex_i18n::translate($t_name, false), $t_id); $TEMPLATE_NAME[$t_id] = rex_i18n::translate($t_name); } } else { $template_select->addOption(rex_i18n::msg('option_no_template'), '0'); } $TEMPLATE_NAME[0] = rex_i18n::msg('template_default_name'); $tmpl_head = '<th>' . rex_i18n::msg('header_template') . '</th>'; } // --------------------- ARTIKEL LIST $art_add_link = ''; if ($KATPERM) { $art_add_link = '<a href="' . $context->getUrl(['function' => 'add_art', 'artstart' => $artstart]) . '"' . rex::getAccesskey(rex_i18n::msg('article_add'), 'add_2') . '><i class="rex-icon rex-icon-add-article"></i></a>'; } // ---------- COUNT DATA $sql = rex_sql::factory(); // $sql->setDebug();
function enterObject() { $error = array(); $rfile = 'file_' . md5($this->getFieldName('file')); $err_msgs = $this->getElement('messages'); // min_err,max_err,type_err,empty_err if (!is_array($err_msgs)) { $err_msgs = explode(',', $err_msgs); } $err_msgs['min_error'] = $err_msgs[0]; $err_msgs['max_error'] = isset($err_msgs[1]) ? rex_i18n::translate($err_msgs[1]) : 'max_error'; $err_msgs['type_error'] = isset($err_msgs[2]) ? rex_i18n::translate($err_msgs[2]) : 'type_error'; $err_msgs['empty_error'] = isset($err_msgs[3]) ? rex_i18n::translate($err_msgs[3]) : 'empty_error'; $err_msgs['delete_file'] = isset($err_msgs[4]) ? rex_i18n::translate($err_msgs[4]) : 'delete '; $this->tmp_messages = $err_msgs; $value = $this->getValue(); if ($value == "") { $value = $this->getElement('default_file'); } $this->setValue(''); $value_email = ''; $value_sql = ''; if (!is_string($value) && $value["delete"] == 1) { $value = ''; } // SIZE CHECK $sizes = explode(',', $this->getElement('max_size')); $minsize = count($sizes) > 1 ? (int) ($sizes[0] * 1024) : 0; $maxsize = count($sizes) > 1 ? (int) ($sizes[1] * 1024) : (int) ($sizes[0] * 1024); if ($this->params['send'] && isset($_FILES[$rfile]) && $_FILES[$rfile]['name'] != '' && ($_FILES[$rfile]['size'] > $maxsize || $_FILES[$rfile]['size'] < $minsize)) { if ($_FILES[$rfile]['size'] < $minsize) { $error[] = $err_msgs['min_error']; } if ($_FILES[$rfile]['size'] > $maxsize) { $error[] = $err_msgs['max_error']; } unset($_FILES[$rfile]); } $database_filename_field = $this->getElement('database_filename_field'); if ($database_filename_field != "") { $value = $this->params['value_pool']['sql'][$database_filename_field]; } $prefix = md5(mt_rand() . microtime(true)) . '_'; if ($this->getElement('file_prefix')) { $prefix .= $this->getElement('file_prefix') . '_'; } $upload_folder = $this->getElement('upload_folder'); if ($upload_folder == "") { $upload_folder = rex_path::addonData('yform', 'uploads'); rex_dir::create($upload_folder); } if ($value != "") { if ($REX["REDAXO"]) { $value = explode("_", $value, 2); $value = $value[0]; } $search_path = $upload_folder . '/' . $value . '_' . $this->getElement('file_prefix'); $files = glob(preg_replace('/(\\*|\\?|\\[)/', '[$1]', $search_path) . '*'); if (count($files) == 1) { $value = basename($files[0]); if (rex_request("rex_upload_downloadfile") == $value) { $file = $upload_folder . '/' . $value; if (file_exists($file)) { ob_end_clean(); $filename = explode("_", basename($file), 2); $filename = $filename[1]; header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename=' . $filename); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); header('Content-Length: ' . filesize($file)); readfile($file); exit; } } } else { $value = ""; } } if ($this->params['send']) { if (isset($_FILES[$rfile]) && $_FILES[$rfile]['name'] != '') { $FILE['size'] = $_FILES[$rfile]['size']; $FILE['name'] = $_FILES[$rfile]['name']; $FILE['type'] = $_FILES[$rfile]['type']; $FILE['tmp_name'] = $_FILES[$rfile]['tmp_name']; $FILE['error'] = $_FILES[$rfile]['error']; $FILE['name_normed'] = strtolower(preg_replace('/[^a-zA-Z0-9.\\-\\$\\+]/', '_', $FILE['name'])); $extensions_array = explode(',', $this->getElement('types')); $ext = '.' . pathinfo($FILE['name'], PATHINFO_EXTENSION); if (!in_array(strtolower($ext), $extensions_array) && !in_array(strtoupper($ext), $extensions_array)) { $error[] = $err_msgs['type_error']; $value = ''; } else { $file_normed = $FILE['name_normed']; $file_normed_new = $prefix . $file_normed; if (file_exists($upload_folder . '/' . $file_normed_new)) { for ($cf = 1; $cf < 1000; $cf++) { $file_normed_new = $prefix . $cf . '_' . $file_normed; if (!file_exists($upload_folder . '/' . $file_normed_new)) { break; } } } $value = $file_normed_new; if (!@move_uploaded_file($FILE['tmp_name'], $upload_folder . '/' . $file_normed_new)) { if (!@copy($FILE['tmp_name'], $upload_folder . '/' . $file_normed_new)) { $error[] = 'upload failed: destination folder problem'; $value = ''; } else { @chmod($upload_folder . '/' . $file_normed_new, $REX['FILEPERM']); } } else { @chmod($upload_folder . '/' . $file_normed_new, $REX['FILEPERM']); } } } } if (count($error) == 0) { switch ($this->getElement('modus')) { case 'database': if ($database_filename_field != "") { $this->params['value_pool']['email'][$database_filename_field] = $value; // $FILE['name_normed']; $this->params['value_pool']['sql'][$database_filename_field] = $value; // $FILE['name_normed']; } $value_email = file_get_contents($upload_folder . '/' . $value); $value_sql = $value_email; break; case 'upload': default: $value_email = $value; $value_sql = $value_email; break; } } $this->setValue($value); $this->params['value_pool']['email'][$this->getName()] = $value_email; $this->params['value_pool']['sql'][$this->getName()] = $value_sql; ## check for required file if ($this->params['send'] && $this->getElement('required') == 1 && $this->getValue() == '') { $error[] = $err_msgs['empty_error']; } ## setting up error Message if ($this->params['send'] && count($error) > 0) { $this->params['warning'][$this->getId()] = $this->params['error_class']; $this->params['warning_messages'][$this->getId()] = implode(', ', $error); } $this->params['form_output'][$this->getId()] = $this->parse('value.upload.tpl.php'); }
<p class="formsubmit <?php echo $this->getHTMLClass(); ?> "> <input type="submit" class="submit <?php echo $this->getElement(4), ' ', $this->getWarningClass(); ?> " name="<?php echo $this->getFieldName(); ?> " id="<?php echo $this->getFieldId(); ?> " value="<?php echo htmlspecialchars(stripslashes(rex_i18n::translate($this->getValue()))); ?> " /> </p>
/** * Erstellt den nötigen HTML Code um ein Formular zu erweitern. * * @param rex_sql $sqlFields rex_sql-objekt, dass die zu verarbeitenden Felder enthält * @param array $epParams Array of all EP parameters * * @return string */ public function renderMetaFields(rex_sql $sqlFields, array $epParams) { $s = ''; // Startwert für MEDIABUTTON, MEDIALIST, LINKLIST zähler $media_id = 1; $mlist_id = 1; $link_id = 1; $llist_id = 1; $activeItem = isset($epParams['activeItem']) ? $epParams['activeItem'] : null; $sqlFields->reset(); for ($i = 0; $i < $sqlFields->getRows(); $i++, $sqlFields->next()) { // Umschliessendes Tag von Label und Formularelement $tag = 'p'; $tag_attr = ''; $name = $sqlFields->getValue('name'); $title = $sqlFields->getValue('title'); $params = $sqlFields->getValue('params'); $typeLabel = $sqlFields->getValue('label'); $attr = $sqlFields->getValue('attributes'); $dblength = $sqlFields->getValue('dblength'); $attrArray = rex_string::split($attr); if (isset($attrArray['perm'])) { if (!rex::getUser()->hasPerm($attrArray['perm'])) { continue; } unset($attrArray['perm']); } $defaultValue = $sqlFields->getValue('default'); if ($activeItem) { $itemValue = $activeItem->getValue($name); if (strpos($itemValue, '|+|') !== false) { // Alte notation mit |+| als Trenner $dbvalues = explode('|+|', $activeItem->getValue($name)); } else { // Neue Notation mit | als Trenner $dbvalues = explode('|', $activeItem->getValue($name)); } } else { $dbvalues = (array) $sqlFields->getValue('default'); } if ($title != '') { $label = rex_i18n::translate($title); } else { $label = htmlspecialchars($name); } $id = preg_replace('/[^a-zA-Z\\-0-9_]/', '_', $label); $labelIt = true; $label = '<label for="' . $id . '">' . $label . '</label>'; $field = ''; switch ($typeLabel) { case 'text': $tag_attr = ' class="form-control"'; $rexInput = rex_input::factory($typeLabel); $rexInput->addAttributes($attrArray); $rexInput->setAttribute('id', $id); $rexInput->setAttribute('name', $name); if ($dblength > 0) { $rexInput->setAttribute('maxlength', $dblength); } if ($activeItem) { $rexInput->setValue($activeItem->getValue($name)); } else { $rexInput->setValue($defaultValue); } $field = $rexInput->getHtml(); $e = []; $e['label'] = $label; $e['field'] = $field; $fragment = new rex_fragment(); $fragment->setVar('elements', [$e], false); $field = $fragment->parse('core/form/form.php'); break; case 'checkbox': // Beachte auch default values in multiple fields bei ADD. // Im EDIT wurde dies bereits vorher gehandelt if (!$activeItem) { $defaultValue = explode('|', $defaultValue); } $name .= '[]'; case 'radio': $formElements = []; $values = []; if (rex_sql::getQueryType($params) == 'SELECT') { $sql = rex_sql::factory(); $value_groups = $sql->getDBArray($params, [], PDO::FETCH_NUM); foreach ($value_groups as $value_group) { if (isset($value_group[1])) { $values[$value_group[1]] = $value_group[0]; } else { $values[$value_group[0]] = $value_group[0]; } } } else { $value_groups = explode('|', $params); foreach ($value_groups as $value_group) { // check ob key:value paar // und der wert beginnt nicht mit "translate:" if (strpos($value_group, ':') !== false && strpos($value_group, 'translate:') !== 0) { $temp = explode(':', $value_group, 2); $values[$temp[0]] = rex_i18n::translate($temp[1]); } else { $values[$value_group] = rex_i18n::translate($value_group); } } } $oneValue = count($values) == 1; $attrStr = ''; $classAdd = ''; $inline = false; if (false !== ($key = array_search('inline', $attrArray))) { $inline = true; unset($attrArray[$key]); } foreach ($attrArray as $key => $value) { if ($key == 'class') { $classAdd = ' ' . $value; } else { $attrStr = ' ' . $key . '="' . $value . '"'; } } if (!$activeItem) { $dbvalues = (array) $defaultValue; } foreach ($values as $key => $value) { $id = preg_replace('/[^a-zA-Z\\-0-9_]/', '_', $id . $key); // wenn man keine Werte angibt (Boolean Chkbox/Radio) // Dummy Wert annehmen, damit an/aus unterscheidung funktioniert if ($oneValue && $key == '') { $key = 'true'; } $selected = ''; if (in_array($key, $dbvalues)) { $selected = ' checked="checked"'; } $e = []; if ($oneValue) { $e['label'] = $label; } else { $e['label'] = '<label for="' . $id . '">' . htmlspecialchars($value) . '</label>'; } $e['field'] = '<input type="' . $typeLabel . '" name="' . $name . '" value="' . htmlspecialchars($key) . '" id="' . $id . '" ' . $attrStr . $selected . ' />'; $formElements[] = $e; } $fragment = new rex_fragment(); $fragment->setVar('elements', $formElements, false); $fragment->setVar('inline', $inline); if ($typeLabel == 'radio') { $field = $fragment->parse('core/form/radio.php'); } else { if (!$oneValue) { $fragment->setVar('grouped', true); } $field = $fragment->parse('core/form/checkbox.php'); } if (!$oneValue) { $e = []; $e['label'] = $label; $e['field'] = $field; $fragment = new rex_fragment(); $fragment->setVar('elements', [$e], false); $field = $fragment->parse('core/form/form.php'); } break; case 'select': $tag_attr = ' class="form-control"'; $select = new rex_select(); $select->setStyle('class="form-control"'); $select->setName($name); $select->setId($id); $multiple = false; foreach ($attrArray as $attr_name => $attr_value) { if (empty($attr_name)) { continue; } $select->setAttribute($attr_name, $attr_value); if ($attr_name == 'multiple') { $multiple = true; $select->setName($name . '[]'); $select->setMultiple(); } } // Beachte auch default values in multiple fields bei ADD. // Im EDIT wurde dies bereits vorher gehandelt if ($multiple && !$activeItem) { $dbvalues = explode('|', $defaultValue); } // hier mit den "raw"-values arbeiten, da die rex_select klasse selbst escaped $select->setSelected($dbvalues); if (rex_sql::getQueryType($params) == 'SELECT') { // Werte via SQL Laden $select->addDBSqlOptions($params); } else { // Optionen mit | separiert // eine einzelne Option kann mit key:value separiert werden $values = []; $value_groups = explode('|', $params); foreach ($value_groups as $value_group) { // check ob key:value paar // und der wert beginnt nicht mit "translate:" if (strpos($value_group, ':') !== false && strpos($value_group, 'translate:') !== 0) { $temp = explode(':', $value_group, 2); $values[$temp[0]] = rex_i18n::translate($temp[1]); } else { $values[$value_group] = rex_i18n::translate($value_group); } } $select->addOptions($values); } $field .= $select->get(); $e = []; $e['label'] = $label; $e['field'] = $field; $fragment = new rex_fragment(); $fragment->setVar('elements', [$e], false); $field = $fragment->parse('core/form/form.php'); break; case 'date': case 'time': case 'datetime': $tag_attr = ' class="form-control-date"'; $active = $dbvalues[0] != 0; if ($dbvalues[0] == '') { $dbvalues[0] = time(); } $inputValue = []; $inputValue['year'] = date('Y', $dbvalues[0]); $inputValue['month'] = date('n', $dbvalues[0]); $inputValue['day'] = date('j', $dbvalues[0]); $inputValue['hour'] = date('G', $dbvalues[0]); $inputValue['minute'] = date('i', $dbvalues[0]); $rexInput = rex_input::factory($typeLabel); $rexInput->addAttributes($attrArray); $rexInput->setAttribute('id', $id); $rexInput->setAttribute('name', $name); $rexInput->setValue($inputValue); $field = $rexInput->getHtml(); $checked = $active ? ' checked="checked"' : ''; $field .= '<input class="rex-metainfo-checkbox" type="checkbox" name="' . $name . '[active]" value="1"' . $checked . ' />'; $e = []; $e['label'] = $label; $e['field'] = $field; $fragment = new rex_fragment(); $fragment->setVar('elements', [$e], false); $field = $fragment->parse('core/form/form.php'); break; case 'textarea': $tag_attr = ' class="form-control"'; $rexInput = rex_input::factory($typeLabel); $rexInput->addAttributes($attrArray); $rexInput->setAttribute('id', $id); $rexInput->setAttribute('name', $name); if ($activeItem) { $rexInput->setValue($activeItem->getValue($name)); } else { $rexInput->setValue($defaultValue); } $field = $rexInput->getHtml(); $e = []; $e['label'] = $label; $e['field'] = $field; $fragment = new rex_fragment(); $fragment->setVar('elements', [$e], false); $field = $fragment->parse('core/form/form.php'); break; case 'legend': $tag = ''; $tag_attr = ''; $labelIt = false; // tabindex entfernen, macht bei einer legend wenig sinn $attr = preg_replace('@tabindex="[^"]*"@', '', $attr); $field = '</fieldset><fieldset><legend id="' . $id . '"' . $attr . '>' . $label . '</legend>'; break; case 'REX_MEDIA_WIDGET': $tag = 'div'; $tag_attr = ' class="rex-form-widget"'; $paramArray = rex_string::split($params); $rexInput = rex_input::factory('mediabutton'); $rexInput->addAttributes($attrArray); $rexInput->setButtonId($media_id); $rexInput->setAttribute('name', $name); $rexInput->setValue($dbvalues[0]); if (isset($paramArray['category'])) { $rexInput->setCategoryId($paramArray['category']); } if (isset($paramArray['types'])) { $rexInput->setTypes($paramArray['types']); } if (isset($paramArray['preview'])) { $rexInput->setPreview($paramArray['preview']); } $id = $rexInput->getAttribute('id'); $field = $rexInput->getHtml(); $e = []; $e['label'] = $label; $e['field'] = $field; $fragment = new rex_fragment(); $fragment->setVar('elements', [$e], false); $field = $fragment->parse('core/form/form.php'); ++$media_id; break; case 'REX_MEDIALIST_WIDGET': $tag = 'div'; $tag_attr = ' class="rex-form-widget"'; $paramArray = rex_string::split($params); $name .= '[]'; $rexInput = rex_input::factory('medialistbutton'); $rexInput->addAttributes($attrArray); $rexInput->setButtonId($mlist_id); $rexInput->setAttribute('name', $name); $rexInput->setValue($dbvalues[0]); if (isset($paramArray['category'])) { $rexInput->setCategoryId($paramArray['category']); } if (isset($paramArray['types'])) { $rexInput->setTypes($paramArray['types']); } if (isset($paramArray['preview'])) { $rexInput->setPreview($paramArray['preview']); } $id = $rexInput->getAttribute('id'); $field = $rexInput->getHtml(); $e = []; $e['label'] = $label; $e['field'] = $field; $fragment = new rex_fragment(); $fragment->setVar('elements', [$e], false); $field = $fragment->parse('core/form/form.php'); ++$mlist_id; break; case 'REX_LINK_WIDGET': $tag = 'div'; $tag_attr = ' class="rex-form-widget"'; $paramArray = rex_string::split($params); $category = ''; if (isset($paramArray['category'])) { $category = $paramArray['category']; } elseif ($activeItem) { $category = $activeItem->getValue('category_id'); } $rexInput = rex_input::factory('linkbutton'); $rexInput->addAttributes($attrArray); $rexInput->setButtonId($link_id); $rexInput->setCategoryId($category); $rexInput->setAttribute('name', $name); $rexInput->setValue($dbvalues[0]); $id = $rexInput->getAttribute('id'); $field = $rexInput->getHtml(); $e = []; $e['label'] = $label; $e['field'] = $field; $fragment = new rex_fragment(); $fragment->setVar('elements', [$e], false); $field = $fragment->parse('core/form/form.php'); ++$link_id; break; case 'REX_LINKLIST_WIDGET': $tag = 'div'; $tag_attr = ' class="rex-form-widget"'; $paramArray = rex_string::split($params); $category = ''; if (isset($paramArray['category'])) { $category = $paramArray['category']; } elseif ($activeItem) { $category = $activeItem->getValue('category_id'); } $name .= '[]'; $rexInput = rex_input::factory('linklistbutton'); $rexInput->addAttributes($attrArray); $rexInput->setButtonId($llist_id); $rexInput->setCategoryId($category); $rexInput->setAttribute('name', $name); $rexInput->setValue(implode(',', $dbvalues)); $id = $rexInput->getAttribute('id'); $field = $rexInput->getHtml(); $e = []; $e['label'] = $label; $e['field'] = $field; $fragment = new rex_fragment(); $fragment->setVar('elements', [$e], false); $field = $fragment->parse('core/form/form.php'); ++$llist_id; break; default: // ----- EXTENSION POINT list($field, $tag, $tag_attr, $id, $label, $labelIt) = rex_extension::registerPoint(new rex_extension_point('METAINFO_CUSTOM_FIELD', [$field, $tag, $tag_attr, $id, $label, $labelIt, 'values' => $dbvalues, 'rawvalues' => $dbvalues, 'type' => $typeLabel, 'sql' => $sqlFields])); } $s .= $this->renderFormItem($field, $tag, $tag_attr, $id, $label, $labelIt, $typeLabel); } return $s; }
public function setColumnLabel($columnName, $label) { $this->columnLabels[$columnName] = rex_i18n::translate($label, null); }
<?php $notice = array(); if ($this->getElement('notice') != "") { $notice[] = $this->getElement('notice'); } if (isset($this->params['warning_messages'][$this->getId()]) && !$this->params['hide_field_warning_messages']) { $notice[] = '<span class="text-warning">' . rex_i18n::translate($this->params['warning_messages'][$this->getId()], null, false) . '</span>'; // var_dump(); } if (count($notice) > 0) { $notice = '<p class="help-block">' . implode("<br />", $notice) . '</p>'; } else { $notice = ''; } $value = isset($value) ? $value : 1; $class_group = trim('form-group ' . $this->getWarningClass()); ?> <div class="checkbox" id="<?php echo $this->getHTMLId(); ?> "> <label> <input type="checkbox" id="<?php echo $this->getFieldId(); ?> " name="<?php echo $this->getFieldName(); ?> " value="<?php echo $value;
$lang_a = new rex_select(); $lang_a->setId('clang_a'); $lang_a->setName('clang_a'); $lang_a->setSize('1'); $lang_a->setAttribute('class', 'form-control'); foreach ($clang_perm as $key) { $val = rex_i18n::translate(rex_clang::get($key)->getName()); $lang_a->addOption($val, $key); } $lang_b = new rex_select(); $lang_b->setId('clang_b'); $lang_b->setName('clang_b'); $lang_b->setSize('1'); $lang_b->setAttribute('class', 'form-control'); foreach ($clang_perm as $key) { $val = rex_i18n::translate(rex_clang::get($key)->getName()); $lang_b->addOption($val, $key); } $lang_a->setSelected(rex_request('clang_a', 'int', null)); $lang_b->setSelected(rex_request('clang_b', 'int', null)); $panel = '<fieldset>'; $grid = []; $formElements = []; $n = []; $n['label'] = '<label for="clang_a">' . rex_i18n::msg('content_contentoflang') . '</label>'; $n['field'] = $lang_a->get(); $formElements[] = $n; $fragment = new rex_fragment(); $fragment->setVar('group', true); $fragment->setVar('elements', $formElements, false); $grid[] = $fragment->parse('core/form/form.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; } } }
function getLabelStyle($label) { $label = rex_i18n::translate($label, null); if ($this->params['form_label_type'] == 'html') { } else { $label = nl2br(htmlspecialchars($label)); } return $label; return '<span style="color:#f90">' . $label . '</span>'; }