Exemplo n.º 1
0
    function enterObject(&$email_elements, &$sql_elements, &$warning, &$form_output, $send = 0)
    {
        if ($this->getValue() == "" && !$send) {
            if (isset($this->elements[3])) {
                $this->setValue($this->elements[3]);
            }
        }
        $classes = "";
        if (isset($this->elements[5])) {
            $classes .= " " . $this->elements[5];
        }
        $wc = "";
        if (isset($warning[$this->getId()])) {
            $wc = " " . $warning[$this->getId()];
        }
        $this->params["form_output"][$this->getId()] = '
			<p class="formtext formlabel-' . $this->getName() . '" id="' . $this->getHTMLId() . '">
				<label class="text' . $wc . '" for="' . $this->getFieldId() . '" >' . rex_translate($this->getElement(2)) . '</label>
				<input type="text" class="text' . $classes . $wc . '" name="' . $this->getFieldName() . '" id="' . $this->getFieldId() . '" value="' . htmlspecialchars(stripslashes($this->getValue())) . '" />
			</p>';
        $email_elements[$this->elements[1]] = stripslashes($this->getValue());
        if (!isset($this->elements[4]) || $this->elements[4] != "no_db") {
            $sql_elements[$this->elements[1]] = $this->getValue();
        }
    }
    function enterObject(&$email_elements, &$sql_elements, &$warning, &$form_output, $send = 0)
    {
        if (!isset($this->elements[3]) || $this->elements[3] == "") {
            $this->elements[3] = 1;
        }
        $checked = "";
        if ($this->getElement(3) != "" && $this->getValue() == $this->getElement(3)) {
            $checked = ' checked="checked"';
            $v = $this->getElement(3);
        } elseif ($this->getValue() == 1) {
            $checked = ' checked="checked"';
            $v = 1;
        } else {
            $this->setValue("0");
            $v = 1;
        }
        $wc = "";
        if (isset($warning[$this->getId()])) {
            $wc = $warning[$this->getId()];
        }
        $form_output[$this->getId()] = '
			<p class="formcheckbox formlabel-' . $this->getName() . '" id="' . $this->getHTMLId() . '">
				<input type="checkbox" class="checkbox ' . $wc . '" name="' . $this->getFieldName() . '" id="' . $this->getFieldId() . '" value="' . $v . '" ' . $checked . ' />
				<label class="checkbox ' . $wc . '" for="' . $this->getFieldId() . '" >' . rex_translate($this->elements[2]) . '</label>
			</p>';
        $email_elements[$this->elements[1]] = stripslashes($this->value);
        if (!isset($this->elements[5]) || $this->elements[5] != "no_db") {
            $sql_elements[$this->elements[1]] = $this->value;
        }
    }
    function enterObject(&$email_elements, &$sql_elements, &$warning, &$form_output, $send = 0)
    {
        if ($this->value == "" && !$send) {
            if (isset($this->elements[3])) {
                $this->setValue($this->elements[3]);
            }
        }
        $classes = "";
        if (isset($this->elements[5])) {
            $classes .= " " . $this->elements[5];
        }
        $wc = "";
        if (isset($warning[$this->getId()])) {
            $wc = " " . $warning[$this->getId()];
        }
        $form_output[$this->getId()] = '
		<p class="formtextarea" id="' . $this->getHTMLId() . '">
			<label class="textarea ' . $wc . '" for="el_' . $this->id . '" >' . rex_translate($this->getElement(2)) . '</label>
			<textarea class="textarea' . $classes . $wc . '" name="' . $this->getFormFieldname() . '" id="el_' . $this->getId() . '" cols="80" rows="10">' . htmlspecialchars(stripslashes($this->value)) . '</textarea>
		</p>';
        $email_elements[$this->getName()] = stripslashes($this->value);
        if (!isset($this->elements[4]) || $this->elements[4] != "no_db") {
            $sql_elements[$this->getName()] = $this->getValue();
        }
    }
    public static function printLangSelect($params)
    {
        global $REX, $I18N;
        $out = '';
        $clang = rex_request('clang', 'int');
        $out .= '
			 <div id="rex-clang" class="rex-toolbar">
			 <div class="rex-toolbar-content">
				 <ul>
					 <li>' . $I18N->msg("languages") . ' : </li>';
        $i = 0;
        $stop = false;
        foreach ($REX['CLANG'] as $key => $val) {
            $i++;
            if ($i == 1) {
                $out .= '<li class="rex-navi-first rex-navi-clang-' . $key . '">';
            } else {
                $out .= '<li class="rex-navi-clang-' . $key . '">';
            }
            $val = rex_translate($val);
            $class = '';
            if ($key == $clang) {
                $class = ' class="rex-active"';
            }
            $curQuery = rex_post('current_query', 'string', '');
            if ($curQuery != '') {
                $urlQuery = $curQuery;
                parse_str($curQuery, $vals);
                $vals['clang'] = $key;
                $urlQuery = http_build_query($vals);
            } else {
                $urlQuery = self::getURLQuery($key);
            }
            if (!$REX['USER']->isAdmin() && !$REX['USER']->hasPerm('clang[all]') && !$REX['USER']->hasPerm('clang[' . $key . ']')) {
                $out .= '<span class="rex-strike">' . $val . '</span>';
                if ($clang == $key) {
                    $stop = true;
                }
            } else {
                $out .= '<a' . $class . ' href="index.php?' . $urlQuery . '">' . $val . '</a>';
                $out .= '</li>';
            }
        }
        $out .= '
				 </ul>
			 </div>
			 </div>
		';
        echo $out;
        if ($stop) {
            echo '
			<!-- *** OUTPUT OF CLANG-VALIDATE - START *** -->
			' . rex_warning($I18N->msg('string_table_no_lang_perm')) . '
			<!-- *** OUTPUT OF CLANG-VALIDATE - END *** -->
			';
            require $REX['INCLUDE_PATH'] . "/layout/bottom.php";
            exit;
        }
    }
 function enterObject(&$email_elements, &$sql_elements, &$warning, &$form_output, $send = 0)
 {
     $multiple = FALSE;
     if (isset($this->elements[6]) && $this->elements[6] == 1) {
         $multiple = TRUE;
     }
     $size = (int) $this->getElement(7);
     if ($size < 1) {
         $size = 1;
     }
     $SEL = new rex_select();
     $SEL->setId("el_" . $this->getId());
     if ($multiple) {
         if ($size == 1) {
             $size = 2;
         }
         $SEL->setName($this->getFormFieldname() . "[]");
         $SEL->setSize($size);
         $SEL->setMultiple(1);
     } else {
         $SEL->setName($this->getFormFieldname());
         $SEL->setSize(1);
     }
     foreach (explode(',', $this->elements[3]) as $v) {
         $teile = explode('=', $v);
         $wert = $teile[0];
         if (isset($teile[1])) {
             $bezeichnung = $teile[1];
         } else {
             $bezeichnung = $teile[0];
         }
         $SEL->addOption(rex_translate($wert), $bezeichnung);
     }
     if (!$send && $this->value == "" && isset($this->elements[5]) && $this->elements[5] != "") {
         $this->value = $this->elements[5];
     }
     if (!is_array($this->getValue())) {
         $this->value = explode(",", $this->getValue());
     }
     foreach ($this->getValue() as $v) {
         $SEL->setSelected($v);
     }
     $this->value = implode(",", $this->getValue());
     $wc = "";
     if (isset($warning[$this->getId()])) {
         $wc = $warning[$this->getId()];
     }
     $SEL->setStyle(' class="select ' . $wc . '"');
     $form_output[$this->getId()] = '
   <p class="formselect formlabel-' . $this->getName() . '" id="' . $this->getHTMLId() . '">
   <label class="select ' . $wc . '" for="el_' . $this->getId() . '" >' . rex_translate($this->getElement(2)) . '</label>' . $SEL->get() . '</p>';
     $email_elements[$this->elements[1]] = $this->getValue();
     if (!isset($this->elements[4]) || $this->elements[4] != "no_db") {
         $sql_elements[$this->elements[1]] = $this->getValue();
     }
 }
 static function getListValue($params)
 {
     $return = array();
     $new_select = new rex_xform_select();
     $values = $new_select->getArrayFromString($params['params']['field']['options']);
     foreach (explode(',', $params['value']) as $k) {
         if (isset($values[$k])) {
             $return[] = rex_translate($values[$k]);
         }
     }
     return implode('<br />', $return);
 }
 function enterObject()
 {
     global $I18N;
     $options[1] = $I18N->msg('xform_prio_top');
     $scopeWhere = $this->getScopeWhere();
     if (false === $scopeWhere) {
         $options[''] = $I18N->msg('xform_prio_bottom');
     } else {
         $this->preEditScopeWhere = $scopeWhere;
         $sql = rex_sql::factory();
         $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[] = '`' . $sql->escape($field) . '`';
         }
         $sql->setQuery(sprintf('SELECT id, %s, `%s` as prio FROM `%s`%s ORDER BY `%2$s`', implode(', ', $selectFields), $sql->escape($this->getElement('name')), $sql->escape($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_translate($sql->getValue($field), $I18N, false);
                 }
                 $options[$prio] = $I18N->msg('xform_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();
 }
Exemplo n.º 8
0
function rex_asd_news_language($curClang, $urlParam)
{
    global $REX;
    global $I18N;
    reset($REX['CLANG']);
    $num_clang = count($REX['CLANG']);
    if ($num_clang > 1) {
        echo '
<div id="rex-clang" class="rex-toolbar">
    <div class="rex-toolbar-content">
        <ul>
            <li>' . $I18N->msg('languages') . ' : </li>';
        $stop = false;
        $i = 1;
        foreach ($REX['CLANG'] as $key => $val) {
            if ($i == 1) {
                echo '<li class="rex-navi-first rex-navi-clang-' . $key . '">';
            } else {
                echo '<li class="rex-navi-clang-' . $key . '">';
            }
            $val = rex_translate($val);
            if (!$REX['USER']->isAdmin() && !$REX['USER']->hasPerm('clang[all]') && !$REX['USER']->hasPerm('clang[' . $key . ']')) {
                echo '<span class="rex-strike">' . $val . '</span>';
                if ($curClang == $key) {
                    $stop = true;
                }
            } else {
                $class = '';
                if ($key == $curClang) {
                    $class = ' class="rex-active"';
                }
                echo '<a' . $class . ' href="index.php?page=' . $REX['PAGE'] . '&amp;clang=' . $key . $urlParam . '"' . rex_tabindex() . '>' . $val . '</a>';
            }
            echo '</li>';
            $i++;
        }
        echo '
        </ul>
    </div>
</div>';
        if ($stop) {
            echo rex_warning('You have no permission to this area');
            require $REX['INCLUDE_PATH'] . '/layout/bottom.php';
            exit;
        }
    }
}
 static function getListValue($params)
 {
     $return = array();
     $values = array();
     foreach (explode(',', $params['params']['field']['options']) as $v) {
         $entry = explode('=', $v);
         if (isset($entry[1])) {
             $values[$entry[1]] = rex_translate($entry[0]);
         } else {
             $values[$entry[0]] = rex_translate($entry[0]);
         }
         // .' ['.$entry[0].']';
     }
     foreach (explode(',', $params['value']) as $k) {
         if (isset($values[$k])) {
             $return[] = $values[$k];
         }
     }
     return implode('<br />', $return);
 }
 function executeAction()
 {
     $text = $this->getElement(2);
     if ($text == '') {
         $text = $this->params['answertext'];
     }
     $text = rex_translate($text, null, false);
     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('&#039;', '\'', $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;
 }
Exemplo n.º 11
0
/**
 * Erstellt den nötigen HTML Code um ein Formular zu erweitern
 *
 * @param $sqlFields rex_sql-objekt, dass die zu verarbeitenden Felder enthält
 * @param $activeItem objekt, dass mit getValue() die Werte des akuellen Eintrags zurückgibt
 * @param $formatCallback callback, dem die infos als Array übergeben werden und den formatierten HTML Text zurückgibt
 */
function rex_a62_metaFields($sqlFields, $activeItem, $formatCallback, $epParams)
{
    global $I18N, $REX;
    $s = '';
    // Startwert für MEDIABUTTON, MEDIALIST, LINKLIST zähler
    $media_id = 1;
    $mlist_id = 1;
    $link_id = 1;
    $llist_id = 1;
    $sqlFields->reset();
    for ($i = 0; $i < $sqlFields->getRows(); $i++, $sqlFields->next()) {
        // Umschliessendes Tag von Label und Formularelement
        $tag = 'p';
        $tag_attr = '';
        $name = $sqlFields->getValue('name');
        $title = $sqlFields->getValue('title');
        $params = $sqlFields->getValue('params');
        $typeLabel = $sqlFields->getValue('label');
        $attr = $sqlFields->getValue('attributes');
        $dblength = $sqlFields->getValue('dblength');
        $restrictions = $sqlFields->getValue('restrictions');
        $attr .= rex_tabindex();
        $attrArray = rex_split_string($attr);
        if (isset($attrArray['perm'])) {
            if (!$REX['USER']->hasPerm($attrArray['perm'])) {
                continue;
            }
            unset($attrArray['perm']);
        }
        $defaultValue = $sqlFields->getValue('default');
        if ($activeItem) {
            $itemValue = $activeItem->getValue($name);
            if (strpos($itemValue, '|+|') !== false) {
                // Alte notation mit |+| als Trenner
                $dbvalues = explode('|+|', $activeItem->getValue($name));
            } else {
                // Neue Notation mit | als Trenner
                $dbvalues = explode('|', $activeItem->getValue($name));
            }
        } else {
            $dbvalues = (array) $sqlFields->getValue('default');
        }
        if ($title != '') {
            $label = rex_translate($title);
        } else {
            $label = htmlspecialchars($name);
        }
        $id = preg_replace('/[^a-zA-Z\\-0-9_]/', '_', $label);
        $labelIt = true;
        $field = '';
        switch ($typeLabel) {
            case 'text':
                $tag_attr = ' class="rex-form-text"';
                $rexInput = rex_input::factory($typeLabel);
                $rexInput->addAttributes($attrArray);
                $rexInput->setAttribute('id', $id);
                $rexInput->setAttribute('name', $name);
                if ($dblength > 0) {
                    $rexInput->setAttribute('maxlength', $dblength);
                }
                if ($activeItem) {
                    $rexInput->setValue($activeItem->getValue($name));
                } else {
                    $rexInput->setValue($defaultValue);
                }
                $field = $rexInput->getHtml();
                break;
            case 'checkbox':
                // Beachte auch default values in multiple fields bei ADD.
                // Im EDIT wurde dies bereits vorher gehandelt
                if (!$activeItem) {
                    $defaultValue = explode('|', $defaultValue);
                }
                $name .= '[]';
            case 'radio':
                $values = array();
                if (rex_sql::getQueryType($params) == 'SELECT') {
                    $sql = rex_sql::factory();
                    $value_groups = $sql->getDBArray($params, MYSQL_NUM);
                    foreach ($value_groups as $value_group) {
                        if (isset($value_group[1])) {
                            $values[$value_group[1]] = $value_group[0];
                        } else {
                            $values[$value_group[0]] = $value_group[0];
                        }
                    }
                } else {
                    $value_groups = explode('|', $params);
                    foreach ($value_groups as $value_group) {
                        // check ob key:value paar
                        // und der wert beginnt nicht mit "translate:"
                        if (strpos($value_group, ':') !== false && strpos($value_group, 'translate:') !== 0) {
                            $temp = explode(':', $value_group, 2);
                            $values[$temp[0]] = rex_translate($temp[1]);
                        } else {
                            $values[$value_group] = rex_translate($value_group);
                        }
                    }
                }
                $class_s = $typeLabel;
                $class_p = $typeLabel == 'radio' ? 'radios' : 'checkboxes';
                $oneValue = count($values) == 1;
                if (!$oneValue) {
                    $labelIt = false;
                    $tag = 'div';
                    $tag_attr = ' class="rex-form-col-a rex-form-' . $class_p . '"';
                    $field .= '<p class="rex-form-label">' . $label . '</p><div class="rex-form-' . $class_p . '-wrapper">';
                }
                $attrStr = '';
                $classAdd = '';
                foreach ($attrArray as $key => $value) {
                    if ($key == 'class') {
                        $classAdd = ' ' . $value;
                    } else {
                        $attrStr = ' ' . $key . '="' . $value . '"';
                    }
                }
                if (!$activeItem) {
                    $dbvalues = (array) $defaultValue;
                }
                foreach ($values as $key => $value) {
                    $id = preg_replace('/[^a-zA-Z\\-0-9_]/', '_', $id . $key);
                    // wenn man keine Werte angibt (Boolean Chkbox/Radio)
                    // Dummy Wert annehmen, damit an/aus unterscheidung funktioniert
                    if ($oneValue && $key == '') {
                        $key = 'true';
                    }
                    $selected = '';
                    if (in_array($key, $dbvalues)) {
                        $selected = ' checked="checked"';
                    }
                    if ($oneValue) {
                        $tag_attr = ' class="rex-form-col-a rex-form-' . $class_s . $classAdd . '"';
                        $field .= '<input class="rex-form-' . $class_s . '" type="' . $typeLabel . '" name="' . $name . '" value="' . htmlspecialchars($key) . '" id="' . $id . '" ' . $attrStr . $selected . ' />' . "\n";
                    } else {
                        $field .= '<p class="rex-form-' . $class_s . ' rex-form-label-right' . $classAdd . '">' . "\n";
                        $field .= '<input class="rex-form-' . $class_s . '" type="' . $typeLabel . '" name="' . $name . '" value="' . htmlspecialchars($key) . '" id="' . $id . '" ' . $attrStr . $selected . ' />' . "\n";
                        $field .= '<label for="' . $id . '">' . htmlspecialchars($value) . '</label>';
                        $field .= '</p>' . "\n";
                    }
                }
                if (!$oneValue) {
                    $field .= '</div>';
                }
                break;
            case 'select':
                $tag_attr = ' class="rex-form-select"';
                $select = new rex_select();
                $select->setStyle('class="rex-form-select"');
                $select->setName($name);
                $select->setId($id);
                $multiple = false;
                foreach ($attrArray as $attr_name => $attr_value) {
                    if (empty($attr_name)) {
                        continue;
                    }
                    $select->setAttribute($attr_name, $attr_value);
                    if ($attr_name == 'multiple') {
                        $multiple = true;
                        $select->setName($name . '[]');
                    }
                }
                // Beachte auch default values in multiple fields bei ADD.
                // Im EDIT wurde dies bereits vorher gehandelt
                if ($multiple && !$activeItem) {
                    $dbvalues = explode('|', $defaultValue);
                }
                // hier mit den "raw"-values arbeiten, da die rex_select klasse selbst escaped
                $select->setSelected($dbvalues);
                if (!$multiple) {
                    $select->setSize(1);
                }
                if (rex_sql::getQueryType($params) == 'SELECT') {
                    // Werte via SQL Laden
                    $select->addDBSqlOptions($params);
                } else {
                    // Optionen mit | separiert
                    // eine einzelne Option kann mit key:value separiert werden
                    $values = array();
                    $value_groups = explode('|', $params);
                    foreach ($value_groups as $value_group) {
                        // check ob key:value paar
                        // und der wert beginnt nicht mit "translate:"
                        if (strpos($value_group, ':') !== false && strpos($value_group, 'translate:') !== 0) {
                            $temp = explode(':', $value_group, 2);
                            $values[$temp[0]] = rex_translate($temp[1]);
                        } else {
                            $values[$value_group] = rex_translate($value_group);
                        }
                    }
                    $select->addOptions($values);
                }
                $field .= $select->get();
                break;
            case 'date':
            case 'time':
            case 'datetime':
                $tag_attr = ' class="rex-form-select-date"';
                $active = $dbvalues[0] != 0;
                if ($dbvalues[0] == '') {
                    $dbvalues[0] = time();
                }
                $inputValue = array();
                $inputValue['year'] = date('Y', $dbvalues[0]);
                $inputValue['month'] = date('m', $dbvalues[0]);
                $inputValue['day'] = date('j', $dbvalues[0]);
                $inputValue['hour'] = date('G', $dbvalues[0]);
                $inputValue['minute'] = date('i', $dbvalues[0]);
                $rexInput = rex_input::factory($typeLabel);
                $rexInput->addAttributes($attrArray);
                $rexInput->setAttribute('id', $id);
                $rexInput->setAttribute('name', $name);
                $rexInput->setValue($inputValue);
                $field = $rexInput->getHtml();
                $checked = $active ? ' checked="checked"' : '';
                $field .= '<input class="rex-form-select-checkbox rex-metainfo-checkbox" type="checkbox" name="' . $name . '[active]" value="1"' . $checked . ' />';
                break;
            case 'textarea':
                $tag_attr = ' class="rex-form-textarea"';
                $rexInput = rex_input::factory($typeLabel);
                $rexInput->addAttributes($attrArray);
                $rexInput->setAttribute('id', $id);
                $rexInput->setAttribute('name', $name);
                if ($activeItem) {
                    $rexInput->setValue($activeItem->getValue($name));
                } else {
                    $rexInput->setValue($defaultValue);
                }
                $field = $rexInput->getHtml();
                break;
            case 'legend':
                $tag = '';
                $tag_attr = '';
                $labelIt = false;
                // tabindex entfernen, macht bei einer legend wenig sinn
                $attr = preg_replace('@tabindex="[^"]*"@', '', $attr);
                $field = '</div></fieldset><fieldset class="rex-form-col-1"><legend id="' . $id . '"' . $attr . '>' . $label . '</legend><div class="rex-form-wrapper">';
                break;
            case 'REX_MEDIA_BUTTON':
                $tag = 'div';
                $tag_attr = ' class="rex-form-widget"';
                $paramArray = rex_split_string($params);
                $rexInput = rex_input::factory('mediabutton');
                $rexInput->addAttributes($attrArray);
                $rexInput->setButtonId($media_id);
                $rexInput->setAttribute('name', $name);
                $rexInput->setValue($dbvalues[0]);
                if (isset($paramArray['category'])) {
                    $rexInput->setCategoryId($paramArray['category']);
                }
                if (isset($paramArray['types'])) {
                    $rexInput->setTypes($paramArray['types']);
                }
                if (isset($paramArray['preview'])) {
                    $rexInput->setPreview($paramArray['preview']);
                }
                $id = $rexInput->getAttribute('id');
                $field = $rexInput->getHtml();
                $media_id++;
                break;
            case 'REX_MEDIALIST_BUTTON':
                $tag = 'div';
                $tag_attr = ' class="rex-form-widget"';
                $paramArray = rex_split_string($params);
                $name .= '[]';
                $rexInput = rex_input::factory('medialistbutton');
                $rexInput->addAttributes($attrArray);
                $rexInput->setButtonId($mlist_id);
                $rexInput->setAttribute('name', $name);
                $rexInput->setValue($dbvalues[0]);
                if (isset($paramArray['category'])) {
                    $rexInput->setCategoryId($paramArray['category']);
                }
                if (isset($paramArray['types'])) {
                    $rexInput->setTypes($paramArray['types']);
                }
                if (isset($paramArray['preview'])) {
                    $rexInput->setPreview($paramArray['preview']);
                }
                $id = $rexInput->getAttribute('id');
                $field = $rexInput->getHtml();
                $mlist_id++;
                break;
            case 'REX_LINK_BUTTON':
                $tag = 'div';
                $tag_attr = ' class="rex-form-widget"';
                $paramArray = rex_split_string($params);
                $category = '';
                if (isset($paramArray['category'])) {
                    $category = $paramArray['category'];
                } elseif ($activeItem) {
                    $category = $activeItem->getValue('category_id');
                }
                $rexInput = rex_input::factory('linkbutton');
                $rexInput->addAttributes($attrArray);
                $rexInput->setButtonId($link_id);
                $rexInput->setCategoryId($category);
                $rexInput->setAttribute('name', $name);
                $rexInput->setValue($dbvalues[0]);
                $id = $rexInput->getAttribute('id');
                $field = $rexInput->getHtml();
                $link_id++;
                break;
            case 'REX_LINKLIST_BUTTON':
                $tag = 'div';
                $tag_attr = ' class="rex-form-widget"';
                $paramArray = rex_split_string($params);
                $category = '';
                if (isset($paramArray['category'])) {
                    $category = $paramArray['category'];
                } elseif ($activeItem) {
                    $category = $activeItem->getValue('category_id');
                }
                $name .= '[]';
                $rexInput = rex_input::factory('linklistbutton');
                $rexInput->addAttributes($attrArray);
                $rexInput->setButtonId($llist_id);
                $rexInput->setCategoryId($category);
                $rexInput->setAttribute('name', $name);
                $rexInput->setValue(implode(',', $dbvalues));
                $id = $rexInput->getAttribute('id');
                $field = $rexInput->getHtml();
                $llist_id++;
                break;
            default:
                // ----- EXTENSION POINT
                list($field, $tag, $tag_attr, $id, $label, $labelIt) = rex_register_extension_point('A62_CUSTOM_FIELD', array($field, $tag, $tag_attr, $id, $label, $labelIt, 'values' => $dbvalues, 'rawvalues' => $dbvalues, 'type' => $typeLabel, 'sql' => $sqlFields));
        }
        $s .= rex_call_func($formatCallback, array($field, $tag, $tag_attr, $id, $label, $labelIt, $typeLabel), false);
    }
    return $s;
}
Exemplo n.º 12
0
                    $lang_a = new rex_select();
                    $lang_a->setId('clang_a');
                    $lang_a->setName('clang_a');
                    $lang_a->setSize('1');
                    $lang_a->setAttribute('tabindex', rex_tabindex(false));
                    foreach ($REX['CLANG'] as $key => $val) {
                        $val = rex_translate($val);
                        $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('tabindex', rex_tabindex(false));
                    foreach ($REX['CLANG'] as $key => $val) {
                        $val = rex_translate($val);
                        $lang_b->addOption($val, $key);
                    }
                    $lang_a->setSelected(rex_request('clang_a', 'int', null));
                    $lang_b->setSelected(rex_request('clang_b', 'int', null));
                    echo '
                <fieldset>
                  <legend class="rex-lgnd">' . $I18N->msg('content_submitcopycontent') . '</legend>
  							  <div class="rex-fldst-wrppr">
									  <p>
											<label for="clang_a">' . $I18N->msg('content_contentoflang') . '</label>
											' . $lang_a->get() . '
											<label for="clang_b">' . $I18N->msg('content_to') . '</label>
											' . $lang_b->get() . '
									  </p>
									  <p>
/**
 * Übersetzt den text $text, falls dieser mit dem prefix "translate:" beginnt.
 */
function rex_translate($text, $I18N_Catalogue = null, $use_htmlspecialchars = true)
{
    if (!$I18N_Catalogue) {
        global $I18N;
        return rex_translate($text, $I18N, $use_htmlspecialchars);
    }
    $tranKey = 'translate:';
    $transKeyLen = strlen($tranKey);
    if (substr($text, 0, $transKeyLen) == $tranKey) {
        $text = $I18N_Catalogue->msg(substr($text, $transKeyLen));
    }
    if ($use_htmlspecialchars) {
        return htmlspecialchars($text);
    }
    return $text;
}
    function addSlice($I_ID, $module_id)
    {
        global $REX, $I18N;
        $MOD = rex_sql::factory();
        $MOD->setQuery('SELECT * FROM ' . $REX['TABLE_PREFIX'] . "module WHERE id={$module_id}");
        if ($MOD->getRows() != 1) {
            $slice_content = rex_warning($I18N->msg('module_doesnt_exist'));
        } else {
            $initDataSql = rex_sql::factory();
            $REX_ACTION = array();
            foreach ($REX['VARIABLES'] as $obj) {
                $REX_ACTION = $obj->getACRequestValues($REX_ACTION);
            }
            // ----- PRE VIEW ACTION [ADD]
            $REX_ACTION = rex_execPreViewAction($module_id, 'add', $REX_ACTION);
            // ----- / PRE VIEW ACTION
            // ****************** Action Werte in Sql-Objekt uebernehmen
            foreach ($REX['VARIABLES'] as $obj) {
                $obj->setACValues($initDataSql, $REX_ACTION);
            }
            $moduleInput = $this->replaceVars($initDataSql, $MOD->getValue('eingabe'));
            $msg = '';
            if ($this->warning != '') {
                $msg .= rex_warning($this->warning);
            }
            if ($this->info != '') {
                $msg .= rex_info($this->info);
            }
            $slice_content = '
                <a id="addslice"></a>
                ' . $msg . '
                <div class="rex-form rex-form-content-editmode-add-slice">
                <form action="index.php#slice' . $I_ID . '" method="post" id="REX_FORM" enctype="multipart/form-data">
                    <fieldset class="rex-form-col-1">
                        <legend><span>' . $I18N->msg('add_block') . '</span></legend>
                        <input type="hidden" name="article_id" value="' . $this->article_id . '" />
                        <input type="hidden" name="page" value="content" />
                        <input type="hidden" name="mode" value="' . $this->mode . '" />
                        <input type="hidden" name="slice_id" value="' . $I_ID . '" />
                        <input type="hidden" name="function" value="add" />
                        <input type="hidden" name="module_id" value="' . $module_id . '" />
                        <input type="hidden" name="save" value="1" />
                        <input type="hidden" name="clang" value="' . $this->clang . '" />
                        <input type="hidden" name="ctype" value="' . $this->ctype . '" />

                        <div class="rex-content-editmode-module-name">
                            <h3 class="rex-hl4">
                                ' . $I18N->msg('module') . ': <span>' . htmlspecialchars(rex_translate($MOD->getValue('name'))) . '</span>
                            </h3>
                        </div>

                        <div class="rex-form-wrapper">

                            <div class="rex-form-row">
                                <div class="rex-content-editmode-slice-input">
                                <div class="rex-content-editmode-slice-input-2">
                                    ' . $moduleInput . '
                                </div>
                                </div>
                            </div>

                        </div>
                    </fieldset>

                    <fieldset class="rex-form-col-1">
                         <div class="rex-form-wrapper">
                            <div class="rex-form-row">
                                <p class="rex-form-col-a rex-form-submit">
                                    <input class="rex-form-submit" type="submit" name="btn_save" value="' . $I18N->msg('add_block') . '"' . rex_accesskey($I18N->msg('add_block'), $REX['ACKEY']['SAVE']) . ' />
                                </p>
                            </div>
                        </div>
                    </fieldset>
                </form>
                </div>
                <script type="text/javascript">
                     <!--
                    jQuery(function($) {
                        $(":input:visible:enabled:not([readonly]):first", $("#REX_FORM")).focus();
                    });
                     //-->
                </script>';
        }
        return $slice_content;
    }
    function getArticle($curctype = -1)
    {
        global $module_id, $REX_USER, $REX, $I18N;
        $this->ctype = $curctype;
        $sliceLimit = '';
        if ($this->getSlice) {
            //$REX['GG'] = 0;
            $sliceLimit = " AND " . $REX['TABLE_PREFIX'] . "article_slice.id = '" . $this->getSlice . "' ";
        }
        // ----- start: article caching
        ob_start();
        ob_implicit_flush(0);
        if ($REX['GG'] && !$this->viasql && !$this->getSlice) {
            if ($this->article_id != 0) {
                $this->contents = '';
                $article_content_file = $REX['INCLUDE_PATH'] . '/generated/articles/' . $this->article_id . '.' . $this->clang . '.content';
                if ($cont = rex_get_file_contents($article_content_file)) {
                    $this->contents = $cont;
                    eval($this->contents);
                }
            }
        } else {
            if ($this->article_id != 0) {
                // ---------- alle teile/slices eines artikels auswaehlen
                $sql = "SELECT " . $REX['TABLE_PREFIX'] . "module.id, " . $REX['TABLE_PREFIX'] . "module.name, " . $REX['TABLE_PREFIX'] . "module.ausgabe, " . $REX['TABLE_PREFIX'] . "module.eingabe, " . $REX['TABLE_PREFIX'] . "article_slice.*, " . $REX['TABLE_PREFIX'] . "article.re_id\r\n          FROM\r\n            " . $REX['TABLE_PREFIX'] . "article_slice\r\n          LEFT JOIN " . $REX['TABLE_PREFIX'] . "module ON " . $REX['TABLE_PREFIX'] . "article_slice.modultyp_id=" . $REX['TABLE_PREFIX'] . "module.id\r\n          LEFT JOIN " . $REX['TABLE_PREFIX'] . "article ON " . $REX['TABLE_PREFIX'] . "article_slice.article_id=" . $REX['TABLE_PREFIX'] . "article.id\r\n          WHERE\r\n            " . $REX['TABLE_PREFIX'] . "article_slice.article_id='" . $this->article_id . "' AND\r\n            " . $REX['TABLE_PREFIX'] . "article_slice.clang='" . $this->clang . "' AND\r\n            " . $REX['TABLE_PREFIX'] . "article.clang='" . $this->clang . "'\r\n            " . $sliceLimit . "\r\n            ORDER BY " . $REX['TABLE_PREFIX'] . "article_slice.re_article_slice_id";
                $this->CONT = new rex_sql();
                $this->CONT->debugsql = 0;
                $this->CONT->setQuery($sql);
                $RE_CONTS = array();
                $RE_CONTS_CTYPE = array();
                $RE_MODUL_OUT = array();
                $RE_MODUL_IN = array();
                $RE_MODUL_ID = array();
                $RE_MODUL_NAME = array();
                $RE_C = array();
                // ---------- SLICE IDS/MODUL SETZEN - speichern der daten
                for ($i = 0; $i < $this->CONT->getRows(); $i++) {
                    $RE_CONTS[$this->CONT->getValue('re_article_slice_id')] = $this->CONT->getValue($REX['TABLE_PREFIX'] . 'article_slice.id');
                    $RE_CONTS_CTYPE[$this->CONT->getValue('re_article_slice_id')] = $this->CONT->getValue($REX['TABLE_PREFIX'] . 'article_slice.ctype');
                    $RE_MODUL_IN[$this->CONT->getValue('re_article_slice_id')] = $this->CONT->getValue($REX['TABLE_PREFIX'] . 'module.eingabe');
                    $RE_MODUL_OUT[$this->CONT->getValue('re_article_slice_id')] = $this->CONT->getValue($REX['TABLE_PREFIX'] . 'module.ausgabe');
                    $RE_MODUL_ID[$this->CONT->getValue('re_article_slice_id')] = $this->CONT->getValue($REX['TABLE_PREFIX'] . 'module.id');
                    $RE_MODUL_NAME[$this->CONT->getValue('re_article_slice_id')] = $this->CONT->getValue($REX['TABLE_PREFIX'] . 'module.name');
                    $RE_C[$this->CONT->getValue('re_article_slice_id')] = $i;
                    $this->CONT->next();
                }
                // ---------- moduleselect: nur module nehmen auf die der user rechte hat
                if ($this->mode == 'edit') {
                    $MODULE = new rex_sql();
                    $MODULE->setQuery('select * from ' . $REX['TABLE_PREFIX'] . 'module order by name');
                    $MODULESELECT = new rex_select();
                    $MODULESELECT->setName('module_id');
                    $MODULESELECT->setSize('1');
                    $MODULESELECT->setAttribute('onchange', 'this.form.submit();');
                    $MODULESELECT->addOption('----------------------------  ' . $I18N->msg('add_block'), '');
                    for ($i = 0; $i < $MODULE->getRows(); $i++) {
                        if ($REX_USER->hasPerm('module[' . $MODULE->getValue('id') . ']') || $REX_USER->hasPerm('admin[]')) {
                            $MODULESELECT->addOption(rex_translate($MODULE->getValue('name'), NULL, FALSE), $MODULE->getValue('id'));
                        }
                        $MODULE->next();
                    }
                }
                // ---------- SLICE IDS SORTIEREN UND AUSGEBEN
                $I_ID = 0;
                $PRE_ID = 0;
                $LCTSL_ID = 0;
                $this->CONT->reset();
                $this->article_content = "";
                for ($i = 0; $i < $this->CONT->getRows(); $i++) {
                    // ----- ctype unterscheidung
                    if ($this->mode != "edit" && $i == 0) {
                        $this->article_content = "<?php if (\$this->ctype == '" . $RE_CONTS_CTYPE[$I_ID] . "' || (\$this->ctype == '-1')) { ?>";
                    }
                    // ------------- EINZELNER SLICE - AUSGABE
                    $this->CONT->counter = $RE_C[$I_ID];
                    $slice_content = "";
                    $SLICE_SHOW = TRUE;
                    if ($this->mode == "edit") {
                        $form_url = 'index.php';
                        if ($this->setanker) {
                            $form_url .= '#addslice';
                        }
                        $this->ViewSliceId = $RE_CONTS[$I_ID];
                        // ----- add select box einbauen
                        if ($this->function == "add" && $this->slice_id == $I_ID) {
                            $slice_content = $this->addSlice($I_ID, $module_id);
                        } else {
                            // ----- BLOCKAUSWAHL - SELECT
                            $MODULESELECT->setId("module_id" . $I_ID);
                            $slice_content = '
              <form action="' . $form_url . '" method="get" id="slice' . $RE_CONTS[$I_ID] . '">
                <fieldset>
                  <legend class="rex-lgnd"><span class="rex-hide">' . $I18N->msg("add_block") . '</span></legend>
                  <input type="hidden" name="article_id" value="' . $this->article_id . '" />
                  <input type="hidden" name="page" value="content" />
                  <input type="hidden" name="mode" value="' . $this->mode . '" />
                  <input type="hidden" name="slice_id" value="' . $I_ID . '" />
                  <input type="hidden" name="function" value="add" />
                  <input type="hidden" name="clang" value="' . $this->clang . '" />
                  <input type="hidden" name="ctype" value="' . $this->ctype . '" />

                  <p class="rex-slct">
                    ' . $MODULESELECT->get() . '
                    <noscript><input type="submit" class="rex-sbmt" name="btn_add" value="' . $I18N->msg("add_block") . '" /></noscript>
                  </p>

                </fieldset>
              </form>';
                        }
                        // ----- EDIT/DELETE BLOCK - Wenn Rechte vorhanden
                        if ($REX_USER->hasPerm("module[" . $RE_MODUL_ID[$I_ID] . "]") || $REX_USER->hasPerm("admin[]")) {
                            $msg = '';
                            if ($this->slice_id == $RE_CONTS[$I_ID] && $this->message != '') {
                                $msg = rex_warning($this->message);
                            }
                            $sliceUrl = 'index.php?page=content&amp;article_id=' . $this->article_id . '&amp;mode=edit&amp;slice_id=' . $RE_CONTS[$I_ID] . '&amp;clang=' . $this->clang . '&amp;ctype=' . $this->ctype . '%s#slice' . $RE_CONTS[$I_ID];
                            $listElements = array();
                            $listElements[] = '<a href="' . sprintf($sliceUrl, '&amp;function=edit') . '" class="rex-clr-grn">' . $I18N->msg('edit') . ' <span class="rex-hide">' . $RE_MODUL_NAME[$I_ID] . '</span></a>';
                            $listElements[] = '<a href="' . sprintf($sliceUrl, '&amp;function=delete&amp;save=1') . '" class="rex-clr-red" onclick="return confirm(\'' . $I18N->msg('delete') . ' ?\')">' . $I18N->msg('delete') . ' <span class="rex-hide">' . $RE_MODUL_NAME[$I_ID] . '</span></a>';
                            if ($REX_USER->hasPerm('moveSlice[]')) {
                                $moveUp = $I18N->msg('move_slice_up');
                                $moveDown = $I18N->msg('move_slice_down');
                                // upd stamp übergeben, da sonst ein block nicht mehrfach hintereindander verschoben werden kann
                                // (Links wären sonst gleich und der Browser lässt das klicken auf den gleichen Link nicht zu)
                                $listElements[] = '<a href="' . sprintf($sliceUrl, '&amp;upd=' . time() . '&amp;function=moveup') . '" title="' . $moveUp . '"><img src="media/file_up.gif" width="16" height="16" alt="' . $moveUp . '" /> <span class="rex-hide">' . $RE_MODUL_NAME[$I_ID] . '</span></a>';
                                $listElements[] = '<a href="' . sprintf($sliceUrl, '&amp;upd=' . time() . '&amp;function=movedown') . '" title="' . $moveDown . '"><img src="media/file_down.gif" width="16" height="16" alt="' . $moveDown . '" /> <span class="rex-hide">' . $RE_MODUL_NAME[$I_ID] . '</span></a>';
                            }
                            // ----- EXTENSION POINT
                            $listElements = rex_register_extension_point('ART_SLICE_MENU', $listElements, array('article_id' => $this->article_id, 'clang' => $this->clang, 'ctype' => $RE_CONTS_CTYPE[$I_ID], 'module_id' => $RE_MODUL_ID[$I_ID], 'slice_id' => $RE_CONTS[$I_ID]));
                            $mne = $msg . '
			       	<div class="rex-cnt-editmode-slc">
                <p class="rex-flLeft">' . htmlspecialchars($RE_MODUL_NAME[$I_ID]) . '</p>
                <ul class="rex-flRight" id="rex-slc-mnu">
              ';
                            foreach ($listElements as $listElement) {
                                $mne .= '<li>' . $listElement . '</li>';
                            }
                            $mne .= '</ul></div>';
                            $slice_content .= $mne;
                            if ($this->function == "edit" && $this->slice_id == $RE_CONTS[$I_ID]) {
                                // **************** Aktueller Slice
                                // ----- PRE VIEW ACTION [EDIT]
                                $REX_ACTION = array();
                                // nach klick auf den übernehmen button,
                                // die POST werte übernehmen
                                if (rex_var::isEditEvent()) {
                                    foreach ($REX['VARIABLES'] as $obj) {
                                        $REX_ACTION = $obj->getACRequestValues($REX_ACTION);
                                    }
                                } else {
                                    foreach ($REX['VARIABLES'] as $obj) {
                                        $REX_ACTION = $obj->getACDatabaseValues($REX_ACTION, $this->CONT);
                                    }
                                }
                                // TODO: PreviewActions gibts nur im EditMode...?
                                if ($this->function == 'edit') {
                                    $modebit = '2';
                                } elseif ($this->function == 'delete') {
                                    $modebit = '4';
                                } else {
                                    $modebit = '1';
                                }
                                // pre-action and add
                                $ga = new rex_sql();
                                $ga->debugsql = 0;
                                $ga->setQuery('SELECT preview FROM ' . $REX['TABLE_PREFIX'] . 'module_action ma,' . $REX['TABLE_PREFIX'] . 'action a WHERE preview != "" AND ma.action_id=a.id AND module_id=' . $RE_MODUL_ID[$I_ID] . ' AND ((a.previewmode & ' . $modebit . ') = ' . $modebit . ')');
                                for ($t = 0; $t < $ga->getRows(); $t++) {
                                    $iaction = $ga->getValue('preview');
                                    // ****************** VARIABLEN ERSETZEN
                                    foreach ($REX['VARIABLES'] as $obj) {
                                        $iaction = $obj->getACOutput($REX_ACTION, $iaction);
                                    }
                                    eval('?>' . $iaction);
                                    // ****************** SPEICHERN FALLS NOETIG
                                    foreach ($REX['VARIABLES'] as $obj) {
                                        $obj->setACValues($this->CONT, $REX_ACTION);
                                    }
                                    $ga->next();
                                }
                                // ----- / PRE VIEW ACTION
                                $slice_content .= $this->editSlice($RE_CONTS[$I_ID], $RE_MODUL_IN[$I_ID], $RE_CONTS_CTYPE[$I_ID], $RE_MODUL_ID[$I_ID]);
                            } else {
                                // Modulinhalt ausgeben
                                $slice_content .= '
                <!-- *** OUTPUT OF MODULE-OUTPUT - START *** -->
                <div class="rex-cnt-slc-otp"><div class="rex-cnt-slc-otp2">
                  ' . $RE_MODUL_OUT[$I_ID] . '
                </div></div>
                <!-- *** OUTPUT OF MODULE-OUTPUT - END *** -->
                ';
                                $slice_content = $this->replaceVars($this->CONT, $slice_content);
                            }
                        } else {
                            // ----- hat keine rechte an diesem modul
                            $mne = '
			  	<div class="rex-cnt-editmode-slc">
                <p class="rex-flLeft" id="slice' . $RE_CONTS[$I_ID] . '">' . $RE_MODUL_NAME[$I_ID] . '</p>
                <ul class="rex-flRight">
                  <li>' . $I18N->msg('no_editing_rights') . ' <span class="rex-hide">' . $RE_MODUL_NAME[$I_ID] . '</span></li>
                </ul>
				  </div>';
                            $slice_content .= $mne . $RE_MODUL_OUT[$I_ID];
                            $slice_content = $this->replaceVars($this->CONT, $slice_content);
                        }
                    } else {
                        // ----- wenn mode nicht edit
                        if ($this->getSlice) {
                            while (list($k, $v) = each($RE_CONTS)) {
                                $I_ID = $k;
                            }
                        }
                        $slice_content .= $RE_MODUL_OUT[$I_ID];
                        $slice_content = $this->replaceVars($this->CONT, $slice_content);
                    }
                    // --------------- ENDE EINZELNER SLICE
                    // --------------- EP: SLICE_SHOW
                    $slice_content = rex_register_extension_point('SLICE_SHOW', $slice_content, array('article_id' => $this->article_id, 'clang' => $this->clang, 'ctype' => $RE_CONTS_CTYPE[$I_ID], 'module_id' => $RE_MODUL_ID[$I_ID], 'slice_id' => $RE_CONTS[$I_ID], 'function' => $this->function, 'function_slice_id' => $this->slice_id));
                    // ---------- slice in ausgabe speichern wenn ctype richtig
                    if ($this->ctype == -1 or $this->ctype == $RE_CONTS_CTYPE[$I_ID]) {
                        $this->article_content .= $slice_content;
                        // last content type slice id
                        $LCTSL_ID = $RE_CONTS[$I_ID];
                    }
                    // ----- zwischenstand: ctype .. wenn ctype neu dann if
                    if ($this->mode != "edit" && isset($RE_CONTS_CTYPE[$RE_CONTS[$I_ID]]) && $RE_CONTS_CTYPE[$I_ID] != $RE_CONTS_CTYPE[$RE_CONTS[$I_ID]] && $RE_CONTS_CTYPE[$RE_CONTS[$I_ID]] != "") {
                        $this->article_content .= "<?php } if(\$this->ctype == '" . $RE_CONTS_CTYPE[$RE_CONTS[$I_ID]] . "' || \$this->ctype == '-1'){ ?>";
                    }
                    // zum nachsten slice
                    $I_ID = $RE_CONTS[$I_ID];
                    $PRE_ID = $I_ID;
                }
                // ----- end: ctype unterscheidung
                if ($this->mode != "edit" && $i > 0) {
                    $this->article_content .= "<?php } ?>";
                }
                // ----- add module im edit mode
                if ($this->mode == "edit") {
                    $form_url = 'index.php';
                    if ($this->setanker) {
                        $form_url .= '#addslice';
                    }
                    if ($this->function == "add" && $this->slice_id == $LCTSL_ID) {
                        $slice_content = $this->addSlice($LCTSL_ID, $module_id);
                    } else {
                        // ----- BLOCKAUSWAHL - SELECT
                        $MODULESELECT->setId("module_id" . $LCTSL_ID);
                        // $slice_content = $add_select_box;
                        $slice_content = '
            <form action="' . $form_url . '" method="get">
              <fieldset>
                <legend class="rex-lgnd"><span class="rex-hide">' . $I18N->msg("add_block") . '</span></legend>
                <input type="hidden" name="article_id" value="' . $this->article_id . '" />
                <input type="hidden" name="page" value="content" />
                <input type="hidden" name="mode" value="' . $this->mode . '" />
                <input type="hidden" name="slice_id" value="' . $LCTSL_ID . '" />
                <input type="hidden" name="function" value="add" />
                <input type="hidden" name="clang" value="' . $this->clang . '" />
                <input type="hidden" name="ctype" value="' . $this->ctype . '" />

                <p class="rex-slct">
                  ' . $MODULESELECT->get() . '
                  <noscript><input type="submit" class="rex-sbmt" name="btn_add" value="' . $I18N->msg("add_block") . '" /></noscript>
                </p>

              </fieldset>
            </form>';
                    }
                    $this->article_content .= $slice_content;
                }
                // -------------------------- schreibe content
                if ($this->mode == "generate" || $this->viasql) {
                    echo $this->replaceLinks($this->article_content);
                } else {
                    eval("?>" . $this->article_content);
                }
            } else {
                echo $I18N->msg('no_article_available');
            }
        }
        // ----- end: article caching
        $CONTENT = ob_get_contents();
        ob_end_clean();
        return $CONTENT;
    }
    function getFieldPage()
    {
        global $REX, $I18N;
        // TODO: function rex_xform_manager_checkField
        // ********************************************* FIELD ADD/EDIT/LIST
        $func = rex_request('func', 'string', 'list');
        $page = rex_request('page', 'string', '');
        $subpage = rex_request('subpage', 'string', '');
        $tripage = rex_request('tripage', 'string', '');
        $type_id = rex_request('type_id', 'string');
        $type_name = rex_request('type_name', 'string');
        $field_id = rex_request('field_id', 'int');
        $show_list = true;
        $link_vars = '';
        foreach ($this->getLinkVars() as $k => $v) {
            $link_vars .= '&' . urlencode($k) . '=' . urlencode($v);
        }
        $TYPE = array('value' => $I18N->msg('values'), 'validate' => $I18N->msg('validates'), 'action' => $I18N->msg('action'));
        // ********************************** TABELLE HOLEN
        unset($table);
        $tables = $this->getTables();
        if (!isset($table)) {
            if (count($tables) > 0) {
                $table = current($tables);
            } else {
                echo 'Keine Tabelle gefunden';
                exit;
            }
        }
        foreach ($tables as $t) {
            if ($t['table_name'] == rex_request('table_name')) {
                $table = $t;
                break;
            }
        }
        $table_echo = '';
        //echo '<table cellpadding="5" class="rex-table" id="xform-alltables">';
        //echo '<tr><td>';
        foreach ($tables as $t) {
            if ($t['table_name'] == $table['table_name']) {
                $table_echo .= '<b>' . rex_translate($t['name']) . ' [' . $t['table_name'] . ']</b> ';
            } else {
                $table_echo .= ' <a href="index.php?' . $link_vars . '&table_name=' . $t['table_name'] . '">' . rex_translate($t['name']) . ' [' . $t['table_name'] . ']</a> ';
            }
        }
        //echo '</td></tr>';
        //echo '';
        if ($table['description'] != '') {
            //echo "<tr><td>".$table["description"].'</td></tr>';
            $table_echo .= '<p>' . $table['description'] . '</p>';
        }
        // if($rex_em_opener_info != "") { echo ' - '.$I18N->msg("openerinfo").': '.$rex_em_opener_info; }
        //echo '</table><br />';
        echo rex_content_block($table_echo);
        $table['fields'] = $this->getTableFields($table['table_name']);
        // ********************************************* Missing Fields
        $mfields = rex_xform_manager_table::getMissingFields($table['table_name']);
        // ksort($mfields);
        $type_real_field = rex_request('type_real_field', 'string');
        if ($type_real_field != '' && !array_key_exists($type_real_field, $mfields)) {
            $type_real_field = '';
        }
        if ($type_real_field != '') {
            ?>
            <div class="rex-addon-output"><h2 class="rex-hl2">Folgendes Feld wird verwendet: <?php 
            echo $type_real_field;
            ?>
</h2><div class="rex-addon-content"><p class="rex-tx1"><?php 
            $rfields = rex_xform_manager_table::getFields($table['table_name']);
            foreach ($rfields[$type_real_field] as $k => $v) {
                echo '<b>' . $k . ':</b> ' . $v . '<br />';
            }
            ?>
</p></div></div><?php 
        }
        // ********************************************* CHOOSE FIELD
        $types = rex_xform::getTypeArray();
        if ($func == 'choosenadd') {
            // type and choose !!
            $link = 'index.php?' . $link_vars . '&table_name=' . $table['table_name'] . '&func=add&';
            if (!rex_xform_manager_table::hasId($table['table_name'])) {
                ?>
                <div class="rex-addon-output" id="xform-choosenadd"><h2 class="rex-hl2"><?php 
                echo $I18N->msg('xform_id_is_missing');
                ?>
</h2><div class="rex-addon-content">
                        <p class="rex-tx1"><?php 
                echo $I18N->msg('xform_id_missing_info');
                ?>
</p>
                    </div></div>
            <?php 
            } else {
                ?>
                <div class="rex-addon-output" id="xform-choosenadd"><h2 class="rex-hl2"><?php 
                echo $I18N->msg('choosenadd');
                ?>
</h2><div class="rex-addon-content">
                        <p class="rex-tx1"><?php 
                echo $I18N->msg('choosenadd_description');
                ?>
</p>
                    </div></div>
                <?php 
                if ($type_real_field == '' && count($mfields) > 0) {
                    ?>
                    <div class="rex-addon-output"><h2 class="rex-hl2">Es gibt noch Felder in der Tabelle welche nicht zugewiesen sind.</h2><div class="rex-addon-content">
                            <?php 
                    $d = 0;
                    foreach ($mfields as $k => $v) {
                        $d++;
                        $l = 'index.php?' . $link_vars . '&table_name=' . $table['table_name'] . '&func=choosenadd&type_real_field=' . $k . '&type_layout=t';
                        echo '<a href="' . $l . '">' . $k . '</a>, ';
                    }
                    ?>
</div></div>

                <?php 
                }
                ?>


                <div class="rex-addon-output xform-table_field">
                    <div class="rex-area-col-2">

                        <div class="rex-area-col-a">
                            <h3 class="rex-hl2">beliebte <?php 
                echo $TYPE['value'];
                ?>
</h3>
                            <div class="rex-area-content"><p class="rex-tx1"><?php 
                if (isset($types['value'])) {
                    ksort($types['value']);
                    foreach ($types['value'] as $k => $v) {
                        if (isset($v['famous']) && $v['famous']) {
                            echo '<p class="rex-button"><a class="rex-button" href="' . $link . 'type_id=value&type_name=' . $k . '&type_real_field=' . $type_real_field . '">' . $k . '</a> <span>' . $v['description'] . '</span></p>';
                        }
                    }
                }
                ?>
</p></div></div>

                        <div class="rex-area-col-b"><h3 class="rex-hl2">beliebte <?php 
                echo $TYPE['validate'];
                ?>
</h3><div class="rex-area-content"><p class="rex-tx1"><?php 
                if (isset($types['validate'])) {
                    ksort($types['validate']);
                    foreach ($types['validate'] as $k => $v) {
                        if (isset($v['famous']) && $v['famous']) {
                            echo '<p class="rex-button"><a class="rex-button" href="' . $link . 'type_id=validate&type_name=' . $k . '">' . $k . '</a> <span>' . $v['description'] . '</span></p>';
                        }
                    }
                }
                ?>
</p></div></div>

                    </div></div>

                <div class="rex-addon-output xform-table_field">
                    <div class="rex-area-col-2">

                        <div class="rex-area-col-a"><h3 class="rex-hl2"><?php 
                echo $TYPE['value'];
                ?>
</h3><div class="rex-area-content"><p class="rex-tx1"><?php 
                if (isset($types['value'])) {
                    ksort($types['value']);
                    foreach ($types['value'] as $k => $v) {
                        if (!isset($v['famous']) || $v['famous'] !== true) {
                            echo '<p class="rex-button"><a class="rex-button" href="' . $link . 'type_id=value&type_name=' . $k . '&type_real_field=' . $type_real_field . '">' . $k . '</a> <span>' . $v['description'] . '</span></p>';
                        }
                    }
                }
                ?>
</p></div></div>

                        <div class="rex-area-col-b"><h3 class="rex-hl2"><?php 
                echo $TYPE['validate'];
                ?>
</h3><div class="rex-area-content"><p class="rex-tx1"><?php 
                if (isset($types['validate'])) {
                    ksort($types['validate']);
                    foreach ($types['validate'] as $k => $v) {
                        if (!isset($v['famous']) || $v['famous'] !== true) {
                            echo '<p class="rex-button"><a class="rex-button" href="' . $link . 'type_id=validate&type_name=' . $k . '">' . $k . '</a> <span>' . $v['description'] . '</span></p>';
                        }
                    }
                }
                ?>
</p></div></div>

                    </div></div>

                <!--
             <div class="rex-addon-output">
             <h2 class="rex-hl2"><?php 
                echo $TYPE['action'];
                ?>
</h2>
             <div class="rex-addon-content">
             <p class="rex-tx1"><?php 
                if (isset($types['action'])) {
                    ksort($types['action']);
                    foreach ($types['action'] as $k => $v) {
                        echo '<p class="rex-button">"<a href="' . $link . 'type_id=action&type_name=' . $k . '">' . $k . '</a>" - ' . $v['description'] . '</p>';
                    }
                }
                ?>
</p>
             </div>
             </div>
             -->

            <?php 
            }
            $table_echo = '<a href="index.php?' . $link_vars . '&amp;table_name=' . $table['table_name'] . '"><b>&laquo; ' . $I18N->msg('back_to_overview') . '</b></a>';
            echo rex_content_block($table_echo);
        }
        // ********************************************* FORMULAR
        if (($func == 'add' || $func == 'edit') && isset($types[$type_id][$type_name])) {
            $xform = new rex_xform();
            $xform->setDebug(false);
            foreach ($this->getLinkVars() as $k => $v) {
                $xform->setHiddenField($k, $v);
            }
            $xform->setHiddenField('func', $func);
            $xform->setHiddenField('table_name', $table['table_name']);
            $xform->setHiddenField('type_real_field', $type_real_field);
            $xform->setValueField('hidden', array('table_name', $table['table_name']));
            $xform->setValueField('hidden', array('type_name', $type_name, 'REQUEST'));
            $xform->setValueField('hidden', array('type_id', $type_id, 'REQUEST'));
            $xform->setValueField('text', array('prio', 'Prioritaet', rex_xform_manager_table::getMaximumPrio($table['table_name']) + 10));
            $selectFields = array();
            $i = 1;
            foreach ($types[$type_id][$type_name]['values'] as $k => $v) {
                $field = $this->getFieldName($k, $type_id);
                $selectFields['f' . $i] = $field;
                $i++;
                switch ($v['type']) {
                    case 'name':
                        if ($func == 'edit') {
                            $xform->setValueField('showvalue', array($field, 'Name'));
                        } else {
                            if (!isset($v['value']) && $type_real_field != '') {
                                $v['value'] = $type_real_field;
                            } elseif (!isset($v['value'])) {
                                $v['value'] = '';
                            }
                            $xform->setValueField('text', array($field, 'Name', $v['value']));
                            $xform->setValidateField('notEmpty', array($field, $I18N->msg('validatenamenotempty')));
                            $xform->setValidateField('preg_match', array($field, "/(([a-zA-Z])+([a-zA-Z0-9\\_])*)/", $I18N->msg('validatenamepregmatch')));
                            $xform->setValidateField('customfunction', array($field, 'rex_xform_manager_checkField', array('table_name' => $table['table_name']), $I18N->msg('validatenamecheck')));
                        }
                        break;
                    case 'no_db':
                        // ToDo: Default Wert beachten
                        $xform->setValueField('checkbox', array($field, $I18N->msg('donotsaveindb'), 'no_db', $v['default']));
                        break;
                    case 'boolean':
                        // checkbox|check_design|Bezeichnung|Value|1/0|[no_db]
                        if (!isset($v['default'])) {
                            $v['default'] = '';
                        }
                        $xform->setValueField('checkbox', array($field, $v['label'], '', $v['default']));
                        break;
                    case 'select':
                        // select|gender|Geschlecht *|Frau=w;Herr=m|[no_db]|defaultwert|multiple=1
                        $xform->setValueField('select', array($field, $v['label'], $v['definition'], '', $v['default'], 0));
                        break;
                    case 'table':
                        // ist fest eingetragen, damit keine Dinge durcheinandergehen
                        if ($func == 'edit') {
                            $xform->setValueField('showvalue', array($field, $v['label']));
                        } else {
                            $_tables = rex_xform_manager_table::getTables();
                            $_options = array();
                            foreach ($_tables as $_table) {
                                $_options[$_table->getTableName()] = str_replace('=', '-', $_table->getName() . ' [' . $_table->getTableName() . ']') . '=' . $_table->getTableName();
                                $_options[$_table->getTableName()] = str_replace(',', '.', $_options[$_table->getTableName()]);
                            }
                            if (!isset($v['default'])) {
                                $v['default'] = '';
                            }
                            $xform->setValueField('select', array($field, $v['label'], implode(',', $_options), '', $v['default'], 0));
                        }
                        break;
                    case 'textarea':
                        $xform->setValueField('textarea', array($field, $v['label']));
                        break;
                    case 'table.field':
                        // Todo:
                    // Todo:
                    case 'select_name':
                        $_fields = array();
                        foreach (rex_xform_manager_table::getXFormFieldsByType($table['table_name']) as $_k => $_v) {
                            $_fields[] = $_k;
                        }
                        $xform->setValueField('select', array($field, $v['label'], implode(',', $_fields), '', '', 0));
                        break;
                    case 'select_names':
                        // Todo: Mehrere Namen aus denanderen Federn ziehen und als multiselectbox anbieten
                        $_fields = array();
                        foreach (rex_xform_manager_table::getXFormFieldsByType($table['table_name']) as $_k => $_v) {
                            $_fields[] = $_k;
                        }
                        $xform->setValueField('select', array($field, $v['label'], implode(',', $_fields), '', '', 1, 5));
                        break;
                    default:
                        // nur beim "Bezeichnungsfeld"
                        if ($field == 'label' && $type_real_field != '' && !isset($v['value'])) {
                            $v['value'] = $type_real_field;
                        } elseif (!isset($v['value'])) {
                            $v['value'] = '';
                        }
                        $xform->setValueField('text', array($field, $v['label'], $v['value']));
                }
            }
            $xform->setActionField('showtext', array('', '<p>' . $I18N->msg('thankyouforentry') . '</p>'));
            $xform->setObjectparams('main_table', $REX['TABLE_PREFIX'] . 'xform_field');
            // f�r db speicherungen und unique abfragen
            if ($func == 'edit') {
                $xform->setObjectparams('submit_btn_label', $I18N->msg('save'));
                $xform->setHiddenField('field_id', $field_id);
                $xform->setActionField('manage_db', array($REX['TABLE_PREFIX'] . 'xform_field', "id={$field_id}"));
                $xform->setObjectparams('main_id', $field_id);
                $xform->setObjectparams('main_where', "id={$field_id}");
                $sql = rex_sql::factory();
                $sql->setQuery("SELECT * FROM " . $REX['TABLE_PREFIX'] . "xform_field WHERE id={$field_id}");
                foreach ($selectFields as $alias => $field) {
                    if ($alias != $field) {
                        if ((!$sql->hasValue($field) || !$sql->getValue($field)) && $sql->hasValue($alias)) {
                            $sql->setValue($field, $sql->getValue($alias));
                        }
                        $xform->setValueField('hidden', array($alias, ''));
                    }
                }
                $xform->setObjectparams('sql_object', $sql);
                $xform->setObjectparams('getdata', true);
            } elseif ($func == 'add') {
                $xform->setObjectparams('submit_btn_label', $I18N->msg('add'));
                $xform->setActionField('manage_db', array($REX['TABLE_PREFIX'] . 'xform_field'));
            }
            if ($type_id == 'value') {
                $xform->setValueField('checkbox', array('list_hidden', $I18N->msg('hideinlist'), 1, '1'));
                $xform->setValueField('checkbox', array('search', $I18N->msg('useassearchfieldalidatenamenotempty'), 1, '1'));
            } elseif ($type_id == 'validate') {
                $xform->setValueField('hidden', array('list_hidden', 1));
            }
            $form = $xform->getForm();
            if ($xform->objparams['form_show']) {
                if ($func == 'add') {
                    echo '<div class="rex-addon-output"><h3 class="rex-hl2">' . $I18N->msg('addfield') . ' "' . $type_name . '"</h3><div class="rex-addon-content">';
                } else {
                    echo '<div class="rex-addon-output"><h3 class="rex-hl2">' . $I18N->msg('editfield') . ' "' . $type_name . '"</h3><div class="rex-addon-content">';
                }
                echo $form;
                echo '</div></div>';
                $table_echo = '<a href="index.php?' . $link_vars . '&amp;table_name=' . $table['table_name'] . '"><b>&laquo; ' . $I18N->msg('back_to_overview') . '</b></a>';
                echo rex_content_block($table_echo);
                $func = '';
            } else {
                if ($func == 'edit') {
                    $this->generateAll();
                    echo rex_info($I18N->msg('thankyouforupdate'));
                } elseif ($func == 'add') {
                    $this->generateAll();
                    echo rex_info($I18N->msg('thankyouforentry'));
                }
                $func = 'list';
            }
        }
        // ********************************************* LOESCHEN
        if ($func == 'delete') {
            $sf = new rex_sql();
            // $sf->debugsql = 1;
            $sf->setQuery('select * from ' . $REX['TABLE_PREFIX'] . 'xform_field where table_name="' . $table['table_name'] . '" and id=' . $field_id);
            $sfa = $sf->getArray();
            if (count($sfa) == 1) {
                $query = 'delete from ' . $REX['TABLE_PREFIX'] . 'xform_field where table_name="' . $table['table_name'] . '" and id=' . $field_id;
                $delsql = new rex_sql();
                // $delsql->debugsql=1;
                $delsql->setQuery($query);
                echo rex_info($I18N->msg('tablefielddeleted'));
                $this->generateAll();
            } else {
                echo rex_warning($I18N->msg('tablefieldnotfound'));
            }
            $func = 'list';
        }
        // ********************************************* CREATE/UPDATE FIELDS
        if ($func == 'updatetable') {
            $this->generateAll();
            echo rex_info($I18N->msg('tablesupdated'));
            $func = 'list';
        }
        if ($func == 'updatetablewithdelete') {
            $this->generateAll(array('delete_fields' => true));
            echo rex_info($I18N->msg('tablesupdated'));
            $func = 'list';
        }
        // ********************************************* LIST
        if ($func == 'list') {
            // ****** EP XFORM_MANAGER_TABLE_FIELD_FUNC
            $show_list = true;
            $show_list = rex_register_extension_point('XFORM_MANAGER_TABLE_FIELD_FUNC', $show_list, array('table' => $t, 'link_vars' => $this->getLinkVars()));
            if ($show_list) {
                function rex_xform_list_format($p, $value = '')
                {
                    if ($value != '') {
                        $p['value'] = $value;
                    }
                    switch ($p['list']->getValue('type_id')) {
                        case 'validate':
                            $style = 'color:#aaa;';
                            // background-color:#cfd9d9;
                            break;
                        case 'action':
                            $style = 'background-color:#cfd9d9;';
                            break;
                        default:
                            $style = 'background-color:#eff9f9;';
                            break;
                    }
                    return '<td style="' . $style . '">' . $p['value'] . '</td>';
                }
                function rex_xform_list_edit_format($p)
                {
                    global $REX, $I18N;
                    return rex_xform_list_format($p, $p['list']->getColumnLink($I18N->msg('edit'), $I18N->msg('edit')));
                }
                function rex_xform_list_delete_format($p)
                {
                    global $REX, $I18N;
                    return rex_xform_list_format($p, $p['list']->getColumnLink($I18N->msg('delete'), $I18N->msg('delete')));
                }
                $table_echo = '
                     <div class="rex-area-col-2">
                             <div class="rex-area-col-a">
                                     <a href="index.php?' . $link_vars . '&table_name=' . $table['table_name'] . '&func=choosenadd"><b>+ ' . $I18N->msg('addtablefield') . '</b></a>
                             </div>
                             <div class="rex-area-col-b rex-algn-rght">
                                 <a href="index.php?' . $link_vars . '&table_name=' . $table['table_name'] . '&func=updatetable"><b>o ' . $I18N->msg('updatetable') . '</b></a>
                                 <a href="index.php?' . $link_vars . '&table_name=' . $table['table_name'] . '&func=updatetablewithdelete" onclick="return confirm(\'' . $I18N->msg('updatetable_with_delete_confirm') . '\')"><b>o ' . $I18N->msg('updatetable_with_delete') . '</b></a>
                             </div>
                     </div>
                     <div class="rex-clearer"></div>
                     ';
                echo rex_content_block($table_echo);
                $sql = 'select id, prio, type_id, type_name, name from ' . $REX['TABLE_PREFIX'] . 'xform_field where table_name="' . $table['table_name'] . '" order by prio';
                $list = rex_list::factory($sql, 30);
                // $list->debug = 1;
                $list->setColumnFormat('id', 'Id');
                foreach ($this->getLinkVars() as $k => $v) {
                    $list->addParam($k, $v);
                }
                $list->addParam('table_name', $table['table_name']);
                $list->removeColumn('id');
                $list->setColumnLayout('prio', array('<th>###VALUE###</th>', '###VALUE###'));
                $list->setColumnFormat('prio', 'custom', 'rex_xform_list_format');
                $list->setColumnLayout('type_id', array('<th>###VALUE###</th>', '###VALUE###'));
                $list->setColumnFormat('type_id', 'custom', 'rex_xform_list_format');
                $list->setColumnLayout('type_name', array('<th>###VALUE###</th>', '###VALUE###'));
                $list->setColumnFormat('type_name', 'custom', 'rex_xform_list_format');
                $list->setColumnLayout('name', array('<th>###VALUE###</th>', '###VALUE###'));
                // ###VALUE###
                $list->setColumnFormat('name', 'custom', 'rex_xform_list_format');
                $list->addColumn($I18N->msg('edit'), $I18N->msg('edit'));
                $list->setColumnParams($I18N->msg('edit'), array('field_id' => '###id###', 'func' => 'edit', 'type_name' => '###type_name###', 'type_id' => '###type_id###'));
                $list->setColumnLayout($I18N->msg('edit'), array('<th>###VALUE###</th>', '###VALUE###'));
                $list->setColumnFormat($I18N->msg('edit'), 'custom', 'rex_xform_list_edit_format');
                $list->addColumn($I18N->msg('delete'), $I18N->msg('delete'));
                $list->setColumnParams($I18N->msg('delete'), array('field_id' => '###id###', 'func' => 'delete'));
                $list->setColumnLayout($I18N->msg('delete'), array('<th>###VALUE###</th>', '###VALUE###'));
                $list->setColumnFormat($I18N->msg('delete'), 'custom', 'rex_xform_list_delete_format');
                $list->addLinkAttribute($I18N->msg('delete'), 'onclick', 'return confirm(\' [###type_id###, ###type_name###, ###name###] ' . $I18N->msg('delete') . ' ?\')');
                echo $list->get();
            }
        }
    }
Exemplo n.º 17
0
     $modules = array();
 }
 if (!is_array($categories)) {
     $categories = array();
 }
 // modules[ctype_id][module_id];
 // modules[ctype_id]['all'];
 // Module ...
 $modul_select = new rex_select();
 $modul_select->setMultiple(true);
 $modul_select->setStyle('class="rex-form-select"');
 $modul_select->setSize(10);
 $m_sql = rex_sql::factory();
 $m_sql->setQuery('SELECT id, name FROM ' . $REX['TABLE_PREFIX'] . 'module ORDER BY name');
 foreach ($m_sql->getArray() as $m) {
     $modul_select->addOption(rex_translate($m['name'], $I18N, false), $m['id']);
 }
 // Kategorien
 $cat_select = new rex_category_select(false, false, false, false);
 $cat_select->setMultiple(true);
 $cat_select->setStyle('class="rex-form-select"');
 $cat_select->setSize(10);
 $cat_select->setName('categories[]');
 $cat_select->setId('categories');
 if (count($categories) > 0) {
     foreach ($categories as $c => $cc) {
         // typsicherer vergleich, weil (0 != "all") => false
         if ($c !== 'all') {
             $cat_select->setSelected($cc);
         }
     }
 static function getListValue($params)
 {
     // TODO Relation table berücksichtigen
     $field = $params['params']['field'];
     if (4 == $field['type']) {
         $link = 'index.php?page=xform&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_xform_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_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);
 }
Exemplo n.º 19
0
                $lang_a->setId('clang_a');
                $lang_a->setName('clang_a');
                $lang_a->setSize('1');
                $lang_a->setAttribute('tabindex', rex_tabindex(false));
                foreach ($clang_perm as $key) {
                    $val = rex_translate($REX['CLANG'][$key]);
                    $lang_a->addOption($val, $key);
                }
                $lang_b = new rex_select();
                $lang_b->setStyle('class="rex-form-select"');
                $lang_b->setId('clang_b');
                $lang_b->setName('clang_b');
                $lang_b->setSize('1');
                $lang_b->setAttribute('tabindex', rex_tabindex(false));
                foreach ($clang_perm as $key) {
                    $val = rex_translate($REX['CLANG'][$key]);
                    $lang_b->addOption($val, $key);
                }
                $lang_a->setSelected(rex_request('clang_a', 'rex-clang-id', null));
                $lang_b->setSelected(rex_request('clang_b', 'rex-clang-id', null));
                $out .= '
              <fieldset class="rex-form-col-2">
                <legend>' . $I18N->msg('content_submitcopycontent') . '</legend>
							  <div class="rex-form-wrapper">
							  
							  	<div class="rex-form-row">
									  <p class="rex-form-col-a rex-form-select">
											<label for="clang_a">' . $I18N->msg('content_contentoflang') . '</label>
											' . $lang_a->get() . '
										</p>
									  <p class="rex-form-col-b rex-form-select">
Exemplo n.º 20
0
<!-- *** OUTPUT CATEGORIES - END *** -->
';
// --------------------------------------------- ARTIKEL LISTE
echo '
<!-- *** OUTPUT ARTICLES - START *** -->';
// --------------------- READ TEMPLATES
if ($category_id > 0 || $category_id == 0 && !$REX['USER']->hasMountpoints()) {
    $template_select = new rex_select();
    $template_select->setName('template_id');
    $template_select->setId('rex-form-template');
    $template_select->setSize(1);
    $templates = OOCategory::getTemplates($category_id);
    if (count($templates) > 0) {
        foreach ($templates as $t_id => $t_name) {
            $template_select->addOption(rex_translate($t_name, null, false), $t_id);
            $TEMPLATE_NAME[$t_id] = rex_translate($t_name);
        }
    } else {
        $template_select->addOption($I18N->msg('option_no_template'), '0');
        $TEMPLATE_NAME[0] = $I18N->msg('template_default_name');
    }
    // --------------------- ARTIKEL LIST
    $art_add_link = '';
    if ($KATPERM && !$REX['USER']->hasPerm('editContentOnly[]')) {
        $art_add_link = '<a class="rex-i-element rex-i-article-add" href="index.php?page=structure&amp;category_id=' . $category_id . '&amp;function=add_art&amp;clang=' . $clang . '"' . rex_accesskey($I18N->msg('article_add'), $REX['ACKEY']['ADD_2']) . '><span class="rex-i-element-text">' . $I18N->msg('article_add') . '</span></a>';
    }
    $add_head = '';
    $add_col = '';
    if ($REX['USER']->hasPerm('advancedMode[]')) {
        $add_head = '<th class="rex-small">' . $I18N->msg('header_id') . '</th>';
        $add_col = '<col width="40" />';
    function getFieldPage()
    {
        global $REX, $I18N;
        // ********************************************* FIELD ADD/EDIT/LIST
        $func = rex_request('func', 'string', 'list');
        $page = rex_request('page', 'string', '');
        $subpage = rex_request('subpage', 'string', '');
        $tripage = rex_request('tripage', 'string', '');
        $type_id = rex_request('type_id', 'string');
        $type_name = rex_request('type_name', 'string');
        $field_id = rex_request('field_id', 'int');
        $show_list = true;
        $link_vars = '';
        foreach ($this->getLinkVars() as $k => $v) {
            $link_vars .= '&' . urlencode($k) . '=' . urlencode($v);
        }
        $TYPE = array('value' => $I18N->msg('xform_values'), 'validate' => $I18N->msg('xform_validates'), 'action' => $I18N->msg('xform_action'));
        // ********************************** TABELLE HOLEN
        $table = $this->table;
        $table_info = '<b>' . rex_translate($table->getName()) . ' [' . $table->getTableName() . ']</b> ';
        echo rex_content_block($table_info);
        // ********************************************* Missing Fields
        $mfields = $table->getMissingFields();
        // ksort($mfields);
        $type_real_field = rex_request('type_real_field', 'string');
        if ($type_real_field != '' && !array_key_exists($type_real_field, $mfields)) {
            $type_real_field = '';
        }
        if ($type_real_field != '') {
            ?>
            <div class="rex-addon-output"><h2 class="rex-hl2">Folgendes Feld wird verwendet: <?php 
            echo $type_real_field;
            ?>
</h2><div class="rex-addon-content"><p class="rex-tx1"><?php 
            $rfields = $this->table->getColumns();
            foreach ($rfields[$type_real_field] as $k => $v) {
                echo '<b>' . $k . ':</b> ' . $v . '<br />';
            }
            ?>
</p></div></div><?php 
        }
        // ********************************************* CHOOSE FIELD
        $types = rex_xform::getTypeArray();
        if ($func == 'choosenadd') {
            // type and choose !!
            $link = 'index.php?' . $link_vars . '&table_name=' . $table->getTableName() . '&func=add&';
            if (!$table->hasId()) {
                ?>
                <div class="rex-addon-output" id="xform-choosenadd"><h2 class="rex-hl2"><?php 
                echo $I18N->msg('xform_id_is_missing');
                ?>
</h2><div class="rex-addon-content">
                        <p class="rex-tx1"><?php 
                echo $I18N->msg('xform_id_missing_info');
                ?>
</p>
                    </div></div>
            <?php 
            } else {
                ?>
                <div class="rex-addon-output" id="xform-choosenadd"><h2 class="rex-hl2"><?php 
                echo $I18N->msg('xform_choosenadd');
                ?>
</h2><div class="rex-addon-content">
                        <p class="rex-tx1"><?php 
                echo $I18N->msg('xform_choosenadd_description');
                ?>
</p>
                    </div></div>
                <?php 
                if ($type_real_field == '' && count($mfields) > 0) {
                    ?>
                    <div class="rex-addon-output"><h2 class="rex-hl2">Es gibt noch Felder in der Tabelle welche nicht zugewiesen sind.</h2><div class="rex-addon-content">
                            <?php 
                    $d = 0;
                    foreach ($mfields as $k => $v) {
                        $d++;
                        $l = 'index.php?' . $link_vars . '&table_name=' . $table->getTableName() . '&func=choosenadd&type_real_field=' . $k . '&type_layout=t';
                        echo '<a href="' . $l . '">' . $k . '</a>, ';
                    }
                    ?>
</div></div>

                <?php 
                }
                ?>


                <div class="rex-addon-output xform-table_field">
                    <div class="rex-area-col-2">

                        <div class="rex-area-col-a">
                            <h3 class="rex-hl2">beliebte <?php 
                echo $TYPE['value'];
                ?>
</h3>
                            <div class="rex-area-content"><p class="rex-tx1"><?php 
                if (isset($types['value'])) {
                    ksort($types['value']);
                    foreach ($types['value'] as $k => $v) {
                        if (isset($v['famous']) && $v['famous']) {
                            echo '<p class="rex-button"><a class="rex-button" href="' . $link . 'type_id=value&type_name=' . $k . '&type_real_field=' . $type_real_field . '">' . $k . '</a> <span>' . $v['description'] . '</span></p>';
                        }
                    }
                }
                ?>
</p></div></div>

                        <div class="rex-area-col-b"><h3 class="rex-hl2">beliebte <?php 
                echo $TYPE['validate'];
                ?>
</h3><div class="rex-area-content"><p class="rex-tx1"><?php 
                if (isset($types['validate'])) {
                    ksort($types['validate']);
                    foreach ($types['validate'] as $k => $v) {
                        if (isset($v['famous']) && $v['famous']) {
                            echo '<p class="rex-button"><a class="rex-button" href="' . $link . 'type_id=validate&type_name=' . $k . '">' . $k . '</a> <span>' . $v['description'] . '</span></p>';
                        }
                    }
                }
                ?>
</p></div></div>

                    </div></div>

                <div class="rex-addon-output xform-table_field">
                    <div class="rex-area-col-2">

                        <div class="rex-area-col-a"><h3 class="rex-hl2"><?php 
                echo $TYPE['value'];
                ?>
</h3><div class="rex-area-content"><p class="rex-tx1"><?php 
                if (isset($types['value'])) {
                    ksort($types['value']);
                    foreach ($types['value'] as $k => $v) {
                        if (!isset($v['famous']) || $v['famous'] !== true) {
                            echo '<p class="rex-button"><a class="rex-button" href="' . $link . 'type_id=value&type_name=' . $k . '&type_real_field=' . $type_real_field . '">' . $k . '</a> <span>' . $v['description'] . '</span></p>';
                        }
                    }
                }
                ?>
</p></div></div>

                        <div class="rex-area-col-b"><h3 class="rex-hl2"><?php 
                echo $TYPE['validate'];
                ?>
</h3><div class="rex-area-content"><p class="rex-tx1"><?php 
                if (isset($types['validate'])) {
                    ksort($types['validate']);
                    foreach ($types['validate'] as $k => $v) {
                        if (!isset($v['famous']) || $v['famous'] !== true) {
                            echo '<p class="rex-button"><a class="rex-button" href="' . $link . 'type_id=validate&type_name=' . $k . '">' . $k . '</a> <span>' . $v['description'] . '</span></p>';
                        }
                    }
                }
                ?>
</p></div></div>

                    </div></div>

                <!--
             <div class="rex-addon-output">
             <h2 class="rex-hl2"><?php 
                echo $TYPE['action'];
                ?>
</h2>
             <div class="rex-addon-content">
             <p class="rex-tx1"><?php 
                if (isset($types['action'])) {
                    ksort($types['action']);
                    foreach ($types['action'] as $k => $v) {
                        echo '<p class="rex-button">"<a href="' . $link . 'type_id=action&type_name=' . $k . '">' . $k . '</a>" - ' . $v['description'] . '</p>';
                    }
                }
                ?>
</p>
             </div>
             </div>
             -->

            <?php 
            }
            $table_echo = '<a href="index.php?' . $link_vars . '&amp;table_name=' . $table->getTableName() . '"><b>&laquo; ' . $I18N->msg('xform_back_to_overview') . '</b></a>';
            echo rex_content_block($table_echo);
        }
        // ********************************************* FORMULAR
        if (($func == 'add' || $func == 'edit') && isset($types[$type_id][$type_name])) {
            $xform = new rex_xform();
            $xform->setDebug(false);
            foreach ($this->getLinkVars() as $k => $v) {
                $xform->setHiddenField($k, $v);
            }
            $xform->setHiddenField('func', $func);
            $xform->setHiddenField('table_name', $table->getTableName());
            $xform->setHiddenField('type_real_field', $type_real_field);
            $xform->setHiddenField('list', rex_request('list', 'string'));
            $xform->setHiddenField('sort', rex_request('sort', 'string'));
            $xform->setHiddenField('sorttype', rex_request('sorttype', 'string'));
            $xform->setHiddenField('start', rex_request('start', 'string'));
            $xform->setValueField('hidden', array('table_name', $table->getTableName()));
            $xform->setValueField('hidden', array('type_name', $type_name, 'REQUEST'));
            $xform->setValueField('hidden', array('type_id', $type_id, 'REQUEST'));
            $xform->setValueField('prio', array('prio', 'Prioritaet', array('name', 'type_id', 'type_name'), array('table_name')));
            $selectFields = array();
            $i = 1;
            foreach ($types[$type_id][$type_name]['values'] as $k => $v) {
                $field = $this->getFieldName($k, $type_id);
                $selectFields['f' . $i] = $field;
                $i++;
                switch ($v['type']) {
                    case 'name':
                        if ($func == 'edit') {
                            $xform->setValueField('showvalue', array($field, 'Name'));
                        } else {
                            if (!isset($v['value']) && $type_real_field != '') {
                                $v['value'] = $type_real_field;
                            } elseif (!isset($v['value'])) {
                                $v['value'] = '';
                            }
                            $xform->setValueField('text', array($field, 'Name', $v['value']));
                            $xform->setValidateField('notEmpty', array($field, $I18N->msg('xform_validatenamenotempty')));
                            $xform->setValidateField('preg_match', array($field, "/(([a-zA-Z])+([a-zA-Z0-9\\_])*)/", $I18N->msg('xform_validatenamepregmatch')));
                            $xform->setValidateField('customfunction', array($field, 'rex_xform_manager_checkField', array('table_name' => $table->getTableName()), $I18N->msg('xform_validatenamecheck')));
                        }
                        break;
                    case 'no_db':
                        if (!isset($v['default']) || $v['default'] != 1) {
                            $v['default'] = 0;
                        }
                        $xform->setValueField('checkbox', array($field, $I18N->msg('xform_donotsaveindb'), 'no_db', $v['default']));
                        break;
                    case 'boolean':
                        // checkbox|check_design|Bezeichnung|Value|1/0|[no_db]
                        if (!isset($v['default'])) {
                            $v['default'] = '';
                        }
                        $xform->setValueField('checkbox', array($field, $v['label'], '', $v['default']));
                        break;
                    case 'select':
                        // select|gender|Geschlecht *|Frau=w;Herr=m|[no_db]|defaultwert|multiple=1
                        $xform->setValueField('select', array($field, $v['label'], $v['options'], '', $v['default'], 0));
                        break;
                    case 'table':
                        // ist fest eingetragen, damit keine Dinge durcheinandergehen
                        if ($func == 'edit') {
                            $xform->setValueField('showvalue', array($field, $v['label']));
                        } else {
                            $_tables = rex_xform_manager_table::getAll();
                            $_options = array();
                            if (isset($v['empty_option']) && $v['empty_option']) {
                                $_options[0] = '–=';
                            }
                            foreach ($_tables as $_table) {
                                $_options[$_table['table_name']] = str_replace('=', '-', rex_translate($_table['name']) . ' [' . $_table['table_name'] . ']') . '=' . $_table['table_name'];
                                $_options[$_table['table_name']] = str_replace(',', '.', $_options[$_table['table_name']]);
                            }
                            if (!isset($v['default'])) {
                                $v['default'] = '';
                            }
                            $xform->setValueField('select', array($field, $v['label'], implode(',', $_options), '', $v['default'], 0));
                        }
                        break;
                    case 'textarea':
                        $xform->setValueField('textarea', array($field, $v['label']));
                        break;
                    case 'table.field':
                        // Todo:
                    // Todo:
                    case 'select_name':
                        $_fields = array();
                        foreach ($table->getValueFields() as $_k => $_v) {
                            $_fields[] = $_k;
                        }
                        $xform->setValueField('select', array($field, $v['label'], implode(',', $_fields), '', '', 0));
                        break;
                    case 'select_names':
                        $_fields = array();
                        foreach ($table->getValueFields() as $_k => $_v) {
                            $_fields[] = $_k;
                        }
                        $xform->setValueField('select', array($field, $v['label'], implode(',', $_fields), '', '', 1, 5));
                        break;
                    default:
                        // nur beim "Bezeichnungsfeld"
                        if ($field == 'label' && $type_real_field != '' && !isset($v['value'])) {
                            $v['value'] = $type_real_field;
                        } elseif (!isset($v['value'])) {
                            $v['value'] = '';
                        }
                        $xform->setValueField('text', array($field, $v['label'], $v['value']));
                }
            }
            $xform->setActionField('showtext', array('', '<p>' . $I18N->msg('xform_thankyouforentry') . '</p>'));
            $xform->setObjectparams('main_table', rex_xform_manager_field::table());
            if ($func == 'edit') {
                $xform->setObjectparams('submit_btn_label', $I18N->msg('xform_save'));
                $xform->setHiddenField('field_id', $field_id);
                $xform->setActionField('manage_db', array(rex_xform_manager_field::table(), "id={$field_id}"));
                $xform->setObjectparams('main_id', $field_id);
                $xform->setObjectparams('main_where', "id={$field_id}");
                $sql = rex_sql::factory();
                $sql->setQuery('SELECT * FROM ' . rex_xform_manager_field::table() . " WHERE id={$field_id}");
                foreach ($selectFields as $alias => $field) {
                    if ($alias != $field) {
                        if ((!$sql->hasValue($field) || null === $sql->getValue($field) || '' === $sql->getValue($field)) && $sql->hasValue($alias)) {
                            $sql->setValue($field, $sql->getValue($alias));
                        }
                        $xform->setValueField('hidden', array($alias, ''));
                    }
                }
                $xform->setObjectparams('sql_object', $sql);
                $xform->setObjectparams('getdata', true);
            } elseif ($func == 'add') {
                $xform->setObjectparams('submit_btn_label', $I18N->msg('xform_add'));
                $xform->setActionField('manage_db', array(rex_xform_manager_field::table()));
            }
            if ($type_id == 'value') {
                $xform->setValueField('checkbox', array('list_hidden', $I18N->msg('xform_hideinlist'), 1, '1'));
                $xform->setValueField('checkbox', array('search', $I18N->msg('xform_useassearchfieldalidatenamenotempty'), 1, '1'));
            } elseif ($type_id == 'validate') {
                $xform->setValueField('hidden', array('list_hidden', 1));
            }
            $form = $xform->getForm();
            if ($xform->objparams['form_show']) {
                if ($func == 'add') {
                    echo '<div class="rex-addon-output"><h3 class="rex-hl2">' . $I18N->msg('xform_addfield') . ' "' . $type_name . '"</h3><div class="rex-addon-content">';
                } else {
                    echo '<div class="rex-addon-output"><h3 class="rex-hl2">' . $I18N->msg('xform_editfield') . ' "' . $type_name . '"</h3><div class="rex-addon-content">';
                }
                echo $form;
                echo '</div></div>';
                $table_echo = '<a href="index.php?' . $link_vars . '&amp;table_name=' . $table->getTableName() . '"><b>&laquo; ' . $I18N->msg('xform_back_to_overview') . '</b></a>';
                echo rex_content_block($table_echo);
                $func = '';
            } else {
                if ($func == 'edit') {
                    $this->generateAll();
                    echo rex_info($I18N->msg('xform_thankyouforupdate'));
                } elseif ($func == 'add') {
                    $this->generateAll();
                    echo rex_info($I18N->msg('xform_thankyouforentry'));
                }
                $func = 'list';
            }
        }
        // ********************************************* LOESCHEN
        if ($func == 'delete') {
            $sf = new rex_sql();
            $sf->debugsql = self::$debug;
            $sf->setQuery('select * from ' . rex_xform_manager_field::table() . ' where table_name="' . $table->getTableName() . '" and id=' . $field_id);
            $sfa = $sf->getArray();
            if (count($sfa) == 1) {
                $query = 'delete from ' . rex_xform_manager_field::table() . ' where table_name="' . $table->getTableName() . '" and id=' . $field_id;
                $delsql = new rex_sql();
                $delsql->debugsql = self::$debug;
                $delsql->setQuery($query);
                echo rex_info($I18N->msg('xform_tablefielddeleted'));
                $this->generateAll();
            } else {
                echo rex_warning($I18N->msg('xform_tablefieldnotfound'));
            }
            $func = 'list';
        }
        // ********************************************* CREATE/UPDATE FIELDS
        if ($func == 'updatetable') {
            $this->generateAll();
            echo rex_info($I18N->msg('xform_tablesupdated'));
            $func = 'list';
        }
        if ($func == 'updatetablewithdelete') {
            $this->generateAll(array('delete_fields' => true));
            echo rex_info($I18N->msg('xform_tablesupdated'));
            $func = 'list';
        }
        if ($func == 'show_form_notation') {
            $formbuilder_fields = $table->getFields();
            $notation_php = '';
            $notation_pipe = '';
            $notation_email = '';
            $notation_php_pre = array('$xform = new rex_xform();', '$xform->setObjectparams(\'form_skin\', \'default\');', '$xform->setObjectparams(\'form_showformafterupdate\', 0);', '$xform->setObjectparams(\'real_field_names\', true);');
            $notation_php .= implode("\n", $notation_php_pre) . "\n";
            $notation_pipe_pre = array('objparams|form_skin|default', 'objparams|form_showformafterupdate|0', 'objparams|real_field_names|true');
            $notation_pipe .= implode("\n", $notation_pipe_pre) . "\n";
            foreach ($formbuilder_fields as $field) {
                $classname = rex_xform::includeClass($field['type_id'], $field['type_name']);
                $cl = new $classname();
                $definitions = $cl->getDefinitions();
                $values = array();
                $i = 1;
                foreach ($definitions['values'] as $key => $_) {
                    $key = $this->getFieldName($key, $field['type_id']);
                    if (isset($field[$key])) {
                        $values[] = $field[$key];
                    } elseif (isset($field['f' . $i])) {
                        $values[] = $field['f' . $i];
                    } else {
                        $values[] = '';
                    }
                    $i++;
                }
                if ($field['type_id'] == 'value') {
                    $notation_php .= "\n" . '$xform->setValueField(\'' . $field['type_name'] . '\', array("' . rtrim(implode('","', $values), '","') . '"));';
                    $notation_pipe .= "\n" . $field['type_name'] . '|' . rtrim(implode('|', $values), '|') . '|';
                    $notation_email .= "\n" . $field['label'] . ': ###' . $field['name'] . '###';
                } elseif ($field['type_id'] == 'validate') {
                    $notation_php .= "\n" . '$xform->setValidateField(\'' . $field['type_name'] . '\', array("' . rtrim(implode('","', $values), '","') . '"));';
                    $notation_pipe .= "\n" . $field['type_id'] . '|' . $field['type_name'] . '|' . rtrim(implode('|', $values), '|') . '|';
                } elseif ($field['type_id'] == 'action') {
                    $notation_php .= "\n" . '$xform->setActionField(\'' . $field['type_name'] . '\', array("' . rtrim(implode('","', $values), '","') . '"));';
                    $notation_pipe .= "\n" . $field['type_id'] . '|' . $field['type_name'] . '|' . rtrim(implode('|', $values), '|') . '|';
                }
            }
            $notation_php .= "\n\n" . '$xform->setActionField(\'db2email\', array(\'emailtemplate\', \'emaillabel\', \'email@domain.de\'));';
            $notation_php .= "\n" . 'echo $xform->getForm();';
            $notation_pipe .= "\n\n" . 'action|db2email|emailtemplate|emaillabel|email@domain.de';
            echo '<div class="rex-addon-output">';
            echo '<h2 class="rex-hl2">PHP</h2>';
            echo '<div class="rex-addon-content">';
            echo '<pre class="rex-code"><code>' . $notation_php . '</code></pre>';
            echo '</div></div>';
            echo '<div class="rex-addon-output">';
            echo '<h2 class="rex-hl2">Pipe</h2>';
            echo '<div class="rex-addon-content">';
            echo '<pre class="rex-code"><code>' . $notation_pipe . '</code></pre>';
            echo '</div></div>';
            echo '<div class="rex-addon-output">';
            echo '<h2 class="rex-hl2">E-Mail</h2>';
            echo '<div class="rex-addon-content">';
            echo '<pre class="rex-code"><code>' . $notation_email . '</code></pre>';
            echo '</div></div>';
            $func = 'list';
        }
        // ********************************************* LIST
        if ($func == 'list') {
            // ****** EP XFORM_MANAGER_TABLE_FIELD_FUNC
            $show_list = true;
            $show_list = rex_register_extension_point('XFORM_MANAGER_TABLE_FIELD_FUNC', $show_list, array('table' => $table, 'link_vars' => $this->getLinkVars()));
            if ($show_list) {
                function rex_xform_list_format($p, $value = '')
                {
                    if ($value != '') {
                        $p['value'] = $value;
                    }
                    switch ($p['list']->getValue('type_id')) {
                        case 'validate':
                            $style = 'color:#aaa;';
                            // background-color:#cfd9d9;
                            break;
                        case 'action':
                            $style = 'background-color:#cfd9d9;';
                            break;
                        default:
                            $style = 'background-color:#eff9f9;';
                            break;
                    }
                    return '<td style="' . $style . '">' . $p['value'] . '</td>';
                }
                function rex_xform_list_edit_format($p)
                {
                    global $REX, $I18N;
                    return rex_xform_list_format($p, $p['list']->getColumnLink($I18N->msg('xform_edit'), $I18N->msg('xform_edit')));
                }
                function rex_xform_list_delete_format($p)
                {
                    global $REX, $I18N;
                    return rex_xform_list_format($p, $p['list']->getColumnLink($I18N->msg('xform_delete'), $I18N->msg('xform_delete')));
                }
                $table_echo = '
                     <div class="rex-area-col-2">
                             <div class="rex-area-col-a">
                                     <a href="index.php?' . $link_vars . '&table_name=' . $table->getTableName() . '&func=choosenadd"><b>+ ' . $I18N->msg('xform_addtablefield') . '</b></a>
                             </div>
                             <div class="rex-area-col-b rex-algn-rght">
                                <ul class="rex-navi-piped">
                                    <li><a href="index.php?' . $link_vars . '&table_name=' . $table->getTableName() . '&func=show_form_notation">' . $I18N->msg('xform_manager_show_form_notation') . '</a></li><li><a href="index.php?' . $link_vars . '&table_name=' . $table->getTableName() . '&func=updatetable">' . $I18N->msg('xform_updatetable') . '</a></li><li><a href="index.php?' . $link_vars . '&table_name=' . $table->getTableName() . '&func=updatetablewithdelete" onclick="return confirm(\'' . $I18N->msg('xform_updatetable_with_delete_confirm') . '\')">' . $I18N->msg('xform_updatetable_with_delete') . '</a></li>
                                </ul>
                             </div>
                     </div>
                     <div class="rex-clearer"></div>
                     ';
                echo rex_content_block($table_echo);
                $sql = 'select id, prio, type_id, type_name, name from ' . rex_xform_manager_field::table() . ' where table_name="' . $table->getTableName() . '" order by prio';
                $list = rex_list::factory($sql, 30);
                // $list->debug = 1;
                $list->setColumnFormat('id', 'Id');
                foreach ($this->getLinkVars() as $k => $v) {
                    $list->addParam($k, $v);
                }
                $list->addParam('start', rex_request('start', 'int'));
                $list->addParam('table_name', $table->getTableName());
                $list->removeColumn('id');
                $list->setColumnLabel('prio', $I18N->msg('xform_manager_table_prio_short'));
                $list->setColumnLabel('type_id', $I18N->msg('xform_manager_type_id'));
                $list->setColumnLabel('type_name', $I18N->msg('xform_manager_type_name'));
                $list->setColumnLabel('name', $I18N->msg('xform_manager_name'));
                $list->setColumnLayout('prio', array('<th>###VALUE###</th>', '###VALUE###'));
                $list->setColumnFormat('prio', 'custom', 'rex_xform_list_format');
                $list->setColumnLayout('type_id', array('<th>###VALUE###</th>', '###VALUE###'));
                $list->setColumnFormat('type_id', 'custom', 'rex_xform_list_format');
                $list->setColumnLayout('type_name', array('<th>###VALUE###</th>', '###VALUE###'));
                $list->setColumnFormat('type_name', 'custom', 'rex_xform_list_format');
                $list->setColumnLayout('name', array('<th>###VALUE###</th>', '###VALUE###'));
                // ###VALUE###
                $list->setColumnFormat('name', 'custom', 'rex_xform_list_format');
                $list->addColumn($I18N->msg('xform_edit'), $I18N->msg('xform_edit'));
                $list->setColumnParams($I18N->msg('xform_edit'), array('field_id' => '###id###', 'func' => 'edit', 'type_name' => '###type_name###', 'type_id' => '###type_id###'));
                $list->setColumnLayout($I18N->msg('xform_edit'), array('<th>###VALUE###</th>', '###VALUE###'));
                $list->setColumnFormat($I18N->msg('xform_edit'), 'custom', 'rex_xform_list_edit_format');
                $list->addColumn($I18N->msg('xform_delete'), $I18N->msg('xform_delete'));
                $list->setColumnParams($I18N->msg('xform_delete'), array('field_id' => '###id###', 'func' => 'delete'));
                $list->setColumnLayout($I18N->msg('xform_delete'), array('<th>###VALUE###</th>', '###VALUE###'));
                $list->setColumnFormat($I18N->msg('xform_delete'), 'custom', 'rex_xform_list_delete_format');
                $list->addLinkAttribute($I18N->msg('xform_delete'), 'onclick', 'return confirm(\' [###type_id###, ###type_name###, ###name###] ' . $I18N->msg('xform_delete') . ' ?\')');
                echo $list->get();
            }
        }
    }
 function getLabelStyle($label)
 {
     $label = rex_translate($label, null, false);
     if ($this->params['form_label_type'] == 'html') {
     } else {
         $label = nl2br(htmlspecialchars($label));
     }
     return $label;
     return '<span style="color:#f90">' . $label . '</span>';
 }
Exemplo n.º 23
0
<?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_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 = '';
}
$class_label = '';
$field_before = '';
$field_after = '';
if (trim($this->getElement('grid')) != '') {
    $grid = explode(',', trim($this->getElement('grid')));
    if (isset($grid[0]) && $grid[0] != '') {
        $class_label .= ' ' . trim($grid[0]);
    }
    if (isset($grid[1]) && $grid[1] != '') {
        $field_before = '<div class="' . trim($grid[1]) . '">';
        $field_after = '</div>';
    }
}
?>

 function preArticle()
 {
     global $REX, $I18N;
     // ---------- moduleselect: nur module nehmen auf die der user rechte hat
     if ($this->mode == 'edit') {
         $MODULE = rex_sql::factory();
         $modules = $MODULE->getArray('select * from ' . $REX['TABLE_PREFIX'] . 'module order by name');
         $template_ctypes = rex_getAttributes('ctype', $this->template_attributes, array());
         // wenn keine ctyes definiert sind, gibt es immer den CTYPE=1
         if (count($template_ctypes) == 0) {
             $template_ctypes = array(1 => 'default');
         }
         $this->MODULESELECT = array();
         foreach ($template_ctypes as $ct_id => $ct_name) {
             $this->MODULESELECT[$ct_id] = new rex_select();
             $this->MODULESELECT[$ct_id]->setName('module_id');
             $this->MODULESELECT[$ct_id]->setSize('1');
             $this->MODULESELECT[$ct_id]->setStyle('class="rex-form-select"');
             $this->MODULESELECT[$ct_id]->setAttribute('onchange', 'this.form.submit();');
             $this->MODULESELECT[$ct_id]->addOption('----------------------------  ' . $I18N->msg('add_block'), '');
             foreach ($modules as $m) {
                 if ($REX['USER']->isAdmin() || $REX['USER']->hasPerm('module[' . $m['id'] . ']')) {
                     if (rex_template::hasModule($this->template_attributes, $ct_id, $m['id'])) {
                         $this->MODULESELECT[$ct_id]->addOption(rex_translate($m['name'], NULL, FALSE), $m['id']);
                     }
                 }
             }
         }
     }
 }
/**
 * Erstellt den nötigen HTML Code um ein Formular zu erweitern
 *
 * @param $sqlFields rex_sql-objekt, dass die zu verarbeitenden Felder enthält
 * @param $activeItem objekt, dass mit getValue() die Werte des akuellen Eintrags zurückgibt
 * @param $formatCallback callback, dem die infos als Array übergeben werden und den formatierten HTML Text zurückgibt
 */
function rex_a62_metaFields($sqlFields, $activeItem, $formatCallback, $epParams)
{
    global $I18N;
    $s = '';
    // Startwert für MEDIABUTTON, MEDIALIST, LINKLIST zähler
    $media_id = 1;
    $mlist_id = 1;
    $link_id = 1;
    $llist_id = 1;
    $sqlFields->reset();
    for ($i = 0; $i < $sqlFields->getRows(); $i++) {
        // Umschliessendes Tag von Label und Formularelement
        $tag = 'p';
        $tag_attr = '';
        $name = $sqlFields->getValue('name');
        $title = $sqlFields->getValue('title');
        $params = $sqlFields->getValue('params');
        $typeLabel = $sqlFields->getValue('label');
        $attr = $sqlFields->getValue('attributes');
        $dblength = $sqlFields->getValue('dblength');
        $dbvalues = array(htmlspecialchars($sqlFields->getValue('default')));
        $dbvalues_esc = $dbvalues;
        if ($activeItem) {
            $itemValue = $activeItem->getValue($name);
            if (strpos($itemValue, '|+|') !== false) {
                // Alte notation mit |+| als Trenner
                $dbvalues = explode('|+|', $activeItem->getValue($name));
            } else {
                // Neue Notation mit | als Trenner
                $dbvalues = explode('|', $activeItem->getValue($name));
            }
            $dbvalues_esc = array_map('htmlspecialchars', $dbvalues);
        }
        if ($title != '') {
            $label = htmlspecialchars(rex_translate($title));
        } else {
            $label = htmlspecialchars($name);
        }
        $id = preg_replace('/[^a-zA-Z\\-0-9_]/', '_', $label);
        $attr .= rex_tabindex();
        $labelIt = true;
        $field = '';
        switch ($typeLabel) {
            case 'text':
                $field = '<input type="' . $typeLabel . '" name="' . $name . '" value="' . $dbvalues_esc[0] . '" id="' . $id . ' "maxlength="' . $dblength . '" ' . $attr . ' />';
                break;
            case 'checkbox':
                $name .= '[]';
            case 'radio':
                $values = array();
                if (rex_sql::getQueryType($params) == 'SELECT') {
                    $sql = new rex_sql();
                    $value_groups = $sql->getDBArray($params, MYSQL_NUM);
                    foreach ($value_groups as $value_group) {
                        if (isset($value_group[1])) {
                            $values[$value_group[1]] = $value_group[0];
                        } else {
                            $values[$value_group[0]] = $value_group[0];
                        }
                    }
                } else {
                    $value_groups = explode('|', $params);
                    foreach ($value_groups as $value_group) {
                        if (strpos($value_group, ':') !== false) {
                            $temp = explode(':', $value_group);
                            $values[$temp[0]] = $temp[1];
                        } else {
                            $values[$value_group] = $value_group;
                        }
                    }
                }
                $class = $typeLabel == 'radio' ? 'rex-rdo' : 'rex-chckbx';
                $oneValue = count($values) == 1;
                if (!$oneValue) {
                    $tag = '';
                    $labelIt = false;
                    $tag = 'div';
                    $tag_attr = ' class="rex-chckbxs rex-ptag"';
                    $field .= '<p>' . $label . '</p>';
                }
                foreach ($values as $key => $value) {
                    $id = preg_replace('/[^a-zA-Z\\-0-9_]/', '_', $id . $key);
                    $key = htmlspecialchars($key);
                    // wenn man keine Werte angibt (Boolean Chkbox/Radio)
                    // Dummy Wert annehmen, damit an/aus unterscheidung funktioniert
                    if ($oneValue && $key == '') {
                        $key = 'true';
                    }
                    $selected = '';
                    if (in_array($key, $dbvalues_esc)) {
                        $selected = ' checked="checked"';
                    }
                    if ($oneValue) {
                        $tag_attr = ' class="' . $class . '"';
                        $field .= '<input type="' . $typeLabel . '" name="' . $name . '" value="' . $key . '" id="' . $id . '" ' . $attr . $selected . ' />' . "\n";
                    } else {
                        $field .= '<p class="' . $class . '">' . "\n";
                        $field .= '<label for="' . $id . '"><span>' . htmlspecialchars($value) . '</span></label>';
                        $field .= '<input type="' . $typeLabel . '" name="' . $name . '" value="' . $key . '" id="' . $id . '" ' . $attr . $selected . ' />' . "\n";
                        $field .= '</p>' . "\n";
                    }
                }
                break;
            case 'select':
                $select = new rex_select();
                $select->setName($name);
                $select->setId($id);
                // hier mit den "raw"-values arbeiten, da die rex_select klasse selbst escaped
                $select->setSelected($dbvalues);
                foreach (rex_split_string($attr) as $attr_name => $attr_value) {
                    if (empty($attr_name)) {
                        continue;
                    }
                    $select->setAttribute($attr_name, $attr_value);
                    if ($attr_name == 'multiple') {
                        $select->setName($name . '[]');
                    }
                }
                if (rex_sql::getQueryType($params) == 'SELECT') {
                    // Werte via SQL Laden
                    $select->addDBSqlOptions($params);
                } else {
                    // Optionen mit | separiert
                    // eine einzelne Option kann mit key:value separiert werden
                    $values = array();
                    $value_groups = explode('|', $params);
                    foreach ($value_groups as $value_group) {
                        if (strpos($value_group, ':') !== false) {
                            $temp = explode(':', $value_group);
                            $values[$temp[0]] = $temp[1];
                        } else {
                            $values[$value_group] = $value_group;
                        }
                    }
                    $select->addOptions($values);
                }
                $field .= $select->get();
                break;
            case 'datetime':
            case 'date':
                if ($dbvalues_esc[0] == '') {
                    $dbvalues_esc[0] = time();
                }
                $style = 'class="rex-fdate"';
                $yearStyle = 'class="rex-fdatey"';
                $yearSelect = new rex_select();
                $yearSelect->addOptions(range(2005, date('Y') + 10), true);
                $yearSelect->setName($name . '[year]');
                $yearSelect->setSize(1);
                $yearSelect->setId($id);
                $yearSelect->setStyle($yearStyle);
                $yearSelect->setSelected(date('Y', $dbvalues_esc[0]));
                $monthSelect = new rex_select();
                $monthSelect->addOptions(range(1, 12), true);
                $monthSelect->setName($name . '[month]');
                $monthSelect->setSize(1);
                $monthSelect->setStyle($style);
                $monthSelect->setSelected(date('m', $dbvalues_esc[0]));
                $daySelect = new rex_select();
                $daySelect->addOptions(range(1, 31), true);
                $daySelect->setName($name . '[day]');
                $daySelect->setSize(1);
                $daySelect->setStyle($style);
                $daySelect->setSelected(date('j', $dbvalues_esc[0]));
                if ($typeLabel == 'datetime') {
                    $hourSelect = new rex_select();
                    $hourSelect->addOptions(range(1, 23), true);
                    $hourSelect->setName($name . '[hour]');
                    $hourSelect->setSize(1);
                    $hourSelect->setStyle($style);
                    $hourSelect->setSelected(date('G', $dbvalues_esc[0]));
                    $minuteSelect = new rex_select();
                    $minuteSelect->addOptions(range(0, 59), true);
                    $minuteSelect->setName($name . '[minute]');
                    $minuteSelect->setSize(1);
                    $minuteSelect->setStyle($style);
                    $minuteSelect->setSelected(date('i', $dbvalues_esc[0]));
                    $field = $daySelect->get() . $monthSelect->get() . $yearSelect->get() . '-' . $hourSelect->get() . $minuteSelect->get();
                } else {
                    $field = $daySelect->get() . $monthSelect->get() . $yearSelect->get();
                }
                break;
            case 'textarea':
                $field = '<textarea name="' . $name . '" id="' . $id . '" cols="50" rows="6" ' . $attr . '>' . $dbvalues_esc[0] . '</textarea>';
                break;
            case 'REX_MEDIA_BUTTON':
                $tag = 'div';
                $tag_attr = ' class="rex-ptag"';
                $field = rex_var_media::getMediaButton($media_id);
                $field = str_replace('REX_MEDIA[' . $media_id . ']', $dbvalues_esc[0], $field);
                $field = str_replace('MEDIA[' . $media_id . ']', $name, $field);
                $id = 'REX_MEDIA_' . $media_id;
                $media_id++;
                break;
            case 'REX_MEDIALIST_BUTTON':
                $tag = 'div';
                $tag_attr = ' class="rex-ptag"';
                $name .= '[]';
                $field = rex_var_media::getMediaListButton($mlist_id, implode(',', $dbvalues_esc));
                $field = str_replace('MEDIALIST[' . $mlist_id . ']', $name, $field);
                $id = 'REX_MEDIALIST_' . $mlist_id;
                $mlist_id++;
                break;
            case 'REX_LINK_BUTTON':
                $tag = 'div';
                $tag_attr = ' class="rex-ptag"';
                $category = '';
                if ($activeItem) {
                    $category = $activeItem->getValue('category_id');
                }
                $field = rex_var_link::getLinkButton($link_id, $dbvalues_esc[0], $category);
                $field = str_replace('LINK[' . $link_id . ']', $name, $field);
                $id = 'LINK_' . $link_id;
                $link_id++;
                break;
            case 'REX_LINKLIST_BUTTON':
                $tag = 'div';
                $tag_attr = ' class="rex-ptag"';
                $category = '';
                if ($activeItem) {
                    $category = $activeItem->getValue('category_id');
                }
                $name .= '[]';
                $field = rex_var_link::getLinklistButton($llist_id, implode(',', $dbvalues), $category);
                $field = str_replace('LINKLIST[' . $llist_id . ']', $name, $field);
                $id = 'REX_LINKLIST_' . $llist_id;
                $llist_id++;
                break;
            default:
                // ----- EXTENSION POINT
                list($field, $tag, $tag_attr, $id, $label, $labelIt) = rex_register_extension_point('A62_CUSTOM_FIELD', array($field, $tag, $tag_attr, $id, $label, $labelIt, 'type' => $typeLabel, 'sql' => $sqlFields));
        }
        $s .= rex_call_func($formatCallback, array($field, $tag, $tag_attr, $id, $label, $labelIt), false);
        $sqlFields->next();
    }
    return $s;
}
 function setColumnLabel($columnName, $label)
 {
     $this->columnLabels[$columnName] = rex_translate($label, null, false);
 }
Exemplo n.º 27
0
echo '
<!-- *** OUTPUT ARTICLES - START *** -->';
// --------------------- READ TEMPLATES
if ($category_id > -1) {
    $TEMPLATES = new rex_sql();
    $TEMPLATES->setQuery('select * from ' . $REX['TABLE_PREFIX'] . 'template order by name');
    $TMPL_SEL = new rex_select();
    $TMPL_SEL->setName('template_id');
    $TMPL_SEL->setId('template_id');
    $TMPL_SEL->setSize(1);
    $TMPL_SEL->addOption($I18N->msg('option_no_template'), '0');
    for ($i = 0; $i < $TEMPLATES->getRows(); $i++) {
        if ($TEMPLATES->getValue('active') == 1) {
            $TMPL_SEL->addOption(rex_translate($TEMPLATES->getValue('name')), $TEMPLATES->getValue('id'));
        }
        $TEMPLATE_NAME[$TEMPLATES->getValue('id')] = rex_translate($TEMPLATES->getValue('name'));
        $TEMPLATES->next();
    }
    $TEMPLATE_NAME[0] = $I18N->msg('template_default_name');
    // --------------------- ARTIKEL LIST
    if (isset($amessage) and $amessage != '') {
        echo rex_warning($amessage);
    }
    $art_add_link = '';
    if ($KATPERM && !$REX_USER->hasPerm('editContentOnly[]')) {
        $art_add_link = '<a href="index.php?page=structure&amp;category_id=' . $category_id . '&amp;function=add_art&amp;clang=' . $clang . '"' . rex_accesskey($I18N->msg('article_add'), $REX['ACKEY']['ADD_2']) . '><img src="media/document_plus.gif" alt="' . $I18N->msg('article_add') . '" /></a>';
    }
    $add_head = '';
    $add_col = '';
    if ($REX_USER->hasPerm('advancedMode[]')) {
        $add_head = '<th class="rex-icon">' . $I18N->msg('header_id') . '</th>';
Exemplo n.º 28
0
<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_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>
        					<th>' . $I18N->msg('action_functions') . '</th>
      					</tr>
    					</thead>
    				<tbody>
              ' . $actions . '
            </tbody>
            </table>
          ';
                }
                $gaa_sel = new rex_select();
                $gaa_sel->setName('action_id');
                $gaa_sel->setId('action_id');
                $gaa_sel->setSize(1);
                $gaa_sel->setStyle('class="rex-form-select"');
                for ($i = 0; $i < $gaa->getRows(); $i++) {
                    $gaa_sel->addOption(rex_translate($gaa->getValue('name'), null, false), $gaa->getValue('id'));
                    $gaa->next();
                }
                echo $actions . '
				<fieldset class="rex-form-col-1">
          <legend>' . $I18N->msg('action_add') . '</legend>
      		<div class="rex-form-wrapper">
						
						<div class="rex-form-row">
							<p class="rex-form-col-a rex-form-select">
								<label for="action_id">' . $I18N->msg('action') . '</label>
								' . $gaa_sel->get() . '
					  	</p>
					  </div>
					  
						<div class="rex-form-row">
Exemplo n.º 30
0
<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_translate($this->getValue())));
?>
" />
</p>