/** * Build a categories tree * * @param array $indexedCategories Array with categories where product is indexed (in order to check checkbox) * @param array $categories Categories to list * @param array $current Current category * @param integer $id_category Current category id */ public static function recurseCategoryForInclude($id_obj, $indexedCategories, $categories, $current, $id_category = 1, $id_category_default = null, $has_suite = array()) { global $done; static $irow; $content = ''; if (!isset($done[$current['infos']['id_parent']])) { $done[$current['infos']['id_parent']] = 0; } $done[$current['infos']['id_parent']] += 1; $todo = count($categories[$current['infos']['id_parent']]); $doneC = $done[$current['infos']['id_parent']]; $level = $current['infos']['level_depth'] + 1; $content .= ' <tr class="' . ($irow++ % 2 ? 'alt_row' : '') . '"> <td> <input type="checkbox" name="categoryBox[]" class="categoryBox' . ($id_category_default == $id_category ? ' id_category_default' : '') . '" id="categoryBox_' . $id_category . '" value="' . $id_category . '"' . (in_array($id_category, $indexedCategories) || (int) Tools::getValue('id_category') == $id_category && !(int) $id_obj ? ' checked="checked"' : '') . ' /> </td> <td> ' . $id_category . ' </td> <td>'; for ($i = 2; $i < $level; $i++) { $content .= '<img src="../img/admin/lvl_' . $has_suite[$i - 2] . '.gif" alt="" />'; } $content .= '<img src="../img/admin/' . ($level == 1 ? 'lv1.gif' : 'lv2_' . ($todo == $doneC ? 'f' : 'b') . '.gif') . '" alt="" /> <label for="categoryBox_' . $id_category . '" class="t">' . stripslashes($current['infos']['name']) . '</label></td> </tr>'; if ($level > 1) { $has_suite[] = $todo == $doneC ? 0 : 1; } if (isset($categories[$id_category])) { foreach ($categories[$id_category] as $key => $row) { if ($key != 'infos') { $content .= AdminProductsController::recurseCategoryForInclude($id_obj, $indexedCategories, $categories, $categories[$id_category][$key], $key, $id_category_default, $has_suite); } } } return $content; }