Esempio n. 1
0
 public function actionReply($username, $page = null)
 {
     $this->title = $username . '发布的回复 - ' . Yii::$app->name;
     $this->description = '';
     $user = $this->findModel($username);
     $query = Reply::find()->where(['user_id' => $user->id]);
     $pagination = new Pagination(['defaultPageSize' => Yii::$app->params['pageSize'], 'totalCount' => $query->count()]);
     $model = $query->orderBy(['id' => SORT_DESC])->offset($pagination->offset)->limit($pagination->limit)->all();
     return $this->render('reply', ['model' => $model, 'user' => $user, 'pagination' => $pagination]);
 }
Esempio n. 2
0
 public function actionIndex()
 {
     //今天注册用户
     $model['userToday'] = User::find()->where(['between', 'created_at', strtotime(date('Y-m-d', time())), strtotime(date('Y-m-d', time())) + 86400])->count();
     //今天主题
     $model['topicToday'] = Topic::find()->where(['between', 'created', strtotime(date('Y-m-d', time())), strtotime(date('Y-m-d', time())) + 86400])->count();
     //今天回复
     $model['replyToday'] = Reply::find()->where(['between', 'created', strtotime(date('Y-m-d', time())), strtotime(date('Y-m-d', time())) + 86400])->count();
     //7天内注册用户
     $model['user7day'] = User::find()->where(['between', 'created_at', strtotime(date('Y-m-d', time())) - 86400 * 7, strtotime(date('Y-m-d', time()))])->count();
     //7天内主题
     $model['topic7day'] = Topic::find()->where(['between', 'created', strtotime(date('Y-m-d', time())) - 86400 * 7, strtotime(date('Y-m-d', time()))])->count();
     //7天内回复
     $model['reply7day'] = Reply::find()->where(['between', 'created', strtotime(date('Y-m-d', time())) - 86400 * 7, strtotime(date('Y-m-d', time()))])->count();
     //30天内注册用户
     $model['user30day'] = User::find()->where(['between', 'created_at', strtotime(date('Y-m-d', time())) - 86400 * 30, strtotime(date('Y-m-d', time()))])->count();
     //30天内主题
     $model['topic30day'] = Topic::find()->where(['between', 'created', strtotime(date('Y-m-d', time())) - 86400 * 30, strtotime(date('Y-m-d', time()))])->count();
     //30天内回复
     $model['reply30day'] = Reply::find()->where(['between', 'created', strtotime(date('Y-m-d', time())) - 86400 * 30, strtotime(date('Y-m-d', time()))])->count();
     return $this->render('index', ['model' => $model]);
 }
Esempio n. 3
0
 /**
  * Displays a single Topic model.
  * @param integer $id
  * @return mixed
  * @throws BadRequestHttpException
  * @throws NotFoundHttpException
  * @throws \Exception
  */
 public function actionView($id)
 {
     $model = $this->findModel($id);
     if ($model->need_login == 1 && Yii::$app->user->isGuest) {
         Yii::$app->getSession()->setFlash('danger', '你访问的主题需要登陆之后才能查看');
         return $this->redirect('/account/login?next=/topic/' . $id);
     }
     if (!empty($model->node->bg) && $model->node->use_bg == 1) {
         $this->bg = $model->node->bg;
     }
     if (!empty($model->node->bg_color)) {
         $this->bg_color = $model->node->bg_color;
     }
     if (isset($model->content->content)) {
         $this->description = $model->node->name . ' - ' . $model->user->username . ' - ' . Helper::truncateUtf8String($model->content->content, 200);
     } else {
         $this->description = $model->node->name . ' - ' . $model->user->username . Helper::truncateUtf8String($model->title, 200);
     }
     $replyQuery = Reply::find()->where(['topic_id' => $model->id]);
     $pagination = new Pagination(['defaultPageSize' => Yii::$app->params['pageSize'], 'totalCount' => $replyQuery->count()]);
     $replyList = $replyQuery->offset($pagination->offset)->limit($pagination->limit)->all();
     $reply = new Reply();
     if (!Yii::$app->user->isGuest) {
         $model->updateCounters(['click' => 1]);
         $reply = new Reply();
         if ($reply->load(Yii::$app->request->post()) && $reply->save()) {
             $this->redirect('/topic/' . $id . '#Reply');
         }
         return $this->render('view', ['model' => $model, 'reply' => $reply, 'replyList' => $replyList, 'pagination' => $pagination]);
     } else {
         return $this->render('view', ['model' => $model, 'reply' => $reply, 'replyList' => $replyList, 'pagination' => $pagination]);
     }
 }
Esempio n. 4
0
File: Reply.php Progetto: npk/v2sex
 static function Count()
 {
     return Reply::find()->count();
 }
Esempio n. 5
0
 static function ReplyCount()
 {
     if (!($ReplyCount = Yii::$app->cache->get('ReplyCount'))) {
         $ReplyCount = Reply::find()->count();
         Yii::$app->cache->set('ReplyCount', $ReplyCount, 86400);
     }
     return $ReplyCount;
 }