public function actionPhotos($id, $url) { $post = Yii::$app->request->post(); $request = Yii::$app->request; //потрібно буде переписати if ($post['offset']) { if ($url == 'new_photos') { $photos = User::getPhoto($id, $post['offset'], 1, 'date'); } elseif ($url == 'best_photos') { $photos = User::getPhoto($id, $post['offset'], 1, 'rating_all'); } else { $photos = User::getPhoto($id, $post['offset'], 1, $url); } foreach ($photos as $p) { $photo[] = $p; } echo json_encode(['photo' => $photo]); return; } User::getUserInfoOrRedirect($this, $id, $user, $isMyProfile); if ($request->isAjax) { $contentId = $request->post('contentId'); } if ($url == 'new_photos') { $heading = Yii::t('yii', 'Новые фотографии'); $photos = User::getPhotoTmp($id, 20, 'date', $contentId); } elseif ($url == 'best_photos') { $heading = Yii::t('yii', 'Популярные фотографии'); $photos = User::getPhotoTmp($id, 20, 'rating_all', $contentId); } else { $photos = User::getPhotoTmp($id, 20, $url, $contentId); $heading = end($photos)['category_name']; } if ($request->isAjax) { echo json_encode(['content' => $photos]); return; } if (!$request->isAjax) { $categories = Category::getAllUserCategory($id); } return $this->render('photos', ['user' => $user, 'categories' => $categories, 'isMyProfile' => $isMyProfile, 'photos' => $photos, 'heading' => $heading, 'url' => $url]); }