diff options
author | Arron Woods <aw@chartblocks.com> | 2015-05-20 16:06:53 +0100 |
---|---|---|
committer | Arron Woods <aw@chartblocks.com> | 2015-05-20 16:06:53 +0100 |
commit | 35c2d9628cc4f3faacaf85403606b727b0466cc0 (patch) | |
tree | 9a16f39539403ad27be4346094b7b5849df1b64c /library | |
parent | 482ce747db34349ba131b9b01bc77b18ab6168c9 (diff) | |
download | php-ssrs-35c2d9628cc4f3faacaf85403606b727b0466cc0.zip php-ssrs-35c2d9628cc4f3faacaf85403606b727b0466cc0.tar.gz php-ssrs-35c2d9628cc4f3faacaf85403606b727b0466cc0.tar.bz2 |
ReplacementRoot hack and resource rendering
Diffstat (limited to 'library')
-rw-r--r-- | library/SSRS/Form/Adapter/ZendFramework2.php | 2 | ||||
-rwxr-xr-x | library/SSRS/Object/RenderStream.php | 5 | ||||
-rwxr-xr-x | library/SSRS/Object/ReportOutput.php | 23 | ||||
-rwxr-xr-x | library/SSRS/Report.php | 13 | ||||
-rw-r--r-- | library/SSRS/Report/CachedStreamResource.php | 5 |
5 files changed, 40 insertions, 8 deletions
diff --git a/library/SSRS/Form/Adapter/ZendFramework2.php b/library/SSRS/Form/Adapter/ZendFramework2.php index 26e28a2..316c3f6 100644 --- a/library/SSRS/Form/Adapter/ZendFramework2.php +++ b/library/SSRS/Form/Adapter/ZendFramework2.php @@ -48,7 +48,7 @@ class ZendFramework2 extends AbstractAdapter { foreach ($this->form->getElements() as $key => $element) { $html .= '<div id="' . $key . '" class="element">'; $html .= $formRow->render($element); - $html .= '</div>'; + $html .= '</div>' . PHP_EOL; } $html .= $formRenderer->closeTag(); diff --git a/library/SSRS/Object/RenderStream.php b/library/SSRS/Object/RenderStream.php index 02cbb33..7b10725 100755 --- a/library/SSRS/Object/RenderStream.php +++ b/library/SSRS/Object/RenderStream.php @@ -14,6 +14,11 @@ class RenderStream extends ObjectAbstract { } } + public function send() { + header('Content-Type: ' . $this->MimeType); + echo $this->Result; + } + public function __toString() { return $this->Result; } diff --git a/library/SSRS/Object/ReportOutput.php b/library/SSRS/Object/ReportOutput.php index 70d7928..7522edd 100755 --- a/library/SSRS/Object/ReportOutput.php +++ b/library/SSRS/Object/ReportOutput.php @@ -4,9 +4,15 @@ namespace SSRS\Object; use SSRS\Report; use SSRS\Report\CachedStreamResource; +use SSRS\Object\ExecutionInfo; class ReportOutput extends ObjectAbstract { + public function __construct($data = null, ExecutionInfo $executionInfo = null) { + parent::__construct($data); + $this->executionInfo = $executionInfo; + } + public function preCacheStreams(Report $report, $localCachePath, $format = 'HTML4.0') { $this->verifyCachePath($localCachePath); @@ -42,8 +48,23 @@ class ReportOutput extends ObjectAbstract { exit(0); } + public function resultClean() { + $output = (string) $this->Result; + $clean = $this->convertReplacementRootUrls($output); + + return $clean; + } + + protected function convertReplacementRootUrls($output) { + $executionId = ($this->executionInfo) ? $this->executionInfo->getExecutionId() : null; + + return preg_replace_callback('#href="//php-ssrs//([^\?]+)([^"]+)"#', function($results) use($executionId) { + return 'href="' . html_entity_decode(urldecode($results[2])) . '&executionId=' . $executionId . '"'; + }, $output); + } + public function __toString() { - return (string) $this->Result; + return $this->resultClean(); } protected function verifyCachePath($path) { diff --git a/library/SSRS/Report.php b/library/SSRS/Report.php index 2333d3a..71d786e 100755 --- a/library/SSRS/Report.php +++ b/library/SSRS/Report.php @@ -65,6 +65,7 @@ class Report { $defaults = array( 'cache_wsdl_path' => null, 'curl_options' => array(), + 'hijackActionUrls' => false ); $this->options = array_merge($defaults, $options); @@ -340,16 +341,22 @@ class Report { */ public function render($format, $deviceInfo = array(), $PaginationMode = 'Estimate') { $this->checkSessionId(); - $deviceInfo = array('DeviceInfo' => $deviceInfo); + + $deviceInfoDefaults = array(); + if ($this->options['hijackActionUrls']) { + $deviceInfoDefaults['ReplacementRoot'] = '//php-ssrs//'; + } + + $deviceInfoTree = array('DeviceInfo' => array_merge($deviceInfoDefaults, $deviceInfo)); $renderParams = array( 'Format' => $format, - 'DeviceInfo' => $this->renderDeviceInfo($deviceInfo), + 'DeviceInfo' => $this->renderDeviceInfo($deviceInfoTree), 'PaginationMode' => $PaginationMode ); $result = $this->getSoapExecution()->Render2($renderParams); - return new ReportOutput($result); + return new ReportOutput($result, $this->getExecutionInfo()); } /** diff --git a/library/SSRS/Report/CachedStreamResource.php b/library/SSRS/Report/CachedStreamResource.php index 013eaee..949c6d7 100644 --- a/library/SSRS/Report/CachedStreamResource.php +++ b/library/SSRS/Report/CachedStreamResource.php @@ -39,9 +39,8 @@ class CachedStreamResource { public function send() { $stream = $this->read(); - - header('Content-Type: ' . $stream->MimeType); - echo $stream->Result; + $stream->send(); + return $this; } } |