/** * Add new instantiation * * @return view */ public function add() { $asset_id = $data['asset_id'] = $this->uri->segment(3); if ($this->input->post()) { /* Media Type Start */ $media_type = $this->input->post('media_type'); $db_media_type = $this->instantiation->get_instantiation_media_types_by_media_type($media_type); if ($db_media_type) { $update_instantiation['instantiation_media_type_id'] = $db_media_type->id; } else { $update_instantiation['instantiation_media_type_id'] = $this->instantiation->insert_instantiation_media_types(array('media_type' => $media_type)); } /* Media Type End */ /* Standard Start */ if ($this->input->post('standard')) { $update_instantiation['standard'] = $this->input->post('standard'); } /* Standard End */ /* Location Start */ if ($this->input->post('location')) { $update_instantiation['location'] = $this->input->post('location'); } /* Location End */ /* Time Start Start */ if ($this->input->post('time_start')) { $update_instantiation['time_start'] = $this->input->post('time_start'); } /* Time Start End */ /* Porjected Duration Start */ if ($this->input->post('projected_duration')) { $update_instantiation['projected_duration'] = $this->input->post('projected_duration'); } /* Porjected Duration End */ /* Porjected Alernative Modes Start */ if ($this->input->post('alternative_modes')) { $update_instantiation['alternative_modes'] = $this->input->post('alternative_modes'); } /* Porjected Alernative Modes End */ /* Color Start */ if ($this->input->post('color')) { $inst_color_d = $this->instantiation->get_instantiation_colors_by_color($this->input->post('color')); if (isset($inst_color_d) && !is_empty($inst_color_d)) { $update_instantiation['instantiation_colors_id'] = $inst_color_d->id; } else { $update_instantiation['instantiation_colors_id'] = $this->instantiation->insert_instantiation_colors(array('color' => $this->input->post('color'))); } } /* Color End */ /* Tracks Start */ if ($this->input->post('tracks')) { $update_instantiation['tracks'] = $this->input->post('tracks'); } /* Tracks End */ /* Channel Configuration Start */ if ($this->input->post('channel_configuration')) { $update_instantiation['channel_configuration'] = $this->input->post('channel_configuration'); } /* Channel Configuration End */ /* Language Configuration Start */ if ($this->input->post('language')) { $update_instantiation['language'] = $this->input->post('language'); } /* Language Configuration End */ /* Insert Instantiation Start */ $update_instantiation['assets_id'] = $asset_id; $instantiation_id = $this->instantiation->insert_instantiations($update_instantiation); /* Insert Instantiation End */ /* Instantiation Identifier Start */ if ($this->input->post('instantiation_id_identifier')) { foreach ($this->input->post('instantiation_id_identifier') as $index => $ins_identifier) { $identifier['instantiation_identifier'] = $ins_identifier; $ins_source = $this->input->post('instantiation_id_source'); if (isset($ins_source[$index]) && !empty($ins_source[$index])) { $identifier['instantiation_source'] = $ins_source[$index]; } $identifier['instantiations_id'] = $instantiation_id; $this->instantiation->insert_instantiation_identifier($identifier); } } /* Instantiation Identifier End */ /* Nomination Start */ $nomination = $this->input->post('nomination'); $reason = $this->input->post('nomination_reason'); if (!empty($nomination)) { $nomination_id = $this->assets_model->get_nomination_status_by_status($nomination)->id; $nomination_record = array('nomination_status_id' => $nomination_id, 'nomination_reason' => $reason, 'nominated_by' => $this->user_id, 'nominated_at' => date('Y-m-d H:i:s')); $nomination_record['instantiations_id'] = $instantiation_id; $nomination_record['created'] = date('Y-m-d H:i:s'); $this->assets_model->insert_nominations($nomination_record); } /* Nomination End */ /* Generation Start */ if ($this->input->post('generation')) { foreach ($this->input->post('generation') as $row) { $db_generation = $this->instantiation->get_generations_by_generation($row); if ($db_generation) { $db_gen_id = $db_generation->id; } else { $db_gen_id = $this->instantiation->insert_generations(array('generation' => $row)); } $this->instantiation->insert_instantiation_generations(array('instantiations_id' => $instantiation_id, 'generations_id' => $db_gen_id)); } } /* Generation End */ /* Date Start */ if ($this->input->post('inst_date')) { foreach ($this->input->post('inst_date') as $index => $value) { $inst_date_types = $this->input->post('inst_date_type'); if (!empty($value)) { $date_type = $this->instantiation->get_date_types_by_type($inst_date_types[$index]); if (isset($date_type) && isset($date_type->id)) { $instantiation_dates_d['date_types_id'] = $date_type->id; } else { $instantiation_dates_d['date_types_id'] = $this->instantiation->insert_date_types(array('date_type' => $inst_date_types[$index])); } $instantiation_dates_d['instantiation_date'] = $value; $instantiation_dates_d['instantiations_id'] = $instantiation_id; $this->instantiation->insert_instantiation_dates($instantiation_dates_d); } } } /* Date End */ /* Demension Start */ if ($this->input->post('asset_dimension')) { foreach ($this->input->post('asset_dimension') as $index => $value) { $unit_measure = $this->input->post('dimension_unit'); $instantiation_dimension_d['instantiations_id'] = $instantiation_id; $instantiation_dimension_d['instantiation_dimension'] = $value; $instantiation_dimension_d['unit_of_measure'] = $unit_measure[$index]; $this->instantiation->insert_instantiation_dimensions($instantiation_dimension_d); } } /* Demension End */ /* Physical Format Start */ if ($this->input->post('physical_format')) { $instantiation_format_physical_d['format_name'] = $this->input->post('physical_format'); $instantiation_format_physical_d['format_type'] = 'physical'; $instantiation_format_physical_d['instantiations_id'] = $instantiation_id; $instantiation_format_physical_id = $this->instantiation->insert_instantiation_formats($instantiation_format_physical_d); } /* Physical Format End */ /* Annotation Start */ if ($this->input->post('annotation')) { foreach ($this->input->post('annotation') as $index => $value) { if (!empty($value)) { $annotation_type = $this->input->post('annotation_type'); $instantiation_annotation_d['instantiations_id'] = $instantiation_id; $instantiation_annotation_d['annotation'] = $value; $instantiation_annotation_d['annotation_type'] = $annotation_type[$index]; $this->instantiation->insert_instantiation_annotations($instantiation_annotation_d); } } } /* Annotation End */ /* Relation Start */ if ($this->input->post('relation')) { $relation_src = $this->input->post('relation_source'); $relation_ref = $this->input->post('relation_ref'); $relation_type = $this->input->post('relation_type'); foreach ($this->input->post('relation') as $index => $value) { if (!empty($value)) { $relation['instantiations_id'] = $instantiation_id; $relation['relation_identifier'] = $value; $relation_types['relation_type'] = $relation_type[$index]; if (!empty($relation_src[$index])) { $relation_types['relation_type_source'] = $relation_src[$index]; } if (!empty($relation_ref[$index])) { $relation_types['relation_type_ref'] = $relation_ref[$index]; } $db_relations = $this->assets_model->get_relation_types_all($relation_types); if (isset($db_relations) && isset($db_relations->id)) { $relation['relation_types_id'] = $db_relations->id; } else { $relation['relation_types_id'] = $this->assets_model->insert_relation_types($relation_types); } $this->instantiation->insert_instantiation_relation($relation); } } } /* Relation End */ /* Essence Track Frame Size Start */ $db_essence_track = FALSE; if ($this->input->post('width') && $this->input->post('height')) { $width = $this->input->post('width'); $height = $this->input->post('height'); if (!empty($width) && !empty($height)) { $db_essence_track = TRUE; $track_frame_size_d = $this->pbcore_model->get_one_by($this->pbcore_model->table_essence_track_frame_sizes, array('width' => trim($this->input->post('width')), 'height' => trim($this->input->post('height')))); if ($track_frame_size_d) { $essence_tracks_d['essence_track_frame_sizes_id'] = $track_frame_size_d->id; } else { $essence_tracks_d['essence_track_frame_sizes_id'] = $this->pbcore_model->insert_record($this->pbcore_model->table_essence_track_frame_sizes, array("width" => $this->input->post('width'), "height" => $this->input->post('height'))); } } } /* Essence Track Frame Size End */ /* Essence Track Frame Rate Start */ if ($frame_rate = $this->input->post('frame_rate')) { if (!empty($frame_rate)) { $db_essence_track = TRUE; $essence_tracks_d['frame_rate'] = $this->input->post('frame_rate'); } } /* Essence Track Frame Rate End */ /* Essence Track Playback Speed Start */ if ($playback_speed = $this->input->post('playback_speed')) { if (!empty($playback_speed)) { $db_essence_track = TRUE; $essence_tracks_d['playback_speed'] = $this->input->post('playback_speed'); } } /* Essence Track Playback Speed End */ /* Essence Track Sampling Rate Start */ if ($sampling_rate = $this->input->post('sampling_rate')) { if (!empty($sampling_rate)) { $db_essence_track = TRUE; $essence_tracks_d['sampling_rate'] = $this->input->post('sampling_rate'); } } /* Essence Track Sampling Rate End */ /* Essence Track Aspect Ratio Start */ if ($aspect_ratio = $this->input->post('aspect_ratio')) { if (!empty($aspect_ratio)) { $db_essence_track = TRUE; $essence_tracks_d['aspect_ratio'] = $this->input->post('aspect_ratio'); } } /* Essence Track Aspect Ratio End */ /* Essence Track Type Start */ $essence_track_type_d = $this->pbcore_model->get_one_by($this->pbcore_model->table_essence_track_types, array('essence_track_type' => 'General'), TRUE); if (isset($essence_track_type_d) && isset($essence_track_type_d->id)) { $essence_tracks_d['essence_track_types_id'] = $essence_track_type_d->id; } else { $essence_tracks_d['essence_track_types_id'] = $this->pbcore_model->insert_record($this->pbcore_model->table_essence_track_types, array('essence_track_type' => 'General')); } /* Essence Track Type End */ /* Essence Track Start */ if ($db_essence_track) { $essence_tracks_d['instantiations_id'] = $instantiation_id; $this->pbcore_model->insert_record($this->pbcore_model->table_essence_tracks, $essence_tracks_d); } /* Essence Track End */ // Update Sphnix Indexes $this->load->library('sphnixrt'); $this->load->model('searchd_model'); $this->load->helper('sphnixdata'); $instantiation_list = $this->searchd_model->get_ins_index(array($instantiation_id)); $new_list_info = make_instantiation_sphnix_array($instantiation_list[0]); $this->sphnixrt->insert('instantiations_list', $new_list_info, $instantiation_id); $asset_list = $this->searchd_model->get_asset_index(array($instantiation_list[0]->assets_id)); $new_asset_info = make_assets_sphnix_array($asset_list[0], FALSE); $this->sphnixrt->update('assets_list', $new_asset_info); // End Update Sphnix Indexes $log = array('user_id' => $this->user_id, 'record_id' => $instantiation_id, 'record' => 'instantiation', 'type' => 'add', 'comments' => 'new instantiation created.'); $this->audit_trail($log); if ($this->input->post('add_another')) { redirect('instantiations/add/' . $asset_id); } else { redirect('records/details/' . $asset_id); } } $data['asset_id'] = $asset_id; $data['pbcore_asset_date_types'] = $this->manage_asset->get_picklist_values(2); $data['pbcore_media_types'] = $this->manage_asset->get_picklist_values(11); $data['pbcore_generations'] = $this->manage_asset->get_picklist_values(12); $data['pbcore_relation_types'] = $this->manage_asset->get_picklist_values(7); $data['pbcore_standards'] = $this->manage_asset->get_picklist_values(14); $data['pbcore_colors'] = $this->manage_asset->get_picklist_values(15); $data['pbcore_physical_formats'] = $this->manage_asset->get_picklist_values(13); $data['nominations'] = $this->instantiation->get_nomination_status(); $this->load->view('instantiations/add', $data); }
/** * You need to add instantiations.id in an array that you want to update. and then run this script. * */ function update_instantiations_index() { $instantiation_ids = array(1, 2, 3, 4); foreach ($instantiation_ids as $_id) { $instantiation = $this->searchd_model->run_query("SELECT id from instantiations WHERE id = {$_id}")->row(); $instantiation_list = $this->searchd_model->get_ins_index(array($instantiation)); $new_list_info = make_instantiation_sphnix_array($instantiation_list[0], FALSE); $this->sphnixrt->update($this->config->item('instantiatiion_index'), $new_list_info); myLog('Instantiation successfully update with id=> ' . $_id); } }
function update_event_info($instantiation_id) { $this->load->library('sphnixrt'); $this->load->model('searchd_model'); $this->load->helper('sphnixdata'); $instantiation_list = $this->searchd_model->get_ins_index(array($instantiation_id)); $new_list_info = make_instantiation_sphnix_array($instantiation_list[0], FALSE); $this->sphnixrt->update('instantiations_list', $new_list_info); $asset_list = $this->searchd_model->get_asset_index(array($instantiation_list[0]->assets_id)); $new_asset_info = make_assets_sphnix_array($asset_list[0], FALSE); $this->sphnixrt->update('assets_list', $new_asset_info); }
/** * Parse and save instantiation and essencetrack info. * * @param string $asset_id * @param array $asset_children */ function import_instantiation_info($asset_id, $asset_children) { error_reporting(E_ALL); ini_set('display_errors', 1); if (isset($asset_children['ams:pbcoreinstantiation'])) { foreach ($asset_children['ams:pbcoreinstantiation'] as $pbcoreinstantiation) { if (isset($pbcoreinstantiation['children']) && !is_empty($pbcoreinstantiation['children'])) { $pbcoreinstantiation_child = $pbcoreinstantiation['children']; $instantiations_d = array(); $instantiations_d['assets_id'] = $asset_id; // Instantiation Location Start // if (isset($pbcoreinstantiation_child['ams:instantiationlocation'][0]['text']) && !is_empty($pbcoreinstantiation_child['ams:instantiationlocation'][0]['text'])) { $instantiations_d['location'] = $pbcoreinstantiation_child['ams:instantiationlocation'][0]['text']; } // Instantiation Location End // // Instantiation Standard Start // if (isset($pbcoreinstantiation_child['ams:instantiationstandard'][0]['text']) && !is_empty($pbcoreinstantiation_child['ams:instantiationstandard'][0]['text'])) { $instantiations_d['standard'] = $pbcoreinstantiation_child['ams:instantiationstandard'][0]['text']; } // Instantiation Standard End // // Instantiation Media Type Start // if (isset($pbcoreinstantiation_child['ams:instantiationmediatype'][0]['text']) && !is_empty($pbcoreinstantiation_child['ams:instantiationmediatype'][0]['text'])) { $inst_media_type = $this->instant->get_instantiation_media_types_by_media_type($pbcoreinstantiation_child['ams:instantiationmediatype'][0]['text']); if (!is_empty($inst_media_type)) { $instantiations_d['instantiation_media_type_id'] = $inst_media_type->id; } else { $instantiations_d['instantiation_media_type_id'] = $this->instant->insert_instantiation_media_types(array("media_type" => $pbcoreinstantiation_child['ams:instantiationmediatype'][0]['text'])); } } // Instantiation Media Type End // // Instantiation File Size Start // if (isset($pbcoreinstantiation_child['ams:instantiationfilesize'][0]['text']) && !is_empty($pbcoreinstantiation_child['ams:instantiationfilesize'][0]['text'])) { $instantiations_d['file_size'] = $pbcoreinstantiation_child['ams:instantiationfilesize'][0]['text']; if (isset($pbcoreinstantiation_child['ams:instantiationfilesize'][0]['attributes']['unitsofmeasure']) && !is_empty($pbcoreinstantiation_child['ams:instantiationfilesize'][0]['attributes']['unitsofmeasure'])) { $instantiations_d['file_size_unit_of_measure'] = $pbcoreinstantiation_child['ams:instantiationfilesize'][0]['attributes']['unitsofmeasure']; } } // Instantiation File Size End // // Instantiation Time Start Start // if (isset($pbcoreinstantiation_child['ams:instantiationtimestart'][0]['text']) && !is_empty($pbcoreinstantiation_child['ams:instantiationtimestart'][0]['text'])) { $instantiations_d['time_start'] = trim($pbcoreinstantiation_child['ams:instantiationtimestart'][0]['text']); } // Instantiation Time Start End // // Instantiation Projected Duration Start // if (isset($pbcoreinstantiation_child['ams:instantiationduration'][0]['text']) && !is_empty($pbcoreinstantiation_child['ams:instantiationduration'][0]['text'])) { $instantiations_d['projected_duration'] = trim($pbcoreinstantiation_child['ams:instantiationduration'][0]['text']); } // Instantiation Projected Duration End // // Instantiation Data Rate Start // if (isset($pbcoreinstantiation_child['ams:instantiationdatarate'][0]['text']) && !is_empty($pbcoreinstantiation_child['ams:instantiationdatarate'][0]['text'])) { $instantiations_d['data_rate'] = trim($pbcoreinstantiation_child['ams:instantiationdatarate'][0]['text']); if (isset($pbcoreinstantiation_child['ams:instantiationdatarate'][0]['attributes']['unitsofmeasure']) && !is_empty($pbcoreinstantiation_child['ams:instantiationdatarate'][0]['attributes']['unitsofmeasure'])) { $data_rate_unit_d = $this->instant->get_data_rate_units_by_unit($pbcoreinstantiation_child['ams:instantiationdatarate'][0]['attributes']['unitsofmeasure']); if (isset($data_rate_unit_d) && isset($data_rate_unit_d->id)) { $instantiations_d['data_rate_units_id'] = $data_rate_unit_d->id; } else { $instantiations_d['data_rate_units_id'] = $this->instant->insert_data_rate_units(array("unit_of_measure" => $pbcoreinstantiation_child['ams:instantiationdatarate'][0]['attributes']['unitsofmeasure'])); } } } // Instantiation Data Rate End // // Instantiation Color Start // if (isset($pbcoreinstantiation_child['ams:instantiationcolors'][0]['text']) && !is_empty($pbcoreinstantiation_child['ams:instantiationcolors'][0]['text'])) { $inst_color_d = $this->instant->get_instantiation_colors_by_color($pbcoreinstantiation_child['ams:instantiationcolors'][0]['text']); if (isset($inst_color_d) && !is_empty($inst_color_d)) { $instantiations_d['instantiation_colors_id'] = $inst_color_d->id; } else { $instantiations_d['instantiation_colors_id'] = $this->instant->insert_instantiation_colors(array('color' => $pbcoreinstantiation_child['ams:instantiationcolors'][0]['text'])); } } // Instantiation Color End // // Instantiation Tracks Start // if (isset($pbcoreinstantiation_child['ams:instantiationtracks'][0]['text']) && !is_empty($pbcoreinstantiation_child['ams:instantiationtracks'][0]['text'])) { $instantiations_d['tracks'] = $pbcoreinstantiation_child['ams:instantiationtracks'][0]['text']; } // Instantiation Tracks End // //Instantiation Channel Configuration Start // if (isset($pbcoreinstantiation_child['ams:instantiationchannelconfiguration'][0]['text']) && !is_empty($pbcoreinstantiation_child['ams:instantiationchannelconfiguration'][0]['text'])) { $instantiations_d['channel_configuration'] = $pbcoreinstantiation_child['ams:instantiationchannelconfiguration'][0]['text']; } //Instantiation Channel Configuration End // //Instantiation Language Start // if (isset($pbcoreinstantiation_child['ams:instantiationlanguage'][0]['text']) && !is_empty($pbcoreinstantiation_child['ams:instantiationlanguage'][0]['text'])) { $instantiations_d['language'] = $pbcoreinstantiation_child['ams:instantiationlanguage'][0]['text']; } //Instantiation Language End // //Instantiation Alternative Mode Start // if (isset($pbcoreinstantiation_child['ams:instantiationalternativemodes'][0]['text']) && !is_empty($pbcoreinstantiation_child['ams:instantiationalternativemodes'][0]['text'])) { $instantiations_d['alternative_modes'] = $pbcoreinstantiation_child['ams:instantiationalternativemodes'][0]['text']; } //Instantiation Alternative Mode End // $insert_instantiation = TRUE; $instantiations_d['created'] = date("Y-m-d H:i:s"); $instantiations_id = $this->instant->insert_instantiations($instantiations_d); // Instantiations Identifier Start // if (isset($pbcoreinstantiation_child['ams:instantiationidentifier'])) { foreach ($pbcoreinstantiation_child['ams:instantiationidentifier'] as $pbcore_identifier) { $instantiation_identifier_d = array(); $instantiation_identifier_d['instantiations_id'] = $instantiations_id; if (isset($pbcore_identifier['text']) && !is_empty($pbcore_identifier['text'])) { $instantiation_identifier_d['instantiation_identifier'] = $pbcore_identifier['text']; if (isset($pbcore_identifier['attributes']['source']) && !is_empty($pbcore_identifier['attributes']['source'])) { $instantiation_identifier_d['instantiation_source'] = $pbcore_identifier['attributes']['source']; } $instantiation_identifier_id = $this->instant->insert_instantiation_identifier($instantiation_identifier_d); } } } // Instantiations Identifier End // // Instantiations Date Start // if (isset($pbcoreinstantiation_child['ams:instantiationdate'])) { foreach ($pbcoreinstantiation_child['ams:instantiationdate'] as $pbcore_date) { $instantiation_dates_d = array(); $instantiation_dates_d['instantiations_id'] = $instantiations_id; if (isset($pbcore_date['text']) && !is_empty($pbcore_date['text'])) { $instantiation_dates_d['instantiation_date'] = str_replace(array('?', 'Unknown', 'unknown', '`', '[' . ']', 'N/A', 'N/A?', 'Jim Cooper', 'various', '.00', '.0', 'John Kelling', 'Roll in', 'interview'), '', $pbcore_date['text']); if (isset($instantiation_dates_d['instantiation_date']) && !is_empty($instantiation_dates_d['instantiation_date'])) { $date_check = $this->is_valid_date($instantiation_dates_d['instantiation_date']); if ($date_check === FALSE) { $instantiation_annotation_d = array(); $instantiation_annotation_d['instantiations_id'] = $instantiations_id; $instantiation_annotation_d['annotation'] = $instantiation_dates_d['instantiation_date']; if (isset($pbcore_date['attributes']['datetype']) && !is_empty($pbcore_date['attributes']['datetype'])) { $instantiation_annotation_d['annotation_type'] = $pbcore_date['attributes']['datetype']; } $this->instant->insert_instantiation_annotations($instantiation_annotation_d); } else { if (isset($pbcore_date['attributes']['datetype']) && !is_empty($pbcore_date['attributes']['datetype'])) { $date_type = $this->instant->get_date_types_by_type($pbcore_date['attributes']['datetype']); if (isset($date_type) && isset($date_type->id)) { $instantiation_dates_d['date_types_id'] = $date_type->id; } else { $instantiation_dates_d['date_types_id'] = $this->instant->insert_date_types(array('date_type' => $pbcore_date['attributes']['datetype'])); } } $this->instant->insert_instantiation_dates($instantiation_dates_d); } } } } } // Instantiations Date End // // Instantiations Dimension Start // if (isset($pbcoreinstantiation_child['ams:instantiationdimensions'])) { foreach ($pbcoreinstantiation_child['ams:instantiationdimensions'] as $pbcore_dimension) { $instantiation_dimension_d = array(); $instantiation_dimension_d['instantiations_id'] = $instantiations_id; if (isset($pbcore_dimension['text']) && !is_empty($pbcore_dimension['text'])) { $instantiation_dimension_d['instantiation_dimension'] = $pbcore_dimension['text']; $instantiation_dimension_d['unit_of_measure'] = ''; if (isset($pbcore_dimension['attributes']['unitofmeasure']) && !is_empty($pbcore_dimension['attributes']['unitofmeasure'])) { $instantiation_dimension_d['unit_of_measure'] = $pbcore_dimension['attributes']['unitofmeasure']; } $this->instant->insert_instantiation_dimensions($instantiation_dimension_d); } } } // Instantiations Dimension End // // Instantiations Format Start // if (isset($pbcoreinstantiation_child['ams:instantiationphysical'])) { foreach ($pbcoreinstantiation_child['ams:instantiationphysical'] as $pbcore_physical) { if (isset($pbcore_physical['text']) && !is_empty($pbcore_physical['text'])) { $instantiation_format_physical_d = array(); $instantiation_format_physical_d['instantiations_id'] = $instantiations_id; $instantiation_format_physical_d['format_name'] = $pbcore_physical['text']; $instantiation_format_physical_d['format_type'] = 'physical'; $instantiation_format_physical_id = $this->instant->insert_instantiation_formats($instantiation_format_physical_d); } } } else { if (isset($pbcoreinstantiation_child['ams:instantiationdigital'])) { foreach ($pbcoreinstantiation_child['ams:instantiationdigital'] as $pbcore_digital) { if (isset($pbcore_digital['text']) && !is_empty($pbcore_digital['text'])) { $instantiation_format_digital_d = array(); $instantiation_format_digital_d['instantiations_id'] = $instantiations_id; $instantiation_format_digital_d['format_name'] = $pbcore_digital['text']; $instantiation_format_digital_d['format_type'] = 'digital'; $instantiation_format_digital_id = $this->instant->insert_instantiation_formats($instantiation_format_digital_d); } } } } // Instantiations Format End // // Instantiations Generation Start // if (isset($pbcoreinstantiation_child['ams:instantiationgenerations']) && !is_empty($pbcoreinstantiation_child['ams:instantiationgenerations'])) { foreach ($pbcoreinstantiation_child['ams:instantiationgenerations'] as $instantiation_generations) { if (isset($instantiation_generations['text']) && !is_empty($instantiation_generations['text'])) { $instantiation_format_generations_d = array(); $instantiation_format_generations_d['instantiations_id'] = $instantiations_id; $generations_d = $this->instant->get_generations_by_generation($instantiation_generations['text']); if (isset($generations_d) && isset($generations_d->id)) { $instantiation_format_generations_d['generations_id'] = $generations_d->id; } else { $instantiation_format_generations_d['generations_id'] = $this->instant->insert_generations(array("generation" => $instantiation_generations['text'])); } $this->instant->insert_instantiation_generations($instantiation_format_generations_d); } } } // Instantiations Generation End // // Instantiations Annotation Start // if (isset($pbcoreinstantiation_child['ams:instantiationannotation'])) { foreach ($pbcoreinstantiation_child['ams:instantiationannotation'] as $pbcore_annotation) { if (isset($pbcore_annotation['text']) && !is_empty($pbcore_annotation['text'])) { $instantiation_annotation_d = array(); $instantiation_annotation_d['instantiations_id'] = $instantiations_id; $instantiation_annotation_d['annotation'] = $pbcore_annotation['text']; if (isset($pbcore_annotation['attributes']['annotationtype']) && !is_empty($pbcore_annotation['attributes']['annotationtype'])) { $instantiation_annotation_d['annotation_type'] = $pbcore_annotation['attributes']['annotationtype']; } $this->instant->insert_instantiation_annotations($instantiation_annotation_d); } } } // Instantiations Annotation End // // Instantiations Relation Start // if (isset($pbcoreinstantiation_child['ams:pbcorerelation'])) { foreach ($pbcoreinstantiation_child['ams:pbcorerelation'] as $pbcorerelation) { if (isset($pbcorerelation['children']['ams:pbcorerelationidentifier'][0]['text']) && !is_empty($pbcore_creator['children']['ams:pbcorerelationidentifier'][0]['text'])) { $instantiation_relation_d = array(); $instantiation_relation_d['instantiations_id'] = $instantiations_id; $instantiation_relation_d = $pbcorerelation['children']['ams:pbcorerelationidentifier'][0]['text']; if (isset($pbcorerelation['children']['pbcorerelationtype'][0]['text']) && !is_empty($pbcore_creator['children']['pbcorerelationtype'][0]['text'])) { $relation_type_info['relation_type'] = $pbcorerelation['children']['pbcorerelationtype'][0]['text']; if (isset($pbcorerelation['children']['ams:pbcorerelationtype'][0]['attributes']['source']) && !is_empty($pbcore_creator['children']['ams:pbcorerelationtype'][0]['attributes']['source'])) { $relation_type_info['relation_type_source'] = $pbcorerelation['children']['ams:pbcorerelationtype'][0]['attributes']['source']; } if (isset($pbcorerelation['children']['ams:pbcorerelationtype'][0]['attributes']['ref']) && !is_empty($pbcore_creator['children']['ams:pbcorerelationtype'][0]['attributes']['ref'])) { $relation_type_info['relation_type_ref'] = $pbcorerelation['children']['ams:pbcorerelationtype'][0]['attributes']['ref']; } $db_relations = $this->assets_model->get_relation_types($relation_type_info['relation_type']); if (isset($db_relations) && isset($db_relations->id)) { $instantiation_relation_d['relation_types_id'] = $db_relations->id; } else { $instantiation_relation_d['relation_types_id'] = $this->assets_model->insert_relation_types($relation_type_info); } $this->instant->insert_instantiation_relation($instantiation_relation_d); } } } } // Instantiations Relation End // // Instantiations Essence Tracks Start // if (isset($pbcoreinstantiation_child['ams:instantiationessencetrack'])) { foreach ($pbcoreinstantiation_child['ams:instantiationessencetrack'] as $pbcore_essence_track) { if (isset($pbcore_essence_track['children']) && !is_empty($pbcore_essence_track['children'])) { $pbcore_essence_child = $pbcore_essence_track['children']; $essence_tracks_d = array(); $essence_tracks_d['instantiations_id'] = $instantiations_id; // Essence Track Standard Start // if (isset($pbcore_essence_child['ams:essencetrackstandard'][0]['text']) && !is_empty($pbcore_essence_child['ams:essencetrackstandard'][0]['text'])) { $essence_tracks_d['standard'] = $pbcore_essence_child['ams:essencetrackstandard'][0]['text']; } // Essence Track Standard End // // Essence Track Data Rate Start // if (isset($pbcore_essence_child['ams:essencetrackdatarate'][0]['text']) && !is_empty($pbcore_essence_child['ams:essencetrackdatarate'][0]['text'])) { $essence_tracks_d['data_rate'] = $pbcore_essence_child['essencetrackdatarate'][0]['text']; if (isset($pbcore_essence_child['ams:essencetrackdatarate'][0]['attributes']['unitsofmeasure']) && !is_empty($pbcore_essence_child['ams:essencetrackdatarate'][0]['attributes']['unitsofmeasure'])) { $data_rate_unit_d = $this->instant->get_data_rate_units_by_unit($pbcore_essence_child['ams:essencetrackdatarate'][0]['attributes']['unitsofmeasure']); if (isset($data_rate_unit_d) && isset($data_rate_unit_d->id)) { $essence_tracks_d['data_rate_units_id'] = $data_rate_unit_d->id; } else { $essence_tracks_d['data_rate_units_id'] = $this->instant->insert_data_rate_units(array("unit_of_measure" => $pbcore_essence_child['ams:essencetrackdatarate'][0]['attributes']['unitsofmeasure'])); } } } // Essence Track Data Rate End // // Essence Track Frame Rate Start // if (isset($pbcore_essence_child['ams:essencetrackframerate'][0]['text']) && !is_empty($pbcore_essence_child['ams:essencetrackframerate'][0]['text'])) { $frame_rate = explode(" ", $pbcore_essence_child['ams:essencetrackframerate'][0]['text']); $essence_tracks_d['frame_rate'] = trim($frame_rate[0]); } // Essence Track Frame Rate End // // Essence Track Play Back Speed Start // if (isset($pbcore_essence_child['ams:essencetrackplaybackspeed'][0]['text']) && !is_empty($pbcore_essence_child['ams:essencetrackplaybackspeed'][0]['text'])) { $essence_tracks_d['playback_speed'] = $pbcore_essence_child['ams:essencetrackplaybackspeed'][0]['text']; } // Essence Track Play Back Speed End // // Essence Track Sampling Rate Start // if (isset($pbcore_essence_child['ams:essencetracksamplingrate'][0]['text']) && !is_empty($pbcore_essence_child['ams:essencetracksamplingrate'][0]['text'])) { $essence_tracks_d['sampling_rate'] = $pbcore_essence_child['ams:essencetracksamplingrate'][0]['text']; } // Essence Track Sampling Rate End // // Essence Track bit depth Start // if (isset($pbcore_essence_child['ams:essencetrackbitdepth'][0]['text']) && !is_empty($pbcore_essence_child['ams:essencetrackbitdepth'][0]['text'])) { $essence_tracks_d['bit_depth'] = $pbcore_essence_child['ams:essencetrackbitdepth'][0]['text']; } // Essence Track bit depth End // // Essence Track Aspect Ratio Start // if (isset($pbcore_essence_child['ams:essencetrackaspectratio'][0]['text']) && !is_empty($pbcore_essence_child['ams:essencetrackaspectratio'][0]['text'])) { $essence_tracks_d['aspect_ratio'] = $pbcore_essence_child['ams:essencetrackaspectratio'][0]['text']; } // Essence Track Aspect Ratio End // // Essence Track Time Start // if (isset($pbcore_essence_child['ams:essencetracktimestart'][0]['text']) && !is_empty($pbcore_essence_child['ams:essencetracktimestart'][0]['text'])) { $essence_tracks_d['time_start'] = $pbcore_essence_child['ams:essencetracktimestart'][0]['text']; } // Essence Track Time End // // Essence Track Duration Start // if (isset($pbcore_essence_child['ams:essencetrackduration'][0]['text']) && !is_empty($pbcore_essence_child['ams:essencetrackduration'][0]['text'])) { $essence_tracks_d['duration'] = $pbcore_essence_child['ams:essencetrackduration'][0]['text']; } // Essence Track Duration End // // Essence Track Language Start // if (isset($pbcore_essence_child['ams:essencetracklanguage'][0]['text']) && !is_empty($pbcore_essence_child['ams:essencetracklanguage'][0]['text'])) { $essence_tracks_d['language'] = $pbcore_essence_child['ams:essencetracklanguage'][0]['text']; } // Essence Track Language Start // // Essence Track Type Start // if (isset($pbcore_essence_child['ams:essencetracktype'][0]['text']) && !is_empty($pbcore_essence_child['ams:essencetracktype'][0]['text'])) { $essence_track_type_d = $this->pbcore_model->get_one_by($this->pbcore_model->table_essence_track_types, array('essence_track_type' => $pbcore_essence_child['ams:essencetracktype'][0]['text']), TRUE); if (isset($essence_track_type_d) && isset($essence_track_type_d->id)) { $essence_tracks_d['essence_track_types_id'] = $essence_track_type_d->id; } else { $essence_tracks_d['essence_track_types_id'] = $this->pbcore_model->insert_record($this->pbcore_model->table_essence_track_types, array('essence_track_type' => $pbcore_essence_child['ams:essencetracktype'][0]['text'])); } } // Essence Track Type End // // Essence Track Frame Size Start // if (isset($pbcore_essence_child['ams:essencetrackframesize'][0]['text']) && !is_empty($pbcore_essence_child['ams:essencetrackframesize'][0]['text'])) { $frame_sizes = explode("x", strtolower($pbcore_essence_child['ams:essencetrackframesize'][0]['text'])); if (isset($frame_sizes[0]) && isset($frame_sizes[1])) { $track_frame_size_d = $this->pbcore_model->get_one_by($this->pbcore_model->table_essence_track_frame_sizes, array('width' => trim($frame_sizes[0]), 'height' => trim($frame_sizes[1]))); if ($track_frame_size_d) { $essence_tracks_d['essence_track_frame_sizes_id'] = $track_frame_size_d->id; } else { $essence_tracks_d['essence_track_frame_sizes_id'] = $this->pbcore_model->insert_record($this->pbcore_model->table_essence_track_frame_sizes, array("width" => $frame_sizes[0], "height" => $frame_sizes[1])); } } } // Essence Track Frame Size End // if (isset($essence_tracks_d['essence_track_types_id']) && !empty($essence_tracks_d['essence_track_types_id']) && $essence_tracks_d['essence_track_types_id'] != NULL) { $essence_tracks_id = $this->pbcore_model->insert_record($this->pbcore_model->table_essence_tracks, $essence_tracks_d); $insert_essence_track = TRUE; // Essence Track Identifier Start // if (isset($pbcore_essence_child['ams:essencetrackidentifier'][0]['text']) && !is_empty($pbcore_essence_child['ams:essencetrackidentifier'][0]['text'])) { $essence_track_identifiers_d = array(); $essence_track_identifiers_d['essence_tracks_id'] = $essence_tracks_id; $essence_track_identifiers_d['essence_track_identifiers'] = $pbcore_essence_child['ams:essencetrackidentifier'][0]['text']; if (isset($pbcore_essence_child['ams:essencetrackidentifier'][0]['attributes']['source']) && !is_empty($pbcore_essence_child['ams:essencetrackidentifier'][0]['attributes']['source'])) { $essence_track_identifiers_d['ams:essence_track_identifier_source'] = $pbcore_essence_child['ams:essencetrackidentifier'][0]['attributes']['source']; } $this->pbcore_model->insert_record($this->pbcore_model->table_essence_track_identifiers, $essence_track_identifiers_d); } // Essence Track Identifier End // // Essence Track Encoding Start // if (isset($pbcore_essence_child['ams:essencetrackencoding'][0]['text']) && !is_empty($pbcore_essence_child['ams:essencetrackencoding'][0]['text'])) { $essence_track_standard_d = array(); $essence_track_standard_d['essence_tracks_id'] = $essence_tracks_id; $essence_track_standard_d['encoding'] = $pbcore_essence_child['ams:essencetrackencoding'][0]['text']; if (isset($pbcore_essence_child['ams:essencetrackencoding'][0]['attributes']['ref']) && !is_empty($pbcore_essence_child['ams:essencetrackencoding'][0]['attributes']['ref'])) { $essence_track_standard_d['encoding_source'] = $pbcore_essence_child['ams:essencetrackencoding'][0]['attributes']['ref']; } $this->pbcore_model->insert_record($this->pbcore_model->table_essence_track_encodings, $essence_track_standard_d); } // Essence Track Encoding End // // Essence Track Annotation Start // if (isset($pbcore_essence_child['ams:essencetrackannotation']) && !is_empty($pbcore_essence_child['ams:essencetrackannotation'])) { foreach ($pbcore_essence_child['ams:essencetrackannotation'] as $trackannotation) { if (isset($trackannotation['text']) && !is_empty($trackannotation['text'])) { $essencetrackannotation = array(); $essencetrackannotation['essence_tracks_id'] = $essence_tracks_id; $essencetrackannotation['annotation'] = $trackannotation['text']; if (isset($trackannotation['attributes']['type']) && !is_empty($trackannotation['attributes']['type'])) { $essencetrackannotation['annotation_type'] = $trackannotation['attributes']['type']; } $this->pbcore_model->insert_record($this->pbcore_model->table_essence_track_annotations, $essencetrackannotation); } } } // Essence Track Annotation End // } } } } // Instantiations Essence Tracks End // // Asset Extension Start // if (isset($asset_children['ams:pbcoreextension']) && !is_empty($asset_children['ams:pbcoreextension'])) { foreach ($asset_children['ams:pbcoreextension'] as $pbcore_extension) { $map_extension = $pbcore_extension['children']['ams:extensionwrap'][0]['children']; if (isset($map_extension['ams:extensionauthorityused'][0]['text']) && !is_empty($map_extension['ams:extensionauthorityused'][0]['text'])) { $nomination_d = array(); $nomination_d['instantiations_id'] = $instantiations_id; if (strtolower($map_extension['ams:extensionauthorityused'][0]['text']) == strtolower('AACIP Record Nomination Status')) { if (isset($map_extension['ams:extensionvalue'][0]['text']) && !is_empty($map_extension['ams:extensionvalue'][0]['text'])) { $nomunation_status = $this->assets_model->get_nomination_status_by_status($map_extension['ams:extensionvalue'][0]['text']); if (isset($nomunation_status) && !is_empty($nomunation_status)) { $nomination_d['nomination_status_id'] = $nomunation_status->id; } else { $nomination_d['nomination_status_id'] = $this->assets_model->insert_nomination_status(array("status" => $map_extension['ams:extensionvalue'][0]['text'])); } } } if (strtolower($map_extension['ams:extensionauthorityused'][0]['text']) == strtolower('AACIP Record Tags')) { if (isset($map_extension['ams:extensionvalue'][0]['text']) && !is_empty($map_extension['ams:extensionvalue'][0]['text'])) { if (preg_match('/historical value/', strtolower($map_extension['ams:extensionvalue'][0]['text']), $match_text)) { $nomination_d['nomination_reason'] = $map_extension['ams:extensionvalue'][0]['text']; } else { if (preg_match('/risk of loss/', strtolower($map_extension['ams:extensionvalue'][0]['text']), $match_text)) { $nomination_d['nomination_reason'] = $map_extension['ams:extensionvalue'][0]['text']; } else { if (preg_match('/local cultural value/', strtolower($map_extension['ams:extensionvalue'][0]['text']), $match_text)) { $nomination_d['nomination_reason'] = $map_extension['ams:extensionvalue'][0]['text']; } else { if (preg_match('/potential to repurpose/', strtolower($map_extension['ams:extensionvalue'][0]['text']), $match_text)) { $nomination_d['nomination_reason'] = $map_extension['ams:extensionvalue'][0]['text']; } } } } } } if (isset($nomination_d['nomination_status_id'])) { $nomination_d['created'] = date("Y-m-d H:i:s"); $this->assets_model->insert_nominations($nomination_d); break; } } } } // Asset Extension End // $this->load->library('sphnixrt'); $this->load->model('searchd_model'); $this->load->helper('sphnixdata'); $instantiation_list = $this->searchd_model->get_ins_index(array($instantiations_id)); $new_list_info = make_instantiation_sphnix_array($instantiation_list[0], TRUE); $this->sphnixrt->insert('instantiations_list', $new_list_info, $instantiations_id); $asset_list = $this->searchd_model->get_asset_index(array($instantiation_list[0]->assets_id)); $new_asset_info = make_assets_sphnix_array($asset_list[0], FALSE); $this->sphnixrt->update('assets_list', $new_asset_info); } } } }
/** * Edit Asset Information. Receives asset_id in 3rd URI segment. * * @return view */ public function edit() { $asset_id = $this->uri->segment(3); if (!empty($asset_id)) { if ($this->input->post()) { $this->delete_asset_attributes($asset_id); $update_asset_tbl['updated'] = date('Y-m-d H:m:i'); if (!$this->is_station_user) { $update_asset_tbl['stations_id'] = $this->input->post('organization'); } $this->assets_model->update_assets($asset_id, $update_asset_tbl); if ($this->input->post('asset_type')) { foreach ($this->input->post('asset_type') as $value) { if (!empty($value)) { $asset_type_d['assets_id'] = $asset_id; if ($asset_type = $this->assets_model->get_assets_type_by_type($value)) { $asset_type_d['asset_types_id'] = $asset_type->id; } else { $asset_type_d['asset_types_id'] = $this->assets_model->insert_asset_types(array("asset_type" => $value)); } $this->assets_model->insert_assets_asset_types($asset_type_d); } } } if ($this->input->post('asset_date')) { foreach ($this->input->post('asset_date') as $index => $value) { $asset_date_info['assets_id'] = $asset_id; $asset_date_info['asset_date'] = $value; $date_type = $this->input->post('asset_date_type'); if ($asset_date_type = $this->instantiation->get_date_types_by_type($date_type[$index])) { $asset_date_info['date_types_id'] = $asset_date_type->id; } else { $asset_date_info['date_types_id'] = $this->instantiation->insert_date_types(array("date_type" => $date_type[$index])); } $this->assets_model->insert_asset_date($asset_date_info); } } if ($this->input->post('asset_identifier')) { foreach ($this->input->post('asset_identifier') as $index => $value) { if (!empty($value)) { $identifier_source = $this->input->post('asset_identifier_source'); $identifier_ref = $this->input->post('asset_identifier_ref'); $identifier_detail['assets_id'] = $asset_id; $identifier_detail['identifier'] = $value; if (!empty($identifier_source[$index])) { $identifier_detail['identifier_source'] = $identifier_source[$index]; } if (!empty($identifier_ref[$index])) { $identifier_detail['identifier_ref'] = $identifier_ref[$index]; } $this->assets_model->insert_identifiers($identifier_detail); } } } if ($this->input->post('asset_title')) { foreach ($this->input->post('asset_title') as $index => $value) { $title_type = $this->input->post('asset_title_type'); $title_source = $this->input->post('asset_title_source'); $title_ref = $this->input->post('asset_title_ref'); if (!empty($value)) { $title_detail['assets_id'] = $asset_id; $title_detail['title'] = $value; if ($title_type[$index] && !empty($title_type[$index])) { $asset_title_types = $this->assets_model->get_asset_title_types_by_title_type($title_type[$index]); if (isset($asset_title_types) && isset($asset_title_types->id)) { $asset_title_types_id = $asset_title_types->id; } else { $asset_title_types_id = $this->assets_model->insert_asset_title_types(array("title_type" => $title_type[$index])); } $title_detail['asset_title_types_id'] = $asset_title_types_id; } if ($title_ref[$index]) { $title_detail['title_ref'] = $title_ref[$index]; } if ($title_source[$index]) { $title_detail['title_source'] = $title_source[$index]; } $title_detail['created'] = date('Y-m-d H:i:s'); $title_detail['updated'] = date('Y-m-d H:i:s'); $this->assets_model->insert_asset_titles($title_detail); } } } if ($this->input->post('asset_subject')) { foreach ($this->input->post('asset_subject') as $index => $value) { $subject_type = $this->input->post('asset_subject_type'); $subject_source = $this->input->post('asset_subject_source'); $subject_ref = $this->input->post('asset_subject_ref'); if (!empty($value)) { $subject_detail['assets_id'] = $asset_id; $subject_d = array(); $subject_d['subject'] = $value; $subject_d['subjects_types_id'] = $subject_type[$index]; if (!empty($subject_ref[$index])) { $subject_d['subject_ref'] = $subject_ref[$index]; } if (!empty($subject_source[$index])) { $subject_d['subject_source'] = $subject_source[$index]; } $subject_id = $this->assets_model->insert_subjects($subject_d); $subject_detail['subjects_id'] = $subject_id; $assets_subject_id = $this->assets_model->insert_assets_subjects($subject_detail); } } } if ($this->input->post('asset_description')) { $desc_type = $this->input->post('asset_description_type'); foreach ($this->input->post('asset_description') as $index => $value) { if (!empty($value)) { $asset_descriptions_d['assets_id'] = $asset_id; $asset_descriptions_d['description'] = $value; $asset_description_type = $this->assets_model->get_description_by_type($desc_type[$index]); if (isset($asset_description_type) && isset($asset_description_type->id)) { $asset_description_types_id = $asset_description_type->id; } else { $asset_description_types_id = $this->assets_model->insert_description_types(array("description_type" => $desc_type[$index])); } $asset_descriptions_d['description_types_id'] = $asset_description_types_id; $this->assets_model->insert_asset_descriptions($asset_descriptions_d); } } } if ($this->input->post('asset_genre')) { $genre_source = $this->input->post('asset_genre_source'); $genre_ref = $this->input->post('asset_genre_ref'); foreach ($this->input->post('asset_genre') as $index => $value) { if (!empty($value)) { $asset_genre_d['genre'] = $value; $asset_genre_d['genre_source'] = $genre_source[$index]; $asset_genre_d['genre_ref'] = $genre_ref[$index]; $asset_genre_type = $this->assets_model->get_genre_type_all($asset_genre_d); if (isset($asset_genre_type) && isset($asset_genre_type->id)) { $asset_genre['genres_id'] = $asset_genre_type->id; } else { $asset_genre['genres_id'] = $this->assets_model->insert_genre($asset_genre_d); } $asset_genre['assets_id'] = $asset_id; $this->assets_model->insert_asset_genre($asset_genre); } } } if ($this->input->post('asset_coverage')) { $coverage_type = $this->input->post('asset_coverage_type'); foreach ($this->input->post('asset_coverage') as $index => $value) { if (!empty($value)) { $coverage['assets_id'] = $asset_id; $coverage['coverage'] = $value; $coverage['coverage_type'] = $coverage_type[$index]; $this->assets_model->insert_coverage($coverage); } } } if ($this->input->post('asset_audience_level')) { $audience_source = $this->input->post('asset_audience_level_source'); $audience_ref = $this->input->post('asset_audience_level_ref'); foreach ($this->input->post('asset_audience_level') as $index => $value) { if (!empty($value)) { $asset_audience_level['assets_id'] = $asset_id; $audience_level['audience_level'] = trim($value); if (!empty($audience_source[$index])) { $audience_level['audience_level_source'] = $audience_source[$index]; } if (!empty($audience_ref[$index])) { $audience_level['audience_level_ref'] = $audience_ref[$index]; } $db_audience_level = $this->assets_model->get_audience_level_all($audience_level); if (isset($db_audience_level) && isset($db_audience_level->id)) { $asset_audience_level['audience_levels_id'] = $db_audience_level->id; } else { $asset_audience_level['audience_levels_id'] = $this->assets_model->insert_audience_level($audience_level); } $asset_audience = $this->assets_model->insert_asset_audience($asset_audience_level); } } } if ($this->input->post('asset_audience_rating')) { $audience_source = $this->input->post('asset_audience_rating_source'); $audience_ref = $this->input->post('asset_audience_rating_ref'); foreach ($this->input->post('asset_audience_rating') as $index => $value) { if (!empty($value)) { $asset_audience_rating['assets_id'] = $asset_id; $audience_rating['audience_rating'] = trim($value); if (!empty($audience_source[$index])) { $audience_rating['audience_rating_source'] = $audience_source[$index]; } if (!empty($audience_ref[$index])) { $audience_rating['audience_rating_ref'] = $audience_ref[$index]; } $db_audience_rating = $this->assets_model->get_audience_rating_all($audience_rating); if (isset($db_audience_rating) && isset($db_audience_rating->id)) { $asset_audience_rating['audience_ratings_id'] = $db_audience_rating->id; } else { $asset_audience_rating['audience_ratings_id'] = $this->assets_model->insert_audience_rating($audience_rating); } $asset_audience = $this->assets_model->insert_asset_audience_rating($asset_audience_rating); } } } if ($this->input->post('asset_annotation')) { $annotation_type = $this->input->post('asset_annotation_type'); $annotation_ref = $this->input->post('asset_annotation_ref'); foreach ($this->input->post('asset_annotation') as $index => $value) { if (!empty($value)) { $annotation['assets_id'] = $asset_id; $annotation['annotation'] = $value; if (!empty($annotation_type[$index])) { $annotation['annotation_type'] = $annotation_type[$index]; } if (!empty($annotation_ref[$index])) { $annotation['annotation_ref'] = $annotation_ref[$index]; } $asset_annotation = $this->assets_model->insert_annotation($annotation); } } } if ($this->input->post('asset_relation_identifier')) { $relation_src = $this->input->post('asset_relation_source'); $relation_ref = $this->input->post('asset_relation_ref'); $relation_type = $this->input->post('asset_relation_type'); foreach ($this->input->post('asset_relation_identifier') as $index => $value) { if (!empty($value)) { $assets_relation['assets_id'] = $asset_id; $assets_relation['relation_identifier'] = $value; $relation_types['relation_type'] = $relation_type[$index]; if (!empty($relation_src[$index])) { $relation_types['relation_type_source'] = $relation_src[$index]; } if (!empty($relation_ref[$index])) { $relation_types['relation_type_ref'] = $relation_ref[$index]; } $db_relations = $this->assets_model->get_relation_types_all($relation_types); if (isset($db_relations) && isset($db_relations->id)) { $assets_relation['relation_types_id'] = $db_relations->id; } else { $assets_relation['relation_types_id'] = $this->assets_model->insert_relation_types($relation_types); } $this->assets_model->insert_asset_relation($assets_relation); } } } if ($this->input->post('asset_creator_name')) { $affiliation = $this->input->post('asset_creator_affiliation'); $ref = $this->input->post('asset_creator_ref'); $roles = $this->input->post('asset_creator_role'); $role_src = $this->input->post('asset_creator_role_source'); $role_ref = $this->input->post('asset_creator_role_ref'); foreach ($this->input->post('asset_creator_name') as $index => $value) { if (!empty($value)) { $assets_creators_roles_d['assets_id'] = $asset_id; $creater['creator_name'] = $value; if (!empty($affiliation[$index])) { $creater['creator_affiliation'] = $affiliation[$index]; } if (!empty($ref[$index])) { $creater['creator_ref'] = $ref[$index]; } $creator_d = $this->assets_model->get_creator_by_creator_info($creater); if (isset($creator_d) && isset($creator_d->id)) { $assets_creators_roles_d['creators_id'] = $creator_d->id; } else { $assets_creators_roles_d['creators_id'] = $this->assets_model->insert_creators($creater); } $role['creator_role'] = $roles[$index]; if (!empty($role_src[$index])) { $role['creator_role_source'] = $role_src[$index]; } if (!empty($role_ref[$index])) { $role['creator_role_ref'] = $role_ref[$index]; } $creator_role = $this->assets_model->get_creator_role_info($role); if (isset($creator_role) && isset($creator_role->id)) { $assets_creators_roles_d['creator_roles_id'] = $creator_role->id; } else { $assets_creators_roles_d['creator_roles_id'] = $this->assets_model->insert_creator_roles($role); } $assets_creators_roles_id = $this->assets_model->insert_assets_creators_roles($assets_creators_roles_d); } } } if ($this->input->post('asset_contributor_name')) { $affiliation = $this->input->post('asset_contributor_affiliation'); $ref = $this->input->post('asset_contributor_ref'); $roles = $this->input->post('asset_contributor_role'); $role_src = $this->input->post('asset_contributor_role_source'); $role_ref = $this->input->post('asset_contributor_role_ref'); foreach ($this->input->post('asset_contributor_name') as $index => $value) { if (!empty($value)) { $assets_contributors_d['assets_id'] = $asset_id; $contributor_info['contributor_name'] = $value; if (!empty($affiliation[$index])) { $contributor_info['contributor_affiliation'] = $affiliation[$index]; } if (!empty($ref[$index])) { $contributor_info['contributor_ref'] = $ref[$index]; } $creator_d = $this->assets_model->get_contributor_by_contributor_info($contributor_info); if (isset($creator_d) && isset($creator_d->id)) { $assets_contributors_d['contributors_id'] = $creator_d->id; } else { $assets_contributors_d['contributors_id'] = $this->assets_model->insert_contributors($contributor_info); } $contributorrole_info['contributor_role'] = $roles[$index]; if (!empty($role_src[$index])) { $contributorrole_info['contributor_role_source'] = $role_src[$index]; } if (!empty($role_ref[$index])) { $contributorrole_info['contributor_role_ref'] = $role_ref[$index]; } $contributor_role = $this->assets_model->get_contributor_role_info($contributorrole_info); if (isset($contributor_role) && isset($contributor_role->id)) { $assets_contributors_d['contributor_roles_id'] = $contributor_role->id; } else { $assets_contributors_d['contributor_roles_id'] = $this->assets_model->insert_contributor_roles($contributorrole_info); } $this->assets_model->insert_assets_contributors_roles($assets_contributors_d); } } } if ($this->input->post('asset_publisher')) { $affiliation = $this->input->post('asset_publisher_affiliation'); $ref = $this->input->post('asset_publisher_ref'); $roles = $this->input->post('asset_publisher_role'); $role_src = $this->input->post('asset_publisher_role_source'); $role_ref = $this->input->post('asset_publisher_role_ref'); foreach ($this->input->post('asset_publisher') as $index => $value) { if (!empty($value)) { $assets_publisher_d['assets_id'] = $asset_id; $publisher_info['publisher'] = $value; if (!empty($affiliation[$index])) { $publisher_info['publisher_affiliation'] = $affiliation[$index]; } if (!empty($ref[$index])) { $publisher_info['publisher_ref'] = $ref[$index]; } $publisher_d = $this->assets_model->get_publisher_info($publisher_info); if (isset($publisher_d) && isset($publisher_d->id)) { $assets_publisher_d['publishers_id'] = $publisher_d->id; } else { $assets_publisher_d['publishers_id'] = $this->assets_model->insert_publishers($publisher_info); } $publisher_role_info['publisher_role'] = $roles[$index]; if (!empty($role_src[$index])) { $publisher_role_info['publisher_role_source'] = $role_src[$index]; } if (!empty($role_ref[$index])) { $publisher_role_info['publisher_role_ref'] = $role_ref[$index]; } $publisher_role = $this->assets_model->get_publisher_role_by_role($publisher_role_info); if (isset($publisher_role) && isset($publisher_role->id)) { $assets_publisher_d['publisher_roles_id'] = $publisher_role->id; } else { $assets_publisher_d['publisher_roles_id'] = $this->assets_model->insert_publisher_roles($publisher_role_info); } $assets_publishers_roles_id = $this->assets_model->insert_assets_publishers_role($assets_publisher_d); } } } if ($this->input->post('asset_rights')) { $right_link = $this->input->post('asset_right_link'); foreach ($this->input->post('asset_rights') as $index => $value) { $rights_summary_d['assets_id'] = $asset_id; $rights_summary_d['rights'] = $value; if (!empty($right_link[$index])) { $rights_summary_d['rights_link'] = $right_link[$index]; } $this->assets_model->insert_rights_summaries($rights_summary_d); } } // Update Sphnix Indexes $asset_list = $this->searchd_model->get_asset_index(array($asset_id)); $new_asset_info = make_assets_sphnix_array($asset_list[0], FALSE); $this->sphnixrt->update('assets_list', $new_asset_info); $instantiations_of_asset = $this->searchd_model->get_ins_by_asset_id($asset_id); if (count($instantiations_of_asset) > 0) { foreach ($instantiations_of_asset as $ins_asset) { $instantiation_list = $this->searchd_model->get_ins_index(array($ins_asset->id)); $new_list_info = make_instantiation_sphnix_array($instantiation_list[0], FALSE); $this->sphnixrt->update('instantiations_list', $new_list_info); } } // End Update Sphnix Indexes $log = array('user_id' => $this->user_id, 'record_id' => $asset_id, 'record' => 'asset', 'type' => 'edit', 'comments' => 'update from asset detail page.'); $this->audit_trail($log); redirect('records/details/' . $asset_id, 'location'); } $data['asset_detail'] = $this->manage_asset->get_asset_detail_by_id($asset_id); if ($data['asset_detail']) { $data['asset_id'] = $asset_id; $data['list_assets'] = $this->instantiation->get_instantiations_by_asset_id($asset_id); $data['pbcore_asset_types'] = $this->manage_asset->get_picklist_values(1); $data['pbcore_asset_date_types'] = $this->manage_asset->get_picklist_values(2); $data['pbcore_asset_title_types'] = $this->manage_asset->get_picklist_values(3); $data['pbcore_asset_subject_types'] = $this->manage_asset->get_subject_types(); $data['pbcore_asset_description_types'] = $this->manage_asset->get_picklist_values(4); $data['pbcore_asset_audience_level'] = $this->manage_asset->get_picklist_values(5); $data['pbcore_asset_audience_rating'] = $this->manage_asset->get_picklist_values(6); $data['pbcore_asset_relation_types'] = $this->manage_asset->get_picklist_values(7); $data['pbcore_asset_creator_roles'] = $this->manage_asset->get_picklist_values(8); $data['pbcore_asset_contributor_roles'] = $this->manage_asset->get_picklist_values(9); $data['pbcore_asset_publisher_roles'] = $this->manage_asset->get_picklist_values(10); $data['organization'] = $this->station_model->get_all(); $this->load->view('assets/edit', $data); } else { show_error('Not a valid asset id'); } } else { show_error('Require asset id for editing'); } }
/** * Update assets information from csv that is exported from AMS Refine. * * @param string $csv_path complete path of csv * * @return */ function update_assets($csv_path, $user_id) { $records = file($csv_path); foreach ($records as $index => $line) { if ($index != 0) { $exploded_columns = preg_split("/\t/", $line); $asset_id = $exploded_columns[51]; myLog('Asset ID => ' . $asset_id); $asset_date_id = $exploded_columns[50]; $asset_identifier_id = $exploded_columns[49]; $asset_type_id = $exploded_columns[48]; $asset_right_id = $exploded_columns[47]; $asset_annotation_id = $exploded_columns[46]; $asset_rating_id = $exploded_columns[45]; $asset_level_id = $exploded_columns[44]; $asset_coverage_id = $exploded_columns[43]; $asset_publisher_id = $exploded_columns[42]; $asset_contributer_id = $exploded_columns[41]; $asset_creator_id = $exploded_columns[40]; $asset_genre_id = $exploded_columns[39]; $asset_subject_id = $exploded_columns[38]; /* Check and update Subject Start */ if (!empty($exploded_columns[3])) { $subjects = $this->assets_model->get_subjects_id_by_subject($exploded_columns[3]); if (isset($subjects) && isset($subjects->id)) { $subject_id = $subjects->id; } else { $subject_d['subject'] = $exploded_columns[3]; $subject_d['subject_source'] = $exploded_columns[4]; $subject_d['subject_ref'] = $exploded_columns[5]; $subject_id = $this->assets_model->insert_subjects($subject_d); } if (!empty($asset_subject_id)) { $this->refine_modal->update_asset_subject($asset_id, $asset_subject_id, array('subjects_id' => $subject_id)); } else { $subject_data = array('subjects_id' => $subject_id, 'assets_id' => $asset_id); $this->assets_model->insert_assets_subjects($subject_data); } } /* Check and update Subject End */ /* Check and update Genre Start */ if (!empty($exploded_columns[6])) { $asset_genre['assets_id'] = $asset_id; $asset_genre_type = $this->assets_model->get_genre_type($exploded_columns[6]); if (isset($asset_genre_type) && isset($asset_genre_type->id)) { $asset_genre['genres_id'] = $asset_genre_type->id; } else { $asset_genre_d['genre'] = $exploded_columns[6]; $asset_genre_d['genre_source'] = $exploded_columns[7]; $asset_genre_d['genre_ref'] = $exploded_columns[8]; $asset_genre['genres_id'] = $this->assets_model->insert_genre($asset_genre_d); } if (!empty($asset_genre_id)) { $this->refine_modal->update_asset_genre($asset_id, $asset_genre_id, array('genres_id' => $asset_genre['genres_id'])); } else { $this->assets_model->insert_asset_genre($asset_genre); } } /* Check and update Genre Start */ /* Check and update Creator Start */ if (!empty($exploded_columns[9])) { $assets_creators_roles_d['assets_id'] = $asset_id; $creator_d = $this->assets_model->get_creator_by_creator_name($exploded_columns[9]); if (isset($creator_d) && isset($creator_d->id)) { $assets_creators_roles_d['creators_id'] = $creator_d->id; } else { $creator_data = array('creator_name' => $exploded_columns[9], 'creator_affiliation' => $exploded_columns[10], 'creator_source' => $exploded_columns[11], 'creator_ref' => $exploded_columns[12]); $assets_creators_roles_d['creators_id'] = $this->assets_model->insert_creators($creator_data); } if (!empty($asset_creator_id)) { $this->refine_modal->update_creator_role($asset_id, $asset_creator_id, array('creators_id' => $assets_creators_roles_d['creators_id'])); } else { $this->assets_model->insert_assets_creators_roles($assets_creators_roles_d); } } /* Check and update Creator End */ /* Check and update Contributer Start */ if (!empty($exploded_columns[13])) { $assets_contributer_roles_d['assets_id'] = $asset_id; $contributer_d = $this->assets_model->get_contributor_by_contributor_name($exploded_columns[13]); if (isset($contributer_d) && isset($contributer_d->id)) { $assets_contributer_roles_d['contributors_id'] = $contributer_d->id; } else { $contributer_data = array('contributor_name' => $exploded_columns[13], 'contributor_affiliation' => $exploded_columns[14], 'contributor_source' => $exploded_columns[15], 'contributor_ref' => $exploded_columns[16]); $assets_contributer_roles_d['contributors_id'] = $this->assets_model->insert_contributors($contributer_data); } if (!empty($asset_contributer_id)) { $this->refine_modal->update_contributer_role($asset_id, $asset_contributer_id, array('contributors_id' => $assets_contributer_roles_d['contributors_id'])); } else { $this->assets_model->insert_assets_contributors_roles($assets_contributer_roles_d); } } /* Check and update Contributer End */ /* Check and update Publisher Start */ if (!empty($exploded_columns[17])) { $assets_publisher_d['assets_id'] = $asset_id; $publisher_d = $this->assets_model->get_publishers_by_publisher($exploded_columns[17]); if (isset($publisher_d) && isset($publisher_d->id)) { $assets_publisher_d['publishers_id'] = $publisher_d->id; } else { $publisher_data = array('publisher' => $exploded_columns[17], 'publisher_affiliation' => $exploded_columns[18], 'publisher_ref' => $exploded_columns[19]); $assets_publisher_d['publishers_id'] = $this->assets_model->insert_publishers($publisher_data); } if (!empty($asset_publisher_id)) { $this->refine_modal->update_publisher_role($asset_id, $asset_publisher_id, array('publishers_id' => $assets_publisher_d['publishers_id'])); } else { $this->assets_model->insert_assets_publishers_role($assets_publisher_d); } } /* Check and update Publisher End */ /* Check and update Coverage Start */ if (!empty($exploded_columns[20])) { $coverage['coverage'] = $exploded_columns[20]; $coverage['coverage_type'] = $exploded_columns[21]; if (!empty($asset_coverage_id)) { $this->refine_modal->update_asset_coverage($asset_id, $asset_coverage_id, $coverage); } else { $coverage['assets_id'] = $asset_id; $asset_coverage = $this->assets_model->insert_coverage($coverage); } } /* Check and update Coverage End */ /* Check and update Audience Level Start */ if (!empty($exploded_columns[22])) { $asset_audience_level['assets_id'] = $asset_id; $db_audience_level = $this->assets_model->get_audience_level($exploded_columns[22]); if (isset($db_audience_level) && isset($db_audience_level->id)) { $asset_audience_level['audience_levels_id'] = $db_audience_level->id; } else { $audience_level['audience_level'] = $exploded_columns[22]; $audience_level['audience_level_source'] = $exploded_columns[23]; $audience_level['audience_level_ref'] = $exploded_columns[24]; $asset_audience_level['audience_levels_id'] = $this->assets_model->insert_audience_level($audience_level); } if (!empty($asset_level_id)) { $this->refine_modal->update_asset_audience_level($asset_id, $asset_level_id, array('audience_levels_id' => $asset_audience_level['audience_levels_id'])); } else { $asset_audience = $this->assets_model->insert_asset_audience($asset_audience_level); } } /* Check and update Audience Level End */ /* Check and update Audience Rating Start */ if (!empty($exploded_columns[25])) { $asset_audience_rating['assets_id'] = $asset_id; $db_audience_rating = $this->assets_model->get_audience_rating($audience_rating['audience_rating']); if (isset($db_audience_rating) && isset($db_audience_rating->id)) { $asset_audience_rating['audience_ratings_id'] = $db_audience_rating->id; } else { $audience_rating['audience_rating'] = $exploded_columns[25]; $audience_rating['audience_rating_source'] = $exploded_columns[26]; $audience_rating['audience_rating_ref'] = $exploded_columns[27]; $asset_audience_rating['audience_ratings_id'] = $this->assets_model->insert_audience_rating($audience_rating); } if (!empty($asset_rating_id)) { $this->refine_modal->update_asset_audience_rating($asset_id, $asset_rating_id, array('audience_ratings_id' => $asset_audience_rating['audience_ratings_id'])); } else { $asset_audience_rate = $this->assets_model->insert_asset_audience_rating($asset_audience_rating); } } /* Check and update Audience Rating End */ /* Check and update Annotation Start */ if (!empty($exploded_columns[28])) { $annotation['annotation'] = $exploded_columns[28]; $annotation['annotation_type'] = $exploded_columns[29]; $annotation['annotation_ref'] = $exploded_columns[30]; if (!empty($asset_annotation_id)) { $this->refine_modal->update_annotation_type($asset_id, $asset_annotation_id, $annotation); } else { $annotation['assets_id'] = $asset_id; $asset_annotation = $this->assets_model->insert_annotation($annotation); } } /* Check and update Annotation End */ /* Check and update Rights Start */ if (!empty($exploded_columns[31])) { $rights_summary_d['rights'] = $exploded_columns[31]; $rights_summary_d['rights_link'] = $exploded_columns[32]; if (!empty($asset_right_id)) { $this->refine_modal->update_right_summary($asset_id, $asset_right_id, $rights_summary_d); } else { $rights_summary_d['assets_id'] = $asset_id; $this->assets_model->insert_rights_summaries($rights_summary_d); } } /* Check and update Rights End */ /* Check and update Asset Type Start */ if (!empty($exploded_columns[33])) { $asset_type_d['assets_id'] = $asset_id; if ($asset_type = $this->assets_model->get_assets_type_by_type($exploded_columns[33])) { $asset_type_d['asset_types_id'] = $asset_type->id; } else { $asset_type_d['asset_types_id'] = $this->assets_model->insert_asset_types(array("asset_type" => $exploded_columns[33])); } if (!empty($asset_type_id)) { $this->refine_modal->update_asset_type($asset_id, $asset_right_id, array('asset_types_id' => $asset_type_d['asset_types_id'])); } else { $this->assets_model->insert_assets_asset_types($asset_type_d); } } /* Check and update Asset Type End */ /* Check and update Asset Identifier Start */ if (!empty($exploded_columns[34])) { $identifier_d['identifier'] = $exploded_columns[34]; $identifier_d['identifier_source'] = $exploded_columns[35]; $identifier_d['identifier_ref'] = $exploded_columns[36]; if (!empty($asset_identifier_id)) { $this->refine_modal->update_asset_identifier($asset_id, $asset_identifier_id, $identifier_d); } else { $identifier_d['assets_id'] = $asset_id; $this->assets_model->insert_identifiers($identifier_d); } } /* Check and update Asset Identifier End */ /* Check and update Asset Date Start */ if (!empty($exploded_columns[37])) { $asset_date['asset_date'] = $exploded_columns[37]; if (!empty($asset_date_id)) { $this->refine_modal->update_asset_date($asset_id, $asset_date_id, $asset_date); } else { $asset_date['assets_id'] = $asset_id; $this->assets_model->insert_asset_date($asset_date); } } /* Check and update Asset Date Start */ $log = array('user_id' => $user_id, 'record_id' => $asset_id, 'record' => 'asset', 'type' => 'refine', 'comments' => 'record updated using refine.'); $this->audit_trail($log); // Update Sphnix Indexes $asset_list = $this->searchd_model->get_asset_index(array($asset_id)); $new_asset_info = make_assets_sphnix_array($asset_list[0], FALSE); $this->sphnixrt->update('assets_list', $new_asset_info); $instantiations_of_asset = $this->searchd_model->get_ins_by_asset_id($asset_id); if (count($instantiations_of_asset) > 0) { foreach ($instantiations_of_asset as $ins_asset) { $instantiation_list = $this->searchd_model->get_ins_index(array($ins_asset->id)); $new_list_info = make_instantiation_sphnix_array($instantiation_list[0], FALSE); $this->sphnixrt->update('instantiations_list', $new_list_info); } } // End Update Sphnix Indexes } } }