From f7b9c269cff6d3d29f7cf1ff3d51644d806f14aa Mon Sep 17 00:00:00 2001 From: Tom Homer Date: Wed, 10 May 2017 22:57:57 -0400 Subject: [PATCH] Autotags Close Tag now are only checked for specific autotags that require them Update to feature #776 --- public_html/lib-common.php | 10 ++++++++-- system/lib-plugins.php | 32 ++++++++++++++++++-------------- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/public_html/lib-common.php b/public_html/lib-common.php index 054319fe3..5afc3ae92 100644 --- a/public_html/lib-common.php +++ b/public_html/lib-common.php @@ -4646,12 +4646,18 @@ function COM_allowedAutotags($list_only = false, $allowed_tags = array()) // List autotags user has permission to use (with descriptions) $autotags = array_keys(PLG_collectTags('permission')); $description = array_flip(PLG_collectTags('description')); + $closetag = array_flip(PLG_collectTags('closetag')); foreach ($autotags as $tag) { + if (in_array($tag, $closetag)) { + $tagname = '[' . $tag . ':][/' . $tag . ']'; + } else { + $tagname = '[' . $tag . ':]'; + } if (!empty($description[$tag])) { $desc = str_replace(array('[', ']'), array('[', ']'), $description[$tag]); - $list .= COM_getTooltip('[' . $tag . ':]', $desc, '', $LANG01[132], 'information') . ', '; + $list .= COM_getTooltip($tagname, $desc, '', $LANG01[132], 'information') . ', '; } else { - $list .= '[' . $tag . ':] , '; + $list .= $tagname . ' , '; } } $list = rtrim($list, ', '); diff --git a/system/lib-plugins.php b/system/lib-plugins.php index 5af7556f1..0ee63324b 100644 --- a/system/lib-plugins.php +++ b/system/lib-plugins.php @@ -1580,7 +1580,6 @@ function PLG_collectTags($type = 'tagname') } } } - } return $autolinkModules; @@ -1614,6 +1613,9 @@ function PLG_replaceTags($content, $plugin = '', $remove = false) } else { $autolinkModules = PLG_collectTags(); } + + //See if any tags require close tags + $tags_requireclose = array_flip(PLG_collectTags('closetag')); for ($i = 1; $i <= 5; $i++) { list($content, $markers) = GLText::protectJavascript($content); @@ -1667,19 +1669,21 @@ function PLG_replaceTags($content, $plugin = '', $remove = false) 'parm2' => $label, ); - // Check for close tag after end of start tag. if exist we have a parm3 - $close_tag = '[/' . $moduleTag . ']'; - $start_pos_close_tag = MBYTE_strpos($content_lower, $close_tag, $end_pos_tag); - if ($start_pos_close_tag > $end_pos_tag) { // make sure close tag is after tag - $end_of_whole_tag_pos = $start_pos_close_tag + strlen($close_tag); - $wrapped_text_length = $start_pos_close_tag - ($end_pos_tag + 1); - $wrapped_text = MBYTE_substr($content, ($end_pos_tag + 1), $wrapped_text_length); - - // New parm3 - $newTag['parm3'] = $wrapped_text; - // Since parm3 now update tagstr and length as well - $newTag['tagstr'] = $tag . $wrapped_text . $close_tag; - $newTag['length'] = $end_of_whole_tag_pos - $start_pos_tag; + if (in_array($moduleTag, $tags_requireclose)) { + // Check for close tag after end of start tag. if exist we have a parm3 + $close_tag = '[/' . $moduleTag . ']'; + $start_pos_close_tag = MBYTE_strpos($content_lower, $close_tag, $end_pos_tag); + if ($start_pos_close_tag > $end_pos_tag) { // make sure close tag is after tag + $end_of_whole_tag_pos = $start_pos_close_tag + strlen($close_tag); + $wrapped_text_length = $start_pos_close_tag - ($end_pos_tag + 1); + $wrapped_text = MBYTE_substr($content, ($end_pos_tag + 1), $wrapped_text_length); + + // New parm3 + $newTag['parm3'] = $wrapped_text; + // Since parm3 now update tagstr and length as well + $newTag['tagstr'] = $tag . $wrapped_text . $close_tag; + $newTag['length'] = $end_of_whole_tag_pos - $start_pos_tag; + } } $tags[] = $newTag;