Skip to content

Commit

Permalink
Better fix for template > page # section doesn't exist with error mes…
Browse files Browse the repository at this point in the history
…sage.

Updated error messages to look better.
Updated english and brazilian portuguese translations.
  • Loading branch information
nerun committed Nov 25, 2022
1 parent 0837875 commit dc999c1
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 26 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
13 changes: 7 additions & 6 deletions templater/lang/en/lang.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<?php
/**
* English language file for template plugin
* English language file for templater plugin
*
* @author Daniel Dias Rodrigues <danieldiasr@gmail.com>
*/
$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'] = '<div class="template"> No permissions to view the template </div>';
$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'] = '<div class="templater"> No permissions to view the template </div>';
$lang['no_such_section'] = '<div class="templater">— There\'s no such section "%1$s" in the page ';
13 changes: 7 additions & 6 deletions templater/lang/pt-br/lang.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<?php
/**
* Brazilian portuguese language file for template plugin
* Brazilian portuguese language file for templater plugin
*
* @author Daniel Dias Rodrigues <danieldiasr@gmail.com>
*/
$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'] = '<div class="template"> Sem permissões para visualizar o template </div>';
$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'] = '<div class="templater"> Sem permissões para visualizar o template </div>';
$lang['no_such_section'] = '<div class="templater">— Não há nenhuma seção "%1$s" na página ';
2 changes: 1 addition & 1 deletion templater/plugin.info.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
39 changes: 27 additions & 12 deletions templater/syntax.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* with bugfix from Ximin Luo <xl269@cam.ac.uk>
* Daniel Dias Rodrigues (aka Nerun) <danieldiasr@gmail.com>
* with one bugfix from jack126guy <halfgray7e@gmail.com>
* @version 0.5.1 (2022-11-25)
* @version 0.5.2 (2022-11-25a)
*/

define('BEGIN_REPLACE_DELIMITER', '@');
Expand All @@ -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',
Expand Down Expand Up @@ -134,16 +134,18 @@ function render($mode, Doku_Renderer $renderer, $data) {
$file = wikiFN($data[0]);
if (!@file_exists($file)) {
$renderer->doc .= '<div class="templater">';
$renderer->doc .= sprintf($this->getLang('template_not_found'), $data[0]);
$renderer->internalLink($data[0], $this->getLang('click_create'));
$renderer->doc .= '</div>';
$renderer->doc .= $this->getLang('template');
$renderer->internalLink($data[0]);
$renderer->doc .= $this->getLang('not_found');
$renderer->doc .= '<br/><br/></div>';
$renderer->info['cache'] = FALSE;
return true;
} else if (array_search($data[0], self::$pagestack) !== false) {
$renderer->doc .= '<div class="templater">';
$renderer->doc .= sprintf($this->getLang('stopped_recursion'), $data[0]);
$renderer->internalLink($data[0], $this->getLang('click_edit'));
$renderer->doc .= '</div>';
$renderer->doc .= $this->getLang('processing_template');
$renderer->internalLink($data[0]);
$renderer->doc .= $this->getLang('stopped_recursion');
$renderer->doc .= '<br/><br/></div>';
return true;
}
self::$pagestack[] = $data[0]; // push this onto the stack
Expand All @@ -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 .= '.<br/><br/></div>';
}
}

// correct relative internal links and media
$instr = $this->_correctRelNS($instr, $data[0]);
Expand Down Expand Up @@ -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;
}

/**
Expand Down

0 comments on commit dc999c1

Please sign in to comment.