Jump to content
Sign in to follow this  
lemonsensation

[Contribution] Category Descriptions MS2

Recommended Posts

It is from the admin/categories.php

 

here is the file:

<?php

/*

$Id: categories.php,v 1.146 2003/07/11 14:40:27 hpdl Exp $

 

adapted for Separate Pricing Per Customer v4.1.1 2005/03/20

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright (c) 2003 osCommerce

 

Released under the GNU General Public License

*/

 

require('includes/application_top.php');

 

require('includes/functions/categories_description.php');

 

require(DIR_WS_CLASSES . 'currencies.php');

$currencies = new currencies();

 

$action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');

 

if (tep_not_null($action)) {

switch ($action) {

case 'setflag':

if ( ($HTTP_GET_VARS['flag'] == '0') || ($HTTP_GET_VARS['flag'] == '1') ) {

if (isset($HTTP_GET_VARS['pID'])) {

tep_set_product_status($HTTP_GET_VARS['pID'], $HTTP_GET_VARS['flag']);

}

 

if (USE_CACHE == 'true') {

tep_reset_cache_block('categories');

tep_reset_cache_block('also_purchased');

}

}

 

tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $HTTP_GET_VARS['cPath'] . '&pID=' . $HTTP_GET_VARS['pID']));

break;

case 'new_category':

 

case 'edit_category':

 

if (ALLOW_CATEGORY_DESCRIPTIONS == 'true')

 

$HTTP_GET_VARS['action']=$HTTP_GET_VARS['action'] . '_ACD';

 

break;

case 'insert_category':

case 'update_category':

if ( ($HTTP_POST_VARS['edit_x']) || ($HTTP_POST_VARS['edit_y']) ) {

 

$HTTP_GET_VARS['action'] = 'edit_category_ACD';

 

} else {

if (isset($HTTP_POST_VARS['categories_id'])) $categories_id = tep_db_prepare_input($HTTP_POST_VARS['categories_id']);

if ($categories_id == '') {

 

$categories_id = tep_db_prepare_input($HTTP_GET_VARS['cID']);

 

}

}

if ($categories_id == '') {

 

$categories_id = tep_db_prepare_input($HTTP_GET_VARS['cID']);

 

}

$sort_order = tep_db_prepare_input($HTTP_POST_VARS['sort_order']);

 

$sql_data_array = array('sort_order' => $sort_order);

 

if ($action == 'insert_category') {

$insert_sql_data = array('parent_id' => $current_category_id,

'date_added' => 'now()');

 

$sql_data_array = array_merge($sql_data_array, $insert_sql_data);

 

tep_db_perform(TABLE_CATEGORIES, $sql_data_array);

 

$categories_id = tep_db_insert_id();

} elseif ($action == 'update_category') {

$update_sql_data = array('last_modified' => 'now()');

 

$sql_data_array = array_merge($sql_data_array, $update_sql_data);

 

tep_db_perform(TABLE_CATEGORIES, $sql_data_array, 'update', "categories_id = '" . (int)$categories_id . "'");

}

 

$languages = tep_get_languages();

for ($i=0, $n=sizeof($languages); $i<$n; $i++) {

$categories_name_array = $HTTP_POST_VARS['categories_name'];

 

//HTC BOC

 

$categories_htc_title_array = $HTTP_POST_VARS['categories_htc_title_tag'];

 

$categories_htc_desc_array = $HTTP_POST_VARS['categories_htc_desc_tag'];

 

$categories_htc_keywords_array = $HTTP_POST_VARS['categories_htc_keywords_tag'];

 

$categories_htc_description_array = $HTTP_POST_VARS['categories_htc_description'];

 

//HTC EOC

 

$language_id = $languages[$i]['id'];

 

//HTC BOC

 

$sql_data_array = array('categories_name' => tep_db_prepare_input($categories_name_array[$language_id]),

 

'categories_htc_title_tag' => (tep_not_null($categories_htc_title_array[$language_id]) ? tep_db_prepare_input($categories_htc_title_array[$language_id]) : tep_db_prepare_input($categories_name_array[$language_id])),

 

'categories_htc_desc_tag' => (tep_not_null($categories_htc_desc_array[$language_id]) ? tep_db_prepare_input($categories_htc_desc_array[$language_id]) : tep_db_prepare_input($categories_name_array[$language_id])),

 

'categories_htc_keywords_tag' => (tep_not_null($categories_htc_keywords_array[$language_id]) ? tep_db_prepare_input($categories_htc_keywords_array[$language_id]) : tep_db_prepare_input($categories_name_array[$language_id])),

 

'categories_htc_description' => tep_db_prepare_input($categories_htc_description_array[$language_id]));

 

//HTC EOC

 

if (ALLOW_CATEGORY_DESCRIPTIONS == 'true') {

 

$sql_data_array = array('categories_name' => tep_db_prepare_input($HTTP_POST_VARS['categories_name'][$language_id]),

 

'categories_heading_title' => tep_db_prepare_input($HTTP_POST_VARS['categories_heading_title'][$language_id]),

 

'categories_description' => tep_db_prepare_input($HTTP_POST_VARS['categories_description'][$language_id]));

 

}

 

if ($action == 'insert_category') {

$insert_sql_data = array('categories_id' => $categories_id,

'language_id' => $languages[$i]['id']);

 

$sql_data_array = array_merge($sql_data_array, $insert_sql_data);

 

tep_db_perform(TABLE_CATEGORIES_DESCRIPTION, $sql_data_array);

} elseif ($action == 'update_category') {

tep_db_perform(TABLE_CATEGORIES_DESCRIPTION, $sql_data_array, 'update', "categories_id = '" . (int)$categories_id . "' and language_id = '" . (int)$languages[$i]['id'] . "'");

}

}

 

