Use text box list control to: wild, wilddir, wildfile, regex, regexdir and regexfile FileSet directives.
"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,
Text="<%[ Configure fileset ]%>"
Visible="<%=!empty($_SESSION['dir'])%>"
OnClick="loadFileSetConfig"
+ CommandParameter="show"
/>
<com:TActiveLinkButton
CssClass="w3-bar-item w3-button tab_btn"
Text="<%[ Configure fileset ]%>"
Visible="<%=!empty($_SESSION['dir'])%>"
OnClick="loadFileSetConfig"
+ CommandParameter="show"
/>
<com:TActiveLinkButton
CssClass="w3-bar-item w3-button tab_btn"
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');
$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();
* 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
* 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;
--- /dev/null
+<?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;
+ }
+
+}
+?>
'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();
$directive_value = false;
}
}
+
+ if ($field_type === 'MultiTextBox') {
+ $directive_value = array($directive_value);
+ }
+
if (!is_array($directive_value)) {
$directive_value = array($directive_value);
}
// 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();
// 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++;
$data = $this->getDirectiveValue();
$data['Include'][] = array();
$this->setData($data);
- $this->loadConfig(null, null);
+ $this->loadConfig();
}
public function newIncludeFile($sender, $param) {
}
$data['Include'][$inc_index]['File'][$file_index] = '';
$this->setData($data);
- $this->loadConfig(null, null);
+ $this->loadConfig();
}
public function newExcludeFile($sender, $param) {
}
$data['Exclude']['File'][$file_index] = '';
$this->setData($data);
- $this->loadConfig(null, null);
+ $this->loadConfig();
}
public function newIncludeOptions($sender, $param) {
$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) {
$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'])) {
}
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'])) {
}
}
$this->setData($data);
- $this->loadConfig(null, null);
+ $this->loadConfig();
}
}
?>
const DATA = 'Data';
const LOAD_VALUES = 'LoadValues';
const SHOW = 'Show';
+ const GROUP_NAME = 'GroupName';
public $display_directive;
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);
+ }
}
?>
--- /dev/null
+<?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();
+ }
+}
+?>
--- /dev/null
+<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>
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');
'DirectiveFileSet',
'DirectiveSchedule',
'DirectiveMessages',
- 'DirectiveRunscript'
+ 'DirectiveRunscript',
+ 'DirectiveMultiTextBox'
);
public $resource_names = array();
$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);
+ }
}
}
* 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';
}
}
- 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()) {