viewarticletrackbacksaction.class.php
查看本檔案說明文件.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/dao/articles.class.php" );
00006 include_once( PLOG_CLASS_PATH."class/dao/trackbacks.class.php" );
00007 include_once( PLOG_CLASS_PATH."class/view/errorview.class.php" );
00008 include_once( PLOG_CLASS_PATH."class/dao/users.class.php" );
00009 include_once( PLOG_CLASS_PATH."class/dao/articlecategories.class.php" );
00010
00011 define( "VIEW_TRACKBACKS_TEMPLATE", "posttrackbacks" );
00012
00019 class ViewArticleTrackbacksAction extends BlogAction
00020 {
00021
00022 var $_articleId;
00023 var $_articleName;
00024 var $_categoryId;
00025 var $_categoryName;
00026 var $_userId;
00027 var $_userName;
00028 var $_date;
00029
00030 function ViewArticleTrackbacksAction( $actionInfo, $request )
00031 {
00032 $this->BlogAction( $actionInfo, $request );
00033 }
00034
00035
00036 function validate()
00037 {
00038 $this->_articleId = $this->_request->getValue( "articleId" );
00039 $this->_articleName = $this->_request->getValue( "articleName" );
00040 $this->_categoryId = $this->_request->getValue( "postCategoryId", -1 );
00041 $this->_categoryName = $this->_request->getValue( "postCategoryName" );
00042 $this->_userId = $this->_request->getValue( "userId", -1 );
00043 $this->_userName = $this->_request->getValue( "userName" );
00044 $this->_date = $this->_request->getValue( "Date", -1 );
00045
00046
00047 $adjustedDates = $this->_getCorrectedDatePeriod( $this->_date );
00048 $this->_date = $adjustedDates["adjustedDate"];
00049 $this->_maxDate = $adjustedDates["maxDate"];
00050
00051 return true;
00052 }
00053
00054 function perform()
00055 {
00056 $this->_view = new BlogView( $this->_blogInfo,
00057 VIEW_TRACKBACKS_TEMPLATE,
00058 SMARTY_VIEW_CACHE_CHECK,
00059 Array( "articleId" => $this->_articleId,
00060 "articleName" => $this->_articleName,
00061 "categoryName" => $this->_categoryName,
00062 "categoryId" => $this->_categoryId,
00063 "userId" => $this->_userId,
00064 "userName" => $this->_userName,
00065 "date" => $this->_date ));
00066
00067 if( $this->_view->isCached()) {
00068 return true;
00069 }
00070
00071
00072
00073
00074
00075
00076
00077 if( $this->_userName ) {
00078 $users = new Users();
00079 $user = $users->getUserInfoFromUsername( $this->_userName );
00080 if( !$user ) {
00081 $this->_setErrorView();
00082 return false;
00083 }
00084
00085 $this->_userId = $user->getId();
00086 }
00087
00088 if( $this->_categoryName ) {
00089 $categories = new ArticleCategories();
00090 $category = $categories->getCategoryByName( $this->_categoryName, $this->_blogInfo->getId());
00091 if( !$category ) {
00092 $this->_setErrorView();
00093 return false;
00094 }
00095
00096 $this->_categoryId = $category->getId();
00097 }
00098
00099
00100 $articles = new Articles();
00101 if( $this->_articleId ) {
00102 $article = $articles->getBlogArticle( $this->_articleId, $this->_blogInfo->getId(),
00103 false, $this->_date, $this->_categoryId, $this->_userId,
00104 POST_STATUS_PUBLISHED, $this->_maxDate );
00105 }
00106 else {
00107 $article = $articles->getBlogArticleByTitle( $this->_articleName, $this->_blogInfo->getId(),
00108 false, $this->_date, $this->_categoryId, $this->_userId,
00109 POST_STATUS_PUBLISHED, $this->_maxDate );
00110 }
00111
00112
00113 if( $article == false ) {
00114 $this->_view = new ErrorView( $this->_blogInfo );
00115 $this->_view->setValue( "message", "error_fetching_article" );
00116 $this->setCommonData();
00117
00118 return false;
00119 }
00120 $this->notifyEvent( EVENT_POST_LOADED, Array( "article" => &$article ));
00121 $this->notifyEvent( EVENT_TRACKBACKS_LOADED, Array( "article" => &$article ));
00122
00123
00124 $this->_view->setValue( "post", $article );
00125 $this->_view->setValue( "trackbacks", $article->getTrackbacks());
00126 $this->setCommonData();
00127
00128
00129 return true;
00130 }
00131 }
00132 ?>