function bootstrap_tour_run_tour in Bootstrap Tour 7.2
Same name and namespace in other branches
- 7 bootstrap_tour.module \bootstrap_tour_run_tour()
Helper function to actually run a tour. Can be called from anywhere.
1 call to bootstrap_tour_run_tour()
- bootstrap_tour_page_build in ./
bootstrap_tour.module - Implementation of hook_init(). Load all the tours and figure out if any are set to auto-run and start on the current page. If so, go ahead and run that one.
File
- ./
bootstrap_tour.module, line 207 - bootstrap_tour.module
Code
function bootstrap_tour_run_tour($id, $force = FALSE) {
$tour = bootstrap_tour_load($id);
if (!bootstrap_tour_access($tour) || empty($tour->steps)) {
bootstrap_tour_cleanup();
return;
}
if ($tour->autorun && !empty($tour->start_path)) {
$tour->steps[0]->path = $tour->start_path;
}
$first_path = $tour->steps[0]->path;
if (empty($first_path)) {
bootstrap_tour_cleanup();
return;
}
if (count($tour->steps) > 1) {
// Set this as the current tour in the session.
$_SESSION['tour'] = $tour->name;
}
if ($first_path == current_path() || $first_path == request_path() || $first_path == '<front>' && request_path() == '') {
if (empty($_GET['step']) || $_GET['step'] == 0) {
// We're starting the tour over.
if (isset($_SESSION['nexttour'])) {
unset($_SESSION['nexttour']);
}
}
}
drupal_alter('bootstrap_tour', $tour);
$step_path = '';
foreach ($tour->steps as $key => &$step) {
// If a path isn't specified, then use the path from the previous step.
if ($step->path) {
$step_path = $step->path;
}
else {
$step->path = $step_path;
}
// Determine we are on the first step of the tour.
if ($key == 0 && ($step->path == current_path() || $step->path == request_path() || $step->path == '<front>' && request_path() == '')) {
if (!empty($_GET['tour']) && (empty($_GET['step']) || $_GET['step'] == 0)) {
$tour->isFirstStep = TRUE;
}
}
// Filter user supplied content.
$step->title = check_plain($step->title);
$step->content = check_markup($step->content, $step->content_text_format);
}
$tour->force = $force;
$tour->cleanUrls = variable_get('clean_url', 0);
drupal_add_js(array(
'bootstrapTour' => array(
'tour' => $tour,
),
), 'setting');
if (module_exists('libraries') && ($library = libraries_detect('bootstrap_tour')) && !empty($library['installed'])) {
libraries_load('bootstrap_tour');
}
else {
// Grab the Bootstrap Tour JS from CDNJS if the library isn't installed.
bootstrap_tour_load_file('css', 'bootstrap-tour.min.css', 'cdnjs.cloudflare.com/ajax/libs/bootstrap-tour/0.6.1/css/bootstrap-tour.min.css');
bootstrap_tour_load_file('js', 'bootstrap-tour.js', 'cdnjs.cloudflare.com/ajax/libs/bootstrap-tour/0.6.1/js/bootstrap-tour.js');
}
drupal_add_js(drupal_get_path('module', 'bootstrap_tour') . '/js/bootstrap-tour.js');
drupal_add_css(drupal_get_path('module', 'bootstrap_tour') . '/css/bootstrap-tour.css');
}