function tep_show_category($counter, $count) { global $tree, $categories_string, $cPath_array, $ii; if ($count == 0) { $kk = ' class="bg_list"'; } else { $kk = ' class="bg_list"'; } $count++; if (!$tree[$counter]['level']) { $categories_string .= $categories_string ? '' : ''; $categories_string .= '<li' . $kk . '><a href='; if (SHOW_COUNTS == 'true') { $products_in_category = tep_count_products_in_category($counter); if ($products_in_category > 0) { $num_prod = ' (' . $products_in_category . ')'; } } if ($tree[$counter]['parent'] == 0) { $cPath_new = 'cPath=' . $counter; } else { $cPath_new = 'cPath=' . $tree[$counter]['path']; } $categories_string .= tep_href_link('index.php', $cPath_new) . '>'; // display categry name $categories_string .= $tree[$counter]['name']; $categories_string .= $num_prod . '</a></li>'; } else { // SUBCATEGORY if (SHOW_COUNTS == 'true') { $products_in_category = tep_count_products_in_category($counter); if ($products_in_category > 0) { $num_prod = ' (' . $products_in_category . ')'; } } $count = 2; $categories_string .= ''; $categories_string .= '<li class="bg_list_sub">'; for ($i = 0; $i < $tree[$counter]['level']; $i++) { $categories_string .= ' '; } $categories_string .= '<a href='; if ($tree[$counter]['parent'] == 0) { $cPath_new = 'cPath=' . $counter; } else { $cPath_new = 'cPath=' . $tree[$counter]['path']; } $categories_string .= tep_href_link('index.php', $cPath_new) . '>'; // display category name $categories_string .= $tree[$counter]['name']; $categories_string .= $num_prod . '</a></li>'; } if ($tree[$counter]['next_id'] != false && $ii < 30) { tep_show_category($tree[$counter]['next_id'], $count); } }
function tep_show_category($counter) { // Category Optimization global $tree, $categories_string, $cPath_array, $parent_child; for ($i = 0; $i < $tree[$counter]['level']; $i++) { $categories_string .= " "; } $categories_string .= '<a href="'; if ($tree[$counter]['parent'] == 0) { $cPath_new = 'cPath=' . $counter; } else { $cPath_new = 'cPath=' . $tree[$counter]['path']; } $categories_string .= tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">'; if (isset($cPath_array) && in_array($counter, $cPath_array)) { $categories_string .= '<b>'; } // display category name $categories_string .= $tree[$counter]['name']; if (isset($cPath_array) && in_array($counter, $cPath_array)) { $categories_string .= '</b>'; } // BOF tep_show_category optimization /* if (tep_has_category_subcategories($counter)) { $categories_string .= '->'; } */ // foreach ($parent_child as $index_of => $sub_parent_child) { if ($counter == $sub_parent_child['parent_id']) { // a category has this one as a parent, so parent has a subcategory $categories_string .= '->'; break; // } } // end foreach ($parent_child as $index_of => $sub_parent_child) // EOF tep_show_category optimization $categories_string .= '</a>'; if (SHOW_COUNTS == 'true') { $products_in_category = tep_count_products_in_category($counter); if ($products_in_category > 0) { $categories_string .= ' (' . $products_in_category . ')'; } } $categories_string .= '<br>'; if ($tree[$counter]['next_id'] != false) { tep_show_category($tree[$counter]['next_id']); } }
function tep_show_category($counter) { global $tree, $categories_string, $cPath_array; for ($i = 0; $i < $tree[$counter]['level']; $i++) { $categories_string .= " "; } $categories_string .= '<a href="'; if ($tree[$counter]['parent'] == 0) { $cPath_new = 'cPath=' . $counter; } else { $cPath_new = 'cPath=' . $tree[$counter]['path']; } $categories_string .= tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">'; if (isset($cPath_array) && in_array($counter, $cPath_array)) { $categories_string .= '<b>'; } // display category name $categories_string .= $tree[$counter]['name']; if (isset($cPath_array) && in_array($counter, $cPath_array)) { $categories_string .= '</b>'; } if (tep_has_category_subcategories($counter)) { $categories_string .= ''; } $categories_string .= '</a>'; if (SHOW_COUNTS == 'false') { $products_in_category = tep_count_products_in_category($counter); if ($products_in_category > 0) { $categories_string .= ' (' . $products_in_category . ')'; } } $categories_string .= '<br>'; if ($tree[$counter]['next_id'] != false) { tep_show_category($tree[$counter]['next_id']); } }
if (!is_dir($categories_cache_dir)) { mkdir($categories_cache_dir, 0777); } $categories_cache_dir .= $products_types['products_types_id'] . '/'; if (!is_dir($categories_cache_dir)) { mkdir($categories_cache_dir, 0777); } $categories_cache_filename = $categories_cache_dir . 'tree_0.html'; $include_categories_cache_filename = false; if (file_exists($categories_cache_filename)) { if (date('Y-m-d H:i:s', filemtime($categories_cache_filename)) > $products_types['products_last_modified']) { $include_categories_cache_filename = true; } } if ($include_categories_cache_filename == false) { $categories_string = tep_show_category(0, 1, '', $products_types['products_types_id'], true); $categories_string = str_replace('?' . tep_session_name() . '=' . tep_session_id(), '', $categories_string); $fp = fopen($categories_cache_filename, 'w'); fwrite($fp, $categories_string); fclose($fp); } else { $categories_string = ''; $fp = fopen($categories_cache_filename, 'r'); while (!feof($fp)) { $categories_string .= fgets($fp, 400); } fclose($fp); } if ($products_types['products_types_default_status'] == '0') { echo ' <div class="li"><div class="level_1"><a href="' . tep_href_link(FILENAME_CATEGORIES, 'tPath=' . $products_types['products_types_id'] . '&view=all') . '" class="active">' . TEXT_ALL_CATEGORY_PRODUCTS . '</a></div></div>' . "\n"; } elseif ($products_types['products_types_default_status'] == '1') {
if (!is_dir($categories_cache_dir)) { mkdir($categories_cache_dir, 0777); } $categories_cache_filename = $categories_cache_dir . 'tree_' . $current_category_id . '.html'; $include_categories_cache_filename = false; if (file_exists($categories_cache_filename)) { if (date('Y-m-d H:i:s', filemtime($categories_cache_filename)) > $type_info['products_last_modified']) { $include_categories_cache_filename = true; } } $box_info_query = tep_db_query("select blocks_name from " . TABLE_BLOCKS . " where blocks_filename = '" . tep_db_input(basename(__FILE__)) . "' and language_id = '" . (int) $languages_id . "'"); $box_info = tep_db_fetch_array($box_info_query); $boxHeading = '<a href="' . tep_href_link(FILENAME_CATEGORIES, 'tPath=' . $check_products_types_id) . '">' . $box_info['blocks_name'] . '</a>'; $boxID = $type_info['products_types_path']; if ($include_categories_cache_filename == false) { $boxContent = tep_show_category(0, 0, '', $check_products_types_id); $boxContent = str_replace('?' . tep_session_name() . '=' . tep_session_id(), '', $boxContent); $fp = fopen($categories_cache_filename, 'w'); fwrite($fp, $boxContent); fclose($fp); } else { $boxContent = ''; $fp = fopen($categories_cache_filename, 'r'); while (!feof($fp)) { $boxContent .= fgets($fp, 400); } fclose($fp); } if (tep_not_null($boxContent)) { include DIR_WS_TEMPLATES_BOXES . 'box.php'; }
function tep_show_category($parent_id = 0, $level = 0, $only_categories = '', $products_types_id = '1', $include_all_products_link = false) { global $languages_id, $cPath_array, $show_product_type, $HTTP_GET_VARS; if (tep_not_null($HTTP_GET_VARS['products_id']) && basename(SCRIPT_FILENAME) == FILENAME_PRODUCT_INFO) { $category_info_query = tep_db_query("select categories_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int) $HTTP_GET_VARS['products_id'] . "' order by categories_id desc limit 1"); $category_info = tep_db_fetch_array($category_info_query); $categories_array = array($category_info['categories_id']); tep_get_parents($categories_array, $category_info['categories_id']); } else { $categories_array = $cPath_array; } if (!is_array($categories_array)) { $categories_array = array(); } $categories_string = ''; $categories_query = tep_db_query("select c.categories_id, c.products_types_id, cd.categories_name from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_status = '1' and categories_listing_status = '1' and c.parent_id = '" . (int) $parent_id . "'" . (strlen($products_types_id) > 0 ? " and c.products_types_id = '" . (int) $products_types_id . "'" : "") . " and c.categories_id = cd.categories_id and cd.language_id = '" . (int) DEFAULT_LANGUAGE_ID . "'" . (is_array($only_categories) ? " and c.categories_id in ('" . implode("', '", array_map('tep_string_to_int', $only_categories)) . "')" : "") . " order by c.sort_order, cd.categories_name"); $categories_count = tep_db_num_rows($categories_query); if ($categories_count > 0) { $i = 0; $categories_string = ''; while ($categories = tep_db_fetch_array($categories_query)) { $active = false; if (in_array($categories['categories_id'], $categories_array)) { $active = true; } $link = tep_href_link(FILENAME_CATEGORIES, 'tPath=' . $categories['products_types_id'] . '&cPath=' . $categories['categories_id']); $next_level = ''; if (in_array($categories['categories_id'], $categories_array)) { $next_level = tep_show_category($categories['categories_id'], $level + 1, $only_categories, $products_types_id); } if (tep_not_null($categories['categories_name'])) { $categories_string .= ' <div class="li' . ($i == 0 && $level == 0 ? '_first' : '') . '"><div class="level_' . $level . '"><a href="' . $link . '"' . ($active ? ' class="active"' : '') . (!empty($next_level11) ? ' onclick="if (document.getElementById(\'loader\')) { getXMLDOM(\'' . tep_href_link(FILENAME_LOADER, 'categories_id=' . $categories['categories_id']) . '\', \'loader\'); return false; }"' : '') . '>' . $categories['categories_name'] . '</a></div></div>' . "\n"; } $categories_string .= $next_level; $i++; } } return $categories_string; }
function show_categories($options) { global $xoopsDB, $xoopsConfig, $xoopsTpl, $xoopsConfig; include_once XOOPS_ROOT_PATH . "/modules/osC/includes/configure.php"; include_once XOOPS_ROOT_PATH . "/modules/osC/includes/database_tables.php"; include_once XOOPS_ROOT_PATH . "/modules/osC/includes/filenames.php"; include_once XOOPS_ROOT_PATH . "/modules/osC/includes/functions/database.php"; include_once XOOPS_ROOT_PATH . "/modules/osC/includes/functions/sessions.php"; include_once XOOPS_ROOT_PATH . "/modules/osC/includes/functions/general.php"; include_once XOOPS_ROOT_PATH . "/modules/osC/includes/functions/html_output.php"; include_once XOOPS_ROOT_PATH . "/modules/osC/includes/classes/boxes.php"; $cPath = ''; $cPath_array = array(); $categories_string = ""; if (!defined('XBLOCK_CONFIG')) { $configuration_query = tep_db_query('select configuration_key as cfgKey, configuration_value as cfgValue from ' . TABLE_CONFIGURATION); while ($configuration = tep_db_fetch_array($configuration_query)) { define($configuration['cfgKey'], $configuration['cfgValue']); } define('XBLOCK_CONFIG', "1"); } if (!isset($_SESSION['languages_id'])) { $lang_query = "select languages_id from " . TABLE_LANGUAGES . " where directory ='" . $xoopsConfig['language'] . "'"; $lang = tep_db_query($lang_query); $lang_id = tep_db_fetch_array($lang); $languages_id = $lang_id['languages_id']; } else { $languages_id = $_SESSION['languages_id']; } $info_box_contents = array(); $info_box_contents[] = array('text' => BOX_HEADING_CATEGORIES); // $cat_list_head = new infoBoxHeading($info_box_contents, true, false); // $categories_string = $cat_list_head->content; // $categories_string = ''; $tree = array(); $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '0' and c.categories_status = 1 and c.categories_id = cd.categories_id and cd.language_id='" . (int) $languages_id . "' order by sort_order, cd.categories_name"); while ($categories = tep_db_fetch_array($categories_query)) { $tree[$categories['categories_id']] = array('name' => $categories['categories_name'], 'parent' => $categories['parent_id'], 'level' => 0, 'path' => $categories['categories_id'], 'next_id' => false); if (isset($parent_id)) { $tree[$parent_id]['next_id'] = $categories['categories_id']; } $parent_id = $categories['categories_id']; if (!isset($first_element)) { $first_element = $categories['categories_id']; } } $cPath = isset($_GET['cPath']) ? $_GET['cPath'] : ''; if (tep_not_null($cPath)) { $cPath_array = tep_parse_category_path($cPath); $cPath = implode('_', $cPath_array); $current_category_id = $cPath_array[sizeof($cPath_array) - 1]; } else { $current_category_id = 0; } //------------------------ if (tep_not_null($cPath)) { $new_path = ''; reset($cPath_array); while (list($key, $value) = each($cPath_array)) { unset($parent_id); unset($first_id); $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int) $value . "' and c.categories_status = 1 and c.categories_id = cd.categories_id and cd.language_id='" . (int) $languages_id . "' order by sort_order, cd.categories_name"); if (tep_db_num_rows($categories_query)) { $new_path .= $value; while ($row = tep_db_fetch_array($categories_query)) { $tree[$row['categories_id']] = array('name' => $row['categories_name'], 'parent' => $row['parent_id'], 'level' => $key + 1, 'path' => $new_path . '_' . $row['categories_id'], 'next_id' => false); if (isset($parent_id)) { $tree[$parent_id]['next_id'] = $row['categories_id']; } $parent_id = $row['categories_id']; if (!isset($first_id)) { $first_id = $row['categories_id']; } $last_id = $row['categories_id']; } $tree[$last_id]['next_id'] = $tree[$value]['next_id']; $tree[$value]['next_id'] = $first_id; $new_path .= '_'; } else { break; } } } $categories_string = tep_show_category($first_element, $categories_string, $tree, $cPath_array); $info_box_contents = array(); $info_box_contents[] = array('text' => $categories_string); $cat_list = new infoBox($info_box_contents); // print_r($tree); // $xoopsTpl->assign("cat_list",$cat_list->content); return $cat_list->content; }
function tep_show_category($counter) { $boxContent = ''; $catlevel = '0'; $boxContent .= '<table border="0" cellpadding="0" cellspacing="0" width="100%">'; // BoF - Contribution Category Box Enhancement 1.1 global $tree, $boxContent, $cPath_array, $cat_name, $customer_group_id, $box_width; $cPath_new = 'cPath=' . $tree[$counter]['path']; $boxContent .= '<table border="0" cellpadding="0" cellspacing="0" width="100%"><tr'; for ($i = 0; $i < $tree[$counter]['level']; $i++) { $catlevel .= $i; } $boxContent .= ' class="level' . $catlevel . '">'; // Add control for detecting last item in menu if ($tree[$counter]['next_id'] != false) { $boxContent .= '<td width="' . $box_width . '" class="menuItem">'; } else { $boxContent .= '<td width="' . $box_width . '" class="menuItemLast">'; } for ($i = 0; $i < $tree[$counter]['level']; $i++) { $boxContent .= " "; } $boxContent .= '<a class="' . $catlevel . 'level" href="'; $boxContent .= tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">'; if (tep_has_category_subcategories($counter)) { $boxContent .= tep_image(DIR_WS_ICONS . 'pointer_blue.gif', ''); } else { $boxContent .= tep_image(DIR_WS_ICONS . 'pointer_blue_light.gif', ''); } // highlights the active chain if (isset($cPath_array) && in_array($counter, $cPath_array)) { $boxContent .= '<b>'; } if ($cat_name == $tree[$counter]['name']) { $boxContent .= '<span class="selectedCat">'; } // highlights the active category name when it is selected $boxContent .= $tree[$counter]['name']; if (SHOW_COUNTS == 'true') { $products_in_category = tep_count_products_in_category($counter); if ($products_in_category > 0) { $boxContent .= ' (' . $products_in_category . ')'; } } if ($cat_name == $tree[$counter]['name']) { $boxContent .= '</span>'; } if (isset($cPath_array) && in_array($counter, $cPath_array)) { $boxContent .= '</b>'; } // EoF Category Box Enhancement $boxContent .= '</a></td>'; /////////////ADD IN PLUS SIGN //////////////////////// if (tep_has_category_subcategories($counter)) { if ($tree[$counter]['next_id'] != false) { $boxContent .= '<td width="10" class="menuItem"><a class="' . $catlevel . 'level" href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">' . tep_image(DIR_WS_ICONS . 'plus.gif', '') . '</a></td>'; } else { $boxContent .= '<td width="10" class="menuItemLast"><a class="' . $catlevel . 'level" href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">' . tep_image(DIR_WS_ICONS . 'plus.gif', '') . '</a></td>'; } } ////////////////////////////////////////////////////// $boxContent .= '</tr></table>'; // $boxContent .= '<br>'; if ($tree[$counter]['next_id'] != false) { tep_show_category($tree[$counter]['next_id']); } }