Beispiel #1
0
 /**
  * Search the list of available plugins or display the most
  * recommended plugins if the user did not trigger a search.
  */
 public function search_action()
 {
     $search = Request::get('search');
     // search for plugins in all repositories
     try {
         $repository = new PluginRepository();
         $search_results = $repository->getPlugins($search);
     } catch (Exception $ex) {
         $search_results = array();
     }
     $plugins = PluginManager::getInstance()->getPluginInfos();
     // filter out already installed plugins
     foreach ($plugins as $plugin) {
         if (isset($search_results[$plugin['name']])) {
             unset($search_results[$plugin['name']]);
         }
     }
     if ($search === NULL) {
         // sort plugins by score
         uasort($search_results, array($this, 'compare_score'));
         $search_results = array_slice($search_results, 0, 6);
     } else {
         // sort plugins by name
         uksort($search_results, 'strnatcasecmp');
     }
     $this->search = $search;
     $this->search_results = $search_results;
     $this->plugins = $plugins;
     $this->unknown_plugins = $this->plugin_admin->scanPluginDirectory();
 }