]> git.sur5r.net Git - bacula/bacula/blob - gui/baculum/protected/Portlets/SlideWindow.php
baculum: Assign Baculum copyright to Kern Sibbald
[bacula/bacula] / gui / baculum / protected / Portlets / SlideWindow.php
1 <?php
2 /*
3  * Bacula(R) - The Network Backup Solution
4  * Baculum   - Bacula web interface
5  *
6  * Copyright (C) 2013-2016 Kern Sibbald
7  *
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.
11  *
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.
16  *
17  * This notice must be preserved when any source code is
18  * conveyed and/or propagated.
19  *
20  * Bacula(R) is a registered trademark of Kern Sibbald.
21  */
22
23  
24 Prado::using('System.Web.UI.WebControls.TCompareValidator');
25 Prado::using('System.Web.UI.ActiveControls.TActiveLabel');
26 Prado::using('System.Web.UI.ActiveControls.TActivePanel');
27 Prado::using('System.Web.UI.ActiveControls.TActiveDropDownList');
28 Prado::using('System.Web.UI.ActiveControls.TActiveTextBox');
29 Prado::using('System.Web.UI.ActiveControls.TActiveRadioButton');
30 Prado::using('System.Web.UI.ActiveControls.TCallback');
31
32 Prado::using('Application.Portlets.Portlets');
33
34 class SlideWindow extends Portlets {
35
36         public $elementsLimit = array(
37                 10 => '10 elements',
38                 25 => '25 elements',
39                 50 => '50 elements',
40                 100 => '100 elements',
41                 200 => '200 elements',
42                 500 => '500 elements',
43                 1000 => '1000 elements',
44                 'unlimited' => 'unlimited'
45         );
46
47         private $defaultElementsLimit = 500;
48
49         public $actions = array(
50                 'VolumeWindow' => array(
51                         'NoAction' => 'select action',
52                         'delete' => 'Delete',
53                         'prune' => 'Prune',
54                         'purge' => 'Purge'
55                 ),
56                 'JobWindow' => array(
57                         'NoAction' => 'select action',
58                         'delete' => 'Delete'
59                 )
60         );
61
62         const NORMAL_VIEW = 'simple';
63         const DETAIL_VIEW = 'details';
64
65         public function onInit($param) {
66                 parent::onInit($param);
67                 if(empty($_SESSION['view' . $this->getParent()->ID]) && empty($_SESSION['limit' . $this->getParent()->ID])) {
68                         $_SESSION['view' . $this->getParent()->ID] = self::DETAIL_VIEW;
69                         $_SESSION['limit' . $this->getParent()->ID] = $this->defaultElementsLimit;
70                 }
71         }
72
73         public function onLoad($param) {
74                 parent::onLoad($param);
75                 if(!$this->getPage()->IsPostBack) {
76                         $limitKeys = array_keys($this->elementsLimit);
77                         $limitValues = array();
78                         foreach($this->elementsLimit as $val) {
79                                 $limitValues[] = Prado::localize($val);
80                         }
81                         $this->Limit->dataSource = array_combine($limitKeys, $limitValues);
82                         $this->Limit->SelectedValue = $_SESSION['limit' . $this->getParent()->ID];
83                         $this->Limit->dataBind();
84                         $this->Simple->Checked = ($_SESSION['view' . $this->getParent()->ID] == self::NORMAL_VIEW);
85                         $this->Details->Checked = ($_SESSION['view' . $this->getParent()->ID] == self::DETAIL_VIEW);
86                         $actions = array_key_exists($this->getParent()->ID, $this->actions) ? $this->actions[$this->getParent()->ID] : array();
87                         $actionsLang = array();
88                         foreach($actions as $key => $val) {
89                                 $actionsLang[$key] = Prado::localize($val);
90                         }
91                         $this->Actions->dataSource = $actionsLang;
92                         $this->Actions->dataBind();
93                 }
94         }
95
96         public function switchView($sender, $param) {
97                 $_SESSION['view' . $this->getParent()->ID] = ($this->Simple->Checked === true) ? self::NORMAL_VIEW : self::DETAIL_VIEW;
98                 $_SESSION['limit' . $this->getParent()->ID] = $this->Limit->SelectedValue;
99                 $this->getParent()->prepareData(true);
100         }
101
102         public function action($sender, $param) {
103                 if(method_exists($this->getParent(), 'executeAction')) {
104                         $this->getParent()->executeAction($this->Actions->SelectedValue, $sender, $param);
105                 }
106         }
107 }
108 ?>