source: trunk/plugins/TakeATour/main.inc.php @ 28208

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

use GET to start a tour also

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/** Tour sended via $_POST or $_GET**/
16if ( isset($_REQUEST['submited_tour']) and defined('IN_ADMIN') and IN_ADMIN )
17{
18  check_pwg_token();
19  pwg_set_session_var('tour_to_launch', $_REQUEST['submited_tour']);
20  global $TAT_restart;
21  $TAT_restart=true;
22}
23elseif ( isset($_GET['tour_ended']) and defined('IN_ADMIN') and IN_ADMIN )
24{
25  pwg_unset_session_var('tour_to_launch');
26}
27
28/** Setup the tour **/
29if (pwg_get_session_var('tour_to_launch') 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') )
34{
35  add_event_handler('init', 'TAT_tour_setup');
36  include('tours/'.pwg_get_session_var('tour_to_launch').'/config.inc.php');
37}
38
39function TAT_tour_setup()
40{
41  global $template, $TAT_restart;
42  $tour_to_launch=pwg_get_session_var('tour_to_launch');
43  load_language('plugin.lang', PHPWG_PLUGINS_PATH .'TakeATour/');
44  load_language('lang', PHPWG_ROOT_PATH.PWG_LOCAL_DIR, array('no_fallback'=>true, 'local'=>true) );
45  $template->set_filename('TAT_js_css', PHPWG_PLUGINS_PATH.'TakeATour/tpl/js_css.tpl');
46  $template->parse('TAT_js_css');//http://piwigo.org/forum/viewtopic.php?id=23248
47  if (isset($TAT_restart) and $TAT_restart)
48  {
49    $TAT_restart=false;
50    $template->assign('TAT_restart',true);
51  }
52  $tat_path=str_replace(basename($_SERVER['SCRIPT_NAME']),'', $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']);
53  $template->assign('TAT_path', $tat_path);
54  @include('tours/'.$tour_to_launch.'/config_preparse.inc.php');
55  $template->set_filename('TAT_tour_tpl', PHPWG_PLUGINS_PATH.'TakeATour/tours/'.$tour_to_launch.'/tour.tpl');
56  $template->parse('TAT_tour_tpl');
57}
58
59/** Add link in Help pages **/
60add_event_handler('loc_end_help','TAT_help');
61function TAT_help()
62{
63  global $template;
64  load_language('plugin.lang', PHPWG_PLUGINS_PATH .'TakeATour/');
65  $template->set_prefilter('help', 'TAT_help_prefilter');
66}
67function TAT_help_prefilter($content, &$smarty)
68{
69 
70  $search = '<div id="helpContent">';
71  $replacement = '<div id="helpContent">
72<fieldset>
73<legend>{\'Visit your Piwigo!\'|@translate}</legend>
74<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>
75</fieldset>';
76  return(str_replace($search, $replacement, $content));
77
78}
79
80/** Add link in no_photo_yet **/
81add_event_handler('loc_end_no_photo_yet','TAT_no_photo_yet');
82function TAT_no_photo_yet()
83{
84  global $template;
85  load_language('plugin.lang', PHPWG_PLUGINS_PATH .'TakeATour/');
86  $template->set_prefilter('no_photo_yet', 'TAT_no_photo_yet_prefilter');
87  $template->assign(
88  array(
89    'F_ACTION' => get_root_url().'admin.php',
90    'pwg_token' => get_pwg_token()
91    )
92  );
93}
94function TAT_no_photo_yet_prefilter($content, &$smarty)
95{
96  $search = '<div class="bigButton"><a href="{$next_step_url}">{\'I want to add photos\'|@translate}</a></div>';
97  $replacement = '<div class="bigButton"><a href="'.get_root_url().'admin.php?submited_tour=first_contact&pwg_token='.get_pwg_token().'">{\'I want to discover my gallery and add photos\'|@translate}</a></div>
98<div class="bigButton"><a href="{$next_step_url}">{\'I want to add photos\'|@translate}</a></div>';
99  return(str_replace($search, $replacement, $content));
100}
101
102/** After a Piwigo Update **/
103add_event_handler('list_check_integrity', 'TAT_prompt'); 
104function TAT_prompt($c13y) 
105{ 
106  global $page;
107  $version_=str_replace('.','_',PHPWG_VERSION);
108  if (file_exists('tours/'.$version_.'/config.inc.php'))
109  {
110    $page['infos'][] = '<a href="'.get_root_url().'admin.php?submited_tour='.$version_.'&pwg_token='.get_pwg_token().'">'.l10n('Discover what is new in the version %s of Piwigo', PHPWG_VERSION).'</a>';
111  }
112}
113
114/** Add admin menu link **/
115add_event_handler('get_admin_plugin_menu_links', 'TAT_admin_menu' );
116function TAT_admin_menu($menu)
117{
118  array_push($menu, array(
119    'NAME' => 'Take a Tour',
120    'URL' => get_root_url().'admin.php?page=plugin-TakeATour'
121    )
122  );
123  return $menu;
124}
125?>
Note: See TracBrowser for help on using the repository browser.