/** * get visible tours for helpbar * * @return array set of tours */ public static function GetHelpbarTourData() { $visible_tours = array(); $route = get_route(); $tours = HelpTour::getToursByRoute($route); foreach ($tours as $index => $tour) { if ($tour->isVisible() and $tour->settings->access != 'link') { $visible_tours[$index] = $tour; if (($tour->settings->access == 'autostart' or $tour->settings->access == 'autostart_once') and !$GLOBALS['user']->cfg->TOUR_AUTOSTART_DISABLE) { $user_visit = new HelpTourUser(array($tour->tour_id, $GLOBALS['user']->user_id)); if ($tour->settings->access == 'autostart_once' and $user_visit->isNew()) { $active_tour_id = $tour->tour_id; $active_tour_step_nr = 1; } elseif ($tour->settings->access == 'autostart' and !$user_visit->completed) { $active_tour_id = $tour->tour_id; $active_tour_step_nr = 1; } } } } //if there is an active tour, initialize it if ($_SESSION['active_tour']['tour_id'] and ($_SESSION['active_tour']['last_route'] == $route or $_SESSION['active_tour']['next_route'] == $route)) { $active_tour = new HelpTour($_SESSION['active_tour']['tour_id']); $step_nr = $_SESSION['active_tour']['step_nr']; if (!($_SESSION['active_tour']['last_route'] == $route) and $_SESSION['active_tour']['next_route'] == $route) { while ($_SESSION['active_tour']['last_route'] == $active_tour->steps[$step_nr - 1]->route) { $step_nr++; } } if ($route == $active_tour->steps[$step_nr - 1]->route) { $_SESSION['active_tour']['step_nr'] = $step_nr; $active_tour_id = $_SESSION['active_tour']['tour_id']; $active_tour_step_nr = $step_nr; } } return array('tours' => $visible_tours, 'active_tour_id' => $active_tour_id, 'active_tour_step_nr' => $active_tour_step_nr); }
public function __construct() { $this->tour_data = HelpTour::getHelpbarTourData(); foreach ($this->tour_data['tours'] as $index => $tour) { $element = new LinkElement($tour->name, URLHelper::getURL('?tour_id=' . $tour->tour_id)); $visit_state = HelpTourUser::find(array($tour->tour_id, $GLOBALS['user']->id)); if ($visit_state === null) { $element->addClass('tour-new'); } elseif (!$visit_state->completed) { $element->addClass('tour-paused'); } else { $element->addClass('tour-completed'); } $element->addClass('tour_link'); $element['id'] = $tour->tour_id; $this->addElement($element); } }