AlanR Posted December 20, 2005 Share Posted December 20, 2005 Modify New Product page to support image directories ------------------------------------------------------------ This is a simple modification to /admin/categories.php It adds a new field to the new product page named: Image Subdir. (images/...): just above the Product Image: field There is also a very minor change to /admin/includes/languages/english/categories.php. It adds only one line to define a new field name. This keeps the language defines stucture consistent with osC standards ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In this field you can add the path to your image location, ie: /pets, pets/dogs, pets/dogs/brown and so on. Add the path in that field, browse to to the correct image on your pc and the file will be uploaded to the correct directory and the image file name in the database will indicate the correct location, ie: /pets/kitty.jpg. The operations are identical to using the standard categories.php but with the addition of image paths. Delete a product and the corresponding image is deleted. The directories must exist on the server, it will not create them and they must be writable. If they can not be found or or not writable the standard osC error checking will give you a warning. You'll have to know/remember the directory names (sticky notes are good). It's based on the 051113 update version of osC MS2 so it incorporates all current updates. The changes are fairly simple and most users are using the stock categories.php file so this can just be used in its place. There is one simple change to admin/includes/languages/categories.php to add the name for the field in keeping with osC language conventions. I've only tested this on Unix/Linux systems but from my understanding it should be cross platform (it uses forward slashes in php for the subdirectory pointing). The installation instructions are in the install document. Quote Local: Mac OS X 10.5.8 - Apache 2.2/php 5.3.0/MySQL 5.4.10 • Web Servers: Linux Tools: BBEdit, Coda, Versions (Subversion), Sequel Pro (db management) Link to comment Share on other sites More sharing options...
sakura811 Posted December 20, 2005 Share Posted December 20, 2005 i just dl your Contributions, but having problems to unpack the zip file, seem like your file name is too long or has syntax problem, please rename your file and try to zip it again. Quote Link to comment Share on other sites More sharing options...
AlanR Posted December 20, 2005 Author Share Posted December 20, 2005 I'm not sure whether you had problems with the length of the folder (and zip file) name or the files inside. I uploaded a newly named folder (zipped). Try again and let me know if it works for you. If you still have problems I'll have to rename the files inside the folders. What system is your local PC running? Quote Local: Mac OS X 10.5.8 - Apache 2.2/php 5.3.0/MySQL 5.4.10 • Web Servers: Linux Tools: BBEdit, Coda, Versions (Subversion), Sequel Pro (db management) Link to comment Share on other sites More sharing options...
kwalker Posted December 20, 2005 Share Posted December 20, 2005 In the /image_paths/ folder, you need to rename the files by getting get rid of those : (colon) . (period) the _ shouldn't pose a problem. Kevin Quote "What I didn't know yesterday, I know today & will remember tomorrow" (By Kwalker) What do you see when you open up the tep_database-pr2.2-CVS.pdf file that came with your osCommerce download? Link to comment Share on other sites More sharing options...
AlanR Posted December 20, 2005 Author Share Posted December 20, 2005 In the /image_paths/ folder, you need to rename the files by getting get rid of those : (colon) . (period) the _ shouldn't pose a problem. Kevin You mean in the folder containing the actual files? Some systems have trouble with '.' ? These are the files within the folder: admin/categories.php admin/includes/languages/english/categories.php Description.txt Install.txt screenshot.png There's nothing there that a standard download of an osC install wouldn't have. Quote Local: Mac OS X 10.5.8 - Apache 2.2/php 5.3.0/MySQL 5.4.10 • Web Servers: Linux Tools: BBEdit, Coda, Versions (Subversion), Sequel Pro (db management) Link to comment Share on other sites More sharing options...
eurokits Posted December 21, 2005 Share Posted December 21, 2005 FANTASTIC !!!!!!! OK. GOOOOODDDDDD. THANKS !!! Quote Link to comment Share on other sites More sharing options...
paul_calf Posted December 22, 2005 Share Posted December 22, 2005 hi after installing your contribution i also installed '3 images'. small images work fine but medium and large are assigned to the 'images' directory. how can i assign these to the same subdirectory? hope you can help, paul. Quote Link to comment Share on other sites More sharing options...
kwalker Posted December 23, 2005 Share Posted December 23, 2005 You mean in the folder containing the actual files? Some systems have trouble with '.' ? These are the files within the folder: admin/categories.php admin/includes/languages/english/categories.php Description.txt Install.txt screenshot.png There's nothing there that a standard download of an osC install wouldn't have. AlanR, thanks for picking up on that.. I meant the folders... not the files itself.. My Bad.... Kevin Quote "What I didn't know yesterday, I know today & will remember tomorrow" (By Kwalker) What do you see when you open up the tep_database-pr2.2-CVS.pdf file that came with your osCommerce download? Link to comment Share on other sites More sharing options...
AlanR Posted December 27, 2005 Author Share Posted December 27, 2005 As you can see I added the option (configurable, you can turn it off) to create new image subdirectories "on the fly". That composite screenshot was made from the New Product screen, creating new directories then immediately viewing the new product in the Categories / Products screen. My goal was to enable direct creation of subdirectories from within the new products screen, "on the fly" so to speak, ie: images/pets/cats and so on. It's in this version, it seemed inconsistent to tell a user that they must use a second program to create directories as they were needed them in the new product screen. Some simple settings in the file must be configured to suit your server environment and installation specifics. Quote Local: Mac OS X 10.5.8 - Apache 2.2/php 5.3.0/MySQL 5.4.10 • Web Servers: Linux Tools: BBEdit, Coda, Versions (Subversion), Sequel Pro (db management) Link to comment Share on other sites More sharing options...
osSea Posted December 31, 2005 Share Posted December 31, 2005 (edited) Hi Alan. Thanks for the about-to-be-very-useful contrib. Regarding the problem with your package directory names, specifically one categories.php file resides in a directory named 'admin:includes:languages:english', and Windows throws an error when trying to decompress it (Windows doesn't allow colons in file/directory names: I know, not a problem on MacOS). I had to view the categories.php file from within WinRAR and copy/paste the contents into a text editor then save the file locally. A simple nested directory packaging should fix the problem. I'm having difficulty getting the 'New?' checkbox to display. I checked /catalog/admin/includes/functions/html_output.php for the tep_draw_checkbox_field() function parameters and I think they may have been passed incorrectly in this contrib, but not being much of a php'er I'm not sure. Let me know if I missed a config option or if there're any code snippets I can post to help you (and me) figure it out. Cheers. Edited December 31, 2005 by osSea Quote Link to comment Share on other sites More sharing options...
AlanR Posted December 31, 2005 Author Share Posted December 31, 2005 Hi Alan. Thanks for the about-to-be-very-useful contrib. Regarding the problem with your package directory names, specifically one categories.php file resides in a directory named 'admin:includes:languages:english', and Windows throws an error when trying to decompress it (Windows doesn't allow colons in file/directory names: I know, not a problem on MacOS). I had to view the categories.php file from within WinRAR and copy/paste the contents into a text editor then save the file locally. A simple nested directory packaging should fix the problem. I'm having difficulty getting the 'New?' checkbox to display. I checked /catalog/admin/includes/functions/html_output.php for the tep_draw_checkbox_field() function parameters and I think they may have been passed incorrectly in this contrib, but not being much of a php'er I'm not sure. Let me know if I missed a config option or if there're any code snippets I can post to help you (and me) figure it out. Cheers. Did you enable the checkbox in the config lines at the top? I used no parameters for the checkbox, only the first three values for the function are needed. Quote Local: Mac OS X 10.5.8 - Apache 2.2/php 5.3.0/MySQL 5.4.10 • Web Servers: Linux Tools: BBEdit, Coda, Versions (Subversion), Sequel Pro (db management) Link to comment Share on other sites More sharing options...
AlanR Posted December 31, 2005 Author Share Posted December 31, 2005 I realized that long file name is the result of nesting empty folder then zipping. It happens even when the folder is zipped on the Linux server. The Mac aliases slashes in file names to colons when the file is zipped. The server version gives you a file name in a string with slashes, no directory structure. I want to make it as easy to understand for newbies as possible so I've now put a placeholder file in each otherwise empty folder and the directory structure is preserved. It's admin/includes/languages/english/catagories.php so I've put a placeholder file in each of /includes/languages/english/. I'll upload that later on. In any case you can edit the existing languages file, there are only three lines to add. Here's a block from the file: define('TEXT_PRODUCTS_STATUS', 'Products Status:'); define('TEXT_PRODUCTS_DATE_AVAILABLE', 'Date Available:'); define('TEXT_PRODUCT_AVAILABLE', 'In Stock'); define('TEXT_PRODUCT_NOT_AVAILABLE', 'Out of Stock'); define('TEXT_PRODUCTS_MANUFACTURER', 'Products Manufacturer:'); define('TEXT_PRODUCTS_NAME', 'Products Name:'); define('TEXT_PRODUCTS_DESCRIPTION', 'Products Description:'); define('TEXT_PRODUCTS_QUANTITY', 'Products Quantity:'); define('TEXT_PRODUCTS_MODEL', 'Products Model:'); define('TEXT_IMAGE_DIRECTORY', 'Image Subdirectory:'); // name of subdir field define('TEXT_IMAGE_PATH_NOTE' , 'images/.../...'); // note under image subdir name define('TEXT_IMAGE_PATH_CHECKBOX' , 'New?'); // checkbox next to image subdir name define('TEXT_PRODUCTS_IMAGE', 'Products Image:'); define('TEXT_PRODUCTS_URL', 'Products URL:'); define('TEXT_PRODUCTS_URL_WITHOUT_HTTP', '<small>(without http://)</small>'); define('TEXT_PRODUCTS_PRICE_NET', 'Products Price (Net):'); define('TEXT_PRODUCTS_PRICE_GROSS', 'Products Price (Gross):'); define('TEXT_PRODUCTS_WEIGHT', 'Products Weight:'); So that solves that problem for now. As to problems seeing the checkbox, see the next post... Quote Local: Mac OS X 10.5.8 - Apache 2.2/php 5.3.0/MySQL 5.4.10 • Web Servers: Linux Tools: BBEdit, Coda, Versions (Subversion), Sequel Pro (db management) Link to comment Share on other sites More sharing options...
AlanR Posted December 31, 2005 Author Share Posted December 31, 2005 Now we can try to figure out why the checkbox does not appear. Add these lines before (or after) at about line 330 // Here we strip away any extra slashes print 'new_dir: ' . $new_dir; print '<br>image_subdirectory: ' . $image_subdirectory; print '<br>USE_REG_GLOBALS_PATCH : ' . USE_REG_GLOBALS_PATCH; print '<br>USE_PHP5_MKDIR : ' . USE_PHP5_MKDIR; print '<br>SHOW_DIR_CHECKBOX : ' . SHOW_DIR_CHECKBOX; print '<br>USE_UNIX_SLASHES : ' . USE_UNIX_SLASHES; Then, after you click preview you'll see the result from these lines at the top of the screen, like so... new_dir: on image_subdirectory: mydir1/mydir2 USE_REG_GLOBALS_PATCH : false USE_PHP5_MKDIR : false SHOW_DIR_CHECKBOX : true USE_UNIX_SLASHES : true You can also override the configuration setting for the checkbox by defeating the test. At about line 650 you'll find a line starting with if (SHOW_DIR_CHECKBOX == 'true') Just change that to if ('true' == 'true') and you defeat the configuration value, good for a test. Let me know what you find. Quote Local: Mac OS X 10.5.8 - Apache 2.2/php 5.3.0/MySQL 5.4.10 • Web Servers: Linux Tools: BBEdit, Coda, Versions (Subversion), Sequel Pro (db management) Link to comment Share on other sites More sharing options...
AlanR Posted December 31, 2005 Author Share Posted December 31, 2005 hi after installing your contribution i also installed '3 images'. small images work fine but medium and large are assigned to the 'images' directory. how can i assign these to the same subdirectory? hope you can help, paul. It's a pretty simple change From the 3 Images contribution I snagged this: // Big Image Start $products_mediumimage = new upload('products_mediumimage'); $products_mediumimage->set_destination(DIR_FS_CATALOG_IMAGES); if ($products_mediumimage->parse() && $products_mediumimage->save()) { $products_mediumimage_name = $products_mediumimage->filename; } else { $products_mediumimage_name = (isset($HTTP_POST_VARS['products_previous_mediumimage']) ? $HTTP_POST_VARS['products_previous_mediumimage'] : ''); } $products_largeimage = new upload('products_largeimage'); $products_largeimage->set_destination(DIR_FS_CATALOG_IMAGES); if ($products_largeimage->parse() && $products_largeimage->save()) { $products_largeimage_name = $products_largeimage->filename; } else { $products_largeimage_name = (isset($HTTP_POST_VARS['products_previous_largeimage']) ? $HTTP_POST_VARS['products_previous_largeimage'] : ''); } // Big Image End And tweaked it to append the subdirectory to the destination folder and prepend the subdirectory to the image name like so... // Big Image Start $products_mediumimage = new upload('products_mediumimage'); $products_mediumimage->set_destination(DIR_FS_CATALOG_IMAGES . $image_subdirectory); if ($products_mediumimage->parse() && $products_mediumimage->save()) { $products_mediumimage_name = ($image_subdirectory . $products_mediumimage)->filename; } else { $products_mediumimage_name = (isset($HTTP_POST_VARS['products_previous_mediumimage']) ? $HTTP_POST_VARS['products_previous_mediumimage'] : ''); } $products_largeimage = new upload('products_largeimage'); $products_largeimage->set_destination(DIR_FS_CATALOG_IMAGES . $image_subdirectory); if ($products_largeimage->parse() && $products_largeimage->save()) { $products_largeimage_name = ($image_subdirectory . $products_largeimage)->filename; } else { $products_largeimage_name = (isset($HTTP_POST_VARS['products_previous_largeimage']) ? $HTTP_POST_VARS['products_previous_largeimage'] : ''); } // Big Image End I haven't tested this but it's pretty easy to see and understand what I've done so you can play with it if you need to. Quote Local: Mac OS X 10.5.8 - Apache 2.2/php 5.3.0/MySQL 5.4.10 • Web Servers: Linux Tools: BBEdit, Coda, Versions (Subversion), Sequel Pro (db management) Link to comment Share on other sites More sharing options...
paul_calf Posted January 1, 2006 Share Posted January 1, 2006 thanks for the reply alan. i followed your changes and now get the following message: Parse error: parse error, unexpected T_OBJECT_OPERATOR in admin/categories.php on line 373 any ideas? Quote Link to comment Share on other sites More sharing options...
osSea Posted January 3, 2006 Share Posted January 3, 2006 (edited) Thanks for the reply Alan, and Happy New Year. Here's what I came up with. When flipping the CHECKBOX switch ('true' == 'true') as the only code change, it appears where it should. Next, I added the code: // Here we strip away any extra slashes the user may add to the subdirectory field and make sure there is a final /. /* ### TESTING - Image Subdirs - echo config parameters */ print 'new_dir: ' . $new_dir; print '<br>image_subdirectory: ' . $image_subdirectory; print '<br>USE_REG_GLOBALS_PATCH : ' . USE_REG_GLOBALS_PATCH; print '<br>USE_PHP5_MKDIR : ' . USE_PHP5_MKDIR; print '<br>SHOW_DIR_CHECKBOX : ' . SHOW_DIR_CHECKBOX; print '<br>USE_UNIX_SLASHES : ' . USE_UNIX_SLASHES; /* TESTING ### */ $image_subdirectory = preg_replace('/\\\/', '/', $image_subdirectory); // in case someone mistakenly uses backward slashes, flip 'em around if ($image_subdirectory == '/') { ($image_subdirectory = ''); // in case the user mistakenly entered only a single / } Now after clicking the 'Preview' button, this is displayed at the top of the page: new_dir:image_subdirectory: USE_REG_GLOBALS_PATCH : USE_REG_GLOBALS_PATCH USE_PHP5_MKDIR : USE_PHP5_MKDIR SHOW_DIR_CHECKBOX : SHOW_DIR_CHECKBOX USE_UNIX_SLASHES : USE_UNIX_SLASHES My php.ini is set to 'register_globals=On' (I'm assuming as some requirement of my hosting company's control panel or other site application: perhaps even osC itself?). So for some reason the variables are not being passed correctly or at all? Does this help give you a clue about what's happening? Edited January 3, 2006 by osSea Quote Link to comment Share on other sites More sharing options...
osSea Posted January 3, 2006 Share Posted January 3, 2006 Got it. My bad. I add comment tags when I modify any files and I didn't close the opening tag in admin/categories.php, causing the variable definitions to not be parsed... Working through your suggestions helped me track it down. As it appeared the variables were not being defined, I ended up back at the beginning where I noticed my mistake. Sorry to waste your time, but thank you for your help nonetheless. This is an excellent contribution and is well worth working through my own stupidity for :blush: Cheers. Quote Link to comment Share on other sites More sharing options...
AlanR Posted January 4, 2006 Author Share Posted January 4, 2006 thanks for the reply alan. i followed your changes and now get the following message: Parse error: parse error, unexpected T_OBJECT_OPERATOR in admin/categories.php on line 373 any ideas? Without installing and combining the 3 Images contribution with this one there's not a lot I can do to help you. Check for mistakes you may have made, if you can't find any it's time to get your feet a little wet with php. This is the simplest part of my contibution, all I'm doing is capturing a string that you place into the subdirectory field ( $image_subdirectory ) and then concatenating (adding) it onto the front of the filename... $products_largeimage_name = ($image_subdirectory . $products_largeimage) and at the end of the target image directory... set_destination(DIR_FS_CATALOG_IMAGES . $image_subdirectory) Revert one or the other (medium or large) types back to the original code and tinker around with the other one till you get the correct result. It'll be easier than you think and you'll learn something new. Quote Local: Mac OS X 10.5.8 - Apache 2.2/php 5.3.0/MySQL 5.4.10 • Web Servers: Linux Tools: BBEdit, Coda, Versions (Subversion), Sequel Pro (db management) Link to comment Share on other sites More sharing options...
paul_calf Posted January 6, 2006 Share Posted January 6, 2006 Without installing and combining the 3 Images contribution with this one there's not a lot I can do to help you. Check for mistakes you may have made, if you can't find any it's time to get your feet a little wet with php. This is the simplest part of my contibution, all I'm doing is capturing a string that you place into the subdirectory field ( $image_subdirectory ) and then concatenating (adding) it onto the front of the filename... $products_largeimage_name = ($image_subdirectory . $products_largeimage) and at the end of the target image directory... set_destination(DIR_FS_CATALOG_IMAGES . $image_subdirectory) Revert one or the other (medium or large) types back to the original code and tinker around with the other one till you get the correct result. It'll be easier than you think and you'll learn something new. hi alan, revising singularly the medium image code gives me "Parse error: parse error, unexpected T_OBJECT_OPERATOR in admin/categories.php on line 373". revising singularly the large image code gives me "Parse error: parse error, unexpected T_OBJECT_OPERATOR in admin/categories.php on line 381". i intend on learning php once the shop's up and running but for now i just have to get it up asap. is the following code of any assistance? much appreciated, paul. <?php/* $Id: categories.php,v 1.146 2003/07/11 14:40:27 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright © 2003 osCommerce Released under the GNU General Public License */ require('includes/application_top.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 'insert_category': case 'update_category': if (isset($HTTP_POST_VARS['categories_id'])) $categories_id = tep_db_prepare_input($HTTP_POST_VARS['categories_id']); $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']; $language_id = $languages[$i]['id']; $sql_data_array = array('categories_name' => tep_db_prepare_input($categories_name_array[$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 ($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] . "'"); } $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); } } 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'])); 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']); } // big image mod starts // if (isset($HTTP_POST_VARS['products_mediumimage'])) { // if (tep_not_null($HTTP_POST_VARS['products_mediumimage']) && ($HTTP_POST_VARS['products_mediumimage'] != 'none')) { if (isset($HTTP_POST_VARS['products_mediumimage']) && tep_not_null($HTTP_POST_VARS['products_mediumimage']) && ($HTTP_POST_VARS['products_mediumimage'] != 'none')) { $sql_data_array['products_mediumimage'] = tep_db_prepare_input($HTTP_POST_VARS['products_mediumimage']); } elseif (isset($HTTP_POST_VARS['products_image']) && tep_not_null($HTTP_POST_VARS['products_image']) && ($HTTP_POST_VARS['products_image'] != 'none')) { $sql_data_array['products_mediumimage'] = tep_db_prepare_input($HTTP_POST_VARS['products_image']); } // if (isset($HTTP_POST_VARS['products_largeimage'])) { // if (tep_not_null($HTTP_POST_VARS['products_largeimage']) && ($HTTP_POST_VARS['products_largeimage'] != 'none')) { if (isset($HTTP_POST_VARS['products_largeimage']) && tep_not_null($HTTP_POST_VARS['products_largeimage']) && ($HTTP_POST_VARS['products_largeimage'] != 'none')) { $sql_data_array['products_largeimage'] = tep_db_prepare_input($HTTP_POST_VARS['products_largeimage']); } elseif (isset($HTTP_POST_VARS['products_mediumimage']) && tep_not_null($HTTP_POST_VARS['products_mediumimage']) && ($HTTP_POST_VARS['products_mediumimage'] != 'none')) { $sql_data_array['products_largeimage'] = tep_db_prepare_input($HTTP_POST_VARS['products_mediumimage']); } elseif (isset($HTTP_POST_VARS['products_image']) && tep_not_null($HTTP_POST_VARS['products_image']) && ($HTTP_POST_VARS['products_image'] != 'none')) { $sql_data_array['products_largeimage'] = tep_db_prepare_input($HTTP_POST_VARS['products_image']); } // big image mod ends 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 . "'"); } $languages = tep_get_languages(); for ($i=0, $n=sizeof($languages); $i<$n; $i++) { $language_id = $languages[$i]['id']; $sql_data_array = array('products_name' => tep_db_prepare_input($HTTP_POST_VARS['products_name'][$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])); 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 . "'"); } } 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': 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') { // BoF Bug Fix for 3 Images copy product as duplicate. $product_query = tep_db_query("select products_quantity, products_model, products_image, products_mediumimage, products_largeimage, products_price, products_date_available, products_weight, products_tax_class_id, manufacturers_id 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_mediumimage, products_largeimage, products_price, products_date_added, products_date_available, products_weight, products_status, products_tax_class_id, manufacturers_id) values ('" . tep_db_input($product['products_quantity']) . "', '" . tep_db_input($product['products_model']) . "', '" . tep_db_input($product['products_image']) . "', '" . tep_db_input($product['products_mediumimage']) . "', '" . tep_db_input($product['products_largeimage']) . "', '" . tep_db_input($product['products_price']) . "', now(), '" . tep_db_input($product['products_date_available']) . "', '" . tep_db_input($product['products_weight']) . "', '0', '" . (int)$product['products_tax_class_id'] . "', '" . (int)$product['manufacturers_id'] . "')"); // EoF Bug Fix for 3 Images copy products as duplicate. // big image ammended $product_query = tep_db_query("select products_quantity, products_model, products_image, products_mediumimage, products_largeimage, products_price, products_date_available, products_weight, products_tax_class_id, manufacturers_id 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_mediumimage, products_largeimage, products_price, products_date_added, products_date_available, products_weight, products_status, products_tax_class_id, manufacturers_id) values ('" . tep_db_input($product['products_quantity']) . "', '" . tep_db_input($product['products_model']) . "', '" . tep_db_input($product['products_image']) . "', '" . tep_db_input($product['products_mediumimage']) . "', '" . tep_db_input($product['products_largeimage']) . "', '" . tep_db_input($product['products_price']) . "', now(), '" . tep_db_input($product['products_date_available']) . "', '" . tep_db_input($product['products_weight']) . "', '0', '" . (int)$product['products_tax_class_id'] . "', '" . (int)$product['manufacturers_id'] . "')"); $dup_products_id = tep_db_insert_id(); // big image ammended stops $description_query = tep_db_query("select language_id, products_name, products_description, 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, products_description, products_url, products_viewed) values ('" . (int)$dup_products_id . "', '" . (int)$description['language_id'] . "', '" . tep_db_input($description['products_name']) . "', '" . tep_db_input($description['products_description']) . "', '" . tep_db_input($description['products_url']) . "', '0')"); } 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'); // Image path modication starts below // Here we strip away any extra slashes the user may add to the subdirectory field and make sure there is a final /. $image_subdirectory = preg_replace('/\\\/', '/', $image_subdirectory); // in case someone mistakenly uses backward slashes, flip 'em around if ($image_subdirectory == '/') { ($image_subdirectory = ''); // in case the user mistakenly entered only a single / } if ($image_subdirectory != '') { // we want to add a path $image_subdirectory = preg_replace('/\/\/+/', '/', $image_subdirectory); // change any multiple slashes to a single / if (strpos($image_subdirectory, '/') === 0) { $image_subdirectory = substr($image_subdirectory, 1); // strip any leading slash } if (strrpos($image_subdirectory, '/') != (strlen($image_subdirectory) -1)) { $image_subdirectory = ($image_subdirectory . '/'); // add one slash at the end if there wasn't one. } } // End corrections $products_image->set_destination(DIR_FS_CATALOG_IMAGES . $image_subdirectory ); // ***** append server image subdirectory if ($products_image->parse() && $products_image->save()) { $products_image_name = $products_image->filename; $products_image_name = $image_subdirectory . $products_image_name ; // ***** Prepend subdirectory to filename } else { $products_image_name = (isset($HTTP_POST_VARS['products_previous_image']) ? $HTTP_POST_VARS['products_previous_image'] : ''); } // Big Image Start $products_mediumimage = new upload('products_mediumimage'); $products_mediumimage->set_destination(DIR_FS_CATALOG_IMAGES); if ($products_mediumimage->parse() && $products_mediumimage->save()) { $products_mediumimage = $products_mediumimage->filename; } else { $products_mediumimage_name = (isset($HTTP_POST_VARS['products_previous_mediumimage']) ? $HTTP_POST_VARS['products_previous_mediumimage'] : ''); } $products_largeimage = new upload('products_largeimage'); $products_largeimage->set_destination(DIR_FS_CATALOG_IMAGES); if ($products_largeimage->parse() && $products_largeimage->save()) { $products_largeimage_name = $products_largeimage->filename; } else { $products_largeimage_name = (isset($HTTP_POST_VARS['products_previous_largeimage']) ? $HTTP_POST_VARS['products_previous_largeimage'] : ''); } // Big Image End 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> <?php // Big Image Start ? > // <script language="javascript"><!-- // function popupImageWindow(url) { // window.open(url,'popupImageWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,res izable=yes,copyhistory=no,width=100,height=100,screenX=150,screenY=150,top=150,le ft=150') // } //--></ script> // Big Image End ?> </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"> <?php if ($action == 'new_product') { $parameters = array('products_name' => '', 'products_description' => '', 'products_url' => '', 'products_id' => '', 'products_quantity' => '', 'products_model' => '', 'products_image' => '', // big image begins 'products_mediumimage' => '', 'products_largeimage' => '', // big image ends 'products_price' => '', 'products_weight' => '', 'products_date_added' => '', 'products_last_modified' => '', 'products_date_available' => '', 'products_status' => '', 'products_tax_class_id' => '', 'manufacturers_id' => ''); $pInfo = new objectInfo($parameters); if (isset($HTTP_GET_VARS['pID']) && empty($HTTP_POST_VARS)) { // big image amended // $product_query = tep_db_query("select pd.products_name, pd.products_description, pd.products_url, p.products_id, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_date_added, p.products_last_modified, date_format(p.products_date_available, '%Y-%m-%d') as products_date_available, p.products_status, p.products_tax_class_id, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$HTTP_GET_VARS['pID'] . "' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "'"); $product_query = tep_db_query("select pd.products_name, pd.products_description, pd.products_url, p.products_id, p.products_quantity, p.products_model, p.products_image, p.products_mediumimage, p.products_largeimage, p.products_price, p.products_weight, p.products_date_added, p.products_last_modified, date_format(p.products_date_available, '%Y-%m-%d') as products_date_available, p.products_status, p.products_tax_class_id, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$HTTP_GET_VARS['pID'] . "' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "'"); $product = tep_db_fetch_array($product_query); $pInfo->objectInfo($product); } elseif (tep_not_null($HTTP_POST_VARS)) { $pInfo->objectInfo($HTTP_POST_VARS); $products_name = $HTTP_POST_VARS['products_name']; $products_description = $HTTP_POST_VARS['products_description']; $products_url = $HTTP_POST_VARS['products_url']; } $manufacturers_array = array(array('id' => '', 'text' => TEXT_NONE)); $manufacturers_query = tep_db_query("select manufacturers_id, manufacturers_name from " . TABLE_MANUFACTURERS . " order by manufacturers_name"); while ($manufacturers = tep_db_fetch_array($manufacturers_query)) { $manufacturers_array[] = array('id' => $manufacturers['manufacturers_id'], 'text' => $manufacturers['manufacturers_name']); } $tax_class_array = array(array('id' => '0', 'text' => TEXT_NONE)); $tax_class_query = tep_db_query("select tax_class_id, tax_class_title from " . TABLE_TAX_CLASS . " order by tax_class_title"); while ($tax_class = tep_db_fetch_array($tax_class_query)) { $tax_class_array[] = array('id' => $tax_class['tax_class_id'], 'text' => $tax_class['tax_class_title']); } $languages = tep_get_languages(); if (!isset($pInfo->products_status)) $pInfo->products_status = '1'; switch ($pInfo->products_status) { case '0': $in_status = false; $out_status = true; break; case '1': default: $in_status = true; $out_status = false; } ?> <link rel="stylesheet" type="text/css" href="includes/javascript/spiffyCal/spiffyCal_v2_1.css"> <script language="JavaScript" src="includes/javascript/spiffyCal/spiffyCal_v2_1.js"></script> <script language="javascript"><!-- var dateAvailable = new ctlSpiffyCalendarBox("dateAvailable", "new_product", "products_date_available","btnDate1","<?php echo $pInfo->products_date_available; ?>",scBTNMODE_CUSTOMBLUE); //--></script> <script language="javascript"><!-- var tax_rates = new Array(); <?php for ($i=0, $n=sizeof($tax_class_array); $i<$n; $i++) { if ($tax_class_array[$i]['id'] > 0) { echo 'tax_rates["' . $tax_class_array[$i]['id'] . '"] = ' . tep_get_tax_rate_value($tax_class_array[$i]['id']) . ';' . "\n"; } } ?> function doRound(x, places) { return Math.round(x * Math.pow(10, places)) / Math.pow(10, places); } function getTaxRate() { var selected_value = document.forms["new_product"].products_tax_class_id.selectedIndex; var parameterVal = document.forms["new_product"].products_tax_class_id[selected_value].value; if ( (parameterVal > 0) && (tax_rates[parameterVal] > 0) ) { return tax_rates[parameterVal]; } else { return 0; } } function updateGross() { var taxRate = getTaxRate(); var grossValue = document.forms["new_product"].products_price.value; if (taxRate > 0) { grossValue = grossValue * ((taxRate / 100) + 1); } document.forms["new_product"].products_price_gross.value = doRound(grossValue, 4); } function updateNet() { var taxRate = getTaxRate(); var netValue = document.forms["new_product"].products_price_gross.value; if (taxRate > 0) { netValue = netValue / ((taxRate / 100) + 1); } document.forms["new_product"].products_price.value = doRound(netValue, 4); } //--></script> <?php echo tep_draw_form('new_product', FILENAME_CATEGORIES, 'cPath=' . $cPath . (isset($HTTP_GET_VARS['pID']) ? '&pID=' . $HTTP_GET_VARS['pID'] : '') . '&action=new_product_preview', 'post', 'enctype="multipart/form-data"'); ?> <table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <td><table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td class="pageHeading"><?php echo sprintf(TEXT_NEW_PRODUCT, 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> <tr> <td><table border="0" cellspacing="0" cellpadding="2"> <tr> <td class="main"><?php echo TEXT_PRODUCTS_STATUS; ?></td> <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '?' . tep_draw_radio_field('products_status', '1', $in_status) . '?' . TEXT_PRODUCT_AVAILABLE . '?' . tep_draw_radio_field('products_status', '0', $out_status) . '?' . TEXT_PRODUCT_NOT_AVAILABLE; ?></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_PRODUCTS_DATE_AVAILABLE; ?><br><small>(YYYY-MM-DD)</small></td> <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '?'; ?><script language="javascript">dateAvailable.writeControl(); dateAvailable.dateFormat="yyyy-MM-dd";</script></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_PRODUCTS_MANUFACTURER; ?></td> <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '?' . tep_draw_pull_down_menu('manufacturers_id', $manufacturers_array, $pInfo->manufacturers_id); ?></td> </tr> <tr> <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> </tr> <?php for ($i=0, $n=sizeof($languages); $i<$n; $i++) { ?> <tr> <td class="main"><?php if ($i == 0) echo TEXT_PRODUCTS_NAME; ?></td> <td class="main"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '?' . tep_draw_input_field('products_name[' . $languages[$i]['id'] . ']', (isset($products_name[$languages[$i]['id']]) ? stripslashes($products_name[$languages[$i]['id']]) : tep_get_products_name($pInfo->products_id, $languages[$i]['id']))); ?></td> </tr> <?php } ?> <tr> <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> </tr> <tr bgcolor="#ebebff"> <td class="main"><?php echo TEXT_PRODUCTS_TAX_CLASS; ?></td> <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '?' . tep_draw_pull_down_menu('products_tax_class_id', $tax_class_array, $pInfo->products_tax_class_id, 'onchange="updateGross()"'); ?></td> </tr> <tr bgcolor="#ebebff"> <td class="main"><?php echo TEXT_PRODUCTS_PRICE_NET; ?></td> <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '?' . tep_draw_input_field('products_price', $pInfo->products_price, 'onKeyUp="updateGross()"'); ?></td> </tr> <tr bgcolor="#ebebff"> <td class="main"><?php echo TEXT_PRODUCTS_PRICE_GROSS; ?></td> <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '?' . tep_draw_input_field('products_price_gross', $pInfo->products_price, 'OnKeyUp="updateNet()"'); ?></td> </tr> <tr> <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> </tr> <script language="javascript"><!-- updateGross(); //--></script> <?php for ($i=0, $n=sizeof($languages); $i<$n; $i++) { ?> <tr> <td class="main" valign="top"><?php if ($i == 0) echo TEXT_PRODUCTS_DESCRIPTION; ?></td> <td><table border="0" cellspacing="0" cellpadding="0"> <tr> <td class="main" valign="top"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']); ?>?</td> <td class="main"><?php echo tep_draw_textarea_field('products_description[' . $languages[$i]['id'] . ']', 'soft', '70', '15', (isset($products_description[$languages[$i]['id']]) ? stripslashes($products_description[$languages[$i]['id']]) : tep_get_products_description($pInfo->products_id, $languages[$i]['id']))); ?></td> </tr> </table></td> </tr> <?php } ?> <tr> <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> </tr> <tr> <td class="main"><?php echo TEXT_PRODUCTS_QUANTITY; ?></td> <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '?' . tep_draw_input_field('products_quantity', $pInfo->products_quantity); ?></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_PRODUCTS_MODEL; ?></td> <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '?' . tep_draw_input_field('products_model', $pInfo->products_model); ?></td> </tr> <tr> <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> </tr> <!-- image subdirectory field added here --> <tr> <td class="main"><?php echo TEXT_IMAGE_DIRECTORY; ?></td> <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '?' . tep_draw_input_field('image_subdirectory', $image_subdirectory); ?></td> </tr> <tr> <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '0'); ?></td> </tr> <!-- end addition --> <tr> <td class="main"><?php echo TEXT_PRODUCTS_IMAGE; ?></td> <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '10') . '?' . tep_draw_file_field('products_image') . '<br>' . tep_draw_separator('pixel_trans.gif', '24', '15') . '?' . $pInfo->products_image . tep_draw_hidden_field('products_previous_image', $pInfo->products_image); ?></td> </tr> <?php // big image starts ?> <tr> <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> </tr> <tr> <td class="main"><?php echo TEXT_PRODUCTS_MEDIUMIMAGE; ?></td> <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '?' . tep_draw_file_field('products_mediumimage') . '<br>' . tep_draw_separator('pixel_trans.gif', '24', '15') . '?' . $pInfo->products_mediumimage . tep_draw_hidden_field('products_previous_mediumimage', $pInfo->products_mediumimage); ?></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_PRODUCTS_LARGEIMAGE; ?></td> <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '?' . tep_draw_file_field('products_largeimage') . '<br>' . tep_draw_separator('pixel_trans.gif', '24', '15') . '?' . $pInfo->products_largeimage . tep_draw_hidden_field('products_previous_largeimage', $pInfo->products_largeimage); ?></td> </tr> <?php // <tr> // <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?</td> // </tr> // <tr> // <td class="main"><a href="java script:popupImageWindow('<?php echo tep_href_link(FILENAME_POPUP_IMAGE, 'largeimage=' . $products_largeimage_name); >')">< ?php echo tep_image(DIR_WS_CATALOG_IMAGES . $products_image_name, $pInfo->products_name, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'align="right" hspace="5" vspace="5"') .'</a>'. $pInfo->products_description; ></td> // </tr> // big image ends ?> <tr> <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> </tr> <?php for ($i=0, $n=sizeof($languages); $i<$n; $i++) { ?> <tr> <td class="main"><?php if ($i == 0) echo TEXT_PRODUCTS_URL . '<br><small>' . TEXT_PRODUCTS_URL_WITHOUT_HTTP . '</small>'; ?></td> <td class="main"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '?' . tep_draw_input_field('products_url[' . $languages[$i]['id'] . ']', (isset($products_url[$languages[$i]['id']]) ? $products_url[$languages[$i]['id']] : tep_get_products_url($pInfo->products_id, $languages[$i]['id']))); ?></td> </tr> <?php } ?> <tr> <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> </tr> <tr> <td class="main"><?php echo TEXT_PRODUCTS_WEIGHT; ?></td> <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '?' . tep_draw_input_field('products_weight', $pInfo->products_weight); ?></td> </tr> </table></td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> </tr> <tr> <td class="main" align="right"><?php echo tep_draw_hidden_field('products_date_added', (tep_not_null($pInfo->products_date_added) ? $pInfo->products_date_added : date('Y-m-d'))) . tep_image_submit('button_preview.gif', IMAGE_PREVIEW) . '??<a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . (isset($HTTP_GET_VARS['pID']) ? '&pID=' . $HTTP_GET_VARS['pID'] : '')) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; ?></td> </tr> </table></form> <?php } elseif ($action == 'new_product_preview') { if (tep_not_null($HTTP_POST_VARS)) { $pInfo = new objectInfo($HTTP_POST_VARS); $products_name = $HTTP_POST_VARS['products_name']; $products_description = $HTTP_POST_VARS['products_description']; $products_url = $HTTP_POST_VARS['products_url']; } else { // big image amended $product_query = tep_db_query("select p.products_id, pd.language_id, pd.products_name, pd.products_description, pd.products_url, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and p.products_id = '" . (int)$HTTP_GET_VARS['pID'] . "'"); $product = tep_db_fetch_array($product_query); $pInfo = new objectInfo($product); $products_image_name = $pInfo->products_image; // Big Image Start $products_mediumimage_name = $pInfo->products_mediumimage; $products_largeimage_name = $pInfo->products_largeimage; // Big Image End } $form_action = (isset($HTTP_GET_VARS['pID'])) ? 'update_product' : 'insert_product'; echo tep_draw_form($form_action, FILENAME_CATEGORIES, 'cPath=' . $cPath . (isset($HTTP_GET_VARS['pID']) ? '&pID=' . $HTTP_GET_VARS['pID'] : '') . '&action=' . $form_action, 'post', 'enctype="multipart/form-data"'); $languages = tep_get_languages(); for ($i=0, $n=sizeof($languages); $i<$n; $i++) { if (isset($HTTP_GET_VARS['read']) && ($HTTP_GET_VARS['read'] == 'only')) { $pInfo->products_name = tep_get_products_name($pInfo->products_id, $languages[$i]['id']); $pInfo->products_description = tep_get_products_description($pInfo->products_id, $languages[$i]['id']); $pInfo->products_url = tep_get_products_url($pInfo->products_id, $languages[$i]['id']); } else { $pInfo->products_name = tep_db_prepare_input($products_name[$languages[$i]['id']]); $pInfo->products_description = tep_db_prepare_input($products_description[$languages[$i]['id']]); $pInfo->products_url = tep_db_prepare_input($products_url[$languages[$i]['id']]); } ?> <table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <td><table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td class="pageHeading"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '?' . $pInfo->products_name; ?></td> <td class="pageHeading" align="right"><?php echo $currencies->format($pInfo->products_price); ?></td> </tr> </table></td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> </tr> <!-- 3 Images mod, extension of Big Images: --> <tr> <td class="main"><a href="java script:popupImageWindow('<?php echo tep_href_link(FILENAME_POPUP_IMAGE, 'largeimage=' . $products_largeimage_name); ?>')"><?php echo tep_image(DIR_WS_CATALOG_IMAGES . $products_image_name, $pInfo->products_name, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'align="right" hspace="5" vspace="5"') .'</a>' . $pInfo->products_description; ?></td> </tr> <!-- :3 Images mod, extension of Big Images --> <?php if ($pInfo->products_url) { ?> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> </tr> <tr> <td class="main"><?php echo sprintf(TEXT_PRODUCT_MORE_INFORMATION, $pInfo->products_url); ?></td> </tr> <?php } ?> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> </tr> <?php if ($pInfo->products_date_available > date('Y-m-d')) { ?> <tr> <td align="center" class="smallText"><?php echo sprintf(TEXT_PRODUCT_DATE_AVAILABLE, tep_date_long($pInfo->products_date_available)); ?></td> </tr> <?php } else { ?> <tr> <td align="center" class="smallText"><?php echo sprintf(TEXT_PRODUCT_DATE_ADDED, tep_date_long($pInfo->products_date_added)); ?></td> </tr> <?php } ?> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> </tr> <?php } if (isset($HTTP_GET_VARS['read']) && ($HTTP_GET_VARS['read'] == 'only')) { if (isset($HTTP_GET_VARS['origin'])) { $pos_params = strpos($HTTP_GET_VARS['origin'], '?', 0); if ($pos_params != false) { $back_url = substr( Quote Link to comment Share on other sites More sharing options...
djrino Posted January 8, 2006 Share Posted January 8, 2006 hi good contribution but where i delete a product the directory on the images not delete its remain there is any modification to delete a directory when on my admin i delete a product category? Quote Link to comment Share on other sites More sharing options...
AlanR Posted January 9, 2006 Author Share Posted January 9, 2006 hi good contributionbut where i delete a product the directory on the images not delete its remain there is any modification to delete a directory when on my admin i delete a product category? I thought about this but decided it was not very useful. Most people creating subdirectories are using them because they have many images and need to organize them so as not to end up with hundreds or thousands of images in the /images folder. It's unlikely that they'll be deleting folders very often and when it is needed I think that it's best done via ftp or ssh where the user has complete control and understanding of what they are deleting. Quote Local: Mac OS X 10.5.8 - Apache 2.2/php 5.3.0/MySQL 5.4.10 • Web Servers: Linux Tools: BBEdit, Coda, Versions (Subversion), Sequel Pro (db management) Link to comment Share on other sites More sharing options...
paul_calf Posted January 9, 2006 Share Posted January 9, 2006 alan sorry to bombard you with this but i'm still having no luck i thought the problem might've been my having an earlier version of 3 images (mark wilmouth's). i have now uploaded didier debbaut's admin/categories.php directly to the server but am still receiving the same error message. may the problem lie elsewhere? i'm still new to oscommerce so you'll have to excuse my lack of knowledge. if it's of any use here is the code around lines 373 & 381: tep_db_query("insert into " . TABLE_PRODUCTS . " (products_quantity, products_model,products_image, products_mediumimage, products_largeimage, products_price, products_date_added, products_date_available, products_weight, products_status, products_tax_class_id, manufacturers_id) values ('" . tep_db_input($product['products_quantity']) . "', '" . tep_db_input($product['products_model']) . "', '" . tep_db_input($product['products_image']) . "', '" . tep_db_input($product['products_mediumimage']) . "', '" . tep_db_input($product['products_largeimage']) . "', '" . tep_db_input($product['products_price']) . "', now(), '" . tep_db_input($product['products_date_available']) . "', '" . tep_db_input($product['products_weight']) . "', '0', '" . (int)$product['products_tax_class_id'] . "', '" . (int)$product['manufacturers_id'] . "')"); $dup_products_id = tep_db_insert_id(); // line 373 big image ammended stops $description_query = tep_db_query("select language_id, products_name, products_description, 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, products_description, products_url, products_viewed) values ('" . (int)$dup_products_id . "', '" . (int)$description['language_id'] . "', '" . tep_db_input($description['products_name']) . "', '" . tep_db_input($description['products_description']) . "', '" . tep_db_input($description['products_url']) . "', '0')"); } hope you can help regards, paul. Quote Link to comment Share on other sites More sharing options...
djrino Posted January 9, 2006 Share Posted January 9, 2006 I thought about this but decided it was not very useful. Most people creating subdirectories are using them because they have many images and need to organize them so as not to end up with hundreds or thousands of images in the /images folder. It's unlikely that they'll be deleting folders very often and when it is needed I think that it's best done via ftp or ssh where the user has complete control and understanding of what they are deleting. Tnx for reply Ok but i need this and if you can help me i apreciate so much.. Many tnx Quote Link to comment Share on other sites More sharing options...
AlanR Posted January 10, 2006 Author Share Posted January 10, 2006 Tnx for reply Ok but i need this and if you can help me i apreciate so much.. Many tnx Sorry but it's not going to happen. It's a non trivial user issue. How can the user know from the product screen what other images are in any directories that would be removed? I won't set it up so that when a user removes one image an entire directory or directory chain is removed. Quote Local: Mac OS X 10.5.8 - Apache 2.2/php 5.3.0/MySQL 5.4.10 • Web Servers: Linux Tools: BBEdit, Coda, Versions (Subversion), Sequel Pro (db management) Link to comment Share on other sites More sharing options...
AlanR Posted January 21, 2006 Author Share Posted January 21, 2006 I had a question about using a default value in the subdirectory field, in this case "products/" It's a simple change. Up at the top of categories.php in the configuration section just predefine the value of $image_subdirectory like so: // ---------- Configure Image Path Tool Features Below ---------- // define('USE_REG_GLOBALS_PATCH', 'false'); // Use the register globals fix define('USE_PHP5_MKDIR', 'false'); // Use the php5 mkdir function, set to false if you need to use chmod after creating directories define('SHOW_DIR_CHECKBOX', 'true'); // Allow users to create new directories define('USE_UNIX_SLASHES', 'true'); // Use / slashes for php4 mkdir. Set to false for Windows $image_subdirectory = 'products/'; // set default subdirectory // ----------------------- End Configure ----------------------- // Then that subdirectory will appear by default in the field and you can choose to use it, backspace through it or add to it. Quote Local: Mac OS X 10.5.8 - Apache 2.2/php 5.3.0/MySQL 5.4.10 • Web Servers: Linux Tools: BBEdit, Coda, Versions (Subversion), Sequel Pro (db management) Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.