* @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; use Joomla\CMS\Language\Text; use Joomla\CMS\Uri\Uri; $hideLinks = $app->getInput()->getBool('hidemainmenu'); if ($hideLinks || !$tours) { return; } // Load the Bootstrap Dropdown $app->getDocument() ->getWebAssetManager() ->useScript('bootstrap.dropdown') ->useScript('joomla.dialog-autocreate'); $lang = $app->getLanguage(); $extension = $app->getInput()->get('option'); $contextTours = []; $starTours = []; $listTours = []; $allTours = []; $contextCount = $params->get('contextcount', 7); $toursCount = $params->get('tourscount', 7); foreach ($tours as $tour) : $uri = new Uri($tour->url); if (in_array('*', $tour->extensions)) : $starTours[] = $tour; elseif (in_array($extension, $tour->extensions)) : if ($extension === 'com_categories') : // Special case for the categories page, where the context is complemented with the extension the categories apply to if ($uri->getVar('option', '') === 'com_categories') : if ($uri->getVar('extension', '') === $app->getInput()->get('extension', '')) : if ($contextCount > 0) : $contextTours[] = $tour; $contextCount--; endif; elseif ($toursCount > 0) : $listTours[] = $tour; $toursCount--; endif; else : if (in_array($app->getInput()->get('extension', ''), $tour->extensions)) : if ($contextCount > 0) : $contextTours[] = $tour; $contextCount--; endif; elseif ($toursCount > 0) : $listTours[] = $tour; $toursCount--; endif; endif; elseif ($contextCount > 0) : $contextTours[] = $tour; $contextCount--; endif; elseif ($toursCount > 0) : $listTours[] = $tour; $toursCount--; endif; // We assume the url is the starting point $key = $uri->getVar('option') ?? 'com_cpanel'; if (!isset($allTours[$key])) : $lang->load("$key.sys", JPATH_ADMINISTRATOR) || $lang->load("$key.sys", JPATH_ADMINISTRATOR . '/components/' . $key); $allTours[$key] = []; endif; $allTours[$key][] = $tour; endforeach; if ($contextCount > 0) : // The '*' tours have lower priority than contextual tours and are added after them, room permitting $contextTours = array_slice(array_merge($contextTours, $starTours), 0, $params->get('contextcount', 7)); endif; $popupId = 'guidedtours-popup-content' . $module->id; $popupOptions = json_encode([ 'src' => '#' . $popupId, 'width' => '800px', 'height' => 'fit-content', 'textHeader' => Text::_('MOD_GUIDEDTOURS_START_TOUR'), 'preferredParent' => 'body', ]); ?> '; $modalHtml[] = '
'; foreach ($allTours as $extension => $tours) : $modalHtml[] = '
'; $modalHtml[] = '

' . Text::_($extension) . '

'; $modalHtml[] = ''; $modalHtml[] = '
'; endforeach; $modalHtml[] = '
'; $modalHtml[] = ''; $modalBody = implode($modalHtml); ?>