You are here

function galleria_get_themes in Galleria 7

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

3 calls to galleria_get_themes()
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_theme_file in ./galleria.module
Returns the JavaScript file of the given theme, or FALSE if it could not be found.

File

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

Code

function galleria_get_themes($nocache = FALSE) {
  if (!$nocache && ($themes = cache_get('galleria_themes')) !== FALSE) {
    return $themes->data;
  }
  $themes = array();

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

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

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