summaryrefslogtreecommitdiffstats
path: root/library/SSRS/Object
diff options
context:
space:
mode:
Diffstat (limited to 'library/SSRS/Object')
-rwxr-xr-xlibrary/SSRS/Object/Abstract.php60
-rwxr-xr-xlibrary/SSRS/Object/ArrayIterator.php41
-rwxr-xr-xlibrary/SSRS/Object/CatalogItem.php10
-rwxr-xr-xlibrary/SSRS/Object/CatalogItems.php29
-rwxr-xr-xlibrary/SSRS/Object/ExecutionInfo.php103
-rwxr-xr-xlibrary/SSRS/Object/ExecutionParameters.php52
-rwxr-xr-xlibrary/SSRS/Object/Extension.php10
-rwxr-xr-xlibrary/SSRS/Object/Extensions.php26
-rwxr-xr-xlibrary/SSRS/Object/ItemDefinition.php22
-rw-r--r--library/SSRS/Object/Properties.php58
-rwxr-xr-xlibrary/SSRS/Object/RenderStream.php22
-rwxr-xr-xlibrary/SSRS/Object/ReportOutput.php28
-rwxr-xr-xlibrary/SSRS/Object/ReportParameter.php120
-rw-r--r--library/SSRS/Object/ReportParameter/ValidValue.php20
14 files changed, 601 insertions, 0 deletions
diff --git a/library/SSRS/Object/Abstract.php b/library/SSRS/Object/Abstract.php
new file mode 100755
index 0000000..4658b48
--- /dev/null
+++ b/library/SSRS/Object/Abstract.php
@@ -0,0 +1,60 @@
+<?php
+
+/**
+ * SSRS_Object_Abstract
+ *
+ * @author arron
+ */
+class SSRS_Object_Abstract {
+
+ public $data = array();
+
+ public function __construct($data = null) {
+ $this->init();
+ $this->setData($data);
+ }
+
+ public function init() {
+
+ }
+
+ public function setData($data) {
+ $clean = $this->_sanitizeData($data);
+
+ if (is_array($clean)) {
+ foreach ($clean AS $key => $value) {
+ $this->$key = $value;
+ }
+ }
+
+ return $this;
+ }
+
+ public function __set($key, $value) {
+ $methodName = 'set' . ucfirst($key);
+ if (method_exists($this, $methodName)) {
+ $this->$methodName($value);
+ } else {
+ $this->data[$key] = $value;
+ }
+ }
+
+ protected function _sanitizeData($data, $recursive = false) {
+ if (is_object($data)) {
+ $data = get_object_vars($data);
+ }
+
+ if ($recursive && is_array($data)) {
+ foreach ($data AS $key => $value) {
+ $data[$key] = $this->_sanitizeData($value);
+ }
+ }
+
+ return $data;
+ }
+
+ public function __get($key) {
+ return isset($this->data[$key]) ? $this->data[$key] : null;
+ }
+
+} \ No newline at end of file
diff --git a/library/SSRS/Object/ArrayIterator.php b/library/SSRS/Object/ArrayIterator.php
new file mode 100755
index 0000000..ad53ad5
--- /dev/null
+++ b/library/SSRS/Object/ArrayIterator.php
@@ -0,0 +1,41 @@
+<?php
+
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+/**
+ * Description of Iterator
+ *
+ * @author andrew
+ */
+class SSRS_Object_ArrayIterator extends SSRS_Object_Abstract implements Iterator {
+
+ public $iteratorKey = 'Array';
+
+ public function next() {
+ return next($this->data[$this->iteratorKey]);
+ }
+
+ public function prev() {
+ return prev($this->data[$this->iteratorKey]);
+ }
+
+ public function key() {
+ return key($this->data[$this->iteratorKey]);
+ }
+
+ public function current() {
+ return current($this->data[$this->iteratorKey]);
+ }
+
+ public function valid() {
+ return isset($this->data[$this->iteratorKey][$this->key()]);
+ }
+
+ public function rewind() {
+ return reset($this->data[$this->iteratorKey]);
+ }
+
+} \ No newline at end of file
diff --git a/library/SSRS/Object/CatalogItem.php b/library/SSRS/Object/CatalogItem.php
new file mode 100755
index 0000000..cf0e25d
--- /dev/null
+++ b/library/SSRS/Object/CatalogItem.php
@@ -0,0 +1,10 @@
+<?php
+
+/**
+ * SSRS_Object_Abstract
+ *
+ * @author arron
+ */
+class SSRS_Object_CatalogItem extends SSRS_Object_Abstract {
+
+}
diff --git a/library/SSRS/Object/CatalogItems.php b/library/SSRS/Object/CatalogItems.php
new file mode 100755
index 0000000..ac16f77
--- /dev/null
+++ b/library/SSRS/Object/CatalogItems.php
@@ -0,0 +1,29 @@
+<?php
+
+/**
+ * SSRS_Object_Abstract
+ *
+ * @author arron
+ */
+
+require_once('ArrayIterator.php');
+
+class SSRS_Object_CatalogItems extends SSRS_Object_ArrayIterator {
+
+ public $iteratorKey = 'CatalogItems';
+
+ public function init() {
+ $this->data['CatalogItems'] = array();
+ }
+
+ public function setCatalogItems(stdClass $items) {
+ foreach ($items->CatalogItem AS $item) {
+ $this->addCatalogItem(new SSRS_Object_CatalogItem($item));
+ }
+ }
+
+ public function addCatalogItem(SSRS_Object_CatalogItem $item) {
+ $this->data['CatalogItems'][] = $item;
+ }
+
+}
diff --git a/library/SSRS/Object/ExecutionInfo.php b/library/SSRS/Object/ExecutionInfo.php
new file mode 100755
index 0000000..1087e3f
--- /dev/null
+++ b/library/SSRS/Object/ExecutionInfo.php
@@ -0,0 +1,103 @@
+<?php
+
+/**
+ * SSRS_Object_Abstract
+ *
+ * @author arron
+ */
+class SSRS_Object_ExecutionInfo extends SSRS_Object_Abstract {
+
+ /**
+ * Copy of self for backwards compatibility
+ *
+ * @var SSRS_Object_ExecutionInfo
+ */
+ public $executionInfo;
+
+ public function __construct(stdClass $info = null) {
+ if ($info) {
+ $this->setData($info->executionInfo);
+ }
+
+ $this->executionInfo = $this;
+ }
+
+ public function getExecutionId() {
+ return empty($this->data['ExecutionID']) ? null : $this->data['ExecutionID'];
+ }
+
+ public function getExpirationTimestamp() {
+ return strtotime($this->data['ExpirationDateTime']);
+ }
+
+ public function setParameters(stdClass $params) {
+ return $this->setReportParameters($params);
+ }
+
+ public function setReportParameters($reportParameters) {
+ $parameters = array();
+
+ if ($reportParameters instanceof stdClass) {
+ $reportParameters = isset($reportParameters->ReportParameter) ? $reportParameters->ReportParameter : array();
+ $reportParameters = is_array($reportParameters) ? $reportParameters : array($reportParameters);
+ }
+
+ foreach ($reportParameters AS $reportParam) {
+ if (is_object($reportParam)) {
+ $data = array(
+ 'name' => $reportParam->Name,
+ 'value' => isset($reportParam->Value) ? $reportParam->Value : null
+ );
+ } else {
+ $data = $reportParam;
+ }
+
+ $parameter = new SSRS_Object_ReportParameter($data['name'], $data['value']);
+ $parameter->setData($reportParam);
+
+ $parameters[] = $parameter;
+ }
+
+ $this->data['ReportParameters'] = $parameters;
+ return $this;
+ }
+
+ public function getReportPath() {
+ return $this->data['ReportPath'];
+ }
+
+ /**
+ * Returns all report parameters in an array
+ *
+ * @return array parameters
+ *
+ */
+ public function getReportParameters() {
+ return $this->data['ReportParameters'];
+ }
+
+ public function getReportParameter($name) {
+ $parameters = $this->getReportParameters();
+ foreach ($parameters AS $parameter) {
+ if ($parameter->name === $name) {
+ return $parameter;
+ }
+ }
+
+ return null;
+ }
+
+ public function __sleep() {
+ $this->executionInfo = null;
+ return array('data');
+ }
+
+ public function __wakeup() {
+ //$this->executionInfo = $this;
+ }
+
+ public function getPageCount() {
+ return isset($this->data['NumPages']) ? $this->data['NumPages'] : 1;
+ }
+
+} \ No newline at end of file
diff --git a/library/SSRS/Object/ExecutionParameters.php b/library/SSRS/Object/ExecutionParameters.php
new file mode 100755
index 0000000..bf3b819
--- /dev/null
+++ b/library/SSRS/Object/ExecutionParameters.php
@@ -0,0 +1,52 @@
+<?php
+
+/**
+ * Description of ExecutionParameters
+ *
+ * @author andrew
+ */
+class SSRS_Object_ExecutionParameters extends SSRS_Object_ArrayIterator {
+
+ public $iteratorKey = 'Parameters';
+
+ public function __construct(array $parameters = array()) {
+ parent::__construct(null);
+ $this->setParameters($parameters);
+ }
+
+ public function init() {
+ $this->data['Parameters'] = array();
+ }
+
+ public function setParameters(array $parameters) {
+ $this->data['Parameters'] = array();
+
+ foreach ($parameters AS $key => $parameter) {
+ if (($parameter instanceof SSRS_Object_ReportParameter) === false) {
+ $values = (array) $parameter;
+ foreach ($values AS $value) {
+ $this->data['Parameters'][] = new SSRS_Object_ReportParameter($key, $value);
+ }
+ } else {
+ $this->data['Parameters'][] = $parameter;
+ }
+ }
+ }
+
+ public function getParameters() {
+ return $this->data['Parameters'];
+ }
+
+ public function getParameterArrayForSoapCall() {
+ $execParams = array();
+ foreach ($this->getParameters() AS $parameter) {
+ $execParams[] = array(
+ 'Name' => $parameter->name,
+ 'Value' => $parameter->value,
+ );
+ }
+
+ return $execParams;
+ }
+
+}
diff --git a/library/SSRS/Object/Extension.php b/library/SSRS/Object/Extension.php
new file mode 100755
index 0000000..efae2dd
--- /dev/null
+++ b/library/SSRS/Object/Extension.php
@@ -0,0 +1,10 @@
+<?php
+
+/**
+ * SSRS_Object_Abstract
+ *
+ * @author arron
+ */
+class SSRS_Object_Extension extends SSRS_Object_Abstract {
+
+}
diff --git a/library/SSRS/Object/Extensions.php b/library/SSRS/Object/Extensions.php
new file mode 100755
index 0000000..786c1b6
--- /dev/null
+++ b/library/SSRS/Object/Extensions.php
@@ -0,0 +1,26 @@
+<?php
+
+/**
+ * SSRS_Object_Abstract
+ *
+ * @author arron
+ */
+class SSRS_Object_Extensions extends SSRS_Object_ArrayIterator {
+
+ public $iteratorKey = 'Extension';
+
+ public function init() {
+ $this->data['Extension'] = array();
+ }
+
+ public function setExtensions(stdClass $items) {
+ foreach ($items->Extension AS $item) {
+ $this->addExtension(new SSRS_Object_Extension($item));
+ }
+ }
+
+ public function addExtension(SSRS_Object_Extension $item) {
+ $this->data['Extension'][] = $item;
+ }
+
+}
diff --git a/library/SSRS/Object/ItemDefinition.php b/library/SSRS/Object/ItemDefinition.php
new file mode 100755
index 0000000..f63d57e
--- /dev/null
+++ b/library/SSRS/Object/ItemDefinition.php
@@ -0,0 +1,22 @@
+<?php
+
+/**
+ * Description of ExecutionParameters
+ *
+ * @author andrew
+ */
+class SSRS_Object_ItemDefinition extends SSRS_Object_Abstract {
+
+ public function getXMLString() {
+ return $this->Definition;
+ }
+
+ public function getSimpleXML() {
+ return new SimpleXMLElement($this->getXMLString());
+ }
+
+ public function __toString() {
+ return $this->getXMLString();
+ }
+
+}
diff --git a/library/SSRS/Object/Properties.php b/library/SSRS/Object/Properties.php
new file mode 100644
index 0000000..6765450
--- /dev/null
+++ b/library/SSRS/Object/Properties.php
@@ -0,0 +1,58 @@
+<?php
+
+class SSRS_Object_Properties {
+
+ protected $_properties = array();
+
+ public function __construct($properties = array()) {
+ $this->addProperties($properties);
+ }
+
+ public function __get($name){
+ return $this->getProperty($name);
+ }
+
+ /**
+ *
+ * @param array $properties
+ */
+ public function addProperties(array $properties) {
+ foreach ($properties AS $key => $value) {
+ if (is_object($value) && isset($value->Name)) {
+ $key = $value->Name;
+ $value = isset($value->Value)? $value->Value : null;
+ }
+
+ $this->addProperty($key, $value);
+ }
+ }
+
+ /**
+ *
+ * @param string $key
+ * @param mixed $value
+ * @return \SSRS_Object_Properties
+ */
+ public function addProperty($key, $value) {
+ $this->_properties[$key] = $value;
+ return $this;
+ }
+
+ /**
+ *
+ * @return array
+ */
+ public function getProperties() {
+ return $this->_properties;
+ }
+
+ /**
+ *
+ * @param string $key
+ * @return mixed
+ */
+ public function getProperty($key) {
+ return array_key_exists($key, $this->_properties) ? $this->_properties[$key] : null;
+ }
+
+} \ No newline at end of file
diff --git a/library/SSRS/Object/RenderStream.php b/library/SSRS/Object/RenderStream.php
new file mode 100755
index 0000000..a1027f8
--- /dev/null
+++ b/library/SSRS/Object/RenderStream.php
@@ -0,0 +1,22 @@
+<?php
+
+/**
+ * SSRS_Object_RenderStream
+ *
+ * @author arron
+ */
+class SSRS_Object_RenderStream extends SSRS_Object_Abstract {
+
+ public $Result;
+ public $MimeType;
+
+ public function __construct(stdClass $stream) {
+ $this->Result = $stream->Result;
+ $this->MimeType = $stream->MimeType;
+ }
+
+ public function __toString() {
+ return $this->Result;
+ }
+
+} \ No newline at end of file
diff --git a/library/SSRS/Object/ReportOutput.php b/library/SSRS/Object/ReportOutput.php
new file mode 100755
index 0000000..208a638
--- /dev/null
+++ b/library/SSRS/Object/ReportOutput.php
@@ -0,0 +1,28 @@
+<?php
+
+/**
+ * Description of ExecutionParameters
+ *
+ * @author andrew
+ */
+class SSRS_Object_ReportOutput extends SSRS_Object_Abstract {
+
+ public function download($filename) {
+ header("Cache-control: max-age=3600, must-revalidate");
+ header("Pragma: public");
+ header("Expires: -1");
+ header("Content-Description: File Transfer");
+ header('Content-Disposition: attachment; filename="' . $filename . '"');
+ header("Content-Type: " . $this->MimeType);
+ header("Content-Transfer-Encoding: binary");
+ header("Content-Length: " . strlen($this->Result));
+
+ echo($this->Result);
+ exit(0);
+ }
+
+ public function __toString() {
+ return (string) $this->Result;
+ }
+
+}
diff --git a/library/SSRS/Object/ReportParameter.php b/library/SSRS/Object/ReportParameter.php
new file mode 100755
index 0000000..9f1e77e
--- /dev/null
+++ b/library/SSRS/Object/ReportParameter.php
@@ -0,0 +1,120 @@
+<?php
+
+/**
+ * Description of ExecutionParameters
+ *
+ * @author andrew
+ */
+class SSRS_Object_ReportParameter extends SSRS_Object_Abstract {
+
+ 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 SSRS_Object_ReportParameter_ValidValue((string) $value->Label, (string) $value->Value);
+ } elseif (is_array($value)) {
+ $data[] = new SSRS_Object_ReportParameter_ValidValue((string) $value['Label'], (string) $value['Value']);
+ } else {
+ $data[] = new SSRS_Object_ReportParameter_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));
+ }
+
+}
diff --git a/library/SSRS/Object/ReportParameter/ValidValue.php b/library/SSRS/Object/ReportParameter/ValidValue.php
new file mode 100644
index 0000000..b75b07e
--- /dev/null
+++ b/library/SSRS/Object/ReportParameter/ValidValue.php
@@ -0,0 +1,20 @@
+<?php
+
+class SSRS_Object_ReportParameter_ValidValue {
+
+ /**
+ * capitals because of SSRS!
+ */
+ public $Value;
+ public $Label;
+
+ public function __construct($label, $value) {
+ $this->Value = $value;
+ $this->Label = $label;
+ }
+
+ public function __toString() {
+ return $this->Value;
+ }
+
+} \ No newline at end of file