]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
baculum: Add text box list control to support directives that can be defined multiple...
authorMarcin Haba <marcin.haba@bacula.pl>
Mon, 22 Apr 2019 05:03:56 +0000 (07:03 +0200)
committerMarcin Haba <marcin.haba@bacula.pl>
Mon, 22 Apr 2019 05:03:56 +0000 (07:03 +0200)
Use text box list control to: wild, wilddir, wildfile, regex, regexdir and regexfile FileSet directives.

12 files changed:
gui/baculum/protected/Web/Data/data_desc.json
gui/baculum/protected/Web/Pages/JobHistoryView.page
gui/baculum/protected/Web/Pages/JobView.page
gui/baculum/protected/Web/Portlets/BaculaConfigDirectives.php
gui/baculum/protected/Web/Portlets/ConfigListTemplate.php
gui/baculum/protected/Web/Portlets/DirectiveControlTemplate.php [new file with mode: 0644]
gui/baculum/protected/Web/Portlets/DirectiveFileSet.php
gui/baculum/protected/Web/Portlets/DirectiveListTemplate.php
gui/baculum/protected/Web/Portlets/DirectiveMultiTextBox.php [new file with mode: 0644]
gui/baculum/protected/Web/Portlets/DirectiveMultiTextBox.tpl [new file with mode: 0644]
gui/baculum/protected/Web/Portlets/DirectiveRenderer.php
gui/baculum/protected/Web/Portlets/DirectiveTemplate.php

index a039b4f7ddbe2348a2aaedd95c92d4e5f5613c3f..0e5142530b12d12012640c6b58821bf34a97d03d 100644 (file)
                                                "Required": false,
                                                "ValueType": "str",
                                                "DefaultValue": 0,
