lifetype-1.1.6/class/action/admin/adminaddblogcategoryaction.class.php
Go to the documentation of this file.00001 <?php
00002
00003 include_once( PLOG_CLASS_PATH."class/action/admin/siteadminaction.class.php" );
00004 include_once( PLOG_CLASS_PATH."class/dao/blogcategories.class.php" );
00005 include_once( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" );
00006 include_once( PLOG_CLASS_PATH."class/view/admin/adminblogcategorieslistview.class.php" );
00007
00014 class AdminAddBlogCategoryAction extends SiteAdminAction
00015 {
00016
00017 var $_categoryName;
00018 var $_categoryDescription;
00019
00024 function AdminAddBlogCategoryAction( $actionInfo, $request )
00025 {
00026 $this->SiteAdminAction( $actionInfo, $request );
00027
00028
00029 $this->registerFieldValidator( "categoryName", new StringValidator());
00030 $this->registerFieldValidator( "categoryDescription", new StringValidator());
00031
00032 $errorView = new AdminTemplatedView( $this->_blogInfo, "newblogcategory" );
00033 $errorView->setErrorMessage( $this->_locale->tr("error_adding_blog_category" ));
00034 $this->setValidationErrorView( $errorView );
00035 }
00036
00040 function perform()
00041 {
00042
00043 $this->_categoryName = $this->_request->getValue( "categoryName" );
00044 $this->_categoryDescription = $this->_request->getValue( "categoryDescription" );
00045
00046
00047 $categories = new BlogCategories();
00048 $category = new BlogCategory( $this->_categoryName, $this->_categoryDescription );
00049
00050
00051 $this->notifyEvent( EVENT_PRE_ADD_BLOG_CATEGORY, Array( "category" => &$category ));
00052
00053
00054 if( $categories->addBlogCategory( $category )) {
00055 $this->_view = new AdminBlogCategoriesListView( $this->_blogInfo );
00056 $this->_view->setSuccess( true );
00057 $this->_view->setSuccessMessage( $this->_locale->pr("blog_category_added_ok", $category->getName()));
00058
00059
00060 $this->notifyEvent( EVENT_POST_ADD_BLOG_CATEGORY, Array( "category" => &$category ));
00061
00062
00063 CacheControl::resetBlogCache( $this->_blogInfo->getId(), false );
00064
00065 $this->setCommonData();
00066 }
00067 else {
00068
00069
00070 $this->_view->setError( true );
00071 $this->_view->setErrorMessage( $this->_locale->tr("error_adding_category" ));
00072 $this->setCommonData( true );
00073 }
00074
00075
00076 return true;
00077 }
00078 }
00079 ?>