source: extensions/spread_menus/spread_menus_on_public_pages.php @ 16859

Last change on this file since 16859 was 9252, checked in by Gotcha, 13 years ago

Problem with $pagestart when picture haven't comments
Thanks to cljosse.
http://fr.piwigo.org/forum/viewtopic.php?pid=161921#p161921

File size: 2.6 KB
Line 
1<?php
2/* Spread menus */
3if (!defined('PHPWG_ROOT_PATH') or !defined('SPREADM_DIR')) die('Hacking attempt!');
4global $conf;
5$default = array(
6        'Dir'                           => SPREADM_DIR,
7        'Path'                          => SPREADM_PATH,
8        'On_picture'            => true,
9        'Exclude'                       => array('theNBMPage','thePopuphelpPage',),     # Excluded pages
10        'On_theme'                      => array( 'Sylvia', 'clear', 'dark', 'aqua', 'blancmontxl',
11                        'GBO_hk-3', 'GBO_hk-3_clear', 'grum-dark-II', 'kardon', 'Pure_clear_blue',
12                        'Pure_green_nature', 'Pure_tr_clear_blue', 'sobre',     'VerticalWhite', 'p0w0', 'wipi' ),  # Eligible themes (currently assumed by the plugin)
13        );
14if (!isset($conf['Spread menus']) or !is_array($conf['Spread menus'])) $conf['Spread menus'] = $default;
15else $conf['Spread menus'] = array_merge( $default, $conf['Spread menus'] );
16
17if ( !function_exists( 'spread_menus_on_public_pages' ) ) {
18        if ( defined('IN_ADMIN') and IN_ADMIN ) return false;
19        add_event_handler('loc_after_page_header', 'spread_menus_on_public_pages', 20);
20
21        function  spread_menus_on_public_pages() {
22          if ( function_exists( 'initialize_menu') ) return false; # The current page has already the menu
23          global $template, $page, $conf;
24          if (!isset($page['start'])) $page['start']=0 ;
25          if ( isset($page['body_id']) and in_array($page['body_id'], $conf['Spread menus']['Exclude']) ) return false;
26          if ( isset($page['body_id']) and $page['body_id'] == 'thePicturePage' and !$conf['Spread menus']['On_picture'] ) return false;
27          $themeconf = $template->get_template_vars('themeconf');
28          # themes could set $themeconf['spread_menus'] with the .css filename they provide in their css subfolder
29          if ( isset($themeconf['spread_menus']) and isset($themeconf['id']) ) $conf['Spread menus']['On_theme'][] = $themeconf['id'];
30          if ( !isset($themeconf['id']) or !in_array($themeconf['id'],$conf['Spread menus']['On_theme']) ) return false;
31
32          $template->set_filenames(array(
33                'spread_menus_on_public_pages' => dirname(__FILE__) . '/template/spread_menus_on_public_pages.tpl',
34          ));
35          include_once(PHPWG_ROOT_PATH.'include/menubar.inc.php');
36          $conf['Spread menus']['Path'] = embellish_url($template->get_template_vars('ROOT_URL').SPREADM_PATH);
37          $template->assign( array( 'SPREADM' => $conf['Spread menus'] ) );
38          $template->parse('spread_menus_on_public_pages');
39         
40          if (is_admin())
41                {
42          $template->assign(
43        'U_ADMIN', get_root_url().'admin.php?page=picture_modify'
44      .'&amp;cat_id='.(isset($page['category']) ? $page['category']['id'] : '')
45      .( isset($page['image_id']) ? '&amp;image_id='.$page['image_id'] : '')
46      );
47                }
48         
49        }
50}
51?>
Note: See TracBrowser for help on using the repository browser.