[ Index ] |
|
Code source de LifeType 1.2.4 |
1 <?php 2 3 lt_include( PLOG_CLASS_PATH."class/view/admin/admintemplatedview.class.php" ); 4 lt_include( PLOG_CLASS_PATH."class/dao/articlecomments.class.php" ); 5 lt_include( PLOG_CLASS_PATH."class/dao/articlecommentstatus.class.php" ); 6 lt_include( PLOG_CLASS_PATH."class/dao/articles.class.php" ); 7 lt_include( PLOG_CLASS_PATH."class/data/pager/pager.class.php" ); 8 9 /** 10 * \ingroup View 11 * @private 12 * 13 * shows a list of the comments 14 */ 15 class AdminArticleCommentsListView extends AdminTemplatedView 16 { 17 var $_article; 18 var $_commentStatus; 19 var $_page; 20 21 function AdminArticleCommentsListView( $blogInfo, $params = Array(), $type = COMMENT_TYPE_COMMENT ) 22 { 23 if( $type == COMMENT_TYPE_COMMENT ) 24 $this->AdminTemplatedView( $blogInfo, "editcomments" ); 25 else 26 $this->AdminTemplatedView( $blogInfo, "edittrackbacks" ); 27 28 $blogSettings = $blogInfo->getSettings(); 29 $this->_locale =& Locales::getLocale( $blogSettings->getValue( "locale" ), "en_UK" ); 30 31 $this->_setParameters( $params ); 32 33 $this->_type = $type; 34 35 $this->_page = $this->getCurrentPageFromRequest(); 36 } 37 38 /** 39 * @private 40 */ 41 function _setParameters( $params ) 42 { 43 // fetch the article id 44 $this->_article = null; 45 if( isset( $params["article"] )) 46 $this->_article = $params["article"]; 47 48 // load the status 49 if( isset( $params["showStatus"] )) 50 $this->_commentStatus = $params["showStatus"]; 51 52 if( !ArticleCommentStatus::isValidStatus( $this->_commentStatus )) 53 $this->_commentStatus = COMMENT_STATUS_ALL; 54 55 // laod the search terms 56 $this->_searchTerms = ""; 57 if( isset( $params["searchTerms"] )) 58 $this->_searchTerms = $params["searchTerms"]; 59 } 60 61 /** 62 * show the contents of the view 63 */ 64 function render() 65 { 66 // load the comments and throw the correct event 67 $comments = new CommentsCommon(); 68 if( $this->_article ) { 69 // load only the comments of the given post 70 $postComments = $comments->getPostComments( $this->_article->getId(), 71 COMMENT_ORDER_NEWEST_FIRST, 72 $this->_commentStatus, 73 $this->_type, 74 $this->_page, 75 DEFAULT_ITEMS_PER_PAGE ); 76 // number of comments 77 $numPostComments = $comments->getNumPostComments( $this->_article->getId(), 78 $this->_commentStatus, 79 $this->_type ); 80 // id of the article, for the pager... 81 $articleId = $this->_article->getId(); 82 } 83 else { 84 // load all comments given the current status 85 $postComments = $comments->getBlogComments( $this->_blogInfo->getId(), 86 COMMENT_ORDER_NEWEST_FIRST, 87 $this->_commentStatus, 88 $this->_type, 89 $this->_searchTerms, 90 $this->_page, 91 DEFAULT_ITEMS_PER_PAGE ); 92 // number of comments 93 $numPostComments = $comments->getNumBlogComments( $this->_blogInfo->getId(), 94 $this->_commentStatus, 95 $this->_type, 96 $this->_searchTerms ); 97 // no article id... 98 $articleId = 0; 99 } 100 $this->notifyEvent( EVENT_COMMENTS_LOADED, Array( "comments", &$postComments )); 101 102 if( $this->_type == COMMENT_TYPE_COMMENT ) 103 $pagerUrl = "?op=editComments"; 104 else 105 $pagerUrl = "?op=editTrackbacks"; 106 107 if( $this->_commentStatus > -1 ) 108 $pagerUrl .= "&articleId={$articleId}&showStatus=".$this->_commentStatus."&searchTerms=".$this->_searchTerms."&page="; 109 else 110 $pagerUrl .= "&articleId={$articleId}&searchTerms=".$this->_searchTerms."&page="; 111 112 // calculate the pager url 113 $pager = new Pager( $pagerUrl, 114 $this->_page, 115 $numPostComments, 116 DEFAULT_ITEMS_PER_PAGE ); 117 118 // get a list with all the different comment status 119 $statusList = ArticleCommentStatus::getStatusList( true ); 120 $statusListWithoutAll = ArticleCommentStatus::getStatusList( false ); 121 122 // and pass all the information to the templates 123 $this->setValue( "comments", $postComments); 124 $this->setValue( "commentstatus", $statusList ); 125 $this->setValue( "commentstatusWithoutAll", $statusListWithoutAll ); 126 $this->setValue( "currentstatus", $this->_commentStatus ); 127 $this->setValue( "searchTerms", $this->_searchTerms ); 128 129 // pass the pager to the view 130 $this->setValue( "pager", $pager );+ 131 132 // pass the common data to the templates 133 $this->setValue( "post", $this->_article ); 134 135 parent::render(); 136 } 137 } 138 ?>
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 |
![]() |