Ejemplo n.º 1
0
 /**
  * Default action. Shows the list of all installed plugins.
  */
 public function index()
 {
     OW::getNavigation()->activateMenuItem(OW_Navigation::ADMIN_PLUGINS, 'admin', 'sidebar_menu_plugins_installed');
     $language = OW::getLanguage();
     $this->setPageTitle($language->text('admin', 'page_title_manage_plugins'));
     $this->setPageHeading($language->text('admin', 'page_title_manage_plugins'));
     $this->setPageHeadingIconClass('ow_ic_gear_wheel');
     $this->pluginService->updatePluginsXmlInfo();
     // get plugins in DB
     $plugins = $this->pluginService->findRegularPlugins();
     usort($plugins, array(__CLASS__, 'sortPlugins'));
     $arrayToAssign['active'] = array();
     $arrayToAssign['inactive'] = array();
     /* @var $plugin BOL_Plugin */
     foreach ($plugins as $plugin) {
         $array = array('title' => $plugin->getTitle(), 'description' => $plugin->getDescription(), 'set_url' => $plugin->isActive && $plugin->getAdminSettingsRoute() !== null ? OW::getRouter()->urlForRoute($plugin->adminSettingsRoute) : false, 'update_url' => (int) $plugin->getUpdate() === 1 && !defined('OW_PLUGIN_XP') ? OW::getRouter()->urlFor('ADMIN_CTRL_Plugins', 'updateRequest', array('key' => $plugin->getKey())) : false);
         if ($plugin->isActive()) {
             $array['deact_url'] = OW::getRouter()->urlFor(__CLASS__, 'deactivate', array('key' => $plugin->getKey()));
             $array['un_url'] = $plugin->getUninstallRoute() === null ? OW::getRouter()->urlFor(__CLASS__, 'uninstallRequest', array('key' => $plugin->getKey())) : OW::getRouter()->urlForRoute($plugin->getUninstallRoute());
             $arrayToAssign['active'][$plugin->getKey()] = $array;
         } else {
             $array['active_url'] = OW::getRouter()->urlFor(__CLASS__, 'activate', array('key' => $plugin->getKey()));
             $arrayToAssign['inactive'][$plugin->getKey()] = $array;
         }
     }
     $event = new OW_Event('admin.plugins_list_view', array('ctrl' => $this, 'type' => 'index'), $arrayToAssign);
     OW::getEventManager()->trigger($event);
     $arrayToAssign = $event->getData();
     $this->assign('plugins', $arrayToAssign);
 }