, Suchi & Berg GmbH * @access public * @modulegroup extern * @module ExternEditModule * @package studip_extern */ use Studip\Button, Studip\LinkButton; // +---------------------------------------------------------------------------+ // This file is part of Stud.IP // ExternEditModule.class.php // // Copyright (C) 2003 Peter Thienel , // Suchi & Berg GmbH // +---------------------------------------------------------------------------+ // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or any later version. // +---------------------------------------------------------------------------+ // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // +---------------------------------------------------------------------------+ require_once "lib/extern/views/ExternEditHtml.class.php"; class ExternEditModule extends ExternEditHtml { function __construct (&$config, $form_values = "", $faulty_values = "", $edit_element = "") { parent::__construct($config, $form_values, $faulty_values, $edit_element); } function editMainSettings ($field_names, $hide_fields = "", $hide = "") { // these two values are always necessary, even there is an error in the users inputs, so // there arent transfered via $_POST $this->form_values[$this->element_name . "_order"] = $this->config->getValue($this->element_name, "order"); $this->form_values[$this->element_name . "_visible"] = $this->config->getValue($this->element_name, "visible"); $order = $this->getValue("order"); $aliases = $this->getValue("aliases"); $visible = $this->getValue("visible"); $widths = $this->getValue("width"); $sort = $this->getValue("sort"); if (!is_array($hide_fields["sort"])) $hide_fields["sort"] = []; if (!is_array($hide_fields["aliases"])) $hide_fields["aliases"] = []; if (!is_array($hide)) $hide = []; $out = "\n"; $out .= "\n"; $out .= "\n"; if (!in_array('aliases', $hide)) $out .= "\n"; if (!in_array("width", $hide)) $out .= "\n"; if (!in_array("sort", $hide)) $out .= "\n"; if (!in_array("visible", $hide)) $out .= "\n"; $out .= "\n"; if (is_array($field_names)) { for ($i = 0; $i < count($field_names); $i++) { // name of column $out .= "\n"; $out .= ''; // column headline if (!in_array('aliases', $hide)) { if (!in_array($order[$i], $hide_fields["aliases"])) { $out .= "\n"; } else { $out .= "\n"; $out .= "element_name}_aliases[$order[$i]]\" "; $out .= "value=\"\">"; } } // width if (!in_array("width", $hide)) { $width = str_replace("%", "", $widths[$order[$i]]); $out .= "\n"; } // sort if (!in_array("sort", $hide)) { if (!in_array($order[$i], $hide_fields["sort"])) { $out .= "\n"; } else { $out .= "\n"; $out .= "element_name}_sort[$order[$i]]\" "; $out .= "value=\"0\">\n"; } } if (!in_array("visible", $hide)) { // move left $out .= "\n"; } } } } // width in pixels or percent if (!in_array("widthpp", $hide) && !in_array('width', $hide)) { $colspan = 4 - count($hide); $title = _("Breite in:"); $info = _("Wählen Sie hier, ob die Breiten der Tabellenspalten als Prozentwerte oder Pixel interpretiert werden sollen."); $width_values = ["%", ""]; $width_names = [_("Prozent"), _("Pixel")]; $out .= "\n"; $out .= ""; $out .= "
" . _("Datenfeld") . "" . _("Überschrift") . "" . _("Breite") . "" . _("Sortierung") . "" . _("Reihenfolge/
Sichtbarkeit") . "
 ' . htmlReady($field_names[$order[$i]]) . 'element_name}_aliases[$order[$i]]\""; $out .= "\" size=\"12\" maxlength=\"50\" value=\""; $out .= $aliases[$order[$i]] . "\">"; if ($this->faulty_values[$this->element_name . "_aliases"][$order[$i]]) $out .= $this->error_sign; $out .= " element_name}_width[$order[$i]]"; $out .= "\" size=\"3\" maxlength=\"3\" value=\"$width\">"; if ($this->faulty_values[$this->element_name . "_width"][$order[$i]]) $out .= $this->error_sign; $out .= "\n "; $out .= Icon::create('arr_2up', 'sort', ['title' => _('Datenfeld verschieben')])->asInput(["type" => "image", "class" => "middle", "name" => $this->element_name . "_move_left[" . $i . "]"]); // move right $out .= "\n"; $out .= Icon::create('arr_2down', 'sort', ['title' => _('Datenfeld verschieben')])->asInput(["type" => "image", "class" => "middle", "name" => $this->element_name . "_move_right[" . $i . "]"]); // visible if ($visible[$order[$i]]) { $out .= "\n"; $out .= Icon::create('checkbox-checked', 'clickable', ['title' => _('Datenfeld ausblenden')])->asInput(["type" => "image", "class" => "middle", "name" => $this->element_name . "_hide[" . $order[$i] . "]"]); } else { $out .= "\n"; $out .= Icon::create('checkbox-unchecked', 'clickable', ['title' => _('Datenfeld einblenden')])->asInput(["type" => "image", "class" => "middle", "name" => $this->element_name . "_show[" . $order[$i] . "]"]); $out .= "
 $titleelement_name}_widthpp\" value=\"%\""; if (mb_substr($widths[0], -1) == "%") $out .= " checked=\"checked\""; $out .= ">" . _("Prozent") . "   getValue("sort"); $out = "\n"; $out .= "\n"; $out .= "\n"; $out .= "\n"; if ($field_names) { for ($i = 0; $i < count($field_names); $i++) { $out .= "\n"; $out .= ""; if (!in_array($i, $hide_fields["sort"])) { $out .= "\n"; } else { $out .= "\n"; $out .= "element_name}_sort[$i]\" "; $out .= "value=\"0\">\n"; } } } $out .= "
