Ejemplo n.º 1
0
 public function testEmojiPlugin()
 {
     $plugin = PluginRepository::find('emoji');
     $post = (object) ['content' => ':octocat:'];
     $params = (object) ['entry' => &$post];
     $plugin->convert($params);
     $this->assertRegExp('/<img .*?>/', $post->content);
 }
Ejemplo n.º 2
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();
 }
Ejemplo n.º 3
0
 /**
  * Fetch update information for a list of plugins. This method
  * returns for each plugin: the plugin name, current version and
  * meta data of the plugin update, if available.
  *
  * @param array  $plugins    array of plugin meta data
  */
 public function getUpdateInfo($plugins)
 {
     $default_repository = new PluginRepository();
     $plugin_manager = PluginManager::getInstance();
     $update_info = array();
     foreach ($plugins as $plugin) {
         $repository = $default_repository;
         $plugindir = get_config('PLUGINS_PATH') . '/' . $plugin['path'];
         $manifest = $plugin_manager->getPluginManifest($plugindir);
         if (isset($manifest['updateURL'])) {
             $repository = new PluginRepository($manifest['updateURL']);
         }
         $meta_data = $repository->getPlugin($manifest['pluginname']);
         if (isset($meta_data) && version_compare($meta_data['version'], $manifest['version']) > 0) {
             $manifest['update'] = $meta_data;
         }
         $update_info[$plugin['id']] = $manifest;
     }
     return $update_info;
 }
Ejemplo n.º 4
0
 public function testLoaded()
 {
     $this->assertGreaterThan(0, PostRepository::count());
     $this->assertGreaterThan(0, PageRepository::count());
     $this->assertGreaterThan(0, PluginRepository::count());
 }
Ejemplo n.º 5
0
 /**
  * @expectedException NotFoundException
  */
 public function testFindNotFound()
 {
     PluginRepository::find(99);
 }