[3572] | 1 | <?php /* |
---|
| 2 | Plugin Name: RV Menu Tree |
---|
[6393] | 3 | Version: 2.1.a |
---|
[3590] | 4 | Plugin URI: http://piwigo.org/ext/extension_view.php?eid=238 |
---|
[3572] | 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; |
---|
[6389] | 30 | add_event_handler('blockmanager_apply', 'rv_mt_menubar_categories'); |
---|
[3572] | 31 | |
---|
| 32 | if ($expand) |
---|
| 33 | return $where; |
---|
| 34 | if ($filter) |
---|
| 35 | { |
---|
| 36 | global $rv_mt_all_open; |
---|
| 37 | $rv_mt_all_open = true; |
---|
| 38 | return $where; |
---|
| 39 | } |
---|
| 40 | |
---|
| 41 | global $page; |
---|
| 42 | if ( !isset($page['category']) ) |
---|
| 43 | $where = 'id_uppercat IS NULL OR uppercats REGEXP \'^[0-9]+,[0-9]+$\''; |
---|
| 44 | else |
---|
| 45 | { |
---|
| 46 | $where = 'id_uppercat is NULL |
---|
| 47 | OR uppercats LIKE "'.$page['category']['upper_names'][0]['id'].',%" |
---|
| 48 | OR uppercats REGEXP \'^[0-9]+,[0-9]+$\''; |
---|
| 49 | } |
---|
| 50 | return $where; |
---|
| 51 | } |
---|
| 52 | |
---|
[6389] | 53 | function rv_mt_menubar_categories($menu_ref_arr) |
---|
[3572] | 54 | { |
---|
[6389] | 55 | $menu = & $menu_ref_arr[0]; |
---|
[3572] | 56 | |
---|
[6389] | 57 | if (($block = $menu->get_block('mbCategories')) != null) |
---|
[3572] | 58 | { |
---|
[6389] | 59 | global $template, $page, $rv_mt_all_open; |
---|
[3572] | 60 | |
---|
[6389] | 61 | $dirname = dirname(__FILE__); |
---|
[3572] | 62 | |
---|
[6389] | 63 | $block->template = $dirname.'/menubar_categories.tpl'; |
---|
[3572] | 64 | |
---|
[6389] | 65 | $template->assign('rvmt', array( |
---|
| 66 | 'PATH' => get_root_url().'plugins/'. basename($dirname).'/', |
---|
| 67 | 'CSS' => str_replace( 'url(', 'url('.get_root_url().'plugins/'.basename($dirname).'/',file_get_contents($dirname.'/rvtree-min.css')), |
---|
| 68 | 'ALL_OPEN' => $rv_mt_all_open, |
---|
| 69 | 'UPPER_IDS' => isset($page['category']['uppercats']) ? array_flip( explode(',', $page['category']['uppercats'])) : null, |
---|
| 70 | ) |
---|
| 71 | ); |
---|
[3572] | 72 | } |
---|
| 73 | } |
---|
| 74 | ?> |
---|