Beispiel #1
0
 public function ViewAction()
 {
     $request = Project::getRequest();
     $info = array();
     $this->BaseSiteData();
     $request_user_id = (int) Project::getUser()->getShowedUser()->id;
     $user_id = (int) Project::getUser()->getDbUser()->id;
     $photo_id = (int) $request->getKeyByNumber(0);
     $login = $request->getUsername();
     $model = new PhotoModel();
     $model->load($photo_id);
     $this->BaseAlbumData($info, $model->album_id);
     $album_model = new AlbumModel();
     $album_model->load($model->album_id);
     $info['user_id'] = $user_id;
     $info['album_name'] = $album_model->name;
     $info['album_id'] = $album_model->id;
     $info['photo_id'] = $model->id;
     $info['photo_name'] = $model->name;
     $info['photo_rating'] = $model->voices > 0 ? $model->rating / $model->voices : 0;
     $info['photo_voices'] = $model->voices;
     $info['photo_creation_date'] = $model->creation_date;
     $info['photo_file'] = $this->checkFile($login, $model->path, false);
     $info['photo_owner_login'] = $login;
     if ((int) $model->is_rating == 1) {
         $info['have_rating'] = true;
     } else {
         $info['have_rating'] = false;
     }
     $info['can_vote'] = PhotoVote::canVote($user_id, $photo_id);
     $info['bottom_list'] = $this->getPhotoBottomList($request_user_id, $model->album_id, $login);
     $controller = new BaseCommentController();
     $info['comment_list'] = $controller->CommentList($model->id, $request->getKeyByNumber(1), $this->getParam('comment_per_page'), 'Photo', 'View', 'photo', array($model->id));
     $info['rate_url'] = $request->createUrl('Photo', 'RatePhoto');
     $info['add_comment_url'] = $request->createUrl('Photo', 'Comment');
     $info['add_comment_element_id'] = $model->id;
     $info['add_comment_id'] = 0;
     $info['element_id'] = $model->id;
     $this->_view->Photo($info);
     $this->_view->parse();
     return;
 }
Beispiel #2
0
 public function ArticleViewAction()
 {
     $request = Project::getRequest();
     $article_model = new ArticleModel();
     $data = array();
     $this->BaseSiteData();
     $id = (int) $request->getKeyByNumber(0);
     $pageId = (int) $request->getKeyByNumber(1);
     if ($id > 0) {
         $article_page_model = new ArticlePageModel();
         $article_tree_model = new ArticleTreeModel();
         $article_vote_model = new ArticleVoteModel();
         $article_pager = new ArticlePagerView();
         $votes = $article_vote_model->loadByArticleUser($id, Project::getUser()->getDbUser()->id);
         $pages = $article_page_model->loadByArticleId($id);
         $data['article'] = $article_model->load($id);
         $data['tab_list'] = TabController::getMainArticleTabs(false, false, false, false, true, $article_model->title);
         $data['category'] = $article_tree_model->load($article_model->articles_tree_id);
         $data['page_content'] = $pages[$pageId];
         $data['pager_view'] = $article_pager->ShowPager(count($pages), $pageId, 'Article', 'ArticleView', array($id));
         $data['vote_status'] = count($votes);
         $data = array_merge($data, $article_vote_model->rateByArticleId($id));
         $article_model->views++;
         $article_model->save();
         if ($article_model->allowcomments > 0) {
             $controller = new BaseCommentController();
             $data['comment_list'] = $controller->CommentList($id, $request->getKeyByNumber(1), 0, 'Article', 'ArticleView', 'article', array($id));
         }
         $this->_view->ViewArticle($data);
         $this->_view->parse();
     }
 }
