Пример #1
0
 /**
  * Returns content for overlay containing details for media attribute
  *
  * Expects the following request parameters: 
  *		value_id = the id of the attribute value (ca_attribute_values) record to display
  *
  *	Optional request parameters:
  *		version = The version of the representation to display. If omitted the display version configured in media_display.conf is used
  *
  */
 public function GetMediaInfo()
 {
     $pn_representation_id = $this->request->getParameter('representation_id', pInteger);
     $pn_value_id = $this->request->getParameter('value_id', pInteger);
     if ($pn_value_id) {
         $t_rep = new ca_object_representations();
         $t_attr_val = new ca_attribute_values($pn_value_id);
         $t_attr = new ca_attributes($t_attr_val->get('attribute_id'));
         $t_subject = $this->opo_datamodel->getInstanceByTableNum($t_attr->get('table_num'), true);
         $t_subject->load($t_attr->get('row_id'));
         $va_rep_display_info = caGetMediaDisplayInfo('media_overlay', $t_attr_val->getMediaInfo('value_blob', 'INPUT', 'MIMETYPE'));
         // check subject_id here
         $va_opts = array('t_attribute_value' => $t_attr_val, 'display' => 'media_overlay', 't_subject' => $t_subject, 'containerID' => 'caMediaPanelContentArea');
         if (strlen($vs_use_book_viewer = $this->request->getParameter('use_book_viewer', pInteger))) {
             $va_opts['use_book_viewer'] = (bool) $vs_use_book_viewer;
         }
         $this->response->addContent(caGetMediaViewerHTMLBundle($this->request, $va_opts));
     } elseif ($pn_representation_id) {
         $t_rep = new ca_object_representations($pn_representation_id);
         $t_subject = new ca_objects($vn_subject_id = $this->request->getParameter('object_id', pInteger));
         if (!$vn_subject_id) {
             if (is_array($va_subject_ids = $t_rep->get($t_subject->tableName() . '.' . $t_subject->primaryKey(), array('returnAsArray' => true))) && sizeof($va_subject_ids)) {
                 $vn_subject_id = array_shift($va_subject_ids);
             } else {
                 $this->postError(1100, _t('Invalid object/representation'), 'ObjectEditorController->GetRepresentationInfo');
                 return;
             }
         }
         $va_opts = array('display' => 'media_overlay', 't_subject' => $t_subject, 't_representation' => $t_rep, 'containerID' => 'caMediaPanelContentArea');
         if (strlen($vs_use_book_viewer = $this->request->getParameter('use_book_viewer', pInteger))) {
             $va_opts['use_book_viewer'] = (bool) $vs_use_book_viewer;
         }
         $this->response->addContent(caGetMediaViewerHTMLBundle($this->request, $va_opts));
     } else {
         //
     }
     //$pn_value_id 	= $this->request->getParameter('value_id', pInteger);
     //$this->response->addContent(caGetMediaViewerHTMLBundle($this->request, array('display' => 'media_overlay', 't_attribute_value' => $pn_value_id, 'containerID' => 'caMediaPanelContentArea')));
 }
Пример #2
0
 /**
  * 
  *
  * @return boolean 
  */
 public function renumberObjects($po_application_plugin_manager = null)
 {
     if (!$this->getPrimaryKey()) {
         return false;
     }
     if ($va_non_conforming_objects = $this->getObjectsWithNonConformingIdnos()) {
         $va_objects = $this->getObjects();
         $vs_lot_num = $this->get('idno_stub');
         $t_object = new ca_objects();
         $vb_web_set_transaction = false;
         if (!$this->inTransaction()) {
             $o_trans = new Transaction($this->getDb());
             $vb_web_set_transaction = true;
         } else {
             $o_trans = $this->getTransaction();
         }
         $t_object->setTransaction($o_trans);
         $t_idno = $t_object->getIDNoPlugInInstance();
         $vs_separator = $t_idno->getSeparator();
         $vn_i = 1;
         foreach ($va_objects as $vn_object_id => $va_object_info) {
             if ($t_object->load($vn_object_id)) {
                 if ($po_application_plugin_manager) {
                     $po_application_plugin_manager->hookBeforeSaveItem(array('id' => $vn_object_id, 'table_num' => $t_object->tableNum(), 'table_name' => $t_object->tableName(), 'instance' => $t_object));
                 }
                 $t_object->setMode(ACCESS_WRITE);
                 $t_object->set('idno', $vs_lot_num . $vs_separator . $vn_i);
                 $t_object->update();
                 if ($t_object->numErrors()) {
                     $t->rollback();
                     $this->errors = $t_object->errors;
                     return false;
                 }
                 if ($po_application_plugin_manager) {
                     $po_application_plugin_manager->hookSaveItem(array('id' => $vn_object_id, 'table_num' => $t_object->tableNum(), 'table_name' => $t_object->tableName(), 'instance' => $t_object));
                 }
                 $vn_i++;
             }
         }
         if ($vb_web_set_transaction) {
             $o_trans->commit();
         }
     }
     return true;
 }
 /**
  * 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');
 }