Ticket #291: jControllerCmdLine.class.php

File jControllerCmdLine.class.php, 1.6 kB (added by doubleface, 1 year ago)

patched version

Line 
1 <?php
2 /**
3 * @package    jelix
4 * @subpackage controllers
5 * @author     Loic Mathaud
6 * @contributor
7 * @copyright  2006 Loic Mathaud
8 * @link        http://www.jelix.org
9 * @licence  http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public Licence, see LICENCE file
10 *
11 */
12
13 /**
14  * a base class for controllers used in command line application
15  * @package    jelix
16  * @subpackage controllers
17  * @since 1.0a3
18  */
19 class jControllerCmdLine extends jController {
20
21     protected $_options;
22     protected $_parameters;
23
24     protected $allowed_options;
25     protected $allowed_parameters;
26
27     /**
28     *
29     * @param jRequest $request
30     */
31     function __construct ($request){
32         $this->request = $request;
33         $params = $this->request->params;
34         unset($params['module']);
35         unset($params['action']);
36         $action = new jSelectorAct($this->request->params['action']);
37         list($this->_options,$this->_parameters) = jCmdUtils::getOptionsAndParams($params,$this->allowed_options[$action->method] , $this->allowed_parameters[$action->method]);
38
39     }
40
41     protected function param ($parName, $parDefaultValue=null, $useDefaultIfEmpty=false){
42         if (isset($this->_parameters[$parName])) {
43             if($this->_parameters[$parName] == '' && $useDefaultIfEmpty)
44                 return $parDefaultValue;
45             else
46                 return $this->_parameters[$parName];
47         } else {
48             return $parDefaultValue;
49         }
50     }
51
52     protected function option($name) {
53         if (isset($this->_options[$name])) {
54             return $this->_options[$name];
55         } else {
56             return false;
57         }
58     }
59
60 }
61
62 ?>
63
Download in other formats: Original Format