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

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

escape language value for js

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