下载请到第三楼
实现很难接受Discuz提供的表情选择功能!或许,这是为了安全而不考虑使用iframe吧!毕竟,据说这个功能漏洞很多?呵呵
但个人认为,iframe功能是真的很好用的!或许现在很多人都在说Web2.0功能之一——无刷新技术,郁闷的是,Discuz竟然没有考虑使用该技术实现无刷新页面而实现表情翻页功能!呵呵,郁闷啊郁闷!
好了,无聊话至此!
该功能不能算是一个插件!因为他仅仅只是在原有基础上进行修改!
以下是修改步聚
-------------------------------------------
表情大改动
1、删除旧表情
修改模板:post_sminsert.htm
将以下信息删除:
- <!--{if $smileyinsert}-->
- <hr class="line" size="0">
- <div id="{$editorid}_smiliebox">
- <table cellpadding="3" cellspacing="0" width="80%" border="0" align="center">
- $smilies
- <!--{if $moresmilies}-->
- <tr>
- <td colspan="$smcols" align="center"><br><a href="#" onclick="opensmiliewindow(200, 500, '$editorid'); return false">
- <div align="right" class="bold">{lang post_smilies_more} ››</div></a></td>
- </tr>
- <!--{/if}-->
- </table>
- </div>
- <!--{/if}-->
复制代码
2、修改post.php文件,使用表情实现分页!
查找:
- foreach($_DCACHE['smilies_display'] as $key => $smiley) {
- $_DCACHE['smilies_display'][$key]['codeinsert'] = addcslashes($smiley['code'], '\\\'');
- }
- include template('post_smilies');
- dexit();
复制代码
将其修改为
- $smile_count = count($_DCACHE['smilies_display']);//计算共有多少个表情
- $get_count = $get_count ? intval($get_count) : 0;//计算初始表情
- $per_count = 30;//每页显示多少表情数量,一般设为30个,可以在一定程度上减少文件的下载
- $smile_array = array();
- $query_smile = $db->query("select * from {$tablepre}smilies where type='smiley' order by displayorder asc,id desc limit ".$get_count.",".$per_count);
- while($query_smile_rows = $db->fetch_array($query_smile))
- {
- $new_array_smile["code"] = $query_smile_rows["code"];
- $new_array_smile["url"] = $query_smile_rows["url"];
- $smile_array[$query_smile_rows["id"]] = $new_array_smile;
- }
- unset($query_smile,$query_smile_rows);
- $smile_select = "<select onchange="window.location=('post.php?action=smilies&get_count='+this.options[this.selectedIndex].value+'')">";
- $totalPage = intval($smile_count/$per_count);
- if($smile_count%$per_count) $totalPage++;
- for($smile_i=0;$smile_i<$totalPage;$smile_i++)
- {
- if($get_count == ($smile_i * $per_count))
- {
- $smile_select .= "<option value='".$get_count."' selected>第 ".($smile_i+1)." 页</option>";
- }
- else
- {
- $smile_select .= "<option value='".($smile_i * $per_count)."'>第 ".($smile_i+1)." 页</option>";
- }
- }
- $smile_select .= "</select>";//完成选择
- include template('post_smilies');
- dexit();
复制代码
3、修改模板文件
viewthread.htm
forumdisplay.htm
post_newreply.htm
post_newthread.htm
在上述模板文件适当位置添加以下代码:
- <iframe id="iframe2" frameborder=0 src="post.php?action=smilies" width="100%" height="100%" scrolling="no" onload="document.all['iframe2'].height=iframe2.document.body.scrollHeight"></iframe>
复制代码
说明一下:该代码可实现框架自适应大小,在FireFox下会有点不准确(高度比IE计算少了很多列,我也没搞懂,汗。但不影响使用!)
4、修改模板文件
post_smilies.htm
找到以下代码:
- <table cellspacing="{INNERBORDERWIDTH}" cellpadding="{TABLESPACE}" width="100%" class="tableborder" id="smilietable">
- <tr><td colspan="2" class="header">{lang post_smilies_more}</td></tr>
- <!--{loop $_DCACHE['smilies_display'] $key $smiley}-->
- <tr align="center">
- <td class="altbg1">$smiley[code]</td>
- <td class="altbg2"><img src="{SMDIR}/$smiley[url]" border="0" alt="$smiley[code]" id="smilie_$key" onClick="insertSmilies($key)" onMouseover="this.style.cursor = is_ie ? 'hand' : 'pointer';" /></td>
- </tr>
- <!--{/loop}-->
- </table>
- <script type="text/javascript">
- function insertSmilies(smilieid) {
- window.opener.checkFocus();
- var src = $('smilie_' + smilieid).src;
- var code = $('smilie_' + smilieid).pop;
- if(typeof window.opener.wysiwyg != 'undefined' && window.opener.wysiwyg && window.opener.allowsmilies && (!window.opener.$('smileyoff') || window.opener.$('smileyoff').checked == false)) {
- if(is_moz) {
- window.opener.applyFormat('InsertImage', false, src);
- var smilies = window.opener.findtags(editdoc.body, 'img');
- for(var i = 0; i < smilies.length; i++) {
- if(smilies[i].src == src && smilies[i].getAttribute('smilieid') < 1) {
- smilies[i].setAttribute('smilieid', smilieid);
- smilies[i].setAttribute('border', "0");
- }
- }
- } else {
- window.opener.insertText('<img src="' + src + '" border="0" smilieid="' + smilieid + '" alt="" /> ', false);
- }
- } else {
- code += ' ';
- window.opener.AddText(code);
- }
- }
- </script>
复制代码
替换代码为:
- <table cellspacing="0" cellpadding="0" width="100%" class="tableborder altbg1" style="border-bottom:0px">
- <tr><td height="25px" style="font-weight:bold;"> {lang post_smilies}</td><td align="right">{$smile_select} </td></tr>
- </table>
- <table cellspacing="{INNERBORDERWIDTH}" cellpadding="{TABLESPACE}" width="100%" class="tableborder" id="smilietable">
- <tr>
- <td colspan="2">
- <!--{loop $smile_array $key $smiley}-->
- <img src="{SMDIR}/$smiley[url]" border="0" alt="$smiley[code]" id="smilie_$key" onClick="insertSmilies($key)" onMouseover="this.style.cursor = is_ie ? 'hand' : 'pointer';" />
- <!--{/loop}-->
- </td>
- </tr>
- </table>
- <script type="text/javascript">
- function insertSmilies(smilieid) {
- window.parent.checkFocus();
- var src = $('smilie_' + smilieid).src;
- var code = $('smilie_' + smilieid).pop;
- if(typeof window.parent.wysiwyg != 'undefined' && window.parent.wysiwyg && window.parent.allowsmilies && (!window.parent.$('smileyoff') || window.parent.$('smileyoff').checked == false)) {
- if(is_moz) {
- window.parent.applyFormat('InsertImage', false, src);
- var smilies = window.parent.findtags(editdoc.body, 'img');
- for(var i = 0; i < smilies.length; i++) {
- if(smilies[i].src == src && smilies[i].getAttribute('smilieid') < 1) {
- smilies[i].setAttribute('smilieid', smilieid);
- smilies[i].setAttribute('border', "0");
- }
- }
- } else {
- window.parent.insertText('<img src="' + src + '" border="0" smilieid="' + smilieid + '" alt="" /> ', false);
- }
- } else {
- code += ' ';
- window.parent.AddText(code);
- }
- }
- </script>
复制代码
[ 本帖最后由 suxiangkun 于 2006-9-15 04:48 编辑 ] |