关于插入表情

By ego008 at 2013-04-09 08:37:49 • 892次点击 • 1收藏

提供一个函数参考:

<?php
$text = "
qaa  a  [smile] a中[xiao]文[呲牙]
";

function expression($str){
    $arr = array('[呲牙]' => '呲牙.jpg', '[smile]' => 'smile.jpg');
    return strtr($str, $arr);
}

echo expression($text);

?>

表情


我已经解决表情功能了,代码如下

//表情匹配功能
	if(!$spider){
		$reexpression =array("呲牙","鄙视","折磨","擦汗","发怒","奋斗","尴尬","惊恐","可爱","可怜","抠鼻","流汗","流泪","强","敲打","睡","偷笑","委屈","握手","抓狂");
		$expression= '#@('. join('|', $reexpression) .')#u';
		$replace = '<img src="'.$options['base_url'].'/static/grey.gif" data-original="'.$options['base_url'].'/static/expression/$1.gif" alt="$1"/>';
		$text = preg_replace($expression, $replace, $text);
	}else{
		$reexpression =array("呲牙","鄙视","折磨","擦汗","发怒","奋斗","尴尬","惊恐","可爱","可怜","抠鼻","流汗","流泪","强","敲打","睡","偷笑","委屈","握手","抓狂");
		$expression= '#@('. join('|', $reexpression) .')#u';
		$replace = '<img src="'.$options['base_url'].'/static/expression/$1.gif" alt="$1"/>';
		$text = preg_replace($expression, $replace, $text);
		}

把上面代码放入common.php的识别视频网站代码的上面,当输入at+表情名时会出现图片。
我现在正想着在回复窗口右边提供一个表情列表,点击后直接可以在输入框输入表情。初级想法是在main-sider里面再浮动一个sider-box,但这个sider-box要放在最下方,我不懂css,网上搜了好多也没找到方法,不知你能否提供一些思路

沉默小子g at 2013-04-09 12:41:47
1

@沉默小子g 以前用过jdialog,挺好用 https://github.com/huacnlee/jdialog/ 1

ego008 at 2013-04-09 13:00:38
2

那个变量可以判断是否在www.test.com/t-XX 页面?
因为表情列表只在www.test.com/t-XX 和www.test.com/newpost页面显示,newpost可以用$newpost_page来判断,那么/t-XX有没有标识符呢?

沉默小子g at 2013-04-09 13:35:43
3

那个jdialog好像是让窗口一直浮动在浏览器右下角,可能是我没描述清楚,我想要的是下面这种效果

沉默小子g at 2013-04-09 13:41:17
4

另外,官网该如何设置才能使得在这里发帖时不自动同步到微博?

沉默小子g at 2013-04-09 14:10:27
5

@沉默小子g

有个变量 $url_path
发满11个帖子后有选择是否同步到微博(防垃圾和帮忙发几个外链)。

ego008 at 2013-04-09 16:26:30
6

@ego008 是11个主题帖还是回复都算?

沉默小子g at 2013-04-09 16:32:24
7

@沉默小子g 主贴

ego008 at 2013-04-09 16:37:51
8
登录 后发表评论