" . _("Datenfeld") . "" . _("Sortierung") . "
 {$field_names[$i]}\n 
\n"; return $out; } function editName ($attribute) { $info = _("Geben Sie den Namen der Konfiguration an."); return $this->editTextfieldGeneric($attribute, "", $info, 40, 40); } function editGroups () { $groups_db = get_all_statusgruppen($this->config->range_id); if (!$groups_db) return FALSE; $title = _("Gruppen auswählen:"); $info = _("Wählen Sie die Statusgruppen aus, die ausgegeben werden sollen."); $groups_config = $this->getValue("groups"); // this value is always necessary, even there is an error in the users inputs, so // it isn't transfered via $_POST $this->form_values[$this->element_name . "_groupsvisible"] = $this->config->getValue($this->element_name, "groupsvisible"); // initialize groups if this value isn't set in the config file if (!$groups_config) { $groups_config = array_keys($groups_db); } $groups_aliases = $this->getValue("groupsalias"); $groups_visible = $this->getValue("groupsvisible"); if (!is_array($groups_visible)) $groups_visible = []; if (!is_array($groups_aliases)) $groups_aliases = []; if (count(array_intersect(array_keys($groups_aliases), array_keys($groups_db)))) { foreach ($groups_config as $group_config) { $groups[$group_config] = $groups_aliases[$group_config]; } } else { if (is_array($groups_config)) { for ($i = 0; $i < count($groups_config); $i++) { $groups[$groups_config[$i]] = $groups_aliases[$i]; } } } $out = "\n"; $out .= "\n"; $out .= "\n"; $out .= "\n"; $out .= "\n"; $out .= "\n"; $out .= "\n"; $i = 0; foreach ($groups_db as $id => $name) { // name of group $out .= "\n"; $out .= ""; // column headline $out .= '\n"; // visible $out .= '
" . _("Gruppenname") . "" . _("alternativer Gruppenname") . "" . _("Sichtbarkeit") . " 
 " . htmlReady($name) . ""; if ($this->faulty_values[$this->element_name . "_groupsalias"][$id]) $out .= $this->error_sign; $out .= "' . '' . 'form_values[$this->element_name . "_order"] = $this->config->getValue($this->element_name, "order"); $order = $this->getValue("order"); $this->form_values[$this->element_name . '_visibility'] = $this->config->getValue($this->element_name, 'visibility'); $visibility = $this->getValue('visibility'); // compat <1.3: new attribute visibility (all SemTypes are visible) if (!is_array($visibility) || !count($visibility)) { $visibility = array_fill(0, count($order), 1); } if (!is_array($order)) { $order = array_keys($SEM_TYPE); } $out = "\n"; $out .= "\n"; $out .= "\n"; $out .= "\n"; $out .= "\n"; $out .= "\n"; $out .= "\n"; foreach ($SEM_CLASS as $class_index => $foo) { $i = 0; foreach ($SEM_TYPE as $type_index => $type) { if ($type["class"] == $class_index) { $mapping[$type_index] = $i++; } } $classes[$class_index] = $this->getValue("class_$class_index"); } if(is_array($order)) { for ($i = 0; $i < count($order); $i++) { if ($SEM_TYPE[$order[$i]]) { $new_order[] = $order[$i]; // name of column $out .= "\n"; $out .= ""; // column headline $out .= "\n"; // move up $out .= "\n"; // visibility $out .= "\n\n"; } } } $out .= "
