[ 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/articlecategories.class.php" ); 5 lt_include( PLOG_CLASS_PATH."class/data/textfilter.class.php" ); 6 lt_include( PLOG_CLASS_PATH."class/view/admin/adminxmlview.class.php" ); 7 8 /** 9 * \ingroup Action 10 * @private 11 * 12 * Action that adds a new article category to the database. 13 */ 14 class AdminAddArticleCategoryAjaxAction extends AdminAction 15 { 16 17 var $_categoryName; 18 var $_categoryUrl; 19 var $_properties; 20 var $_categoryDescription; 21 22 /** 23 * Constructor. If nothing else, it also has to call the constructor of the parent 24 * class, BlogAction with the same parameters 25 */ 26 function AdminAddArticleCategoryAjaxAction( $actionInfo, $request ) 27 { 28 $this->AdminAction( $actionInfo, $request ); 29 } 30 31 function validate() 32 { 33 // check if the user has the add_category permission 34 if( !$this->userHasPermission( "add_category" ) ) { 35 $this->_view = new AdminXmlView( $this->_blogInfo, "response" ); 36 $this->_view->setValue( "method", "addCategoryAjax" ); 37 $this->_view->setValue( "success", "0" ); 38 $this->_view->setValue( "message", $this->_locale->tr("error_permission_required") ); 39 return false; 40 } 41 42 // check if category name is empty 43 $this->_categoryName = Textfilter::filterAllHTML($this->_request->getValue( "categoryName" )); 44 $this->_categoryUrl = ""; 45 $this->_categoryInMainPage = 1; 46 $this->_categoryDescription = $this->_categoryName; 47 $this->_properties = ""; 48 49 if( empty($this->_categoryName) || $this->_categoryName == "" ) { 50 $this->_view = new AdminXmlView( $this->_blogInfo, "response" ); 51 $this->_view->setValue( "method", "addCategoryAjax" ); 52 $this->_view->setValue( "success", "0" ); 53 $this->_view->setValue( "message", $this->_locale->tr("error_adding_article_category") ); 54 return false; 55 } 56 57 return true; 58 } 59 60 /** 61 * Carries out the specified action 62 */ 63 function perform() 64 { 65 // create the object... 66 $categories = new ArticleCategories(); 67 $category = new ArticleCategory( $this->_categoryName, 68 $this->_categoryUrl, 69 $this->_blogInfo->getId(), 70 $this->_categoryInMainPage, 71 $this->_categoryDescription, 72 0, 73 $this->_properties ); 74 75 // fire the pre event... 76 $this->notifyEvent( EVENT_PRE_CATEGORY_ADD, Array( "category" => &$category )); 77 78 $this->_view = new AdminXmlView( $this->_blogInfo, "response" ); 79 $this->_view->setValue( "method", "addCategoryAjax" ); 80 81 // once we have built the object, we can add it to the database! 82 $catId = $categories->addArticleCategory( $category ); 83 84 // once we have built the object, we can add it to the database 85 $this->_view = new AdminXmlView( $this->_blogInfo, "response" ); 86 $this->_view->setValue( "method", "addCategoryAjax" ); 87 if( $catId ) 88 { 89 $this->_view->setValue( "success", "1" ); 90 $this->_view->setValue( "message", $this->_locale->pr("category_added_ok", $this->_categoryName) ); 91 92 $result = '<id>'.$catId.'</id>'; 93 $result .= '<name>'.$this->_categoryName.'</name>'; 94 $this->_view->setValue( "result", $result ); 95 96 // fire the post event 97 $this->notifyEvent( EVENT_POST_CATEGORY_ADD, Array( "category" => &$category )); 98 99 // clear the cache if everything went fine 100 CacheControl::resetBlogCache( $this->_blogInfo->getId(), false ); 101 } 102 else 103 { 104 $this->_view->setValue( "success", "0" ); 105 $this->_view->setValue( "message", $this->_locale->tr("error_adding_article_category") ); 106 } 107 108 return true; 109 } 110 } 111 ?>
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 |
![]() |