1 | <?php |
---|
2 | /* |
---|
3 | Plugin Name: Take A Tour of Your Piwigo |
---|
4 | Version: 1.0 |
---|
5 | Description: Plugin Personnel |
---|
6 | Plugin URI: http://piwigo.org |
---|
7 | Author:Piwigo Team |
---|
8 | Author URI: |
---|
9 | */ |
---|
10 | if (!defined('PHPWG_ROOT_PATH')) |
---|
11 | { |
---|
12 | die('Hacking attempt!'); |
---|
13 | } |
---|
14 | |
---|
15 | $avalaible_tour = array('first_contact', 'privacy', 'picture_protection'); |
---|
16 | |
---|
17 | if ( isset($_POST['submited_tour']) and in_array($_POST['submited_tour'], $avalaible_tour) and defined('IN_ADMIN') and IN_ADMIN ) |
---|
18 | { |
---|
19 | check_pwg_token(); |
---|
20 | pwg_set_session_var('tour_to_launch', $_POST['submited_tour']); |
---|
21 | global $TAT_restart; |
---|
22 | $TAT_restart=true; |
---|
23 | } |
---|
24 | elseif ( isset($_GET['tour_ended']) and in_array($_GET['tour_ended'], $avalaible_tour) and defined('IN_ADMIN') and IN_ADMIN ) |
---|
25 | { |
---|
26 | pwg_unset_session_var('tour_to_launch'); |
---|
27 | } |
---|
28 | |
---|
29 | if (pwg_get_session_var('tour_to_launch') and defined('IN_ADMIN') and IN_ADMIN and isset($_GET['page']) and $_GET['page']=="plugin-TakeATour" ) |
---|
30 | { |
---|
31 | pwg_unset_session_var('tour_to_launch'); |
---|
32 | } |
---|
33 | elseif ( pwg_get_session_var('tour_to_launch') and defined('IN_ADMIN') and IN_ADMIN) |
---|
34 | { |
---|
35 | add_event_handler('init', 'TAT_add_js_css'); |
---|
36 | include('tours/'.pwg_get_session_var('tour_to_launch').'/config.inc.php'); |
---|
37 | } |
---|
38 | |
---|
39 | function TAT_add_js_css() |
---|
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 | |
---|
60 | add_event_handler('loc_end_help','TAT_help'); |
---|
61 | function TAT_help() |
---|
62 | { |
---|
63 | global $template; |
---|
64 | load_language('plugin.lang', PHPWG_PLUGINS_PATH .'TakeATour/'); |
---|
65 | $template->set_prefilter('help', 'TAT_help_prefilter'); |
---|
66 | } |
---|
67 | function 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 | add_event_handler('loc_end_no_photo_yet','TAT_no_photo_yet'); |
---|
80 | function TAT_no_photo_yet() |
---|
81 | { |
---|
82 | global $template; |
---|
83 | load_language('plugin.lang', PHPWG_PLUGINS_PATH .'TakeATour/'); |
---|
84 | $template->set_prefilter('no_photo_yet', 'TAT_no_photo_yet_prefilter'); |
---|
85 | $template->assign( |
---|
86 | array( |
---|
87 | 'F_ACTION' => get_root_url().'admin.php', |
---|
88 | 'pwg_token' => get_pwg_token() |
---|
89 | ) |
---|
90 | ); |
---|
91 | } |
---|
92 | function TAT_no_photo_yet_prefilter($content, &$smarty) |
---|
93 | { |
---|
94 | |
---|
95 | $search = '<div class="bigButton"><a href="{$next_step_url}">{\'I want to add photos\'|@translate}</a></div>'; |
---|
96 | $replacement = '<form style="text-align:center" action="{$F_ACTION}" method="post"> |
---|
97 | <input type="hidden" name="submited_tour" value="first_contact"> |
---|
98 | <input type="hidden" name="pwg_token" value="{$pwg_token}"> |
---|
99 | <input type="submit" name="button2" id="button2" value="{\'I want to discover my gallery and add photos\'|@translate}"> |
---|
100 | </form> |
---|
101 | <div class="bigButton"><a href="{$next_step_url}">{\'I want to add photos\'|@translate}</a></div>'; |
---|
102 | $content=str_replace($search, $replacement, $content); |
---|
103 | $search = '</style>'; |
---|
104 | $replacement = ' |
---|
105 | form input[type="submit"] { |
---|
106 | font-size: 25px; |
---|
107 | letter-spacing: 2px; |
---|
108 | margin: 0 5px; |
---|
109 | padding: 20px; |
---|
110 | border:none; |
---|
111 | background-color:#666666; |
---|
112 | color:#fff; |
---|
113 | cursor:pointer; |
---|
114 | } |
---|
115 | form input[type="submit"]:hover { |
---|
116 | background-color:#ff7700; |
---|
117 | color:white; |
---|
118 | } |
---|
119 | </style>'; |
---|
120 | return(str_replace($search, $replacement, $content)); |
---|
121 | } |
---|
122 | |
---|
123 | add_event_handler('get_admin_plugin_menu_links', 'TAT_admin_menu' ); |
---|
124 | function TAT_admin_menu($menu) |
---|
125 | { |
---|
126 | array_push($menu, array( |
---|
127 | 'NAME' => 'Take a Tour', |
---|
128 | 'URL' => get_root_url().'admin.php?page=plugin-TakeATour' |
---|
129 | ) |
---|
130 | ); |
---|
131 | return $menu; |
---|
132 | } |
---|
133 | ?> |
---|