PHPCMSv9 评论表情插件 兼容所有浏览器

  • 插件名称:评论表情
  • 适用版本:v9
  • 语言编码:GBK简体 
  • 插件作者:Remember
  • 版权所属:Remember & 化蝶自在飞
  • 支持网站:http://www.phpgogo.com/
  • 插件介绍:评论增加表情,兼容所有浏览器。
  • 适用版本号:AlL


  • 修改了一下化蝶的,使其兼容所有浏览器,IE系列、Chrom、Firefox、Opera....测试通过。只不过是插入表情的方法不一样.....

    表情包改成了活泼的五角星,哈哈。看看效果:

    评论表情.jpg 

    引用一下化蝶的代码:

    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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值