source: extensions/takeatour/main.inc.php @ 27898

Last change on this file since 27898 was 27898, checked in by flop25, 6 years ago

first upload
working WIP
one tour available

File size: 5.0 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$avalaible_tour = array('first_contact', 'privacy', 'picture_protection');
16
17if ( isset($_POST['submited_tour']) and in_array($_POST['submited_tour'], $avalaible_tour) and defined('IN_ADMIN') and IN_ADMIN )
18{
19  pwg_set_session_var('tour_to_launch', $_POST['submited_tour']);
20  global $TAT_restart;
21  $TAT_restart=true;
22}
23elseif ( isset($_GET['tour_ended']) and in_array($_GET['tour_ended'], $avalaible_tour) and defined('IN_ADMIN') and IN_ADMIN )
24{
25  pwg_unset_session_var('tour_to_launch');
26}
27
28if ( pwg_get_session_var('tour_to_launch') and defined('IN_ADMIN') and IN_ADMIN )
29{
30  add_event_handler('init', 'TAT_add_js_css');
31}
32function TAT_add_js_css()
33{
34  global $template, $TAT_restart;
35  $tour_to_launch=pwg_get_session_var('tour_to_launch');
36  load_language('plugin.lang', PHPWG_PLUGINS_PATH .'TakeATour/');
37  $template->set_filename('TAT_js_css', PHPWG_PLUGINS_PATH.'TakeATour/tpl/js_css.tpl');
38  $template->parse('TAT_js_css');//http://piwigo.org/forum/viewtopic.php?id=23248
39  if (isset($TAT_restart) and $TAT_restart)
40  {
41    $TAT_restart=false;
42    $template->assign('TAT_restart',true);
43  }
44  $tat_path=str_replace(basename($_SERVER['SCRIPT_NAME']),'', $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']);
45  //$tat_path=$_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'];
46  $template->assign('TAT_path', $tat_path);
47  $template->set_filename('TAT_tour_tpl', PHPWG_PLUGINS_PATH.'TakeATour/tpl/'.$tour_to_launch.'.tpl');
48  $template->parse('TAT_tour_tpl');
49  unset($tour_to_launch);
50}
51
52if ( defined('IN_ADMIN') and IN_ADMIN )
53{
54/* first contact */
55add_event_handler('loc_end_element_set_global', 'TAT_FC_14');
56add_event_handler('loc_end_picture_modify', 'TAT_FC_16');
57add_event_handler('loc_end_picture_modify', 'TAT_FC_17');
58add_event_handler('loc_end_cat_modify', 'TAT_FC_23');
59add_event_handler('loc_end_themes_installed', 'TAT_FC_35');
60}
61
62function TAT_FC_14() {
63  global $template;
64  $template->set_prefilter('batch_manager_global', 'TAT_FC_14_prefilter');
65}
66function TAT_FC_14_prefilter ($content, &$smarty) {
67  $search = '<span class="wrap2';
68  $replacement = '{counter print=false assign=TAT_FC_14}<span {if $TAT_FC_14==1}id="TAT_FC_14"{/if} class="wrap2';
69  return str_replace($search, $replacement, $content);
70}
71function TAT_FC_16() {
72  global $template;
73  $template->set_prefilter('picture_modify', 'TAT_FC_16_prefilter');
74}
75function TAT_FC_16_prefilter ($content, &$smarty) {
76  $search = '<strong>{\'Linked albums\'|@translate}</strong>';
77  $replacement = '<span id="TAT_FC_16"><strong>{\'Linked albums\'|@translate}</strong></span>';
78  return str_replace($search, $replacement, $content);
79}
80function TAT_FC_17() {
81  global $template;
82  $template->set_prefilter('picture_modify', 'TAT_FC_17_prefilter');
83}
84function TAT_FC_17_prefilter ($content, &$smarty) {
85  $search = '<strong>{\'Representation of albums\'|@translate}</strong>';
86  $replacement = '<span id="TAT_FC_17"><strong>{\'Representation of albums\'|@translate}</strong></span>';
87  return str_replace($search, $replacement, $content);
88}
89function TAT_FC_23() {
90  global $template;
91  $template->set_prefilter('album_properties', 'TAT_FC_23_prefilter');
92}
93function TAT_FC_23_prefilter ($content, &$smarty) {
94  $search = '<strong>{\'Lock\'|@translate}</strong>';
95  $replacement = '<span id="TAT_FC_23"><strong>{\'Lock\'|@translate}</strong></span>';
96  return str_replace($search, $replacement, $content);
97}
98function TAT_FC_35() {
99  global $template;
100  $template->set_prefilter('themes', 'TAT_FC_35_prefilter');
101}
102function TAT_FC_35_prefilter ($content, &$smarty) {
103  $search = '<a href="{$set_default_baseurl}{$theme.ID}" class="tiptip"';
104  $replacement = '{counter print=false assign=TAT_FC_35}<a href="{$set_default_baseurl}{$theme.ID}" class="tiptip" {if $TAT_FC_35==1}id="TAT_FC_35"{/if}';
105  return str_replace($search, $replacement, $content);
106}
107
108/*
109add_event_handler('init', 'TAT_add_js_css');
110function TAT_add_js_css()
111{
112  $avalaible_tour = array('first_contact', 'privacy', 'picture_protection');
113
114  if ( isset($_POST['submited_tour']) and in_array($_POST['submited_tour'], $avalaible_tour) and defined('IN_ADMIN') and IN_ADMIN )
115  {
116    $tour_to_launch = $_POST['submited_tour'];
117  }
118  global $template;
119  load_language('plugin.lang', PHPWG_PLUGINS_PATH .'TakeATour/');
120  $template->set_filename('TAT_js_css', PHPWG_PLUGINS_PATH.'TakeATour/tpl/js_css.tpl');
121  $template->parse('TAT_js_css');//http://piwigo.org/forum/viewtopic.php?id=23248
122  $template->set_filename('TAT_tour_tpl', PHPWG_PLUGINS_PATH.'TakeATour/tpl/'.$tour_to_launch.'.tpl');
123  $template->parse('TAT_tour_tpl');
124}*/
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.