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)); }