1 | <?php |
---|
2 | /* |
---|
3 | Plugin Name: Search 1 menu |
---|
4 | Version: auto |
---|
5 | Description: Move quick Search as menu level 1 |
---|
6 | Plugin URI: https://piwigo.org/ext/extension_view.php?eid=892 |
---|
7 | Author: ddtddt |
---|
8 | Author URI: http://temmii.com/piwigo/ |
---|
9 | */ |
---|
10 | |
---|
11 | // +-----------------------------------------------------------------------+ |
---|
12 | // | Search 1 menu for Piwigo by TEMMII | |
---|
13 | // +-----------------------------------------------------------------------+ |
---|
14 | // | Copyright(C) 2008-2021 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('S1M_DIR' , basename(dirname(__FILE__))); |
---|
34 | define('S1M_PATH' , PHPWG_PLUGINS_PATH . S1M_DIR . '/'); |
---|
35 | |
---|
36 | add_event_handler('blockmanager_register_blocks', 'register_s1m_menubar_blocks'); |
---|
37 | add_event_handler('blockmanager_apply', 's1m_apply'); |
---|
38 | |
---|
39 | function register_s1m_menubar_blocks( $menu_ref_arr ) |
---|
40 | { |
---|
41 | $menu = & $menu_ref_arr[0]; |
---|
42 | if ($menu->get_id() != 'menubar') |
---|
43 | return; |
---|
44 | $menu->register_block( new RegisteredBlock( 'mbsearch', 'Quick search', 'S1M')); |
---|
45 | } |
---|
46 | |
---|
47 | function s1m_apply($menu_ref_arr) |
---|
48 | { |
---|
49 | global $template,$user; |
---|
50 | |
---|
51 | $menu = & $menu_ref_arr[0]; |
---|
52 | |
---|
53 | $template->assign ( |
---|
54 | array ( |
---|
55 | 'C1MTITLE' => l10n('Quick search'), |
---|
56 | ) ); |
---|
57 | |
---|
58 | |
---|
59 | if (($block = $menu->get_block( 'mbsearch' )) != null) { |
---|
60 | $template->set_template_dir(S1M_PATH.'template/'); |
---|
61 | if ($user['theme'] == 'bootstrapdefault'||$user['theme'] == 'bootstrap_darkroom'){ |
---|
62 | $block->template = 'menubar_search_Bootstrap_Default.tpl'; |
---|
63 | }else if ($user['theme'] == 'smartpocket'){ |
---|
64 | $block->template = 'menubar_search_smartpocket.tpl'; |
---|
65 | }else{ |
---|
66 | $block->template = 'menubar_search.tpl'; |
---|
67 | } |
---|
68 | } |
---|
69 | } |
---|
70 | |
---|
71 | add_event_handler('blockmanager_apply' , 'remove_item_menu_search', EVENT_HANDLER_PRIORITY_NEUTRAL+10); |
---|
72 | function remove_item_menu_search($menu_ref_arr){ |
---|
73 | if (($block = $menu_ref_arr[0]->get_block('mbMenu')) != null){ |
---|
74 | unset($block->data['qsearch']); |
---|
75 | } |
---|
76 | } |
---|
77 | |
---|
78 | |
---|
79 | |
---|
80 | |
---|
81 | ?> |
---|