function remove_categories($category_id) { $categories = olc_get_category_tree($category_id, '', '0', '', true); $products = array(); $products_delete = array(); for ($i = 0, $n = sizeof($categories); $i < $n; $i++) { $product_ids_query = olc_db_query("SELECT products_id\n\t\t\t\t\t\t \t FROM " . TABLE_PRODUCTS_TO_CATEGORIES . "\n\t\t\t\t\t\t \t WHERE categories_id = '" . $categories[$i]['id'] . "'"); while ($product_ids = olc_db_fetch_array($product_ids_query)) { $products[$product_ids['products_id']]['categories'][] = $categories[$i]['id']; } } reset($products); while (list($key, $value) = each($products)) { $category_ids = ''; for ($i = 0, $n = sizeof($value['categories']); $i < $n; $i++) { $category_ids .= '\'' . $value['categories'][$i] . '\', '; } $category_ids = substr($category_ids, 0, -2); $check_query = olc_db_query("SELECT COUNT(*) AS total\n\t\t\t\t\t\t \t FROM " . TABLE_PRODUCTS_TO_CATEGORIES . "\n\t\t\t\t\t\t \t WHERE products_id = '" . $key . "'\n\t\t\t\t\t\t \t AND categories_id NOT IN (" . $category_ids . ")"); $check = olc_db_fetch_array($check_query); if ($check['total'] < '1') { $products_delete[$key] = $key; } } // Removing categories can be a lengthy process @olc_set_time_limit(0); for ($i = 0, $n = sizeof($categories); $i < $n; $i++) { $this->remove_category($categories[$i]['id']); } reset($products_delete); while (list($key) = each($products_delete)) { $this->remove_product($key); } }
</td> <td class="pageHeading" align="right"><?php echo olc_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?> </td> </tr> <?php //Medreces insert Filter categories & manufactures !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ?> <tr class="dataTableHeadingRow"><?php echo olc_draw_form('filter_xsell_products', FILENAME_XSELL_PRODUCTS, $first_entrance ? '' : olc_get_all_get_params()); ?> <td class="dataTableHeadingRow" align="left">Set Filters</td> <td class="smallText" align="right"> <?php echo 'to Categories: ' . olc_draw_pull_down_menu('categories_id', olc_get_category_tree(), $CATEGORIES_id); echo '<br/>to Manufacturers: ' . olc_draw_pull_down_menu('manufacturers_id', $manufacturers_array, $MANUFACTURES_id); ?> </td> <td class="dataTableContent" align="right"><?php echo olc_image_submit('button_select.gif', 'GO!!!'); ?> </td> </form></tr> <?php // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ?> </table> </td> </tr> <!-- body_text //-->
$categories_contained = olc_output_generated_category_path($pInfo->products_id, 'product'); $contents[] = array('text' => HTML_BR . TEXT_INFO_CURRENT_CATEGORIES . '<br/><b>' . $categories_contained . HTML_B_END); if (QUICKLINK_ACTIVATED == TRUE_STRING_S) { $contents[] = array('text' => '<hr noshade="noshade"/>'); $contents[] = array('text' => HTML_B_START . TEXT_MULTICOPY . '</b><br/>' . TEXT_MULTICOPY_DESC); $cat_tree = olc_get_category_tree(); $tree = EMPTY_STRING; for ($i = 0; $n = sizeof($cat_tree), $i < $n; $i++) { $cat_tree_text = $cat_tree[$i]['text']; //$tree .='<input type="checkbox" name="cat_ids[]" value="'.$cat_tree[$i]['id'].'"><font size="1">' $tree .= olc_draw_checkbox_field('cat_ids[]', $cat_tree[$i]['id'], !(strpos($categories_contained, str_replace(HTML_NBSP, EMPTY_STRING, $cat_tree_text)) === false)) . $cat_tree_text . '</font><br/>'; } $contents[] = array('text' => $tree . '<br/><hr noshade="noshade"/>'); $contents[] = array('text' => HTML_B_START . TEXT_SINGLECOPY . '</b><br/>' . TEXT_SINGLECOPY_DESC); } $contents[] = array('text' => HTML_BR . TEXT_CATEGORIES . HTML_BR . olc_draw_pull_down_menu('categories_id', olc_get_category_tree(), $current_category_id)); $contents[] = array('text' => HTML_BR . TEXT_HOW_TO_COPY . HTML_BR . olc_draw_radio_field('copy_as', 'link', true) . HTML_NBSP . TEXT_COPY_AS_LINK . HTML_BR . olc_draw_radio_field('copy_as', 'duplicate') . HTML_NBSP . TEXT_COPY_AS_DUPLICATE); $contents[] = array('align' => 'center', 'text' => HTML_BR . olc_image_submit('button_copy.gif', IMAGE_COPY) . BLANK . HTML_A_START . olc_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $pInfo->products_id) . '">' . olc_image_button('button_cancel.gif', IMAGE_CANCEL) . HTML_A_END); break; default: if ($rows > 0) { if (is_object($cInfo)) { // category info box contents $heading[] = array('text' => HTML_B_START . $cInfo->categories_name . HTML_B_END); $contents[] = array('align' => 'center', 'text' => HTML_A_START . olc_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $cInfo->categories_id . '&action=edit_category') . '">' . olc_image_button('button_edit.gif', IMAGE_EDIT) . '</a> <a href="' . olc_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $cInfo->categories_id . '&action=delete_category') . '">' . olc_image_button('button_delete.gif', IMAGE_DELETE) . '</a> <a href="' . olc_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $cInfo->categories_id . '&action=move_category') . '">' . olc_image_button('button_move.gif', IMAGE_MOVE) . HTML_A_END); $contents[] = array('text' => HTML_BR . TEXT_DATE_ADDED . HTML_NBSP . olc_date_short($cInfo->date_added)); if (olc_not_null($cInfo->last_modified)) { $contents[] = array('text' => TEXT_LAST_MODIFIED . HTML_NBSP . olc_date_short($cInfo->last_modified)); } $contents[] = array('text' => HTML_BR . olc_info_image_c($cInfo->categories_image, $cInfo->categories_name) . HTML_BR . $cInfo->categories_image);
} if (!$categories_image) { $categories_image = $_POST['categories_previous_image']; } if ($categories_image) { olc_db_query(SQL_UPDATE . TABLE_CATEGORIES . " set categories_image = '" . olc_db_input($categories_image) . "' where categories_id = " . $categories_id); } //olc_redirect(olc_href_link(FILENAME_CATEGORIES, $cPath_parameter . $cID_text . $categories_id)); $cID = $categories_id; $action0 = EMPTY_STRING; } break; case 'delete_category_confirm': if ($_POST[$categories_id_text]) { $categories_id = olc_db_prepare_input($_POST[$categories_id_text]); $categories = olc_get_category_tree($categories_id, EMPTY_STRING, '0', EMPTY_STRING, true); $products = array(); $products_delete = array(); for ($i = 0, $n = sizeof($categories); $i < $n; $i++) { $product_ids_query = olc_db_query("select products_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id = '" . $categories[$i]['id'] . APOS); while ($product_ids = olc_db_fetch_array($product_ids_query)) { $products[$product_ids[$products_id_text]]['categories'][] = $categories[$i]['id']; } } reset($products); while (list($key, $value) = each($products)) { $category_ids = EMPTY_STRING; for ($i = 0, $n = sizeof($value['categories']); $i < $n; $i++) { if ($category_ids) { $category_ids .= COMMA; }
function olc_get_category_tree($parent_id = '0', $spacing = '', $exclude = '', $category_tree_array = '', $include_itself = false) { if (!is_array($category_tree_array)) { $category_tree_array = array(); } if (sizeof($category_tree_array) < 1 && $exclude != '0') { $category_tree_array[] = array('id' => '0', 'text' => TEXT_TOP); } if ($include_itself) { $category_query = olc_db_query(SELECT . "cd.categories_name" . SQL_FROM . TABLE_CATEGORIES_DESCRIPTION . " cd\n\t\t\twhere cd.language_id = '" . SESSION_LANGUAGE_ID . "' and cd.categories_id = '" . $parent_id . APOS); $category = olc_db_fetch_array($category_query); $category_tree_array[] = array('id' => $parent_id, 'text' => $category['categories_name']); } $spacer = HTML_NBSP . HTML_NBSP . HTML_NBSP; $categories_query = olc_db_query(SELECT . "c.categories_id, cd.categories_name, c.parent_id" . SQL_FROM . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = cd.categories_id and cd.language_id = " . SESSION_LANGUAGE_ID . " and c.parent_id = " . $parent_id . " order by c.sort_order, cd.categories_name"); while ($categories = olc_db_fetch_array($categories_query)) { $categories_id = $categories['categories_id']; if ($exclude != $categories_id) { $category_tree_array[] = array('id' => $categories_id, 'text' => $spacing . $categories['categories_name']); } $category_tree_array = olc_get_category_tree($categories_id, $spacing . $spacer, $exclude, $category_tree_array); } return $category_tree_array; }