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

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

Take A Tour:
-only 2 files per tour.tpl
-allow external tours
-absolute url when ending the tour
-better code, commented
wiki updated (2.7 technical changes)

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