blob: 60a09a2253f29773f61e56ae04d7a56ab5b56c91 (
plain)
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
<?php
namespace SSRS\Object;
use SSRS\Object\ReportParameter\ValidValue;
class ReportParameter extends ObjectAbstract {
public function __construct($name, $value) {
$this->name = $name;
$this->value = $value;
}
public $name;
public $value;
/**
*
* @return array
*/
public function getDefaultValue() {
$defaults = array();
if (key_exists('DefaultValues', $this->data) && isset($this->data['DefaultValues']->Value)) {
$defaults = (array) $this->data['DefaultValues']->Value;
}
if ($this->isSelect()) {
$validValues = array();
foreach ($this->getValidValues() AS $validValue) {
$validValues[] = $validValue->Value;
}
$defaults = array_intersect($defaults, $validValues);
}
return $defaults;
}
public function setValidValues($validValues) {
if ($validValues instanceof \stdClass && isset($validValues->ValidValue) && is_object($validValues->ValidValue)) {
$validValues = array($validValues->ValidValue);
} elseif ($validValues instanceof \stdClass && isset($validValues->ValidValue)) {
$validValues = $validValues->ValidValue;
}
$data = array();
foreach ($validValues AS $value) {
if (is_object($value)) {
$data[] = new ValidValue((string) $value->Label, (string) $value->Value);
} elseif (is_array($value)) {
$data[] = new ValidValue((string) $value['Label'], (string) $value['Value']);
} else {
$data[] = new ValidValue((string) $value, (string) $value);
}
}
$this->data['ValidValues'] = $data;
return $this;
}
/**
*
* @return \SSRS_Object_ReportParameter_ValidValue[]
*/
public function getValidValues() {
return empty($this->data['ValidValues']) ? array() : $this->data['ValidValues'];
}
/**
*
* @return bool
*/
public function hasDependencies() {
return (isset($this->data['Dependencies']->Dependency) && !empty($this->data['Dependencies']->Dependency));
}
/**
*
* @return bool
*/
public function getDependencies() {
return (array) $this->data['Dependencies']->Dependency;
}
/**
*
* @return bool
*/
public function hasOutstandingDependencies() {
return ($this->getState() == 'HasOutstandingDependencies');
}
/**
*
* @return bool
*/
public function getState() {
return key_exists('State', $this->data) ? $this->data['State'] : null;
}
/**
*
* @return bool
*/
public function isMultiValue() {
return !empty($this->data['MultiValue']);
}
/**
*
* @return bool
*/
public function isSelect() {
return ($this->isMultiValue() || (!empty($this->data['ValidValues']) && is_array($this->data['ValidValues']) && count($this->data['ValidValues']) > 0));
}
}
|