You are here

function andromeda_slideshow_type_load_libraries in Andromeda Slideshow 7.2

Same name and namespace in other branches
  1. 7 andromeda_slideshow.module \andromeda_slideshow_type_load_libraries()

Loads libraries for a slideshow type

1 call to andromeda_slideshow_type_load_libraries()
andromeda_slideshow_build_type in ./andromeda_slideshow.module
Builds a slideshow type by its name

File

./andromeda_slideshow.module, line 651
Slideshow for the Andromeda (http://drupal.org/project/andromeda) Theme

Code

function andromeda_slideshow_type_load_libraries($type) {
  $libraries = array();
  if (isset($type['libraries']) && sizeof($type['libraries'])) {
    $libraries = $type['libraries'];
    $missing = FALSE;
    foreach ($libraries as $name => $library) {
      $path = libraries_get_path($name);
      if ($path) {
        if (isset($library['css']) && sizeof($library['css'])) {

          //check and add library path to css files
          foreach ($library['css'] as $i => $css) {
            if (file_exists($path . '/' . $css)) {
              $library['css'][$i] = $path . '/' . $css;
            }
            else {
              $missing = TRUE;
            }
          }
        }
        if (isset($library['js']) && sizeof($library['js'])) {

          //add library path to js files
          foreach ($library['js'] as $j => $js) {
            if (file_exists($path . '/' . $js)) {
              $library['js'][$j] = $path . '/' . $js;
            }
            else {
              $missing = TRUE;
            }
          }
        }
      }
      if (!$missing) {
        $libraries[$name] = $library;
      }
      else {
        drupal_set_message(t('The @name library is missing. Please download it and place it under sites/all/libraries.', array(
          '@name' => $name,
        )), 'error');
      }
    }
  }
  return $libraries;
}