PageRenderTime 123ms CodeModel.GetById 26ms RepoModel.GetById 1ms app.codeStats 0ms

/admin/categories.php

http://daocart.googlecode.com/
PHP | 1025 lines | 779 code | 147 blank | 99 comment | 167 complexity | a91cdd2d312df540c8c7d8bc509c66b5 MD5 | raw file
Possible License(s): AGPL-1.0, GPL-2.0, BSD-3-Clause

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /**
  3. * @package admin
  4. * @copyright Copyright 2003-2007 Zen Cart Development Team
  5. * @copyright Portions Copyright 2003 osCommerce
  6. * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
  7. * @version $Id: categories.php 6991 2007-09-13 01:01:24Z drbyte $
  8. */
  9. require('includes/application_top.php');
  10. require(DIR_WS_MODULES . 'prod_cat_header_code.php');
  11. $action = (isset($_GET['action']) ? $_GET['action'] : '');
  12. if (!isset($_SESSION['categories_products_sort_order'])) {
  13. $_SESSION['categories_products_sort_order'] = CATEGORIES_PRODUCTS_SORT_ORDER;
  14. }
  15. if (!isset($_GET['reset_categories_products_sort_order'])) {
  16. $reset_categories_products_sort_order = $_SESSION['categories_products_sort_order'];
  17. }
  18. if (zen_not_null($action)) {
  19. switch ($action) {
  20. case 'set_categories_products_sort_order':
  21. $_SESSION['categories_products_sort_order'] = $_GET['reset_categories_products_sort_order'];
  22. $action='';
  23. zen_redirect(zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $_GET['cPath'] . ((isset($_GET['pID']) and !empty($_GET['pID'])) ? '&pID=' . $_GET['pID'] : '') . ((isset($_GET['page']) and !empty($_GET['page'])) ? '&page=' . $_GET['page'] : '')));
  24. break;
  25. case 'set_editor':
  26. // Reset will be done by init_html_editor.php. Now we simply redirect to refresh page properly.
  27. $action='';
  28. zen_redirect(zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $_GET['cPath'] . ((isset($_GET['pID']) and !empty($_GET['pID'])) ? '&pID=' . $_GET['pID'] : '') . ((isset($_GET['page']) and !empty($_GET['page'])) ? '&page=' . $_GET['page'] : '')));
  29. break;
  30. case 'update_category_status':
  31. // disable category and products including subcategories
  32. if (isset($_POST['categories_id'])) {
  33. $categories_id = zen_db_prepare_input($_POST['categories_id']);
  34. $categories = zen_get_category_tree($categories_id, '', '0', '', true);
  35. for ($i=0, $n=sizeof($categories); $i<$n; $i++) {
  36. $product_ids = $db->Execute("select products_id
  37. from " . TABLE_PRODUCTS_TO_CATEGORIES . "
  38. where categories_id = '" . (int)$categories[$i]['id'] . "'");
  39. while (!$product_ids->EOF) {
  40. $products[$product_ids->fields['products_id']]['categories'][] = $categories[$i]['id'];
  41. $product_ids->MoveNext();
  42. }
  43. }
  44. // change the status of categories and products
  45. zen_set_time_limit(600);
  46. for ($i=0, $n=sizeof($categories); $i<$n; $i++) {
  47. if ($_POST['categories_status'] == '1') {
  48. $categories_status = '0';
  49. $products_status = '0';
  50. } else {
  51. $categories_status = '1';
  52. $products_status = '1';
  53. }
  54. $sql = "update " . TABLE_CATEGORIES . " set categories_status='" . $categories_status . "'
  55. where categories_id='" . $categories[$i]['id'] . "'";
  56. $db->Execute($sql);
  57. // set products_status based on selection
  58. if ($_POST['set_products_status'] == 'set_products_status_nochange') {
  59. // do not change current product status
  60. } else {
  61. if ($_POST['set_products_status'] == 'set_products_status_on') {
  62. $products_status = '1';
  63. } else {
  64. $products_status = '0';
  65. }
  66. $sql = "select products_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id='" . $categories[$i]['id'] . "'";
  67. $category_products = $db->Execute($sql);
  68. while (!$category_products->EOF) {
  69. $sql = "update " . TABLE_PRODUCTS . " set products_status='" . $products_status . "' where products_id='" . $category_products->fields['products_id'] . "'";
  70. $db->Execute($sql);
  71. $category_products->MoveNext();
  72. }
  73. }
  74. } // for
  75. }
  76. zen_redirect(zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $_GET['cPath'] . '&cID=' . $_GET['cID']));
  77. break;
  78. case 'remove_type':
  79. $sql = "delete from " . TABLE_PRODUCT_TYPES_TO_CATEGORY . "
  80. where category_id = '" . zen_db_prepare_input($_GET['cID']) . "'
  81. and product_type_id = '" . zen_db_prepare_input($_GET['type_id']) . "'";
  82. $db->Execute($sql);
  83. zen_remove_restrict_sub_categories($_GET['cID'], $_GET['type_id']);
  84. $action = "edit";
  85. zen_redirect(zen_href_link(FILENAME_CATEGORIES, 'action=edit_category&cPath=' . $_GET['cPath'] . '&cID=' . zen_db_prepare_input($_GET['cID'])));
  86. break;
  87. case 'setflag':
  88. if ( ($_GET['flag'] == '0') || ($_GET['flag'] == '1') ) {
  89. if (isset($_GET['pID'])) {
  90. zen_set_product_status($_GET['pID'], $_GET['flag']);
  91. }
  92. }
  93. zen_redirect(zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $_GET['cPath'] . '&pID=' . $_GET['pID'] . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')));
  94. break;
  95. case 'insert_category':
  96. case 'update_category':
  97. if ( isset($_POST['add_type']) or isset($_POST['add_type_all']) ) {
  98. // check if it is already restricted
  99. $sql = "select * from " . TABLE_PRODUCT_TYPES_TO_CATEGORY . "
  100. where category_id = '" . zen_db_prepare_input($_POST['categories_id']) . "'
  101. and product_type_id = '" . zen_db_prepare_input($_POST['restrict_type']) . "'";
  102. $type_to_cat = $db->Execute($sql);
  103. if ($type_to_cat->RecordCount() < 1) {
  104. //@@TODO find all sub-categories and restrict them as well.
  105. $insert_sql_data = array('category_id' => zen_db_prepare_input($_POST['categories_id']),
  106. 'product_type_id' => zen_db_prepare_input($_POST['restrict_type']));
  107. zen_db_perform(TABLE_PRODUCT_TYPES_TO_CATEGORY, $insert_sql_data);
  108. /*
  109. // moved below so evaluated separately from current category
  110. if (isset($_POST['add_type_all'])) {
  111. zen_restrict_sub_categories($_POST['categories_id'], $_POST['restrict_type']);
  112. }
  113. */
  114. }
  115. // add product type restrictions to subcategories if not already set
  116. if (isset($_POST['add_type_all'])) {
  117. zen_restrict_sub_categories($_POST['categories_id'], $_POST['restrict_type']);
  118. }
  119. $action = "edit";
  120. zen_redirect(zen_href_link(FILENAME_CATEGORIES, 'action=edit_category&cPath=' . $cPath . '&cID=' . zen_db_prepare_input($_POST['categories_id'])));
  121. }
  122. if (isset($_POST['categories_id'])) $categories_id = zen_db_prepare_input($_POST['categories_id']);
  123. $sort_order = zen_db_prepare_input($_POST['sort_order']);
  124. $sql_data_array = array('sort_order' => (int)$sort_order);
  125. if ($action == 'insert_category') {
  126. $insert_sql_data = array('parent_id' => $current_category_id,
  127. 'date_added' => 'now()');
  128. $sql_data_array = array_merge($sql_data_array, $insert_sql_data);
  129. zen_db_perform(TABLE_CATEGORIES, $sql_data_array);
  130. $categories_id = zen_db_insert_id();
  131. // check if [arent is restricted
  132. $sql = "select parent_id from " . TABLE_CATEGORIES . "
  133. where categories_id = '" . $categories_id . "'";
  134. $parent_cat = $db->Execute($sql);
  135. if ($parent_cat->fields['parent_id'] != '0') {
  136. $sql = "select * from " . TABLE_PRODUCT_TYPES_TO_CATEGORY . "
  137. where category_id = '" . $parent_cat->fields['parent_id'] . "'";
  138. $has_type = $db->Execute($sql);
  139. if ($has_type->RecordCount() > 0 ) {
  140. while (!$has_type->EOF) {
  141. $insert_sql_data = array('category_id' => $categories_id,
  142. 'product_type_id' => $has_type->fields['product_type_id']);
  143. zen_db_perform(TABLE_PRODUCT_TYPES_TO_CATEGORY, $insert_sql_data);
  144. $has_type->moveNext();
  145. }
  146. }
  147. }
  148. } elseif ($action == 'update_category') {
  149. $update_sql_data = array('last_modified' => 'now()');
  150. $sql_data_array = array_merge($sql_data_array, $update_sql_data);
  151. zen_db_perform(TABLE_CATEGORIES, $sql_data_array, 'update', "categories_id = '" . (int)$categories_id . "'");
  152. }
  153. $languages = zen_get_languages();
  154. for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
  155. $categories_name_array = $_POST['categories_name'];
  156. $categories_description_array = $_POST['categories_description'];
  157. $language_id = $languages[$i]['id'];
  158. // clean $categories_description when blank or just <p /> left behind
  159. $sql_data_array = array('categories_name' => zen_db_prepare_input($categories_name_array[$language_id]),
  160. 'categories_description' => ($categories_description_array[$language_id] == '<p />' ? '' : zen_db_prepare_input($categories_description_array[$language_id])));
  161. if ($action == 'insert_category') {
  162. $insert_sql_data = array('categories_id' => $categories_id,
  163. 'language_id' => $languages[$i]['id']);
  164. $sql_data_array = array_merge($sql_data_array, $insert_sql_data);
  165. zen_db_perform(TABLE_CATEGORIES_DESCRIPTION, $sql_data_array);
  166. } elseif ($action == 'update_category') {
  167. zen_db_perform(TABLE_CATEGORIES_DESCRIPTION, $sql_data_array, 'update', "categories_id = '" . (int)$categories_id . "' and language_id = '" . (int)$languages[$i]['id'] . "'");
  168. }
  169. }
  170. if ($_POST['categories_image_manual'] != '') {
  171. // add image manually
  172. $categories_image_name = $_POST['img_dir'] . $_POST['categories_image_manual'];
  173. $db->Execute("update " . TABLE_CATEGORIES . "
  174. set categories_image = '" . $categories_image_name . "'
  175. where categories_id = '" . (int)$categories_id . "'");
  176. } else {
  177. if ($categories_image = new upload('categories_image')) {
  178. $categories_image->set_destination(DIR_FS_CATALOG_IMAGES . $_POST['img_dir']);
  179. if ($categories_image->parse() && $categories_image->save()) {
  180. $categories_image_name = $_POST['img_dir'] . $categories_image->filename;
  181. }
  182. if ($categories_image->filename != 'none' && $categories_image->filename != '' && $_POST['image_delete'] != 1) {
  183. // save filename when not set to none and not blank
  184. $db->Execute("update " . TABLE_CATEGORIES . "
  185. set categories_image = '" . $categories_image_name . "'
  186. where categories_id = '" . (int)$categories_id . "'");
  187. } else {
  188. // remove filename when set to none and not blank
  189. if ($categories_image->filename != '' || $_POST['image_delete'] == 1) {
  190. $db->Execute("update " . TABLE_CATEGORIES . "
  191. set categories_image = ''
  192. where categories_id = '" . (int)$categories_id . "'");
  193. }
  194. }
  195. }
  196. }
  197. zen_redirect(zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $categories_id));
  198. break;
  199. // bof: categories meta tags
  200. case 'update_category_meta_tags':
  201. // add or update meta tags
  202. //die('I SEE ' . $action . ' - ' . $_POST['categories_id']);
  203. $categories_id = $_POST['categories_id'];
  204. $languages = zen_get_languages();
  205. for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
  206. $language_id = $languages[$i]['id'];
  207. $check = $db->Execute("select *
  208. from " . TABLE_METATAGS_CATEGORIES_DESCRIPTION . "
  209. where categories_id = '" . (int)$categories_id . "'
  210. and language_id = '" . (int)$language_id . "'");
  211. if ($check->RecordCount() > 0) {
  212. $action = 'update_category_meta_tags';
  213. } else {
  214. $action = 'insert_categories_meta_tags';
  215. }
  216. $sql_data_array = array('metatags_title' => zen_db_prepare_input($_POST['metatags_title'][$language_id]),
  217. 'metatags_keywords' => zen_db_prepare_input($_POST['metatags_keywords'][$language_id]),
  218. 'metatags_description' => zen_db_prepare_input($_POST['metatags_description'][$language_id]));
  219. if ($action == 'insert_categories_meta_tags') {
  220. $insert_sql_data = array('categories_id' => $categories_id,
  221. 'language_id' => $language_id);
  222. $sql_data_array = array_merge($sql_data_array, $insert_sql_data);
  223. zen_db_perform(TABLE_METATAGS_CATEGORIES_DESCRIPTION, $sql_data_array);
  224. } elseif ($action == 'update_category_meta_tags') {
  225. zen_db_perform(TABLE_METATAGS_CATEGORIES_DESCRIPTION, $sql_data_array, 'update', "categories_id = '" . (int)$categories_id . "' and language_id = '" . (int)$language_id . "'");
  226. }
  227. }
  228. zen_redirect(zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $categories_id));
  229. break;
  230. // eof: categories meta tags
  231. case 'delete_category_confirm_old':
  232. // demo active test
  233. if (zen_admin_demo()) {
  234. $_GET['action']= '';
  235. $messageStack->add_session(ERROR_ADMIN_DEMO, 'caution');
  236. zen_redirect(zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath));
  237. }
  238. if (isset($_POST['categories_id'])) {
  239. $categories_id = zen_db_prepare_input($_POST['categories_id']);
  240. $categories = zen_get_category_tree($categories_id, '', '0', '', true);
  241. $products = array();
  242. $products_delete = array();
  243. for ($i=0, $n=sizeof($categories); $i<$n; $i++) {
  244. $product_ids = $db->Execute("select products_id
  245. from " . TABLE_PRODUCTS_TO_CATEGORIES . "
  246. where categories_id = '" . (int)$categories[$i]['id'] . "'");
  247. while (!$product_ids->EOF) {
  248. $products[$product_ids->fields['products_id']]['categories'][] = $categories[$i]['id'];
  249. $product_ids->MoveNext();
  250. }
  251. }
  252. reset($products);
  253. while (list($key, $value) = each($products)) {
  254. $category_ids = '';
  255. for ($i=0, $n=sizeof($value['categories']); $i<$n; $i++) {
  256. $category_ids .= "'" . (int)$value['categories'][$i] . "', ";
  257. }
  258. $category_ids = substr($category_ids, 0, -2);
  259. $check = $db->Execute("select count(*) as total
  260. from " . TABLE_PRODUCTS_TO_CATEGORIES . "
  261. where products_id = '" . (int)$key . "'
  262. and categories_id not in (" . $category_ids . ")");
  263. if ($check->fields['total'] < '1') {
  264. $products_delete[$key] = $key;
  265. }
  266. }
  267. // removing categories can be a lengthy process
  268. zen_set_time_limit(600);
  269. for ($i=0, $n=sizeof($categories); $i<$n; $i++) {
  270. zen_remove_category($categories[$i]['id']);
  271. }
  272. reset($products_delete);
  273. while (list($key) = each($products_delete)) {
  274. zen_remove_product($key);
  275. }
  276. }
  277. zen_redirect(zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath));
  278. break;
  279. //////////////////////////////////
  280. // delete new
  281. case 'delete_category_confirm':
  282. // demo active test
  283. if (zen_admin_demo()) {
  284. $_GET['action']= '';
  285. $messageStack->add_session(ERROR_ADMIN_DEMO, 'caution');
  286. zen_redirect(zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath));
  287. }
  288. // future cat specific deletion
  289. $delete_linked = 'true';
  290. if ($_POST['delete_linked'] == 'delete_linked_no') {
  291. $delete_linked = 'false';
  292. } else {
  293. $delete_linked = 'true';
  294. }
  295. // delete category and products
  296. if (isset($_POST['categories_id'])) {
  297. $categories_id = zen_db_prepare_input($_POST['categories_id']);
  298. // create list of any subcategories in the selected category,
  299. $categories = zen_get_category_tree($categories_id, '', '0', '', true);
  300. zen_set_time_limit(600);
  301. // loop through this cat and subcats for delete-processing.
  302. for ($i=0, $n=sizeof($categories); $i<$n; $i++) {
  303. $sql = "select products_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id='" . $categories[$i]['id'] . "'";
  304. $category_products = $db->Execute($sql);
  305. while (!$category_products->EOF) {
  306. $cascaded_prod_id_for_delete = $category_products->fields['products_id'];
  307. $cascaded_prod_cat_for_delete = array();
  308. $cascaded_prod_cat_for_delete[] = $categories[$i]['id'];
  309. //echo 'processing product_id: ' . $cascaded_prod_id_for_delete . ' in category: ' . $cascaded_prod_cat_for_delete . '<br>';
  310. // determine product-type-specific override script for this product
  311. $product_type = zen_get_products_type($category_products->fields['products_id']);
  312. // now loop thru the delete_product_confirm script for each product in the current category
  313. if (file_exists(DIR_WS_MODULES . $zc_products->get_handler($product_type) . '/delete_product_confirm.php')) {
  314. require(DIR_WS_MODULES . $zc_products->get_handler($product_type) . '/delete_product_confirm.php');
  315. } else {
  316. require(DIR_WS_MODULES . 'delete_product_confirm.php');
  317. }
  318. // THIS LINE COMMENTED BECAUSE IT'S DONE ALREADY DURING DELETE_PRODUCT_CONFIRM.PHP:
  319. //zen_remove_product($category_products->fields['products_id'], $delete_linked);
  320. $category_products->MoveNext();
  321. }
  322. zen_remove_category($categories[$i]['id']);
  323. } // end for loop
  324. }
  325. zen_redirect(zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath));
  326. break;
  327. // eof delete new
  328. /////////////////////////////////
  329. // @@TODO where is delete_product_confirm
  330. case 'move_category_confirm':
  331. if (isset($_POST['categories_id']) && ($_POST['categories_id'] != $_POST['move_to_category_id'])) {
  332. $categories_id = zen_db_prepare_input($_POST['categories_id']);
  333. $new_parent_id = zen_db_prepare_input($_POST['move_to_category_id']);
  334. $path = explode('_', zen_get_generated_category_path_ids($new_parent_id));
  335. if (in_array($categories_id, $path)) {
  336. $messageStack->add_session(ERROR_CANNOT_MOVE_CATEGORY_TO_PARENT, 'error');
  337. zen_redirect(zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath));
  338. } else {
  339. $sql = "select count(*) as count from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id='" . (int)$new_parent_id . "'";
  340. $zc_count_products = $db->Execute($sql);
  341. if ( $zc_count_products->fields['count'] > 0) {
  342. $messageStack->add_session(ERROR_CATEGORY_HAS_PRODUCTS, 'error');
  343. } else {
  344. $messageStack->add_session(SUCCESS_CATEGORY_MOVED, 'success');
  345. }
  346. $db->Execute("update " . TABLE_CATEGORIES . "
  347. set parent_id = '" . (int)$new_parent_id . "', last_modified = now()
  348. where categories_id = '" . (int)$categories_id . "'");
  349. // fix here - if this is a category with subcats it needs to know to loop through
  350. // reset all products_price_sorter for moved category products
  351. $reset_price_sorter = $db->Execute("select products_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id='" . (int)$categories_id . "'");
  352. while (!$reset_price_sorter->EOF) {
  353. zen_update_products_price_sorter($reset_price_sorter->fields['products_id']);
  354. $reset_price_sorter->MoveNext();
  355. }
  356. zen_redirect(zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $new_parent_id));
  357. }
  358. } else {
  359. $messageStack->add_session(ERROR_CANNOT_MOVE_CATEGORY_TO_CATEGORY_SELF . $cPath, 'error');
  360. zen_redirect(zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath));
  361. }
  362. break;
  363. // @@TODO where is move_product_confirm
  364. // @@TODO where is insert_product
  365. // @@TODO where is update_product
  366. // attribute features
  367. case 'delete_attributes':
  368. zen_delete_products_attributes($_GET['products_id']);
  369. $messageStack->add_session(SUCCESS_ATTRIBUTES_DELETED . ' ID#' . $_GET['products_id'], 'success');
  370. $action='';
  371. // reset products_price_sorter for searches etc.
  372. zen_update_products_price_sorter($_GET['products_id']);
  373. zen_redirect(zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $_GET['products_id'] . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')));
  374. break;
  375. case 'update_attributes_sort_order':
  376. zen_update_attributes_products_option_values_sort_order($_GET['products_id']);
  377. $messageStack->add_session(SUCCESS_ATTRIBUTES_UPDATE . ' ID#' . $_GET['products_id'], 'success');
  378. $action='';
  379. zen_redirect(zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $_GET['products_id'] . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')));
  380. break;
  381. // attributes copy to product
  382. case 'update_attributes_copy_to_product':
  383. $copy_attributes_delete_first = ($_POST['copy_attributes'] == 'copy_attributes_delete' ? '1' : '0');
  384. $copy_attributes_duplicates_skipped = ($_POST['copy_attributes'] == 'copy_attributes_ignore' ? '1' : '0');
  385. $copy_attributes_duplicates_overwrite = ($_POST['copy_attributes'] == 'copy_attributes_update' ? '1' : '0');
  386. zen_copy_products_attributes($_POST['products_id'], $_POST['products_update_id']);
  387. // die('I would copy Product ID#' . $_POST['products_id'] . ' to a Product ID#' . $_POST['products_update_id'] . ' - Existing attributes ' . $_POST['copy_attributes']);
  388. $_GET['action']= '';
  389. zen_redirect(zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $_GET['products_id'] . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')));
  390. break;
  391. // attributes copy to category
  392. case 'update_attributes_copy_to_category':
  393. $copy_attributes_delete_first = ($_POST['copy_attributes'] == 'copy_attributes_delete' ? '1' : '0');
  394. $copy_attributes_duplicates_skipped = ($_POST['copy_attributes'] == 'copy_attributes_ignore' ? '1' : '0');
  395. $copy_attributes_duplicates_overwrite = ($_POST['copy_attributes'] == 'copy_attributes_update' ? '1' : '0');
  396. $copy_to_category = $db->Execute("select products_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id='" . $_POST['categories_update_id'] . "'");
  397. while (!$copy_to_category->EOF) {
  398. zen_copy_products_attributes($_POST['products_id'], $copy_to_category->fields['products_id']);
  399. $copy_to_category->MoveNext();
  400. }
  401. // die('CATEGORIES - I would copy Product ID#' . $_POST['products_id'] . ' to a Category ID#' . $_POST['categories_update_id'] . ' - Existing attributes ' . $_POST['copy_attributes'] . ' Total Products ' . $copy_to_category->RecordCount());
  402. $_GET['action']= '';
  403. zen_redirect(zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $_GET['products_id'] . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')));
  404. break;
  405. case 'new_product':
  406. if (isset($_GET['product_type'])) {
  407. // see if this category is restricted
  408. $pieces = explode('_',$_GET['cPath']);
  409. $cat_id = $pieces[sizeof($pieces)-1];
  410. // echo $cat_id;
  411. $sql = "select product_type_id from " . TABLE_PRODUCT_TYPES_TO_CATEGORY . " where category_id = '" . $cat_id . "'";
  412. $product_type_list = $db->Execute($sql);
  413. $sql = "select product_type_id from " . TABLE_PRODUCT_TYPES_TO_CATEGORY . " where category_id = '" . $cat_id . "' and product_type_id = '" . $_GET['product_type'] . "'";
  414. $product_type_good = $db->Execute($sql);
  415. if ($product_type_list->RecordCount() < 1 || $product_type_good->RecordCount() > 0) {
  416. $url = zen_get_all_get_params();
  417. $sql = "select type_handler from " . TABLE_PRODUCT_TYPES . " where type_id = '" . $_GET['product_type'] . "'";
  418. $handler = $db->Execute($sql);
  419. zen_redirect(zen_href_link($handler->fields['type_handler'] . '.php', zen_get_all_get_params()));
  420. } else {
  421. $messageStack->add(ERROR_CANNOT_ADD_PRODUCT_TYPE, 'error');
  422. }
  423. }
  424. break;
  425. }
  426. }
  427. // check if the catalog image directory exists
  428. if (is_dir(DIR_FS_CATALOG_IMAGES)) {
  429. if (!is_writeable(DIR_FS_CATALOG_IMAGES)) $messageStack->add(ERROR_CATALOG_IMAGE_DIRECTORY_NOT_WRITEABLE, 'error');
  430. } else {
  431. $messageStack->add(ERROR_CATALOG_IMAGE_DIRECTORY_DOES_NOT_EXIST, 'error');
  432. }
  433. ?>
  434. <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
  435. <html <?php echo HTML_PARAMS; ?>>
  436. <head>
  437. <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
  438. <title><?php echo TITLE; ?></title>
  439. <link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
  440. <link rel="stylesheet" type="text/css" href="includes/cssjsmenuhover.css" media="all" id="hoverJS">
  441. <script language="javascript" src="includes/menu.js"></script>
  442. <script language="javascript" src="includes/general.js"></script>
  443. <script type="text/javascript">
  444. <!--
  445. function init()
  446. {
  447. cssjsmenu('navbar');
  448. if (document.getElementById)
  449. {
  450. var kill = document.getElementById('hoverJS');
  451. kill.disabled = true;
  452. }
  453. if (typeof _editor_url == "string") HTMLArea.replaceAll();
  454. }
  455. // -->
  456. </script>
  457. <?php if ($action != 'edit_category_meta_tags') { // bof: categories meta tags ?>
  458. <?php if ($editor_handler != '') include ($editor_handler); ?>
  459. <?php } // meta tags disable editor eof: categories meta tags?>
  460. </head>
  461. <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onLoad="init()">
  462. <div id="spiffycalendar" class="text"></div>
  463. <!-- header //-->
  464. <?php require(DIR_WS_INCLUDES . 'header.php'); ?>
  465. <!-- header_eof //-->
  466. <!-- body //-->
  467. <table border="0" width="100%" cellspacing="2" cellpadding="2">
  468. <?php if ($action == '') { ?>
  469. <tr>
  470. <td><table border="0" cellspacing="0" cellpadding="0">
  471. <tr>
  472. <td class="smallText" align="center" width="100" valign="top"><?php echo TEXT_LEGEND; ?></td>
  473. <td class="smallText" align="center" width="100" valign="top"><?php echo TEXT_LEGEND_STATUS_OFF . '<br />' . zen_image(DIR_WS_IMAGES . 'icon_red_on.gif', IMAGE_ICON_STATUS_OFF); ?></td>
  474. <td class="smallText" align="center" width="100" valign="top"><?php echo TEXT_LEGEND_STATUS_ON . '<br />' . zen_image(DIR_WS_IMAGES . 'icon_green_on.gif', IMAGE_ICON_STATUS_ON); ?></td>
  475. <td class="smallText" align="center" width="100" valign="top"><?php echo TEXT_LEGEND_LINKED . '<br />' . zen_image(DIR_WS_IMAGES . 'icon_yellow_on.gif', IMAGE_ICON_LINKED); ?></td>
  476. <td class="smallText" align="center" width="150" valign="top"><?php echo TEXT_LEGEND_META_TAGS . '<br />' . TEXT_YES . '&nbsp;' . TEXT_NO . '<br />' . zen_image(DIR_WS_IMAGES . 'icon_edit_metatags_on.gif', ICON_METATAGS_ON) . '&nbsp;' . zen_image(DIR_WS_IMAGES . 'icon_edit_metatags_off.gif', ICON_METATAGS_OFF); ?></td>
  477. </tr>
  478. </table></td>
  479. </tr>
  480. <tr>
  481. <td class="smallText" width="100%" align="right">
  482. <?php
  483. // toggle switch for editor
  484. echo TEXT_EDITOR_INFO . zen_draw_form('set_editor_form', FILENAME_CATEGORIES, '', 'get') . '&nbsp;&nbsp;' . zen_draw_pull_down_menu('reset_editor', $editors_pulldown, $current_editor_key, 'onChange="this.form.submit();"') . zen_hide_session_id() .
  485. zen_draw_hidden_field('cID', $cPath) .
  486. zen_draw_hidden_field('cPath', $cPath) .
  487. zen_draw_hidden_field('pID', $_GET['pID']) .
  488. zen_draw_hidden_field('page', $_GET['page']) .
  489. zen_draw_hidden_field('action', 'set_editor') .
  490. '</form>';
  491. ?>
  492. </td>
  493. </tr>
  494. <tr>
  495. <td class="smallText" width="100%" align="right">
  496. <?php
  497. // check for which buttons to show for categories and products
  498. $check_categories = zen_has_category_subcategories($current_category_id);
  499. $check_products = zen_products_in_category_count($current_category_id, false, false, 1);
  500. $zc_skip_products = false;
  501. $zc_skip_categories = false;
  502. if ($check_products == 0) {
  503. $zc_skip_products = false;
  504. $zc_skip_categories = false;
  505. }
  506. if ($check_categories == true) {
  507. $zc_skip_products = true;
  508. $zc_skip_categories = false;
  509. }
  510. if ($check_products > 0) {
  511. $zc_skip_products = false;
  512. $zc_skip_categories = true;
  513. }
  514. if ($zc_skip_products == true) {
  515. // toggle switch for display sort order
  516. $categories_products_sort_order_array = array(array('id' => '0', 'text' => TEXT_SORT_CATEGORIES_SORT_ORDER_PRODUCTS_NAME),
  517. array('id' => '1', 'text' => TEXT_SORT_CATEGORIES_NAME)
  518. );
  519. } else {
  520. // toggle switch for display sort order
  521. $categories_products_sort_order_array = array(array('id' => '0', 'text' => TEXT_SORT_PRODUCTS_SORT_ORDER_PRODUCTS_NAME),
  522. array('id' => '1', 'text' => TEXT_SORT_PRODUCTS_NAME),
  523. array('id' => '2', 'text' => TEXT_SORT_PRODUCTS_MODEL),
  524. array('id' => '3', 'text'=> TEXT_SORT_PRODUCTS_QUANTITY),
  525. array('id' => '4', 'text'=> TEXT_SORT_PRODUCTS_QUANTITY_DESC),
  526. array('id' => '5', 'text'=> TEXT_SORT_PRODUCTS_PRICE),
  527. array('id' => '6', 'text'=> TEXT_SORT_PRODUCTS_PRICE_DESC)
  528. );
  529. }
  530. echo TEXT_CATEGORIES_PRODUCTS_SORT_ORDER_INFO . zen_draw_form('set_categories_products_sort_order_form', FILENAME_CATEGORIES, '', 'get') . '&nbsp;&nbsp;' . zen_draw_pull_down_menu('reset_categories_products_sort_order', $categories_products_sort_order_array, $reset_categories_products_sort_order, 'onChange="this.form.submit();"') . zen_hide_session_id() .
  531. zen_draw_hidden_field('cID', $cPath) .
  532. zen_draw_hidden_field('cPath', $cPath) .
  533. zen_draw_hidden_field('pID', $_GET['pID']) .
  534. zen_draw_hidden_field('page', $_GET['page']) .
  535. zen_draw_hidden_field('action', 'set_categories_products_sort_order') .
  536. '</form>';
  537. ?>
  538. </td>
  539. </tr>
  540. <?php } ?>
  541. <tr>
  542. <!-- body_text //-->
  543. <td width="100%" valign="top">
  544. <?php
  545. require(DIR_WS_MODULES . 'category_product_listing.php');
  546. $heading = array();
  547. $contents = array();
  548. // Make an array of product types
  549. $sql = "select type_id, type_name from " . TABLE_PRODUCT_TYPES;
  550. $product_types = $db->Execute($sql);
  551. while (!$product_types->EOF) {
  552. $type_array[] = array('id' => $product_types->fields['type_id'], 'text' => $product_types->fields['type_name']);
  553. $product_types->MoveNext();
  554. }
  555. switch ($action) {
  556. case 'setflag_categories':
  557. $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_STATUS_CATEGORY . '</b>');
  558. $contents = array('form' => zen_draw_form('categories', FILENAME_CATEGORIES, 'action=update_category_status&cPath=' . $_GET['cPath'] . '&cID=' . $_GET['cID'], 'post', 'enctype="multipart/form-data"') . zen_draw_hidden_field('categories_id', $cInfo->categories_id) . zen_draw_hidden_field('categories_status', $cInfo->categories_status));
  559. $contents[] = array('text' => zen_get_category_name($cInfo->categories_id, $_SESSION['languages_id']));
  560. $contents[] = array('text' => '<br />' . TEXT_CATEGORIES_STATUS_WARNING . '<br /><br />');
  561. $contents[] = array('text' => TEXT_CATEGORIES_STATUS_INTRO . ' ' . ($cInfo->categories_status == '1' ? TEXT_CATEGORIES_STATUS_OFF : TEXT_CATEGORIES_STATUS_ON));
  562. if ($cInfo->categories_status == '1') {
  563. $contents[] = array('text' => '<br />' . TEXT_PRODUCTS_STATUS_INFO . ' ' . TEXT_PRODUCTS_STATUS_OFF . zen_draw_hidden_field('set_products_status_off', true));
  564. } else {
  565. $contents[] = array('text' => '<br />' . TEXT_PRODUCTS_STATUS_INFO . '<br />' .
  566. zen_draw_radio_field('set_products_status', 'set_products_status_on', true) . ' ' . TEXT_PRODUCTS_STATUS_ON . '<br />' .
  567. zen_draw_radio_field('set_products_status', 'set_products_status_off') . ' ' . TEXT_PRODUCTS_STATUS_OFF . '<br />' .
  568. zen_draw_radio_field('set_products_status', 'set_products_status_nochange') . ' ' . TEXT_PRODUCTS_STATUS_NOCHANGE);
  569. }
  570. // $contents[] = array('text' => '<br />' . TEXT_PRODUCTS_STATUS_INFO . '<br />' . zen_draw_radio_field('set_products_status', 'set_products_status_off', true) . ' ' . TEXT_PRODUCTS_STATUS_OFF . '<br />' . zen_draw_radio_field('set_products_status', 'set_products_status_on') . ' ' . TEXT_PRODUCTS_STATUS_ON);
  571. $contents[] = array('align' => 'center', 'text' => '<br />' . zen_image_submit('button_update.gif', IMAGE_UPDATE) . ' <a href="' . zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
  572. break;
  573. case 'new_category':
  574. $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_NEW_CATEGORY . '</b>');
  575. $contents = array('form' => zen_draw_form('newcategory', FILENAME_CATEGORIES, 'action=insert_category&cPath=' . $cPath, 'post', 'enctype="multipart/form-data"'));
  576. $contents[] = array('text' => TEXT_NEW_CATEGORY_INTRO);
  577. $category_inputs_string = '';
  578. $languages = zen_get_languages();
  579. for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
  580. $category_inputs_string .= '<br />' . zen_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '&nbsp;' . zen_draw_input_field('categories_name[' . $languages[$i]['id'] . ']', '', zen_set_field_length(TABLE_CATEGORIES_DESCRIPTION, 'categories_name'));
  581. }
  582. $contents[] = array('text' => '<br />' . TEXT_CATEGORIES_NAME . $category_inputs_string);
  583. $category_inputs_string = '';
  584. for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
  585. $category_inputs_string .= '<br />' . zen_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '&nbsp;';
  586. if ($_SESSION['html_editor_preference_status']=='FCKEDITOR') {
  587. $oFCKeditor = new FCKeditor('categories_description[' . $languages[$i]['id'] . ']') ;
  588. $oFCKeditor->Value = zen_get_category_description($cInfo->categories_id, $languages[$i]['id']);
  589. $oFCKeditor->Width = '97%' ;
  590. $oFCKeditor->Height = '200' ;
  591. // $oFCKeditor->Config['ToolbarLocation'] = 'Out:xToolbar' ;
  592. // $oFCKeditor->Create() ;
  593. $output = $oFCKeditor->CreateHtml() ;
  594. $category_inputs_string .= '<br />' . $output;
  595. // $category_inputs_string .= '<IFRAME src= "' . DIR_WS_CATALOG . 'FCKeditor/fckeditor.html?FieldName=categories_description[' . $languages[$i]['id'] . ']&Upload=false&Browse=false&Toolbar=Short" width="97%" height="200" frameborder="no" scrolling="yes"></IFRAME>';
  596. // $category_inputs_string .= '<INPUT type="hidden" name="categories_description[' . $languages[$i]['id'] . ']" ' . 'value=' . "'" . zen_get_category_description($cInfo->categories_id, $languages[$i]['id']) . "'>";
  597. } else {
  598. $category_inputs_string .= zen_draw_textarea_field('categories_description[' . $languages[$i]['id'] . ']', 'soft', '100%', '20', zen_get_category_description($cInfo->categories_id, $languages[$i]['id']));
  599. }
  600. }
  601. $contents[] = array('text' => '<br />' . TEXT_CATEGORIES_DESCRIPTION . $category_inputs_string);
  602. $contents[] = array('text' => '<br />' . TEXT_CATEGORIES_IMAGE . '<br />' . zen_draw_file_field('categories_image'));
  603. $dir = @dir(DIR_FS_CATALOG_IMAGES);
  604. $dir_info[] = array('id' => '', 'text' => "Main Directory");
  605. while ($file = $dir->read()) {
  606. if (is_dir(DIR_FS_CATALOG_IMAGES . $file) && strtoupper($file) != 'CVS' && $file != "." && $file != "..") {
  607. $dir_info[] = array('id' => $file . '/', 'text' => $file);
  608. }
  609. }
  610. $dir->close();
  611. sort($dir_info);
  612. $default_directory = 'categories/';
  613. $contents[] = array('text' => TEXT_CATEGORIES_IMAGE_DIR . ' ' . zen_draw_pull_down_menu('img_dir', $dir_info, $default_directory));
  614. $contents[] = array('text' => '<br />' . TEXT_CATEGORIES_IMAGE_MANUAL . '&nbsp;' . zen_draw_input_field('categories_image_manual'));
  615. $contents[] = array('text' => '<br />' . TEXT_SORT_ORDER . '<br />' . zen_draw_input_field('sort_order', '', 'size="6"'));
  616. $contents[] = array('align' => 'center', 'text' => '<br />' . zen_image_submit('button_save.gif', IMAGE_SAVE) . ' <a href="' . zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
  617. break;
  618. case 'edit_category':
  619. // echo 'I SEE ' . $_SESSION['html_editor_preference_status'];
  620. // set image delete
  621. $on_image_delete = false;
  622. $off_image_delete = true;
  623. $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_EDIT_CATEGORY . '</b>');
  624. $contents = array('form' => zen_draw_form('categories', FILENAME_CATEGORIES, 'action=update_category&cPath=' . $cPath, 'post', 'enctype="multipart/form-data"') . zen_draw_hidden_field('categories_id', $cInfo->categories_id));
  625. $contents[] = array('text' => TEXT_EDIT_INTRO);
  626. $languages = zen_get_languages();
  627. $category_inputs_string = '';
  628. for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
  629. $category_inputs_string .= '<br />' . zen_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '&nbsp;' . zen_draw_input_field('categories_name[' . $languages[$i]['id'] . ']', zen_get_category_name($cInfo->categories_id, $languages[$i]['id']), zen_set_field_length(TABLE_CATEGORIES_DESCRIPTION, 'categories_name'));
  630. }
  631. $contents[] = array('text' => '<br />' . TEXT_EDIT_CATEGORIES_NAME . $category_inputs_string);
  632. $category_inputs_string = '';
  633. for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
  634. $category_inputs_string .= '<br />' . zen_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '&nbsp;' ;
  635. if ($_SESSION['html_editor_preference_status']=='FCKEDITOR') {
  636. $oFCKeditor = new FCKeditor('categories_description[' . $languages[$i]['id'] . ']') ;
  637. $oFCKeditor->Value = zen_get_category_description($cInfo->categories_id, $languages[$i]['id']);
  638. $oFCKeditor->Width = '97%' ;
  639. $oFCKeditor->Height = '200' ;
  640. // $oFCKeditor->Config['ToolbarLocation'] = 'Out:xToolbar' ;
  641. // $oFCKeditor->Create() ;
  642. $output = $oFCKeditor->CreateHtml() ;
  643. $category_inputs_string .= '<br />' . $output;
  644. // $category_inputs_string .= '<IFRAME src= "' . DIR_WS_CATALOG . 'FCKeditor/fckeditor.html?FieldName=categories_description[' . $languages[$i]['id'] . ']&Upload=false&Browse=false&Toolbar=Short" width="97%" height="200" frameborder="no" scrolling="yes"></IFRAME>';
  645. // $category_inputs_string .= '<INPUT type="hidden" name="categories_description[' . $languages[$i]['id'] . ']" ' . 'value=' . "'" . zen_get_category_description($cInfo->categories_id, $languages[$i]['id']) . "'>";
  646. } else {
  647. $category_inputs_string .= zen_draw_textarea_field('categories_description[' . $languages[$i]['id'] . ']', 'soft', '100%', '20', zen_get_category_description($cInfo->categories_id, $languages[$i]['id']));
  648. }
  649. }
  650. $contents[] = array('text' => '<br />' . TEXT_CATEGORIES_DESCRIPTION . $category_inputs_string);
  651. $contents[] = array('text' => '<br />' . TEXT_EDIT_CATEGORIES_IMAGE . '<br />' . zen_draw_file_field('categories_image'));
  652. $dir = @dir(DIR_FS_CATALOG_IMAGES);
  653. $dir_info[] = array('id' => '', 'text' => "Main Directory");
  654. while ($file = $dir->read()) {
  655. if (is_dir(DIR_FS_CATALOG_IMAGES . $file) && strtoupper($file) != 'CVS' && $file != "." && $file != "..") {
  656. $dir_info[] = array('id' => $file . '/', 'text' => $file);
  657. }
  658. }
  659. $dir->close();
  660. sort($dir_info);
  661. $default_directory = substr( $cInfo->categories_image, 0,strpos( $cInfo->categories_image, '/')+1);
  662. $contents[] = array('text' => TEXT_CATEGORIES_IMAGE_DIR . ' ' . zen_draw_pull_down_menu('img_dir', $dir_info, $default_directory));
  663. $contents[] = array('text' => '<br />' . TEXT_CATEGORIES_IMAGE_MANUAL . '&nbsp;' . zen_draw_input_field('categories_image_manual'));
  664. $contents[] = array('text' => '<br />' . zen_info_image($cInfo->categories_image, $cInfo->categories_name));
  665. $contents[] = array('text' => '<br />' . $cInfo->categories_image);
  666. $contents[] = array('text' => '<br />' . TEXT_IMAGES_DELETE . ' ' . zen_draw_radio_field('image_delete', '0', $off_image_delete) . '&nbsp;' . TABLE_HEADING_NO . ' ' . zen_draw_radio_field('image_delete', '1', $on_image_delete) . '&nbsp;' . TABLE_HEADING_YES);
  667. $contents[] = array('text' => '<br />' . TEXT_EDIT_SORT_ORDER . '<br />' . zen_draw_input_field('sort_order', $cInfo->sort_order, 'size="6"'));
  668. $contents[] = array('align' => 'center', 'text' => '<br />' . zen_image_submit('button_save.gif', IMAGE_SAVE) . ' <a href="' . zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $cInfo->categories_id) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
  669. $contents[] = array('text' => TEXT_RESTRICT_PRODUCT_TYPE . ' ' . zen_draw_pull_down_menu('restrict_type', $type_array) . '&nbsp<input type="submit" name="add_type_all" value="' . BUTTON_ADD_PRODUCT_TYPES_SUBCATEGORIES_ON . '">' . '&nbsp<input type="submit" name="add_type" value="' . BUTTON_ADD_PRODUCT_TYPES_SUBCATEGORIES_OFF . '">');
  670. $sql = "select * from " . TABLE_PRODUCT_TYPES_TO_CATEGORY . "
  671. where category_id = '" . $cInfo->categories_id . "'";
  672. $restrict_types = $db->Execute($sql);
  673. if ($restrict_types->RecordCount() > 0 ) {
  674. $contents[] = array('text' => '<br />' . TEXT_CATEGORY_HAS_RESTRICTIONS . '<br />');
  675. while (!$restrict_types->EOF) {
  676. $sql = "select type_name from " . TABLE_PRODUCT_TYPES . " where type_id = '" . $restrict_types->fields['product_type_id'] . "'";
  677. $type = $db->Execute($sql);
  678. $contents[] = array('text' => '<a href="' . zen_href_link(FILENAME_CATEGORIES, 'action=remove_type&cPath=' . $cPath . '&cID='.$cInfo->categories_id.'&type_id='.$restrict_types->fields['product_type_id']) . '">' . zen_image_button('button_delete.gif', IMAGE_DELETE) . '</a>&nbsp;' . $type->fields['type_name'] . '<br />');
  679. $restrict_types->MoveNext();
  680. }
  681. }
  682. break;
  683. case 'delete_category':
  684. $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_DELETE_CATEGORY . '</b>');
  685. $contents = array('form' => zen_draw_form('categories', FILENAME_CATEGORIES, 'action=delete_category_confirm&cPath=' . $cPath) . zen_draw_hidden_field('categories_id', $cInfo->categories_id));
  686. $contents[] = array('text' => TEXT_DELETE_CATEGORY_INTRO);
  687. $contents[] = array('text' => '<br />' . TEXT_DELETE_CATEGORY_INTRO_LINKED_PRODUCTS);
  688. $contents[] = array('text' => '<br /><b>' . $cInfo->categories_name . '</b>');
  689. if ($cInfo->childs_count > 0) $contents[] = array('text' => '<br />' . sprintf(TEXT_DELETE_WARNING_CHILDS, $cInfo->childs_count));
  690. if ($cInfo->products_count > 0) $contents[] = array('text' => '<br />' . sprintf(TEXT_DELETE_WARNING_PRODUCTS, $cInfo->products_count));
  691. /*
  692. // future cat specific
  693. if ($cInfo->products_count > 0) {
  694. $contents[] = array('text' => '<br />' . TEXT_PRODUCTS_LINKED_INFO . '<br />' .
  695. zen_draw_radio_field('delete_linked', 'delete_linked_yes') . ' ' . TEXT_PRODUCTS_DELETE_LINKED_YES . '<br />' .
  696. zen_draw_radio_field('delete_linked', 'delete_linked_no', true) . ' ' . TEXT_PRODUCTS_DELETE_LINKED_NO);
  697. }
  698. */
  699. $contents[] = array('align' => 'center', 'text' => '<br />' . zen_image_submit('button_delete.gif', IMAGE_DELETE) . ' <a href="' . zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $cInfo->categories_id) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
  700. break;
  701. // bof: categories meta tags
  702. case 'edit_category_meta_tags':
  703. $heading[] = array('text' => '<strong>' . TEXT_INFO_HEADING_EDIT_CATEGORY_META_TAGS . '</strong>');
  704. $contents = array('form' => zen_draw_form('categories', FILENAME_CATEGORIES, 'action=update_category_meta_tags&cPath=' . $cPath, 'post', 'enctype="multipart/form-data"') . zen_draw_hidden_field('categories_id', $cInfo->categories_id));
  705. $contents[] = array('text' => TEXT_EDIT_CATEGORIES_META_TAGS_INTRO . ' - <strong>' . $cInfo->categories_id . ' ' . $cInfo->categories_name . '</strong>');
  706. $languages = zen_get_languages();
  707. $category_inputs_string_metatags_title = '';
  708. for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
  709. $category_inputs_string_metatags_title .= '<br />' . zen_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['metatags_title']) . '&nbsp;' . zen_draw_input_field('metatags_title[' . $languages[$i]['id'] . ']', zen_get_category_metatags_title($cInfo->categories_id, $languages[$i]['id']), zen_set_field_length(TABLE_METATAGS_CATEGORIES_DESCRIPTION, 'metatags_title'));
  710. }
  711. $contents[] = array('text' => '<br />' . TEXT_EDIT_CATEGORIES_META_TAGS_TITLE . $category_inputs_string_metatags_title);
  712. $category_inputs_string_metatags_keywords = '';
  713. for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
  714. $category_inputs_string_metatags_keywords .= '<br />' . zen_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['metatags_keywords']) . '&nbsp;' ;
  715. $category_inputs_string_metatags_keywords .= zen_draw_textarea_field('metatags_keywords[' . $languages[$i]['id'] . ']', 'soft', '100%', '20', zen_get_category_metatags_keywords($cInfo->categories_id, $languages[$i]['id']));
  716. }
  717. $contents[] = array('text' => '<br />' . TEXT_EDIT_CATEGORIES_META_TAGS_KEYWORDS . $category_inputs_string_metatags_keywords);
  718. $category_inputs_string_metatags_description = '';
  719. for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
  720. $category_inputs_string_metatags_description .= '<br />' . zen_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '&nbsp;' ;
  721. $category_inputs_string_metatags_description .= zen_draw_textarea_field('metatags_description[' . $languages[$i]['id'] . ']', 'soft', '100%', '20', zen_get_category_metatags_description($cInfo->categories_id, $languages[$i]['id']));
  722. }
  723. $contents[] = array('text' => '<br />' . TEXT_EDIT_CATEGORIES_META_TAGS_DESCRIPTION . $category_inputs_string_metatags_description);
  724. $contents[] = array('align' => 'center', 'text' => '<br />' . zen_image_submit('button_save.gif', IMAGE_SAVE) . ' <a href="' . zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $cInfo->categories_id) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
  725. break;
  726. // eof: categories meta tags
  727. case 'move_category':
  728. $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_MOVE_CATEGORY . '</b>');
  729. $contents = array('form' => zen_draw_form('categories', FILENAME_CATEGORIES, 'action=move_category_confirm&cPath=' . $cPath) . zen_draw_hidden_field('categories_id', $cInfo->categories_id));
  730. $contents[] = array('text' => sprintf(TEXT_MOVE_CATEGORIES_INTRO, $cInfo->categories_name));
  731. $contents[] = array('text' => '<br />' . sprintf(TEXT_MOVE, $cInfo->categories_name) . '<br />' . zen_draw_pull_down_menu('move_to_category_id', zen_get_category_tree(), $current_category_id));
  732. $contents[] = array('align' => 'center', 'text' => '<br />' . zen_image_submit('button_move.gif', IMAGE_MOVE) . ' <a href="' . zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $cInfo->categories_id) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
  733. break;
  734. case 'delete_product':
  735. $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_DELETE_PRODUCT . '</b>');
  736. $contents = array('form' => zen_draw_form('products', FILENAME_CATEGORIES, 'action=delete_product_confirm&cPath=' . $cPath . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')) . zen_draw_hidden_field('products_id', $pInfo->products_id));
  737. $contents[] = array('text' => TEXT_DELETE_PRODUCT_INTRO);
  738. $contents[] = array('text' => '<br /><b>' . $pInfo->products_name . ' ID#' . $pInfo->products_id . '</b>');
  739. $product_categories_string = '';
  740. $product_categories = zen_generate_category_path($pInfo->products_id, 'product');
  741. for ($i = 0, $n

Large files files are truncated, but you can click here to view the full file