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

Last change on this file since 21292 was 21292, checked in by mistic100, 11 years ago

fix bread crumb

File size: 2.6 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__)));
19define('GUESTBOOK_URL',    get_absolute_root_url() . make_index_url(array('section' => 'guestbook')));
20
21add_event_handler('init', 'gb_init');
22
23function 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
48function 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
62function gb_section_init()
63{
64  global $tokens, $page, $conf;
65
66  if ($tokens[0] == 'guestbook')
67  {
68    add_event_handler('loc_begin_page_header', 'gb_page_header');
69   
70    $page['section'] = 'guestbook';
71    $page['title'] = l10n('GuestBook');
72    $page['section_title'] = '<a href="'.get_gallery_home_url().'">'.l10n('Home').'</a>'.$conf['level_separator'].l10n('GuestBook');
73  }
74}
75
76function gb_page_header()
77{
78  global $page;
79  $page['body_id'] = 'theGuestBook';
80}
81
82function gb_index() 
83{
84  global $template, $page, $conf;
85
86  if (isset($page['section']) and $page['section'] == 'guestbook')
87  {
88    include(GUESTBOOK_PATH . '/include/guestbook.inc.php');
89  }
90}
91
92/*function gb_register_stuffs_module($modules)
93{
94  array_push($modules, array(
95    'path' => GUESTBOOK_PATH . '/stuffs_module',
96    'name' => GB_NAME,
97    'description' => l10n('gb_stuffs_desc'),
98  ));
99
100  return $modules;
101}*/
102
103function gb_admin_menu($menu) 
104{
105  array_push($menu, array(
106    'NAME' => 'GuestBook',
107    'URL' => GUESTBOOK_ADMIN,
108  ));
109  return $menu;
110}
111
112?>
Note: See TracBrowser for help on using the repository browser.