[ 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/stringvalidator.class.php" ); 6 lt_include( PLOG_CLASS_PATH."class/view/admin/adminblogcategorieslistview.class.php" ); 7 8 /** 9 * \ingroup Action 10 * @private 11 * 12 * Action that adds a new article blog category 13 */ 14 class AdminAddBlogCategoryAction extends AdminAction 15 { 16 17 var $_categoryName; 18 var $_categoryDescription; 19 20 /** 21 * Constructor. If nothing else, it also has to call the constructor of the parent 22 * class, BlogAction with the same parameters 23 */ 24 function AdminAddBlogCategoryAction( $actionInfo, $request ) 25 { 26 $this->AdminAction( $actionInfo, $request ); 27 28 // register two validators 29 $this->registerFieldValidator( "categoryName", new StringValidator()); 30 $this->registerFieldValidator( "categoryDescription", new StringValidator()); 31 // and the view we should show in case there is a validation error 32 $errorView = new AdminTemplatedView( $this->_blogInfo, "newblogcategory" ); 33 $errorView->setErrorMessage( $this->_locale->tr("error_adding_blog_category" )); 34 $this->setValidationErrorView( $errorView ); 35 36 $this->requireAdminPermission( "add_blog_category" ); 37 } 38 39 /** 40 * Carries out the specified action 41 */ 42 function perform() 43 { 44 // fetch the data, we already know it's valid and that we can trust it! 45 $this->_categoryName = $this->_request->getValue( "categoryName" ); 46 $this->_categoryDescription = $this->_request->getValue( "categoryDescription" ); 47 48 // create the object... 49 $categories = new BlogCategories(); 50 $category = new BlogCategory( $this->_categoryName, $this->_categoryDescription ); 51 52 // fire the pre event... 53 $this->notifyEvent( EVENT_PRE_ADD_BLOG_CATEGORY, Array( "category" => &$category )); 54 55 // once we have built the object, we can add it to the database! 56 if( $categories->addBlogCategory( $category )) { 57 if( $this->userHasPermission( "view_blog_categories", ADMIN_PERMISSION )) 58 $this->_view = new AdminBlogCategoriesListView( $this->_blogInfo ); 59 else 60 $this->_view = new AdminTemplatedView( $this->_blogInfo, "newblogcategory" ); 61 62 $this->_view->setSuccess( true ); 63 $this->_view->setSuccessMessage( $this->_locale->pr("blog_category_added_ok", $category->getName())); 64 65 // fire the post event 66 $this->notifyEvent( EVENT_POST_ADD_BLOG_CATEGORY, Array( "category" => &$category )); 67 68 // clear the cache if everything went fine 69 CacheControl::resetBlogCache( $this->_blogInfo->getId(), false ); 70 71 $this->setCommonData(); 72 } 73 else { 74 // if there was an error, we should say so... as well as not changing the view since 75 // we're going back to the original view where we can add the category 76 $this->_view->setError( true ); 77 $this->_view->setErrorMessage( $this->_locale->tr("error_adding_category" )); 78 $this->setCommonData( true ); 79 } 80 81 // better to return true if everything fine 82 return true; 83 } 84 } 85 ?>
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 |
![]() |