You are here

function bootstrap_tour_load_file in Bootstrap Tour 7.2

Helper function to load a file from local disk or from remote url

Parameters

$type:

$filename:

$uri:

1 call to bootstrap_tour_load_file()
bootstrap_tour_run_tour in ./bootstrap_tour.module
Helper function to actually run a tour. Can be called from anywhere.

File

./bootstrap_tour.module, line 182
bootstrap_tour.module

Code

function bootstrap_tour_load_file($type, $filename, $uri) {
  $file = 'public://' . $filename;
  $realfile = drupal_realpath($file);
  $options = NULL;
  if (!file_exists($realfile)) {
    global $base_url;
    $base = parse_url($base_url);
    $url = $base['scheme'] . '://' . $uri;
    if (system_retrieve_file($url, $file, FALSE, FILE_EXISTS_REPLACE) === FALSE) {

      // If we can't cache the file locally, use the remote CDN link
      $file = $url;
      $options = 'external';
    }
  }
  if ($type == 'js') {
    drupal_add_js($file, $options);
  }
  else {
    drupal_add_css($file, $options);
  }
}