function __construct($tag = '', &$table, $attributes = array()) { global $I18N; global $REX; parent::rex_form_select_element('', $table, $attributes); $dummy = null; $this->chkbox_element = new rex_form_checkbox_element('', $dummy); $this->chkbox_element->setAttribute('name', 'enable_restrictions'); $this->chkbox_element->setAttribute('id', 'enable_restrictions_chkbx'); $this->chkbox_element->addOption($I18N->msg('minfo_field_label_no_restrictions'), ''); if ($table->getPrefix() == 'art_' || $table->getPrefix() == 'cat_') { $restrictionsSelect = new rex_category_select(false, false, true, false); } elseif ($table->getPrefix() == 'med_') { $restrictionsSelect = new rex_mediacategory_select(); } elseif ($table->getPrefix() == global_settings_metainfo::PREFIX) { $restrictionsSelect = new rex_select(); $restrictionsSelect->setSize(1); $restrictionsSelect->setDisabled(true); } else { trigger_error('Unexpected TablePrefix "' . $table->getPrefix() . '"!', E_USER_ERROR); exit; } $restrictionsSelect->setMultiple(true); $this->setSelect($restrictionsSelect); $this->setNotice($I18N->msg('ctrl')); }
function enterObject(&$email_elements, &$sql_elements, &$warning, &$form_output, $send = 0) { global $REX, $I18N; // ---------- CONFIG & CHECK $this->be_em = array(); $this->be_em["source_table"] = $this->params["main_table"]; // "rex_em_data_" wegcutten $this->be_em["label"] = $this->elements[2]; // HTML Bezeichnung $this->be_em["target_table"] = $this->elements[3]; // Zieltabelle $this->be_em["target_field"] = $this->elements[4]; // Zielfield welches angezeigt wird. $this->be_em["relation_type"] = (int) $this->elements[5]; // select single = 0 / select multiple = 1 / popup single = 2 / popup multiple = 3 if ($this->be_em["relation_type"] > 4) { $this->be_em["relation_type"] = 0; } $this->be_em["eoption"] = (int) $this->elements[6]; // "Leer" Option $this->be_em["page"] = $this->elements[8]; // page=editme if ($this->be_em["page"] == "") { $this->be_em["page"] = 'editme'; } $this->be_em["subpage"] = $this->elements[9]; // page=editme if ($this->be_em["subpage"] == "") { $this->be_em["subpage"] = $this->be_em["target_table"]; } if ($this->be_em["eoption"] != 1) { $this->be_em["eoption"] = 0; } $disabled = FALSE; // ---------- Datensatz existiert bereits, Values aus verkn�pfungstabelle holen if ($this->params["main_id"] > 0 && $send == 0) { if (trim($this->getValue()) != "") { $values = explode(",", $this->getValue()); } else { $vs = rex_sql::factory(); $vs->debugsql = $this->params["debug"]; $vs->setQuery(' select target_id as id from rex_xform_relation where source_table="' . $this->be_em["source_table"] . '" and source_name="' . $this->getName() . '" and source_id="' . $this->params["main_id"] . '"'); $v = $vs->getArray(); $values = array(); if (count($v) > 0) { foreach ($v as $w) { $values[$w["id"]] = $w["id"]; } } } $this->setValue($values); // echo '<pre>++ ';var_dump($this->getValue());echo '</pre>'; } // ---------- connected, fix values if (isset($this->params["rex_xform_set"][$this->getName()])) { $values = $this->getValue(); $values[] = $this->params["rex_xform_set"][$this->getName()]; $this->setValue($values); $disabled = TRUE; } // ---------- Value angleichen -> immer Array mit IDs daraus machen if (!is_array($this->getValue())) { if (trim($this->getValue()) == "") { $this->setValue(array()); } else { $this->setValue(explode(",", $this->getValue())); } } // ---------- (array) $this->getValue() // ---------- check values $sql = 'select id,' . $this->be_em["target_field"] . ' from ' . $this->be_em["target_table"]; $value_names = array(); if (count($this->getValue()) > 0) { $add_sql = array(); foreach ($this->getValue() as $v) { $add_sql[] = ' id=' . $v . ''; } if (count($add_sql) > 0) { $sql .= ' where ' . implode(" OR ", $add_sql); } $values = array(); $vs = rex_sql::factory(); $sss->debugsql = $this->params["debug"]; $vs->setQuery($sql); foreach ($vs->getArray() as $v) { $value_names[$v["id"]] = $v[$this->be_em["target_field"]] . ' [id=' . $v['id'] . ']'; $values[] = $v["id"]; $value_name = $v[$this->be_em["target_field"]]; } $this->setValue($values); } // ------------------------------------ POPUP, single, multiple 1-1, n-m if ($this->be_em["relation_type"] == 2 || $this->be_em["relation_type"] == 3) { $multiple = "0"; if ($this->be_em["relation_type"] == 3) { $multiple = "1"; } $link = 'index.php?page=xform&subpage=manager&tripage=data_edit&table_name=' . $this->be_em["target_table"]; if ($multiple) { $out = ' <div class="rex-widget"> <div class="rex-widget-xform-manager-datalist"> <input type="hidden" name="FORM[' . $this->params["form_name"] . '][el_' . $this->getId() . ']" id="XFORM_MANAGER_DATALIST_' . $this->getId() . '" value="' . implode(",", $this->getValue()) . '" /> <p class="rex-widget-field"> <select name="XFORM_MANAGER_DATALIST_SELECT[' . $this->getId() . ']" id="XFORM_MANAGER_DATALIST_SELECT_' . $this->getId() . '" size="8">'; foreach ($value_names as $k => $v) { $out .= '<option value="' . $k . '">' . $v . '</option>'; } $out .= ' </select> </p> <p class="rex-widget-icons rex-widget-2col"> <span class="rex-widget-column rex-widget-column-first"> <a href="#" class="rex-icon-file-top" onclick="xform_manager_moveDatalist(' . $this->getId() . ',\'top\');return false;" title="' . $I18N->msg("xform_relation_move_first_data") . '"></a> <a href="#" class="rex-icon-file-up" onclick="xform_manager_moveDatalist(' . $this->getId() . ',\'up\');return false;" title="' . $I18N->msg("xform_relation_move_up_data") . '"></a> <a href="#" class="rex-icon-file-down" onclick="xform_manager_moveDatalist(' . $this->getId() . ',\'down\');return false;" title="' . $I18N->msg("xform_relation_down_first_data") . '"></a> <a href="#" class="rex-icon-file-bottom" onclick="xform_manager_moveDatalist(' . $this->getId() . ',\'bottom\');return false;" title="' . $I18N->msg("xform_relation_move_last_data") . '"></a> </span> <span class="rex-widget-column"> <a href="#" class="rex-icon-file-open" onclick="xform_manager_openDatalist(' . $this->getId() . ', \'' . $this->be_em["target_field"] . '\', \'' . $link . '\',\'' . $multiple . '\');return false;" title="' . $I18N->msg("xform_relation_choose_entry") . '"></a> <a href="#" class="rex-icon-file-delete" onclick="xform_manager_deleteDatalist(' . $this->getId() . ',\'' . $multiple . '\');return false;" title="' . $I18N->msg("xform_relation_delete_entry") . '"></a> </span> </p> </div> </div> <div class="rex-clearer"></div>'; } else { $out = ' <div class="rex-widget"> <div class="rex-widget-data"> <p class="rex-widget-field"> <input type="hidden" name="FORM[' . $this->params["form_name"] . '][el_' . $this->getId() . ']" id="XFORM_MANAGER_DATA_' . $this->getId() . '" value="' . implode(",", $this->getValue()) . '" /> <input type="text" size="30" name="XFORM_MANAGER_DATANAME[' . $this->getId() . ']" value="' . htmlspecialchars($value_name) . '" id="XFORM_MANAGER_DATANAME_' . $this->getId() . '" readonly="readonly" class="text" /> </p> <p class="rex-widget-icons rex-widget-1col"> <span class="rex-widget-column rex-widget-column-first"> <a href="#" class="rex-icon-file-open" onclick="xform_manager_openDatalist(' . $this->getId() . ', \'' . $this->be_em["target_field"] . '\', \'' . $link . '\',\'' . $multiple . '\');return false;" title="' . $I18N->msg("xform_relation_choose_entry") . '"></a> <a href="#" class="rex-icon-file-delete" onclick="xform_manager_deleteDatalist(' . $this->getId() . ',\'' . $multiple . '\');return false;" title="' . $I18N->msg("xform_relation_delete_entry") . '"></a> </span> </p> </div> </div> <div class="rex-clearer"></div> '; } $form_output[] = ' <p class="formpopup" id="' . $this->getHTMLId() . '"> <label class="select ' . $wc . '" for="el_' . $this->id . '" >' . $this->be_em["label"] . '</label> ' . $out . ' </p>'; } // --------------------------------------- POPUP, 1-n if ($this->be_em["relation_type"] == 4) { $text = 'not yet implemented'; // TODO /* if($this->params["main_id"] < 1) { $text = 'Diesen Bereich können Sie erst bearbeiten, wenn der Datensatz angelegt wurde.'; }else { $link = 'javascript:rex_xform_openRelation('.$this->getId().',\''.$this->be_em["target_table"].'\',\'id'. '&rex_em_filter['.$this->be_em["target_field"].']='.$this->params["main_id"]. '&rex_em_set['.$this->be_em["target_field"].']='.$this->params["main_id"]. '&page='.$this->be_em["page"]. '&subpage='.$this->be_em["subpage"]. '\');'; $text = '<a href="'.$link.'">'. 'Link'. '</a>'; } */ $form_output[] = ' <p class="formhtml" id="' . $this->getHTMLId() . '"> <label class="select " for="el_' . $this->getId() . '" >' . $this->be_em["label"] . '</label> <input type="hidden" name="FORM[' . $this->params["form_name"] . '][el_' . $this->getId() . '][]" id="REX_RELATION_' . $this->getId() . '" /> <span>' . $text . '</span> </p>'; return; } // --------------------------------------- Selectbox, single or multiple if ($this->be_em["relation_type"] < 2) { if ($send == 1 && $this->be_em["eoption"] == 0 && count($this->getValue()) == 0) { // Error. Fehlermeldung ausgeben $this->params["warning"][] = $this->elements[7]; $this->params["warning_messages"][] = $this->elements[7]; $wc = $this->params["error_class"]; } $wc = ""; if (isset($warning[$this->getId()])) { $wc = $warning[$this->getId()]; } // ----- SELECT BOX $sss = rex_sql::factory(); $sss->debugsql = $this->params["debug"]; $sss->setQuery('select * from ' . $this->be_em["target_table"] . ' order by ' . $this->be_em["target_field"]); $SEL = new rex_select(); $SEL->setName('FORM[' . $this->params["form_name"] . '][el_' . $this->id . '][]'); $SEL->setId("el_" . $this->id); $SEL->setStyle('class="select"'); $SEL->setDisabled($disabled); $SEL->setSize(1); // mit --- keine auswahl --- if ($this->be_em["relation_type"] == 1) { $SEL->setMultiple(TRUE); $SEL->setSize(5); } elseif ($this->be_em["eoption"] == 1) { $SEL->addOption("-", ""); } foreach ($sss->getArray() as $v) { $s = $v[$this->be_em["target_field"]]; if (strlen($s) > 50) { $s = substr($s, 0, 45) . ' ... '; } $s = $s . ' [id=' . $v["id"] . ']'; $SEL->addOption($s, $v["id"]); } // var_dump($this->getValue()); $SEL->setSelected($this->getValue()); $form_output[] = ' <p class="formselect" id="' . $this->getHTMLId() . '"> <label class="select ' . $wc . '" for="el_' . $this->id . '" >' . $this->be_em["label"] . '</label> ' . $SEL->get() . ' </p>'; } // --------------------------------------- save $email_elements[$this->getName()] = stripslashes(implode(",", $this->getValue())); $sql_elements[$this->getName()] = implode(",", $this->getValue()); }
function enterObject(&$email_elements, &$sql_elements, &$warning, &$form_output, $send = 0) { global $REX; // $this->params["debug"] = TRUE; // ---------- CONFIG & CHECK $this->be_em = array(); $this->be_em["source_table"] = $this->params["main_table"]; // "rex_em_data_" wegcutten $this->be_em["label"] = $this->elements[2]; // HTML Bezeichnung $this->be_em["target_table"] = $this->elements[3]; // Zieltabelle $this->be_em["target_field"] = $this->elements[4]; // Zielfield welches angezeigt wird. $this->be_em["relation_type"] = (int) $this->elements[5]; // single = 0 / multiple = 1 / popup = 2 if ($this->be_em["relation_type"] > 2) { $this->be_em["relation_type"] = 0; } $this->be_em["eoption"] = (int) $this->elements[6]; // "Leer" Option $this->be_em["page"] = $this->elements[8]; // page=editme if ($this->be_em["page"] == "") { $this->be_em["page"] = 'editme'; } $this->be_em["subpage"] = $this->elements[9]; // page=editme if ($this->be_em["subpage"] == "") { $this->be_em["subpage"] = $this->be_em["target_table"]; } if ($this->be_em["eoption"] != 1) { $this->be_em["eoption"] = 0; } $disabled = FALSE; if ($this->be_em["relation_type"] == 2) { if ($this->params["main_id"] < 1) { $text = 'Diesen Bereich können Sie erst bearbeiten, wenn der Datensatz angelegt wurde.'; } else { $link = 'javascript:rex_xform_openRelation(' . $this->getId() . ',\'' . $this->be_em["target_table"] . '\',\'id' . '&rex_em_filter[' . $this->be_em["target_field"] . ']=' . $this->params["main_id"] . '&rex_em_set[' . $this->be_em["target_field"] . ']=' . $this->params["main_id"] . '&page=' . $this->be_em["page"] . '&subpage=' . $this->be_em["subpage"] . '\');'; $text = '<a href="' . $link . '">' . 'Link' . '</a>'; } $form_output[] = ' <p class="formhtml"> <label class="select " for="el_' . $this->getId() . '" >' . $this->be_em["label"] . '</label> <input type="hidden" name="FORM[' . $this->params["form_name"] . '][el_' . $this->getId() . '][]" id="REX_RELATION_' . $this->getId() . '" /> <span>' . $text . '</span> </p>'; return; } // ---------- Datensatz existiert bereits, Values aus verknŸpfungstabelle holen if ($this->params["main_id"] > 0 && $send == 0) { $vs = rex_sql::factory(); $sss->debugsql = $this->params["debug"]; $vs->setQuery('select target_id as id from rex_' . $this->params["manager_type"] . '_relation where source_table="' . $this->be_em["source_table"] . '" and source_name="' . $this->getName() . '" and source_id="' . $this->params["main_id"] . '"'); $v = $vs->getArray(); $values = array(); if (count($v) > 0) { foreach ($v as $w) { $values[$w["id"]] = $w["id"]; } } // Fallback - wenn nichts da, dann vielleicht im Datensatz selbst. // Nur nštig wenn man Daten aus anderen Tabellen importiert hat und // man die Datenstruktur angleichen mšchte. if (trim($this->getValue()) != "") { $values = array_merge($values, explode(",", $this->getValue())); } // Neue Daten speichern $this->setValue($values); } // ---------- Fertigsets einbauen. Sind quasi fest eingebrannte Werte if (isset($this->params["rex_em_set"][$this->getName()])) { $values = $this->getValue(); $values[] = $this->params["rex_em_set"][$this->getName()]; $this->setValue($values); $disabled = TRUE; } // ---------- Value angleichen -> immer Array mit IDs daraus machen if (!is_array($this->getValue())) { if (trim($this->getValue()) == "") { $this->setValue(array()); } else { $this->setValue(explode(",", $this->getValue())); } } // Ab hier ist Value immer Array // Values prŸfen $sql = 'select id,' . $this->be_em["target_field"] . ' from ' . $this->be_em["target_table"]; $value_names = array(); if (count($this->getValue()) > 0) { $addsql = ''; foreach ($this->getValue() as $v) { if ($addsql != "") { $addsql .= ' OR '; } $addsql .= ' id=' . $v . ''; } if ($addsql != "") { $sql .= ' where ' . $addsql; } $values = array(); $vs = rex_sql::factory(); $sss->debugsql = $this->params["debug"]; $vs->setQuery($sql); foreach ($vs->getArray() as $v) { $value_names[$v["id"]] = $v[$this->be_em["target_field"]]; $values[] = $v["id"]; } $this->setValue($values); } if ($send == 1 && $this->be_em["eoption"] == 0 && count($this->getValue()) == 0) { // Error. Fehlermeldung ausgeben $this->params["warning"][] = $this->elements[7]; $this->params["warning_messages"][] = $this->elements[7]; $wc = $this->params["error_class"]; } $wc = ""; if (isset($warning["el_" . $this->getId()])) { $wc = $warning["el_" . $this->getId()]; } // ----- SELECT BOX $sss = rex_sql::factory(); $sss->debugsql = $this->params["debug"]; $sss->setQuery('select * from ' . $this->be_em["target_table"] . ' order by ' . $this->be_em["target_field"]); $SEL = new rex_select(); $SEL->setName('FORM[' . $this->params["form_name"] . '][el_' . $this->id . '][]'); $SEL->setId("el_" . $this->id); $SEL->setDisabled($disabled); $SEL->setSize(1); // mit --- keine auswahl --- if ($this->be_em["relation_type"] == 1) { $SEL->setMultiple(TRUE); $SEL->setSize(5); } elseif ($this->be_em["eoption"] == 1) { $SEL->addOption("-", ""); } foreach ($sss->getArray() as $v) { $SEL->addOption($v[$this->be_em["target_field"]], $v["id"]); } // var_dump($this->getValue()); $SEL->setSelected($this->getValue()); $form_output[] = ' <p class="formselect"> <label class="select ' . $wc . '" for="el_' . $this->id . '" >' . $this->be_em["label"] . '</label> ' . $SEL->get() . ' </p>'; $email_elements[$this->getName()] = stripslashes(implode(",", $this->getValue())); $sql_elements[$this->getName()] = implode(",", $this->getValue()); return; }
function rex_version_header($params) { global $REX, $I18N; $return = ""; $rex_version_article = $REX['LOGIN']->getSessionVar("rex_version_article"); if (!is_array($rex_version_article)) { $rex_version_article = array(); } $working_version_empty = TRUE; $gw = rex_sql::factory(); $gw->setQuery('select * from ' . $REX['TABLE_PREFIX'] . 'article_slice where article_id=' . $params['article_id'] . ' and clang=' . $params['clang'] . ' and revision=1 LIMIT 1'); if ($gw->getRows() > 0) { $working_version_empty = FALSE; } $revisions = array(); $revisions[0] = $I18N->msg("version_liveversion"); $revisions[1] = $I18N->msg("version_workingversion"); $version_id = rex_request("rex_set_version", "int", "-1"); if ($version_id === 0) { $rex_version_article[$params['article_id']] = 0; } elseif ($version_id == 1) { $rex_version_article[$params['article_id']] = 1; } elseif (!isset($rex_version_article[$params['article_id']])) { $rex_version_article[$params['article_id']] = 1; } $func = rex_request("rex_version_func", "string"); switch ($func) { case "copy_work_to_live": if ($working_version_empty) { $return .= rex_warning($I18N->msg("version_warning_working_version_to_live")); } else { if (!$REX['USER']->hasPerm('version[only_working_version]')) { require $REX['INCLUDE_PATH'] . '/addons/version/functions/function_rex_copyrevisioncontent.inc.php'; // rex_copyRevisionContent($article_id,$clang,$from_revision_id, $to_revision_id, $gc->getValue("id"),$delete_to_revision); rex_copyRevisionContent($params['article_id'], $params['clang'], 1, 0, 0, TRUE); $return .= rex_info($I18N->msg("version_info_working_version_to_live")); } } break; case "copy_live_to_work": require $REX['INCLUDE_PATH'] . '/addons/version/functions/function_rex_copyrevisioncontent.inc.php'; // rex_copyRevisionContent($article_id,$clang,$from_revision_id, $to_revision_id, $gc->getValue("id"),$delete_to_revision); rex_copyRevisionContent($params['article_id'], $params['clang'], 0, 1, 0, TRUE); $return .= rex_info($I18N->msg("version_info_live_version_to_working")); break; } if ($REX['USER']->hasPerm('version[only_working_version]')) { $rex_version_article[$params['article_id']] = 1; unset($revisions[0]); } $REX['LOGIN']->setSessionVar("rex_version_article", $rex_version_article); $link = 'index.php?page=' . $params['page'] . '&article_id=' . $params['article_id'] . '&clang=' . $params['clang']; $return .= ' <div id="rex-version-header" class="rex-toolbar rex-toolbar-has-form rex-version-revision-' . $rex_version_article[$params['article_id']] . '"> <div class="rex-toolbar-content rex-version-header"> <form action="index.php" method="post"> <fieldset> <input type="hidden" name="page" value="' . $params['page'] . '" /> <input type="hidden" name="mode" value="' . $params['mode'] . '" /> <input type="hidden" name="article_id" value="' . $params['article_id'] . '" /> <input type="hidden" name="clang" value="' . $params['clang'] . '" /> <input type="hidden" name="ctype" value="' . $params['ctype'] . '" /> '; $s = new rex_select(); foreach ($revisions as $k => $r) { $s->addOption($r, $k); } $s->setSelected($rex_version_article[$params['article_id']]); $s->setName('rex_set_version'); $s->setId('rex-select-version-id'); $s->setSize('1'); $s->setAttribute('onchange', 'this.form.submit();'); if ($REX['USER']->hasPerm('version[only_working_version]')) { $s->setDisabled(); } $return .= '<ul class="rex-display-inline">'; $return .= '<li class="rex-navi-first"><label for="rex-select-version-id">' . $I18N->msg('version') . ':</label> ' . $s->get() . '</li>'; if ($REX['USER']->hasPerm('version[only_working_version]')) { if ($rex_version_article[$params['article_id']] > 0) { $return .= '<li><a href="' . $link . '&rex_version_func=copy_live_to_work">' . $I18N->msg('version_copy_from_liveversion') . '</a></li>'; $return .= '<li><a href="/' . rex_getUrl($params['article_id'], $params['clang'], array("rex_version" => 1)) . '" target="_blank">' . $I18N->msg("version_preview") . '</a></li>'; } } else { if ($rex_version_article[$params['article_id']] > 0) { if (!$working_version_empty) { $return .= '<li><a href="' . $link . '&rex_version_func=copy_work_to_live">' . $I18N->msg('version_working_to_live') . '</a></li>'; } $return .= '<li><a href="../' . rex_getUrl($params['article_id'], $params['clang'], array("rex_version" => 1)) . '" target="_blank">' . $I18N->msg("version_preview") . '</a></li>'; } else { $return .= '<li><a href="' . $link . '&rex_version_func=copy_live_to_work" onclick="return confirm(\'' . $I18N->msg('version_confirm_copy_live_to_workingversion') . '\');">' . $I18N->msg('version_copy_live_to_workingversion') . '</a></li>'; } } $return .= '</ul>'; $return .= ' <noscript> <input type="submit" /> </noscript> </fieldset> </form> </div> <div class="rex-clearer"></div> <style type="text/css"> /* <![CDATA[ */ #rex-version-header label { font-weight: bold; } #rex-version-header li { margin-right: 15px; } div.rex-version-revision-0 { background-color:#bbddaa; } div.rex-version-revision-1 { background-color:#EFECD1; } /* ]]> */ </style> </div> '; $params['slice_revision'] = $rex_version_article[$params['article_id']]; return $return; }