<include file="__THEME__/public_header" />


<div id="page-wrap">
  <div id="main-wrap">
    <div id="st-index-grid">
    <!--左边 -->
      <include file="__THEME__/public_left" />
      <div id="col8" class="content-bg clearfix boxShadow">
        <div id="col4" class="main-left">
          <div id="aside" class="pad">
            <dl class="nav-left mt10 border-no">

              <dd <neq name='_GET.type' value='send'>class="current"</neq>>
                <a href="{:U('public/Comment/index',array('app_name'=>t($_GET['app_name']),'type'=>'receive'))}">收到的评论</a>
              </dd>
              <dd <eq name='_GET.type' value='send'>class="current"</eq>>
                <a href="{:U('public/Comment/index',array('app_name'=>t($_GET['app_name']),'type'=>'send'))}">发出的评论</a>
              </dd>
              <dd><a href="{:U('public/Message')}">我的私信</a></dd>
              <dd><a href="{:U('public/Message/notify')}">系统消息</a></dd>
            </dl>
          </div>
        </div>
        <div id="col7" class="main-right">
          <div class="extend minh person-set">
            <div class="feed-nav">
              <div class="set-hd">
                <h3><neq name='_GET.type' value='send'>{:L('PUBLIC_RECEIVE_COMMENT')}</neq><eq name='_GET.type' value='send'>{:L('PUBLIC_SEND_COMMENT')}</eq></h3>
              </div>
              <div class="mod-feed-tab">
                <ul class="inner-feed-nav">
                  <li <eq name='_GET.t' value=''>class="current"</eq>>
                    <a href="{:U('public/Comment',array('type'=>t($_GET['type'])))}">{:L('PUBLIC_ALL_STREAM')}</a>
                  </li>
                  <volist name='tab' id='t'>
                    {eqxue{if($tabHash[$key]){?}
                      <li <eq name='_GET.t' value='$key'>class="current"</eq>>
                        <a href="{:U('public/Comment',array('t'=>$key,'type'=>t($_GET['type'])))}">{$tabHash[$key]}</a>
                      </li>
                    {eqxue{}?}
                  </volist>
                </ul>
              </div>
            </div>
            {eqxue{ $cancomment1 = intval(CheckPermission('core_normal','feed_comment')); ?}
            <!-- 收到的评论 -->
            {eqxue{if($_GET['type'] == 'receive'):?}
            <div class="feed_lists" id="comment-lists">
              <neq name='list.data' value=''>
              <volist name='list.data' id='vo'>
              <dl class="feed_list clearfix" id="comment_list" model-node='comment_list'>
                <dt class="face"><a href="{$vo.user_info.space_url}"><img src="{$vo.user_info.avatar_small}" width="50" height="50"></a></dt>
                <dd class="content">
                  <?php $source_user_at = '@{uid='.$vo['sourceInfo']['source_user_info']['uid'].'|uname='.$vo['sourceInfo']['source_user_info']['uname'].'}：';?>
                  {eqxue{if($vo['sourceInfo']['feedtype'] == 'post' || $vo['sourceInfo']['feedtype'] == 'weiba_post'):?}
                  <p class="hd"><space uid="vo.user_info.uid">{uname}</space>：{$vo.content}
                  </p>
                  <dl class="comment">
                    <dt class="arrow bgcolor_arrow"><em class="arrline">◆</em><span class="downline">◆</span></dt>
                    <dd class="name"><space uid="vo.sourceInfo.source_user_info.uid">@{uname}</space></dd>
                    <dd>{$vo.sourceInfo.source_body|format=true}</dd>
                  </dl>
                  {eqxue{elseif($vo['sourceInfo']['feedtype'] == 'repost'):?}
                  <p class="hd"><space uid="vo.user_info.uid">{uname}</space>：{$vo.content}//{$source_user_at|parse_html}{$vo.sourceInfo.source_body|format=true}
                  </p>
                  {eqxue{else:?}
                  <p class="hd"><space uid="vo.user_info.uid">{uname}</space>：
                    {eqxue{if($vo['is_audit']){?}
                      {$vo.content}
                    {eqxue{}else{?}
                      内容正在审核
                    {eqxue{}?}
                  </p>
                  <dl class="comment">
                    <dt class="arrow bgcolor_arrow"><em class="arrline">◆</em><span class="downline">◆</span></dt>
                    <dd class="name"><space uid="vo.sourceInfo.source_user_info.uid">@{uname}</space></dd>
                    <dd>{$vo.sourceInfo.source_body|format=true}</dd>
                  </dl>
                  {eqxue{endif;?}
                  <p class="info">
                    {eqxue{if($vo['is_audit']){?}
                      <span class="right">
                      {eqxue{if(CheckPermission('core_normal','comment_del')){?}
                        <em class="hover">
                          <a event-args="comment_id={$vo.comment_id}" event-node="comment_del" href="javascript:void(0);">{:L('PUBLIC_STREAM_DELETE')}</a>
                          <i class="vline">|</i>
                        </em>
                        {eqxue{}?}
                        <a href="{$vo.sourceInfo.source_url}">{:L('PUBLIC_VIEW')}</a>
                        {eqxue{if(in_array('comment',$weibo_premission)):?}
                        <neq name='_GET.type' value='send'>
                        <i class="vline">|</i><a href="javascript:void(0);" onclick="if({$cancomment1}){ui.reply({eqxue{echo $vo['comment_id'];?});}else{ui.error('没有权限');}">{:L('PUBLIC_STREAM_REPLY')}</a>
                        </neq>
                        {eqxue{endif;?}
                      </span>
                      <span class="date">{$vo.ctime|friendlyDate}</span>&nbsp;
                      <span>来自网站</span>
                      {eqxue{if($i<=$unread_comment_count){?}
                        <img src="__THEME__/image/icon_new.gif" />
                      {eqxue{}?}
                    {eqxue{}?}
                  </p>
                </dd>
              </dl>
              </volist>
              <else />
              <div class="note">{:L('PUBLIC_COMMENTS_ISNOT')}</div>
              </neq>
              <div id='page' class='page'>{$list.html}</div>
            </div>
            {eqxue{else:?}
            <!-- 发出的评论 -->
            <div class="feed_lists" id="feed-lists">
              <neq name='list.data' value=''>
              <volist name='list.data' id='vo'>
              <dl class="feed_list" id="comment_list" model-node='comment_list'>
                <dt class="face"><a href="{$vo.user_info.space_url}"><img src="{$vo.user_info.avatar_small}"></a></dt>
                <dd class="content">
                  <?php $source_user_at = '@{uid='.$vo['sourceInfo']['source_user_info']['uid'].'|uname='.$vo['sourceInfo']['source_user_info']['uname'].'}：';?>
                  {eqxue{if($vo['sourceInfo']['feedtype'] == 'post' || $vo['sourceInfo']['feedtype'] == 'weiba_post'):?}
                  <p class="hd"><space uid="vo.user_info.uid">{uname}</space>：{$vo.content}{$vo.replyInfo|parse_html}</p>
                  <dl class="comment">
                    <dt class="arrow bgcolor_arrow"><em class="arrline">◆</em><span class="downline">◆</span></dt>
                    <dd class="name">{$vo.sourceInfo.source_user_info.space_link}</dd>
                    <dd>{$vo.sourceInfo.source_body|format=true}</dd>
                  </dl>
                  {eqxue{elseif($vo['sourceInfo']['feedtype'] == 'repost'):?}
                  <p class="hd"><space uid="vo.user_info.uid">{uname}</space>：{$vo.content}//{$source_user_at|parse_html}{$vo.sourceInfo.source_body|format=true}</p>
                  {eqxue{else:?}
                  <p class="hd"><space uid="vo.user_info.uid">{uname}</space>：{$vo.content}</p>
                  <dl class="comment">
                    <dt class="arrow bgcolor_arrow"><em class="arrline">◆</em><span class="downline">◆</span></dt>
                    <dd class="name"><space uid="vo.sourceInfo.source_user_info.uid">@{uname}</space></dd>
                    <dd>{$vo.sourceInfo.source_body|format=true}</dd>
                  </dl>
                  {eqxue{endif;?}
                  <p class="info">
                    <span class="right">
                    {eqxue{if(CheckPermission('core_normal','comment_del')){?}
                      <em class="hover">
                        <a event-args="comment_id={$vo.comment_id}" event-node="comment_del" href="javascript:void(0);">{:L('PUBLIC_STREAM_DELETE')}</a>
                        <i class="vline">|</i>
                      </em>
                      {eqxue{}?}
                      <a href="{$vo.sourceInfo.source_url}">{:L('PUBLIC_VIEW')}</a>
                      <neq name='_GET.type' value='send'>
                      <i class="vline">|</i><a href="javascript:void(0);" onclick="if({$cancomment1}){ui.reply({eqxue{echo $vo['comment_id'];?});}else{ui.error('没有权限');}">{:L('PUBLIC_STREAM_REPLY')}</a>
                      </neq>
                    </span>
                    <span class="date">{$vo.ctime|friendlyDate}</span>&nbsp;
                    <span>来自网站</span>
                  </p>
                </dd>
              </dl>
              </volist>
              <else />
              <div class="note">{:L('PUBLIC_COMMENTS_ISNOT')}</div>
              </neq>
              <div id='page' class='page'>{$list.html}</div>
            </div>
            {eqxue{endif;?}
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

<script type="text/javascript" src="__THEME__/js/module.weibo.js"></script>
<script type="text/javascript">
M.addEventFns({
  img_small:{ //图片显示
    click:function(){
      $(this.parentModel).find('div').each(function(){
        if($(this).attr('rel') == 'small'){
          $(this).hide();
        }else if($(this).attr('rel') == 'big'){
          $(this).show()
        }
      });
    }
  },
  img_big:{
    click:function(){
      $(this.parentModel).find('div').each(function(){
        if($(this).attr('rel') == 'small'){
          $(this).show();
        }else if($(this).attr('rel') == 'big'){
          $(this).hide()
        }
      });
    }
  },
  comment_del:{
    click:function(){
      var attrs = M.getEventArgs(this);
      var pmodel = this.parentModel;
      ui.confirm(this,'{:L('PUBLIC_COMMENT_CONFIRM_TIPS')}',function(msg){
        $(pmodel).fadeOut();
        core.comment.delComment(attrs.comment_id);  
      });
    },
    load:function(){
      core.plugInit('comment');
    }
  }
});

  //旋转图片
function revolving (type, id) {
  var img = $("#image_index_"+id);
  img.rotate(type);
}


$.fn.rotate = function(p){

  var img = $(this)[0],
    n = img.getAttribute('step');
  // 保存图片大小数据
  if (!this.data('width') && !$(this).data('height')) {
    this.data('width', img.width);
    this.data('height', img.height);
  };
  this.data('maxWidth',img.getAttribute('maxWidth'))

  if(n == null) n = 0;
  if(p == 'left'){
    (n == 0)? n = 3 : n--;
  }else if(p == 'right'){
    (n == 3) ? n = 0 : n++;
  };
  img.setAttribute('step', n);

  // IE浏览器使用滤镜旋转
  if(document.all) {
    if(this.data('height')>this.data('maxWidth') && (n==1 || n==3) ){
      if(!this.data('zoomheight')){
        this.data('zoomwidth',this.data('maxWidth'));
        this.data('zoomheight',(this.data('maxWidth')/this.data('height'))*this.data('width'));
      }
      img.height = this.data('zoomwidth');
      img.width  = this.data('zoomheight');
      
    }else{
      img.height = this.data('height');
      img.width  = this.data('width');
    }
    
    img.style.filter = 'progid:DXImageTransform.Microsoft.BasicImage(rotation='+ n +')';
    // IE8高度设置
    if ($.browser.version == 8) {
      switch(n){
        case 0:
          this.parent().height('');
          //this.height(this.data('height'));
          break;
        case 1:
          this.parent().height(this.data('width') + 10);
          //this.height(this.data('width'));
          break;
        case 2:
          this.parent().height('');
          //this.height(this.data('height'));
          break;
        case 3:
          this.parent().height(this.data('width') + 10);
          //this.height(this.data('width'));
          break;
      };
    };
  // 对现代浏览器写入HTML5的元素进行旋转： canvas
  }else{
    var c = this.next('canvas')[0];
    if(this.next('canvas').length == 0){
      this.css({'visibility': 'hidden', 'position': 'absolute'});
      c = document.createElement('canvas');
      c.setAttribute('class', 'maxImg canvas');
      img.parentNode.appendChild(c);
    }
    var canvasContext = c.getContext('2d');
    switch(n) {
      default :
      case 0 :
        img.setAttribute('height',this.data('height'));
        img.setAttribute('width',this.data('width'));
        c.setAttribute('width', img.width);
        c.setAttribute('height', img.height);
        canvasContext.rotate(0 * Math.PI / 180);
        canvasContext.drawImage(img, 0, 0);
        break;
      case 1 :
        if(img.height>this.data('maxWidth') ){
          h = this.data('maxWidth');
          w = (this.data('maxWidth')/img.height)*img.width;
        }else{
          h = this.data('height');
          w = this.data('width');
        }
        c.setAttribute('width', h);
        c.setAttribute('height', w);
        canvasContext.rotate(90 * Math.PI / 180);
        canvasContext.drawImage(img, 0, -h, w ,h );
        break;
      case 2 :
        img.setAttribute('height',this.data('height'));
        img.setAttribute('width',this.data('width'));
        c.setAttribute('width', img.width);
        c.setAttribute('height', img.height);
        canvasContext.rotate(180 * Math.PI / 180);
        canvasContext.drawImage(img, -img.width, -img.height);
        break;
      case 3 :
        if(img.height>this.data('maxWidth') ){
          h = this.data('maxWidth');
          w = (this.data('maxWidth')/img.height)*img.width;
        }else{
          h = this.data('height');
          w = this.data('width');
        }
        c.setAttribute('width', h);
        c.setAttribute('height', w);
        canvasContext.rotate(270 * Math.PI / 180);
        canvasContext.drawImage(img, -w, 0,w,h);
        break;
    };
  };
};
</script>
<include file="__THEME__/public_footer" />