コード例 #1
0
 public function actionIndex()
 {
     $id = Yii::app()->getRequest()->getQuery('id');
     $app = AppInfoList::model()->published()->findByPk($id);
     if (!$app instanceof AppInfoList) {
         throw new THttpException('查看的App审核中或不存在');
     }
     $this->pageTitle = 'App哥伦部 - 《' . $app->AppName . '》';
     $aInfo = array();
     //app_info_list表的基本信息
     $aInfo['Id'] = $app->Id;
     $aInfo['AppName'] = $app->AppName;
     $aInfo['Remarks'] = htmlspecialchars($app->Remarks);
     $aInfo['IconUrl'] = $app->IconUrl;
     $aInfo['CommentCount'] = $app->reply_count;
     $aInfo['CommitUserId'] = $app->CommitUserId;
     $aInfo['AppUrl'] = CommonFunc::transUrl($app->AppUrl);
     $aInfo['CommitTime'] = AppInfoList::getPeriod($app->CommitTime);
     $aInfo['AppInfo'] = $app->AppInfo;
     $aInfo['SourceId'] = $app->SourceId;
     $aInfo['markName'] = Source::getSourceName($app->SourceId);
     $aInfo['pushListObj'] = isset($app->pushListObj) && $app->pushListObj->FileSize ? $app->pushListObj->FileSize : "0MB";
     //app_info_list赞的总数
     $appID = $app->Id;
     $count_key = 'link_' . $appID;
     $memberArray = CommonFunc::getRedis('user_' . Yii::app()->user->id);
     $aInfo['hasFavorited'] = false;
     $aInfo['isUpped'] = false;
     if (!empty($memberArray)) {
         $aInfo['hasFavorited'] = isset($memberArray['favorite'][$appID]) ? 1 : 0;
         if (!isset($memberArray['like'])) {
             $memberArray['like'] = array();
         }
         $aInfo['isUpped'] = in_array($app->Id, $memberArray['like']) ? true : false;
     }
     $countArray = CommonFunc::getRedis($count_key);
     if (!empty($countArray)) {
         if (!isset($countArray['count'])) {
             $countArray['count'] = 0;
         }
         if (!isset($countArray['user'])) {
             $countArray['user'] = array();
         }
         $aInfo['count'] = $countArray['count'];
         $aInfo['p_user'] = AppInfoList::getLikedPeople($countArray['user'], 0);
     } else {
         $aInfo['count'] = 0;
         $aInfo['p_user'] = array();
     }
     //发信息的人
     $user = $app->link_user;
     if (!empty($user)) {
         $aInfo['username'] = htmlspecialchars($user->UserName);
         if (!empty($user['Icon'])) {
             $aInfo['userurl'] = $user->Icon;
         } else {
             $aInfo['userurl'] = '';
         }
     } else {
         $aInfo['username'] = '';
         $aInfo['userurl'] = '';
     }
     //信息的轮播图片(link_info表)
     $aInfo['imgurl'] = array();
     if (!empty($app->VideoUrl)) {
         $aInfo['videoUrl'] = $app->VideoUrl;
     }
     if (!empty($app->ScreenShoot)) {
         $aInfo['imgurl'] = explode(',', $app->ScreenShoot);
     }
     $aReply = array();
     $replies = AppReviews::model()->with('author_icon')->together()->findAll(array('select' => array('Id', 'Pid', 'Content', 'UpdateTime', 'AuthorId', 'ToAuthorId'), 'order' => 't.Pid asc, t.UpdateTime desc', 'condition' => 'AppId = :AppId', 'params' => array(':AppId' => $id)));
     if (!empty($replies)) {
         foreach ($replies as $single_reply) {
             $toAuthorNanme = '';
             if ($single_reply->ToAuthorId) {
                 $toAuthorNanme = htmlspecialchars($single_reply->toAuthor->UserName);
             }
             $replay_info = array('Id' => $single_reply->Id, 'Content' => $single_reply->Content, 'Pid' => $single_reply->Pid, 'AuthorName' => htmlspecialchars($single_reply->replyUser->UserName), 'UpdateTime' => AppInfoList::getPeriod($single_reply->UpdateTime), 'AuthorIcon' => $single_reply->author_icon->Icon, 'AuthorId' => $single_reply->AuthorId, 'ToAuthorID' => $single_reply->ToAuthorId, 'ToAuthorName' => $toAuthorNanme);
             if ($single_reply->Pid != 0) {
                 if (!isset($aReply[$single_reply->Pid])) {
                     $aReply[$single_reply->Pid] = array('children' => array($replay_info));
                 } else {
                     if (!isset($aReply[$single_reply->Pid]['children'])) {
                         $aReply[$single_reply->Pid]['children'] = array();
                     }
                     $aReply[$single_reply->Pid]['children'][] = $replay_info;
                 }
             } else {
                 if (!isset($aReply[$single_reply->Id])) {
                     $aReply[$single_reply->Id] = $replay_info;
                     $aReply[$single_reply->Id]['children'] = array();
                 } else {
                     $aReply[$single_reply->Id] = array_merge($aReply[$single_reply->Id], $replay_info);
                 }
             }
         }
     }
     foreach ($aReply as $key => $value) {
         if (!isset($value['Id']) || empty($value['Id'])) {
             unset($aReply[$key]);
         }
     }
     $aInfo['replies'] = $aReply;
     $this->render('detail', array('data' => $aInfo));
 }
