From 3fd65bd364d91012498ec95e2f52cdf1e6254ba3 Mon Sep 17 00:00:00 2001 From: hickert Date: Wed, 20 Apr 2011 15:32:03 +0000 Subject: [PATCH] Updated widgets to allow disabling items git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20760 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../TemplateWidget_textEditor.tpl | 12 +++++++++++ .../TemplateEngine/class_TemplateEngine.inc | 20 +++++++++++++++++++ .../TemplateEngine/class_TemplateWidget.inc | 9 +++++++++ .../class_TemplateWidget_checkbox.inc | 3 ++- .../class_TemplateWidget_combobox.inc | 3 ++- .../class_TemplateWidget_file.inc | 8 +++++--- .../class_TemplateWidget_fixedList.inc | 6 ++++-- .../class_TemplateWidget_list.inc | 7 +++++-- .../class_TemplateWidget_string.inc | 7 ++++--- .../class_TemplateWidget_textEditor.inc | 1 + .../class_TemplateWidget_textarea.inc | 4 +++- 11 files changed, 67 insertions(+), 13 deletions(-) create mode 100644 gosa-plugins/goto-ng/admin/newConfigManagement/TemplateEngine/TemplateWidget_textEditor.tpl diff --git a/gosa-plugins/goto-ng/admin/newConfigManagement/TemplateEngine/TemplateWidget_textEditor.tpl b/gosa-plugins/goto-ng/admin/newConfigManagement/TemplateEngine/TemplateWidget_textEditor.tpl new file mode 100644 index 000000000..02c573890 --- /dev/null +++ b/gosa-plugins/goto-ng/admin/newConfigManagement/TemplateEngine/TemplateWidget_textEditor.tpl @@ -0,0 +1,12 @@ +{if $write_protect} + {t}The text is write protected due to its encoding. Editing may break it!{/t} +
+ +{/if} + +
+   + +
diff --git a/gosa-plugins/goto-ng/admin/newConfigManagement/TemplateEngine/class_TemplateEngine.inc b/gosa-plugins/goto-ng/admin/newConfigManagement/TemplateEngine/class_TemplateEngine.inc index fd9617c60..e81fe3eb2 100644 --- a/gosa-plugins/goto-ng/admin/newConfigManagement/TemplateEngine/class_TemplateEngine.inc +++ b/gosa-plugins/goto-ng/admin/newConfigManagement/TemplateEngine/class_TemplateEngine.inc @@ -56,7 +56,21 @@ class TemplateEngine { return($this->itemType); } + + function editItem($type, $values) + { + $this->is_new = FALSE; + $this->setValues($type, $values); + } + + + function createItem($type, $values) + { + $this->is_new = TRUE; + $this->setValues($type, $values); + } + /*! \brief Sets the current item type we want to render * E.g. 'KickstartTemplate' and the corresponding values. @@ -104,6 +118,12 @@ class TemplateEngine $item['type'], $item['display'], $providedValues); + + // Check if we've to disable this item. + if(isset($item['disable']) && $item['disable'] || + isset($item['initiallyEditableOnly']) && $item['initiallyEditableOnly']){ + $this->widgets[$name]->setEnabled(FALSE); + } } } } diff --git a/gosa-plugins/goto-ng/admin/newConfigManagement/TemplateEngine/class_TemplateWidget.inc b/gosa-plugins/goto-ng/admin/newConfigManagement/TemplateEngine/class_TemplateWidget.inc index 45f4fae03..190d9c7ee 100644 --- a/gosa-plugins/goto-ng/admin/newConfigManagement/TemplateEngine/class_TemplateWidget.inc +++ b/gosa-plugins/goto-ng/admin/newConfigManagement/TemplateEngine/class_TemplateWidget.inc @@ -14,6 +14,7 @@ class TemplateWidget protected $display = ""; protected $syntax = ""; protected $values = ""; + protected $enabled = TRUE; /*! \brief Constructs the template widget and sets the default values. * @param Config The GOsa configuration object. @@ -40,6 +41,14 @@ class TemplateWidget } + /*! \brief Enabled or disabled the widget. + */ + function setEnabled($bool = TRUE) + { + $this->enabled = $bool; + } + + /*! \brief Returns the display-name for the current widget. * @return String The display-name for the widget, this * name will usually be rendered infront of input fields. diff --git a/gosa-plugins/goto-ng/admin/newConfigManagement/TemplateEngine/class_TemplateWidget_checkbox.inc b/gosa-plugins/goto-ng/admin/newConfigManagement/TemplateEngine/class_TemplateWidget_checkbox.inc index cd6cb1b0f..43318395e 100644 --- a/gosa-plugins/goto-ng/admin/newConfigManagement/TemplateEngine/class_TemplateWidget_checkbox.inc +++ b/gosa-plugins/goto-ng/admin/newConfigManagement/TemplateEngine/class_TemplateWidget_checkbox.inc @@ -5,7 +5,8 @@ class TemplateWidget_checkbox extends TemplateWidget function render() { $str = ""; - $str .= "enabled)? "disabled" : ""; + $str .= "value) $str .= " checked "; $str .= ">"; return($str); diff --git a/gosa-plugins/goto-ng/admin/newConfigManagement/TemplateEngine/class_TemplateWidget_combobox.inc b/gosa-plugins/goto-ng/admin/newConfigManagement/TemplateEngine/class_TemplateWidget_combobox.inc index d0a306926..e1b4ecdb4 100644 --- a/gosa-plugins/goto-ng/admin/newConfigManagement/TemplateEngine/class_TemplateWidget_combobox.inc +++ b/gosa-plugins/goto-ng/admin/newConfigManagement/TemplateEngine/class_TemplateWidget_combobox.inc @@ -7,7 +7,8 @@ class TemplateWidget_combobox extends TemplateWidget $str = ""; // Build up list data - $str .= ""; foreach($this->values as $name => $value){ if($name == $this->value){ $str .= "\n"; diff --git a/gosa-plugins/goto-ng/admin/newConfigManagement/TemplateEngine/class_TemplateWidget_file.inc b/gosa-plugins/goto-ng/admin/newConfigManagement/TemplateEngine/class_TemplateWidget_file.inc index d73f64641..197d6453a 100644 --- a/gosa-plugins/goto-ng/admin/newConfigManagement/TemplateEngine/class_TemplateWidget_file.inc +++ b/gosa-plugins/goto-ng/admin/newConfigManagement/TemplateEngine/class_TemplateWidget_file.inc @@ -29,20 +29,22 @@ class TemplateWidget_file extends TemplateWidget function render() { - $title = set_post($this->description); + $title = set_post($this->description); + $disabled = (!$this->enabled) ? 'disalbed' : ''; if(mb_strlen($this->value) == 0){ $ret = ""._("No file uploaded yet").""; $ret.= "
postName}\" name=\"{$this->postName}\" + {$disabled} type=\"file\" size=\"20\" maxlength=\"255\" accept=\"*.*\"> "; - $ret.= ""; + $ret.= ""; }else{ $ret = ""._("File uploaded").": ".mb_strlen($this->value)." "._("Bytes"); - $ret.= " "; + $ret.= " "; } return($ret); } diff --git a/gosa-plugins/goto-ng/admin/newConfigManagement/TemplateEngine/class_TemplateWidget_fixedList.inc b/gosa-plugins/goto-ng/admin/newConfigManagement/TemplateEngine/class_TemplateWidget_fixedList.inc index 0f9809728..8e227e218 100644 --- a/gosa-plugins/goto-ng/admin/newConfigManagement/TemplateEngine/class_TemplateWidget_fixedList.inc +++ b/gosa-plugins/goto-ng/admin/newConfigManagement/TemplateEngine/class_TemplateWidget_fixedList.inc @@ -33,6 +33,8 @@ class TemplateWidget_fixedList extends TemplateWidget $str = ""; // Build up list data + $this->listWidget->setDeleteable($this->enabled); + $disabled = (!$this->enabled)? "disabled" : ""; $data = $this->value; foreach($this->value as $key => $name){ $lData[$key] = array('data' => array($this->values[$name])); @@ -40,12 +42,12 @@ class TemplateWidget_fixedList extends TemplateWidget $this->listWidget->setListData($data, $lData); $this->listWidget->update(); $str .= $this->listWidget->render(); - $str .= ""; foreach($this->getAvailableOptions() as $name => $value){ $str .= "\n"; } $str .= ""; - $str .= ""; + $str .= ""; return($str); } diff --git a/gosa-plugins/goto-ng/admin/newConfigManagement/TemplateEngine/class_TemplateWidget_list.inc b/gosa-plugins/goto-ng/admin/newConfigManagement/TemplateEngine/class_TemplateWidget_list.inc index ccac0fee9..8bf17a07f 100644 --- a/gosa-plugins/goto-ng/admin/newConfigManagement/TemplateEngine/class_TemplateWidget_list.inc +++ b/gosa-plugins/goto-ng/admin/newConfigManagement/TemplateEngine/class_TemplateWidget_list.inc @@ -20,11 +20,14 @@ class TemplateWidget_list extends TemplateWidget function render() { $str = ""; + $this->listWidget->setDeleteable($this->enabled); $this->listWidget->setListData($this->value); $this->listWidget->update(); $str .= $this->listWidget->render(); - $str .= ""; - $str .= ""; + $disabled = (!$this->enabled)? "disabled" : ""; + + $str .= ""; + $str .= ""; return($str); } diff --git a/gosa-plugins/goto-ng/admin/newConfigManagement/TemplateEngine/class_TemplateWidget_string.inc b/gosa-plugins/goto-ng/admin/newConfigManagement/TemplateEngine/class_TemplateWidget_string.inc index 2bf3ccca0..99dc273b8 100644 --- a/gosa-plugins/goto-ng/admin/newConfigManagement/TemplateEngine/class_TemplateWidget_string.inc +++ b/gosa-plugins/goto-ng/admin/newConfigManagement/TemplateEngine/class_TemplateWidget_string.inc @@ -6,12 +6,13 @@ class TemplateWidget_string extends TemplateWidget { $desc = set_post($this->description); $value = set_post($this->value); - + $name = " name=\"{$this->postName}\" "; $value = " value=\"{$value}\" "; $title = (empty($this->description))?"": " title=\"{$desc}\""; - - return(""); + + $disabled = (!$this->enabled)? "disabled" : ""; + return(""); } } diff --git a/gosa-plugins/goto-ng/admin/newConfigManagement/TemplateEngine/class_TemplateWidget_textEditor.inc b/gosa-plugins/goto-ng/admin/newConfigManagement/TemplateEngine/class_TemplateWidget_textEditor.inc index 7c824f4f1..ce85384bb 100644 --- a/gosa-plugins/goto-ng/admin/newConfigManagement/TemplateEngine/class_TemplateWidget_textEditor.inc +++ b/gosa-plugins/goto-ng/admin/newConfigManagement/TemplateEngine/class_TemplateWidget_textEditor.inc @@ -26,6 +26,7 @@ class TemplateWidget_textEditor extends TemplateWidget $smarty->assign("postName", set_post($this->postName)); $smarty->assign("write_protect", set_post($this->write_protect)); $smarty->assign("value", set_post($this->value)); + $smarty->assign("enabled", set_post($this->enabled)); return($smarty->fetch(get_template_path("TemplateWidget_textEditor.tpl", TRUE, dirname(__FILE__)))); } diff --git a/gosa-plugins/goto-ng/admin/newConfigManagement/TemplateEngine/class_TemplateWidget_textarea.inc b/gosa-plugins/goto-ng/admin/newConfigManagement/TemplateEngine/class_TemplateWidget_textarea.inc index 030dd1156..8ca6ff838 100644 --- a/gosa-plugins/goto-ng/admin/newConfigManagement/TemplateEngine/class_TemplateWidget_textarea.inc +++ b/gosa-plugins/goto-ng/admin/newConfigManagement/TemplateEngine/class_TemplateWidget_textarea.inc @@ -5,8 +5,10 @@ class TemplateWidget_textarea extends TemplateWidget function render() { $title = set_post($this->description); + $disabled = (!$this->enabled)? "disabled" : ""; return(""); } -- 2.30.2