1 | <?php /* |
---|
2 | Plugin Name: RV Menu Tree |
---|
3 | Version: 2.1.b |
---|
4 | Plugin URI: http://piwigo.org/ext/extension_view.php?eid=238 |
---|
5 | Description: Replaces the categories in the menu bar with a nicer one (javascript). |
---|
6 | Author: rvelices |
---|
7 | Author URI: http://www.modusoptimus.com |
---|
8 | */ |
---|
9 | |
---|
10 | if (!function_exists('rv_ua_is_handheld')) |
---|
11 | { |
---|
12 | function rv_ua_is_handheld() |
---|
13 | { |
---|
14 | if ( isset($_SESSION['is_handheld']) ) |
---|
15 | return $_SESSION['is_handheld']; |
---|
16 | $ret=false; |
---|
17 | if ( strpos($_SERVER['HTTP_USER_AGENT'], 'BlackBerry')!==false ) |
---|
18 | $ret=true; |
---|
19 | if ( session_id()!="" ) |
---|
20 | $_SESSION['is_handheld']=$ret; |
---|
21 | return $ret; |
---|
22 | } |
---|
23 | } |
---|
24 | |
---|
25 | add_event_handler('get_categories_menu_sql_where', 'rv_mt_get_categories_menu_sql_where', EVENT_HANDLER_PRIORITY_NEUTRAL, 3 ); |
---|
26 | |
---|
27 | function rv_mt_get_categories_menu_sql_where($where, $expand, $filter) |
---|
28 | { |
---|
29 | if (rv_ua_is_handheld()) return $where; |
---|
30 | add_event_handler('blockmanager_apply', 'rv_mt_menubar_categories'); |
---|
31 | |
---|
32 | if ($expand or $filter) |
---|
33 | return $where; |
---|
34 | |
---|
35 | global $page; |
---|
36 | if ( !isset($page['category']) ) |
---|
37 | $where = 'id_uppercat IS NULL OR uppercats REGEXP \'^[0-9]+,[0-9]+$\''; |
---|
38 | else |
---|
39 | { |
---|
40 | $where = 'id_uppercat is NULL |
---|
41 | OR uppercats LIKE "'.$page['category']['upper_names'][0]['id'].',%" |
---|
42 | OR uppercats REGEXP \'^[0-9]+,[0-9]+$\''; |
---|
43 | } |
---|
44 | return $where; |
---|
45 | } |
---|
46 | |
---|
47 | function rv_mt_menubar_categories($menu_ref_arr) |
---|
48 | { |
---|
49 | $menu = & $menu_ref_arr[0]; |
---|
50 | |
---|
51 | if (($block = $menu->get_block('mbCategories')) != null) |
---|
52 | { |
---|
53 | global $template, $page; |
---|
54 | |
---|
55 | $rvmt_path = get_root_url().'plugins/'. basename(dirname(__FILE__)).'/'; |
---|
56 | $template->set_template_dir($rvmt_path.'template/'); |
---|
57 | $template->assign(array( |
---|
58 | 'RVMT_PATH' => $rvmt_path, |
---|
59 | 'RVMT_UPPER_IDS' => isset($page['category']['uppercats']) ? array_flip( explode(',', $page['category']['uppercats'])) : null, |
---|
60 | ) |
---|
61 | ); |
---|
62 | $block->template = 'rv_menutree_categories.tpl'; |
---|
63 | } |
---|
64 | } |
---|
65 | ?> |
---|