From dc999c1b78ffe97b43e77414f0b8b2e0156314db Mon Sep 17 00:00:00 2001 From: nerun Date: Fri, 25 Nov 2022 14:35:50 -0300 Subject: [PATCH] Better fix for template > page # section doesn't exist with error message. Updated error messages to look better. Updated english and brazilian portuguese translations. --- CHANGELOG.md | 5 +++++ README.md | 2 +- templater/lang/en/lang.php | 13 ++++++------ templater/lang/pt-br/lang.php | 13 ++++++------ templater/plugin.info.txt | 2 +- templater/syntax.php | 39 ++++++++++++++++++++++++----------- 6 files changed, 48 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d8d7c1..869047a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # CHANGELOG +2022-11-25a v0.5.2 +* Better fix for `{{template>page#section}}` doesn't exist with error message +* Updated error messages to look better +* Updated english and brazilian portuguese translations + 2022-11-25 v0.5.1 * Internationalization: added lang/en and lang/pt-br * Bug fix for when `{{template>page#section}}` doesn't exist diff --git a/README.md b/README.md index afdd7f6..b1263be 100644 --- a/README.md +++ b/README.md @@ -5,4 +5,4 @@ Plugin for [DokuWiki](https://www.dokuwiki.org), available at [plugin: templater Author : Jonathan Arkell Updater : Daniel Dias Rodrigues - Current Version : 0.5.1 (2022-11-25) + Current Version : 0.5.2 (2022-11-25a) diff --git a/templater/lang/en/lang.php b/templater/lang/en/lang.php index c743d9b..7751a2c 100644 --- a/templater/lang/en/lang.php +++ b/templater/lang/en/lang.php @@ -1,11 +1,12 @@ */ -$lang['template_not_found'] = 'Template "%1$s" not found. '; -$lang['click_create'] = '[Click here to create it]'; -$lang['click_edit'] = '[Click here to edit it]'; -$lang['stopped_recursion'] = 'Processing of template "%1$s" stopped due to recursion. '; -$lang['no_permissions_view'] = '
No permissions to view the template
'; +$lang['template'] = '— Template '; +$lang['not_found'] = ' not found.'; +$lang['processing_template'] = '— Processing of template '; +$lang['stopped_recursion'] = ' stopped due to recursion.'; +$lang['no_permissions_view'] = '
No permissions to view the template
'; +$lang['no_such_section'] = '
— There\'s no such section "%1$s" in the page '; diff --git a/templater/lang/pt-br/lang.php b/templater/lang/pt-br/lang.php index b0a93b4..543c000 100644 --- a/templater/lang/pt-br/lang.php +++ b/templater/lang/pt-br/lang.php @@ -1,11 +1,12 @@ */ -$lang['template_not_found'] = 'O template "%1$s" não foi encontrado. '; -$lang['click_create'] = '[Clique aqui para criá-lo]'; -$lang['click_edit'] = '[Clique aqui para editá-lo]'; -$lang['stopped_recursion'] = 'O processamento do template "%1$s" foi interrompido devido à recursão. '; -$lang['no_permissions_view'] = '
Sem permissões para visualizar o template
'; +$lang['template'] = '— O template '; +$lang['not_found'] = ' não foi encontrado.'; +$lang['processing_template'] = '— O processamento do template '; +$lang['stopped_recursion'] = ' foi interrompido devido à recursão.'; +$lang['no_permissions_view'] = '
Sem permissões para visualizar o template
'; +$lang['no_such_section'] = '
— Não há nenhuma seção "%1$s" na página '; diff --git a/templater/plugin.info.txt b/templater/plugin.info.txt index 5a2e777..4bff4cc 100644 --- a/templater/plugin.info.txt +++ b/templater/plugin.info.txt @@ -2,7 +2,7 @@ base templater author Jonathan Arkell (updated by Daniel Dias Rodrigues) email jonnay@jonnay.net -date 2022-11-25 +date 2022-11-25a 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/templater/syntax.php b/templater/syntax.php index 53a011e..67d3f3a 100644 --- a/templater/syntax.php +++ b/templater/syntax.php @@ -21,7 +21,7 @@ * with bugfix from Ximin Luo * Daniel Dias Rodrigues (aka Nerun) * with one bugfix from jack126guy - * @version 0.5.1 (2022-11-25) + * @version 0.5.2 (2022-11-25a) */ define('BEGIN_REPLACE_DELIMITER', '@'); @@ -43,7 +43,7 @@ function getInfo() { return array( 'author' => 'Jonathan Arkell (updated by Daniel Dias Rodrigues)', 'email' => 'jonnay@jonnay.net', - 'date' => '2022-11-25', + 'date' => '2022-11-25a', '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', @@ -134,16 +134,18 @@ function render($mode, Doku_Renderer $renderer, $data) { $file = wikiFN($data[0]); if (!@file_exists($file)) { $renderer->doc .= '
'; - $renderer->doc .= sprintf($this->getLang('template_not_found'), $data[0]); - $renderer->internalLink($data[0], $this->getLang('click_create')); - $renderer->doc .= '
'; + $renderer->doc .= $this->getLang('template'); + $renderer->internalLink($data[0]); + $renderer->doc .= $this->getLang('not_found'); + $renderer->doc .= '

'; $renderer->info['cache'] = FALSE; return true; } else if (array_search($data[0], self::$pagestack) !== false) { $renderer->doc .= '
'; - $renderer->doc .= sprintf($this->getLang('stopped_recursion'), $data[0]); - $renderer->internalLink($data[0], $this->getLang('click_edit')); - $renderer->doc .= '
'; + $renderer->doc .= $this->getLang('processing_template'); + $renderer->internalLink($data[0]); + $renderer->doc .= $this->getLang('stopped_recursion'); + $renderer->doc .= '

'; return true; } self::$pagestack[] = $data[0]; // push this onto the stack @@ -166,8 +168,15 @@ function render($mode, Doku_Renderer $renderer, $data) { $instr = p_get_instructions($rawFile); // filter section if given - if ($data[2]) - $instr = $this->_getSection($data[2], $instr); + if ($data[2]) { + $getSection[] = $this->_getSection($data[2], $instr); + $instr = $getSection[0][0]; + if(!is_null($getSection[0][1])) { + $renderer->doc .= sprintf($getSection[0][1], $data[2]); + $renderer->internalLink($data[0]); + $renderer->doc .= '.

'; + } + } // correct relative internal links and media $instr = $this->_correctRelNS($instr, $data[0]); @@ -228,8 +237,14 @@ function _getSection($title, $instructions) { // Fix for when page#section doesn't exist if(!isset($i)) { $i[] = $instruction; - } - return $i; + $no_section = $this->getLang('no_such_section'); + } else { + $no_section = null; + } + + $array_i_nosection = array($i,$no_section); + + return $array_i_nosection; } /**