openrat-cms

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

commit c122f04ac950924aac55b8e101b2fa9a0889b254
parent 8f7f20f0911cf0ff5c71fca6c75a3634a475ebbc
Author: Jan Dankert <develop@jandankert.de>
Date:   Sun, 10 Nov 2019 23:21:56 +0100

New: Parse the macro settings as YAML.

Diffstat:
modules/cms-core/model/BaseObject.class.php | 2+-
modules/cms-core/model/Element.class.php | 22++++++----------------
modules/cms-macros/macro/RSSReader.class.php | 1+
3 files changed, 8 insertions(+), 17 deletions(-)

diff --git a/modules/cms-core/model/BaseObject.class.php b/modules/cms-core/model/BaseObject.class.php @@ -1333,7 +1333,7 @@ SQL */ public function getSettings() { - return Spyc::YAMLLoad($this->settings); + return Spyc::YAMLLoadString($this->settings); } diff --git a/modules/cms-core/model/Element.class.php b/modules/cms-core/model/Element.class.php @@ -2,6 +2,8 @@ namespace cms\model; +use Logger; + /** * Diese Objektklasse stellt ein Element das. * @@ -531,25 +533,13 @@ SQL function getDynamicParameters() { - $parameters = explode( "\n",$this->code ); - $items = array(); + // Fixing old syntax ("key:value") to valid YAML syntax. + $this->code = preg_replace( '/^(\w+)\:(.+)$/m','${1}: ${2}', $this->code ); - foreach( $parameters as $it ) - { - $paar = explode( ":",$it,2 ); - if ( count($paar) > 1 ) - { - $param_name = trim($paar[0]); - $param_value = trim($paar[1]); + $items = \Spyc::YAMLLoadString( $this->code ); -// // Wenn Inhalt mit "'" beginnt und mit "'" aufhoert, dann diese Zeichen abschneiden -// if ( substr($param_value,0,1) == "'" && substr($param_value,strlen($param_value)-1,1) == "'" ) -// $param_value = substr($param_value,1,strlen($param_value)-2); + Logger::trace('dynamic-parameters: '.print_r($items,true)); - if ( !empty($param_value) ) - $items[$param_name] = $param_value; - } - } return $items; } diff --git a/modules/cms-macros/macro/RSSReader.class.php b/modules/cms-macros/macro/RSSReader.class.php @@ -138,6 +138,7 @@ class RSSReader extends Macro $arr["generator"] = $sarr[1]; // Strip items $parts = explode("<item>", $feed); + $items = array(); foreach($parts as $part) { $item = substr($part, 0, strpos($part, "</item>"));