You are here

function galleria_get_plugins in Galleria 7

Searches for available plugins inside the Galleria folder. The list of plugins is cached for performance reasons.

3 calls to galleria_get_plugins()
galleria_form_optionset_edit in includes/galleria.admin.inc
Form builder; Form to edit a given option set.
galleria_form_settings in includes/galleria.admin.inc
Form builder; Form for advanced module settings.
galleria_get_plugin_file in ./galleria.module
Returns the JavaScript file of the given plugin, or FALSE if it could not be found.

File

./galleria.module, line 291
A light-weight, customizable image gallery plugin for Drupal based on jQuery

Code

function galleria_get_plugins($nocache = FALSE) {
  if (!$nocache && ($plugins = cache_get('galleria_plugins')) !== FALSE) {
    return $plugins->data;
  }
  $plugins = array();

  // Search for theme folders
  $path = libraries_get_path('galleria') . '/plugins/';
  if (is_dir($path) && ($path_handle = opendir($path)) !== FALSE) {
    while (($plugin = readdir($path_handle)) !== FALSE) {
      if (!is_dir($path . $plugin) || $plugin[0] == '.') {
        continue;
      }

      // Search for the theme JavaScript file, minified version first
      $js = glob($path . $plugin . '/*.min.js');
      if ($js === FALSE || count($js) == 0) {
        $js = glob($path . $plugin . '/*.js');
      }

      // Sort by filename to (hopefully) get the newest version.
      if (count($js) > 0) {
        rsort($js);
        $plugins[$plugin] = $js[0];
      }
    }
    closedir($path_handle);
    cache_set('galleria_plugins', $plugins);
  }
  return $plugins;
}