[ 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/ -> adminaddglobalarticlecategoryaction.class.php (source)

   1  <?php
   2  
   3         /**
   4         * GLobal artical Category files added by Ameng(Ameng.vVlogger.com) 2005-06-20
   5         * version 1.0 
   6         * Changed from original article category.
   7         */
   8  
   9      lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
  10      lt_include( PLOG_CLASS_PATH."class/dao/globalarticlecategories.class.php" );
  11      lt_include( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" );
  12      lt_include( PLOG_CLASS_PATH."class/view/admin/adminglobalarticlecategorieslistview.class.php" );
  13  
  14      /**
  15       * \ingroup Action
  16       * @private
  17       *
  18       * Action that adds a new article category to the database.
  19       */
  20      class AdminAddGlobalArticleCategoryAction extends AdminAction 
  21      {
  22  
  23          var $_categoryName;
  24          var $_categoryDescription;
  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 AdminAddGlobalArticleCategoryAction( $actionInfo, $request )
  31          {
  32              $this->AdminAction( $actionInfo, $request );
  33              
  34              // register two validators
  35              $this->registerFieldValidator( "categoryName", new StringValidator());
  36              $this->registerFieldValidator( "categoryDescription", new StringValidator());
  37              // and the view we should show in case there is a validation error
  38              $errorView = new AdminTemplatedView( $this->_blogInfo, "newglobalarticlecategory" );
  39              $errorView->setErrorMessage( $this->_locale->tr("error_adding_global_article_category" ));            
  40              $this->setValidationErrorView( $errorView );
  41                  
  42              $this->requireAdminPermission( "add_global_category" );                
  43          }
  44  
  45          /**
  46           * Carries out the specified action
  47           */
  48          function perform()
  49          {
  50              // fetch the data, we already know it's valid and that we can trust it!
  51              $this->_categoryName     = $this->_request->getValue( "categoryName" );
  52               $this->_categoryDescription = $this->_request->getValue( "categoryDescription" );
  53          
  54              // create the object...
  55              $categories = new GlobalArticleCategories();
  56              $category   = new GlobalArticleCategory( $this->_categoryName,
  57                                                         $this->_categoryDescription );
  58                                                 
  59              // fire the pre event...
  60              $this->notifyEvent( EVENT_PRE_ADD_GLOBAL_CATEGORY, Array( "category" => &$category ));
  61  
  62              // once we have built the object, we can add it to the database!
  63               if( $categories->addGlobalArticleCategory( $category )) {
  64                  // if everything went fine, transfer the execution flow to the action that
  65                  // lists all the article categories... without forgetting that we should let the
  66                  // next class know that we actually added a category alongside a message
  67                  // and the category that we just added!
  68                  if( $this->userHasPermission( "view_global_categories", ADMIN_PERMISSION ))
  69                      $this->_view = new AdminGlobalArticleCategoriesListView( $this->_blogInfo );
  70                  else
  71                      $this->_view = new AdminTemplatedView( $this->_blogInfo, "newglobalarticlecategory" );
  72                  $this->_view->setSuccess( true );
  73                  $this->_view->setSuccessMessage( $this->_locale->pr("global_category_added_ok", $category->getName()));
  74                  
  75                  // fire the post event
  76                  $this->notifyEvent( EVENT_POST_ADD_GLOBAL_CATEGORY, Array( "category" => &$category ));
  77                  
  78                  $this->setCommonData();                
  79              }
  80              else {
  81                  // if there was an error, we should say so... as well as not changing the view since
  82                  // we're going back to the original view where we can add the category
  83                  $this->_view->setError( true );
  84                  $this->_view->setErrorMessage( $this->_locale->tr("error_adding_global_article_category" ));
  85                  $this->setCommonData( true );
  86              }
  87  
  88              // better to return true if everything fine
  89              return true;
  90          }
  91      }
  92  ?>


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