]> git.sur5r.net Git - bacula/bacula/blob - gui/baculum/protected/Portlets/SlideWindow.php
baculum: Tweak change license statements
[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-2015 Marcin Haba
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         public $actions = array(
47                 'VolumeWindow' => array(
48                         'NoAction' => 'select action',
49                         'delete' => 'Delete',
50                         'prune' => 'Prune',
51                         'purge' => 'Purge'
52                 ),
53                 'JobWindow' => array(
54                         'NoAction' => 'select action',
55                         'delete' => 'Delete'
56                 )
57         );
58
59         const NORMAL_VIEW = 'simple';
60         const DETAIL_VIEW = 'details';
61
62         public function onInit($param) {
63                 parent::onInit($param);
64                 if(empty($_SESSION['view' . $this->getParent()->ID]) && empty($_SESSION['limit' . $this->getParent()->ID])) {
65                         $_SESSION['view' . $this->getParent()->ID] = self::DETAIL_VIEW;
66                         $_SESSION['limit' . $this->getParent()->ID] = $this->elementsLimit['unlimited'];
67                 }
68         }
69
70         public function onLoad($param) {
71                 parent::onLoad($param);
72                 if(!$this->getPage()->IsPostBack) {
73                         $limitKeys = array_keys($this->elementsLimit);
74                         $limitValues = array();
75                         foreach($this->elementsLimit as $val) {
76                                 $limitValues[] = Prado::localize($val);
77                         }
78                         $this->Limit->dataSource = array_combine($limitKeys, $limitValues);
79                         $this->Limit->SelectedValue = $_SESSION['limit' . $this->getParent()->ID];
80                         $this->Limit->dataBind();
81                         $this->Simple->Checked = ($_SESSION['view' . $this->getParent()->ID] == self::NORMAL_VIEW);
82                         $this->Details->Checked = ($_SESSION['view' . $this->getParent()->ID] == self::DETAIL_VIEW);
83                         $actions = array_key_exists($this->getParent()->ID, $this->actions) ? $this->actions[$this->getParent()->ID] : array();
84                         $actionsLang = array();
85                         foreach($actions as $key => $val) {
86                                 $actionsLang[$key] = Prado::localize($val);
87                         }
88                         $this->Actions->dataSource = $actionsLang;
89                         $this->Actions->dataBind();
90                 }
91         }
92
93         public function switchView($sender, $param) {
94                 $_SESSION['view' . $this->getParent()->ID] = ($this->Simple->Checked === true) ? self::NORMAL_VIEW : self::DETAIL_VIEW;
95                 $_SESSION['limit' . $this->getParent()->ID] = $this->Limit->SelectedValue;
96                 $this->getParent()->prepareData(true);
97         }
98
99         public function action($sender, $param) {
100                 if(method_exists($this->getParent(), 'executeAction')) {
101                         $this->getParent()->executeAction($this->Actions->SelectedValue, $sender, $param);
102                 }
103         }
104 }
105 ?>