<p class="bundleDisplayPlacementEditorHelpText"> <?php print _t('Relationships will be created by matching the identifier extracted from the media file name with identifiers in related records.'); ?> </p> <p> <table> <?php foreach (array('ca_entities', 'ca_places', 'ca_occurrences', 'ca_collections') as $vs_rel_table) { if ($o_config->get("{$vs_rel_table}_disable")) { continue; } if (!($t_rel_table = $t_object->getAppDatamodel()->getInstanceByTableName($vs_rel_table))) { continue; } $t_rel = ca_relationship_types::getRelationshipTypeInstance('ca_objects', $vs_rel_table); if (!$t_rel) { continue; } ?> <tr> <td class='formLabel'> <?php print caHTMLCheckboxInput('create_relationship_for[]', array('value' => $vs_rel_table, 'id' => "caCreateRelationshipForMedia{$vs_rel_table}", 'onclick' => "jQuery('#caRelationshipTypeIdFor{$vs_rel_table}').prop('disabled', !jQuery('#caCreateRelationshipForMedia{$vs_rel_table}').prop('checked'))"), array('dontConvertAttributeQuotesToEntities' => true)); print ' ' . _t("to %1 with relationship type", $t_rel_table->getProperty('NAME_SINGULAR')); ?> </td> <td class='formLabel'> <?php print $t_rel->getRelationshipTypesAsHTMLSelect('ltor', null, null, array('name' => "relationship_type_id_for_{$vs_rel_table}", 'id' => "caRelationshipTypeIdFor{$vs_rel_table}", 'disabled' => 1));
<p class="bundleDisplayPlacementEditorHelpText"> <?php print _t('Relationships will be created by matching the identifier extracted from the media file name with identifiers in related records.'); ?> </p> <div style='padding:10px 0px 10px 10px;'> <table> <?php foreach (array('ca_entities', 'ca_places', 'ca_occurrences', 'ca_collections') as $vs_rel_table) { if ($o_config->get("{$vs_rel_table}_disable")) { continue; } if (!($t_rel_table = $t_instance->getAppDatamodel()->getInstanceByTableName($vs_rel_table))) { continue; } $t_rel = ca_relationship_types::getRelationshipTypeInstance($t_instance->tableName(), $vs_rel_table); if (!$t_rel) { continue; } ?> <tr> <td class='formLabel'> <?php print caHTMLCheckboxInput('create_relationship_for[]', array('value' => $vs_rel_table, 'id' => "caCreateRelationshipForMedia{$vs_rel_table}", 'onclick' => "jQuery('#caRelationshipTypeIdFor{$vs_rel_table}').prop('disabled', !jQuery('#caCreateRelationshipForMedia{$vs_rel_table}').prop('checked'))"), array('dontConvertAttributeQuotesToEntities' => true)); print ' ' . _t("to %1 with relationship type", $t_rel_table->getProperty('NAME_SINGULAR')); ?> </td> <td class='formLabel'> <?php print $t_rel->getRelationshipTypesAsHTMLSelect('ltor', null, null, array('name' => "relationship_type_id_for_{$vs_rel_table}", 'id' => "caRelationshipTypeIdFor{$vs_rel_table}", 'disabled' => 1)); ?>
/** * Generates a form for specification of media import settings. The form is rendered into the current view, inherited from ActionController * * @param array $pa_values An optional array of values to preset in the format, overriding any existing values in the model of the record being editing. * @param array $pa_options Array of options passed through to _initView * */ public function Index($pa_values = null, $pa_options = null) { AssetLoadManager::register("directoryBrowser"); list($t_ui) = $this->_initView($pa_options); $this->view->setVar('batch_mediaimport_last_settings', $va_last_settings = is_array($va_last_settings = $this->request->user->getVar('batch_mediaimport_last_settings')) ? $va_last_settings : array()); // get import type from request $vs_import_target = $this->getRequest()->getParameter('target', pString); $t_instance = $this->getRequest()->getAppDatamodel()->getInstance($vs_import_target); // if that failed, try last settings if (!$t_instance) { $vs_import_target = $va_last_settings['importTarget']; $t_instance = $this->getRequest()->getAppDatamodel()->getInstance($vs_import_target); } // if that too failed, go back to objects if (!$t_instance) { $t_instance = new ca_objects(); $vs_import_target = 'ca_objects'; } $this->getView()->setVar('import_target', $vs_import_target); $t_instance->set('status', $va_last_settings[$vs_import_target . '_status']); $t_instance->set('access', $va_last_settings[$vs_import_target . '_access']); $t_rep = new ca_object_representations(); $t_rep->set('status', $va_last_settings['ca_object_representations_status']); $t_rep->set('access', $va_last_settings['ca_object_representations_access']); $va_nav = $t_ui->getScreensAsNavConfigFragment($this->request, null, $this->request->getModulePath(), $this->request->getController(), $this->request->getAction(), array(), array()); if (!$this->request->getActionExtra() || !isset($va_nav['fragment'][str_replace("Screen", "screen_", $this->request->getActionExtra())])) { $this->request->setActionExtra($va_nav['defaultScreen']); } $this->view->setVar('t_ui', $t_ui); $this->view->setVar('import_target', caHTMLSelect('import_target', $this->opa_importable_tables, array('id' => 'caImportTargetSelect', 'onchange' => 'window.location.replace("' . caNavUrl($this->getRequest(), $this->getRequest()->getModulePath(), $this->getRequest()->getController(), $this->getRequest()->getAction()) . '/target/" + jQuery("#caImportTargetSelect").val()); return false;'), array('value' => $vs_import_target))); $this->view->setVar('import_mode', caHTMLSelect('import_mode', array(_t('Import all media, matching with existing records where possible') => 'TRY_TO_MATCH', _t('Import only media that can be matched with existing records') => 'ALWAYS_MATCH', _t('Import all media, creating new records for each') => 'DONT_MATCH'), array(), array('value' => $va_last_settings['importMode']))); $this->view->setVar('match_mode', caHTMLSelect('match_mode', array(_t('Match using file name') => 'FILE_NAME', _t('Match using directory name') => 'DIRECTORY_NAME', _t('Match using directory name, then file name') => 'FILE_AND_DIRECTORY_NAMES'), array(), array('value' => $va_last_settings['matchMode']))); $this->view->setVar('match_type', caHTMLSelect('match_type', array(_t('matches exactly') => 'EXACT', _t('starts with') => 'STARTS', _t('ends with') => 'ENDS', _t('contains') => 'CONTAINS'), array(), array('value' => $va_last_settings['matchType']))); $this->view->setVar($vs_import_target . '_type_list', $t_instance->getTypeListAsHTMLFormElement($vs_import_target . '_type_id', null, array('value' => $va_last_settings[$vs_import_target . '_type_id']))); $this->view->setVar($vs_import_target . '_limit_to_types_list', $t_instance->getTypeListAsHTMLFormElement($vs_import_target . '_limit_matching_to_type_ids[]', array('multiple' => 1), array('height' => '100px', 'values' => $va_last_settings[$vs_import_target . '_limit_matching_to_type_ids']))); $this->view->setVar('ca_object_representations_type_list', $t_rep->getTypeListAsHTMLFormElement('ca_object_representations_type_id', null, array('value' => $va_last_settings['ca_object_representations_type_id']))); if ($vs_import_target != 'ca_objects') { // non-object representations have relationship types $t_rel = ca_relationship_types::getRelationshipTypeInstance($t_instance->tableName(), 'ca_object_representations'); $this->getView()->setVar($vs_import_target . '_representation_relationship_type', $t_rel->getRelationshipTypesAsHTMLSelect('ltor', null, null, array('name' => $vs_import_target . '_representation_relationship_type'), array('value' => $va_last_settings[$vs_import_target . '_representation_relationship_type']))); } $va_importer_list = ca_data_importers::getImporters(null, array('formats' => array('exif'))); $va_object_importer_options = $va_object_representation_importer_options = array("-" => ''); foreach ($va_importer_list as $vn_importer_id => $va_importer_info) { if ($va_importer_info['table_num'] == $t_instance->tableNum()) { // target table $va_object_importer_options[$va_importer_info['label']] = $vn_importer_id; } else { $va_object_representation_importer_options[$va_importer_info['label']] = $vn_importer_id; } } $this->view->setVar($vs_import_target . '_mapping_list', caHTMLSelect($vs_import_target . '_mapping_id', $va_object_importer_options, array(), array('value' => $va_last_settings[$vs_import_target . '_mapping_id']))); $this->view->setVar($vs_import_target . '_mapping_list_count', sizeof($va_object_importer_options)); $this->view->setVar('ca_object_representations_mapping_list', caHTMLSelect('ca_object_representations_mapping_id', $va_object_representation_importer_options, array(), array('value' => $va_last_settings['ca_object_representations_mapping_id']))); $this->view->setVar('ca_object_representations_mapping_list_count', sizeof($va_object_representation_importer_options)); // // Available sets // $t_set = new ca_sets(); $va_available_set_list = caExtractValuesByUserLocale($t_set->getSets(array('table' => $vs_import_target, 'user_id' => $this->request->getUserID(), 'access' => __CA_SET_EDIT_ACCESS__, 'omitCounts' => true))); $va_available_sets = array(); foreach ($va_available_set_list as $vn_set_id => $va_set) { $va_available_sets[$va_set['name']] = $vn_set_id; } $this->view->setVar('available_sets', $va_available_sets); $this->view->setVar('t_instance', $t_instance); $this->view->setVar('t_rep', $t_rep); $this->render('mediaimport/import_options_html.php'); }