source: extensions/Contact1menu/main.inc.php @ 32912

Last change on this file since 32912 was 32912, checked in by ddtddt, 17 months ago

[Contact1menu] check php8 + remove item menu

File size: 3.6 KB
RevLine 
[8105]1<?php
2/*
3Plugin Name: Contact 1 menu
[18772]4Version: auto
[8105]5Description: Add contact as menu level 1
[9418]6Plugin URI: http://piwigo.org/ext/extension_view.php?eid=479
[8105]7Author: ddtddt
[31457]8Author URI: http://temmii.com/piwigo/
[8105]9*/
10
[31457]11// +-----------------------------------------------------------------------+
[32385]12// | Contact 1 menu plugin for piwigo  by TEMMII                           |
[31457]13// +-----------------------------------------------------------------------+
[32912]14// | Copyright(C) 2010 - 2023 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]31if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
32
33define('C1M_DIR' , basename(dirname(__FILE__)));
34define('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]38if($desacc['state'] != 'active') 
39{
[18824]40  if (script_basename() == 'admin')   
41  {
42    include_once(dirname(__FILE__).'/initadmin.php');
43  }
[18772]44}
45else
[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;
[18824]61    $menu = & $menu_ref_arr[0];
[8105]62   
[18824]63    load_language('plugin.lang', CONTACT_FORM_PATH);
64    load_language('lang', PHPWG_ROOT_PATH.PWG_LOCAL_DIR, array('no_fallback'=>true, 'local'=>true) );
65    $template->assign(array(
66      'C1MTITLE'     => l10n('Contact'),
67      'C1MNAME'      => l10n('Contact'),
68      'C1MURL'       => CONTACT_FORM_PUBLIC,
69      ));
70
71     
72    if (($block = $menu->get_block( 'mbContact' )) != null)
73    {
74      $template->set_template_dir(C1M_PATH.'template/');
[31875]75        if ($user['theme'] == 'bootstrapdefault'){
76                  $block->template = 'menubar_contact_Bootstrap_Default.tpl';           
77                }else if ($user['theme'] == 'smartpocket'){
78                  $block->template = 'menubar_contact_smartpocket.tpl';         
79                }else{
80                  $block->template = 'menubar_contact.tpl';
81                }
[8105]82    }
[18824]83  }
[8105]84}
85
[32912]86add_event_handler('blockmanager_apply' , 'remove_item_contact', EVENT_HANDLER_PRIORITY_NEUTRAL+50);
87function remove_item_contact($menu_ref_arr){
88  if (($block = $menu_ref_arr[0]->get_block('mbMenu')) != null){
89    unset($block->data['contact']);
90  }
91}
92
[31875]93?>
Note: See TracBrowser for help on using the repository browser.