[ 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/validator/integervalidator.class.php" ); 6 lt_include( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" ); 7 lt_include( PLOG_CLASS_PATH."class/data/validator/emptyvalidator.class.php" ); 8 lt_include( PLOG_CLASS_PATH."class/view/admin/admintemplatedview.class.php" ); 9 lt_include( PLOG_CLASS_PATH."class/view/admin/adminarticlecategorieslistview.class.php" ); 10 lt_include( PLOG_CLASS_PATH."class/data/textfilter.class.php" ); 11 12 /** 13 * \ingroup Action 14 * @private 15 * 16 * Updates an article category. 17 */ 18 class AdminUpdateArticleCategoryAction extends AdminAction 19 { 20 21 var $_categoryName; 22 var $_categoryUrl; 23 var $_categoryId; 24 var $_categoryDescription; 25 var $_categoryInMainPage; 26 var $_properties; 27 28 /** 29 * Constructor. If nothing else, it also has to call the constructor of the parent 30 * class, BlogAction with the same parameters 31 */ 32 function AdminUpdateArticleCategoryAction( $actionInfo, $request ) 33 { 34 $this->AdminAction( $actionInfo, $request ); 35 36 // data validation settings 37 $this->registerFieldValidator( "categoryName", new StringValidator()); 38 $this->registerFieldValidator( "categoryId", new IntegerValidator()); 39 $this->registerFieldValidator( "categoryDescription", new StringValidator()); 40 $this->registerFieldValidator( "categoryInMainPage", new EmptyValidator()); 41 $errorView = new AdminTemplatedView( $this->_blogInfo, "editarticlecategory" ); 42 $errorView->setErrorMessage( $this->_locale->tr("error_updating_article_category" )); 43 $this->setValidationErrorView( $errorView ); 44 45 $this->requirePermission( "update_category" ); 46 } 47 48 /** 49 * Carries out the specified action 50 */ 51 function perform() 52 { 53 // get the data from the form 54 $this->_categoryName = Textfilter::filterAllHTML($this->_request->getValue( "categoryName" )); 55 $this->_categoryId = $this->_request->getValue( "categoryId" ); 56 $this->_categoryDescription = Textfilter::filterAllHTML($this->_request->getValue( "categoryDescription" )); 57 $this->_categoryInMainPage = $this->_request->getValue( "categoryInMainPage" ); 58 $this->_properties = Array(); 59 60 // fetch the category we're trying to update 61 $categories = new ArticleCategories(); 62 $category = $categories->getCategory( $this->_categoryId, $this->_blogInfo->getId()); 63 if( !$category ) { 64 $this->_view = new AdminArticleCategoriesListView( $this->_blogInfo ); 65 $this->_view->setErrorMessage( $this->_locale->tr("error_fetching_category")); 66 $this->setCommonData(); 67 68 return false; 69 } 70 71 // fire the pre-event 72 $this->notifyEvent( EVENT_PRE_CATEGORY_UPDATE, Array( "category" => &$category )); 73 74 // update the fields 75 $category->setName( $this->_categoryName ); 76 $category->setUrl( "" ); 77 $category->setInMainPage( $this->_categoryInMainPage ); 78 $category->setProperties( $this->_properties ); 79 $category->setDescription( $this->_categoryDescription ); 80 81 if( $this->userHasPermission( "view_categories" )) 82 $this->_view = new AdminArticleCategoriesListView( $this->_blogInfo ); 83 else { 84 $this->_view = new AdminTemplatedView( $this->_blogInfo, "editarticlecategory" ); 85 $this->_view->setValue( "category", $category ); 86 $this->_view->setValue( "categoryName", $category->getName()); 87 $this->_view->setValue( "categoryDescription", $category->getDescription()); 88 $this->_view->setValue( "categoryInMainPage", $category->isInMainPage()); 89 $this->_view->setValue( "categoryId", $category->getId()); 90 } 91 92 if( !$categories->updateCategory( $category )) { 93 $this->_view->setErrorMessage( $this->_locale->tr("error_updating_article_category")); 94 } 95 else { 96 // if everything fine, load the list of categories 97 $this->_view->setSuccessMessage( $this->_locale->pr("article_category_updated_ok", $category->getName())); 98 99 // fire the post-event 100 $this->notifyEvent( EVENT_POST_CATEGORY_UPDATE, Array( "category" => &$category )); 101 102 // clear the cache 103 CacheControl::resetBlogCache( $this->_blogInfo->getId()); 104 } 105 106 $this->setCommonData(); 107 108 // better to return true if everything fine 109 return true; 110 } 111 } 112 ?>
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 |
![]() |