if (ALLOW_CATEGORY_DESCRIPTIONS == 'true') {

 

tep_db_query("update " . TABLE_CATEGORIES . " set categories_image = '" . $HTTP_POST_VARS['categories_image'] . "' where categories_id = '" . tep_db_input($categories_id) . "'");

 

$categories_image = '';

 

} else {

 

if ($categories_image = new upload('categories_image', DIR_FS_CATALOG_IMAGES)) {

 

tep_db_query("update " . TABLE_CATEGORIES . " set categories_image = '" . tep_db_input($categories_image->filename) . "' where categories_id = '" . (int)$categories_id . "'");

 

}

 

}

 

if (USE_CACHE == 'true') {

tep_reset_cache_block('categories');

tep_reset_cache_block('also_purchased');

}

 

tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $categories_id));

break;

case 'delete_category_confirm':

if (isset($HTTP_POST_VARS['categories_id'])) {

$categories_id = tep_db_prepare_input($HTTP_POST_VARS['categories_id']);

 

$categories = tep_get_category_tree($categories_id, '', '0', '', true);

$products = array();

$products_delete = array();

 

for ($i=0, $n=sizeof($categories); $i<$n; $i++) {

$product_ids_query = tep_db_query("select products_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id = '" . (int)$categories[$i]['id'] . "'");

 

while ($product_ids = tep_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 .= "'" . (int)$value['categories'][$i] . "', ";

}

$category_ids = substr($category_ids, 0, -2);

 

$check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$key . "' and categories_id not in (" . $category_ids . ")");

$check = tep_db_fetch_array($check_query);

if ($check['total'] < '1') {

$products_delete[$key] = $key;

}

}

 

// removing categories can be a lengthy process

tep_set_time_limit(0);

for ($i=0, $n=sizeof($categories); $i<$n; $i++) {

tep_remove_category($categories[$i]['id']);

}

 

reset($products_delete);

while (list($key) = each($products_delete)) {

tep_remove_product($key);

}

}

 

if (USE_CACHE == 'true') {

tep_reset_cache_block('categories');

tep_reset_cache_block('also_purchased');

}

 

tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath));

break;

case 'delete_product_confirm':

if (isset($HTTP_POST_VARS['products_id']) && isset($HTTP_POST_VARS['product_categories']) && is_array($HTTP_POST_VARS['product_categories'])) {

$product_id = tep_db_prepare_input($HTTP_POST_VARS['products_id']);

$product_categories = $HTTP_POST_VARS['product_categories'];

 

for ($i=0, $n=sizeof($product_categories); $i<$n; $i++) {

tep_db_query("delete from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$product_id . "' and categories_id = '" . (int)$product_categories[$i] . "'");

// BOF Separate Pricing per Customer

tep_db_query("delete from " . TABLE_PRODUCTS_GROUPS . " where products_id = '" . tep_db_input($product_id) . "' ");

// EOF Separate Pricing per Customer

}

 

$product_categories_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$product_id . "'");

$product_categories = tep_db_fetch_array($product_categories_query);

 

if ($product_categories['total'] == '0') {

tep_remove_product($product_id);

// START: Extra Fields Contribution

tep_db_query("delete from " . TABLE_PRODUCTS_TO_PRODUCTS_EXTRA_FIELDS . " where products_id = " . (int)$product_id);

// END: Extra Fields Contribution

}

}

 

if (USE_CACHE == 'true') {

tep_reset_cache_block('categories');

tep_reset_cache_block('also_purchased');

}

 

tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath));

break;

case 'move_category_confirm':

if (isset($HTTP_POST_VARS['categories_id']) && ($HTTP_POST_VARS['categories_id'] != $HTTP_POST_VARS['move_to_category_id'])) {

$categories_id = tep_db_prepare_input($HTTP_POST_VARS['categories_id']);

$new_parent_id = tep_db_prepare_input($HTTP_POST_VARS['move_to_category_id']);

 

$path = explode('_', tep_get_generated_category_path_ids($new_parent_id));

 

if (in_array($categories_id, $path)) {

$messageStack->add_session(ERROR_CANNOT_MOVE_CATEGORY_TO_PARENT, 'error');

 

tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $categories_id));

} else {

tep_db_query("update " . TABLE_CATEGORIES . " set parent_id = '" . (int)$new_parent_id . "', last_modified = now() where categories_id = '" . (int)$categories_id . "'");

 

if (USE_CACHE == 'true') {

tep_reset_cache_block('categories');

tep_reset_cache_block('also_purchased');

}

 

tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $new_parent_id . '&cID=' . $categories_id));

}

}

 

break;

case 'move_product_confirm':

$products_id = tep_db_prepare_input($HTTP_POST_VARS['products_id']);

$new_parent_id = tep_db_prepare_input($HTTP_POST_VARS['move_to_category_id']);

 

$duplicate_check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$products_id . "' and categories_id = '" . (int)$new_parent_id . "'");

$duplicate_check = tep_db_fetch_array($duplicate_check_query);

if ($duplicate_check['total'] < 1) tep_db_query("update " . TABLE_PRODUCTS_TO_CATEGORIES . " set categories_id = '" . (int)$new_parent_id . "' where products_id = '" . (int)$products_id . "' and categories_id = '" . (int)$current_category_id . "'");

 

if (USE_CACHE == 'true') {

tep_reset_cache_block('categories');

tep_reset_cache_block('also_purchased');

}

 

tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $new_parent_id . '&pID=' . $products_id));

break;

case 'insert_product':

case 'update_product':

if (isset($HTTP_POST_VARS['edit_x']) || isset($HTTP_POST_VARS['edit_y'])) {

$action = 'new_product';

} else {

if (isset($HTTP_GET_VARS['pID'])) $products_id = tep_db_prepare_input($HTTP_GET_VARS['pID']);

$products_date_available = tep_db_prepare_input($HTTP_POST_VARS['products_date_available']);

 

$products_date_available = (date('Y-m-d') < $products_date_available) ? $products_date_available : 'null';

 

$sql_data_array = array('products_quantity' => tep_db_prepare_input($HTTP_POST_VARS['products_quantity']),

'products_model' => tep_db_prepare_input($HTTP_POST_VARS['products_model']),

'products_price' => tep_db_prepare_input($HTTP_POST_VARS['products_price']),

'products_date_available' => $products_date_available,

'products_weight' => tep_db_prepare_input($HTTP_POST_VARS['products_weight']),

'products_status' => tep_db_prepare_input($HTTP_POST_VARS['products_status']),

'products_tax_class_id' => tep_db_prepare_input($HTTP_POST_VARS['products_tax_class_id']),

'manufacturers_id' => tep_db_prepare_input($HTTP_POST_VARS['manufacturers_id']),

 

'products_sort_order' => tep_db_prepare_input($HTTP_POST_VARS['products_sort_order']));

 

if (isset($HTTP_POST_VARS['products_image']) && tep_not_null($HTTP_POST_VARS['products_image']) && ($HTTP_POST_VARS['products_image'] != 'none')) {

$sql_data_array['products_image'] = tep_db_prepare_input($HTTP_POST_VARS['products_image']);

}

 

if ($action == 'insert_product') {

$insert_sql_data = array('products_date_added' => 'now()');

 

$sql_data_array = array_merge($sql_data_array, $insert_sql_data);

 

tep_db_perform(TABLE_PRODUCTS, $sql_data_array);

$products_id = tep_db_insert_id();

 

tep_db_query("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . " (products_id, categories_id) values ('" . (int)$products_id . "', '" . (int)$current_category_id . "')");

} elseif ($action == 'update_product') {

$update_sql_data = array('products_last_modified' => 'now()');

 

$sql_data_array = array_merge($sql_data_array, $update_sql_data);

 

tep_db_perform(TABLE_PRODUCTS, $sql_data_array, 'update', "products_id = '" . (int)$products_id . "'");

}

 

// BOF Separate Pricing Per Customer

$customers_group_query = tep_db_query("select customers_group_id, customers_group_name from " . TABLE_CUSTOMERS_GROUPS . " where customers_group_id != '0' order by customers_group_id");

while ($customers_group = tep_db_fetch_array($customers_group_query)) // Gets all of the customers groups

{

$attributes_query = tep_db_query("select customers_group_id, customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where ((products_id = '" . $products_id . "') && (customers_group_id = " . $customers_group['customers_group_id'] . ")) order by customers_group_id");

$attributes = tep_db_fetch_array($attributes_query);

if (tep_db_num_rows($attributes_query) > 0) {

if ($HTTP_POST_VARS['sppcoption'][$customers_group['customers_group_id']]) { // this is checking if the check box is checked

if ( ($HTTP_POST_VARS['sppcprice'][$customers_group['customers_group_id']] <> $attributes['customers_group_price']) && ($attributes['customers_group_id'] == $customers_group['customers_group_id']) ) {

tep_db_query("update " . TABLE_PRODUCTS_GROUPS . " set customers_group_price = '" . $HTTP_POST_VARS['sppcprice'][$customers_group['customers_group_id']] . "' where customers_group_id = '" . $attributes['customers_group_id'] . "' and products_id = '" . $products_id . "'");

$attributes = tep_db_fetch_array($attributes_query);

}

elseif (($HTTP_POST_VARS['sppcprice'][$customers_group['customers_group_id']] == $attributes['customers_group_price'])) {

$attributes = tep_db_fetch_array($attributes_query);

}

}

else {

tep_db_query("delete from " . TABLE_PRODUCTS_GROUPS . " where customers_group_id = '" . $customers_group['customers_group_id'] . "' and products_id = '" . $products_id . "'");

$attributes = tep_db_fetch_array($attributes_query);

}

}

elseif (($HTTP_POST_VARS['sppcoption'][$customers_group['customers_group_id']]) && ($HTTP_POST_VARS['sppcprice'][$customers_group['customers_group_id']] != '')) {

tep_db_query("insert into " . TABLE_PRODUCTS_GROUPS . " (products_id, customers_group_id, customers_group_price) values ('" . $products_id . "', '" . $customers_group['customers_group_id'] . "', '" . $HTTP_POST_VARS['sppcprice'][$customers_group['customers_group_id']] . "')");

$attributes = tep_db_fetch_array($attributes_query);

}

 

}

// EOF Separate Pricing Per Customer

 

$languages = tep_get_languages();

for ($i=0, $n=sizeof($languages); $i<$n; $i++) {

$language_id = $languages[$i]['id'];

 

//HTC BOC

 

$sql_data_array = array('products_name' => tep_db_prepare_input($HTTP_POST_VARS['products_name'][$language_id]),

'products_info' => tep_db_prepare_input($HTTP_POST_VARS['products_info'][$language_id]),

 

'products_description' => tep_db_prepare_input($HTTP_POST_VARS['products_description'][$language_id]),

 

'products_url' => tep_db_prepare_input($HTTP_POST_VARS['products_url'][$language_id]),

 

'products_head_title_tag' => ((tep_not_null($HTTP_POST_VARS['products_head_title_tag'][$language_id])) ? tep_db_prepare_input($HTTP_POST_VARS['products_head_title_tag'][$language_id]) : tep_db_prepare_input($HTTP_POST_VARS['products_name'][$language_id])),

 

'products_head_desc_tag' => ((tep_not_null($HTTP_POST_VARS['products_head_desc_tag'][$language_id])) ? tep_db_prepare_input($HTTP_POST_VARS['products_head_desc_tag'][$language_id]) : tep_db_prepare_input($HTTP_POST_VARS['products_name'][$language_id])),

 

'products_head_keywords_tag' => ((tep_not_null($HTTP_POST_VARS['products_head_keywords_tag'][$language_id])) ? tep_db_prepare_input($HTTP_POST_VARS['products_head_keywords_tag'][$language_id]) : tep_db_prepare_input($HTTP_POST_VARS['products_name'][$language_id])));

 

//HTC EOC

 

if ($action == 'insert_product') {

$insert_sql_data = array('products_id' => $products_id,

'language_id' => $language_id);

 

$sql_data_array = array_merge($sql_data_array, $insert_sql_data);

 

tep_db_perform(TABLE_PRODUCTS_DESCRIPTION, $sql_data_array);

} elseif ($action == 'update_product') {

tep_db_perform(TABLE_PRODUCTS_DESCRIPTION, $sql_data_array, 'update', "products_id = '" . (int)$products_id . "' and language_id = '" . (int)$language_id . "'");

}

}

 

// START: Extra Fields Contribution

$extra_fields_query = tep_db_query("SELECT * FROM " . products_to_products_extra_fields . " WHERE products_id = " . (int)$products_id);

while ($products_extra_fields = tep_db_fetch_array($extra_fields_query)) {

$extra_product_entry[$products_extra_fields['products_extra_fields_id']] = $products_extra_fields['products_extra_fields_value'];

}

 

if ($HTTP_POST_VARS['extra_field']) { // Check to see if there are any need to update extra fields.

foreach ($HTTP_POST_VARS['extra_field'] as $key=>$val) {

if (isset($extra_product_entry[$key])) { // an entry exists

if ($val == '') tep_db_query("DELETE FROM " . products_to_products_extra_fields . " where products_id = " . (int)$products_id . " AND products_extra_fields_id = " . $key);

else tep_db_query("UPDATE " . products_to_products_extra_fields . " SET products_extra_fields_value = '" . tep_db_prepare_input($val) . "' WHERE products_id = " . (int)$products_id . " AND products_extra_fields_id = " . $key);

}

else { // an entry does not exist

if ($val != '') tep_db_query("INSERT INTO " . products_to_products_extra_fields . " (products_id, products_extra_fields_id, products_extra_fields_value) VALUES ('" . (int)$products_id . "', '" . $key . "', '" . tep_db_prepare_input($val) . "')");

}

}

} // Check to see if there are any need to update extra fields.

// END: Extra Fields Contribution

 

 

 

if (USE_CACHE == 'true') {

tep_reset_cache_block('categories');

tep_reset_cache_block('also_purchased');

}

 

tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $products_id));

}