" . _("Datenfeld") . "" . _("Überschrift") . "" . _("Reihenfolge") . "" . _("Sichtbarkeit") . "
 "; if (mb_strlen($SEM_TYPE[$order[$i]]["name"]) > 25) { $out .= htmlReady(mb_substr($SEM_TYPE[$order[$i]]["name"], 0, 22) . "... ({$SEM_CLASS[$SEM_TYPE[$order[$i]]['class']]['name']})"); } else { $out .= htmlReady($SEM_TYPE[$order[$i]]["name"] . " ({$SEM_CLASS[$SEM_TYPE[$order[$i]]['class']]['name']})"); } $out .= "element_name}_class_"; $out .= $SEM_TYPE[$order[$i]]['class'] . "[{$mapping[$order[$i]]}]\""; $out .= "\" size=\"20\" maxlength=\"100\" value=\""; if (isset($classes[$SEM_TYPE[$order[$i]]['class']][$mapping[$order[$i]]])) { $out .= $classes[$SEM_TYPE[$order[$i]]['class']][$mapping[$order[$i]]] . "\">"; } else { $out .= $SEM_TYPE[$order[$i]]["name"] . " ({$SEM_CLASS[$SEM_TYPE[$order[$i]]['class']]['name']})\">"; } if ($this->faulty_values[$this->element_name . "_class_{$SEM_TYPE[$order[$i]]['class']}"][$mapping[$order[$i]]]) { $out .= $this->error_sign; } $out .= ""; $out .= Icon::create('arr_2up', Icon::ROLE_SORT, ['title' => _('Datenfeld verschieben')]) ->asInput(['name'=>$this->element_name.'_move_left['.$i.']','align'=>'middle',]); // move down $out .= Icon::create('arr_2down', Icon::ROLE_SORT, ['title' => _('Datenfeld verschieben')]) ->asInput(['name'=>$this->element_name.'_move_right['.$i.']','align'=>'middle',]); $out .= ""; $out .= "element_name}_visibility"; $out .= '[' . ($order[$i] - 1) . "]\" value=\"1\""; if ($visibility[$order[$i] - 1] == 1) { $out .= ' checked="checked"'; } $out .= '>'; $out .= "
\n"; $out .= "\n"; // update order if (count(array_diff($order, $new_order))) { $this->config->setValue($this->element_name, 'order', $new_order); $this->config->store(); } return $out; } function editSelectSubjectAreas ($selector) { $info = _("Wählen Sie die Studienbereiche aus, deren Veranstaltungen angezeigt werden sollen."); $info2 = _("Sie können beliebig viele Studienbereiche auswählen."); $form_name = $this->element_name . "_" . 'subjectareasselected'; if ($this->faulty_values[$form_name][0]) { $error_sign = $this->error_sign; } else { $error_sign = ''; } $selected = $this->config->getValue($this->element_name, 'subjectareasselected'); $selector->selected = []; $selector->sem_tree_ranges = []; $selector->sem_tree_ids = []; if (is_array($selected) && count($selected)) { foreach ($selected as $selected_id) { $selector->selected[$selected_id] = TRUE; $selector->sem_tree_ranges[$selector->tree->tree_data[$selected_id]['parent_id']][] = $selected_id; $selector->sem_tree_ids[] = $selected_id; } } $form_name_tmp = $selector->form_name; $selector->form_name = 'SelectSubjectAreas'; $selector->doSearch(); $out = "\n"; $out .= ''; $selector->form_name = $form_name_tmp; $out .= '
' . _("Suche") . ': '; $out .= $selector->getSearchField(['size' => 30 ,'style' => 'vertical-align:middle;']); $out .= $selector->getSearchButton(['style' => 'vertical-align:middle;']); $out .= '
(' . sprintf(_("Geben Sie '%s' ein, um alle Studienbereiche zu finden."), '%%%') . ')'; if ($selector->num_search_result !== false){ $out .= "
  " . sprintf(_("Ihre Suche ergab %s Treffer."),$selector->num_search_result) . (($selector->num_search_result) ? _(" (Suchergebnisse werden blau angezeigt)") : '') . ''; } $out .= '
'; $out .= $selector->getChooserField(['style' => 'width:98%;','size' => 15], 70, 'subjectareasselected'); $out .= ''; $out .= tooltipIcon($info); $out .= "$error_sign"; $out .= "
\n"; return $out; } function editMarkerDescription ($markers, $new_datafields = FALSE) { $out = "\n"; $out .= "\n"; $out .= '\n"; $out .= '\n"; $out .= "\n"; $spacer = 0; $global_vars = FALSE; foreach ((array) $markers as $marker) { $mark = $marker[0]; $description = $marker[1]; if ($mark == '__GLOBAL__') { $out .= "\n"; $out .= ''; $spacer++; $global_vars = true; } else if ($mark[0] == '<') { if ($global_vars) { $out .= "\n"; $out .= ''; $spacer--; $global_vars = false; } if (mb_substr($mark, 0, 8) == '
' . _("Marker") . "' . _("Beschreibung") . "
' . _('Globale Variablen') . '