Hello!
Theris my template before html_entity_decode_deep
#IFfollowup.isprivate=Да## ##lang.followup.isprivate##
##ENDIFfollowup.isprivate## :
##followup.description##
##ENDFOREACHfollowups##
there is after
##IFfollowup.isprivate=Да## ##lang.followup.isprivate##
##ENDIFfollowup.isprivate## :
##followup.description##
##ENDFOREACHfollowups##
My problem is that condition "=Да" present in database as "=Да"
so without decode my condition will not work!
This one patch work for me.
note 1 $data already decoded on:
//Template processing
// Decode html chars to have clean text
$data = html_entity_decode_deep($data);
so decode other side $data['##'.$if_field.'##'] ==
html_entity_decode_deep($out[2][$key]) )
note 2 , regexp ".*?" work only without U parameter.
--- ./notificationtemplate.class.php 2011-01-18 17:04:00.000000000 +0300
+++ ./notificationtemplate.class.php.new 2011-02-08 13:02:43.000000000
+0300
@@ -324,13 +324,14 @@
static function processIf($string, $data) {
- if (preg_match_all("/##IF([a-z\.]*)[=]?([\w ]*)##/i",$string,$out)) {
+ if (preg_match_all("/##IF([a-z\.]*)[=]?(.*?)##/i",$string,$out)) {
foreach ($out[1] as $key => $tag_infos) {
$if_field = $tag_infos;
//Get the field tag value (if one)
- $regex_if = "/##IF".$if_field."[=]?[\w
]*##(.*)##ENDIF".$if_field."##/Uis";
+ $regex_if =
"/##IF".$if_field."[=]?.*?##(.*?)##ENDIF".$if_field."##/is";
//Get the else tag value (if one)
- $regex_else = "/##ELSE".$if_field."[=]?[\w
]*##(.*)##ENDELSE".$if_field."##/Uis";
+ $regex_else =
"/##ELSE".$if_field."[=]?.*?##(.*?)##ENDELSE".$if_field."##/is";
+
if (empty($out[2][$key])){ // No = : check if ot empty or not
null
if (isset($data['##'.$if_field.'##'])
&& $data['##'.$if_field.'##'] != ''
@@ -342,7 +343,7 @@
}
} else { // check exact match
if (isset($data['##'.$if_field.'##'])
- && $data['##'.$if_field.'##'] == $out[2][$key]) {
+ && $data['##'.$if_field.'##'] ==
html_entity_decode_deep($out[2][$key])) {
$condition_ok=true;
} else {
$condition_ok=false;
2011/2/7 MoYo <[email protected]>
> Hi,
>
> denis could you try this patch proposed here :
> http://www.glpi-project.org/forum/viewtopic.php?id=22834
> which is based on yours.
>
> Regards
>
> Julien
>
>
> --- inc/notificationtemplate.class.php.orig 2011-01-24 01:52:54.000000000
> +0100
> +++ inc/notificationtemplate.class.php 2011-02-04 10:02:13.000000000 +0100
> @@ -208,7 +208,7 @@
> Plugin::loadLang(strtolower($plug['plugin']));
> }
>
> - if ($template_datas = $this->getByLanguage($language)) {
> + if ($template_datas =
> html_entity_decode_deep($this->getByLanguage($language))) {
> //Template processing
> // Decode html chars to have clean text
> $data = html_entity_decode_deep($data);
> @@ -323,14 +323,13 @@
>
>
> static function processIf($string, $data) {
> -
> - if (preg_match_all("/##IF([a-z\.]*)[=]?([\w ]*)##/i",$string,$out)) {
> + if (preg_match_all("/##IF([a-z\.]*)[=]?(.*?)##/i",$string,$out)) {
> foreach ($out[1] as $key => $tag_infos) {
> $if_field = $tag_infos;
> //Get the field tag value (if one)
> - $regex_if = "/##IF".$if_field."[=]?[\w
> ]*##(.*)##ENDIF".$if_field."##/Uis";
> + $regex_if =
> "/##IF".$if_field."[=]?.*##(.*)##ENDIF".$if_field."##/Uis";
> //Get the else tag value (if one)
> - $regex_else = "/##ELSE".$if_field."[=]?[\w
> ]*##(.*)##ENDELSE".$if_field."##/Uis";
> + $regex_else =
> "/##ELSE".$if_field."[=]?.*##(.*)##ENDELSE".$if_field."##/Uis";
> if (empty($out[2][$key])){ // No = : check if ot empty or not
> null
> if (isset($data['##'.$if_field.'##'])
> && $data['##'.$if_field.'##'] != ''
> @@ -342,7 +341,7 @@
> }
> } else { // check exact match
> if (isset($data['##'.$if_field.'##'])
> - && $data['##'.$if_field.'##'] == $out[2][$key]) {
> + && html_entity_decode_deep($data['##'.$if_field.'##']) ==
> $out[2][$key]) {
> $condition_ok=true;
> } else {
> $condition_ok=false;
>
>
>
>
> _______________________________________________
> Glpi-dev mailing list
> [email protected]
> https://mail.gna.org/listinfo/glpi-dev
>
>
_______________________________________________
Glpi-dev mailing list
[email protected]
https://mail.gna.org/listinfo/glpi-dev