openrat-cms

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit ef5abe8d10192170b2b70d383a06336ae26e535b
parent bb407109c6e5b0fd8b3074a0910468542f7ba9f0
Author: dankert <openrat@jandankert.de>
Date:   Sun,  6 Feb 2022 21:56:52 +0100

New CssOutput which outputs the CSS in a cleaner way.

Diffstat:
Mmodules/cms/output/BaseOutput.class.php | 4++++
Amodules/cms/output/CssOutput.class.php | 26++++++++++++++++++++++++++
Mmodules/cms/output/HtmlOutput.class.php | 3---
Mmodules/cms/output/OutputFactory.class.php | 13+++++++++----
Mmodules/cms/ui/action/index/IndexThemestyleAction.class.php | 2--
Dmodules/cms/ui/themes/default/html/views/index/themestyle.php | 2--
Dmodules/cms/ui/themes/default/html/views/index/themestyle.tpl.src.xml | 1-
Dmodules/cms/ui/themes/default/html/views/title/ping.php | 3---
Dmodules/cms/ui/themes/default/html/views/title/ping.tpl.src.xml | 3---
9 files changed, 39 insertions(+), 18 deletions(-)

diff --git a/modules/cms/output/BaseOutput.class.php b/modules/cms/output/BaseOutput.class.php @@ -31,6 +31,10 @@ abstract class BaseOutput implements Output try { $this->beforeAction( $request ); + // special behaviour of UI actions, these are placed in a special package. + if ( in_array( $request->action,['index','tree','title','usergroup']) ) + $request->isUIAction = true; + $dispatcher = new Dispatcher(); $dispatcher->request = $request; diff --git a/modules/cms/output/CssOutput.class.php b/modules/cms/output/CssOutput.class.php @@ -0,0 +1,26 @@ +<?php + +namespace cms\output; + +use cms\output\APIOutput; +use util\json\JSON; +use util\YAML; + +/** + * CSS rendering. + */ +class CssOutput extends APIOutput +{ + /** + * Renders the output as CSS. + */ + protected function renderOutput( $data ) + { + return implode('',$data['output']); + } + + public function getContentType() + { + return 'text/css'; + } +} diff --git a/modules/cms/output/HtmlOutput.class.php b/modules/cms/output/HtmlOutput.class.php @@ -42,9 +42,6 @@ class HtmlOutput extends BaseOutput if ( $request->isAction ) throw new \RuntimeException('The HTML output driver does not accept POST requests'); - if ( in_array( $request->action,['index','tree','title','usergroup']) ) - $request->isUIAction = true; - } diff --git a/modules/cms/output/OutputFactory.class.php b/modules/cms/output/OutputFactory.class.php @@ -13,6 +13,7 @@ class OutputFactory { const OUTPUT_YAML = 5; const OUTPUT_HTML = 6; const OUTPUT_PLAIN = 7; + const OUTPUT_CSS = 8; /** @@ -26,6 +27,7 @@ class OutputFactory { 'yaml' => self::OUTPUT_YAML, 'plain' => self::OUTPUT_PLAIN, 'html' => self::OUTPUT_HTML, + 'css' => self::OUTPUT_CSS, ]; /** @@ -41,7 +43,8 @@ class OutputFactory { 'application/yaml' => self::OUTPUT_YAML, 'application/xhtml+xml' => self::OUTPUT_HTML, 'text/html' => self::OUTPUT_HTML, - '*/*' => self::OUTPUT_HTML, + 'text/css' => self::OUTPUT_CSS, + //'*/*' => self::OUTPUT_HTML, ]; @@ -66,11 +69,13 @@ class OutputFactory { return new XmlOutput(); case self::OUTPUT_YAML: return new YamlOutput(); - case self::OUTPUT_PLAIN: - return new PlainOutput(); case self::OUTPUT_HTML: - default: return new HtmlOutput(); + case self::OUTPUT_CSS: + return new CssOutput(); + case self::OUTPUT_PLAIN: + default: + return new PlainOutput(); } } diff --git a/modules/cms/ui/action/index/IndexThemestyleAction.class.php b/modules/cms/ui/action/index/IndexThemestyleAction.class.php @@ -35,8 +35,6 @@ class IndexThemestyleAction extends IndexAction implements Method { $styleName = $this->request->getText('style'); - header('Content-Type: text/css'); - $this->setTemplateVar('style',$this->getThemeCSS( $styleName) ); } diff --git a/modules/cms/ui/themes/default/html/views/index/themestyle.php b/modules/cms/ui/themes/default/html/views/index/themestyle.php @@ -1 +0,0 @@ -<?php /* THIS FILE IS GENERATED from themestyle.tpl.src.xml - DO NOT CHANGE */ defined('APP_STARTED') || die('Forbidden'); use \template_engine\Output as O; ?><?php echo ''.@$style.'' ?> -\ No newline at end of file diff --git a/modules/cms/ui/themes/default/html/views/index/themestyle.tpl.src.xml b/modules/cms/ui/themes/default/html/views/index/themestyle.tpl.src.xml @@ -1 +0,0 @@ -<text xmlns="http://www.openrat.de/template" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openrat.de/template ../../../../../../../template_engine/components/template.xsd" value="${style}" escape="false" type="none" newline="false"/> diff --git a/modules/cms/ui/themes/default/html/views/title/ping.php b/modules/cms/ui/themes/default/html/views/title/ping.php @@ -1,2 +0,0 @@ -<?php /* THIS FILE IS GENERATED from ping.tpl.src.xml - DO NOT CHANGE */ defined('APP_STARTED') || die('Forbidden'); use \template_engine\Output as O; ?> - <span><?php echo O::escapeHtml('1') ?></span> -\ No newline at end of file diff --git a/modules/cms/ui/themes/default/html/views/title/ping.tpl.src.xml b/modules/cms/ui/themes/default/html/views/title/ping.tpl.src.xml @@ -1,3 +0,0 @@ -<output xmlns="http://www.openrat.de/template" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openrat.de/template ../../../../../../../template_engine/components/template.xsd"> - <text value="1"/> -</output>