break;

case 'copy_to_confirm':

 

tep_db_query("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . " (products_id, categories_id) values ('" . (int)$dup_products_id . "', '" . (int)$categories_id . "')");

 

 

// BOF Separate Pricing Per Customer 26042006 by Infobroker

 

$customers_group_query = tep_db_query("select customers_group_id, customers_group_name from " . TABLE_CUSTOMERS_GROUPS . " where customers_group_id != '0' order by customers_group_id");

while ($customers_group = tep_db_fetch_array($customers_group_query)) // Gets all of the customers groups

{

$attributes_query = tep_db_query("select customers_group_id, customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where ((products_id = '" . $products_id . "') && (customers_group_id = " . $customers_group['customers_group_id'] . ")) order by customers_group_id");

$attributes = tep_db_fetch_array($attributes_query);

 

tep_db_query("insert into " . TABLE_PRODUCTS_GROUPS . " (customers_group_id, customers_group_price, products_id) values ('" . $attributes['customers_group_id'] . "', '" . tep_db_input($attributes['customers_group_price']) . "', '" . (int)$dup_products_id . "')");

 

 

 

}

// EOF Separate Pricing Per Customer 26042006 by Infobroker

 

if (isset($HTTP_POST_VARS['products_id']) && isset($HTTP_POST_VARS['categories_id'])) {

$products_id = tep_db_prepare_input($HTTP_POST_VARS['products_id']);

$categories_id = tep_db_prepare_input($HTTP_POST_VARS['categories_id']);

 

if ($HTTP_POST_VARS['copy_as'] == 'link') {

if ($categories_id != $current_category_id) {

$check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$products_id . "' and categories_id = '" . (int)$categories_id . "'");

$check = tep_db_fetch_array($check_query);

if ($check['total'] < '1') {

tep_db_query("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . " (products_id, categories_id) values ('" . (int)$products_id . "', '" . (int)$categories_id . "')");

}

} else {

$messageStack->add_session(ERROR_CANNOT_LINK_TO_SAME_CATEGORY, 'error');

}

} elseif ($HTTP_POST_VARS['copy_as'] == 'duplicate') {

// $product_query = tep_db_query("select products_quantity, products_model, products_image, products_price, products_date_available, products_weight, products_tax_class_id, manufacturers_id from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");

//PRODUCT_SORT_ORDER ADDED TO THIS SELECT

 

$product_query = tep_db_query("select products_quantity, products_model, products_image, products_price, products_date_available, products_weight, products_tax_class_id, manufacturers_id, products_sort_order from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");

$product = tep_db_fetch_array($product_query);

 

tep_db_query("insert into " . TABLE_PRODUCTS . " (products_quantity, products_model,products_image, products_price, products_date_added, products_date_available, products_weight, products_status, products_tax_class_id, manufacturers_id, products_sort_order) values ('" . tep_db_input($product['products_quantity']) . "', '" . tep_db_input($product['products_model']) . "', '" . tep_db_input($product['products_image']) . "', '" . tep_db_input($product['products_price']) . "', now(), " . (empty($product['products_date_available']) ? "null" : "'" . tep_db_input($product['products_date_available']) . "'") . ", '" . tep_db_input($product['products_weight']) . "', '0', '" . (int)$product['products_tax_class_id'] . "', '" . (int)$product['manufacturers_id'] . "', '" . (int)$product['products_sort_order'] . "')");

$dup_products_id = tep_db_insert_id();

 

// modified for products short description

//HTC BOC

 

$description_query = tep_db_query("select language_id, products_name, products_info, products_description, products_head_title_tag, products_head_desc_tag, products_head_keywords_tag, products_url from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$products_id . "'");

 

while ($description = tep_db_fetch_array($description_query)) {

tep_db_query("insert into " . TABLE_PRODUCTS_DESCRIPTION . " (products_id, language_id, products_name, prodcts_info, products_description, products_head_title_tag, products_head_desc_tag, products_head_keywords_tag, products_url, products_viewed) values ('" . (int)$dup_products_id . "', '" . (int)$description['language_id'] . "', '" . tep_db_input($description['products_name']) . "', '" . tep_db_input($description['products_info']) . "', '" . tep_db_input($description['products_description']) . "', '" . tep_db_input($description['products_head_title_tag']) . "', '" . tep_db_input($description['products_head_desc_tag']) . "', '" . tep_db_input($description['products_head_keywords_tag']) . "', '" . tep_db_input($description['products_url']) . "', '0')");

}

 

//HTC EOC

 

tep_db_query("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . " (products_id, categories_id) values ('" . (int)$dup_products_id . "', '" . (int)$categories_id . "')");

$products_id = $dup_products_id;

}

 

if (USE_CACHE == 'true') {

tep_reset_cache_block('categories');

tep_reset_cache_block('also_purchased');

}

}

 

tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $categories_id . '&pID=' . $products_id));

break;

case 'new_product_preview':

// copy image only if modified

$products_image = new upload('products_image');

$products_image->set_destination(DIR_FS_CATALOG_IMAGES);

if ($products_image->parse() && $products_image->save()) {

$products_image_name = $products_image->filename;

} else {

$products_image_name = (isset($HTTP_POST_VARS['products_previous_image']) ? $HTTP_POST_VARS['products_previous_image'] : '');

}

break;

}

}

 

// check if the catalog image directory exists

if (is_dir(DIR_FS_CATALOG_IMAGES)) {

if (!is_writeable(DIR_FS_CATALOG_IMAGES)) $messageStack->add(ERROR_CATALOG_IMAGE_DIRECTORY_NOT_WRITEABLE, 'error');

} else {

$messageStack->add(ERROR_CATALOG_IMAGE_DIRECTORY_DOES_NOT_EXIST, 'error');

}

?>

<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">

<html <?php echo HTML_PARAMS; ?>>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">

<title><?php echo TITLE; ?></title>

<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">

<script language="javascript" src="includes/general.js"></script>

</head>

<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="SetFocus();">

<div id="spiffycalendar" class="text"></div>

<!-- header //-->

<?php require(DIR_WS_INCLUDES . 'header.php'); ?>

<!-- header_eof //-->

 

<!-- body //-->

<table border="0" width="100%" cellspacing="2" cellpadding="2">

<tr>

<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">

<!-- left_navigation //-->

<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>

<!-- left_navigation_eof //-->

</table></td>

<!-- body_text //-->

 

<td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">

 

<?php

//----- new_category / edit_category (when ALLOW_CATEGORY_DESCRIPTIONS is 'true') -----

 

if ($HTTP_GET_VARS['action'] == 'new_category_ACD' || $HTTP_GET_VARS['action'] == 'edit_category_ACD') {

 

if ( ($HTTP_GET_VARS['cID']) && (!$HTTP_POST_VARS) ) {

 

$categories_query = tep_db_query("select c.categories_id, cd.categories_name, cd.categories_heading_title, cd.categories_description, c.categories_image, c.parent_id, c.sort_order, c.date_added, c.last_modified from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = '" . $HTTP_GET_VARS['cID'] . "' and c.categories_id = cd.categories_id and cd.language_id = '" . $languages_id . "' order by c.sort_order, cd.categories_name");

 

$category = tep_db_fetch_array($categories_query);

 

 

 

$cInfo = new objectInfo($category);

 

} elseif ($HTTP_POST_VARS) {

 

$cInfo = new objectInfo($HTTP_POST_VARS);

 

$categories_name = $HTTP_POST_VARS['categories_name'];

 

$categories_heading_title = $HTTP_POST_VARS['categories_heading_title'];

 

$categories_description = $HTTP_POST_VARS['categories_description'];

 

$categories_url = $HTTP_POST_VARS['categories_url'];

 

} else {

 

$cInfo = new objectInfo(array());

 

}

 

 

 

$languages = tep_get_languages();

 

 

 

$text_new_or_edit = ($HTTP_GET_VARS['action']=='new_category_ACD') ? TEXT_INFO_HEADIN

Share this post


Link to post
Share on other sites

I went through it and something had been changed in the admin/includes/functions/general.php - put it back and works like a charm. I have this heavly modified.

 

Thanks,

Philip

Share this post


Link to post
Share on other sites

I would like to know if I could get TINYMCE to work with this? I automatically have a box I can paste stuff into and sort of edit text with the editor..but it doesn't have the image bar and link bar and all that stuff like in define content... does anyone know how to make category descriptions work with a full on tinymce editor?

 

Thanks :)

