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

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

[take a tour]
empty language value with a space
tour 2.7 : search page, select js
tour privacy : wip

File size: 4.4 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 **/
29/*
30 * REMOVE FOR RELEASE
31$version_=str_replace('.','_',PHPWG_VERSION);
32if (pwg_get_session_var('tour_to_launch')!=$version_ and isset($_GET['page']) and $_GET['page']=="plugin-TakeATour")
33{
34  pwg_unset_session_var('tour_to_launch');
35}
36else*/if ( pwg_get_session_var('tour_to_launch') )
37{
38  add_event_handler('init', 'TAT_tour_setup');
39  include('tours/'.pwg_get_session_var('tour_to_launch').'/config.inc.php');
40}
41
42function TAT_tour_setup()
43{
44  global $template, $TAT_restart;
45  $tour_to_launch=pwg_get_session_var('tour_to_launch');
46  load_language('plugin.lang', PHPWG_PLUGINS_PATH .'TakeATour/');
47  load_language('lang', PHPWG_ROOT_PATH.PWG_LOCAL_DIR, array('no_fallback'=>true, 'local'=>true) );
48  $template->set_filename('TAT_js_css', PHPWG_PLUGINS_PATH.'TakeATour/tpl/js_css.tpl');
49  $template->parse('TAT_js_css');//http://piwigo.org/forum/viewtopic.php?id=23248
50  if (isset($TAT_restart) and $TAT_restart)
51  {
52    $TAT_restart=false;
53    $template->assign('TAT_restart',true);
54  }
55  $tat_path=str_replace(basename($_SERVER['SCRIPT_NAME']),'', $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']);
56  $template->assign('TAT_path', $tat_path);
57  @include('tours/'.$tour_to_launch.'/config_preparse.inc.php');
58  $template->set_filename('TAT_tour_tpl', PHPWG_PLUGINS_PATH.'TakeATour/tours/'.$tour_to_launch.'/tour.tpl');
59  $template->parse('TAT_tour_tpl');
60}
61
62/** Add link in Help pages **/
63add_event_handler('loc_end_help','TAT_help');
64function TAT_help()
65{
66  global $template;
67  load_language('plugin.lang', PHPWG_PLUGINS_PATH .'TakeATour/');
68  $template->set_prefilter('help', 'TAT_help_prefilter');
69}
70function TAT_help_prefilter($content, &$smarty)
71{
72 
73  $search = '<div id="helpContent">';
74  $replacement = '<div id="helpContent">
75<fieldset>
76<legend>{\'Visit your Piwigo!\'|@translate}</legend>
77<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>
78</fieldset>';
79  return(str_replace($search, $replacement, $content));
80
81}
82
83/** Add link in no_photo_yet **/
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  $search = '<div class="bigButton"><a href="{$next_step_url}">{\'I want to add photos\'|@translate}</a></div>';
100  $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>
101<div class="bigButton"><a href="{$next_step_url}">{\'I want to add photos\'|@translate}</a></div>';
102  return(str_replace($search, $replacement, $content));
103}
104
105/** After a Piwigo Update **/
106add_event_handler('list_check_integrity', 'TAT_prompt'); 
107function TAT_prompt($c13y) 
108{ 
109  global $page;
110  $version_=str_replace('.','_',PHPWG_VERSION);
111  if (file_exists('tours/'.$version_.'/config.inc.php'))
112  {
113    $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>';
114  }
115}
116
117/** Add admin menu link **/
118add_event_handler('get_admin_plugin_menu_links', 'TAT_admin_menu' );
119function TAT_admin_menu($menu)
120{
121  array_push($menu, array(
122    'NAME' => 'Take a Tour',
123    'URL' => get_root_url().'admin.php?page=plugin-TakeATour'
124    )
125  );
126  return $menu;
127}
128?>
Note: See TracBrowser for help on using the repository browser.