[ Index ] |
|
Code source de LifeType 1.2.4 |
1 <?php 2 3 lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" ); 4 lt_include( PLOG_CLASS_PATH."class/dao/blogcategories.class.php" ); 5 lt_include( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" ); 6 lt_include( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" ); 7 lt_include( PLOG_CLASS_PATH."class/data/validator/emptyvalidator.class.php" ); 8 lt_include( PLOG_CLASS_PATH."class/view/admin/admintemplatedview.class.php" ); 9 lt_include( PLOG_CLASS_PATH."class/view/admin/adminblogcategorieslistview.class.php" ); 10 lt_include( PLOG_CLASS_PATH."class/data/textfilter.class.php" ); 11 12 /** 13 * \ingroup Action 14 * @private 15 * 16 * Updates an article category. 17 */ 18 class AdminUpdateBlogCategoryAction extends AdminAction 19 { 20 21 var $_categoryName; 22 var $_categoryUrl; 23 var $_categoryId; 24 var $_categoryDescription; 25 var $_properties; 26 27 /** 28 * Constructor. If nothing else, it also has to call the constructor of the parent 29 * class, BlogAction with the same parameters 30 */ 31 function AdminUpdateBlogCategoryAction( $actionInfo, $request ) 32 { 33 $this->AdminAction( $actionInfo, $request ); 34 35 // data validation settings 36 $this->registerFieldValidator( "categoryName", new StringValidator()); 37 $this->registerFieldValidator( "categoryId", new IntegerValidator()); 38 $this->registerFieldValidator( "categoryDescription", new StringValidator()); 39 $errorView = new AdminTemplatedView( $this->_blogInfo, "editblogcategory" ); 40 $errorView->setErrorMessage( $this->_locale->tr("error_updating_article_category" )); 41 $this->setValidationErrorView( $errorView ); 42 43 $this->requireAdminPermission( "update_blog_category" ); 44 } 45 46 /** 47 * Carries out the specified action 48 */ 49 function perform() 50 { 51 // get the data from the form 52 $this->_categoryName = $this->_request->getValue( "categoryName" ); 53 $this->_categoryId = $this->_request->getValue( "categoryId" ); 54 $this->_categoryDescription = $this->_request->getValue( "categoryDescription" ); 55 $this->_properties = Array(); 56 57 // fetch the category we're trying to update 58 $categories = new BlogCategories(); 59 $category = $categories->getBlogCategory( $this->_categoryId ); 60 if( !$category ) { 61 $this->_view = new AdminBlogCategoriesListView( $this->_blogInfo ); 62 $this->_view->setErrorMessage( $this->_locale->tr("error_fetching_category")); 63 $this->setCommonData(); 64 65 return false; 66 } 67 68 // fire the pre-event 69 $this->notifyEvent( EVENT_PRE_UPDATE_BLOG_CATEGORY, Array( "category" => &$category )); 70 71 // update the fields 72 $category->setName( $this->_categoryName ); 73 $category->setProperties( $this->_properties ); 74 $category->setDescription( $this->_categoryDescription ); 75 76 // this is view we're going to use to show our messages 77 $this->_view = new AdminBlogCategoriesListView( $this->_blogInfo ); 78 79 if( !$categories->updateBlogCategory( $category )) { 80 $this->_view->setErrorMessage( $this->_locale->tr("error_updating_article_category")); 81 } 82 else { 83 // if everything fine, load the list of categories 84 $this->_view->setSuccessMessage( $this->_locale->pr("article_category_updated_ok", $category->getName())); 85 86 // fire the post-event 87 $this->notifyEvent( EVENT_POST_UPDATE_BLOG_CATEGORY, Array( "category" => &$category )); 88 89 // clear the cache 90 CacheControl::resetBlogCache( $this->_blogInfo->getId()); 91 } 92 93 $this->setCommonData(); 94 95 // better to return true if everything fine 96 return true; 97 } 98 } 99 ?>
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 |
![]() |