[ Index ] |
|
Code source de LifeType 1.2.4 |
1 <?php 2 3 lt_include( PLOG_CLASS_PATH."class/action/blogaction.class.php" ); 4 lt_include( PLOG_CLASS_PATH."class/view/blogview.class.php" ); 5 lt_include( PLOG_CLASS_PATH."class/view/errorview.class.php" ); 6 lt_include( PLOG_CLASS_PATH."class/dao/blogs.class.php" ); 7 lt_include( PLOG_CLASS_PATH."class/dao/articles.class.php" ); 8 lt_include( PLOG_CLASS_PATH."class/dao/articlecategories.class.php" ); 9 lt_include( PLOG_CLASS_PATH."class/dao/users.class.php" ); 10 lt_include( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" ); 11 12 /** 13 * \ingroup Action 14 * @private 15 * 16 * Adds a comment 17 */ 18 class CommentAction extends BlogAction 19 { 20 21 var $_articleId; 22 var $_parentId; 23 24 function ViewArticleAction( $actionInfo, $request ) 25 { 26 $this->BlogAction( $actionInfo, $request ); 27 28 // data validation 29 $this->registerFieldValidator( "articleId", new IntegerValidator()); 30 $this->registerFieldValidator( "parentId", new IntegerValidator()); 31 $this->setValidationErrorView( new ErrorView( $this->_blogInfo, "error_incorrect_article_id" )); 32 } 33 34 function perform() 35 { 36 // fetch the data and make some arrangements if needed 37 $this->_parentId = $this->_request->getValue( "parentId" ); 38 $this->_articleId = $this->_request->getValue( "articleId" ); 39 40 if( $this->_parentId < 0 || $this->_parentId == "" ) 41 $this->_parentId = 0; 42 43 // check if comments are enabled 44 $blogSettings = $this->_blogInfo->getSettings(); 45 if( !$blogSettings->getValue( "comments_enabled" )) { 46 $this->_view = new ErrorView( $this->_blogInfo, "error_comments_not_enabled" ); 47 $this->setCommonData(); 48 49 return false; 50 } 51 52 // fetch the article 53 $blogs = new Blogs(); 54 $articles = new Articles(); 55 $article = $articles->getBlogArticle( $this->_articleId, $this->_blogInfo->getId()); 56 57 // if there was a problem fetching the article, we give an error and quit 58 if( $article == false ) { 59 $this->_view = new ErrorView( $this->_blogInfo ); 60 $this->_view->setValue( "message", "error_fetching_article" ); 61 $this->setCommonData(); 62 return false; 63 } 64 65 $this->_view = new BlogView( $this->_blogInfo, "commentarticle", SMARTY_VIEW_CACHE_CHECK, 66 Array( "articleId" => $this->_articleId, "parentId" => $this->_parentId )); 67 // do nothing if the view was already cached 68 if( $this->_view->isCached()){ 69 $this->setCommonData(); 70 return true; 71 } 72 73 // fetch the comments so far 74 lt_include( PLOG_CLASS_PATH."class/dao/articlecomments.class.php" ); 75 $comments = new ArticleComments(); 76 $postComments = $comments->getPostComments( $article->getId()); 77 if( $this->_parentId > 0 ) { 78 // get a pre-set string for the subject field, for those users interested 79 $comment = $comments->getComment( $this->_parentId ); 80 // create the string 81 if( $comment ) { 82 $replyString = $this->_locale->tr("reply_string").$comment->getTopic(); 83 $this->_view->setValue( "comment", $comment ); 84 } 85 } 86 87 // if everything's fine, we set up the article object for the view 88 $this->_view->setValue( "post", $article ); 89 $this->_view->setValue( "parentId", $this->_parentId ); 90 $this->_view->setValue( "comments", $postComments ); 91 $this->_view->setValue( "postcomments", $postComments ); 92 $this->_view->setValue( "topic", $replyString ); 93 94 $this->setCommonData(); 95 96 // and return everything normal 97 return true; 98 } 99 } 100 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 21:04:15 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |