Code Duplication    Length = 28-30 lines in 2 locations

catalog/admin/includes/functions/general.php 1 location

@@ 92-119 (lines=28) @@
89
      } else {
90
        $cPath_new = implode('_', $cPath_array);
91
      }
92
    } else {
93
      if (!isset($cPath_array) || (sizeof($cPath_array) == 0)) {
94
        $cPath_new = $current_category_id;
95
      } else {
96
        $cPath_new = '';
97
        $last_category_query = tep_db_query("select parent_id from " . TABLE_CATEGORIES . " where categories_id = '" . (int)$cPath_array[(sizeof($cPath_array)-1)] . "'");
98
        $last_category = tep_db_fetch_array($last_category_query);
99
100
        $current_category_query = tep_db_query("select parent_id from " . TABLE_CATEGORIES . " where categories_id = '" . (int)$current_category_id . "'");
101
        $current_category = tep_db_fetch_array($current_category_query);
102
103
        if ($last_category['parent_id'] == $current_category['parent_id']) {
104
          for ($i = 0, $n = sizeof($cPath_array) - 1; $i < $n; $i++) {
105
            $cPath_new .= '_' . $cPath_array[$i];
106
          }
107
        } else {
108
          for ($i = 0, $n = sizeof($cPath_array); $i < $n; $i++) {
109
            $cPath_new .= '_' . $cPath_array[$i];
110
          }
111
        }
112
113
        $cPath_new .= '_' . $current_category_id;
114
115
        if (substr($cPath_new, 0, 1) == '_') {
116
          $cPath_new = substr($cPath_new, 1);
117
        }
118
      }
119
    }
120
121
    return 'cPath=' . $cPath_new;
122
  }

catalog/includes/functions/general.php 1 location

@@ 226-255 (lines=30) @@
223
  function tep_get_path($current_category_id = '') {
224
    global $cPath_array;
225
226
    if (tep_not_null($current_category_id)) {
227
      $cp_size = sizeof($cPath_array);
228
      if ($cp_size == 0) {
229
        $cPath_new = $current_category_id;
230
      } else {
231
        $cPath_new = '';
232
        $last_category_query = tep_db_query("select parent_id from " . TABLE_CATEGORIES . " where categories_id = '" . (int)$cPath_array[($cp_size-1)] . "'");
233
        $last_category = tep_db_fetch_array($last_category_query);
234
235
        $current_category_query = tep_db_query("select parent_id from " . TABLE_CATEGORIES . " where categories_id = '" . (int)$current_category_id . "'");
236
        $current_category = tep_db_fetch_array($current_category_query);
237
238
        if ($last_category['parent_id'] == $current_category['parent_id']) {
239
          for ($i=0; $i<($cp_size-1); $i++) {
240
            $cPath_new .= '_' . $cPath_array[$i];
241
          }
242
        } else {
243
          for ($i=0; $i<$cp_size; $i++) {
244
            $cPath_new .= '_' . $cPath_array[$i];
245
          }
246
        }
247
        $cPath_new .= '_' . $current_category_id;
248
249
        if (substr($cPath_new, 0, 1) == '_') {
250
          $cPath_new = substr($cPath_new, 1);
251
        }
252
      }
253
    } else {
254
      $cPath_new = implode('_', $cPath_array);
255
    }
256
257
    return 'cPath=' . $cPath_new;
258
  }