注意事项
1、因为回复带了编辑器功能,所以UCH本来使用的AJAX技术的回复发布、编辑、删除被屏蔽了,其实就是回复、编辑、删除功能不能无刷新显示而已,最终结果是一样的。
2、本插件适合安装了本人制作的话题编辑器和图片插件,完美表情插件的用户。
81. 选吧主题图片上传和编辑器插件 https://discuz.dismall.com/viewth ... 4837&highlight= 作者 zetd
82. 完美UCH表情功能 https://discuz.dismall.com/viewth ... 8531&highlight= 作者 zetd
3、提供本人修改文件对照修改,有PHP基础的可以直接看文件
4、插件有风险,请先做备份!
演示地址www.qnw.com.cn/uch
本来这个功能不想开发的,但考虑到后面的一系列插件最终决定将回复也做了编辑器和图片上传功能。
修改步骤:
1、请下载到source目录下
2、修改source目录space_thread.php在- //访问统计
- inserttable('log', array('id'=>$id, 'idtype'=>'tid'));
复制代码 增加- //获取相册列表
- function getalbums($uid) {
- global $_SGLOBAL;
-
- $albums = array();
- $query = $_SGLOBAL['db']->query("SELECT * FROM ".tname('album')." WHERE uid='$uid'");
- while ($value = $_SGLOBAL['db']->fetch_array($query)) {
- $albums[$value['albumid']] = $value;
- }
- return $albums;
- }
- $albums = getalbums($_SGLOBAL['supe_uid']);
复制代码 3、在source目录下cp_thread.php的- if(!defined('IN_UCHOME')) {
- exit('Access Denied');
- }
复制代码 后面增加- //回复
- if(submitcheck('newpostsubmit')) {
- $pid = empty($_GET['pid'])?0:intval($_GET['pid']);
- if(empty($pid)) {
- if(!checkperm('allowpost')) {
- showmessage('no_privilege');
- }
-
- //判断是否操作太快
- $waittime = interval_check('post');
- if($waittime > 0) {
- showmessage('operating_too_fast','',1,array($waittime));
- }
- //获得话题
- $tid = empty($_POST['tid'])?0:intval($_POST['tid']);
- $thread = array();
- if($tid) {
- $query = $_SGLOBAL['db']->query("SELECT * FROM ".tname('thread')." WHERE tid='$tid' LIMIT 1");
- $thread = $_SGLOBAL['db']->fetch_array($query);
- }
- if(empty($thread)) showmessage('the_discussion_topic_does_not_exist');
- //权限
- $mtag = ckmtagspace($thread['tagid']);
- include_once(S_ROOT.'./source/function_post.php');
- if($blog = blog_post($_POST, $thread)) {
-
- $tagid=$blog['tagid'];
- $tid=$blog['tid'];
- $message=$blog['message'];
- $psetarr = array(
- 'tagid' => $tagid,
- 'tid' => $tid,
- 'uid' => $_SGLOBAL['supe_uid'],
- 'username' => $_SGLOBAL['supe_username'],
- 'ip' => getonlineip(),
- 'dateline' => $_SGLOBAL['timestamp'],
- 'message' => $message,
- 'pic' => getpicurl($_POST['pic']),
- 'isthread' => 0
- );
- $pid = inserttable('post', $psetarr,1);
- $summay = getstr($message, 150, 1, 1);
- //更新统计数据
- $_SGLOBAL['db']->query("UPDATE ".tname('thread')."
- SET replynum=replynum+1, lastpost='$_SGLOBAL[timestamp]', lastauthor='$_SGLOBAL[supe_username]', lastauthorid='$_SGLOBAL[supe_uid]'
- WHERE tid='$tid'");
- //积分
- updatespacestatus('get', 'post');
- if($thread['uid'] != $_SGLOBAL['supe_uid']) {
- $fs = array();
- $fs['icon'] = 'post';
- $fs['body_template'] = '';
- $fs['body_data'] = array();
- $fs['body_general'] = '';
-
- $fs['title_template'] = lang('feed_thread_reply');
- $fs['title_data'] = array('touser'=>"<a href="space.php?uid=$thread[uid]">$thread[username]</a>", 'thread'=>"<a href="space.php?uid=$thread[uid]&do=thread&id=$thread[tid]">$thread[subject]</a>");
-
- if(ckprivacy('post', 1)) {
- feed_add($fs['icon'], $fs['title_template'], $fs['title_data'], $fs['body_template'], $fs['body_data'], $fs['body_general']);
- }
- //通知
- $note = lang('note_thread_reply')." <a href="space.php?uid=$thread[uid]&do=thread&id=$thread[tid]&pid=$pid" target="_blank">$thread[subject]</a>";
- notification_add($thread['uid'], 'post', $note);
- }
- showmessage('do_success', "space.php?uid=$_SGLOBAL[supe_uid]&do=thread&id=$tid&pid=$pid", 0);
- }
- else
- {
- showmessage('that_should_at_least_write_things');
- }
- }
- else
- {
- $query = $_SGLOBAL['db']->query("SELECT * FROM ".tname('post')." WHERE pid='$pid'");
- $thread = $_SGLOBAL['db']->fetch_array($query);
- if(empty($thread)) showmessage('the_discussion_topic_does_not_exist');
- include_once(S_ROOT.'./source/function_post.php');
- if($blog = blog_post($_POST, $thread)) {
- $message=$blog['message'];
- updatetable('post', array('message'=>$message), array('pid'=>$pid));
- }
- showmessage('do_success', "space.php?uid=$_SGLOBAL[supe_uid]&do=thread&id=$thread[tid]&pid=$pid", 0);
- }
- }
复制代码 另外要在- $post['message'] = html2bbcode($post['message']);//显示用
复制代码 后面加句- $albums = getalbums($_SGLOBAL['supe_uid']);//获取相册列表
复制代码 4、修改模板目录下space_thread_view.htm文件
将- <!--{if $mtag[ismember]}-->
复制代码 后面所有的内容删除,然后增加- <script language="javascript" src="image/editor/editor_function.js"></script>
- <script type="text/javascript">
- function validate(obj) {
- uploadEdit(obj);
- return true;
- }
- function picView(albumid) {
- if(albumid == 'none') {
- $('albumpic_body').innerHTML = '';
- } else {
- ajaxget('do.php?ac=ajax&op=album&id='+albumid+'&ajaxdiv=albumpic_body', 'albumpic_body');
- }
- }
- function edit_album_show(id) {
- var obj = $('uchome-edit-'+id);
- if(id == 'album') {
- $('uchome-edit-pic').style.display = 'none';
- }
- if(id == 'pic') {
- $('uchome-edit-album').style.display = 'none';
- }
- if(obj.style.display == '') {
- obj.style.display = 'none';
- } else {
- obj.style.display = '';
- }
- }
- </script>
-
- <div class="quickpost">
- <form method="post" action="cp.php?ac=thread" class="quickpost" id="postform" name="postform" enctype="multipart/form-data">
- <h4>回复主题</h4>
- <table width="100%">
- <tr>
- <td><!--<textarea id="post_message" name="message" onkeydown="ctrlEnter(event, 'postsubmit_btn');" rows="6"></textarea>-->
- <textarea class="userData" name="message" id="uchome-ttHtmlEditor" style="height:100%;width:100%;display:none;border:0px"></textarea>
- <iframe src="editor.php?charset=$_SC[charset]&allowhtml=$allowhtml" name="uchome-ifrHtmlEditor" id="uchome-ifrHtmlEditor" scrolling="no" border="0" frameborder="0" style="width:100%;border: 1px solid #C5C5C5;" height="250"></iframe>
-
-
- </td>
- </tr>
- <tr><td>
- <div class="tabs_header">
- <ul class="tabs">
- <li class="active" style="width:68px;"><a>默认表情</a></li>
- </ul>
- </div>
- <script language='javascript' type='text/javascript' src='smils.js'></script>
- <style type='text/css'>@import url(smils.css);</style>
- <div id="smilieslist"></div>
- <script type="text/javascript">ajaxget('do.php?ac=ajax&op=smilsbig&ajaxdiv=smilieslist', 'smilieslist');</script>
- </td></tr>
- <tr>
- <td>
- <input type="hidden" name="tid" value="$thread[tid]" />
- <input type="hidden" name="newpostsubmit" value="true" />
- <input type="button" id="postsubmit_btn" name="postsubmit_btn" value="回复" class="submit" onclick="validate(this);" style="display: none;" />
- <div id="post_status"></div>
- </td>
- </tr>
- </table>
- </form>
- <!--{if !$threadedit['uid'] || $threadedit['uid']==$_SGLOBAL['supe_uid']}-->
- <table cellspacing="4" cellpadding="4" width="100%" >
- <tr><th width="65">图片:</th><td>
- <input type="button" name="clickbutton[]" value="上传图片" class="button" onclick="edit_album_show('pic')">
- <input type="button" name="clickbutton[]" value="浏览图片" class="button" onclick="edit_album_show('album')">
- </td></tr>
- </table>
- <!--{/if}-->
- <table cellspacing="4" cellpadding="4" width="100%" id="uchome-edit-pic" class="infotable" style="display:none;">
- <tr>
- <th width="65"> </th>
- <td>
- <strong>选择图片</strong>:
- <table summary="Upload" cellspacing="2" cellpadding="0">
- <tbody id="attachbodyhidden" style="display:none">
- <tr>
- <td>
- <form method="post" id="upload" action="cp.php?ac=upload" enctype="multipart/form-data" target="uploadframe" style="background: transparent;">
- <input type="file" name="attach" style="border: 1px solid #CCC;" />
- <span id="localfile"></span>
- <input type="hidden" name="uploadsubmit" id="uploadsubmit" value="true" />
- <input type="hidden" name="albumid" id="albumid" value="0" />
- </form>
- </td>
- </tr>
- </tbody>
- <tbody id="attachbody"></tbody>
- </table>
- <strong>存储相册</strong>:
- <table cellspacing="2" cellpadding="0">
- <tr>
- <td>
- <select name="albumid" id="uploadalbum" onchange="addSort(this)">
- <option value="0">默认相册</option>
- <!--{loop $albums $value}-->
- <option value="$value[albumid]">$value[albumname]</option>
- <!--{/loop}-->
- <option value="addoption" style="color:red;">+新建相册</option>
- </select>
- <script src="source/script_upload.js" type="text/javascript"></script>
- <iframe id="uploadframe" name="uploadframe" width="0" height="0" marginwidth="0" frameborder="0" src="about:blank"></iframe>
- </td>
- </tr>
- </table>
- </td>
- </tr>
- </table>
- <table cellspacing="4" cellpadding="4" width="100%" id="uchome-edit-album" style="display:none;">
- <tr>
- <th width="65"> </th>
- <td>
- 选择相册: <select name="view_albumid" onchange="picView(this.value)">
- <option value="none">选择一个相册</option>
- <option value="0">默认相册</option>
- <!--{loop $albums $value}-->
- <option value="$value[albumid]">$value[albumname]</option>
- <!--{/loop}-->
- </select> (点击图片可以插入到内容中)
- <div id="albumpic_body"></div>
- </td>
- </tr>
- </table>
- <table cellspacing="4" cellpadding="4" width="100%" class="infotable">
- <tr>
- <th width="65"> </th>
- <td><input type="button" id="issuance" onclick="document.getElementById('postsubmit_btn').click();" value="回复" class="submit" /></td>
- </tr>
- </table>
- </div>
- <!--{else}-->
- <div class="article quickpost">你还不是该圈子成员,不能参与讨论。<a href="cp.php?ac=mtag&op=join&tagid=$mtag[tagid]" id="mtag_join_$mtag[tagid]" onclick="ajaxmenu(event, this.id, 99999)">现在就加入</a>。</div>
- <!--{/if}-->
- </div>
- </div>
- <div class="f_status f_status_w s_clear">
- <a href="javascript:;" onclick="window.scrollTo(0,0);" id="a_top" title="TOP">TOP</a>
- <a href="cp.php?ac=share&type=thread&id=$thread[tid]" id="a_share" onclick="ajaxmenu(event, this.id, 99999, '', -1)">分享</a>
- </div>
- <script type="text/javascript">
- resizeImg('detail_0','500');
- </script>
- <!--{template footer}-->
复制代码 5、修改模板文件下cp_thread.htm
找到- <!--{elseif $_GET['op'] == 'delete'}-->
复制代码 将这行以上所有代码删除替换为7、修改模板文件下space_post_li.htm,把编辑和删除两个链接里的这段代码删除或者屏蔽- onclick="ajaxmenu(event, this.id, 99999,'' , -1)"
复制代码
然后在- <div class="detail" id="detail_$value[pid]">
- <!--{eval echo smils_replace($value['message']);}-->
- <!--{if $value[pic]}--><div><a href="$value[pic]" target="_blank"><img src="$value[pic]" class="resizeimg" /></a></div><!--{/if}-->
- </div>
复制代码 后面增加- <script type="text/javascript">
- resizeImg('detail_$value[pid]','500');
- </script>
复制代码 8、修改根目录下smilsfunction.php(这个文件是自己写的表情代码替换)
在- $message=str_replace($list[0],$list[1],$message);
复制代码 增加一行代码- $message = str_replace(array('[quote]','[/quote]','[b]','[/b]'), array('<div class="quote"><span class="q">','</span></div>','<b>','</b>'), $message);
复制代码 刷新缓存,测试一下吧!
[ 本帖最后由 zetd 于 2008-6-10 18:27 编辑 ] |