00001 <?php
00002
00003 lt_include( PLOG_CLASS_PATH."class/action/blogaction.class.php" );
00004 lt_include( PLOG_CLASS_PATH."class/view/blogview.class.php" );
00005 lt_include( PLOG_CLASS_PATH."class/view/errorview.class.php" );
00006 lt_include( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
00007 lt_include( PLOG_CLASS_PATH."class/dao/articles.class.php" );
00008 lt_include( PLOG_CLASS_PATH."class/dao/articlecategories.class.php" );
00009 lt_include( PLOG_CLASS_PATH."class/dao/users.class.php" );
00010 lt_include( 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 if(!$article->getCommentsEnabled()) {
00066
00067
00068 $this->_view = new ErrorView( $this->_blogInfo, "error_comments_not_enabled" );
00069 $this->setCommonData();
00070 return false;
00071 }
00072
00073 $this->_view = new BlogView( $this->_blogInfo, "commentarticle", SMARTY_VIEW_CACHE_CHECK,
00074 Array( "articleId" => $this->_articleId, "parentId" => $this->_parentId ));
00075
00076 if( $this->_view->isCached()){
00077 $this->setCommonData();
00078 return true;
00079 }
00080
00081
00082 $this->_view->setValue( "allowComments", true );
00083
00084
00085 lt_include( PLOG_CLASS_PATH."class/dao/articlecomments.class.php" );
00086 $comments = new ArticleComments();
00087 $postComments = $comments->getPostComments( $article->getId());
00088 if( $this->_parentId > 0 ) {
00089
00090 $comment = $comments->getComment( $this->_parentId );
00091
00092 if( $comment ) {
00093 $replyString = $this->_locale->tr("reply_string").$comment->getTopic();
00094 $this->_view->setValue( "comment", $comment );
00095 }
00096 }
00097
00098
00099 $this->_view->setValue( "post", $article );
00100 $this->_view->setValue( "parentId", $this->_parentId );
00101 $this->_view->setValue( "comments", $postComments );
00102 $this->_view->setValue( "postcomments", $postComments );
00103 $this->_view->setValue( "topic", $replyString );
00104
00105 $this->setCommonData();
00106
00107
00108 return true;
00109 }
00110 }
00111 ?>