Re: Additional Images - MS2 Updated - Code
Parikesit <[email protected]>
| Newsgroups | gmane.comp.web.oscommerce.contributions |
|---|---|
| Message-ID | <17948a6dba5e45b4cc2083af9d13f047@osCommerce-Forums> |
This message was sent from: Contributions
http://forums.oscommerce.com/viewtopic.php?p=226862#226862
----------------------------------------------------------------
Here the changes:
[code]case 'add_images':
$products_id = $HTTP_GET_VARS['pID'];
$add_images_error = true;
if ($medium_images = new upload('medium_images', DIR_FS_CATALOG_IMAGES)) {
$add_images_error = false;
$sql_data_array = array('products_id' => tep_db_prepare_input($products_id),
'images_description' => tep_db_prepare_input($HTTP_POST_VARS['images_description']),
'medium_images' => tep_db_prepare_input($medium_images->filename));
if ($popup_images = new upload('popup_images', DIR_FS_CATALOG_IMAGES)) {
$add_data_array = array('popup_images' => tep_db_prepare_input($popup_images->filename));
} else {
$add_data_array = array('popup_images' => tep_db_prepare_input($medium_images->filename));
}
$sql_data_array = array_merge($sql_data_array, $add_data_array);
}
if ($add_images_error == false) {
tep_db_perform(TABLE_ADDITIONAL_IMAGES, $sql_data_array);
} else {
$messageStack->add_session(ERROR_ADDITIONAL_IMAGE_IS_EMPTY, 'error');
}
tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $products_id));
break;[/code]
[code]case 'del_images':
$products_id = tep_db_prepare_input($HTTP_GET_VARS['pID']);
if ( ($HTTP_GET_VARS['pID']) && (is_array($HTTP_POST_VARS['additional_images_id'])) ) {
$additional_images_id[] = tep_db_prepare_input($HTTP_POST_VARS['additional_images_id']);
for ($i=0; $i<sizeof($additional_images_id); $i++) {
tep_db_query("delete from " . TABLE_ADDITIONAL_IMAGES . " where additional_images_id = '" . tep_db_input($additional_images_id[$i]) . "'");
}
}
tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $products_id));
break;[/code]
[code]case 'new_images':
$heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_NEW_IMAGES . '</b>');
$contents = array('form' => tep_draw_form('new_images', FILENAME_CATEGORIES, 'action=add_images&cPath=' . $cPath . '&pID=' . $HTTP_GET_VARS['pID'], 'post', 'enctype="multipart/form-data"'));
$contents[] = array('text' => TEXT_NEW_IMAGES_INTRO);
$contents[] = array('text' => '<br>' . TEXT_PRODUCTS_IMAGES_DESC . '<br>' . tep_draw_input_field('images_description'));
$contents[] = array('text' => '<br>' . TEXT_PRODUCTS_IMAGES_NEW . '<br>' . tep_draw_file_field('medium_images'));
$contents[] = array('text' => '<br>' . TEXT_PRODUCTS_IMAGES_NEWPOP . '<br>' . tep_draw_file_field('popup_images'));
$contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_save.gif', IMAGE_SAVE) . ' <a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $HTTP_GET_VARS['pID']) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
break;[/code]
[code]case 'delete_images':
$heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_NEW_IMAGES . '</b>');
$contents = array('form' => tep_draw_form('delete_images', FILENAME_CATEGORIES, 'action=del_images&cPath=' . $cPath . '&pID=' . $HTTP_GET_VARS['pID']));
$contents[] = array('text' => TEXT_DEL_IMAGES_INTRO);
$images_product = tep_db_query("SELECT additional_images_id, images_description, medium_images FROM " . TABLE_ADDITIONAL_IMAGES . " where products_id = '" . $HTTP_GET_VARS['pID'] . "'");
if (!tep_db_num_rows($images_product)) {
$contents[] = array('align' => 'center', 'text' => '<br><font color="red">No Additional Images!</font>');
$contents[] = array('align' => 'center', 'text' => '<br><a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $HTTP_GET_VARS['pID']) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
} else {
while ($new_images = tep_db_fetch_array($images_product)) {
$contents[] = array('text' => ' ' . tep_draw_checkbox_field('additional_images_id[]', $new_images['additional_images_id'], true) . $new_images['images_description'] . ' (' . $new_images['medium_images'] . ')');
}
$contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_delete.gif', IMAGE_SAVE) . ' <a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $HTTP_GET_VARS['pID']) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
}
break;[/code]
May this helpful,