diff options
author | arron.woods <arron.woods@deae1e92-32f9-c189-e222-5b9b5081a27a> | 2011-05-13 18:36:39 +0000 |
---|---|---|
committer | arron.woods <arron.woods@deae1e92-32f9-c189-e222-5b9b5081a27a> | 2011-05-13 18:36:39 +0000 |
commit | 74e2283e0cadf78f716aa613b30660fb0e30df6f (patch) | |
tree | ef1b27d8b89977b1b50e464b91fa44299c8dd299 | |
parent | 075fd46c240da6cae5212811535be106c4581677 (diff) | |
download | php-ssrs-74e2283e0cadf78f716aa613b30660fb0e30df6f.zip php-ssrs-74e2283e0cadf78f716aa613b30660fb0e30df6f.tar.gz php-ssrs-74e2283e0cadf78f716aa613b30660fb0e30df6f.tar.bz2 |
DeviceInfo parameter for render
-rwxr-xr-x | library/SSRS/Report.php | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/library/SSRS/Report.php b/library/SSRS/Report.php index 372f416..52c7396 100755 --- a/library/SSRS/Report.php +++ b/library/SSRS/Report.php @@ -268,12 +268,13 @@ class SSRS_Report { * @param string $PaginationMode * @return SSRS_Object_ReportOutput */ - public function render($format, $PaginationMode='Estimate') { + public function render($format, $deviceInfo = array(), $PaginationMode='Estimate') { $this->checkSessionId(); + $deviceInfo = array('DeviceInfo' => array_merge(array('Toolbar' => 'false'), $deviceInfo)); $renderParams = array( 'Format' => $format, - 'DeviceInfo' => '<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>', + 'DeviceInfo' => $this->renderXmlOptions($deviceInfo), 'PaginationMode' => $PaginationMode ); @@ -293,10 +294,36 @@ class SSRS_Report { /** * Checks to see if the Session ID is not empty and returns boolean value - * + * @return bool */ public function hasValidSessionId() { return (!empty($this->_sessionId)); } + /** + * Takes an array of options and converts them to an XML string recursively + * @param array $options + * @return string $xml + */ + public function renderXmlOptions(array $options) { + $xml = ''; + foreach ($options AS $key => $value) { + switch (true) { + case is_array($value): + $value = $this->renderXmlOptions($value); + break; + case is_bool($value): + $value = ($value) ? 'true' : 'false'; + break; + default: + $value = htmlentities((string) $value); + } + + $key = preg_replace('/[^a-z0-9_\-]+/i', '_', $key); + $xml .= sprintf('<%s>%s</%s>', $key, $value, $key); + } + + return $xml; + } + } |