/**
  * {@inheritDoc}
  * @see ReactComponentInterface::queryElements()
  */
 public function get($route)
 {
     global $user;
     $options = $this->getOptions();
     $node = node_load($options['nid']);
     if ($options['uid'] != $user->uid || !is_object($node)) {
         return;
     }
     // Only attempt to render comments if the node has visible comments.
     // Unpublished comments are not included in $node->comment_count, so show
     // comments unconditionally if the user is an administrator.
     if (user_access('access comments') || user_access('administer comments')) {
         $mode = COMMENT_MODE_THREADED;
         $comments_per_page = $options['limit'];
         if ($cids = comment_get_thread($node, $mode, $comments_per_page)) {
             $this->_elements = comment_load_multiple($cids);
         }
     }
 }
 public function actionNormal()
 {
     if (isset($_POST['newsid'])) {
         $newsid = $_POST['newsid'];
     } else {
         $basic = new basic();
         $basic->error_code = 1;
         $basic->error_msg = "no input parameters";
         $jsonObj = CJSON::encode($basic);
         echo $jsonObj;
         die(0);
     }
     $newsdetail['error_code'] = 0;
     //$newsdetail->error_msg=
     $node = node_load($newsid);
     if (!$node->field_yuedushu) {
         $node->field_yuedushu['und'][0]['value'] = 0;
     }
     $node->field_yuedushu['und'][0]['value'] = $node->field_yuedushu['und'][0]['value'] + 1;
     node_save($node);
     $newsdetail['newsid'] = $newsid;
     $newsdetail['newstitle'] = str_replace(" ", "", $node->title);
     $newscontent = $node->body['und'][0]['value'];
     $newscontent = str_replace("/tydaily2", Yii::app()->name . 'tydaily2', $newscontent);
     $mobile = "<meta charset=\"UTF-8\"><meta content=\"width=device-width,user-scalable=yes,initial-scale=1\" name=\"viewport\">";
     $ccs = "<style type=\"text/css\">p{text-align:justify;line-height:1.75em;margin:1px;font-family:Microsoft YaHei;font-size:18px;}img{margin:2px;max-width:100%;text-align:center;} </style>";
     $mobile = '<head>' . $mobile . $ccs . '</head>';
     if ($node->type == "_xinwen") {
         $field_fubiaoti = str_replace(" ", "", $node->field_subtitle['und'][0]['value']);
         $newsdetail['newssubtitle'] = $field_fubiaoti;
         $newsdetail['newsfrom'] = "太原日报";
         $newsdetail['shareimg'] = $node->field_suoluetu['und'][0]['value'];
         $newsdetail['shareurl'] = Yii::app()->name . 'epaper2/index.php?r=news/ashare&id=' . $node->nid;
         $newsdetail['pageno'] = $node->field_pageno['und'][0]['value'];
         $newsdetail['pagename'] = $node->field_pagename['und'][0]['value'];
         $riqi = strtotime($node->field_riq['und'][0]['value']);
         $newsdetail['createtime'] = date('Y年m月d日', $riqi);
         //$newsdetail['createtime']=$node->field_riq['und'][0]['value'];
         //$ccs="<style type=\"text/css\">p{font-size:120%;line-height:1.5em;text-indent: 2em;text-align:justify;}</style>";
         $ccs = "<style type=\"text/css\">p{text-indent: 2em;}</style>";
         $newscontent = nl2br($newscontent);
         $newscontent = str_replace("<br />", "</p><p>", $newscontent);
         $newscontent = str_replace("&nbsp;", "", $newscontent);
         $newscontent = str_replace("width:100", "max-width:100", $newscontent);
         //$newscontent=str_replace("<p>","<p style='font-size:120%;line-height:1.5em;text-indent: 2em;text-align:justify;'>",$newscontent);
         $newsdetail['newscontent'] = $mobile . $ccs . '<body>' . $newscontent . '</body>';
         //$newsdetail['newscontent']=$mobile.$newscontent;
     } else {
         $newsdetail['newssubtitle'] = $node->field_fubiaoti['und'][0]['value'];
         $newsdetail['newsfrom'] = $node->field_src['und'][0]['value'];
         $name = user_load($node->uid)->field_nick['und'][0]['value'];
         if ($name) {
             $newsdetail['author'] = $name;
         } else {
             $newsdetail['author'] = '太原日报APP';
         }
         $newsdetail['newscontent'] = $mobile . '<body>' . $newscontent . '</body>';
         $newsdetail['shareurl'] = Yii::app()->name . 'epaper2/index.php?r=news/share&id=' . $node->nid;
         $newsdetail['shareimg'] = $node->field_image['und'][0]['uri'];
         $newsdetail['shareimg'] = str_replace("public://", ThumbnailImg, $newsdetail['shareimg']);
         if (count($node->field__shijian)) {
             $newsdetail['createtime'] = $node->field__shijian['und'][0]['value'];
         } else {
             $newsdetail['createtime'] = date('Y-m-d H:i:s', $node->created);
         }
         //相关链接
         if ($node->field_link) {
             if ($node->field_linkpic) {
                 $field_linkpic = $node->field_linkpic;
                 $img = $field_linkpic['und'][0]['uri'];
                 $link['linkimg'] = str_replace("public://", BigImg, $img);
                 $link['linkurl'] = $node->field_link['und'][0]['value'];
                 $newsdetail['link'] = $link;
             }
         }
         //新闻推荐
         if ($node->field__tuijian['und']) {
             $recommends = array();
             $tuijians = $node->field__tuijian['und'];
             foreach ($tuijians as $recommend) {
                 $news = node_load($recommend['value']);
                 if ($news->type == 'article') {
                     $re['recommendid'] = $news->nid;
                     $re['recommendtitle'] = $news->title;
                     $re['recommendsubtitle'] = $news->field_fubiaoti['und'][0]['value'];
                     $re['recommendicon'] = $news->field_image['und'][0]['uri'];
                     $re['recommendicon'] = str_replace("public://", BigImg, $re['recommendicon']);
                     array_push($recommends, $re);
                 }
             }
             $newsdetail['recommends'] = $recommends;
         }
     }
     $comtlist = array();
     //评论
     $query = new EntityFieldQuery();
     $query->entityCondition('entity_type', 'comment')->propertyCondition('nid', $newsid)->propertyCondition('status', 1)->propertyCondition('pid', 0);
     $result = $query->execute();
     if (isset($result['comment'])) {
         $news_items_nids = array_keys($result['comment']);
         $comments = comment_load_multiple($news_items_nids);
     }
     if ($comments) {
         //print_r($comments);
         foreach ($comments as $c) {
             //print_r($c);
             $comment = new newc();
             $u = user_load($c->uid);
             $comment->comtid = $c->cid;
             $comment->comtusername = $u->field_nick['und'][0]['value'];
             $comment->comtuserheadimg = str_replace("public://", BigImg, $u->picture->uri);
             $comment->comtcontent = $c->subject;
             $comment->comttime = date('Y-m-d H:i:s', $c->created);
             if ($c->field_praise) {
                 $comment->comtpraise = count($c->field_praise['und']);
             } else {
                 $comment->comtpraise = 0;
             }
             //子评论
             $childcomtlist = array();
             $query = new EntityFieldQuery();
             $query->entityCondition('entity_type', 'comment')->propertyCondition('pid', $c->cid);
             $result = $query->execute();
             if (isset($result['comment'])) {
                 $news_items_nids = array_keys($result['comment']);
                 $childcmts = comment_load_multiple($news_items_nids);
                 if ($childcmts) {
                     foreach ($childcmts as $childcmt) {
                         //print_r($childcmt);
                         $childcomt = new childcomt();
                         $childcomt->comtid = $childcmt->cid;
                         $childcomt->comtuserid = $childcmt->uid;
                         $user = user_load($childcmt->uid);
                         if ($user->picture->uri == "") {
                             $childcomt->comtuserheadimg = BigImg . 'user/basic.png';
                         } else {
                             $childcomt->comtuserheadimg = str_replace("public://", BigImg, $user->picture->uri);
                         }
                         $childcomt->comtusername = $user->field_nick['und'][0]['value'];
                         $childcomt->comtcontent = $childcmt->subject;
                         $childcomt->comttime = date('Y-m-d H:i:s', $childcmt->created);
                         array_push($childcomtlist, $childcomt);
                     }
                 }
             }
             $comment->childcomtlist = $childcomtlist;
             array_push($comtlist, $comment);
         }
     }
     $newsdetail['comtlist'] = $comtlist;
     $jsonObj = CJSON::encode($newsdetail);
     echo $jsonObj;
 }
