<?php if(!defined('IN_SDCMS')) exit;?>{include file="top.php"}
<title>{$title}_{sdcms[bbs_webname]}</title>
<meta name="keywords" content="{sdcms[bbs_seokey]}">
<meta name="description" content="{sdcms[bbs_seodesc]}">
<script src="{WEB_ROOT}public/ueditor/ueditor.config.js"></script>
<script src="{WEB_ROOT}public/ueditor/ueditor.all.min.js"></script>
</head>

<body>
	
    {include file="head.php"}

    <div class="bg_inner">
        <div class="width banner_inner">
            <div class="left">
                <ul>
                    <li class="hover"><a>{sdcms[bbs_webname]}</a></li>
                </ul>
            </div>
            <div class="right"><span class="am-icon-phone am-icon-fw"></span>{sdcms[ct_tel]}{block("inner_text")}</div>
        </div>
    </div>

    <div class="width">
        <div class="bread bread-1 mt">
        	<ul>
                <li><a href="{$webroot}">首页</a></li>
                <li><a href="{N('bbs')}">社区首页</a></li>
                <li class="active"><a href="{THIS_LOCAL}">查看主题</a></li>
            </ul>
        </div>
    </div>
    
	<div class="width minheight">
    	<!---->
        <div class="bbs">
            <div class="lefter">
                 <div class="showbbs box">
                 	<div class="title">
                        <h1>{$title}</h1>
                        <div class="info">{$uname}　　{formatTime($createdate)}　　<span class="ui-icon-eye"></span>{$hits}　　<span class="ui-icon-comment"></span>{$replynum}{if $islogin==$userid}　　<a href="{N('bbsedit','','id='.$id.'')}"><span class="ui-icon-edit"></span>编辑</a>{/if}</div>
                        <div class="face"><img src="{if strlen($uface)}{$uface}{else}{WEB_ROOT}upfile/noface.gif{/if}" alt="{$uname}"></div>
                    </div>
                    {if $view_lever==1}
                        <div class="content">{$content}</div>
                    {else}
                    	{if $islogin==0}
                        	<div class="tip">您需要登录后才可以查看，请先<a href="{N('login')}">登录</a>或<a href="{N('reg')}">注册</a></div>
                        {elseif $view_lever==0}
                        	<div class="tip">您所在用户组，无法查看帖子</div>
                        {else}
                        	<div class="content">{$content}</div>
                        {/if}
                    {/if}
                 </div>
                 
                 <div class="box mt20 reply">
                 	<div class="title">最新回复</div>
                    
                    <ul class="media-list media-border mb-20">
                    	{sdcms:rs pagesize="15" table="sd_bbs_reply" join="left join sd_user on sd_bbs_reply.userid=sd_user.id" where="sd_bbs_reply.islock=1 and bbsid=$id and istopic=0" order="replyid" key="replyid"}
                        <li class="media">
                            <div class="media-img mr-20 radius">
                                <img src="{if strlen($rs[uface])}{$rs[uface]}{else}{WEB_ROOT}upfile/noface.gif{/if}" alt="{$rs[uname]}" width="64" height="64" >
                            </div>
                            <div class="media-body">
                                <div class="media-header row align-items-center">
                                    <div class="col-8 font-14">{$rs[uname]}<span class="pl text-gray">{formatTime($rs[createdate])}</span></div>
                                    <div class="col-4 text-right font-13 text-gray">{switch ($i+15*($page-1))}{case 1}沙发{/case}{case 2}板凳{/case}{case 3}地板{/case}{default}{$i+15*($page-1)}楼{/switch}</div>
                                </div>
                                <div class="media-text">
                                    {if $view_lever==1}
                                        {$rs[content]}
                                        {if $rs[reply]<>''}<div class="line line-left"><span class="text-red">管理员回复：</span></div>{$rs[reply]}</div>{/if}
                                    {else}
                                        {if $islogin==0}
                                        <div class="tip">您需要登录后才可以查看，请先<a href="{N('login')}">登录</a>或<a href="{N('reg')}">注册</a></div>
                                        {elseif $view_lever==0 && $rs[userid]==$userid}
                                        <div class="tip">您所在用户组，无法查看帖子</div>
                                        {else}
                                            {$rs[content]}
                                            {if $rs[reply]<>''}<div class="line line-left"><span class="text-red">管理员回复：</span></div>{$rs[reply]}</div>{/if}
                                        {/if}
                                    {/if}
                                </div>
                            </div>
                        </li>
                        {/sdcms:rs}
                    </ul>

                    {if $pg->totalpage>1}
                    <div class="page page-center page-mid"><ul>{$showpage}</ul></div>
                    {/if}
                    {if $islogin==0}
                        <div class="form_reply">
                            <div class="face"><img src="{WEB_ROOT}upfile/noface.gif"><p>{$r_uname}</p></div>
                            <div class="info">
                                <textarea placeholder="您需要登录后才可以回复" disabled></textarea>
                            </div>
                            <div class="clear"></div>
                        </div>
                    {else}
                        {if $reply_lever==0}
                        <div class="form_reply">
                            <div class="face"><img src="{WEB_ROOT}upfile/noface.gif"><p>{$r_uname}</p></div>
                            <div class="info">
                                <textarea placeholder="您所在用户组没有回帖权限" disabled></textarea>
                            </div>
                            <div class="clear"></div>
                        </div>
                        {else}
                        <form method="post" class="post_reply">
                            <div class="form_reply">
                                <div class="face"><img src="{if strlen($r_uface)}{$r_uface}{else}{WEB_ROOT}upfile/noface.gif{/if}"><p>{$r_uname}</p></div>
                                <div class="info">
                                    <script id="content" name="content" type="text/plain" style="height:150px;"></script>
                                    <script>UE.getEditor('content',{serverUrl:'{U('home/upload/index')}',toolbars:editorBbs});</script>
                                    {if sdcms[bbs_reply_code]==1}
                                        <div class="input-group mt">
                                            <input type="text" class="form-ip radius-right-none" name="code" id="code" size="8" maxlength="8" placeholder="请输入验证码" data-rule="验证码:required;">
                                            <span class="code"><img src="{U('code')}" height="40" id="verify" title="点击更换验证码"></span>
                                        </div>
                                    {/if}
                                    <input type="submit" value="回复" class="btn btn-blue mt">
                                </div>
                                <div class="clear"></div>
                            </div>
                        </form>
                        {/if}
                    {/if}
                 </div>

            </div>

            <div class="righter box">
            	<div class="searchs">
                	<h2>论坛搜索</h2>
                    <form action="{U('home/bbs/search')}" method="get">
                        {if sdcms[url_mode]==1}<input type="hidden" name="c" value="bbs" /><input type="hidden" name="a" value="search" />{/if}
                    	<input type="text" name="keyword" placeholder="请输入关键字"><input type="submit" value="搜索">
                    </form>
                </div>
                
                <div class="topic">
                	<h2>热门主题</h2>
                    <ul>
                    	{sdcms:rs top="20" table="sd_bbs" where="islock=1" order="hits desc,replynum desc,bbs_id desc"}
                    	<li><span{if $i<4} class="hover"{/if}>{substr("0".$i,-2)}</span><a href="{N('bbsshow','','id='.$rs[bbs_id].'')}" title="{$rs[title]}">{$rs[title]}</a></li>
                        {/sdcms:rs}
                    </ul>
                </div>
                
            </div>
        </div>
        <!---->
    </div>
    
    {include file="foot.php"}

    <script>
	$(function()
	{
		$("#nav_bbs").addClass("hover");
		{if $islogin!=0&&$reply_lever==1}
		//快捷键提交评论
	    $(".post_reply").find('textarea').on("keydown", function(e){
	    	e.stopPropagation();
	    	if(e.ctrlKey && e.which ==13){
	    		$('.post_reply').submit();
	    	}
	    });
		
		$(".post_reply").form(
		{
			type:2,
			align:'bottom-center',
			result:function(form)
			{
				var content=UE.getEditor('content').getContent();
				if(content=='')
				{
					toastr.error('回复内容不能为空');
					return false;	
				}
				$.ajax(
				{
					type:'post',
					cache:false,
					dataType:'json',
					url:"{U('home/bbs/reply','id='.$id.'')}",
					data:$(form).serialize(),
					error:function(e){alert(e.responseText);},
					success:function(d)
					{
						if(d.state=='success')
						{
							sdcms.success(d.msg);
							setTimeout(function(){location.href='{THIS_LOCAL}';},1500);
						}
						else
						{
							sdcms.error(d.msg);
						}  
					}
				});
			}
		});
		{/if}
	})
	</script>
</body>
</html>