Beispiel #3
0
 public function SocialViewAction()
 {
     $v_request = Project::getRequest();
     $v_current_userID = (int) Project::getUser()->getDbUser()->id;
     $data = array();
     $this->_get_categories($data, $v_categoryID);
     //$this->_BaseSiteData($data);
     $data['action'] = 'SocialView';
     $v_id = (int) $v_request->getKeyByNumber(0);
     if ($v_id > 0) {
         $v_sp_model = new SocialModel();
         $data['social_row'] = $v_sp_model->loadSocialRows($v_id);
         $v_tab_name = $data['social_row'][0]['name'];
         $v_encoding = mb_detect_encoding($v_tab_name);
         if (mb_strlen($v_tab_name, $v_encoding) > 50) {
             $v_tab_name = mb_substr($v_tab_name, 0, 50, $v_encoding) . '...';
         }
         //$data['tab_social_view'] = $v_tab_name;
         // ---
         $controller = new BaseCommentController();
         $data['comment_list'] = $controller->CommentList($v_id, $v_request->getKeyByNumber(1), 0, 'Social', 'SocialView', 'social', array($v_id));
         $data['add_comment_url'] = $v_request->createUrl('Social', 'SocialCommentAdd');
         $data['add_comment_element_id'] = $v_id;
         $data['add_comment_id'] = 0;
         // -- Проверка наличия внесение комментариев текущим пользователем по данной соц.позиции
         $v_sp_comment_model = new SocialCommentModel();
         $v_sp_votes_model = new SocialVotesModel();
         $v_count_comment = $v_sp_comment_model->GetCountRecComment($v_current_userID, $v_id);
         $v_count_votes = $v_sp_votes_model->GetCountRecVotes($v_current_userID, $v_id);
         $data['count_comment'] = $v_count_comment;
         $data['count_votes'] = $v_count_votes;
         // ---
         $this->_view->assign('tab_list', TabController::getSocialTabs(false, false, false, false, true, $v_tab_name));
         // Show tabs
         $this->_view->Social_View($data);
         $this->_view->parse();
     } else {
         Project::getResponse()->redirect($v_request->createUrl('Social', 'SocialMainList'));
     }
 }
Beispiel #4
0
 public function BookmarksViewAction()
 {
     $v_request = Project::getRequest();
     $data = array();
     $this->_get_catalogs($data, $v_categoryID);
     //$this->_BaseSiteData($data);
     $data['action'] = 'BookmarksView';
     $v_id = (int) $v_request->getKeyByNumber(0);
     if ($v_id > 0) {
         $v_bookmarks_model = new BookmarksModel();
         $v_bookmarks_model->load($v_id);
         $v_bookmarks_model->views++;
         $v_bookmarks_model->save();
         $data['bookmark_row'] = $v_bookmarks_model->loadBookmarkRow($v_id);
         $v_tab_name = $data['bookmark_row']['title'];
         $v_encoding = mb_detect_encoding($v_tab_name);
         if (mb_strlen($v_tab_name, $v_encoding) > 50) {
             $v_tab_name = mb_substr($v_tab_name, 0, 50, $v_encoding) . '...';
         }
         $data['tab_bookmarks_view'] = $v_tab_name;
         // ---
         $controller = new BaseCommentController();
         $data['comment_list'] = $controller->CommentList($v_id, $v_request->getKeyByNumber(1), 0, 'Bookmarks', 'BookmarksView', 'bookmarks', array($v_id));
         $data['add_comment_url'] = $v_request->createUrl('Bookmarks', 'BookmarksCommentAdd');
         $data['add_comment_element_id'] = $v_id;
         $data['add_comment_id'] = 0;
         // ---
         $this->_view->assign('tab_list', TabController::getBookmarksTabs(false, false, false, false, false, false, true, $v_tab_name));
         // Show tabs
         $this->_view->Bookmarks_View($data);
         $this->_view->parse();
     } else {
         Project::getResponse()->redirect($v_request->createUrl('Bookmarks', 'BookmarksList'));
     }
 }
 public function ViewQuestionAction()
 {
     $request = Project::getRequest();
     $this->BaseSiteData($data);
     $id = (int) $request->getKeyByNumber(0);
     $question_cat_model = new QuestionCatModel();
     $data['question_cat_list'] = $question_cat_model->loadAll();
     if ($id > 0) {
         $question_model = new QuestionModel();
         $data['question'] = $question_model->loadQuestion($id);
         $data['question_tab'] = $question_model->getNWordsFromText($question_model->q_text, 8);
         $controller = new BaseCommentController();
         $data['comment_list'] = $controller->CommentList($id, $request->getKeyByNumber(1), 0, 'QuestionAnswer', 'ViewQuestion', 'questions', array($id));
         //			if($question_model->user_id == Project::getUser()->getDbUser()->id) $data['managed'] = true;
         $this->_view->assign('tab_list', TabController::getOwnTabs(false, false, false, false, false, false, true, false, false, false));
         //$this->_view->assign('tab_list', TabController::getQuestionAnswerTabs(true, false, false, false, false));
         $this->_view->ViewQuestion($data);
         $this->_view->parse();
     } else {
         Project::getResponse()->redirect($request->createUrl('QuestionAnswer', 'List'));
     }
 }
