[ Index ] |
|
Code source de LifeType 1.2.4 |
1 <?php 2 /** 3 * GLobal artical Category files added by Ameng(Ameng.vVlogger.com) 2005-06-20 4 * version 1.0 5 * Changed from original article category. 6 */ 7 lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" ); 8 lt_include( PLOG_CLASS_PATH."class/dao/globalarticlecategories.class.php" ); 9 lt_include( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" ); 10 lt_include( PLOG_CLASS_PATH."class/data/validator/arrayvalidator.class.php" ); 11 lt_include( PLOG_CLASS_PATH."class/data/validator/emptyvalidator.class.php" ); 12 lt_include( PLOG_CLASS_PATH."class/view/admin/adminglobalarticlecategorieslistview.class.php" ); 13 14 /** 15 * \ingroup Action 16 * @private 17 * 18 * Deletes an article category from the database 19 */ 20 class AdminDeleteGlobalArticleCategoryAction extends AdminAction 21 { 22 23 var $_categoryId; 24 var $_categoryIds; 25 26 /** 27 * Constructor. If nothing else, it also has to call the constructor of the parent 28 * class, BlogAction with the same parameters 29 */ 30 function AdminDeleteGlobalArticleCategoryAction( $actionInfo, $request ) 31 { 32 $this->AdminAction( $actionInfo, $request ); 33 $this->_mode = $actionInfo->getActionParamValue(); 34 35 // get the array that contains the categories we'd like to delete 36 if( $this->_mode == "deleteGlobalArticleCategory" ) 37 $this->registerFieldValidator( "categoryId", new IntegerValidator()); 38 else 39 $this->registerFieldValidator( "categoryIds", new ArrayValidator()); 40 41 $view = new AdminGlobalArticleCategoriesListView( $this->_blogInfo ); 42 $view->setErrorMessage( $this->_locale->tr("error_incorrect_global_category_id")); 43 $this->setValidationErrorView( $view ); 44 45 $this->requireAdminPermission( "update_global_category" ); 46 } 47 48 /** 49 * @private 50 * removes categories from the database 51 */ 52 function _deleteGlobalArticleCategories() 53 { 54 $categories = new GlobalArticleCategories(); 55 56 $errorMessage = ""; 57 $successMessage = ""; 58 $totalOk = 0; 59 60 foreach( $this->_categoryIds as $categoryId ) { 61 // get the category 62 $category = $categories->getGlobalArticleCategory( $categoryId ); 63 64 if( $category ) { 65 // get how many articles it has 66 $numArticles = $category->getNumArticles( POST_STATUS_ALL ); 67 68 // fire the pre-event 69 $this->notifyEvent( EVENT_PRE_DELETE_GLOBAL_CATEGORY, Array( "category" => &$category )); 70 71 // if everything correct, we can proceed and delete it 72 if( $numArticles > 0 ) { 73 $errorMessage .= $this->_locale->pr( "error_global_category_has_articles", $category->getName())."<br/>"; 74 } 75 else { 76 if( !$categories->deleteGlobalArticleCategory( $categoryId)) 77 $errorMessage .= $this->_locale->pr("error_deleting_global_category")."<br/>"; 78 else { 79 if( $totalOk < 2 ) 80 $successMessage .= $this->_locale->pr("global_category_deleted_ok", $category->getName())."<br/>"; 81 else 82 $successMessage = $this->_locale->pr( "global_categories_deleted_ok", $totalOk ); 83 84 // fire the pre-event 85 $this->notifyEvent( EVENT_POST_DELETE_GLOBAL_CATEGORY, Array( "category" => &$category )); 86 } 87 } 88 } 89 else { 90 $errorMessage .= $this->_locale->pr("error_deleting_global_category2", $categoryId)."<br/>"; 91 } 92 } 93 94 // prepare the view and all the information it needs to know 95 $this->_view = new AdminGlobalArticleCategoriesListView( $this->_blogInfo ); 96 if( $errorMessage != "" ) 97 $this->_view->setErrorMessage( $errorMessage ); 98 if( $successMessage != "" ) { 99 // and clear the cache to avoid outdated information 100 CacheControl::resetBlogCache( $this->_blogInfo->getId(), false ); 101 $this->_view->setSuccessMessage( $successMessage ); 102 } 103 104 $this->setCommonData(); 105 106 return true; 107 } 108 109 /** 110 * Carries out the specified action 111 */ 112 function perform() 113 { 114 // prepare the parameters.. If there's only one category id, then add it to 115 // an array. 116 if( $this->_mode == "deleteGlobalArticleCategory" ) { 117 $this->_categoryIds = Array(); 118 $this->_categoryIds[] = $this->_request->getValue( "categoryId" ); 119 } 120 else 121 $this->_categoryIds = $this->_request->getValue( "categoryIds" ); 122 123 return $this->_deleteGlobalArticleCategories(); 124 } 125 } 126 ?>
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 |
![]() |