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

Last change on this file was 29334, checked in by rvelices, 10 years ago

update plugin version

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 2.2 KB
Line 
1<?php /*
2Plugin Name: RV Menu Tree
3Version: 2.7.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, 2 );
19
20function rv_mt_get_categories_menu_sql_where($where, $expand)
21{
22        if (mobile_theme())
23                return $where;
24        add_event_handler('blockmanager_apply', 'rv_mt_menubar_categories');
25
26        if ($expand)
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                $upper_ids = isset($page['category']['uppercats']) ? array_flip( explode(',', $page['category']['uppercats'])) : null;
50                $refLevel = 0;
51                foreach($block->data['MENU_CATEGORIES'] as &$cat)
52                {
53                        $level = $cat['LEVEL'];
54                        if ($level>$refLevel)
55                                $pre = '<ul'.($refLevel==0?' class=rvTree id=theCategoryMenu':'').'>';
56                        else
57                                $pre = '</li>'.str_repeat('</ul></li>', $refLevel-$level);
58
59                        $class= $cat['SELECTED'] ? 'selected ' : '';
60                        if ($cat['count_categories'] > 0)
61                                $class .= isset($upper_ids[$cat['id']]) ? 'liOpen':'liClosed';
62                        if (!empty($class))
63                                $class=' class="'.$class.'"';
64                        $cat['PRE'] = $pre;
65                        $cat['CLASS'] = $class;
66                        $refLevel = $level;
67                }
68                unset($cat);
69                $rvmt_base_name  = basename(dirname(__FILE__));
70                $template->assign(array(
71                        'RVMT_BASE_NAME' => $rvmt_base_name,
72                        'RVMT_POST' => str_repeat('</li></ul>', $refLevel),
73                        )
74                );
75                $block->template = realpath(PHPWG_ROOT_PATH.'plugins/'.$rvmt_base_name.'/template/rv_menutree_categories.tpl');
76        }
77}
78?>
Note: See TracBrowser for help on using the repository browser.