/** * -Image Action' . * Manufacturers :: AddManufacturer: * * $image_obj = modApiFunc("Images", "processImageInput", "mnf_image"); * $error = $image_obj->get_error(); * if($error != NULL) * { * ... * } * * * * ( , * , . .) image_obj . * * (local_file, server_file, url), . * , , image_id , * . * * , alt_text, * . * * , , * image_obj. */ function processImageInput($image_input_id) { global $application; $request =& $application->getInstance('Request'); //js2php: , // . $image_id = $request->getValueByKey('ii_image_id_' . $image_input_id); if (empty($image_id)) { $image_id = NULL; } $image_error_code = $request->getValueByKey('ii_error_code_' . $image_input_id); $image_error_msg = $request->getValueByKey('ii_error_msg_' . $image_input_id); if (empty($image_error_code)) { $image_error_code = NULL; $image_error_msg = ''; // } $image_obj = new image_obj($image_id, $image_error_code, $image_error_msg); // . $source = $request->getValueByKey('ii_source_' . $image_input_id); $b_source_empty = false; switch ($source) { case NULL: case "": break; case 'local_file': if (isset($_FILES["ii_input_file_" . $image_input_id]) && !empty($_FILES["ii_input_file_" . $image_input_id]['name'])) { $new_image_obj = modApiFunc("Images", "process_images_upload_local_file", "ii_alt_text_" . $image_input_id, "ii_input_file_" . $image_input_id, 'ii_image_id_' . $image_input_id); // , , image_id . if (!$image_obj->is_empty() && $new_image_obj->is_empty()) { $new_image_obj->set_id($image_obj->get_id()); } $image_obj = $new_image_obj; } else { // , . $b_source_empty = true; } break; case 'server_file': $path = $request->getValueByKey("server_only_server_file_ii_server_file_" . $image_input_id); if (!empty($path)) { $new_image_obj = modApiFunc("Images", "process_images_upload_server_file", "ii_alt_text_" . $image_input_id, "server_only_server_file_ii_server_file_" . $image_input_id, 'ii_image_id_' . $image_input_id); // , , image_id . if (!$image_obj->is_empty() && $new_image_obj->is_empty()) { $new_image_obj->set_id($image_obj->get_id()); } $image_obj = $new_image_obj; } else { // , . $b_source_empty = true; } break; case 'url': $url = $request->getValueByKey("ii_url_" . $image_input_id); if (!empty($url) && $url != getMsg("IMG", "EMPTY_URL")) { $new_image_obj = modApiFunc("Images", "process_images_upload_url", "ii_alt_text_" . $image_input_id, "ii_url_" . $image_input_id, 'ii_image_id_' . $image_input_id); // , , image_id . if (!$image_obj->is_empty() && $new_image_obj->is_empty()) { $new_image_obj->set_id($image_obj->get_id()); } $image_obj = $new_image_obj; } else { // . $b_source_empty = true; } break; default: // , . . - (local_file url) // . break; } // source, alt_text. if ($b_source_empty === true && $image_obj->get_id() !== null) { // alt_text $image_obj = modApiFunc("Images", "process_images_update_alt_text", "ii_alt_text_" . $image_input_id, $image_obj->get_id()); } return $image_obj; }