source: extensions/TakeATour/main.inc.php @ 28060

Last change on this file since 28060 was 28060, checked in by flop25, 10 years ago

modular tour
tours can be disabled with conf

File size: 3.0 KB
Line 
1<?php
2/*
3Plugin Name: Take A Tour of Your Piwigo
4Version: 1.0
5Description: Plugin Personnel
6Plugin URI: http://piwigo.org
7Author:Piwigo Team
8Author URI:
9*/
10if (!defined('PHPWG_ROOT_PATH'))
11{
12  die('Hacking attempt!');
13}
14
15$avalaible_tour = array('first_contact', 'privacy', 'picture_protection');
16
17if ( isset($_POST['submited_tour']) and in_array($_POST['submited_tour'], $avalaible_tour) and defined('IN_ADMIN') and IN_ADMIN )
18{
19  pwg_set_session_var('tour_to_launch', $_POST['submited_tour']);
20  global $TAT_restart;
21  $TAT_restart=true;
22}
23elseif ( isset($_GET['tour_ended']) and in_array($_GET['tour_ended'], $avalaible_tour) and defined('IN_ADMIN') and IN_ADMIN )
24{
25  pwg_unset_session_var('tour_to_launch');
26}
27
28if ( pwg_get_session_var('tour_to_launch') and defined('IN_ADMIN') and IN_ADMIN  )
29{
30  global $conf;
31  if ((isset($conf['TakeATour_tour_ignored']) and !in_array(pwg_get_session_var('tour_to_launch'), $conf['TakeATour_tour_ignored'])) or !isset($conf['TakeATour_tour_ignored']))
32  {
33      add_event_handler('init', 'TAT_add_js_css');
34      include('tours/'.pwg_get_session_var('tour_to_launch').'/config.inc.php');
35  }
36}
37function TAT_add_js_css()
38{
39  global $template, $TAT_restart;
40  $tour_to_launch=pwg_get_session_var('tour_to_launch');
41  load_language('plugin.lang', PHPWG_PLUGINS_PATH .'TakeATour/');
42  $template->set_filename('TAT_js_css', PHPWG_PLUGINS_PATH.'TakeATour/tpl/js_css.tpl');
43  $template->parse('TAT_js_css');//http://piwigo.org/forum/viewtopic.php?id=23248
44  if (isset($TAT_restart) and $TAT_restart)
45  {
46    $TAT_restart=false;
47    $template->assign('TAT_restart',true);
48  }
49  $tat_path=str_replace(basename($_SERVER['SCRIPT_NAME']),'', $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']);
50  //$tat_path=$_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'];
51  $template->assign('TAT_path', $tat_path);
52  include('tours/'.$tour_to_launch.'/config_preparse.inc.php');
53  $template->set_filename('TAT_tour_tpl', PHPWG_PLUGINS_PATH.'TakeATour/tours/'.$tour_to_launch.'/tour.tpl');
54  $template->parse('TAT_tour_tpl');
55}
56
57
58/*
59add_event_handler('init', 'TAT_add_js_css');
60function TAT_add_js_css()
61{
62  $avalaible_tour = array('first_contact', 'privacy', 'picture_protection');
63
64  if ( isset($_POST['submited_tour']) and in_array($_POST['submited_tour'], $avalaible_tour) and defined('IN_ADMIN') and IN_ADMIN )
65  {
66    $tour_to_launch = $_POST['submited_tour'];
67  }
68  global $template;
69  load_language('plugin.lang', PHPWG_PLUGINS_PATH .'TakeATour/');
70  $template->set_filename('TAT_js_css', PHPWG_PLUGINS_PATH.'TakeATour/tpl/js_css.tpl');
71  $template->parse('TAT_js_css');//http://piwigo.org/forum/viewtopic.php?id=23248
72  $template->set_filename('TAT_tour_tpl', PHPWG_PLUGINS_PATH.'TakeATour/tpl/'.$tour_to_launch.'.tpl');
73  $template->parse('TAT_tour_tpl');
74}*/
75add_event_handler('get_admin_plugin_menu_links', 'TAT_admin_menu' );
76function TAT_admin_menu($menu)
77{
78  array_push($menu, array(
79    'NAME' => 'Take a Tour',
80    'URL' => get_root_url().'admin.php?page=plugin-TakeATour'
81    )
82  );
83  return $menu;
84}
85?>
Note: See TracBrowser for help on using the repository browser.