3 * Bacula(R) - The Network Backup Solution
4 * Baculum - Bacula web interface
6 * Copyright (C) 2013-2016 Kern Sibbald
8 * The main author of Baculum is Marcin Haba.
9 * The original author of Bacula is Kern Sibbald, with contributions
10 * from many others, a complete list can be found in the file AUTHORS.
12 * You may use this file and others of this release according to the
13 * license defined in the LICENSE file, which includes the Affero General
14 * Public License, v3.0 ("AGPLv3") and some additional permissions and
15 * terms pursuant to its AGPLv3 Section 7.
17 * This notice must be preserved when any source code is
18 * conveyed and/or propagated.
20 * Bacula(R) is a registered trademark of Kern Sibbald.
23 Prado::using('System.Web.UI.TTemplateControl');
24 Prado::using('System.Web.UI.ActiveControls.TActiveControlAdapter');
26 class BConditional extends TTemplateControl implements IActiveControl {
28 const BCONDITION = 'BCondition';
29 const TYPE_TPL_FALSE = 0;
30 const TYPE_TPL_TRUE = 1;
32 private $item_true_template;
33 private $item_false_template;
35 public function __construct() {
36 parent::__construct();
37 $this->setAdapter(new TActiveControlAdapter($this));
40 public function getActiveControl() {
41 return $this->getAdapter()->getBaseActiveControl();
44 public function onLoad($param) {
45 $this->prepareControlContent();
46 parent::onLoad($param);
49 public function bubbleEvent($sender,$param) {
50 if ($param instanceof TCommandEventParameter) {
51 $this->raiseBubbleEvent($this, $param);
58 private function createItemInternal($item_type) {
59 $item = $this->createItem($item_type);
60 if (!is_null($item)) {
61 $this->getControls()->add($item);
66 protected function createItem($item_type) {
70 case self::TYPE_TPL_TRUE: {
71 $template = $this->getTrueTemplate();
74 case self::TYPE_TPL_FALSE: {
75 $template = $this->getFalseTemplate();
79 if (!is_null($template)) {
80 $item = new BConditionalItem;
81 $item->setItemType($item_type);
82 $item->setTemplate($template);
83 $item->setTemplateControl($this);
84 $item->setData($this->getTemplateControl());
89 public function getTrueTemplate() {
90 return $this->item_true_template;
93 public function setTrueTemplate($template) {
94 if ($template instanceof ITemplate) {
95 $this->item_true_template = $template;
99 public function getFalseTemplate() {
100 return $this->item_false_template;
103 public function setFalseTemplate($template) {
104 if ($template instanceof ITemplate) {
105 $this->item_false_template = $template;
109 public function setBCondition($value) {
110 settype($value, 'bool');
111 $this->setViewState(self::BCONDITION, $value);
114 public function getBCondition() {
115 $value = $this->getViewState(self::BCONDITION);
119 public function dataBind() {
120 $this->dataBindProperties();
121 $this->prepareControlContent();
124 public function prepareControlContent() {
125 if ($this->getBCondition() === true) {
126 $this->createItemInternal(self::TYPE_TPL_TRUE);
128 $this->createItemInternal(self::TYPE_TPL_FALSE);
133 class BConditionalItem extends TTemplateControl implements IDataRenderer, INamingContainer {
137 public function getItemType() {
138 return $this->item_type;
141 public function setItemType($type) {
142 $this->item_type = $type;
145 public function getData() {
149 public function setData($data) {
153 public function bubbleEvent($sender,$param) {
154 if ($param instanceof TCommandEventParameter) {
155 $this->raiseBubbleEvent($this, $param);