Share this post


Link to post
Share on other sites

Having a little trouble getting this contribution running. I had previously installed the STS contribution using the "clean" install method where several files are completely replaced, including categories.php.

 

After installing Category Descriptions I'm getting parse errors around line 78 in my categories.php file. One thing I speficially noticed is that step 6.5 from the Cat Desc readme is not identical in the STS moded categories.php. The readme says to look for the following at approx line 78:

 

$sql_data_array = array('categories_name' => tep_db_prepare_input($categories_name_array[$language_id]));

 

The STS modded file's line is the following:

 

$sql_data_array = array('categories_name' => tep_db_prepare_input($categories_name_array[$language_id]),

 

It's very close but not identical.

 

Is there a compatibility issue between these two contributions?

 

Any input is appreciated.

 

 

Keith

Share this post


Link to post
Share on other sites

Well I fixed the compatiblity issues I was having with STS. In case anyone else is having trouble, here is what I did.

 

Edit 6.5 provides 5 lines of code to be added after:

$sql_data_array = array('categories_name' => tep_db_prepare_input($categories_name_array[$language_id]));

 

If you have installed the STS contribution, you will need to add those 5 lines after:

//HTC BOC

$sql_data_array = array('categories_name' => tep_db_prepare_input($categories_name_array[$language_id]),

'categories_htc_title_tag' => (tep_not_null($categories_htc_title_array[$language_id]) ? tep_db_prepare_input($categories_htc_title_array[$language_id]) : tep_db_prepare_input($categories_name_array[$language_id])),

'categories_htc_desc_tag' => (tep_not_null($categories_htc_desc_array[$language_id]) ? tep_db_prepare_input($categories_htc_desc_array[$language_id]) : tep_db_prepare_input($categories_name_array[$language_id])),

'categories_htc_keywords_tag' => (tep_not_null($categories_htc_keywords_array[$language_id]) ? tep_db_prepare_input($categories_htc_keywords_array[$language_id]) : tep_db_prepare_input($categories_name_array[$language_id])),

'categories_htc_description' => tep_db_prepare_input($categories_htc_description_array[$language_id]));

//HTC EOC

 

That's it.

Share this post


Link to post
Share on other sites

I've installed this contribution tonight and it appears to be working a charm, I've also got the sub-category descriptions installed and working too.

 

What I'd like to do now tho is to change the font colour and also to have a boxed border around the description text.

 

Can anyone throw any light onto how I can do this?

 

Cheers

Jo


Smile: A curve that can make a million things straight

Share this post


Link to post
Share on other sites

I see no-one has posted in here for some time now... but guess what, I have many problems :'(

 

 

I installed categories description and followed the install intructions with great detail but...

first time round it didnt work and had to resort to my backup, second time round I got it working (hurray!) but then I noticed the sub-catagories didnt work, so I added the rest of it to make that work... and at a quick glance it seemed to work fine and then I noticed (none of this adding was simple mind as my code has been heavily moddified and none of the code was where it was supposed to be or look like what is was supposed too)... my problems:

 

If a catagory had sub-catagories with other sub-catagories within that the catagory description would be listed twice... once as normal text where it should be and again in with the title in big bold letters, this would also loose the column_right...

If the catagory didn't have any other sub-catagories then the page would be fine.

 

There are more problems with this but 1 at a time!

PLEASE can anyone help me with this.?


if at first it doesn't work... use a bigger hammer

Share this post


Link to post
Share on other sites

The sub category names are listed in the left column. They are also listed (with category pictures) when you click on the main category name. I want to remove this.

 

I suppose it's some changes in the catalog/index.php file ??

 

Thanks!

Share this post


Link to post
Share on other sites

if you have a problem cancelling a new category insert and pulling up the whole screen properly, here is the fix:

 

in admin/categories.php

 

Find:

		  <tr>
		<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
	  </tr>
	  <tr>
	  <tr>
		<td class="main"><?php echo TEXT_EDIT_CATEGORIES_IMAGE; ?></td>
		<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_file_field('categories_image') . '<br>' . tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . $cInfo->categories_image . tep_draw_hidden_field('categories_previous_image', $cInfo->categories_image); ?></td>
	  </tr>
	  <tr>
		<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
	  </tr>
	  <tr>
		<td class="main"><?php echo TEXT_EDIT_SORT_ORDER; ?></td>
		<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('sort_order', $cInfo->sort_order, 'size="2"'); ?></td>
	  </tr>
	  <tr>
		<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
	  </tr>
	</table></td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  </tr>

 

afterwards make sure the next lines are:

 

	  <tr>
	<td class="main" align="left"><?php echo tep_draw_hidden_field('categories_date_added', (($cInfo->date_added) ? $cInfo->date_added : date('Y-m-d'))) . tep_draw_hidden_field('parent_id', $cInfo->parent_id) . tep_image_submit('button_save.gif', IMAGE_SAVE) . '  <a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . (isset($HTTP_GET_VARS['cID']) ? '&cID=' . $HTTP_GET_VARS['cID'] : '')) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; ?></td>
  </form></tr>

 

Scott

Share this post


Link to post
Share on other sites

Another line that needs to be changed:

 

catalog/admin/categories.php

 

find:

	  if ($HTTP_GET_VARS['cID']) {
	echo tep_image_submit('button_update.gif', IMAGE_UPDATE);
  } else {
	echo tep_image_submit('button_insert.gif', IMAGE_INSERT);
  }

 

make sure the next line reads:

	  echo '  <a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . (isset($HTTP_GET_VARS['cID']) ? '&cID=' . $HTTP_GET_VARS['cID'] : '')) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>';

 

Scott

Share this post


Link to post
Share on other sites

this also needs to change:

 

find this:

	  <tr>
	<td><table border="0" width="100%" cellspacing="0" cellpadding="0">
	  <tr>
		<td class="pageHeading"><?php echo sprintf($text_new_or_edit, tep_output_generated_category_path($current_category_id)); ?></td>
		<td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
	  </tr>
	</table></td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  </tr>

 

make sure the next line is this:

 

	  <tr><?php echo tep_draw_form('new_category', FILENAME_CATEGORIES, 'cPath=' . $cPath . (isset($HTTP_GET_VARS['cID']) ? '&cID=' . $HTTP_GET_VARS['cID'] : '') . '&action=new_category_preview', 'post', 'enctype="multipart/form-data"'); ?>

Share this post


Link to post
Share on other sites

Hi olsonsp4c

 

Are the changes in your two above posts intended for everyone who has installed this great contribution?


The Coopco Underwear Shop

 

If you live to be 100 years of age, that means you have lived for 36,525 days. Don't waste another, there aren't many left.

Share this post


Link to post
Share on other sites
Hi olsonsp4c

 

Are the changes in your two above posts intended for everyone who has installed this great contribution?

 

yes :rolleyes:

Share this post


Link to post
Share on other sites
yes :rolleyes:

Odd, I do not have any of the find text in the 3 posts given.


The Coopco Underwear Shop

 

If you live to be 100 years of age, that means you have lived for 36,525 days. Don't waste another, there aren't many left.

Share this post


Link to post
Share on other sites
Odd, I do not have any of the find text in the 3 posts given.

 

OK, let me clarify - I am using version 1.9 of Category Description addon. The file to be modified is catalog/includes/categories.php - I used the NON-WYSIWYG version.

 

Scott

Share this post


Link to post
Share on other sites

Another edit to be made in catalog/admin/categories.php

 

Find this:

 

	  $category_query = tep_db_query("select c.categories_id, cd.language_id, cd.categories_name, cd.categories_heading_title, cd.categories_description, c.categories_image, c.sort_order, c.date_added, c.last_modified from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = cd.categories_id and c.categories_id = '" . $HTTP_GET_VARS['cID'] . "'");
  $category = tep_db_fetch_array($category_query);

  $cInfo = new objectInfo($category);
  $categories_image_name = $cInfo->categories_image;
}

