{include file="$template_path/html/header.html"}
<link href="{$template_data}css/custom/resource.css" rel="stylesheet" />
<link href="{$template_data}css/custom/mobile.css" media="screen" rel="stylesheet" type="text/css" />
</head>
<body>
{include file="$template_path/html/pagenav.html"}
<div class="pagetit pagetabs">
  <div class="navblock">
    <ul class="titnav clr">
      <li><a href="/" title="主页">主页</a></li>
      <li class="pipe">&gt;</li>
      <li><a href="/{$languageURL}categories/all/" title="文件">文件</a></li>
      <li class="pipe">&gt;</li>
      {foreach from=$item.categories item=e}
        {foreach from=$e item=c name=foo}
          <li><a href="/{$languageURL}categories/{$categories[$c].id}" title="{$categories[$c].name}">{$categories[$c].name}</a></li>
          {if !$smarty.foreach.foo.last}<li class="pipe">&gt;</li>{/if}
        {/foreach}
      {/foreach}
    </ul>
    <h2>{$item.name}</h2>
    <ul class="pagetab clr">
      <li><a href="/{$languageURL}items/{$item.id}" title="文件详情">作品详情</a></li>
      {if $faqs>0 || check_login_bool() && $item.user_id == $smarty.session.user.user_id}
      <li><a{if $smarty.get.controller == 'faq'} class="active"{/if} href="/{$languageURL}items/faq/{$item.id}" title="常见问题解答">常见问题解答</a></li>
      {/if}
      {if check_login_bool() && $item.user_id == $smarty.session.user.user_id}
      <li><a{if $smarty.get.controller == 'edit'} class="active"{/if} href="/{$languageURL}items/edit/{$item.id}" title="编辑">编辑</a></li>
      {/if}
        {if check_login_bool() && $item.user_id == $smarty.session.user.user_id}
        <li><a{if $smarty.get.controller == 'record'} class="active"{/if} href="/{$languageURL}items/record/{$item.id}" title="购买记录">购买记录</a></li>
        {/if}
      <li><a{if $smarty.get.controller == 'comments'} class="active"{/if} href="/{$languageURL}items/comments/{$item.id}" title="评论">评论</a></li>
    </ul>
  </div>
</div>
<div class="resourcebg">
  <div class="pageblock clr">
    {$errorMessage}
    {include file="$root_path/apps/items/views/purchase_panel.html"}
    <div class="leftdetail">

<div class="commentblock">
  {if $paging}
  <div class="pagenums clr">
    <div class="pagination">
    {$paging}
    </div>
  </div>
  {/if}
  {if $comments}
  <div class="commentlist">
    {foreach from=$comments item=c}
    <div class="comment clr">
      <div class="comment__user">
        <a href="/{$languageURL}user/{$users[$c.user_id].username}" class="avatar" title="{$users[$c.user_id].username}">
        {if $users[$c.user_id].avatar != ''} 
        <img alt="{$users[$c.user_id].username}" class="" src="{$data_server}uploads/users/{$c.user_id}/A_{$users[$c.user_id].avatar}" />
        {else}
        <img alt="{$users[$c.user_id].username}" class="" src="{$template_data}img/default-user.jpg" />
        {/if}
        <span>{$users[$c.user_id].username}</span>
        </a>
      </div>
      <div class="comment__container">
        <div class="content-box comment__body">
          <div class="comment__header">
            <a href="/{$languageURL}user/{$users[$c.user_id].username}" class="comment__username">{$users[$c.user_id].nickname}</a>
            {if $item.user_id == $c.user_id}
              <strong class="comment__user-type--author">作者</strong>
            {elseif isset($buyFromUsers[$c.user_id])}
              <strong class="comment__user-type--purchased">买家</strong>
            {/if}
          </div>
          <p>{$c.comment|nl2br}</p>
          <div class="comment__meta">
            发表于 {$c.datetime|date_format:"%Y-%m-%d"}
            {if $c.report_by == '0'}
            <a href="/{$languageURL}items/comments/{$item.id}/?report={$c.id}" class="glyph-flag fancybox"><span class="glyph-alt">报告评论问题</span></a>
            {/if} 
          </div>
        </div>
        {if isset($c.reply)}
        {foreach from=$c.reply item=cc}
        <div class="comment__reply ">
          <a href="/{$languageURL}user/{$users[$cc.user_id].username}" class='comment__reply__avatar'>
            {if $users[$cc.user_id].avatar != ''} 
            <img alt="{$users[$cc.user_id].username}" height="30" src="{$data_server}uploads/users/{$cc.user_id}/A_{$users[$cc.user_id].avatar}" width="30" />
            {else}
            <img alt="{$users[$cc.user_id].username}" class="avt" height="30" src="{$template_data}img/default-user.jpg" width="30" />
            {/if}
          </a>
          <div class="comment__reply__body">
            <div class="comment__header">
              <a href="/{$languageURL}user/{$users[$cc.user_id].username}" class="comment__username">{$users[$cc.user_id].nickname}</a>
              {if $item.user_id == $cc.user_id}
              <strong class="comment__user-type--author">作者</strong>
              {elseif isset($buyFromUsers[$cc.user_id])}
              <strong class="comment__user-type--purchased">买家</strong>
              {/if}
            </div>
            <p>{$cc.comment|nl2br}</p>
          </div>
          <div class="comment__meta">
            发表于 {$cc.datetime|date_format:"%Y-%m-%d"}
            {if $cc.report_by == '0'}
            <a href="/{$languageURL}items/comments/{$item.id}/?report={$cc.id}" onclick="return confirm('{$lang.are_you_sure_report}');" class="glyph-flag fancybox"><span class="glyph-alt">报告评论问题</span></a>
            {/if}
          </div>
        </div>
        {/foreach}
        {/if}
        <div id="replyhere_{$c.id}"></div>
        {literal}
        <script language="javascript">
        seajs.use(["jq"], function($){
          $("{/literal}#replyhere_{$c.id}{literal}").load("{/literal}/{$languageURL}items/reply/{$c.id}{literal}");
        });
        </script>
        {/literal}
      </div>
    </div> 
    {/foreach}   
  </div>
  {else}
  <div class="content-box vertical-space">暂时没有评论</div>
  {/if}
  {if check_login_bool()}
  <h2 class="box-heading">添加评论</h2>
  <div class="content-box">
    <form action="" method="post">
      <fieldset class="horizontal-form">
        <div class="input-group">
          <label for="item_comment_content">评论内容</label>
          <div class="inputs">
            <textarea class="big input supertall" name="comment" rows="1"></textarea>
          </div>
        </div>
        <div class="input-group">
          <label for="reply_notification">回复提醒？</label>
          <div class="inputs">
            <label for="reply_notification">
              <input class="checkbox" id="reply_notification" name="reply_notification" type="checkbox" value="1" />
              当我收到一个回复时提醒我
            </label>
          </div>
        </div>
      </fieldset>
      <div class="form-submit">
        <button type="submit" name="add" class="btntheme btnsize">提交评论</button>
      </div>
    </form>
  </div>
  {literal}
  <script type="text/javascript">
  seajs.use(["jq"], function($){
    $(function(){
      $("textarea.comment__new-reply-field").live("keyup keydown",function(){
        var h=$(this);
        h.height(20).height(h[0].scrollHeight); 
      });
    });
  });
  </script>
  {/literal}
  {/if}
</div>

    </div>
    {include file="$root_path/apps/items/views/rightside.html"}
  </div>
</div>
{include file="$template_path/html/footer.html"}
</body>
</html>