1 | <?php |
---|
2 | /* |
---|
3 | Plugin Name: GuestBook |
---|
4 | Version: auto |
---|
5 | Description: Add a guestbook to the gallery |
---|
6 | Plugin URI: http://piwigo.org/ext/extension_view.php?eid=609 |
---|
7 | Author: Mistic |
---|
8 | Author URI: http://www.strangeplanet.fr |
---|
9 | */ |
---|
10 | |
---|
11 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
12 | |
---|
13 | global $prefixeTable; |
---|
14 | |
---|
15 | |
---|
16 | define('GUESTBOOK_PATH' , PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/'); |
---|
17 | define('GUESTBOOK_TABLE' , $prefixeTable . 'guestbook'); |
---|
18 | define('GUESTBOOK_URL', make_index_url(array('section' => 'guestbook'))); |
---|
19 | define('GUESTBOOK_ADMIN', get_root_url().'admin.php?page=plugin-' . basename(dirname(__FILE__))); |
---|
20 | |
---|
21 | add_event_handler('init', 'gb_init'); |
---|
22 | |
---|
23 | function gb_init() |
---|
24 | { |
---|
25 | global $conf; |
---|
26 | |
---|
27 | load_language('plugin.lang', GUESTBOOK_PATH); |
---|
28 | $conf['guestbook'] = unserialize($conf['guestbook']); |
---|
29 | |
---|
30 | // menubar |
---|
31 | if (script_basename() != 'admin') |
---|
32 | { |
---|
33 | add_event_handler('blockmanager_apply', 'gb_menubar_apply', EVENT_HANDLER_PRIORITY_NEUTRAL+10); |
---|
34 | } |
---|
35 | else |
---|
36 | { |
---|
37 | add_event_handler('get_admin_plugin_menu_links', 'gb_admin_menu'); |
---|
38 | } |
---|
39 | |
---|
40 | // guestbook section |
---|
41 | add_event_handler('loc_end_section_init', 'gb_section_init'); |
---|
42 | add_event_handler('loc_end_index', 'gb_index'); |
---|
43 | |
---|
44 | // stuff |
---|
45 | // add_event_handler('get_stuffs_modules', 'gb_register_stuffs_module') |
---|
46 | } |
---|
47 | |
---|
48 | function gb_menubar_apply($menu_ref_arr) |
---|
49 | { |
---|
50 | $menu = &$menu_ref_arr[0]; |
---|
51 | |
---|
52 | if ( ($block = $menu->get_block('mbMenu')) != null ) |
---|
53 | { |
---|
54 | array_push($block->data, array( |
---|
55 | 'URL' => GUESTBOOK_URL, |
---|
56 | 'TITLE' => l10n('GuestBook'), |
---|
57 | 'NAME' => l10n('GuestBook') |
---|
58 | )); |
---|
59 | } |
---|
60 | } |
---|
61 | |
---|
62 | function gb_section_init() |
---|
63 | { |
---|
64 | global $tokens, $page; |
---|
65 | |
---|
66 | if ($tokens[0] == 'guestbook') |
---|
67 | { |
---|
68 | $page['section'] = 'guestbook'; |
---|
69 | $page['title'] = l10n('GuestBook'); |
---|
70 | } |
---|
71 | } |
---|
72 | |
---|
73 | function gb_index() |
---|
74 | { |
---|
75 | global $template, $page, $conf; |
---|
76 | |
---|
77 | if (isset($page['section']) and $page['section'] == 'guestbook') |
---|
78 | { |
---|
79 | include(GUESTBOOK_PATH . '/include/guestbook.inc.php'); |
---|
80 | } |
---|
81 | } |
---|
82 | |
---|
83 | /*function gb_register_stuffs_module($modules) |
---|
84 | { |
---|
85 | array_push($modules, array( |
---|
86 | 'path' => GUESTBOOK_PATH . '/stuffs_module', |
---|
87 | 'name' => GB_NAME, |
---|
88 | 'description' => l10n('gb_stuffs_desc'), |
---|
89 | )); |
---|
90 | |
---|
91 | return $modules; |
---|
92 | }*/ |
---|
93 | |
---|
94 | function gb_admin_menu($menu) |
---|
95 | { |
---|
96 | array_push($menu, array( |
---|
97 | 'NAME' => 'GuestBook', |
---|
98 | 'URL' => GUESTBOOK_ADMIN, |
---|
99 | )); |
---|
100 | return $menu; |
---|
101 | } |
---|
102 | |
---|
103 | ?> |
---|