$form_action = ($HTTP_GET_VARS['cID']) ? 'update_category' : 'insert_category';

 

Make sure the next line reads this:

 

	echo tep_draw_form($form_action, FILENAME_CATEGORIES, 'cPath=' . $cPath . (isset($HTTP_GET_VARS['cID']) ? '&cID=' . $HTTP_GET_VARS['cID'] : '') . '&action=' . $form_action, 'post', 'enctype="multipart/form-data"');

 

I think this is the last edit - now all your buttons should work properly...

 

Scott

Share this post


Link to post
Share on other sites
OK, let me clarify - I am using version 1.9 of Category Description addon. The file to be modified is catalog/includes/categories.php - I used the NON-WYSIWYG version.

 

Scott

I will look in that file, the posts indicated catalog/admin/categories.php


The Coopco Underwear Shop

 

If you live to be 100 years of age, that means you have lived for 36,525 days. Don't waste another, there aren't many left.

Share this post


Link to post
Share on other sites
I will look in that file, the posts indicated catalog/admin/categories.php

Well, no file there.


The Coopco Underwear Shop

 

If you live to be 100 years of age, that means you have lived for 36,525 days. Don't waste another, there aren't many left.

Share this post


Link to post
Share on other sites
Well, no file there.

 

Sorry - i posted it quickly - it is catalog/admin/categories.php for ALL the edits I posted...

 

