1 | <?php |
---|
2 | /* |
---|
3 | Plugin Name: Contact 1 menu |
---|
4 | Version: auto |
---|
5 | Description: Add contact as menu level 1 |
---|
6 | Plugin URI: http://piwigo.org/ext/extension_view.php?eid=479 |
---|
7 | Author: ddtddt |
---|
8 | Author URI:http://piwigo.org |
---|
9 | */ |
---|
10 | |
---|
11 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
12 | |
---|
13 | define('C1M_DIR' , basename(dirname(__FILE__))); |
---|
14 | define('C1M_PATH' , PHPWG_PLUGINS_PATH . C1M_DIR . '/'); |
---|
15 | |
---|
16 | $desacc = pwg_db_fetch_assoc(pwg_query("SELECT state FROM " . PLUGINS_TABLE . " WHERE id = 'ContactForm';")); |
---|
17 | |
---|
18 | if($desacc['state'] != 'active') |
---|
19 | { |
---|
20 | if (script_basename() == 'admin') |
---|
21 | { |
---|
22 | include_once(dirname(__FILE__).'/initadmin.php'); |
---|
23 | } |
---|
24 | } |
---|
25 | else |
---|
26 | { |
---|
27 | add_event_handler('blockmanager_register_blocks', 'register_c1m_menubar_blocks'); |
---|
28 | add_event_handler('blockmanager_apply', 'c1m_apply'); |
---|
29 | |
---|
30 | function register_c1m_menubar_blocks( $menu_ref_arr ) |
---|
31 | { |
---|
32 | $menu = & $menu_ref_arr[0]; |
---|
33 | if ($menu->get_id() != 'menubar') |
---|
34 | return; |
---|
35 | $menu->register_block( new RegisteredBlock( 'mbContact', 'Contact', 'C1M')); |
---|
36 | } |
---|
37 | |
---|
38 | function c1m_apply($menu_ref_arr) |
---|
39 | { |
---|
40 | global $template; |
---|
41 | |
---|
42 | $menu = & $menu_ref_arr[0]; |
---|
43 | |
---|
44 | load_language('plugin.lang', CONTACT_FORM_PATH); |
---|
45 | load_language('lang', PHPWG_ROOT_PATH.PWG_LOCAL_DIR, array('no_fallback'=>true, 'local'=>true) ); |
---|
46 | // Envoi des données au template |
---|
47 | $template->assign(array( |
---|
48 | 'C1MTITLE' => l10n('Contact'), |
---|
49 | 'C1MNAME' => l10n('Contact'), |
---|
50 | 'C1MURL' => CONTACT_FORM_PUBLIC, |
---|
51 | )); |
---|
52 | |
---|
53 | |
---|
54 | if (($block = $menu->get_block( 'mbContact' )) != null) |
---|
55 | { |
---|
56 | $template->set_template_dir(C1M_PATH.'template/'); |
---|
57 | $block->template = 'menubar_contact.tpl'; |
---|
58 | } |
---|
59 | } |
---|
60 | } |
---|
61 | |
---|
62 | ?> |
---|