function osm_apply_menu($menu_ref_arr)
{
    global $template, $page, $conf;
    $menu =& $menu_ref_arr[0];
    if (($block = $menu->get_block('mbLinks')) != null) {
        include_once dirname(__FILE__) . '/include/functions.php';
        include_once dirname(__FILE__) . '/include/functions_map.php';
        osm_load_language();
        load_language('plugin.lang', OSM_PATH);
        // Comment are used only with this condition index.php l294
        if ($page['start'] == 0 and !isset($page['chronology_field'])) {
            $js_data = osm_get_items($page);
            if ($js_data != array()) {
                $local_conf = array();
                $local_conf['contextmenu'] = 'false';
                $local_conf['control'] = true;
                $local_conf['img_popup'] = false;
                $local_conf['popup'] = 2;
                $local_conf['center_lat'] = 0;
                $local_conf['center_lng'] = 0;
                $local_conf['zoom'] = 2;
                $local_conf['autocenter'] = 1;
                $local_conf['divname'] = 'mapmenu';
                $local_conf['paths'] = osm_get_gps($page);
                $height = isset($conf['osm_conf']['main_menu']['height']) ? $conf['osm_conf']['main_menu']['height'] : '200';
                $js = osm_get_js($conf, $local_conf, $js_data);
                $template->set_template_dir(dirname(__FILE__) . '/template/');
                $template->assign(array('OSM_PATH' => embellish_url(get_gallery_home_url() . OSM_PATH), 'OSMJS' => $js, 'HEIGHT' => $height));
                $block->template = 'osm-menu.tpl';
            }
        }
    }
}
function osm_render_category()
{
    global $template, $page, $conf, $filter;
    include_once dirname(__FILE__) . '/include/functions.php';
    include_once dirname(__FILE__) . '/include/functions_map.php';
    osm_load_language();
    load_language('plugin.lang', OSM_PATH);
    // TF, 20160102: pass config as parameter
    $js_data = osm_get_items($conf, $page);
    if ($js_data != array()) {
        $local_conf = array();
        $local_conf['contextmenu'] = 'false';
        $local_conf['control'] = true;
        $local_conf['img_popup'] = false;
        $local_conf['popup'] = 1;
        $local_conf['center_lat'] = 0;
        $local_conf['center_lng'] = 0;
        $local_conf['zoom'] = 2;
        $local_conf['auto_center'] = 1;
        // TF, 20160102: pass config as parameter
        $local_conf['paths'] = osm_get_gps($conf, $page);
        $height = isset($conf['osm_conf']['category_description']['height']) ? $conf['osm_conf']['category_description']['height'] : '200';
        $width = isset($conf['osm_conf']['category_description']['width']) ? $conf['osm_conf']['category_description']['width'] : 'auto';
        $js = osm_get_js($conf, $local_conf, $js_data);
        $template->set_filename('map', dirname(__FILE__) . '/template/osm-category.tpl');
        $template->assign(array('CONTENT_ENCODING' => get_pwg_charset(), 'OSM_PATH' => embellish_url(get_gallery_home_url() . OSM_PATH), 'HOME' => make_index_url(), 'HOME_PREV' => isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : get_absolute_root_url(), 'HOME_NAME' => l10n("Home"), 'HOME_PREV_NAME' => l10n("Previous"), 'OSMJS' => $js, 'HEIGHT' => $height, 'WIDTH' => $width));
        $osm_content = $template->parse('map', true);
        //$osm_content = '<div id="osmmap"><div class="map_title">'.l10n('EDIT_MAP').'</div>' . $osm_content . '</div>';
        $index = isset($conf['osm_conf']['category_description']['index']) ? $conf['osm_conf']['category_description']['index'] : 0;
        // 0 - PLUGIN_INDEX_CONTENT_BEGIN
        // 1 - PLUGIN_INDEX_CONTENT_COMMENT
        // 2 - PLUGIN_INDEX_CONTENT_END
        if ($index <= 1) {
            // From index category comment at L300
            if ($page['start'] == 0 and !isset($page['chronology_field'])) {
                if (empty($page['comment'])) {
                    $page['comment'] = $osm_content;
                } else {
                    if ($index == 0) {
                        $page['comment'] = '<div>' . $osm_content . $page['comment'] . '</div>';
                    } else {
                        $page['comment'] = '<div>' . $page['comment'] . $osm_content . '</div>';
                    }
                }
            }
        } else {
            $osm_content = '<div id="osmmap">' . $osm_content . '</div>';
            $template->concat('PLUGIN_INDEX_CONTENT_END', "\n" . $osm_content);
        }
    }
}
$tokens = explode('/', preg_replace('#^/#', '', $section));
$next_token = 0;
$result = osm_parse_map_data_url($tokens, $next_token);
$page = array_merge($page, $result);
if (isset($page['category'])) {
    check_restrictions($page['category']['id']);
}
/* If the config include parameters get them */
$zoom = isset($conf['osm_conf']['left_menu']['zoom']) ? $conf['osm_conf']['left_menu']['zoom'] : 2;
$center = isset($conf['osm_conf']['left_menu']['center']) ? $conf['osm_conf']['left_menu']['center'] : '0,0';
$center_arr = preg_split('/,/', $center);
$center_lat = isset($center_arr) ? $center_arr[0] : 0;
$center_lng = isset($center_arr) ? $center_arr[1] : 0;
/* If we have zoom and center coordonate, set it otherwise fallback default */
$zoom = isset($_GET['zoom']) ? $_GET['zoom'] : $zoom;
$center_lat = isset($_GET['center_lat']) ? $_GET['center_lat'] : $center_lat;
$center_lng = isset($_GET['center_lng']) ? $_GET['center_lng'] : $center_lng;
$local_conf = array();
$local_conf['zoom'] = $zoom;
$local_conf['center_lat'] = $center_lat;
$local_conf['center_lng'] = $center_lng;
$local_conf['contextmenu'] = 'false';
$local_conf['control'] = true;
$local_conf['img_popup'] = false;
// TF, 20160102: pass config as parameter
$local_conf['paths'] = osm_get_gps($conf, $page);
$local_conf = $local_conf + $conf['osm_conf']['map'] + $conf['osm_conf']['left_menu'];
// TF, 20160102: pass config as parameter
$js_data = osm_get_items($conf, $page);
$js = osm_get_js($conf, $local_conf, $js_data);
osm_gen_template($conf, $js, $js_data, 'osm-map.tpl', $template);