[8105] | 1 | <?php |
---|
| 2 | /* |
---|
| 3 | Plugin Name: Contact 1 menu |
---|
[18772] | 4 | Version: auto |
---|
[8105] | 5 | Description: Add contact as menu level 1 |
---|
[9418] | 6 | Plugin URI: http://piwigo.org/ext/extension_view.php?eid=479 |
---|
[8105] | 7 | Author: ddtddt |
---|
[31457] | 8 | Author URI: http://temmii.com/piwigo/ |
---|
[8105] | 9 | */ |
---|
| 10 | |
---|
[31457] | 11 | // +-----------------------------------------------------------------------+ |
---|
| 12 | // | Contact 1 menu plugin for piwigo | |
---|
| 13 | // +-----------------------------------------------------------------------+ |
---|
[31875] | 14 | // | Copyright(C) 2010 - 2017 ddtddt http://temmii.com/piwigo/ | |
---|
[31457] | 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 | |
---|
[8105] | 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 | |
---|
[18772] | 36 | $desacc = pwg_db_fetch_assoc(pwg_query("SELECT state FROM " . PLUGINS_TABLE . " WHERE id = 'ContactForm';")); |
---|
[8105] | 37 | |
---|
[18772] | 38 | if($desacc['state'] != 'active') |
---|
| 39 | { |
---|
[18824] | 40 | if (script_basename() == 'admin') |
---|
| 41 | { |
---|
| 42 | include_once(dirname(__FILE__).'/initadmin.php'); |
---|
| 43 | } |
---|
[18772] | 44 | } |
---|
| 45 | else |
---|
[8105] | 46 | { |
---|
[18824] | 47 | add_event_handler('blockmanager_register_blocks', 'register_c1m_menubar_blocks'); |
---|
| 48 | add_event_handler('blockmanager_apply', 'c1m_apply'); |
---|
[8105] | 49 | |
---|
[18824] | 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 | } |
---|
[8105] | 57 | |
---|
[18824] | 58 | function c1m_apply($menu_ref_arr) |
---|
| 59 | { |
---|
[31875] | 60 | global $template, $user; |
---|
| 61 | //var_dump($user); |
---|
[18824] | 62 | $menu = & $menu_ref_arr[0]; |
---|
[8105] | 63 | |
---|
[18824] | 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/'); |
---|
[31875] | 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 | } |
---|
[8105] | 84 | } |
---|
[18824] | 85 | } |
---|
[8105] | 86 | } |
---|
| 87 | |
---|
[31875] | 88 | ?> |
---|