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

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

add pwg_token
add text on top of the help pages and a button for no_photo_yet
etc

File size: 4.3 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  check_pwg_token();
20  pwg_set_session_var('tour_to_launch', $_POST['submited_tour']);
21  global $TAT_restart;
22  $TAT_restart=true;
23}
24elseif ( isset($_GET['tour_ended']) and in_array($_GET['tour_ended'], $avalaible_tour) and defined('IN_ADMIN') and IN_ADMIN )
25{
26  pwg_unset_session_var('tour_to_launch');
27}
28
29if (pwg_get_session_var('tour_to_launch') and defined('IN_ADMIN') and IN_ADMIN and isset($_GET['page']) and $_GET['page']=="plugin-TakeATour" )
30{ 
31  pwg_unset_session_var('tour_to_launch');
32}
33elseif ( pwg_get_session_var('tour_to_launch') and defined('IN_ADMIN') and IN_ADMIN)
34{
35  global $conf;
36  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']))
37  {
38      add_event_handler('init', 'TAT_add_js_css');
39      include('tours/'.pwg_get_session_var('tour_to_launch').'/config.inc.php');
40  }
41}
42
43function TAT_add_js_css()
44{
45  global $template, $TAT_restart;
46  $tour_to_launch=pwg_get_session_var('tour_to_launch');
47  load_language('plugin.lang', PHPWG_PLUGINS_PATH .'TakeATour/');
48  load_language('lang', PHPWG_ROOT_PATH.PWG_LOCAL_DIR, array('no_fallback'=>true, 'local'=>true) );
49  $template->set_filename('TAT_js_css', PHPWG_PLUGINS_PATH.'TakeATour/tpl/js_css.tpl');
50  $template->parse('TAT_js_css');//http://piwigo.org/forum/viewtopic.php?id=23248
51  if (isset($TAT_restart) and $TAT_restart)
52  {
53    $TAT_restart=false;
54    $template->assign('TAT_restart',true);
55  }
56  $tat_path=str_replace(basename($_SERVER['SCRIPT_NAME']),'', $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']);
57  //$tat_path=$_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'];
58  $template->assign('TAT_path', $tat_path);
59  include('tours/'.$tour_to_launch.'/config_preparse.inc.php');
60  $template->set_filename('TAT_tour_tpl', PHPWG_PLUGINS_PATH.'TakeATour/tours/'.$tour_to_launch.'/tour.tpl');
61  $template->parse('TAT_tour_tpl');
62}
63
64
65add_event_handler('loc_end_help','TAT_help');
66function TAT_help()
67{
68  global $template;
69  load_language('plugin.lang', PHPWG_PLUGINS_PATH .'TakeATour/');
70  $template->set_prefilter('help', 'TAT_help_prefilter');
71}
72function TAT_help_prefilter($content, &$smarty)
73{
74 
75  $search = '<div id="helpContent">';
76  $replacement = '<div id="helpContent">
77<fieldset>
78<legend>{\'Visit your Piwigo!\'|@translate}</legend>
79<p class="nextStepLink"><a href="admin.php?page=plugin-TakeATour">{\'Take a tour and discover the features of your Piwigo gallery » Go to the available tours\'|@translate}</a></p>
80</fieldset>';
81  return(str_replace($search, $replacement, $content));
82
83}
84add_event_handler('loc_end_no_photo_yet','TAT_no_photo_yet');
85function TAT_no_photo_yet()
86{
87  global $template;
88  load_language('plugin.lang', PHPWG_PLUGINS_PATH .'TakeATour/');
89  $template->set_prefilter('no_photo_yet', 'TAT_no_photo_yet_prefilter');
90  $template->assign(
91  array(
92    'F_ACTION' => get_root_url().'admin.php',
93    'pwg_token' => get_pwg_token()
94    )
95  );
96}
97function TAT_no_photo_yet_prefilter($content, &$smarty)
98{
99 
100  $search = '<div class="bigButton"><a href="{$next_step_url}">{\'I want to add photos\'|@translate}</a></div>';
101  $replacement = '<form class="bigButton" action="{$F_ACTION}" method="post">
102  <input type="hidden" name="submited_tour" value="first_contact">
103  <input type="hidden" name="pwg_token" value="{$pwg_token}">
104  <input type="submit" name="button2" id="button2" value="{\'I want to discover my gallery and add photos\'|@translate}">
105</form>
106<div class="bigButton"><a href="{$next_step_url}">{\'I want to add photos\'|@translate}</a></div>';
107  return(str_replace($search, $replacement, $content));
108}
109
110add_event_handler('get_admin_plugin_menu_links', 'TAT_admin_menu' );
111function TAT_admin_menu($menu)
112{
113  array_push($menu, array(
114    'NAME' => 'Take a Tour',
115    'URL' => get_root_url().'admin.php?page=plugin-TakeATour'
116    )
117  );
118  return $menu;
119}
120?>
Note: See TracBrowser for help on using the repository browser.