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