Fixed bug: alerts were triggered only for first tag of each type

This commit is contained in:
Simon DELAGE 2018-11-15 07:10:28 +01:00
parent 3911921b0a
commit 35e1d042d2
8 changed files with 25 additions and 23 deletions

View file

@ -2,7 +2,7 @@
/**
* Tag Alerts plugin main file
*
* @author: Simon Delage <simon.geekitude@gmail.com>
* @author: Simon Delage <sdelage@gmail.com>
* @license: CC Attribution-Share Alike 3.0 Unported <http://creativecommons.org/licenses/by-sa/3.0/>
*/
@ -53,7 +53,7 @@ class action_plugin_tagalerts extends DokuWiki_Action_Plugin{
global $ACT;
if (($this->getConf('action') == "messages") & ($ACT == "show")) {
// Get an array of notification triggers from 'notify' option (make sure the list is well formated: no blanks between triggers and no '_' in triggers)
// Get an array of triggers from settings (make sure the list is well formated: no blanks between triggers and no '_' in triggers)
$errorTriggers = explode(',',str_replace('_', ' ', str_replace(', ', ',', $this->getConf('error'))));
$infoTriggers = explode(',',str_replace('_', ' ', str_replace(', ', ',', $this->getConf('info'))));
$successTriggers = explode(',',str_replace('_', ' ', str_replace(', ', ',', $this->getConf('success'))));
@ -64,16 +64,18 @@ class action_plugin_tagalerts extends DokuWiki_Action_Plugin{
$tagalerts['info'] = array_values((array_intersect($this->pagetags, $infoTriggers)));
$tagalerts['success'] = array_values((array_intersect($this->pagetags, $successTriggers)));
$tagalerts['notify'] = array_values((array_intersect($this->pagetags, $notifyTriggers)));
foreach($tagalerts as $type=>$tag) {
if (isset($tag[0])) {
// Alert from conf file
if (isset($conf['plugin']['tagalerts']['specAlerts'][$tag[0]])) {
$msg = $conf['plugin']['tagalerts']['specAlerts'][$tag[0]];
// Or from localized $conf
} else {
$msg = $this->getLang('tagalerts').$tag[0].".";
foreach($tagalerts as $type=>$tags) {
for ($i = 0; $i < count($tags); $i++) {
if (isset($tags[$i]) {
// Alert from conf file
if (isset($conf['plugin']['tagalerts']['specAlerts'][$tags[$i]])) {
$msg = $conf['plugin']['tagalerts']['specAlerts'][$tags[$i]];
// Or from localized $conf
} else {
$msg = $this->getLang('tagalerts').$tags[$i].".";
}
echo '<div class="tag'.$type.'">'.hsc($msg).'</div>';
}
echo '<div class="tag'.$type.'">'.hsc($msg).'</div>';
}
}
}

View file

@ -2,12 +2,12 @@
/**
* Configuration defaults file for Tag Alert plugin
*
* @author: Simon Delage <simon.geekitude@gmail.com>
* @author: Simon Delage <sdelage@gmail.com>
* @license: CC Attribution-Share Alike 3.0 Unported <http://creativecommons.org/licenses/by-sa/3.0/>
*/
$conf['action'] = 'inline';
$conf['error'] = ''; //comma separated list of tags for wich a "tag error" should be thrown
$conf['info'] = ''; //comma separated list of tags for wich a "tag info" should be thrown
$conf['success'] = ''; //comma separated list of tags for wich a "tag success" should be thrown
$conf['notify'] = ''; //comma separated list of tags for wich a "tag notification" should be thrown
$conf['error'] = ''; //comma separated list of tags for wich a "tag error" should be thrown
$conf['info'] = ''; //comma separated list of tags for wich a "tag info" should be thrown
$conf['success'] = ''; //comma separated list of tags for wich a "tag success" should be thrown
$conf['notify'] = ''; //comma separated list of tags for wich a "tag notification" should be thrown

View file

@ -2,7 +2,7 @@
/**
* Configuration metadata file for Tag Alert plugin
*
* @author: Simon Delage <simon.geekitude@gmail.com>
* @author: Simon Delage <sdelage@gmail.com>
* @license: CC Attribution-Share Alike 3.0 Unported <http://creativecommons.org/licenses/by-sa/3.0/>
*/

View file

@ -2,7 +2,7 @@
/**
* English language file for Tag Alerts plugin
*
* @author: Simon Delage <simon.geekitude@gmail.com>
* @author: Simon Delage <sdelage@gmail.com>
* @license: CC Attribution-Share Alike 3.0 Unported <http://creativecommons.org/licenses/by-sa/3.0/>
*/

View file

@ -2,7 +2,7 @@
/**
* English settings file for Tag Alerts plugin
*
* @author: Simon Delage <simon.geekitude@gmail.com>
* @author: Simon Delage <sdelage@gmail.com>
* @license: CC Attribution-Share Alike 3.0 Unported <http://creativecommons.org/licenses/by-sa/3.0/>
*/

View file

@ -2,7 +2,7 @@
/**
* French language file for Tag Alerts plugin
*
* @author: Simon Delage <simon.geekitude@gmail.com>
* @author: Simon Delage <sdelage@gmail.com>
* @license: CC Attribution-Share Alike 3.0 Unported <http://creativecommons.org/licenses/by-sa/3.0/>
*/

View file

@ -2,7 +2,7 @@
/**
* French settings file for Tag Alerts plugin
*
* @author: Simon Delage <simon.geekitude@gmail.com>
* @author: Simon Delage <sdelage@gmail.com>
* @license: CC Attribution-Share Alike 3.0 Unported <http://creativecommons.org/licenses/by-sa/3.0/>
*/

View file

@ -1,7 +1,7 @@
base tagalerts
author Simon Delage
email simon.geekitude@gmail.com
date 2018-11-14
email sdelage@gmail.com
date 2018-11-15
name Tag Alerts
desc Throw alerts when some tags are detected (based on Dokuwiki system messages or just styling tag list links)
url https://www.dokuwiki.org/plugin:tagalerts