- 适用版本:v9
- 语言编码:GBK简体
- 插件作者:Remember
- 版权所属:Remember & 化蝶自在飞
- 支持网站:http://www.phpgogo.com/
- 插件介绍:评论增加表情,兼容所有浏览器。
- 适用版本号:AlL
-
修改了一下化蝶的,使其兼容所有浏览器,IE系列、Chrom、Firefox、Opera....测试通过。只不过是插入表情的方法不一样.....
表情包改成了活泼的五角星,哈哈。看看效果:
引用一下化蝶的代码:
phpcms/templates/default/comment/show_list.html
里面找到:
<form action="{APP_PATH}index.php?m=comment&c=index&a=post&commentid={$commentid}" method="post" onsubmit="return on_submit()"> <input type="hidden" name="title" value="{urlencode(($comment[title] ? $comment[title] : $title))}"> <input type="hidden" name="url" value="{urlencode(($comment[url] ? $comment[url] : $url))}"> <div class="comment-form"> <h5><strong>我来说两句</strong><span class="fn rt blue">已有<font color="#FF0000">{if $comment[total]}{$comment[total]}{else}0{/if}</font>条评论,<a href="{APP_PATH}index.php?m=comment&c=index&a=init&commentid={$commentid}" target="_blank">点击全部查看</a></span></h5> <div class="posn">我的态度:<input type="radio" name="direction" value="1" /> <img src="{IMG_PATH}icon/zheng.png" /> <input type="radio" name="direction" value="2" /> <img src="{IMG_PATH}icon/fan.png" /> <input type="radio" name="direction" value="3" /> <img src="{IMG_PATH}icon/zhong.png" /> </div> <textarea rows="8" cols="80" name="content"></textarea><br>
把此段代码修改为如下:
-
<form action="{APP_PATH}index.php?m=comment&c=index&a=post&commentid={$commentid}" method="post" onsubmit="return on_submit()" name="commentform"> <input type="hidden" name="title" value="{urlencode(($comment[title] ? $comment[title] : $title))}"> <input type="hidden" name="url" value="{urlencode(($comment[url] ? $comment[url] : $url))}"> <div class="comment-form"> <h5><strong>我来说两句</strong><span class="fn rt blue">已有<font color="#FF0000">{if $comment[total]}{$comment[total]}{else}0{/if}</font>条评论,<a href="{APP_PATH}index.php?m=comment&c=index&a=init&commentid={$commentid}" target="_blank">点击全部查看</a></span></h5> <div class="posn">我的态度:<input type="radio" name="direction" value="1" /> <img src="{IMG_PATH}icon/zheng.png" /> <input type="radio" name="direction" value="2" /> <img src="{IMG_PATH}icon/fan.png" /> <input type="radio" name="direction" value="3" /> <img src="{IMG_PATH}icon/zhong.png" /> </div> <div class="commentsmile"> <?php for($a = 1;$a < 14;$a++){ ?> {php $fname = "smile_".$a;} <img src="{IMG_PATH}smilies/smile_{$a}.gif" id="{$fname}" alt="{$fname}" border="0" onClick="AddOnPos(document.commentform.comment,'[{$fname}]');" onMouseover="this.style.cursor = 'pointer';" /> <?php }?> <script type="text/javascript" src="{JS_PATH}smile.js"></script> </div> <textarea rows="8" cols="80" name="content" id="comment"></textarea><br>
在
phpcms/templates/default/comment/list.html
里面找到:
-
<form action="{APP_PATH}index.php?m=comment&c=index&a=post&commentid={$commentid}" method="post"> <input type="hidden" name="title" value="{urlencode(($comment[title] ? $comment[title] : $title))}"> <input type="hidden" name="url" value="{urlencode(($comment[url] ? $comment[url] : $url))}"> <a name="comment"></a> <h5><strong>我来说两句</strong></h5> <div class="posn">我的态度:<input type="radio" name="direction" value="1" /> <img src="{IMG_PATH}icon/zheng.png" /> <input type="radio" name="direction" value="2" /> <img src="{IMG_PATH}icon/fan.png" /> <input type="radio" name="direction" value="3" /> <img src="{IMG_PATH}icon/zhong.png" /> </div> <textarea rows="8" cols="80" name="content"></textarea><br>
将其修改为:
-
<form action="{APP_PATH}index.php?m=comment&c=index&a=post&commentid={$commentid}" method="post" name="commentform"> <input type="hidden" name="title" value="{urlencode(($comment[title] ? $comment[title] : $title))}"> <input type="hidden" name="url" value="{urlencode(($comment[url] ? $comment[url] : $url))}"> <a name="comment"></a> <h5><strong>我来说两句</strong></h5> <div class="posn">我的态度:<input type="radio" name="direction" value="1" /> <img src="{IMG_PATH}icon/zheng.png" /> <input type="radio" name="direction" value="2" /> <img src="{IMG_PATH}icon/fan.png" /> <input type="radio" name="direction" value="3" /> <img src="{IMG_PATH}icon/zhong.png" /> </div> <div class="commentsmile"> <?php for($a = 1;$a < 14;$a++){ ?> {php $fname = "smile_".$a;} <img src="{IMG_PATH}smilies/smile_{$a}.gif" id="{$fname}" alt="{$fname}" border="0" onClick="AddOnPos(document.commentform.comment,'[{$fname}]');" onMouseover="this.style.cursor = 'pointer';" /> <?php }?> <script type="text/javascript" src="{JS_PATH}smile.js"></script> </div> <textarea rows="8" cols="80" name="content" id="comment"></textarea><br>
在
phpcms/modules/comment/functions/global.func.php
里面的最下面加上:
/*评论表情*/
function smilecallback($matches)
{
if($matches)
{
$fname = substr($matches[0],1,-1);
return "<img src=statics/images/smilies/".$fname.".gif />";
}
else return '';
}
函数
然后再找到
phpcms/modules/comment/classes/comment.class.php
里面找到:
-
在其前面加上://判断当前站点是否需要审核 $site = $this->comment_setting_db->site($siteid);
-
$data['content'] = preg_replace_callback("/\[smile_[0-9]{1,3}\]/","smilecallback",$data['content']);
- smile.js:
-
function AddOnPos(obj, charvalue) { //·ÇIEÄÚºËä¯ÀÀÆ÷ if(window.getSelection){ obj.value = obj.value + charvalue; } //IEÄÚºËä¯ÀÀÆ÷ else if(document.selection) { obj.focus(); var r = document.selection.createRange(); var ctr = obj.createTextRange(); var i; var s = obj.value; var ivalue = "&^asdjfls2FFFF325%$^&"; r.text = ivalue; i = obj.value.indexOf(ivalue); r.moveStart("character", -ivalue.length); r.text = ""; obj.value = s.substr(0,i) + charvalue + s.substr(i,s.length); ctr.collapse(true); ctr.moveStart("character", i + charvalue.length); ctr.select(); } }
转自:http://bbs.phpcms.cn/thread-281137-1-1.html
PHPCMSv9 评论表情插件 兼容所有浏览器
最新推荐文章于 2021-03-21 22:53:38 发布