Witam. Jestem w trakcie pisania pracy i większość strony robiona jest graficznie bez większej ingerencji w źródło, a że z PHP jestem od niedawna dlatego też nie znam jeszcze wszystkiego dokładnie. Jeśli ktoś ma chwilę czasu i chęci to proszę o ogólniejsze objaśnienie wierszy w podanym kodzie. Z góry bardzo dziękuję.

  1. <?php
  2.  
  3.  if (isset($cPath_array)) {
  4. for ($i=0, $n=sizeof($cPath_array); $i<$n; $i++) {
  5. $categories_query = tep_db_query("select categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . (int)$cPath_array[$i] . "' and language_id = '" . (int)$languages_id . "'");
  6. if (tep_db_num_rows($categories_query) > 0)
  7. $categories = tep_db_fetch_array($categories_query);
  8. }
  9. $cat_name = $categories['categories_name']; 
  10. }
  11.  
  12.  
  13. $info_box_contents = array();
  14. $info_box_contents[] = array('text' => BOX_HEADING_CATEGORIES);
  15.  
  16. new infoBoxHeading($info_box_contents, true, true);
  17.  
  18. $categories_string = '';
  19.  
  20.  
  21.  
  22. $tree = array();
  23.  
  24. $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_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' order by sort_order, cd.categories_name");
  25. while ($categories = tep_db_fetch_array($categories_query)) {
  26. $tree[$categories['categories_id']] = array('name' => $categories['categories_name'],
  27. 'parent' => $categories['parent_id'],
  28. 'level' => 0,
  29. 'path' => $categories['categories_id'],
  30. 'next_id' => false);
  31.  
  32. if (isset($parent_id)) {
  33. $tree[$parent_id]['next_id'] = $categories['categories_id'];
  34. }
  35.  
  36. $parent_id = $categories['categories_id'];
  37.  
  38. if (!isset($first_element)) {
  39. $first_element = $categories['categories_id'];
  40. }
  41. }
  42.  
  43.  
  44. if (tep_not_null($cPath)) {
  45. $new_path = '';
  46. reset($cPath_array);
  47. while (list($key, $value) = each($cPath_array)) {
  48. unset($parent_id);
  49. unset($first_id);
  50. $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_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' order by sort_order, cd.categories_name");
  51. if (tep_db_num_rows($categories_query)) {
  52. $new_path .= $value;
  53. while ($row = tep_db_fetch_array($categories_query)) {
  54. $tree[$row['categories_id']] = array('name' => $row['categories_name'],
  55.  'parent' => $row['parent_id'],
  56.  'level' => $key+1,
  57.  'path' => $new_path . '_' . $row['categories_id'],
  58.  'next_id' => false);
  59.  
  60. if (isset($parent_id)) {
  61. $tree[$parent_id]['next_id'] = $row['categories_id'];
  62. }
  63.  
  64. $parent_id = $row['categories_id'];
  65.  
  66. if (!isset($first_id)) {
  67. $first_id = $row['categories_id'];
  68. }
  69.  
  70. $last_id = $row['categories_id'];
  71. }
  72. $tree[$last_id]['next_id'] = $tree[$value]['next_id'];
  73. $tree[$value]['next_id'] = $first_id;
  74. $new_path .= '_';
  75. } else {
  76. break;
  77. }
  78. }
  79. }
  80. tep_show_category($first_element); 
  81.  
  82. if (ALLOW_QUICK_SEARCH_DESCRIPTION == 'true') {
  83. $param = '<input type="hidden" name="search_in_description" value="1">';
  84. } else {
  85. $param = '';
  86. }
  87. $hide = tep_hide_session_id();
  88.  
  89. $info_box_contents = array();
  90. $info_box_contents[] = array('text' => $categories_string);
  91.  
  92.  
  93.  
  94. new infoBox($info_box_contents);
  95. ?>