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

Last change on this file since 29521 was 29475, checked in by plg, 10 years ago

dispatch language keys in tour_* files (1 tour = 1 language file)

File size: 4.6 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  list(, $tour_name) = explode('/', $tour_to_launch);
50  load_language('tour_'.$tour_name.'.lang', PHPWG_PLUGINS_PATH .'TakeATour/', array('force_fallback'=>'en_UK'));
51
52  $template->set_filename('TAT_js_css', PHPWG_PLUGINS_PATH.'TakeATour/tpl/js_css.tpl');
53  $template->assign('ADMIN_THEME', $conf['admin_theme']);
54  $template->parse('TAT_js_css');
55
56  if (isset($TAT_restart) and $TAT_restart)
57  {
58    $TAT_restart=false;
59    $template->assign('TAT_restart',true);
60  }
61  $tat_path=str_replace(basename($_SERVER['SCRIPT_NAME']),'', $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']);
62  $template->assign('TAT_path', $tat_path);
63  $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;
64  include($tour_to_launch.'/config.inc.php');
65  $template->set_filename('TAT_tour_tpl', $TOUR_PATH);
66  $template->parse('TAT_tour_tpl');
67}
68
69/** Add link in Help pages **/
70add_event_handler('loc_end_help','TAT_help');
71function TAT_help()
72{
73  global $template;
74  load_language('plugin.lang', PHPWG_PLUGINS_PATH .'TakeATour/');
75  $template->set_prefilter('help', 'TAT_help_prefilter');
76}
77function TAT_help_prefilter($content, &$smarty)
78{
79 
80  $search = '<div id="helpContent">';
81  $replacement = '<div id="helpContent">
82<fieldset>
83<legend>{\'Visit your Piwigo!\'|@translate}</legend>
84<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>
85</fieldset>';
86  return(str_replace($search, $replacement, $content));
87
88}
89
90/** Add link in no_photo_yet **/
91add_event_handler('loc_end_no_photo_yet','TAT_no_photo_yet');
92function TAT_no_photo_yet()
93{
94  global $template;
95  load_language('plugin.lang', PHPWG_PLUGINS_PATH .'TakeATour/');
96  $template->set_prefilter('no_photo_yet', 'TAT_no_photo_yet_prefilter');
97  $template->assign(
98  array(
99    'F_ACTION' => get_root_url().'admin.php',
100    'pwg_token' => get_pwg_token()
101    )
102  );
103}
104function TAT_no_photo_yet_prefilter($content, &$smarty)
105{
106  $search = '<div class="bigButton"><a href="{$next_step_url}">{\'I want to add photos\'|@translate}</a></div>';
107  $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>
108<div class="bigButton"><a href="{$next_step_url}">{\'I want to add photos\'|@translate}</a></div>';
109  return(str_replace($search, $replacement, $content));
110}
111
112/** After a Piwigo Update **/
113add_event_handler('list_check_integrity', 'TAT_prompt'); 
114function TAT_prompt($c13y) 
115{ 
116  global $page;
117  $version_=str_replace('.','_',PHPWG_VERSION);
118  if (file_exists('tours/'.$version_.'/config.inc.php'))
119  {
120    $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>';
121  }
122}
123
124/** Add admin menu link **/
125add_event_handler('get_admin_plugin_menu_links', 'TAT_admin_menu' );
126function TAT_admin_menu($menu)
127{
128  array_push($menu, array(
129    'NAME' => 'Take a Tour',
130    'URL' => get_root_url().'admin.php?page=plugin-TakeATour'
131    )
132  );
133  return $menu;
134}
135?>
Note: See TracBrowser for help on using the repository browser.