commit 352eed733e1fc7e66409dbf1501de5bd8ed9028e
parent 6e64e322e1cd01ed85d23c02311c848d37425ea2
Author: dankert <openrat@jandankert.de>
Date: Sat, 19 Mar 2022 01:29:19 +0100
Fix: PreviewOutput should inherit from UIOutput.
Diffstat:
4 files changed, 22 insertions(+), 22 deletions(-)
diff --git a/modules/cms/output/APIOutput.class.php b/modules/cms/output/APIOutput.class.php
@@ -79,7 +79,6 @@ abstract class APIOutput extends BaseOutput
protected function outputData($request, $data)
{
$data += [
- 'output' => $data,
'session' => [
'name' => session_name(),
'id' => session_id(),
diff --git a/modules/cms/output/BaseOutput.class.php b/modules/cms/output/BaseOutput.class.php
@@ -24,8 +24,8 @@ abstract class BaseOutput implements Output
/**
* Outputting the data to the client.
* Must be overwritten by subclasses.
- * @param $request Request
- * @param $data data data array
+ * @param $request RequestParams
+ * @param $data array data array
* @return void
*/
abstract protected function outputData($request, $data);
diff --git a/modules/cms/output/CssOutput.class.php b/modules/cms/output/CssOutput.class.php
@@ -3,24 +3,33 @@
namespace cms\output;
use cms\output\APIOutput;
+use Exception;
use util\json\JSON;
use util\YAML;
/**
* CSS rendering.
*/
-class CssOutput extends APIOutput
+class CssOutput extends BaseOutput
{
- /**
- * Renders the output as CSS.
- */
- protected function renderOutput( $data )
+ public function getContentType()
{
- return implode('',$data['output']);
+ return 'text/css';
}
- public function getContentType()
+ protected function outputData($request, $data)
{
- return 'text/css';
+ echo implode('',$data['output'] );
+ }
+
+
+ /**
+ * @param $text string Error Message
+ * @param $cause Exception
+ */
+ protected function setError($text, $cause)
+ {
+ echo "/* CSS Output error */";
+ echo "/* ".$cause->getMessage()." */";
}
}
diff --git a/modules/cms/output/PreviewOutput.class.php b/modules/cms/output/PreviewOutput.class.php
@@ -9,12 +9,9 @@ use util\YAML;
/**
* Preview rendering.
*/
-class PreviewOutput extends APIOutput
+class PreviewOutput extends UIOutput
{
- /**
- * Renders the output directly from the action output.
- */
- protected function renderOutput( $data )
+ protected function outputData($request, $data)
{
// HTTP Spec:
// "Applications SHOULD use this field to indicate the transfer-length of the
@@ -23,11 +20,6 @@ class PreviewOutput extends APIOutput
// And the overhead of 'Transfer-Encoding: chunked' is eliminated...
header('Content-Length: ' . strlen($data['output']['value']));
- return $data['output']['value'];
- }
-
- public function getContentType()
- {
- return null; // 'null' because the actions are setting their Content-Type.
+ echo $data['output']['value'];
}
}