lifetype-1.1.6/class/action/admin/adminaddarticlecategoryajaxaction.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/data/textfilter.class.php" );
00006 include_once( PLOG_CLASS_PATH."class/view/admin/adminxmlview.class.php" );
00007
00014 class AdminAddArticleCategoryAjaxAction extends AdminAction
00015 {
00016
00017 var $_categoryName;
00018 var $_categoryUrl;
00019 var $_properties;
00020 var $_categoryDescription;
00021
00026 function AdminAddArticleCategoryAjaxAction( $actionInfo, $request )
00027 {
00028 $this->AdminAction( $actionInfo, $request );
00029 }
00030 function validate()
00031 {
00032
00033 $this->_categoryName = Textfilter::filterAllHTML($this->_request->getValue( "categoryName" ));
00034 $this->_categoryUrl = "";
00035 $this->_categoryInMainPage = 1;
00036 $this->_categoryDescription = $this->_categoryName;
00037 $this->_properties = "";
00038
00039
00040 if( empty($this->_categoryName) || $this->_categoryName == "" ) {
00041 $this->_view = new AdminXmlView( $this->_blogInfo, "response" );
00042 $this->_view->setValue( "method", "addCategoryAjax" );
00043 $this->_view->setValue( "success", "0" );
00044 $this->_view->setValue( "message", $this->_locale->tr("error_adding_article_category") );
00045 return false;
00046 }
00047 return true;
00048 }
00049
00053 function perform()
00054 {
00055
00056 $categories = new ArticleCategories();
00057 $category = new ArticleCategory( $this->_categoryName,
00058 $this->_categoryUrl,
00059 $this->_blogInfo->getId(),
00060 $this->_categoryInMainPage,
00061 $this->_categoryDescription,
00062 0,
00063 $this->_properties );
00064
00065
00066 $this->notifyEvent( EVENT_PRE_CATEGORY_ADD, Array( "category" => &$category ));
00067
00068 $this->_view = new AdminXmlView( $this->_blogInfo, "response" );
00069 $this->_view->setValue( "method", "addCategoryAjax" );
00070
00071
00072 $catId = $categories->addArticleCategory( $category );
00073
00074
00075 $this->_view = new AdminXmlView( $this->_blogInfo, "response" );
00076 $this->_view->setValue( "method", "addCategoryAjax" );
00077 if( $catId )
00078 {
00079 $this->_view->setValue( "success", "1" );
00080 $this->_view->setValue( "message", $this->_locale->pr("category_added_ok", $this->_categoryName) );
00081
00082 $result = '<id>'.$catId.'</id>';
00083 $result .= '<name>'.$this->_categoryName.'</name>';
00084 $this->_view->setValue( "result", $result );
00085
00086
00087 $this->notifyEvent( EVENT_POST_CATEGORY_ADD, Array( "category" => &$category ));
00088
00089
00090 CacheControl::resetBlogCache( $this->_blogInfo->getId(), false );
00091 }
00092 else
00093 {
00094 $this->_view->setValue( "success", "0" );
00095 $this->_view->setValue( "message", $this->_locale->tr("error_adding_article_category") );
00096 }
00097
00098 return true;
00099 }
00100 }
00101 ?>