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

   1  <?php
   2  
   3      lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
   4      lt_include( PLOG_CLASS_PATH."class/view/admin/admintemplatedview.class.php" );
   5      lt_include( PLOG_CLASS_PATH."class/view/admin/adminarticlecategorieslistview.class.php" );
   6      lt_include( PLOG_CLASS_PATH."class/dao/articlecategories.class.php" );
   7      lt_include( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" );
   8      lt_include( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
   9      lt_include( PLOG_CLASS_PATH."class/data/validator/emptyvalidator.class.php" );
  10  
  11      /**
  12       * \ingroup Action
  13       * @private
  14       *
  15       * Action that shows a form to change the settings of the article category
  16       */
  17      class AdminEditArticleCategoryAction extends AdminAction 
  18      {
  19  
  20          var $_categoryId;
  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 AdminEditArticleCategoryAction( $actionInfo, $request )
  27          {
  28              $this->AdminAction( $actionInfo, $request );
  29              
  30              // stuff for the data validation
  31              $this->registerFieldValidator( "categoryId", new IntegerValidator());
  32              $this->_form->registerField( "categoryName" );
  33              $this->_form->registerField( "categoryDescription" );
  34              $errorView = new AdminArticleCategoriesListView( $this->_blogInfo );
  35              $errorView->setErrorMessage( $this->_locale->tr("error_incorrect_category_id"));
  36              $this->setValidationErrorView( $errorView );
  37              
  38              $this->requirePermission( "update_category" );
  39          }
  40  
  41          /**
  42           * Carries out the specified action
  43           */
  44          function perform()
  45          {
  46              // fetch the category
  47              $this->_categoryId = $this->_request->getValue( "categoryId" );
  48              $categories = new ArticleCategories();
  49              $category   = $categories->getCategory( $this->_categoryId, $this->_blogInfo->getId());
  50              // show an error if we couldn't fetch the category
  51              if( !$category ) {
  52                  $this->_view = new AdminArticleCategoriesListView( $this->_blogInfo );
  53                  $this->_view->setErrorMessage( $this->_locale->tr("error_fetching_category") );
  54                  $this->_view->setError( true );
  55                  $this->setCommonData();
  56  
  57                  return false;
  58              }
  59              
  60              $this->notifyEvent( EVENT_CATEGORY_LOADED, Array( "category" => &$category ));            
  61              // otherwise show the form to edit its fields
  62              $this->_view = new AdminTemplatedView( $this->_blogInfo, "editarticlecategory" );
  63              $this->_view->setValue( "category", $category );
  64              $this->_view->setValue( "categoryName", $category->getName());
  65              $this->_view->setValue( "categoryDescription", $category->getDescription());
  66              $this->_view->setValue( "categoryInMainPage", $category->isInMainPage());
  67              $this->_view->setValue( "categoryId", $category->getId());
  68              $this->setCommonData();
  69  
  70              // better to return true if everything fine
  71              return true;
  72          }
  73      }
  74  ?>


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