00001 <?php
00002
00003 lt_include( PLOG_CLASS_PATH."class/action/blogaction.class.php" );
00004 lt_include( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" );
00005 lt_include( PLOG_CLASS_PATH."class/data/validator/usernamevalidator.class.php" );
00006 lt_include( PLOG_CLASS_PATH."class/view/errorview.class.php" );
00007
00008 define( "VIEW_TRACKBACKS_TEMPLATE", "posttrackbacks" );
00009
00016 class ViewArticleTrackbacksAction extends BlogAction
00017 {
00018
00019 var $_articleId;
00020 var $_articleName;
00021 var $_categoryId;
00022 var $_categoryName;
00023 var $_userId;
00024 var $_userName;
00025 var $_date;
00026
00027 function ViewArticleTrackbacksAction( $actionInfo, $request )
00028 {
00029 $this->BlogAction( $actionInfo, $request );
00030
00031 $this->registerFieldValidator( "articleId", new IntegerValidator(), true );
00032 $this->registerFieldValidator( "articleName", new StringValidator(), true );
00033 $this->registerFieldValidator( "postCategoryId", new IntegerValidator(), true );
00034 $this->registerFieldValidator( "postCategoryName", new StringValidator(), true );
00035 $this->registerFieldValidator( "userId", new IntegerValidator(), true );
00036 $this->registerFieldValidator( "userName", new UsernameValidator(), true );
00037
00038 $this->setValidationErrorView( new ErrorView( $this->_blogInfo, "error_fetching_article" ));
00039 }
00040
00041 function validate()
00042 {
00043 if( !parent::validate())
00044 return false;
00045
00046 $this->_articleId = $this->_request->getValue( "articleId" );
00047 $this->_articleName = $this->_request->getValue( "articleName" );
00048 $this->_categoryId = $this->_request->getValue( "postCategoryId", -1 );
00049 $this->_categoryName = $this->_request->getValue( "postCategoryName" );
00050 $this->_userId = $this->_request->getValue( "userId", -1 );
00051 $this->_userName = $this->_request->getValue( "userName" );
00052 $this->_date = $this->_request->getValue( "Date" );
00053 $val = new IntegerValidator();
00054 if( !$val->validate( $this->_date ) )
00055 $this->_date = -1;
00056
00057
00058 $adjustedDates = $this->_getCorrectedDatePeriod( $this->_date );
00059 $this->_date = $adjustedDates["adjustedDate"];
00060 $this->_maxDate = $adjustedDates["maxDate"];
00061
00062 return true;
00063 }
00064
00065 function perform()
00066 {
00067 lt_include( PLOG_CLASS_PATH."class/view/blogview.class.php" );
00068
00069 $this->_view = new BlogView( $this->_blogInfo,
00070 VIEW_TRACKBACKS_TEMPLATE,
00071 SMARTY_VIEW_CACHE_CHECK,
00072 Array( "articleId" => $this->_articleId,
00073 "articleName" => $this->_articleName,
00074 "categoryName" => $this->_categoryName,
00075 "categoryId" => $this->_categoryId,
00076 "userId" => $this->_userId,
00077 "userName" => $this->_userName,
00078 "date" => $this->_date ));
00079
00080 if( $this->_view->isCached()) {
00081 $this->setCommonData();
00082 return true;
00083 }
00084
00085 lt_include( PLOG_CLASS_PATH."class/dao/articles.class.php" );
00086 lt_include( PLOG_CLASS_PATH."class/dao/trackbacks.class.php" );
00087 lt_include( PLOG_CLASS_PATH."class/dao/users.class.php" );
00088 lt_include( PLOG_CLASS_PATH."class/dao/articlecategories.class.php" );
00089
00090
00091
00092
00093
00094
00095
00096 if( $this->_userName ) {
00097 $users = new Users();
00098 $user = $users->getUserInfoFromUsername( $this->_userName );
00099 if( !$user ) {
00100 $this->_view = new ErrorView( $this->_blogInfo );
00101 $this->_view->setValue( "message", "error_incorrect_user" );
00102 $this->setCommonData();
00103 return false;
00104 }
00105
00106 $this->_userId = $user->getId();
00107 }
00108
00109 if( $this->_categoryName ) {
00110 $categories = new ArticleCategories();
00111 $category = $categories->getCategoryByName( $this->_categoryName, $this->_blogInfo->getId());
00112 if( !$category ) {
00113 $this->_view = new ErrorView( $this->_blogInfo );
00114 $this->_view->setValue( "message", "error_fetching_category" );
00115 $this->setCommonData();
00116 return false;
00117 }
00118
00119 $this->_categoryId = $category->getId();
00120 }
00121
00122
00123 $articles = new Articles();
00124 if( $this->_articleId ) {
00125 $article = $articles->getBlogArticle( $this->_articleId,
00126 $this->_blogInfo->getId(),
00127 false,
00128 $this->_date,
00129 $this->_categoryId,
00130 $this->_userId,
00131 POST_STATUS_PUBLISHED,
00132 $this->_maxDate );
00133 }
00134 else {
00135 $article = $articles->getBlogArticleByTitle( $this->_articleName,
00136 $this->_blogInfo->getId(),
00137 false,
00138 $this->_date,
00139 $this->_categoryId,
00140 $this->_userId,
00141 POST_STATUS_PUBLISHED,
00142 $this->_maxDate );
00143 }
00144
00145
00146 if( $article == false ) {
00147 $this->_view = new ErrorView( $this->_blogInfo );
00148 $this->_view->setValue( "message", "error_fetching_article" );
00149 $this->setCommonData();
00150
00151 return false;
00152 }
00153 $this->notifyEvent( EVENT_POST_LOADED, Array( "article" => &$article ));
00154 $this->notifyEvent( EVENT_TRACKBACKS_LOADED, Array( "article" => &$article ));
00155
00156
00157 $this->_view->setValue( "post", $article );
00158 $this->_view->setValue( "trackbacks", $article->getTrackbacks( true ));
00159 $this->setCommonData();
00160
00161
00162 return true;
00163 }
00164 }
00165 ?>