<?php /* $Id: function.inc.php 6206 2012-02-10 10:12:34Z denis $ */ $NETCAT_FOLDER = join(strstr(__FILE__, "/") ? "/" : "\\", array_slice(preg_split("/[\\/\\\\]+/", __FILE__), 0, -4)) . (strstr(__FILE__, "/") ? "/" : "\\"); include_once $NETCAT_FOLDER . "vars.inc.php"; global $MODULE_FOLDER; // include need classes include_once $MODULE_FOLDER . "cache/nc_cache.class.php"; include_once $MODULE_FOLDER . "cache/nc_cache_list.class.php"; include_once $MODULE_FOLDER . "cache/nc_cache_full.class.php"; include_once $MODULE_FOLDER . "cache/nc_cache_browse.class.php"; include_once $MODULE_FOLDER . "cache/nc_cache_function.class.php"; include_once $MODULE_FOLDER . "cache/nc_cache_io.class.php"; // modules classes if (nc_module_check_by_keyword("calendar", 0)) { include_once $MODULE_FOLDER . "cache/modules/nc_cache_calendar.class.php"; } // load objects for inside_admin events nc_cache_browse::getObject(); nc_cache_full::getObject(); nc_cache_list::getObject(); nc_cache_function::getObject(); if (nc_module_check_by_keyword("calendar", 0)) { nc_cache_calendar::getObject(); }
function nc_browse_cc($browse_template) { global $db; global $admin_mode, $admin_url_prefix; global $current_cc, $current_sub; global $cc_in_sub, $cc_array, $cc_keyword, $use_multi_sub_class; global $REQUEST_URI, $SUB_FOLDER; // this happens when non-existent sub requested in admin mode if (!$current_sub["Subdivision_ID"]) { return ""; } // cache section if (nc_module_check_by_keyword("cache") && $current_cc['Cache_Access_ID'] == 1 && $browse_template['nocache'] != true) { $nc_cache_browse = nc_cache_browse::getObject(); try { // check cached data $cached_data = $nc_cache_browse->read($current_cc, $browse_template, $REQUEST_URI, $current_cc['Cache_Lifetime']); if ($cached_data != -1) { // debug info $cache_debug_info = "Read, catalogue[" . $current_cc['Catalogue_ID'] . "], sub[" . $current_cc['Subdivision_ID'] . "], cc[" . $current_cc['Sub_Class_ID'] . "], Access_ID[" . $current_cc['Cache_Access_ID'] . "], Lifetime[" . $current_cc['Cache_Lifetime'] . "], bytes[" . strlen($cached_data) . "]"; $nc_cache_browse->debugMessage($cache_debug_info, __FILE__, __LINE__); // return cache return $cached_data; } } catch (Exception $e) { // for debug $nc_cache_browse->errorMessage($e); } } $sort_by = $browse_template['sortby'] ? $browse_template['sortby'] : "`Priority`"; if (!$admin_mode) { $check_cond = " AND `Checked` = 1"; } else { $check_cond = ""; } // cc_in_sub has all templates in sub $data = array(); if ($sort_by == 'Priority' && $GLOBALS['sub'] == $current_sub["Subdivision_ID"]) { foreach ((array) $cc_in_sub as $row) { if ($admin_mode || $row["Checked"] == 1) { $data[] = $row; } } } if (empty($data)) { $data = $db->get_results("SELECT `Sub_Class_ID`, `Sub_Class_Name`, `EnglishName`\n FROM `Sub_Class`\n WHERE `Subdivision_ID` = '" . $current_sub["Subdivision_ID"] . "'" . $check_cond . " ORDER BY " . $sort_by, ARRAY_A); } $data_count = sizeof($data); if (!$data_count || $data_count < 2) { return null; } $result = $browse_template['prefix']; $array_result = array(); $routing_module_enabled = nc_module_check_by_keyword('routing'); $current_page_url = urldecode(strtok($REQUEST_URI, '?')); for ($i = 0; $i < $data_count; $i++) { $nav_name = $data[$i]["Sub_Class_Name"]; if ($admin_mode) { $nav_url = $admin_url_prefix . "?catalogue=" . $current_sub["Catalogue_ID"] . "&sub=" . $current_sub["Subdivision_ID"] . "&cc=" . $data[$i]["Sub_Class_ID"]; } else { if ($routing_module_enabled) { $nav_url = nc_routing::get_infoblock_path($data[$i]["Sub_Class_ID"]); } else { $nav_url = $SUB_FOLDER . $current_sub["Hidden_URL"] . $data[$i]["EnglishName"] . ".html"; } } if ($data[$i]["Sub_Class_ID"] == $current_cc["Sub_Class_ID"] && ($cc_keyword || !$use_multi_sub_class)) { if ($browse_template['active_link'] && ($nav_url == $REQUEST_URI || $nav_url == $current_page_url || $SUB_FOLDER . $current_sub['Hidden_URL'] . $current_cc['EnglishName'] . ".html" == $current_page_url)) { $current_template = $browse_template['active_link']; } else { $current_template = $browse_template['active']; } $array_result[$i] = $current_template; } else { $array_result[$i] = $browse_template['unactive']; } $array_result[$i] = str_replace("%NAME", $nav_name, $array_result[$i]); $array_result[$i] = str_replace("%URL", $nav_url, $array_result[$i]); } $result .= join($browse_template['divider'], $array_result); $result .= $browse_template['suffix']; // cache section if (nc_module_check_by_keyword("cache") && $current_cc['Cache_Access_ID'] == 1 && is_object($nc_cache_browse) && $browse_template['nocache'] != true) { try { $bytes = $nc_cache_browse->add($current_cc, $browse_template, $REQUEST_URI, $result); // debug info if ($bytes) { $cache_debug_info = "Written, catalogue[" . $current_cc['Catalogue_ID'] . "], sub[" . $current_cc['Subdivision_ID'] . "], cc[" . $current_cc['Sub_Class_ID'] . "], Access_ID[" . $current_cc['Cache_Access_ID'] . "], Lifetime[" . $current_cc['Cache_Lifetime'] . "], bytes[" . $bytes . "]"; $nc_cache_browse->debugMessage($cache_debug_info, __FILE__, __LINE__, "ok"); } } catch (Exception $e) { // for debug $nc_cache_browse->errorMessage($e); } } return $result; }