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