Beispiel #6
0
 public function CommentsAction()
 {
     $request = Project::getRequest();
     $request_user_id = (int) Project::getUser()->getShowedUser()->id;
     $user_id = (int) Project::getUser()->getDbUser()->id;
     $this->BaseSiteData();
     $info = array();
     $this->BaseBlogData($info);
     $post_id = (int) $request->getKeyByNumber(0);
     $post_page_number = (int) $request->getKeyByNumber(1);
     $page_number = (int) $request->getKeyByNumber(2);
     $post_model = new BlogPostModel();
     $post = $post_model->getPost($post_id, $user_id, $request_user_id);
     if (!$post) {
         $request->clear();
         $this->_view->addFlashMessage(FM::ERROR, "Полный текст этого поста доступен только после подписки на блог.");
         $this->PostListAction();
         return;
     }
     $post_model->load($post_id);
     $this->_view->assign('current_tree_name', $post_model->getTreeNameById($post_model->ub_tree_id));
     $this->_view->assign('post_id', $post_model->id);
     $info['full_text'] = $request_user_id !== $user_id ? $this->PostPreprocess($post_model->full_text, $user_id, $post_model->ub_tree_id) : $post_model->full_text;
     $info['post_title'] = $post_model->title;
     $info['post_creation_date'] = $post_model->creation_date;
     $info['post_allow_comments'] = (int) $post_model->allowcomments;
     $tree_model = new BlogTreeModel();
     $tree_model->load($post_model->ub_tree_id);
     $blog_banners_model = new BlogModel('blog_banners');
     $blog_banners_model->load($tree_model->blog_banner_id);
     $info['blog_banner_code'] = $blog_banners_model->code;
     $controller = new BaseCommentController();
     $info['comment_list'] = $controller->CommentList($post_id, $page_number, $this->getParam('comment_per_page'), 'Blog', 'Comments', 'blog', array($post_id, $post_page_number), (int) $post_model->allowcomments);
     $tag_model = new BlogTagModel();
     $tag_model->load($post_model->bc_tag_id);
     $info['post_tag'] = $tag_model->name;
     //$moodModel = new MoodModel();
     //$moodModel->load($post_model->mood);
     $info['post_mood'] = $post_model->mood;
     //$moodModel -> name;
     $userModel = new UserModel();
     $info['user_avatar'] = $userModel->getFullAvatarById($post_model->avatar_id);
     $info['add_comment_url'] = $request->createUrl('Blog', 'SaveComment', array($post_id, $post_page_number, $page_number));
     $this->_view->assign('post_user_id', $request_user_id);
     $this->_view->CommentList($info);
     $this->_view->parse();
 }
 function __construct($View = null, $params = array(), $vars = array())
 {
     parent::__construct('PhotoComment', $View, $params, $vars);
 }