[ 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/ -> adminchangelinkscategoryaction.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/dao/mylinks.class.php" );
   5      lt_include( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
   6      lt_include( PLOG_CLASS_PATH."class/data/validator/arrayvalidator.class.php" );
   7      lt_include( PLOG_CLASS_PATH."class/view/admin/adminlinkslistview.class.php" );
   8  
   9      /**
  10       * \ingroup Action
  11       * @private
  12       *
  13       * Action that shows a form to change the settings of the current blog.
  14       */
  15      class AdminChangeLinksCategoryAction extends AdminAction 
  16      {
  17  
  18          var $_linkIds;
  19          var $_linkCategoryId;
  20  
  21          /**
  22           * Constructor. If nothing else, it also has to call the constructor of the parent
  23           * class, BlogAction with the same parameters
  24           */
  25          function AdminChangeLinksCategoryAction( $actionInfo, $request )
  26          {
  27              $this->AdminAction( $actionInfo, $request );
  28              
  29              $this->registerFieldValidator( "linkIds", new ArrayValidator());
  30              $this->registerFieldValidator( "linkCategoryId", new IntegerValidator());
  31              $view = new AdminLinksListView( $this->_blogInfo );    
  32              $view->setErrorMessage( $this->_locale->tr("error_no_links_selected"));
  33              $this->setValidationErrorView( $view );
  34          }
  35          
  36  		function perform()
  37          {
  38              $this->_linkIds = $this->_request->getValue( "linkIds" );
  39              $this->_linkCategoryId = $this->_request->getValue( "linkCategoryId" );
  40                  
  41              $this->_changeLinks();
  42          }
  43  
  44          /**
  45           * Carries out the specified action
  46           * @private
  47           */
  48          function _changeLinks()
  49          {
  50              $errorMessage = "";
  51              $successMessage = "";
  52              $numOk = 0;
  53  
  54              // update the link
  55              $links = new MyLinks();
  56  
  57              foreach( $this->_linkIds as $linkId ) {
  58                  // load the link
  59                  $link = $links->getMyLink( $linkId, $this->_blogInfo->getId());
  60                  
  61                  if( $link ) {
  62                      // fire the event
  63                      $this->notifyEvent( EVENT_PRE_LINK_UPDATE, Array( "link" => &$link ));
  64  
  65                      // update the link category
  66                      $link->setCategoryId( $this->_linkCategoryId );
  67                      $result = $links->updateMyLink( $link );
  68                      
  69                      if( !$result )
  70                          $errorMessage .= $this->_locale->pr("error_updating_link", $link->getName())."<br/>";
  71                      else {
  72                          $numOk++;
  73                          if( $numOk > 1 )
  74                              $successMessage = $this->_locale->pr("links_updated_ok", $numOk );
  75                          else
  76                              $successMessage = $this->_locale->pr("link_updated_ok", $link->getName());
  77                      }
  78                  }
  79                  else {
  80                      $errorMessage .= $this->_locale->pr("error_updating_link2", $linkId)."<br/>";
  81                  }
  82              }
  83  
  84              $this->_view = new AdminLinksListView( $this->_blogInfo );
  85              if( $errorMessage != "" ) $this->_view->setErrorMessage( $errorMessage );
  86              if( $successMessage != "" ) $this->_view->setSuccessMessage( $successMessage );
  87              $this->setCommonData();
  88              
  89              // clear the cache
  90              CacheControl::resetBlogCache( $this->_blogInfo->getId(), false );
  91  
  92              // better to return true if everything fine
  93              return true;
  94          }
  95      }
  96  ?>


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