示例#3
0
 public function actionView()
 {
     //date_default_timezone_set("Asia/Shanghai");
     if (isset($_POST['newsid'])) {
         $newsid = $_POST['newsid'];
     } else {
         $basic = new basic();
         $basic->error_code = 1;
         $basic->error_msg = "no input parameters";
         $jsonObj = CJSON::encode($basic);
         echo $jsonObj;
         die(0);
     }
     $article = node_load($newsid);
     if (!$article->field_yuedushu) {
         $article->field_yuedushu['und'][0]['value'] = 0;
     }
     $article->field_yuedushu['und'][0]['value'] = $article->field_yuedushu['und'][0]['value'] + 1;
     node_save($article);
     if ($article) {
         $newsView['id'] = $article->nid;
         $newsView['title'] = $article->title;
         $newsView['createtime'] = date('Y年m月d日 H:i:s', $article->created);
         $newsView['content'] = nl2br($article->body['und'][0]['value']);
         $newsView['content'] = '       ' . preg_replace('/(\\s){2,}/', "\r<br />\n      ", $newsView['content']);
         if ($article->field_shimin) {
             $newsView['src'] = $article->field_shimin['und'][0]['value'];
         } else {
             $newsView['src'] = '匿名';
         }
         $newsView['img'] = str_replace("public://", BigImg, $article->field_tux['und'][0]['uri']);
         //评论
         $comtlist = array();
         $query = new EntityFieldQuery();
         $query->entityCondition('entity_type', 'comment')->propertyCondition('nid', $newsid)->propertyCondition('status', 1)->propertyCondition('pid', 0);
         $result = $query->execute();
         if (isset($result['comment'])) {
             $news_items_nids = array_keys($result['comment']);
             $comments = comment_load_multiple($news_items_nids);
         }
         if ($comments) {
             foreach ($comments as $c) {
                 $comment['comtname'] = $c->subject;
                 $comment['comtcontent'] = $c->comment_body['und'][0]['value'];
                 $comment['comttime'] = date('Y-m-d H:i:s', $c->created);
                 array_push($comtlist, $comment);
             }
         }
         $newsView['comtlist'] = $comtlist;
         $jsonObj = CJSON::encode($newsView);
         echo $jsonObj;
     } else {
         $basic = new basic();
         $basic->error_code = 2;
         $basic->error_msg = "error article";
         $jsonObj = CJSON::encode($basic);
         echo $jsonObj;
         die(0);
     }
 }
