[phpBB Debug] PHP Warning: in file [ROOT]/includes/crs/crs_misc_functions.php on line 37: mime_content_type(): Empty filename or path
[phpBB Debug] PHP Warning: in file [ROOT]/includes/crs/crs_misc_functions.php on line 37: mime_content_type(): Empty filename or path
Zen Cart 源代码 functions_categories.php

Zen Cart 源代码 functions_categories.php




下载文件

文件名: functions_categories.php
文件类型: PHP文件
文件大小: 22.65 KiB
MD5: ab5aa82fc98780c0d9713e340b5b57ad

functions_categories.php - 关闭高亮
  1. <?php
  2. /**
  3.  * functions_categories.php
  4.  *
  5.  * @package functions
  6.  * @copyright Copyright 2003-2009 Zen Cart Development Team
  7.  * @copyright Portions Copyright 2003 osCommerce
  8.  * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
  9.  * @version $Id: functions_categories.php 17534 2010-09-08 19:50:34Z wilt $
  10.  */
  11.  
  12. ////
  13. // Generate a path to categories
  14.   function zen_get_path($current_category_id = '') {
  15.     global $cPath_array, $db;
  16.  
  17.     if (zen_not_null($current_category_id)) {
  18.       $cp_size = sizeof($cPath_array);
  19.       if ($cp_size == 0) {
  20.         $cPath_new = $current_category_id;
  21.       } else {
  22.         $cPath_new = '';
  23.         $last_category_query = "select parent_id
  24.                                from " . TABLE_CATEGORIES . "
  25.                                where categories_id = '" . (int)$cPath_array[($cp_size-1)] . "'";
  26.  
  27.         $last_category = $db->Execute($last_category_query);
  28.  
  29.         $current_category_query = "select parent_id
  30.                                   from " . TABLE_CATEGORIES . "
  31.                                   where categories_id = '" . (int)$current_category_id . "'";
  32.  
  33.         $current_category = $db->Execute($current_category_query);
  34.  
  35.         if ($last_category->fields['parent_id'] == $current_category->fields['parent_id']) {
  36.           for ($i=0; $i<($cp_size-1); $i++) {
  37.             $cPath_new .= '_' . $cPath_array[$i];
  38.           }
  39.         } else {
  40.           for ($i=0; $i<$cp_size; $i++) {
  41.             $cPath_new .= '_' . $cPath_array[$i];
  42.           }
  43.         }
  44.         $cPath_new .= '_' . $current_category_id;
  45.  
  46.         if (substr($cPath_new, 0, 1) == '_') {
  47.           $cPath_new = substr($cPath_new, 1);
  48.         }
  49.       }
  50.     } else {
  51.       $cPath_new = implode('_', $cPath_array);
  52.     }
  53.  
  54.     return 'cPath=' . $cPath_new;
  55.   }
  56.  
  57. ////
  58. // Return the number of products in a category
  59. // TABLES: products, products_to_categories, categories
  60.   function zen_count_products_in_category($category_id, $include_inactive = false) {
  61.     global $db;
  62.     $products_count = 0;
  63.     if ($include_inactive == true) {
  64.       $products_query = "select count(*) as total
  65.                         from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c
  66.                         where p.products_id = p2c.products_id
  67.                         and p2c.categories_id = '" . (int)$category_id . "'";
  68.  
  69.     } else {
  70.       $products_query = "select count(*) as total
  71.                         from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c
  72.                         where p.products_id = p2c.products_id
  73.                         and p.products_status = '1'
  74.                         and p2c.categories_id = '" . (int)$category_id . "'";
  75.  
  76.     }
  77.     $products = $db->Execute($products_query);
  78.     $products_count += $products->fields['total'];
  79.  
  80.     $child_categories_query = "select categories_id
  81.                               from " . TABLE_CATEGORIES . "
  82.                               where parent_id = '" . (int)$category_id . "'";
  83.  
  84.     $child_categories = $db->Execute($child_categories_query);
  85.  
  86.     if ($child_categories->RecordCount() > 0) {
  87.       while (!$child_categories->EOF) {
  88.         $products_count += zen_count_products_in_category($child_categories->fields['categories_id'], $include_inactive);
  89.         $child_categories->MoveNext();
  90.       }
  91.     }
  92.  
  93.     return $products_count;
  94.   }
  95.  
  96. ////
  97. // Return true if the category has subcategories
  98. // TABLES: categories
  99.   function zen_has_category_subcategories($category_id) {
  100.     global $db;
  101.     $child_category_query = "select count(*) as count
  102.                             from " . TABLE_CATEGORIES . "
  103.                             where parent_id = '" . (int)$category_id . "'";
  104.  
  105.     $child_category = $db->Execute($child_category_query);
  106.  
  107.     if ($child_category->fields['count'] > 0) {
  108.       return true;
  109.     } else {
  110.       return false;
  111.     }
  112.   }
  113.  
  114. ////
  115.   function zen_get_categories($categories_array = '', $parent_id = '0', $indent = '', $status_setting = '') {
  116.     global $db;
  117.  
  118.     if (!is_array($categories_array)) $categories_array = array();
  119.  
  120.     // show based on status
  121.     if ($status_setting != '') {
  122.       $zc_status = " c.categories_status='" . (int)$status_setting . "' and ";
  123.     } else {
  124.       $zc_status = '';
  125.     }
  126.  
  127.     $categories_query = "select c.categories_id, cd.categories_name, c.categories_status
  128.                         from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd
  129.                         where " . $zc_status . "
  130.                         parent_id = '" . (int)$parent_id . "'
  131.                         and c.categories_id = cd.categories_id
  132.                         and cd.language_id = '" . (int)$_SESSION['languages_id'] . "'
  133.                         order by sort_order, cd.categories_name";
  134.  
  135.     $categories = $db->Execute($categories_query);
  136.  
  137.     while (!$categories->EOF) {
  138.       $categories_array[] = array('id' => $categories->fields['categories_id'],
  139.                                   'text' => $indent . $categories->fields['categories_name']);
  140.  
  141.       if ($categories->fields['categories_id'] != $parent_id) {
  142.         $categories_array = zen_get_categories($categories_array, $categories->fields['categories_id'], $indent . '&nbsp;&nbsp;', '1');
  143.       }
  144.       $categories->MoveNext();
  145.     }
  146.  
  147.     return $categories_array;
  148.   }
  149.  
  150. ////
  151. // Return all subcategory IDs
  152. // TABLES: categories
  153.   function zen_get_subcategories(&$subcategories_array, $parent_id = 0) {
  154.     global $db;
  155.     $subcategories_query = "select categories_id
  156.                            from " . TABLE_CATEGORIES . "
  157.                            where parent_id = '" . (int)$parent_id . "'";
  158.  
  159.     $subcategories = $db->Execute($subcategories_query);
  160.  
  161.     while (!$subcategories->EOF) {
  162.       $subcategories_array[sizeof($subcategories_array)] = $subcategories->fields['categories_id'];
  163.       if ($subcategories->fields['categories_id'] != $parent_id) {
  164.         zen_get_subcategories($subcategories_array, $subcategories->fields['categories_id']);
  165.       }
  166.       $subcategories->MoveNext();
  167.     }
  168.   }
  169.  
  170.  
  171. ////
  172. // Recursively go through the categories and retreive all parent categories IDs
  173. // TABLES: categories
  174.   function zen_get_parent_categories(&$categories, $categories_id) {
  175.     global $db;
  176.     $parent_categories_query = "select parent_id
  177.                                from " . TABLE_CATEGORIES . "
  178.                                where categories_id = '" . (int)$categories_id . "'";
  179.  
  180.     $parent_categories = $db->Execute($parent_categories_query);
  181.  
  182.     while (!$parent_categories->EOF) {
  183.       if ($parent_categories->fields['parent_id'] == 0) return true;
  184.       $categories[sizeof($categories)] = $parent_categories->fields['parent_id'];
  185.       if ($parent_categories->fields['parent_id'] != $categories_id) {
  186.         zen_get_parent_categories($categories, $parent_categories->fields['parent_id']);
  187.       }
  188.       $parent_categories->MoveNext();
  189.     }
  190.   }
  191.  
  192. ////
  193. // Construct a category path to the product
  194. // TABLES: products_to_categories
  195.   function zen_get_product_path($products_id) {
  196.     global $db;
  197.     $cPath = '';
  198.  
  199.     $category_query = "select p.products_id, p.master_categories_id
  200.                       from " . TABLE_PRODUCTS . " p
  201.                       where p.products_id = '" . (int)$products_id . "' limit 1";
  202.  
  203.  
  204.     $category = $db->Execute($category_query);
  205.  
  206.     if ($category->RecordCount() > 0) {
  207.  
  208.       $categories = array();
  209.       zen_get_parent_categories($categories, $category->fields['master_categories_id']);
  210.  
  211.       $categories = array_reverse($categories);
  212.  
  213.       $cPath = implode('_', $categories);
  214.  
  215.       if (zen_not_null($cPath)) $cPath .= '_';
  216.       $cPath .= $category->fields['master_categories_id'];
  217.     }
  218.  
  219.     return $cPath;
  220.   }
  221.  
  222. ////
  223. // Parse and secure the cPath parameter values
  224.   function zen_parse_category_path($cPath) {
  225. // make sure the category IDs are integers
  226.     $cPath_array = array_map('zen_string_to_int', explode('_', $cPath));
  227.  
  228. // make sure no duplicate category IDs exist which could lock the server in a loop
  229.     $tmp_array = array();
  230.     $n = sizeof($cPath_array);
  231.     for ($i=0; $i<$n; $i++) {
  232.       if (!in_array($cPath_array[$i], $tmp_array)) {
  233.         $tmp_array[] = $cPath_array[$i];
  234.       }
  235.     }
  236.  
  237.     return $tmp_array;
  238.   }
  239.  
  240.   function zen_product_in_category($product_id, $cat_id) {
  241.     global $db;
  242.     $in_cat=false;
  243.     $category_query_raw = "select categories_id from " . TABLE_PRODUCTS_TO_CATEGORIES . "
  244.                           where products_id = '" . (int)$product_id . "'";
  245.  
  246.     $category = $db->Execute($category_query_raw);
  247.  
  248.     while (!$category->EOF) {
  249.       if ($category->fields['categories_id'] == $cat_id) $in_cat = true;
  250.       if (!$in_cat) {
  251.         $parent_categories_query = "select parent_id from " . TABLE_CATEGORIES . "
  252.                                    where categories_id = '" . $category->fields['categories_id'] . "'";
  253.  
  254.         $parent_categories = $db->Execute($parent_categories_query);
  255. //echo 'cat='.$category->fields['categories_id'].'#'. $cat_id;
  256.  
  257.         while (!$parent_categories->EOF) {
  258.           if (($parent_categories->fields['parent_id'] !=0) ) {
  259.             if (!$in_cat) $in_cat = zen_product_in_parent_category($product_id, $cat_id, $parent_categories->fields['parent_id']);
  260.           }
  261.           $parent_categories->MoveNext();
  262.         }
  263.       }
  264.       $category->MoveNext();
  265.     }
  266.     return $in_cat;
  267.   }
  268.  
  269.   function zen_product_in_parent_category($product_id, $cat_id, $parent_cat_id) {
  270.     global $db;
  271. //echo $cat_id . '#' . $parent_cat_id;
  272.     if ($cat_id == $parent_cat_id) {
  273.       $in_cat = true;
  274.     } else {
  275.       $parent_categories_query = "select parent_id from " . TABLE_CATEGORIES . "
  276.                                  where categories_id = '" . (int)$parent_cat_id . "'";
  277.  
  278.       $parent_categories = $db->Execute($parent_categories_query);
  279.  
  280.       while (!$parent_categories->EOF) {
  281.         if ($parent_categories->fields['parent_id'] !=0 && !$in_cat) {
  282.           $in_cat = zen_product_in_parent_category($product_id, $cat_id, $parent_categories->fields['parent_id']);
  283.         }
  284.         $parent_categories->MoveNext();
  285.       }
  286.     }
  287.     return $in_cat;
  288.   }
  289.  
  290.  
  291. ////
  292. // products with name, model and price pulldown
  293.   function zen_draw_products_pull_down($name, $parameters = '', $exclude = '') {
  294.     global $currencies, $db;
  295.  
  296.     if ($exclude == '') {
  297.       $exclude = array();
  298.     }
  299.  
  300.     $select_string = '<select name="' . $name . '"';
  301.  
  302.     if ($parameters) {
  303.       $select_string .= ' ' . $parameters;
  304.     }
  305.  
  306.     $select_string .= '>';
  307.  
  308.     $products = $db->Execute("select p.products_id, pd.products_name, p.products_price
  309.                              from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
  310.                              where p.products_id = pd.products_id
  311.                              and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
  312.                              order by products_name");
  313.  
  314.     while (!$products->EOF) {
  315.       if (!in_array($products->fields['products_id'], $exclude)) {
  316.         $display_price = zen_get_products_base_price($products->fields['products_id']);
  317.         $select_string .= '<option value="' . $products->fields['products_id'] . '">' . $products->fields['products_name'] . ' (' . $currencies->format($display_price) . ')</option>';
  318.       }
  319.       $products->MoveNext();
  320.     }
  321.  
  322.     $select_string .= '</select>';
  323.  
  324.     return $select_string;
  325.   }
  326.  
  327. ////
  328. // product pulldown with attributes
  329.   function zen_draw_products_pull_down_attributes($name, $parameters = '', $exclude = '') {
  330.     global $db, $currencies;
  331.  
  332.     if ($exclude == '') {
  333.       $exclude = array();
  334.     }
  335.  
  336.     $select_string = '<select name="' . $name . '"';
  337.  
  338.     if ($parameters) {
  339.       $select_string .= ' ' . $parameters;
  340.     }
  341.  
  342.     $select_string .= '>';
  343.  
  344.     $new_fields=', p.products_model';
  345.  
  346.     $products = $db->Execute("select distinct p.products_id, pd.products_name, p.products_price" . $new_fields ."
  347.                              from " . TABLE_PRODUCTS . " p, " .
  348.                                        TABLE_PRODUCTS_DESCRIPTION . " pd, " .
  349.                                        TABLE_PRODUCTS_ATTRIBUTES . " pa " ."
  350.                              where p.products_id= pa.products_id and p.products_id = pd.products_id
  351.                              and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
  352.                              order by products_name");
  353.  
  354.     while (!$products->EOF) {
  355.       if (!in_array($products->fields['products_id'], $exclude)) {
  356.         $display_price = zen_get_products_base_price($products->fields['products_id']);
  357.         $select_string .= '<option value="' . $products->fields['products_id'] . '">' . $products->fields['products_name'] . ' (' . TEXT_MODEL . ' ' . $products->fields['products_model'] . ') (' . $currencies->format($display_price) . ')</option>';
  358.       }
  359.       $products->MoveNext();
  360.     }
  361.  
  362.     $select_string .= '</select>';
  363.  
  364.     return $select_string;
  365.   }
  366.  
  367.  
  368. ////
  369. // categories pulldown with products
  370.   function zen_draw_products_pull_down_categories($name, $parameters = '', $exclude = '') {
  371.     global $db, $currencies;
  372.  
  373.     if ($exclude == '') {
  374.       $exclude = array();
  375.     }
  376.  
  377.     $select_string = '<select name="' . $name . '"';
  378.  
  379.     if ($parameters) {
  380.       $select_string .= ' ' . $parameters;
  381.     }
  382.  
  383.     $select_string .= '>';
  384.  
  385.     $categories = $db->Execute("select distinct c.categories_id, cd.categories_name " ."
  386.                                from " . TABLE_CATEGORIES . " c, " .
  387.                                          TABLE_CATEGORIES_DESCRIPTION . " cd, " .
  388.                                          TABLE_PRODUCTS_TO_CATEGORIES . " ptoc " ."
  389.                                where ptoc.categories_id = c.categories_id
  390.                                and c.categories_id = cd.categories_id
  391.                                and cd.language_id = '" . (int)$_SESSION['languages_id'] . "'
  392.                                order by categories_name");
  393.  
  394.     while (!$categories->EOF) {
  395.       if (!in_array($categories->fields['categories_id'], $exclude)) {
  396.         $select_string .= '<option value="' . $categories->fields['categories_id'] . '">' . $categories->fields['categories_name'] . '</option>';
  397.       }
  398.       $categories->MoveNext();
  399.     }
  400.  
  401.     $select_string .= '</select>';
  402.  
  403.     return $select_string;
  404.   }
  405.  
  406. ////
  407. // categories pulldown with products with attributes
  408.   function zen_draw_products_pull_down_categories_attributes($name, $parameters = '', $exclude = '') {
  409.     global $db, $currencies;
  410.  
  411.     if ($exclude == '') {
  412.       $exclude = array();
  413.     }
  414.  
  415.     $select_string = '<select name="' . $name . '"';
  416.  
  417.     if ($parameters) {
  418.       $select_string .= ' ' . $parameters;
  419.     }
  420.  
  421.     $select_string .= '>';
  422.  
  423.     $categories = $db->Execute("select distinct c.categories_id, cd.categories_name " ."
  424.                                from " . TABLE_CATEGORIES . " c, " .
  425.                                          TABLE_CATEGORIES_DESCRIPTION . " cd, " .
  426.                                          TABLE_PRODUCTS_TO_CATEGORIES . " ptoc, " .
  427.                                          TABLE_PRODUCTS_ATTRIBUTES . " pa " ."
  428.                                where pa.products_id= ptoc.products_id
  429.                                and ptoc.categories_id= c.categories_id
  430.                                and c.categories_id = cd.categories_id
  431.                                and cd.language_id = '" . (int)$_SESSION['languages_id'] . "'
  432.                                order by categories_name");
  433.  
  434.     while (!$categories->EOF) {
  435.       if (!in_array($categories->fields['categories_id'], $exclude)) {
  436.         $select_string .= '<option value="' . $categories->fields['categories_id'] . '">' . $categories->fields['categories_name'] . '</option>';
  437.       }
  438.       $categories->MoveNext();
  439.     }
  440.  
  441.     $select_string .= '</select>';
  442.  
  443.     return $select_string;
  444.   }
  445.  
  446. ////
  447. // look up categories product_type
  448.   function zen_get_product_types_to_category($lookup) {
  449.     global $db;
  450.  
  451.     $lookup = str_replace('cPath=','',$lookup);
  452.  
  453.     $sql = "select product_type_id from " . TABLE_PRODUCT_TYPES_TO_CATEGORY . " where category_id='" . (int)$lookup . "'";
  454.     $look_up = $db->Execute($sql);
  455.  
  456.     if ($look_up->RecordCount() > 0) {
  457.       return $look_up->fields['product_type_id'];
  458.     } else {
  459.       return false;
  460.     }
  461.   }
  462.  
  463. //// look up parent categories name
  464.   function zen_get_categories_parent_name($categories_id) {
  465.     global $db;
  466.  
  467.     $lookup_query = "select parent_id from " . TABLE_CATEGORIES . " where categories_id='" . (int)$categories_id . "'";
  468.     $lookup = $db->Execute($lookup_query);
  469.  
  470.     $lookup_query = "select categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id='" . (int)$lookup->fields['parent_id'] . "' and language_id= " . $_SESSION['languages_id'];
  471.     $lookup = $db->Execute($lookup_query);
  472.  
  473.     return $lookup->fields['categories_name'];
  474.   }
  475.  
  476. ////
  477. // Get all products_id in a Category and its SubCategories
  478. // use as:
  479. // $my_products_id_list = array();
  480. // $my_products_id_list = zen_get_categories_products_list($categories_id)
  481.   function zen_get_categories_products_list($categories_id, $include_deactivated = false, $include_child = true, $parent_category = '0', $display_limit = '') {
  482.     global $db;
  483.     global $categories_products_id_list;
  484.     $childCatID = str_replace('_', '', substr($categories_id, strrpos($categories_id, '_')));
  485.  
  486.     $current_cPath = ($parent_category != '0' ? $parent_category . '_' : '') . $categories_id;
  487.  
  488.     $sql = "select p.products_id
  489.            from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c
  490.            where p.products_id = p2c.products_id
  491.            and p2c.categories_id = '" . (int)$childCatID . "'" .
  492.             ($include_deactivated ? " and p.products_status = 1" : "") .
  493.             $display_limit;
  494.  
  495.     $products = $db->Execute($sql);
  496.     while (!$products->EOF) {
  497.       $categories_products_id_list[$products->fields['products_id']] = $current_cPath;
  498.       $products->MoveNext();
  499.     }
  500.  
  501.     if ($include_child) {
  502.       $sql = "select categories_id from " . TABLE_CATEGORIES . "
  503.              where parent_id = '" . (int)$childCatID . "'";
  504.  
  505.       $childs = $db->Execute($sql);
  506.       if ($childs->RecordCount() > 0 ) {
  507.         while (!$childs->EOF) {
  508.           zen_get_categories_products_list($childs->fields['categories_id'], $include_deactivated, $include_child, $current_cPath, $display_limit);
  509.           $childs->MoveNext();
  510.         }
  511.       }
  512.     }
  513.     return $categories_products_id_list;
  514.   }
  515.  
  516. //// bof: manage master_categories_id vs cPath
  517.   function zen_generate_category_path($id, $from = 'category', $categories_array = '', $index = 0) {
  518.     global $db;
  519.  
  520.     if (!is_array($categories_array)) $categories_array = array();
  521.  
  522.     if ($from == 'product') {
  523.       $categories = $db->Execute("select categories_id
  524.                                  from " . TABLE_PRODUCTS_TO_CATEGORIES . "
  525.                                  where products_id = '" . (int)$id . "'");
  526.  
  527.       while (!$categories->EOF) {
  528.         if ($categories->fields['categories_id'] == '0') {
  529.           $categories_array[$index][] = array('id' => '0', 'text' => TEXT_TOP);
  530.         } else {
  531.           $category = $db->Execute("select cd.categories_name, c.parent_id
  532.                                    from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd
  533.                                    where c.categories_id = '" . (int)$categories->fields['categories_id'] . "'
  534.                                    and c.categories_id = cd.categories_id
  535.                                    and cd.language_id = '" . (int)$_SESSION['languages_id'] . "'");
  536.  
  537.           $categories_array[$index][] = array('id' => $categories->fields['categories_id'], 'text' => $category->fields['categories_name']);
  538.           if ( (zen_not_null($category->fields['parent_id'])) && ($category->fields['parent_id'] != '0') ) $categories_array = zen_generate_category_path($category->fields['parent_id'], 'category', $categories_array, $index);
  539.           $categories_array[$index] = array_reverse($categories_array[$index]);
  540.         }
  541.         $index++;
  542.         $categories->MoveNext();
  543.       }
  544.     } elseif ($from == 'category') {
  545.       $category = $db->Execute("select cd.categories_name, c.parent_id
  546.                                from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd
  547.                                where c.categories_id = '" . (int)$id . "'
  548.                                and c.categories_id = cd.categories_id
  549.                                and cd.language_id = '" . (int)$_SESSION['languages_id'] . "'");
  550.  
  551.       $categories_array[$index][] = array('id' => $id, 'text' => $category->fields['categories_name']);
  552.       if ( (zen_not_null($category->fields['parent_id'])) && ($category->fields['parent_id'] != '0') ) $categories_array = zen_generate_category_path($category->fields['parent_id'], 'category', $categories_array, $index);
  553.     }
  554.  
  555.     return $categories_array;
  556.   }
  557.  
  558.   function zen_output_generated_category_path($id, $from = 'category') {
  559.     $calculated_category_path_string = '';
  560.     $calculated_category_path = zen_generate_category_path($id, $from);
  561.     for ($i=0, $n=sizeof($calculated_category_path); $i<$n; $i++) {
  562.       for ($j=0, $k=sizeof($calculated_category_path[$i]); $j<$k; $j++) {
  563. //        $calculated_category_path_string .= $calculated_category_path[$i][$j]['text'] . '&nbsp;&gt;&nbsp;';
  564.         $calculated_category_path_string = $calculated_category_path[$i][$j]['text'] . '&nbsp;&gt;&nbsp;' . $calculated_category_path_string;
  565.       }
  566.       $calculated_category_path_string = substr($calculated_category_path_string, 0, -16) . '<br>';
  567.     }
  568.     $calculated_category_path_string = substr($calculated_category_path_string, 0, -4);
  569.  
  570.     if (strlen($calculated_category_path_string) < 1) $calculated_category_path_string = TEXT_TOP;
  571.  
  572.     return $calculated_category_path_string;
  573.   }
  574.  
  575.   function zen_get_generated_category_path_ids($id, $from = 'category') {
  576.     global $db;
  577.     $calculated_category_path_string = '';
  578.     $calculated_category_path = zen_generate_category_path($id, $from);
  579.     for ($i=0, $n=sizeof($calculated_category_path); $i<$n; $i++) {
  580.       for ($j=0, $k=sizeof($calculated_category_path[$i]); $j<$k; $j++) {
  581.         $calculated_category_path_string .= $calculated_category_path[$i][$j]['id'] . '_';
  582.       }
  583.       $calculated_category_path_string = substr($calculated_category_path_string, 0, -1) . '<br>';
  584.     }
  585.     $calculated_category_path_string = substr($calculated_category_path_string, 0, -4);
  586.  
  587.     if (strlen($calculated_category_path_string) < 1) $calculated_category_path_string = TEXT_TOP;
  588.  
  589.     return $calculated_category_path_string;
  590.   }
  591.  
  592.   function zen_get_generated_category_path_rev($this_categories_id) {
  593.     $categories = array();
  594.     zen_get_parent_categories($categories, $this_categories_id);
  595.  
  596.     $categories = array_reverse($categories);
  597.  
  598.     $categories_imploded = implode('_', $categories);
  599.  
  600.     if (zen_not_null($categories_imploded)) $categories_imploded .= '_';
  601.     $categories_imploded .= $this_categories_id;
  602.  
  603.     return $categories_imploded;
  604.   }
  605. //// bof: manage master_categories_id vs cPath
  606.  
  607. ?>


cron