[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 |
---|
[9418] | 8 | Author URI:http://piwigo.org |
---|
[8105] | 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 | |
---|
[18772] | 16 | $desacc = pwg_db_fetch_assoc(pwg_query("SELECT state FROM " . PLUGINS_TABLE . " WHERE id = 'ContactForm';")); |
---|
[8105] | 17 | |
---|
[18772] | 18 | if($desacc['state'] != 'active') |
---|
| 19 | { |
---|
[18824] | 20 | if (script_basename() == 'admin') |
---|
| 21 | { |
---|
| 22 | include_once(dirname(__FILE__).'/initadmin.php'); |
---|
| 23 | } |
---|
[18772] | 24 | } |
---|
| 25 | else |
---|
[8105] | 26 | { |
---|
[18824] | 27 | add_event_handler('blockmanager_register_blocks', 'register_c1m_menubar_blocks'); |
---|
| 28 | add_event_handler('blockmanager_apply', 'c1m_apply'); |
---|
[8105] | 29 | |
---|
[18824] | 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 | } |
---|
[8105] | 37 | |
---|
[18824] | 38 | function c1m_apply($menu_ref_arr) |
---|
| 39 | { |
---|
| 40 | global $template; |
---|
[8105] | 41 | |
---|
[18824] | 42 | $menu = & $menu_ref_arr[0]; |
---|
[8105] | 43 | |
---|
[18824] | 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'; |
---|
[8105] | 58 | } |
---|
[18824] | 59 | } |
---|
[8105] | 60 | } |
---|
| 61 | |
---|
[18822] | 62 | ?> |
---|