示例#1
0
 /**
  * Search a plugin on the download platform
  */
 public function search()
 {
     $api = new HawkApi();
     $search = App::request()->getParams('search');
     // Search plugins on the API
     try {
         $plugins = $api->searchPlugins($search);
     } catch (\Hawk\HawkApiException $e) {
         $plugins = array();
     }
     // Remove the plugins already downloaded on the application
     foreach ($plugins as &$plugin) {
         $installed = Plugin::get($plugin['name']);
         $plugin['installed'] = $installed !== null;
         if ($installed) {
             $plugin['currentVersion'] = $installed->getDefinition('version');
         }
     }
     $this->addKeysToJavaScript($this->_plugin . '.search-plugin-downloads', $this->_plugin . '.download-plugin-dependencies');
     return $this->index(View::make($this->getPlugin()->getView('plugin-search-list.tpl'), array('searchResult' => json_encode(array_values($plugins)))), Lang::get($this->_plugin . '.search-plugins-result-title', array('search' => htmlentities($search))));
 }