reset(); show_confirmation(T_('Art Cleared'), T_('Art information has been removed from the database'), $burl); break; // Upload art case 'upload_art': // we didn't find anything if (empty($_FILES['file']['tmp_name'])) { show_confirmation(T_('Art Not Located'), T_('Art could not be located at this time. This may be due to write access error, or the file is not received correctly.'), $burl); break; } // Pull the image information $data = array('file'=>$_FILES['file']['tmp_name']); $image_data = Art::get_from_source($data, $object_type); // If we got something back insert it if ($image_data) { $art = new Art($object_id, $object_type); $art->insert($image_data,$_FILES['file']['type']); show_confirmation(T_('Art Inserted'), '', $burl); } // Else it failed else { show_confirmation(T_('Art Not Located'), T_('Art could not be located at this time. This may be due to write access error, or the file is not received correctly.'), $burl); } break; case 'find_art': // Prevent the script from timing out set_time_limit(0); $item = new $object_type($object_id); $item->format(); $art = new Art($object_id, $object_type); $images = array(); $cover_url = array(); // If we've got an upload ignore the rest and just insert it if (!empty($_FILES['file']['tmp_name'])) { $path_info = pathinfo($_FILES['file']['name']); $upload['file'] = $_FILES['file']['tmp_name']; $upload['mime'] = 'image/' . $path_info['extension']; $image_data = Art::get_from_source($upload, $object_type); if ($image_data) { $art->insert($image_data,$upload['0']['mime']); show_confirmation(T_('Art Inserted'), '', $burl); break; } // if image data } // if it's an upload $keywords = $item->get_keywords(); $keyword = ''; $options = array(); foreach ($keywords as $key => $word) { if (isset($_REQUEST['option_' . $key])) { $word['value'] = $_REQUEST['option_' . $key]; } $options[$key] = $word['value']; if ($word['important']) { if (!empty($word['value'])) { $keyword .= ' ' . $word['value']; } } } $options['keyword'] = trim($keyword); // Attempt to find the art. $images = $art->gather($options); if (!empty($_REQUEST['cover'])) { $path_info = pathinfo($_REQUEST['cover']); $cover_url[0]['url'] = scrub_in($_REQUEST['cover']); $cover_url[0]['mime'] = 'image/' . $path_info['extension']; } $images = array_merge($cover_url, $images); // If we've found anything then go for it! if (count($images)) { // We don't want to store raw's in here so we need to strip them out into a separate array foreach ($images as $index=>$image) { if ($image['raw']) { unset($images[$index]['raw']); } } // end foreach // Store the results for further use $_SESSION['form']['images'] = $images; require_once AmpConfig::get('prefix') . '/templates/show_arts.inc.php'; } // Else nothing else { show_confirmation(T_('Art Not Located'), T_('Art could not be located at this time. This may be due to write access error, or the file is not received correctly.'), $burl); } require_once AmpConfig::get('prefix') . '/templates/show_get_art.inc.php'; break; case 'select_art': /* Check to see if we have the image url still */ $image_id = $_REQUEST['image']; // Prevent the script from timing out set_time_limit(0); $image = Art::get_from_source($_SESSION['form']['images'][$image_id], 'album'); $mime = $_SESSION['form']['images'][$image_id]['mime']; // Special case for albums, I'm not sure if we should keep it, remove it or find a generic way if ($object_type == 'album') { $album = new $object_type($object_id); $album_groups = $album->get_group_disks_ids(); foreach ($album_groups as $a_id) { $art = new Art($a_id, $object_type); $art->insert($image, $mime); } } else { $art = new Art($object_id, $object_type); $art->insert($image, $mime); } header("Location:" . $burl); break; } UI::show_footer();