コード例 #2
0
 public function actionAppDetail()
 {
     $appID = Yii::app()->getRequest()->getQuery('appid');
     if (empty($appID)) {
         echo new ReturnInfo(RET_ERROR, 'Argument appid passed to ' . __CLASS__ . '::' . __FUNCTION__ . '() that can not be empty.');
         Yii::app()->end();
     }
     $appInfoObj = AppInfoList::model()->findByPk($appID);
     if (empty($appInfoObj)) {
         echo new ReturnInfo(RET_ERROR, 'Argument appid passed to ' . __CLASS__ . '::' . __FUNCTION__ . '() that can not find a record.');
         Yii::app()->end();
     }
     $appInfoArray = array('id' => $appInfoObj->Id, 'appName' => $appInfoObj->AppName, 'remarks' => $appInfoObj->Remarks, 'commentCount' => $appInfoObj->reply_count, 'commitUserId' => $appInfoObj->CommitUserId, 'CommitTime' => AppInfoList::getPeriod($appInfoObj->CommitTime), 'markName' => Source::getSourceName($appInfoObj->SourceId), 'pushListObj' => isset($appInfoObj->pushListObj) && $appInfoObj->pushListObj->FileSize ? $appInfoObj->pushListObj->FileSize : "0MB", 'iconUrl' => $appInfoObj->IconUrl, 'appSource' => $appInfoObj->SourceId, 'appUrl' => $appInfoObj->AppUrl, 'appInfo' => $appInfoObj->AppInfo, 'up' => $appInfoObj->Up);
     $appID = $appInfoObj->Id;
     $count_key = 'link_' . $appID;
     $memberArray = CommonFunc::getRedis('user_' . Yii::app()->user->id);
     $appInfoArray['hasFavorited'] = false;
     $appInfoArray['isUpped'] = false;
     if (!empty($memberArray)) {
         $appInfoArray['hasFavorited'] = isset($memberArray['favorite'][$appID]) ? 1 : 0;
         if (!isset($memberArray['like'])) {
             $memberArray['like'] = array();
         }
         $appInfoArray['isUpped'] = in_array($appInfoObj->Id, $memberArray['like']) ? true : false;
     }
     $countArray = CommonFunc::getRedis($count_key);
     if (!empty($countArray)) {
         if (!isset($countArray['count'])) {
             $countArray['count'] = 0;
         }
         if (!isset($countArray['user'])) {
             $countArray['user'] = array();
         }
         $appInfoArray['count'] = $countArray['count'];
         $appInfoArray['p_user'] = AppInfoList::getLikedPeople($countArray['user'], 0);
     } else {
         $appInfoArray['count'] = 0;
         $appInfoArray['p_user'] = array();
     }
     //发信息的人
     $user = $appInfoObj->link_user;
     if (!empty($user)) {
         $appInfoArray['username'] = htmlspecialchars($user->UserName);
         if (!empty($user['Icon'])) {
             $appInfoArray['userurl'] = $user->Icon;
         } else {
             $appInfoArray['userurl'] = '';
         }
     } else {
         $appInfoArray['username'] = '';
         $appInfoArray['userurl'] = '';
     }
     //信息的轮播图片(link_info表)
     $appInfoArray['imgurl'] = array();
     if (!empty($appInfoObj->VideoUrl)) {
         $appInfoArray['videoUrl'] = $appInfoObj->VideoUrl;
     }
     if (!empty($appInfoObj->ScreenShoot)) {
         $appInfoArray['imgurl'] = explode(',', $appInfoObj->ScreenShoot);
     }
     echo new ReturnInfo(RET_SUC, $appInfoArray);
 }