[ 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/ -> adminupdatepluginsettingsaction.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/adminpluginsettingsview.class.php" );
   5      lt_include( PLOG_CLASS_PATH."class/plugin/pluginmanager.class.php" );
   6      lt_include( PLOG_CLASS_PATH."class/data/validator/emptyvalidator.class.php" );
   7      lt_include( PLOG_CLASS_PATH."class/plugin/globalpluginconfig.class.php" );
   8  
   9      /**
  10       * \ingroup Action
  11       * @private
  12       */
  13      class AdminUpdatePluginSettingsAction extends AdminAction 
  14      {
  15          
  16          var $pm;
  17  
  18          /**
  19           * Constructor. If nothing else, it also has to call the constructor of the parent
  20           * class, BlogAction with the same parameters
  21           */
  22          function AdminUpdatePluginSettingsAction( $actionInfo, $request )
  23          {
  24              $this->AdminAction( $actionInfo, $request );
  25  
  26              // initialize the plugin manager and load the plugins
  27              $this->pm =& PluginManager::getPluginManager();            
  28  
  29              // register the validators for all the plugin data
  30              $this->registerValidators();
  31              $view = new AdminPluginSettingsView( $this->_blogInfo, $this->_userInfo );
  32              $view->setData( false );
  33              $view->setErrorMessage( $this->_locale->tr("error_updating_global_plugin_settings" ));
  34              $this->setValidationErrorView( $view );
  35              
  36              $this->requireAdminPermission( "update_plugin_settings" );            
  37          }
  38  
  39          /**
  40           * @private
  41           */
  42  		function registerValidators()
  43          {
  44              // get all the plugins
  45              $this->pm->refreshPluginList();
  46              $this->pm->setBlogInfo( $this->_blogInfo );
  47              $this->pm->setUserInfo( $this->_userInfo );
  48  
  49              // now one by one, query their public configuration values and set the validators
  50              foreach( $this->pm->getPlugins() as $plugin ) {
  51                  foreach( $plugin->getPluginConfigurationKeys() as $key ) {
  52                      isset( $key["validator"] ) ? $validator = $key["validator"] : $validator = new EmptyValidator();
  53                      isset( $key["allowEmpty"] ) ? $allowEmpty = $key["allowEmpty"] : $allowEmpty = false;
  54                      $this->registerFieldValidator( $key["name"], $validator, $allowEmpty );
  55                  }
  56              }
  57              
  58              // "can override" fields
  59              $this->registerField( "canOverride" );
  60          }
  61  
  62          /**
  63           * Carries out the specified action
  64           */
  65          function perform()
  66          {
  67              // load the plugin config values
  68              $settings = Array();
  69              foreach( $this->pm->getPlugins() as $plugin ) {
  70                  foreach( $plugin->getPluginConfigurationKeys() as $key ) {
  71                      $keyName = $key["name"];
  72                      $settings[$keyName] = $this->_request->getValue( $keyName );
  73                  }
  74              }            
  75              // and now save them
  76              GlobalPluginConfig::setValues( $settings );
  77              
  78              // load the override settings and save them
  79              GlobalPluginConfig::setOverrideSettings( $this->_request->getValue( "canOverride" ));
  80              
  81              $this->_view = new AdminPluginSettingsView( $this->_blogInfo, $this->_userInfo );
  82              $this->_view->setData( true );
  83              $this->_view->setSuccessMessage( $this->_locale->tr( "global_plugin_settings_saved_ok" ));
  84              $this->setCommonData();
  85              
  86              return( true );            
  87          }
  88      }
  89  ?>


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