| [ 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/data/validator/stringvalidator.class.php" ); 5 lt_include( PLOG_CLASS_PATH."class/view/errorview.class.php" ); 6 7 define( "VIEW_TRACKBACKS_TEMPLATE", "posttrackbacks" ); 8 9 /** 10 * \ingroup Action 11 * @private 12 * 13 * It's almost the same as the ViewArticleAction... 14 */ 15 class ViewArticleTrackbacksAction extends BlogAction 16 { 17 18 var $_articleId; 19 var $_articleName; 20 var $_categoryId; 21 var $_categoryName; 22 var $_userId; 23 var $_userName; 24 var $_date; 25 26 function ViewArticleTrackbacksAction( $actionInfo, $request ) 27 { 28 $this->BlogAction( $actionInfo, $request ); 29 30 $this->registerFieldValidator( "articleId", new IntegerValidator(), true ); 31 $this->registerFieldValidator( "articleName", new StringValidator(), true ); 32 $this->registerFieldValidator( "postCategoryId", new IntegerValidator(), true ); 33 $this->registerFieldValidator( "postCategoryName", new StringValidator(), true ); 34 $this->registerFieldValidator( "userId", new IntegerValidator(), true ); 35 $this->registerFieldValidator( "userName", new StringValidator(), true ); 36 37 $this->setValidationErrorView( new ErrorView( $this->_blogInfo, "error_fetching_article" )); 38 } 39 40 function validate() 41 { 42 if( !parent::validate()) 43 return false; 44 45 $this->_articleId = $this->_request->getValue( "articleId" ); 46 $this->_articleName = $this->_request->getValue( "articleName" ); 47 $this->_categoryId = $this->_request->getValue( "postCategoryId", -1 ); 48 $this->_categoryName = $this->_request->getValue( "postCategoryName" ); 49 $this->_userId = $this->_request->getValue( "userId", -1 ); 50 $this->_userName = $this->_request->getValue( "userName" ); 51 $this->_date = $this->_request->getValue( "Date", -1 ); 52 53 // Caculate the correct article date period 54 $adjustedDates = $this->_getCorrectedDatePeriod( $this->_date ); 55 $this->_date = $adjustedDates["adjustedDate"]; 56 $this->_maxDate = $adjustedDates["maxDate"]; 57 58 return true; 59 } 60 61 function perform() 62 { 63 lt_include( PLOG_CLASS_PATH."class/view/blogview.class.php" ); 64 65 $this->_view = new BlogView( $this->_blogInfo, 66 VIEW_TRACKBACKS_TEMPLATE, 67 SMARTY_VIEW_CACHE_CHECK, 68 Array( "articleId" => $this->_articleId, 69 "articleName" => $this->_articleName, 70 "categoryName" => $this->_categoryName, 71 "categoryId" => $this->_categoryId, 72 "userId" => $this->_userId, 73 "userName" => $this->_userName, 74 "date" => $this->_date )); 75 76 if( $this->_view->isCached()) { 77 $this->setCommonData(); 78 return true; 79 } 80 81 lt_include( PLOG_CLASS_PATH."class/dao/articles.class.php" ); 82 lt_include( PLOG_CLASS_PATH."class/dao/trackbacks.class.php" ); 83 lt_include( PLOG_CLASS_PATH."class/dao/users.class.php" ); 84 lt_include( PLOG_CLASS_PATH."class/dao/articlecategories.class.php" ); 85 86 // --- 87 // if we got a category name or a user name instead of a category 88 // id and a user id, then we have to look up first those 89 // and then proceed 90 // --- 91 // users... 92 if( $this->_userName ) { 93 $users = new Users(); 94 $user = $users->getUserInfoFromUsername( $this->_userName ); 95 if( !$user ) { 96 $this->_view = new ErrorView( $this->_blogInfo ); 97 $this->_view->setValue( "message", "error_incorrect_user" ); 98 $this->setCommonData(); 99 return false; 100 } 101 // if there was a user, use his/her id 102 $this->_userId = $user->getId(); 103 } 104 // ...and categories... 105 if( $this->_categoryName ) { 106 $categories = new ArticleCategories(); 107 $category = $categories->getCategoryByName( $this->_categoryName, $this->_blogInfo->getId()); 108 if( !$category ) { 109 $this->_view = new ErrorView( $this->_blogInfo ); 110 $this->_view->setValue( "message", "error_fetching_category" ); 111 $this->setCommonData(); 112 return false; 113 } 114 // if there was a user, use his/her id 115 $this->_categoryId = $category->getId(); 116 } 117 118 // fetch the article 119 $articles = new Articles(); 120 if( $this->_articleId ) { 121 $article = $articles->getBlogArticle( $this->_articleId, 122 $this->_blogInfo->getId(), 123 false, 124 $this->_date, 125 $this->_categoryId, 126 $this->_userId, 127 POST_STATUS_PUBLISHED, 128 $this->_maxDate ); 129 } 130 else { 131 $article = $articles->getBlogArticleByTitle( $this->_articleName, 132 $this->_blogInfo->getId(), 133 false, 134 $this->_date, 135 $this->_categoryId, 136 $this->_userId, 137 POST_STATUS_PUBLISHED, 138 $this->_maxDate ); 139 } 140 141 // if the article id doesn't exist, cancel the whole thing... 142 if( $article == false ) { 143 $this->_view = new ErrorView( $this->_blogInfo ); 144 $this->_view->setValue( "message", "error_fetching_article" ); 145 $this->setCommonData(); 146 147 return false; 148 } 149 $this->notifyEvent( EVENT_POST_LOADED, Array( "article" => &$article )); 150 $this->notifyEvent( EVENT_TRACKBACKS_LOADED, Array( "article" => &$article )); 151 152 // if everything's fine, we set up the article object for the view 153 $this->_view->setValue( "post", $article ); 154 $this->_view->setValue( "trackbacks", $article->getTrackbacks( true )); 155 $this->setCommonData(); 156 157 // and return everything normal 158 return true; 159 } 160 } 161 ?>
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 |
|