00001 <?php
00002
00003 lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
00004 lt_include( PLOG_CLASS_PATH."class/dao/articlecategories.class.php" );
00005 lt_include( PLOG_CLASS_PATH."class/dao/articlecategory.class.php" );
00006 lt_include( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" );
00007 lt_include( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
00008 lt_include( PLOG_CLASS_PATH."class/data/textfilter.class.php" );
00009 lt_include( PLOG_CLASS_PATH."class/view/admin/adminarticlecategorieslistview.class.php" );
00010
00017 class AdminAddArticleCategoryAction extends AdminAction
00018 {
00019
00020 var $_categoryName;
00021 var $_categoryDescription;
00022 var $_categoryInMainPage;
00023
00028 function AdminAddArticleCategoryAction( $actionInfo, $request )
00029 {
00030 $this->AdminAction( $actionInfo, $request );
00031
00032
00033 $this->registerFieldValidator( "categoryName", new StringValidator());
00034 $this->registerFieldValidator( "categoryDescription", new StringValidator(), true );
00035 $this->registerFieldValidator( "categoryInMainPage", new IntegerValidator(), true );
00036
00037
00038 $errorView = new AdminTemplatedView( $this->_blogInfo, "newpostcategory" );
00039 $errorView->setErrorMessage( $this->_locale->tr("error_adding_article_category" ));
00040 $this->setValidationErrorView( $errorView );
00041
00042 $this->requirePermission( "add_category" );
00043
00044 }
00045
00049 function perform()
00050 {
00051
00052 $this->_categoryName = Textfilter::filterAllHTML($this->_request->getValue( "categoryName" ));
00053 $this->_categoryInMainPage = Textfilter::checkboxToBoolean($this->_request->getValue( "categoryInMainPage" ));
00054 $this->_categoryDescription = Textfilter::filterAllHTML($this->_request->getValue( "categoryDescription" ));
00055
00056
00057 $categories = new ArticleCategories();
00058 $category = new ArticleCategory( $this->_categoryName,
00059 "",
00060 $this->_blogInfo->getId(),
00061 $this->_categoryInMainPage,
00062 $this->_categoryDescription,
00063 0,
00064 Array() );
00065
00066
00067 $this->notifyEvent( EVENT_PRE_CATEGORY_ADD, Array( "category" => &$category ));
00068
00069
00070 if( $categories->addArticleCategory( $category )) {
00071
00072
00073
00074
00075 if( $this->userHasPermission( "view_categories" ))
00076 $this->_view = new AdminArticleCategoriesListView( $this->_blogInfo );
00077 else
00078 $this->_view = new AdminTemplatedView( $this->_blogInfo, "newpostcategory" );
00079
00080 $this->_view->setSuccess( true );
00081 $this->_view->setSuccessMessage( $this->_locale->pr("category_added_ok", $category->getName()));
00082
00083
00084 $this->notifyEvent( EVENT_POST_CATEGORY_ADD, Array( "category" => &$category ));
00085
00086
00087 CacheControl::resetBlogCache( $this->_blogInfo->getId(), false );
00088
00089 $this->setCommonData();
00090 }
00091 else {
00092
00093
00094 $this->_view->setError( true );
00095 $this->_view->setErrorMessage( $this->_locale->tr("error_adding_article_category" ));
00096 $this->setCommonData( true );
00097 }
00098
00099
00100 return true;
00101 }
00102 }
00103 ?>