Scott

Share this post


Link to post
Share on other sites

Category Descriptions v1.95 is out: http://addons.oscommerce.com/info/1373

 

Though the addon says MS2, I have this running nicely on my RC2a installation.

 

Scott

Edited by olsonsp4c

Share this post


Link to post
Share on other sites

After installing the ACA version of this I get the following error, whenever adding, modifing or deleting any item or category on the website admin. any ideas

 

Warning: Cannot modify header information - headers already sent by (output started at /homepages/34/d153292508/htdocs/woolmama/cart/admin/includes/functions/categories_description.php:1) in /homepages/34/d153292508/htdocs/woolmama/cart/admin/includes/functions/general.php on line 22

 

can anyone help with this...

 

--Jmac

Edited by johnmacdaddy

Share this post


Link to post
Share on other sites

I have installed the 1.7 version.

 

It works but I only can add the category description for my default language, but I want it for three different languages...

 

How can I modifie the code that he chooses three instead of one language?

Share this post


Link to post
Share on other sites

Hello!

 

I am new to osCommerce and started to configure the shop. As we switched from another e-commerce platform to osCommerce, we want to keep some of the old one's feature. Until now everything has worked out fine. But today a problem came up which I couldn't solve.

 

We want to use category descriptions which specify the content of the category. So I installed the contribution "category description" which works out fine. Then I installed EP, which was no problem either. Now I wanted to add the field "category_description" to easypopulate.php, so that the content can be exported to the data base. The main difference is that my variable is in the table "category_description" (named "category_description" as well) and not in "product_description". I read the manuals and searched the forum, but I found only answers for adding a field concerning the product not the category.

 

May anybody give me a hint how to add the field "category_description"?

 

You can my easypopulate.php here. But in fact it is the standard configuration.

 

Thanks for your help!

 

Daniel

Share this post


Link to post
Share on other sites

where do i put the following code?

 

$products_modules-> register_module ('category_description.php');

 

i have installed all of the files and it apprears in my admin page but i don't get the page which allows me to edit the catagory descriptions!

 

the above code appears to be causing errors in the code.

 

help would be most appreciated as i have done this several times now with the smae result!!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×