You are here

function andromeda_slideshow_build_type in Andromeda Slideshow 7.2

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

Builds a slideshow type by its name

This function prepares a type's js and css files to be attached later to the block

1 call to andromeda_slideshow_build_type()
andromeda_slideshow_block_view in ./andromeda_slideshow.module
Implements hook_block_view().

File

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

Code

function andromeda_slideshow_build_type($type) {
  $type = andromeda_slideshow_load_type($type);
  if ($type) {
    $module_path = drupal_get_path('module', $type['module']);
    $libraries = andromeda_slideshow_type_load_libraries($type);
    $scripts = array();
    $styles = array();

    //load libraries js and css files
    foreach ($libraries as $library) {
      foreach ($library['css'] as $css) {
        $styles[] = $css;
      }
      foreach ($library['js'] as $js) {
        $scripts[] = $js;
      }
    }

    //load type js and css files
    if (isset($type['js']) && sizeof($type['js'])) {
      foreach ($type['js'] as $js) {
        if (file_exists($module_path . '/' . $js)) {
          $scripts[] = $module_path . '/' . $js;
        }
      }
    }
    if (isset($type['css']) && sizeof($type['css'])) {
      foreach ($type['css'] as $css) {
        if (file_exists($module_path . '/' . $css)) {
          $styles[] = $module_path . '/' . $css;
        }
      }
    }
    $type['styles'] = $styles;
    $type['scripts'] = $scripts;
    return $type;
  }
  return FALSE;
}