[ 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/ -> adminplugincenteraction.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/adminerrorview.class.php" );
   6      lt_include( PLOG_CLASS_PATH."class/plugin/pluginmanager.class.php" );
   7      lt_include( PLOG_CLASS_PATH."class/xml/rssparser/rssparser.class.php" );
   8  
   9      /**
  10       * \ingroup Action
  11       * @private
  12       *
  13       * Shows the list of plugins loaded.
  14       *
  15       * In the future it'll be possible to do more things from within the
  16       * "Plugin Center", but for now this is enough... Planned things:
  17       * <ul>
  18       * <li>per blog enable/disable plugin</li>
  19       * <li>add/remove plugins</li>
  20       * <li>I'll add more when I can think of more :)</li>
  21       * </ul>
  22       */
  23      class AdminPluginCenterAction extends AdminAction 
  24      {
  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 AdminPluginCenterAction( $actionInfo, $request )
  31          {
  32              $this->AdminAction( $actionInfo, $request );
  33  
  34              $this->requireAdminPermission( "view_plugins" );
  35          }
  36  
  37          /**
  38           * Carries out the specified action
  39           */
  40          function perform()
  41          {
  42              // initialize the plugin manager and load the plugins
  43              $pluginManager =& PluginManager::getPluginManager();
  44  
  45              $doVersionCheck = $this->_request->getValue( "doVersionCheck", false );
  46  
  47              // check if the plugin manager is enabled or not, since if it's not
  48              // there is no point in this feature...
  49              if( !$pluginManager->isEnabled()) {
  50                  $this->_view = new AdminErrorView( $this->_blogInfo );
  51                  $this->_view->setMessage( $this->_locale->tr("error_plugins_disabled"));
  52                  $this->setCommonData();
  53  
  54                  return false;
  55              }
  56  
  57              // we need to get an array with the plugins
  58              $pluginManager->refreshPluginList();
  59              $pluginManager->setBlogInfo( $this->_blogInfo );
  60              $pluginManager->setUserInfo( $this->_userInfo );
  61              $plugins = $pluginManager->getPlugins();
  62  
  63              // create a view and put the plugin objects in the template
  64              $this->_view = new AdminTemplatedView( $this->_blogInfo, "plugincenter" );
  65              $this->_view->setValue( "plugins", $plugins );
  66  
  67              // load the feed with plugin versions and display an error if there was a problem
  68              if( $doVersionCheck ) {
  69                  $rss = new RssParser();
  70                  if( $rss->parse( Version::getPluginVersionFeed())) {
  71                      $items = $rss->getItems();
  72  
  73                      // process the parsed rss feed
  74                      $data = Array();
  75                      foreach( $items as $pluginData ) {
  76                          $data[$pluginData->getTitle()] = Array(
  77                              "version" => $pluginData->_item["lt"]["version"],
  78                              "downloadLink" => $pluginData->getLink()
  79                          );
  80                      }
  81  
  82                      $this->_view->setValue( "pluginData", $data );
  83                  }
  84                  else {
  85                      $doVersionCheck = false;
  86                  }
  87              }
  88              else {
  89                  $doVersionCheck = false;
  90              }
  91  
  92              $this->_view->setValue( "versionCheck", $doVersionCheck );
  93              $this->setCommonData();
  94  
  95              // better to return true if everything fine
  96              return true;
  97          }
  98      }
  99  ?>


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