From bb587b91163668dc377c6de792bbc66e48016e86 Mon Sep 17 00:00:00 2001 From: nerun Date: Thu, 14 Dec 2023 22:35:00 -0300 Subject: [PATCH] Version 0.8.4: rollback removing #ifemp. Not working. --- CHANGELOG.md | 3 +++ README.md | 2 +- plugin.info.txt | 2 +- syntax.php | 28 +++++++--------------------- 4 files changed, 12 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 345792e..b43b657 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # CHANGELOG +2023-12-14 v0.8.4: +* Rollback: removed `#ifemp`. + 2023-12-09 v0.8.3: * A better fix for "Uninitialized string offset". diff --git a/README.md b/README.md index a7cfffa..e5b4326 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,6 @@ Plugin for [DokuWiki](https://www.dokuwiki.org), available at [plugin: templater Maintainer : Daniel Dias Rodrigues Author : Jonathan Arkell - Current Version : 0.8.3 (2023-12-09) + Current Version : 0.8.4 (2023-12-14) Want to translate this plugin to your language? Go to [DokuWiki Localization](https://translate.dokuwiki.org/plugin/templater). \ No newline at end of file diff --git a/plugin.info.txt b/plugin.info.txt index d6042e2..3509804 100644 --- a/plugin.info.txt +++ b/plugin.info.txt @@ -2,7 +2,7 @@ base templater author Daniel Rodrigues ("Nerun") and Jonathan Arkell. email danieldiasr@gmail.com -date 2023-12-09 +date 2023-12-14 name Templater Plugin desc Displays a wiki page (or a section thereof) within another, with user selectable replacements. url https://www.dokuwiki.org/plugin:templater diff --git a/syntax.php b/syntax.php index 11a76a2..4629607 100644 --- a/syntax.php +++ b/syntax.php @@ -22,14 +22,13 @@ * Ximin Luo * jack126guy * Turq Whiteside - * @version 0.8.3 (2023-12-09) + * @version 0.8.4 (2023-12-14) */ use dokuwiki\File\PageResolver; define('BEGIN_REPLACE_DELIMITER', '@'); define('END_REPLACE_DELIMITER', '@'); -define('CONDITIONAL_CHUNK_DELIMITER', '#ifemp'); require_once('debug.php'); @@ -45,7 +44,7 @@ function getInfo() { return array( 'author' => 'Daniel Dias Rodrigues', 'email' => 'danieldiasr@gmail.com', - 'date' => '2023-12-09', + 'date' => '2023-12-14', 'name' => 'Templater Plugin', 'desc' => 'Displays a wiki page (or a section thereof) within another, with user selectable replacements', 'url' => 'http://www.dokuwiki.org/plugin:templater', @@ -164,12 +163,9 @@ function render($mode, Doku_Renderer $renderer, $data) { // Get the raw file, and parse it into its instructions. This could be cached... maybe. $rawFile = io_readfile($file); - // Split into chunks - $parts = explode(CONDITIONAL_CHUNK_DELIMITER, $rawFile); - // fill in all known values if(!empty($data[1]['keys']) && !empty($data[1]['vals'])) { - $parts = str_replace($data[1]['keys'], $data[1]['vals'], $parts); + $rawFile = str_replace($data[1]['keys'], $data[1]['vals'], $rawFile); } // replace unmatched substitutions with "" or use DEFAULT_STR from data arguments if exists. @@ -177,22 +173,11 @@ function render($mode, Doku_Renderer $renderer, $data) { if(!empty($data[1]['keys']) && !empty($data[1]['vals'])) { $def_key = array_search(BEGIN_REPLACE_DELIMITER."DEFAULT_STR".END_REPLACE_DELIMITER, $data[1]['keys']); - if ($def_key) { - // if caller defined a DEFAULT_STR, use that - $DEFAULT_STR = $def_key ? $data[1]['vals'][$def_key] : ""; - $parts = preg_replace($left_overs, $DEFAULT_STR, $parts); - } - else { - // otherwise remove any chunk with unmatched @placeholder@s, allowing for conditionally including only populated sections - foreach ($parts as $key => $value) { - if (preg_match($left_overs, $value) != 0) { - unset($parts[$key]); - } - } - } + $DEFAULT_STR = $def_key ? $data[1]['vals'][$def_key] : ""; + $rawFile = preg_replace($left_overs, $DEFAULT_STR, $rawFile); } - $instr = p_get_instructions(implode($parts)); + $instr = p_get_instructions($rawFile); // filter section if given if ($data[2]) { @@ -347,3 +332,4 @@ function _massageReplacers($replacers) { } } ?> +