openrat-cms

# OpenRat Content Management System
git clone http://git.code.weiherhei.de/openrat-cms.git
Log | Files | Refs

commit cef1cc32abde4babafee10e741c108c38c3a840e
parent 15ceb9a6f26ca36b952b571965c57f239c262bd2
Author: Jan Dankert <develop@jandankert.de>
Date:   Sun, 10 Nov 2019 22:07:48 +0100

Refactoring: Macro classes should be able to do a simple 'echo'.

Diffstat:
modules/cms-core/model/Value.class.php | 9+++++++--
modules/cms-macros/macro/RSSReader.class.php | 15++++++++++++---
modules/util/Macro.class.php | 5+++--
modules/wikiparser/renderer/HtmlRenderer.class.php | 12+++++++++---
4 files changed, 31 insertions(+), 10 deletions(-)

diff --git a/modules/cms-core/model/Value.class.php b/modules/cms-core/model/Value.class.php @@ -1329,8 +1329,13 @@ SQL } } - $macro->execute(); - $inhalt .= $macro->getOutput(); + ob_start(); + + $macro->execute(); + + $output = ob_get_contents(); + ob_end_clean(); + $inhalt .= $output; } else { diff --git a/modules/cms-macros/macro/RSSReader.class.php b/modules/cms-macros/macro/RSSReader.class.php @@ -55,7 +55,9 @@ class RSSReader extends Macro function execute() { - // Sessionvariable mit CRC verschluesseln, falls es mehrere RSS-Feeds im Projekt gibt + // TODO: Caching of macro output should be done by the CMS. + + // Sessionvariable mit CRC verschluesseln, falls es mehrere RSS-Feeds im Projekt gibt $sessVar = 'RSSReader_'.crc32($this->url); $cache = $this->getSessionVar( $sessVar ); @@ -67,8 +69,15 @@ class RSSReader extends Macro else { // Wenn Cache leer, dann RSS erzeugen und in Session speichern - $this->create(); - $this->setSessionVar( $sessVar,$this->getOutput() ); + + ob_start(); + $this->create(); + + $output = ob_get_contents(); + ob_end_clean(); + + $this->setSessionVar( $sessVar,$output ); + echo $output; } } diff --git a/modules/util/Macro.class.php b/modules/util/Macro.class.php @@ -135,7 +135,7 @@ class Macro */ public function output( $text ) { - $this->output .= $text; + echo $text; } @@ -144,12 +144,13 @@ class Macro */ public function outputLn( $text ) { - $this->output .= $text."\n"; + echo $text."\n"; } /** * Ermittelt die bisher erstellte Ausgabe. + * @deprecated * @return string */ public function getOutput() diff --git a/modules/wikiparser/renderer/HtmlRenderer.class.php b/modules/wikiparser/renderer/HtmlRenderer.class.php @@ -259,9 +259,15 @@ class HtmlRenderer } - - $macro->execute(); - $val .= $macro->getOutput(); + + ob_start(); + + $macro->execute(); + + $output = ob_get_contents(); + ob_end_clean(); + + $val .= $output; } else {