lifetype/branches/lifetype-1.0.6/class/action/commentaction.class.php
Go to the documentation of this file.00001 <?php
00002
00003 include_once( PLOG_CLASS_PATH."class/action/blogaction.class.php" );
00004 include_once( PLOG_CLASS_PATH."class/view/blogview.class.php" );
00005 include_once( PLOG_CLASS_PATH."class/view/errorview.class.php" );
00006 include_once( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
00007 include_once( PLOG_CLASS_PATH."class/dao/articles.class.php" );
00008 include_once( PLOG_CLASS_PATH."class/dao/articlecategories.class.php" );
00009 include_once( PLOG_CLASS_PATH."class/dao/users.class.php" );
00010 include_once( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
00011
00018 class CommentAction extends BlogAction
00019 {
00020
00021 var $_articleId;
00022 var $_parentId;
00023
00024 function ViewArticleAction( $actionInfo, $request )
00025 {
00026 $this->BlogAction( $actionInfo, $request );
00027
00028
00029 $this->registerFieldValidator( "articleId", new IntegerValidator());
00030 $this->registerFieldValidator( "parentId", new IntegerValidator());
00031 $this->setValidationErrorView( new ErrorView( $this->_blogInfo, "error_incorrect_article_id" ));
00032 }
00033
00034 function perform()
00035 {
00036
00037 $this->_parentId = $this->_request->getValue( "parentId" );
00038 $this->_articleId = $this->_request->getValue( "articleId" );
00039
00040 if( $this->_parentId < 0 || $this->_parentId == "" )
00041 $this->_parentId = 0;
00042
00043
00044 $blogSettings = $this->_blogInfo->getSettings();
00045 if( !$blogSettings->getValue( "comments_enabled" )) {
00046 $this->_view = new ErrorView( $this->_blogInfo, "error_comments_not_enabled" );
00047 $this->setCommonData();
00048
00049 return false;
00050 }
00051
00052
00053 $blogs = new Blogs();
00054 $articles = new Articles();
00055 $article = $articles->getBlogArticle( $this->_articleId, $this->_blogInfo->getId());
00056
00057
00058 if( $article == false ) {
00059 $this->_view = new ErrorView( $this->_blogInfo );
00060 $this->_view->setValue( "message", "error_fetching_article" );
00061 $this->setCommonData();
00062 return false;
00063 }
00064
00065 $this->_view = new BlogView( $this->_blogInfo, "commentarticle", SMARTY_VIEW_CACHE_CHECK,
00066 Array( "articleId" => $this->_articleId, "parentId" => $this->_parentId ));
00067
00068 if( $this->_view->isCached())
00069 return true;
00070
00071
00072 $comments = new ArticleComments();
00073 $postComments = $comments->getPostComments( $article->getId());
00074 if( $this->_parentId > 0 ) {
00075
00076 $comment = $comments->getPostComment( $article->getId(), $this->_parentId );
00077
00078 if( $comment ) {
00079 $replyString = $this->_locale->tr("reply_string").$comment->getTopic();
00080 $this->_view->setValue( "comment", $comment );
00081 }
00082 }
00083
00084
00085 $this->_view->setValue( "post", $article );
00086 $this->_view->setValue( "parentId", $this->_parentId );
00087 $this->_view->setValue( "comments", $postComments );
00088 $this->_view->setValue( "postcomments", $postComments );
00089 $this->_view->setValue( "topic", $replyString );
00090
00091 $this->setCommonData();
00092
00093
00094 return true;
00095 }
00096 }
00097 ?>