static function add_translated_data_object($options, $resource) { $d = $options[0]; $parameters = $options[1]; if ($d->EOLDataObjectID) { if ($existing_data_object = DataObject::find($d->EOLDataObjectID)) { $new_data_object = clone $existing_data_object; $new_data_object->id = NULL; $new_data_object->identifier = $d->identifier; $new_data_object->object_created_at = $d->object_created_at; $new_data_object->object_modified_at = $d->object_modified_at; $new_data_object->object_title = $d->object_title; $new_data_object->language = $d->language; $new_data_object->rights_statement = $d->rights_statement; $new_data_object->rights_holder = $d->rights_holder; $new_data_object->description = $d->description; $new_data_object->description_linked = null; $new_data_object->location = $d->location; // check to see if this translation exists by looking in data_object_translations // if its found, check to see if its different // otherwise add it, then add all associations (agents, references, hierarchy_entries) // then add new agents $content_manager = new ContentManager(); list($data_object, $status) = DataObject::find_and_compare($resource, $new_data_object, $content_manager); if (@(!$data_object->id)) { return false; } self::add_entries_for_translated_object($existing_data_object, $data_object, $resource); $resource->harvest_event->add_data_object($data_object, $status); if ($status != "Reused") { $i = 0; $data_object->delete_agents(); foreach ($parameters['agents'] as &$a) { $agent = Agent::find_or_create($a); if ($agent->logo_url && !$agent->logo_cache_url) { if ($logo_cache_url = $this->content_manager->grab_file($agent->logo_url, "partner")) { $agent->logo_cache_url = $logo_cache_url; $agent->save(); } } $data_object->add_agent($agent->id, @$a['agent_role']->id ?: 0, $i); unset($a); $i++; } $data_object->delete_translations(); $data_object->add_translation($existing_data_object->id, $data_object->language_id); $data_object->delete_info_items(); foreach ($existing_data_object->info_items as $ii) { $data_object->add_info_item($ii->id); } // audience // info items // table of contents // all related tables.... } } else { echo "DataObject {$d->EOLDataObjectID} doesn't exist\n"; } } else { return false; } }
public function crop_image_pct($data_object_id, $x_pct, $y_pct, $w_pct, $h_pct = NULL) { //function called by a user interaction (custom crop). If h is not given, assume a square crop $data_object = DataObject::find($data_object_id); if (!$data_object) { write_to_resource_harvesting_log("ContentManager: Cropping invalid data object ID {$data_object_id}"); trigger_error("ContentManager: Cropping invalid data object ID {$data_object_id}", E_USER_NOTICE); } elseif ($data_object->is_image() && $data_object->object_cache_url) { /* we have problems because we don't actually save the filename extension of the original file. Until we can get this from the database, we hack around this as follows */ $cache_path = self::cache_num2path($data_object->object_cache_url); foreach (self::$valid_image_extensions as $ext) { $image_url = CONTENT_LOCAL_PATH . $cache_path . "." . $ext; if (is_file($image_url)) { break; } } // If we can't find the original download, save the local or previous jpg versions as the original (yuck) if (!is_file($image_url)) { $image_url = CONTENT_LOCAL_PATH . $cache_path . "_orig.jpg"; } if (!is_file($image_url)) { $image_url = "http://content.eol.org/content/" . $cache_path . "_orig.jpg"; } return $this->grab_file($image_url, "image", array('crop_pct' => array($x_pct, $y_pct, $w_pct, $h_pct), 'data_object_id' => $data_object->id, 'data_object_guid' => $data_object->guid)); } }