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://temmii.com/piwigo/ |
---|
9 | */ |
---|
10 | |
---|
11 | // +-----------------------------------------------------------------------+ |
---|
12 | // | Contact 1 menu plugin for piwigo | |
---|
13 | // +-----------------------------------------------------------------------+ |
---|
14 | // | Copyright(C) 2010 - 2017 ddtddt http://temmii.com/piwigo/ | |
---|
15 | // +-----------------------------------------------------------------------+ |
---|
16 | // | This program is free software; you can redistribute it and/or modify | |
---|
17 | // | it under the terms of the GNU General Public License as published by | |
---|
18 | // | the Free Software Foundation | |
---|
19 | // | | |
---|
20 | // | This program is distributed in the hope that it will be useful, but | |
---|
21 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
22 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
23 | // | General Public License for more details. | |
---|
24 | // | | |
---|
25 | // | You should have received a copy of the GNU General Public License | |
---|
26 | // | along with this program; if not, write to the Free Software | |
---|
27 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
28 | // | USA. | |
---|
29 | // +-----------------------------------------------------------------------+ |
---|
30 | |
---|
31 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
32 | |
---|
33 | define('C1M_DIR' , basename(dirname(__FILE__))); |
---|
34 | define('C1M_PATH' , PHPWG_PLUGINS_PATH . C1M_DIR . '/'); |
---|
35 | |
---|
36 | $desacc = pwg_db_fetch_assoc(pwg_query("SELECT state FROM " . PLUGINS_TABLE . " WHERE id = 'ContactForm';")); |
---|
37 | |
---|
38 | if($desacc['state'] != 'active') |
---|
39 | { |
---|
40 | if (script_basename() == 'admin') |
---|
41 | { |
---|
42 | include_once(dirname(__FILE__).'/initadmin.php'); |
---|
43 | } |
---|
44 | } |
---|
45 | else |
---|
46 | { |
---|
47 | add_event_handler('blockmanager_register_blocks', 'register_c1m_menubar_blocks'); |
---|
48 | add_event_handler('blockmanager_apply', 'c1m_apply'); |
---|
49 | |
---|
50 | function register_c1m_menubar_blocks( $menu_ref_arr ) |
---|
51 | { |
---|
52 | $menu = & $menu_ref_arr[0]; |
---|
53 | if ($menu->get_id() != 'menubar') |
---|
54 | return; |
---|
55 | $menu->register_block( new RegisteredBlock( 'mbContact', 'Contact', 'C1M')); |
---|
56 | } |
---|
57 | |
---|
58 | function c1m_apply($menu_ref_arr) |
---|
59 | { |
---|
60 | global $template, $user; |
---|
61 | //var_dump($user); |
---|
62 | $menu = & $menu_ref_arr[0]; |
---|
63 | |
---|
64 | load_language('plugin.lang', CONTACT_FORM_PATH); |
---|
65 | load_language('lang', PHPWG_ROOT_PATH.PWG_LOCAL_DIR, array('no_fallback'=>true, 'local'=>true) ); |
---|
66 | // Envoi des données au template |
---|
67 | $template->assign(array( |
---|
68 | 'C1MTITLE' => l10n('Contact'), |
---|
69 | 'C1MNAME' => l10n('Contact'), |
---|
70 | 'C1MURL' => CONTACT_FORM_PUBLIC, |
---|
71 | )); |
---|
72 | |
---|
73 | |
---|
74 | if (($block = $menu->get_block( 'mbContact' )) != null) |
---|
75 | { |
---|
76 | $template->set_template_dir(C1M_PATH.'template/'); |
---|
77 | if ($user['theme'] == 'bootstrapdefault'){ |
---|
78 | $block->template = 'menubar_contact_Bootstrap_Default.tpl'; |
---|
79 | }else if ($user['theme'] == 'smartpocket'){ |
---|
80 | $block->template = 'menubar_contact_smartpocket.tpl'; |
---|
81 | }else{ |
---|
82 | $block->template = 'menubar_contact.tpl'; |
---|
83 | } |
---|
84 | } |
---|
85 | } |
---|
86 | } |
---|
87 | |
---|
88 | ?> |
---|