]> git.sur5r.net Git - bacula/bacula/blob - gui/baculum/protected/Portlets/Console.php
baculum: Tweak end of lines (CF+LF => LF)
[bacula/bacula] / gui / baculum / protected / Portlets / Console.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 Prado::using('System.Web.UI.ActiveControls.TActivePanel');
21 Prado::using('System.Web.UI.ActiveControls.TActiveButton');
22 Prado::using('System.Web.UI.ActiveControls.TActiveTextBox');
23 Prado::using('Application.Portlets.Portlets');
24
25 class Console extends Portlets {
26
27         const MAX_CONSOLE_OUTPUT_BATCH = -1000;
28
29         public function sendCommand($sender, $param) {
30                 $cmd = trim($this->CommandLine->Text);
31                 if(!empty($cmd)) {
32                         $command = explode(' ', $cmd);
33                         $out = $this->Application->getModule('api')->set(array('console'), $command)->output;
34                         if(is_array($out)) {
35                                 $out = array_slice($out, self::MAX_CONSOLE_OUTPUT_BATCH);
36                                 $output = $this->OutputListing->Text . PHP_EOL . implode(PHP_EOL, $out);
37                         } else {
38                                 $output = $this->OutputListing->Text . PHP_EOL . $out;
39                         }
40                         $this->OutputListing->Text = $output;
41                         $this->CommandLine->Text = '';
42                 }
43         }
44
45         public function clearConsole($sender, $param) {
46                 $this->OutputListing->Text = '';
47                 $this->CommandLine->Text = '';
48         }
49 }
50
51 ?>