[ Index ]
 

Code source de LifeType 1.2.4

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/class/action/admin/ -> adminupdateglobalarticlecategoryaction.class.php (source)

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


Généré le : Mon Nov 26 21:04:15 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics