source: extensions/GuestBook/main.inc.php @ 17317

Last change on this file since 17317 was 17317, checked in by mistic100, 12 years ago

compatible with question_mark_in_urls=false

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