source: extensions/rv_menutree/trunk/main.inc.php @ 24720

Last change on this file since 24720 was 24720, checked in by rvelices, 11 years ago

menu tree uses css in a file instead of inline (avoid sending it too many times to the browser)

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 1.7 KB
Line 
1<?php /*
2Plugin Name: RV Menu Tree
3Version: 2.6.a
4Plugin URI: http://piwigo.org/ext/extension_view.php?eid=238
5Description: Replaces the categories in the menu bar with a nicer one (javascript).
6Author: rvelices
7Author URI: http://www.modusoptimus.com
8*/
9
10
11add_event_handler('loc_begin_page_header', 'rv_mt_begin_page_header');
12function rv_mt_begin_page_header()
13{
14        global $template;
15        $template->func_combine_css( array('path'=>'plugins/rv_menutree/menutree.css') );
16}
17
18add_event_handler('get_categories_menu_sql_where', 'rv_mt_get_categories_menu_sql_where', EVENT_HANDLER_PRIORITY_NEUTRAL, 3 );
19
20function rv_mt_get_categories_menu_sql_where($where, $expand, $filter)
21{
22        if (mobile_theme())
23                return $where;
24        add_event_handler('blockmanager_apply', 'rv_mt_menubar_categories');
25
26        if ($expand or $filter)
27                return $where;
28
29        global $page;
30        if ( !isset($page['category']) )
31                $where = 'id_uppercat IS NULL OR uppercats REGEXP \'^[0-9]+,[0-9]+$\'';
32        else
33        {
34                $where = 'id_uppercat is NULL
35  OR uppercats LIKE "'.$page['category']['upper_names'][0]['id'].',%"
36  OR uppercats REGEXP \'^[0-9]+,[0-9]+$\'';
37        }
38        return $where;
39}
40
41function rv_mt_menubar_categories($menu_ref_arr)
42{
43        $menu = & $menu_ref_arr[0];
44
45        if (($block = $menu->get_block('mbCategories')) != null)
46        {
47                global $template, $page;
48
49                $rvmt_base_name  = basename(dirname(__FILE__));
50                $template->set_template_dir(PHPWG_ROOT_PATH.'plugins/'.$rvmt_base_name.'/template/');
51                $template->assign(array(
52                        'RVMT_BASE_NAME' => $rvmt_base_name,
53                        'RVMT_UPPER_IDS' => isset($page['category']['uppercats']) ? array_flip( explode(',', $page['category']['uppercats'])) : null,
54                        )
55                );
56                $block->template = 'rv_menutree_categories.tpl';
57        }
58}
59?>
Note: See TracBrowser for help on using the repository browser.