public static final function updateIconsByApiData($image, $object_id = 0, $object_type = 'product', $lang_code = CART_LANGUAGE) { if (!empty($image['deleted']) && $image['deleted'] == 'Y') { // delete image $image_info = db_get_row("SELECT image_id, pair_id\n FROM ?:images_links\n WHERE object_id = ?i\n AND object_type=?s AND type = 'M'", $object_id, $object_type); if (!empty($image_info)) { fn_delete_image($image_info['image_id'], $image_info['pair_id'], $object_type); } return true; } $icon_list = array(); if ($icon = self::fn_twg_get_image_by_api_data($image)) { $icon_list[] = $icon; } $detailed_alt = db_get_field("SELECT a.description\n FROM ?:common_descriptions as a, ?:images_links as b\n WHERE a.object_holder = ?s\n AND a.lang_code = ?s\n AND a.object_id = b.detailed_id\n AND b.object_id = ?i\n AND b.object_type = ?s\n AND b.type = ?s", 'images', $lang_code, $object_id, $object_type, 'M'); $icon_data = array('type' => 'M', 'image_alt' => !empty($image['alt']) ? $image['alt'] : '', 'detailed_alt' => $detailed_alt); return fn_update_image_pairs($icon_list, array(), array($icon_data), $object_id, $object_type, array(), '', 0, true, $lang_code); }
function fn_attach_image_pairs($name, $object_type, $object_id = 0, $lang_code = CART_LANGUAGE, $object_ids = array()) { $icons = fn_filter_uploaded_data($name . '_image_icon', array('png', 'gif', 'jpg', 'jpeg', 'ico')); $detailed = fn_filter_uploaded_data($name . '_image_detailed', array('png', 'gif', 'jpg', 'jpeg', 'ico')); $pairs_data = !empty($_REQUEST[$name . '_image_data']) ? $_REQUEST[$name . '_image_data'] : array(); return fn_update_image_pairs($icons, $detailed, $pairs_data, $object_id, $object_type, $object_ids, true, $lang_code); }
function fn_exim_1c_add_product_image($filename, $dir_1c_images, $product_id, $type, $lang_code) { if (file_exists($dir_1c_images . $filename)) { $detail_file = fn_explode('.', $filename); $type_file = array_shift($detail_file); $condition = db_quote(" AND images.image_path LIKE ?s", "%" . $type_file . "%"); $images = db_get_array("SELECT images.image_id, images_links.pair_id" . " FROM ?:images AS images" . " LEFT JOIN ?:images_links AS images_links ON images.image_id = images_links.detailed_id" . " WHERE images_links.object_id = ?i {$condition}", $product_id); foreach ($images as $image) { fn_delete_image_pair($image['pair_id'], 'product'); } $image_data[] = array('name' => $filename, 'path' => $dir_1c_images . $filename, 'size' => filesize($dir_1c_images . $filename)); $pair_data[] = array('pair_id' => '', 'type' => $type, 'object_id' => 0, 'image_alt' => '', 'detailed_alt' => ''); $pair_ids = fn_update_image_pairs(array(), $image_data, $pair_data, $product_id, 'product', array(), 1, $lang_code); } }
function fn_attach_image_pairs($name, $object_type, $object_id = 0, $lang_code = CART_LANGUAGE, $object_ids = array(), $parent_object = '', $parent_object_id = 0) { $icons = fn_filter_uploaded_data($name . '_image_icon'); $detailed = fn_filter_uploaded_data($name . '_image_detailed'); $pairs_data = !empty($_REQUEST[$name . '_image_data']) ? $_REQUEST[$name . '_image_data'] : array(); return fn_update_image_pairs($icons, $detailed, $pairs_data, $object_id, $object_type, $object_ids, $parent_object, $parent_object_id, true, false, $lang_code); }
function fn_attach_aditional_image_pairs($name, $object_type, $object_id = 0, $lang_code = CART_LANGUAGE, $object_ids = array()) { foreach ($object_ids as $object_id1) { $icons = fn_filter_uploaded_data($name . '_image_icon' . $object_id1, array('png', 'gif', 'jpg', 'jpeg', 'ico')); $detailed = fn_filter_uploaded_data($name . '_image_detailed' . $object_id1, array('png', 'gif', 'jpg', 'jpeg', 'ico')); $pairs_data = !empty($_REQUEST[$name . '_image_data' . $object_id1]) ? $_REQUEST[$name . '_image_data' . $object_id1] : array(); fn_update_image_pairs($icons, $detailed, $pairs_data, $object_id, $object_type, array(), true, $lang_code, "A"); } }