steps.ajax.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Get the intro steps for the web page
  5. * @author Angel Fernando Quiroz Campos <angel.quiroz@beeznest.com>
  6. * @package chamilo.plugin.tour
  7. */
  8. require_once __DIR__.'/../../../main/inc/global.inc.php';
  9. require_once api_get_path(LIBRARY_PATH) . 'plugin.class.php';
  10. require_once api_get_path(PLUGIN_PATH) . 'tour/src/tour_plugin.class.php';
  11. if (!api_is_anonymous()) {
  12. $currentPageClass = isset($_GET['page_class']) ? $_GET['page_class'] : '';
  13. $tourPlugin = Tour::create();
  14. $json = $tourPlugin->getTourConfig();
  15. $currentPageSteps = array();
  16. foreach ($json as $pageContent) {
  17. if ($pageContent['pageClass'] == $currentPageClass) {
  18. foreach ($pageContent['steps'] as $step) {
  19. $currentPageSteps[] = array(
  20. 'element' => $step['elementSelector'],
  21. 'intro' => $tourPlugin->get_lang($step['message'])
  22. );
  23. }
  24. break;
  25. }
  26. }
  27. if (!empty($currentPageSteps)) {
  28. echo json_encode($currentPageSteps);
  29. }
  30. }