示例#4
0
 public function actionMycoms()
 {
     if (isset($_POST['uid'])) {
         $all = array();
         $mySends = array();
         //我发出的评论
         $query = new EntityFieldQuery();
         $query->entityCondition('entity_type', 'comment')->propertyCondition('status', 1)->propertyOrderBy('created', 'DESC')->propertyCondition('uid', $_POST['uid']);
         $result = $query->execute();
         if (isset($result['comment'])) {
             $news_items_nids = array_keys($result['comment']);
             $comments = comment_load_multiple($news_items_nids);
             if ($comments) {
                 foreach ($comments as $c) {
                     $myCmt['nid'] = $c->nid;
                     $node = node_load($c->nid);
                     if ($node->type == 'multi') {
                         $myCmt['ntype'] = 2;
                     } else {
                         $myCmt['ntype'] = 1;
                     }
                     //$myCmt['news']=strip_tags($node->body['und'][0]['value']);
                     $myCmt['ntitle'] = $node->title;
                     /*
                     $user=user_load($c->uid);	
                     if($user->picture->uri=="")
                     	$myCmt['comtuserheadimg']=BigImg.'user/basic.png';
                     else
                     	$myCmt['comtuserheadimg']=str_replace("public://",BigImg,$user->picture->uri);			
                     $myCmt['comtusername']=$user->field_nick['und'][0]['value']; 
                     
                     $myCmt['comtcontent']=$c->subject;
                     */
                     $myCmt['comttime'] = date('Y-m-d H:i:s', $c->created);
                     array_push($mySends, $myCmt);
                 }
             }
         }
         $all['mySends'] = $mySends;
         //我收到的评论
         $myRecvs = array();
         $criteria = new CDbCriteria();
         $criteria->condition = 'toid=:toid';
         $criteria->params = array(':toid' => $_POST['uid']);
         $criteria->order = 'id DESC';
         $myrecvss = Cominfo::model()->findAll($criteria);
         foreach ($myrecvss as $c) {
             $myCmt['nid'] = $c->nid;
             $node = node_load($c->nid);
             if ($node->type == 'multi') {
                 $myCmt['ntype'] = 2;
             } else {
                 $myCmt['ntype'] = 1;
             }
             $myCmt['ntitle'] = $node->title;
             /*
             $user=user_load($c->uid);	
             if($user->picture->uri=="")
             	$myCmt['comtuserheadimg']=BigImg.'user/basic.png';
             else
             	$myCmt['comtuserheadimg']=str_replace("public://",BigImg,$user->picture->uri);
             $myCmt['comtusername']=$c->uname;
             */
             $myCmt['comtcontent'] = $c->ucontent;
             $myCmt['comttime'] = $c->create_time;
             array_push($myRecvs, $myCmt);
         }
         Cominfo::model()->updateAll(array('isnew' => 0), 'toid=:toid', array(':toid' => $_POST['uid']));
         $all['myRecvs'] = $myRecvs;
     } else {
         $all['error_code'] = 1;
         $all['error_msg'] = "no enough input parameters";
     }
     $jsonObj = CJSON::encode($all);
     echo $jsonObj;
 }