-                                               "FieldType": "TextBox"
+                                               "FieldType": "MultiTextBox"
                                        },
                                        "WildDir": {
                                                "Required": false,
                                                "ValueType": "str",
                                                "DefaultValue": 0,
-                                               "FieldType": "TextBox"
+                                               "FieldType": "MultiTextBox"
                                        },
                                        "WildFile": {
                                                "Required": false,
                                                "ValueType": "str",
                                                "DefaultValue": 0,
-                                               "FieldType": "TextBox"
+                                               "FieldType": "MultiTextBox"
                                        },
                                        "Regex": {
                                                "Required": false,
                                                "ValueType": "str",
                                                "DefaultValue": 0,
-                                               "FieldType": "TextBox"
+                                               "FieldType": "MultiTextBox"
                                        },
                                        "RegexDir": {
                                                "Required": false,
                                                "ValueType": "str",
                                                "DefaultValue": 0,
-                                               "FieldType": "TextBox"
+                                               "FieldType": "MultiTextBox"
                                        },
                                        "RegexFile": {
                                                "Required": false,
                                                "ValueType": "str",
                                                "DefaultValue": 0,
-                                               "FieldType": "TextBox"
+                                               "FieldType": "MultiTextBox"
                                        },
                                        "Exclude": {
                                                "Required": false,
index d8d2d995e034cdb496238966316c690de5f0f2c9..12cea7fcbba965a68fc98e4dc822fc16174fd496 100644 (file)
@@ -23,6 +23,7 @@
                        Text="<%[ Configure fileset ]%>"
                        Visible="<%=!empty($_SESSION['dir'])%>"
                        OnClick="loadFileSetConfig"
+                       CommandParameter="show"
                />
                <com:TActiveLinkButton
                        CssClass="w3-bar-item w3-button tab_btn"
index 512948d20c3167042d761c24c40814550d1b3f62..f16eb3c69be96da1aa87489c69e6b06a008e4d10 100644 (file)
@@ -23,6 +23,7 @@
                        Text="<%[ Configure fileset ]%>"
                        Visible="<%=!empty($_SESSION['dir'])%>"
                        OnClick="loadFileSetConfig"
+                       CommandParameter="show"
                />
                <com:TActiveLinkButton
                        CssClass="w3-bar-item w3-button tab_btn"
index 93e799c6db1c88eae0d2795663dbd82a9381e8ef..274ae3d588567834ea1a78053466055946bae758 100644 (file)
@@ -31,6 +31,7 @@ Prado::using('Application.Web.Portlets.DirectiveInteger');
 Prado::using('Application.Web.Portlets.DirectiveListBox');
 Prado::using('Application.Web.Portlets.DirectiveSize');
 Prado::using('Application.Web.Portlets.DirectiveTextBox');
+Prado::using('Application.Web.Portlets.DirectiveMultiTextBox');
 Prado::using('Application.Web.Portlets.DirectiveTimePeriod');
 Prado::using('Application.Web.Portlets.DirectiveRunscript');
 Prado::using('Application.Web.Portlets.DirectiveMessages');
@@ -232,49 +233,6 @@ class BaculaConfigDirectives extends DirectiveListTemplate {
                $this->RepeaterDirectives->dataBind();
        }
 
-       public function createDirectiveElement($sender, $param) {
-               $load_values = $this->getLoadValues();
-               for ($i = 0; $i < count($this->directive_types); $i++) {
-                       $control = $this->getChildControl($param->Item, $this->directive_types[$i]);
-                       if (is_object($control)) {
-                               $control->setHost($param->Item->Data['host']);
-                               $control->setComponentType($param->Item->Data['component_type']);
-                               $control->setComponentName($param->Item->Data['component_name']);
-                               $control->setResourceType($param->Item->Data['resource_type']);
-                               $control->setResourceName($param->Item->Data['resource_name']);
-                               $control->setDirectiveName($param->Item->Data['directive_name']);
-                               $control->setDirectiveValue($param->Item->Data['directive_value']);
-                               $control->setDefaultValue($param->Item->Data['default_value']);
-                               $control->setRequired($param->Item->Data['required']);
-                               $control->setData($param->Item->Data['data']);
-                               $control->setResource($param->Item->Data['resource']);
-                               $control->setLabel($param->Item->Data['label']);
-                               $control->setInConfig($param->Item->Data['in_config']);
-                               $show_all_directives = ($param->Item->Data['in_config'] || !$load_values || $this->getShowAllDirectives());
-                               $control->setShow($show_all_directives);
-                               $control->setResourceNames($this->resource_names);
-                               break;
-                       }
-               }
-               for ($i = 0; $i < count($this->directive_list_types); $i++) {
-                       $control = $this->getChildControl($param->Item, $this->directive_list_types[$i]);
-                       if (is_object($control)) {
-                               $control->setHost($param->Item->Data['host']);
-                               $control->setComponentType($param->Item->Data['component_type']);
-                               $control->setComponentName($param->Item->Data['component_name']);
-                               $control->setResourceType($param->Item->Data['resource_type']);
-                               $control->setResourceName($param->Item->Data['resource_name']);
-                               $control->setDirectiveName($param->Item->Data['directive_name']);
-                               $control->setData($param->Item->Data['directive_value']);
-                               $control->setLoadValues($this->getLoadValues());
-                               $control->setResourceNames($this->resource_names);
-                               $control->setShow(true);
-                               $control->raiseEvent('OnDirectiveListLoad', $this, null);
-                       }
-               }
-       }
-
-
        public function saveResource($sender, $param) {
                $directives = array();
                $host = $this->getHost();
index db09f6d8507a9228ed7698a8394b562819263c79..d1ad390aa1fcb0f7438b2a9b0294ead65f0fc341 100644 (file)
@@ -3,7 +3,7 @@
  * Bacula(R) - The Network Backup Solution
  * Baculum   - Bacula web interface
  *
- * Copyright (C) 2013-2016 Kern Sibbald
+ * Copyright (C) 2013-2019 Kern Sibbald
  *
  * The main author of Baculum is Marcin Haba.
  * The original author of Bacula is Kern Sibbald, with contributions
@@ -20,9 +20,9 @@
  * Bacula(R) is a registered trademark of Kern Sibbald.
  */
 
-Prado::using('System.Web.UI.TTemplateControl');
+Prado::using('Application.Web.Portlets.DirectiveControlTemplate');
 
-class ConfigListTemplate extends TTemplateControl {
+class ConfigListTemplate extends DirectiveControlTemplate {
 
        public function getChildControl($parent, $type) {
                $child_control = null;
diff --git a/gui/baculum/protected/Web/Portlets/DirectiveControlTemplate.php b/gui/baculum/protected/Web/Portlets/DirectiveControlTemplate.php
new file mode 100644 (file)
index 0000000..8ec576f
--- /dev/null
@@ -0,0 +1,42 @@
+<?php
+/*
+ * Bacula(R) - The Network Backup Solution
+ * Baculum   - Bacula web interface
+ *
+ * Copyright (C) 2013-2019 Kern Sibbald
+ *
+ * The main author of Baculum is Marcin Haba.
+ * The original author of Bacula is Kern Sibbald, with contributions
+ * from many others, a complete list can be found in the file AUTHORS.
+ *
+ * You may use this file and others of this release according to the
+ * license defined in the LICENSE file, which includes the Affero General
+ * Public License, v3.0 ("AGPLv3") and some additional permissions and
+ * terms pursuant to its AGPLv3 Section 7.
+ *
+ * This notice must be preserved when any source code is
+ * conveyed and/or propagated.
+ *
+ * Bacula(R) is a registered trademark of Kern Sibbald.
+ */
+
+Prado::using('System.Web.UI.TTemplateControl');
+
+abstract class DirectiveControlTemplate extends TTemplateControl {
+
+       public function getCmdParam() {
+               $command_param = null;
+               if ($this->getPage()->IsCallBack) {
+                       if (method_exists($this->getPage()->CallBackEventTarget, 'getCommandParameter')) {
+                               $command_param = $this->getPage()->CallBackEventTarget->getCommandParameter();
+                       }
+               } elseif ($this->getPage()->IsPostBack) {
+                       if (method_exists($this->getPage()->PostBackEventTarget, 'getCommandParameter')) {
+                               $command_param = $this->getPage()->PostBackEventTarget->getCommandParameter();
+                       }
+               }
+               return $command_param;
+       }
+
+}
+?>
index ee85e8c081e3be1945508f74e14fbca794f68acb..6b73d9d764ed5aeb38cfb3b54d071f1ee63ee633 100644 (file)
@@ -40,11 +40,15 @@ class DirectiveFileSet extends DirectiveListTemplate {
                'DirectiveInteger'
        );
 
+       private $directive_list_types = array(
+               'DirectiveMultiTextBox'
+       );
+
        private $directive_inc_exc_types = array(
                'DirectiveTextBox'
        );
 
-       public function loadConfig($sender, $param) {
+       public function loadConfig() {
                $component_type = $this->getComponentType();
                $component_name = $this->getComponentType();
                $resource_type = $this->getResourceType();
@@ -188,6 +192,11 @@ class DirectiveFileSet extends DirectiveListTemplate {
                                                $directive_value = false;
                                        }
                                }
+
+                               if ($field_type === 'MultiTextBox') {
+                                       $directive_value = array($directive_value);
+                               }
+
                                if (!is_array($directive_value)) {
                                        $directive_value = array($directive_value);
                                }
@@ -244,14 +253,18 @@ class DirectiveFileSet extends DirectiveListTemplate {
                                                // value the same as default value, skip it
                                                continue;
                                        }
-                                       if (!isset($counter, $directive_values['Include'][$counter])) {
-                                               $directive_values['Include'][$counter] = array('Options' => array());
+                                       if (!key_exists($counter, $directive_values['Include'])) {
+                                               $directive_values['Include'][$counter] = array();
                                        }
-                                       if (!isset($directive_values['Include'][$counter]['Options'][$index])) {
+                                       if (!key_exists('Options', $directive_values['Include'][$counter])) {
+                                               $directive_values['Include'][$counter]['Options'] = array();
+                                       }
+                                       if (!key_exists($index, $directive_values['Include'][$counter]['Options'])) {
                                                $directive_values['Include'][$counter]['Options'][$index] = array();
                                        }
                                        $directive_values['Include'][$counter]['Options'][$index][$directive_name] = $directive_value;
                                }
+
                                $controls = $value->RepeaterFileSetInclude->findControlsByType($this->directive_types[$i]);
                                for ($j = 0; $j < count($controls); $j++) {
                                        $directive_name = $controls[$j]->getDirectiveName();
@@ -260,16 +273,36 @@ class DirectiveFileSet extends DirectiveListTemplate {
                                                // Include file directive removed
                                                continue;
                                        }
-                                       if (!key_exists('Include', $directive_values)) {
-                                               $directive_values['Include'] = array();
-                                       }
-                                       if (!isset($directive_values['Include'][$counter])) {
+                                       if (!key_exists($counter, $directive_values['Include'])) {
                                                $directive_values['Include'][$counter] = array();
                                        }
                                        if (!key_exists($directive_name, $directive_values['Include'][$counter])) {
                                                $directive_values['Include'][$counter][$directive_name] = array();
                                        }
-                                       array_push($directive_values['Include'][$counter][$directive_name], $directive_value);
+                                       $directive_values['Include'][$counter][$directive_name][] = $directive_value;
+                               }
+                       }
+                       for ($i = 0; $i < count($this->directive_list_types); $i++) {
+                               $controls = $value->RepeaterFileSetOptions->findControlsByType($this->directive_list_types[$i]);
+                               for ($j = 0; $j < count($controls); $j++) {
+                                       $directive_name = $controls[$j]->getDirectiveName();
+                                       $directive_value = array_filter($controls[$j]->getDirectiveValue());
+                                       sort($directive_value);
+                                       $index = $controls[$j]->getGroupName();
+                                       if (count($directive_value) == 0) {
+                                               // option not set or removed
+                                               continue;
+                                       }
+                                       if (!key_exists($counter, $directive_values['Include'])) {
+                                               $directive_values['Include'][$counter] = array();
+                                       }
+                                       if (!key_exists('Options', $directive_values['Include'][$counter])) {
+                                               $directive_values['Include'][$counter]['Options'] = array();
+                                       }
+                                       if (!key_exists($index, $directive_values['Include'][$counter]['Options'])) {
+                                               $directive_values['Include'][$counter]['Options'][$index] = array();
+                                       }
+                                       $directive_values['Include'][$counter]['Options'][$index][$directive_name] = $directive_value;
                                }
                        }
                        $counter++;
@@ -324,7 +357,7 @@ class DirectiveFileSet extends DirectiveListTemplate {
                $data = $this->getDirectiveValue();
                $data['Include'][] = array();
                $this->setData($data);
-               $this->loadConfig(null, null);
+               $this->loadConfig();
        }
 
        public function newIncludeFile($sender, $param) {
@@ -336,7 +369,7 @@ class DirectiveFileSet extends DirectiveListTemplate {
                }
                $data['Include'][$inc_index]['File'][$file_index] = '';
                $this->setData($data);
-               $this->loadConfig(null, null);
+               $this->loadConfig();
        }
 
        public function newExcludeFile($sender, $param) {
@@ -349,7 +382,7 @@ class DirectiveFileSet extends DirectiveListTemplate {
                }
                $data['Exclude']['File'][$file_index] = '';
                $this->setData($data);
-               $this->loadConfig(null, null);
+               $this->loadConfig();
        }
 
        public function newIncludeOptions($sender, $param) {
@@ -362,7 +395,7 @@ class DirectiveFileSet extends DirectiveListTemplate {
                $data['Include'][$inc_index]['Options'][$opt_index] = array();
                $this->SourceTemplateControl->setShowAllDirectives(true);
                $this->setData($data);
-               $this->loadConfig(null, null);
+               $this->loadConfig();
        }
 
        public function newIncludeExcludeFile($sender, $param) {
@@ -370,8 +403,11 @@ class DirectiveFileSet extends DirectiveListTemplate {
                $inc_index = $this->RepeaterFileSetIncludes->getItems()->getCount() - 1;
                $inc_exc = $param->getCallbackParameter();
                if (property_exists($inc_exc, 'Include') && is_array($inc_exc->Include)) {
-                       if (!key_exists($inc_index, $data['Include']) || !key_exists('File', $data['Include'][$inc_index])) {
-                               $data['Include'][$inc_index] = array('File' => array());
+                       if (!key_exists($inc_index, $data['Include'])){
+                               $data['Include'][$inc_index] = array();
+                       }
+                       if (!key_exists('File', $data['Include'][$inc_index])) {
+                               $data['Include'][$inc_index]['File'] = array();
                        }
                        for ($i = 0; $i < count($inc_exc->Include); $i++) {
                                if (in_array($inc_exc->Include[$i], $data['Include'][$inc_index]['File'])) {
@@ -383,7 +419,7 @@ class DirectiveFileSet extends DirectiveListTemplate {
                }
                if (property_exists($inc_exc, 'Exclude') && is_array($inc_exc->Exclude)) {
                        if (!key_exists('File', $data['Exclude'])) {
-                               $data['Exclude'] = array('File' => array());
+                               $data['Exclude']['File'] = array();
                        }
                        for ($i = 0; $i < count($inc_exc->Exclude); $i++) {
                                if (in_array($inc_exc->Exclude[$i], $data['Exclude']['File'])) {
@@ -394,7 +430,7 @@ class DirectiveFileSet extends DirectiveListTemplate {
                        }
                }
                $this->setData($data);
-               $this->loadConfig(null, null);
+               $this->loadConfig();
        }
 }
 ?>
index 2b08f7e699d82ee3b7e4177ade661f20ccd43ca7..18d17feafcab35c82d394a47a8a9a92ea0f36c9d 100644 (file)
@@ -36,6 +36,7 @@ class DirectiveListTemplate extends ConfigListTemplate implements IActiveControl
        const DATA = 'Data';
        const LOAD_VALUES = 'LoadValues';
        const SHOW = 'Show';
+       const GROUP_NAME = 'GroupName';
 
        public $display_directive;
 
@@ -154,5 +155,13 @@ class DirectiveListTemplate extends ConfigListTemplate implements IActiveControl
        public function setShow($show) {
                $this->setViewState(self::SHOW, $show);
        }
+
+       public function getGroupName() {
+               return $this->getViewState(self::GROUP_NAME);
+       }
+
+       public function setGroupName($group_name) {
+               $this->setViewState(self::GROUP_NAME, $group_name);
+       }
 }
 ?>
diff --git a/gui/baculum/protected/Web/Portlets/DirectiveMultiTextBox.php b/gui/baculum/protected/Web/Portlets/DirectiveMultiTextBox.php
new file mode 100644 (file)
index 0000000..6757059
--- /dev/null
@@ -0,0 +1,89 @@
+<?php
+/*
+ * Bacula(R) - The Network Backup Solution
+ * Baculum   - Bacula web interface
+ *
+ * Copyright (C) 2013-2019 Kern Sibbald
+ *
+ * The main author of Baculum is Marcin Haba.
+ * The original author of Bacula is Kern Sibbald, with contributions
+ * from many others, a complete list can be found in the file AUTHORS.
+ *
+ * You may use this file and others of this release according to the
+ * license defined in the LICENSE file, which includes the Affero General
+ * Public License, v3.0 ("AGPLv3") and some additional permissions and
+ * terms pursuant to its AGPLv3 Section 7.
+ *
+ * This notice must be preserved when any source code is
+ * conveyed and/or propagated.
+ *
+ * Bacula(R) is a registered trademark of Kern Sibbald.
+ */
+
+Prado::using('System.Web.UI.ActiveControls.TActiveLabel');
+Prado::using('System.Web.UI.ActiveControls.TActiveTextBox');
+Prado::using('System.Web.UI.ActiveControls.TActiveLinkButton');
+Prado::using('Application.Web.Portlets.DirectiveListTemplate');
+
+class DirectiveMultiTextBox extends DirectiveListTemplate {
+
+       public function onLoad($param) {
+               parent::onLoad($param);
+               if ($this->getCmdParam() !== 'add_multitextbox') {
+                       $this->loadConfig();
+               }
+       }
+
+       public function getDirectiveValue() {
+               $values = array();
+               $controls = $this->MultiTextBoxRepeater->getItems();
+               foreach ($controls as $control) {
+                       $val = $control->Directive->getText();
+                       if (!empty($val)) {
+                               $values[] = $val;
+                       } else {
+                               $values[] = null;
+                       }
+               }
+               return $values;
+       }
+
+       public function loadConfig() {
+               $load_values = $this->getLoadValues();
+               $host = $this->getHost();
+               $component_type = $this->getComponentType();
+               $component_name = $this->getComponentName();
+               $resource_type = $this->getResourceType();
+               $resource_name = $this->getResourceName();
+               $directive_name = $this->getDirectiveName();
+
+               $data = $this->getData();
+               if (!is_array($data) ) {
+                       $data = array($data);
+               }
+               $values = array();
+               for ($i = 0; $i < count($data); $i++) {
+                       $values[] = array(
+                               'directive_value' => $data[$i],
+                               'label' => $this->getDirectiveName(),
+                               'show' => $this->getShow()
+                       );
+               }
+               $this->MultiTextBoxRepeater->DataSource = $values;
+               $this->MultiTextBoxRepeater->dataBind();
+       }
+
+       public function createMultiTextBoxElement($sender, $param) {
+               $param->Item->Label->Text = $param->Item->Data['label'];
+               $param->Item->Directive->Text = $param->Item->Data['directive_value'];
+
+       }
+
+       public function addField($sender, $param) {
+               $data = $this->getDirectiveValue();
+               $data[] = '';
+               $this->setData($data);
+               $this->loadConfig();
+       }
+}
+?>
diff --git a/gui/baculum/protected/Web/Portlets/DirectiveMultiTextBox.tpl b/gui/baculum/protected/Web/Portlets/DirectiveMultiTextBox.tpl
new file mode 100644 (file)
index 0000000..84e647a
--- /dev/null
@@ -0,0 +1,22 @@
+<com:TActiveRepeater ID="MultiTextBoxRepeater" OnItemDataBound="createMultiTextBoxElement">
+       <prop:ItemTemplate>
+               <div class="w3-row w3-margin-bottom<%=!$this->Data['show'] ? ' hide' : '';%>">
+                       <div class="w3-col w3-quarter"><com:TActiveLabel ID="Label" ActiveControl.EnableUpdate="false" />:</div>
+                       <div class="w3-col w3-threequarter directive_value">
+                               <com:TActiveTextBox ID="Directive"
+                                       CssClass="w3-input w3-border w3-twothird"
+                                       ActiveControl.EnableUpdate="false"
+                                       AutoTrim="true"
+                               />      <com:TActiveLinkButton ID="AddFieldBtn"
+                                               OnCommand="SourceTemplateControl.addField"
+                                               CommandParameter="add_multitextbox"
+                                       >
+                                       <prop:Text>
+                                               <i class="fa fa-plus" title="<%[ Add directive ]%>" alt="<%[ Add directive ]%>"></i>
+                                       </prop:Text>
+                               </com:TActiveLinkButton>
+                               <i class="fa fa-trash-alt remove_btn" onclick="document.getElementById('<%=$this->Directive->ClientID%>').value = '';" alt="<%[ Remove directive ]%>" title="<%[ Remove directive ]%>"></i>
+                       </div>
+               </div>
+       </prop:ItemTemplate>
+</com:TActiveRepeater>
index d064c0ad0cdfbf968c2fd0fa9f4da9b778c4602d..160960c00c27bc688c3125fcae28c08fffb2a796 100644 (file)
@@ -31,6 +31,7 @@ Prado::using('Application.Web.Portlets.DirectiveInteger');
 Prado::using('Application.Web.Portlets.DirectiveListBox');
 Prado::using('Application.Web.Portlets.DirectiveSize');
 Prado::using('Application.Web.Portlets.DirectiveTextBox');
+Prado::using('Application.Web.Portlets.DirectiveMultiTextBox');
 Prado::using('Application.Web.Portlets.DirectiveTimePeriod');
 Prado::using('Application.Web.Portlets.DirectiveRunscript');
 Prado::using('Application.Web.Portlets.DirectiveMessages');
@@ -54,7 +55,8 @@ class DirectiveRenderer extends DirectiveListTemplate implements IItemDataRender
                'DirectiveFileSet',
                'DirectiveSchedule',
                'DirectiveMessages',
-               'DirectiveRunscript'
+               'DirectiveRunscript',
+               'DirectiveMultiTextBox'
        );
 
        public $resource_names = array();
@@ -99,9 +101,16 @@ class DirectiveRenderer extends DirectiveListTemplate implements IItemDataRender
                        $control->setData($data['directive_value']);
                        $control->setLoadValues($this->SourceTemplateControl->getLoadValues());
                        $control->setResourceNames($this->SourceTemplateControl->getResourceNames());
-                       $control->setShow(true);
+                       $control->setShow($data['show']);
+                       $control->setGroupName($data['group_name']);
                        $this->getControls()->add($control);
-                       $control->raiseEvent('OnDirectiveListLoad', $this, null);
+                       if (!$this->getPage()->IsCallBack || $this->getPage()->getCallbackEventParameter()  === 'show_all_directives' || $this->getCmdParam() === 'show') {
+                               /*
+                                * List types should be loaded only by load request, not by callback request.
+                                * Otherwise OnLoad above is called during callback and overwrites data in controls.
+                                */
+                               $control->raiseEvent('OnDirectiveListLoad', $this, null);
+                       }
                }
        }
 
index 6e458abf9305302d97e23b2c18efd0c83c36601e..b103a869a558499fd3827c57e8767aef837f58f4 100644 (file)
  * Bacula(R) is a registered trademark of Kern Sibbald.
  */
 
-Prado::using('System.Web.UI.TTemplateControl');
 Prado::using('System.Web.UI.ActiveControls.TActiveControlAdapter');
+Prado::using('Application.Web.Portlets.DirectiveControlTemplate');
 Prado::using('Application.Web.Portlets.IDirectiveField');
 
-class DirectiveTemplate extends TTemplateControl implements IDirectiveField, IActiveControl {
+class DirectiveTemplate extends DirectiveControlTemplate implements IDirectiveField, IActiveControl {
 
        const HOST = 'Host';
        const COMPONENT_TYPE = 'ComponentType';
@@ -81,20 +81,6 @@ class DirectiveTemplate extends TTemplateControl implements IDirectiveField, IAc
                }
        }
 
-       public function getCmdParam() {
-               $command_param = null;
-               if ($this->getPage()->IsCallBack) {
-                       if (method_exists($this->getPage()->CallBackEventTarget, 'getCommandParameter')) {
-                               $command_param = $this->getPage()->CallBackEventTarget->getCommandParameter();
-                       }
-               } elseif ($this->getPage()->IsPostBack) {
-                       if (method_exists($this->getPage()->PostBackEventTarget, 'getCommandParameter')) {
-                               $command_param = $this->getPage()->PostBackEventTarget->getCommandParameter();
-                       }
-               }
-               return $command_param;
-       }
-
        public function onLoad($param) {
                parent::onLoad($param);
                if (!$this->getIsDirectiveCreated()) {