-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbitrix-option.php
More file actions
76 lines (60 loc) · 1.86 KB
/
bitrix-option.php
File metadata and controls
76 lines (60 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
/*
Получение опций
Указываются опции через STD_IN (с новой строки), и/или через перечисление в параметрах
*/
namespace Bitrixcli;
require(__DIR__ . '/lib/cli-cms.php');
class OptionCli extends BitrixCli {
protected $options = array(), $item;
public static $cliParams = array(
'noVal' // без значения
=> array(),
'val' // со значением
=> array('o' => 'option', 'v' => 'view', 'f' => 'format'),
'optionVal' // с необязательным значением
=> array(),
)
;
public function __construct($BitrixCMS) {
die('TODO'); // передача модуля и опции
parent::__construct($BitrixCMS);
}
public function run() {
try {
$this->getParms();
$this->outputElements();
} catch (Exception $e) {
$this->error($e);
}
}
protected function getParms() {
$params = $this->getCliParms();
if(isset($params['o'])) {
$this->options = array_merge($this->options, (array)$params['o']);
}
if(isset($params['option'])) {
$this->options = array_merge($this->options, (array)$params['option']);
}
$options = $this->getStdinStrParms();
$this->options = array_merge($this->options, $options);
if(count($this->options) == 0) throw new Exception('No options', 1);
}
protected $viewFormat = 'option';
protected function outputElements() {
$view = $this->getViewFormat();
foreach($this->options as $opt) {
$this->getOpt($opt);
if(isset($this->item)) {
$DataView = new DataView($this->item);
$DataView->view($view);
}
}
}
// TODO
protected function getOpt($name) {
$this->item = \COption::GetOptionString($moduleName, $name, '');
}
}
$OptionCli = new OptionCli($BitrixCMS);
$OptionCli->run();