/**
  * Override BundlableLabelableBaseModelWithAttributes::changeType() to update
  * current location "subclass" (ie. type) value when type change is used.
  * This should be invoked by any model that can be used to indicate object
  * storage location. This includes, for now at least, ca_loans, ca_movements, 
  * ca_occurrences and ca_objects_x_storage_locations.
  *
  * @param mixed $pm_type The type_id or code to change the current type to
  * @return bool True if change succeeded, false if error
  */
 public function changeType($pm_type)
 {
     if (!$this->getPrimaryKey()) {
         return false;
     }
     // row must be loaded
     if (!($vb_already_in_transaction = $this->inTransaction())) {
         $this->setTransaction($o_t = new Transaction($this->getDb()));
     }
     if ($vn_rc = parent::changeType($pm_type)) {
         $o_db = $this->getDb();
         $o_db->query("\n\t\t\t\t\tUPDATE ca_objects SET current_loc_subclass = ? \n\t\t\t\t\tWHERE \n\t\t\t\t\t\tcurrent_loc_class = ? AND current_loc_id = ?\n\t\t\t\t", array($this->get('type_id'), $this->tableNum(), $this->getPrimaryKey()));
         if ($o_db->numErrors()) {
             $this->errors = $o_db->errors;
             if (!$vb_already_in_transaction) {
                 $o_t->rollback();
             }
             return false;
         }
     }
     if (!$vb_already_in_transaction) {
         $o_t->commit();
     }
     return $vn_rc;
 }
 protected function initLabelDefinitions($pa_options = null)
 {
     parent::initLabelDefinitions($pa_options);
     $this->BUNDLES['ca_object_representations'] = array('type' => 'related_table', 'repeating' => true, 'label' => _t('Media representations'));
     $this->BUNDLES['ca_entities'] = array('type' => 'related_table', 'repeating' => true, 'label' => _t('Related entities'));
     $this->BUNDLES['ca_objects'] = array('type' => 'related_table', 'repeating' => true, 'label' => _t('Related objects'));
     $this->BUNDLES['ca_object_lots'] = array('type' => 'related_table', 'repeating' => true, 'label' => _t('Related lots'));
     $this->BUNDLES['ca_places'] = array('type' => 'related_table', 'repeating' => true, 'label' => _t('Related places'));
     $this->BUNDLES['ca_collections'] = array('type' => 'related_table', 'repeating' => true, 'label' => _t('Related collections'));
     $this->BUNDLES['ca_occurrences'] = array('type' => 'related_table', 'repeating' => true, 'label' => _t('Related occurrences'));
     $this->BUNDLES['ca_storage_locations'] = array('type' => 'related_table', 'repeating' => true, 'label' => _t('Related storage locations'));
     $this->BUNDLES['ca_loans'] = array('type' => 'related_table', 'repeating' => true, 'label' => _t('Related loans'));
     $this->BUNDLES['ca_movements'] = array('type' => 'related_table', 'repeating' => true, 'label' => _t('Related movements'));
     $this->BUNDLES['ca_tour_stops'] = array('type' => 'related_table', 'repeating' => true, 'label' => _t('Related tour stops'));
     $this->BUNDLES['ca_list_items'] = array('type' => 'related_table', 'repeating' => true, 'label' => _t('Related vocabulary terms'));
     $this->BUNDLES['ca_sets'] = array('type' => 'special', 'repeating' => true, 'label' => _t('Sets'));
     $this->BUNDLES['authority_references_list'] = array('type' => 'special', 'repeating' => false, 'label' => _t('References'));
     $this->BUNDLES['hierarchy_navigation'] = array('type' => 'special', 'repeating' => false, 'label' => _t('Hierarchy navigation'));
     $this->BUNDLES['hierarchy_location'] = array('type' => 'special', 'repeating' => false, 'label' => _t('Location in hierarchy'));
 }
 /**
  * Returns values for bundle. Can be used to set initial state of bundle as well as to grab partial value sets for
  * progressive loading of bundles.
  *
  * NOTE: Currently only support ca_object_representations bundle
  *
  */
 public function getBundleFormValues($ps_bundle_name, $ps_placement_code, $pa_bundle_settings, $pa_options = null)
 {
     global $g_ui_locale;
     // Check if user has access to this bundle
     if ($pa_options['request']->user->getBundleAccessLevel($this->tableName(), $ps_bundle_name) == __CA_BUNDLE_ACCESS_NONE__) {
         return;
     }
     // Check if user has access to this type
     if ((bool) $this->getAppConfig()->get('perform_type_access_checking')) {
         $vn_type_access = $pa_options['request']->user->getTypeAccessLevel($this->tableName(), $this->getTypeID());
         if ($vn_type_access == __CA_BUNDLE_ACCESS_NONE__) {
             return;
         }
         if ($vn_type_access == __CA_BUNDLE_ACCESS_READONLY__) {
             $pa_bundle_settings['readonly'] = true;
         }
     }
     // Check if user has access to this source
     if ((bool) $this->getAppConfig()->get('perform_source_access_checking')) {
         $vn_source_access = $pa_options['request']->user->getSourceAccessLevel($this->tableName(), $this->getSourceID());
         if ($vn_source_access == __CA_BUNDLE_ACCESS_NONE__) {
             return;
         }
         if ($vn_source_access == __CA_BUNDLE_ACCESS_READONLY__) {
             $pa_bundle_settings['readonly'] = true;
         }
     }
     if ((bool) $this->getAppConfig()->get('perform_item_level_access_checking') && $this->getPrimaryKey()) {
         $vn_item_access = $this->checkACLAccessForUser($pa_options['request']->user);
         if ($vn_item_access == __CA_ACL_NO_ACCESS__) {
             return;
         }
         if ($vn_item_access == __CA_ACL_READONLY_ACCESS__) {
             $pa_bundle_settings['readonly'] = true;
         }
     }
     $va_info = $this->getBundleInfo($ps_bundle_name);
     if (!($vs_type = $va_info['type'])) {
         return null;
     }
     if (isset($pa_options['config']) && is_object($pa_options['config'])) {
         $o_config = $pa_options['config'];
     } else {
         $o_config = $this->getAppConfig();
     }
     // start and count
     $pn_start = caGetOption('start', $pa_options, 0);
     $pn_limit = caGetOption('limit', $pa_options, null);
     $vs_element = '';
     switch ($vs_type) {
         # -------------------------------------------------
         case 'preferred_label':
         case 'nonpreferred_label':
             break;
             # -------------------------------------------------
         # -------------------------------------------------
         case 'intrinsic':
             break;
             # -------------------------------------------------
         # -------------------------------------------------
         case 'attribute':
             break;
             # -------------------------------------------------
         # -------------------------------------------------
         case 'related_table':
             switch ($ps_bundle_name) {
                 # -------------------------------
                 case 'ca_object_representations':
                     foreach (array('restrict_to_types', 'restrict_to_relationship_types') as $vs_k) {
                         $pa_options[$vs_k] = $pa_bundle_settings[$vs_k];
                     }
                     $va_reps = $this->getRepresentations(array('thumbnail', 'original'), null, $pa_options);
                     $t_item = new ca_object_representations();
                     $va_rep_type_list = $t_item->getTypeList();
                     $va_errors = array();
                     $vs_bundle_template = caGetOption('display_template', $pa_bundle_settings, null);
                     // Paging
                     $vn_primary_id = 0;
                     $va_initial_values = array();
                     if (sizeof($va_reps)) {
                         $o_type_config = Configuration::load($t_item->getAppConfig()->get('annotation_type_config'));
                         $va_annotation_type_mappings = $o_type_config->getAssoc('mappings');
                         // Get display template values
                         $va_display_template_values = array();
                         if ($vs_bundle_template && is_array($va_relation_ids = caExtractValuesFromArrayList($va_reps, 'relation_id')) && sizeof($va_relation_ids)) {
                             if ($vs_linking_table = RepresentableBaseModel::getRepresentationRelationshipTableName($this->tableName())) {
                                 $va_display_template_values = caProcessTemplateForIDs($vs_bundle_template, $vs_linking_table, $va_relation_ids, array_merge($pa_options, array('returnAsArray' => true, 'returnAllLocales' => false, 'includeBlankValuesInArray' => true)));
                             }
                         }
                         $vn_i = 0;
                         foreach ($va_reps as $va_rep) {
                             $vn_num_multifiles = $va_rep['num_multifiles'];
                             if ($vs_extracted_metadata = caFormatMediaMetadata(caSanitizeArray(caUnserializeForDatabase($va_rep['media_metadata'])))) {
                                 $vs_extracted_metadata = "<h3>" . _t('Extracted metadata') . ":</h3>\n{$vs_extracted_metadata}\n";
                             }
                             $vs_md5 = isset($va_rep['info']['original']['MD5']) ? "<h3>" . _t('MD5 signature') . ':</h3>' . $va_rep['info']['original']['MD5'] : '';
                             if ($va_rep['is_primary']) {
                                 $vn_primary_id = $va_rep['representation_id'];
                             }
                             $va_initial_values[$va_rep['representation_id']] = array('idno' => $va_rep['idno'], '_display' => $vs_bundle_template && isset($va_display_template_values[$vn_i]) ? $va_display_template_values[$vn_i] : '', 'status' => $va_rep['status'], 'status_display' => $t_item->getChoiceListValue('status', $va_rep['status']), 'access' => $va_rep['access'], 'access_display' => $t_item->getChoiceListValue('access', $va_rep['access']), 'rep_type_id' => $va_rep['type_id'], 'rep_type' => $t_item->getTypeName($va_rep['type_id']), 'rep_label' => $va_rep['label'], 'is_primary' => (int) $va_rep['is_primary'], 'is_primary_display' => $va_rep['is_primary'] == 1 ? _t('PRIMARY') : '', 'locale_id' => $va_rep['locale_id'], 'icon' => $va_rep['tags']['thumbnail'], 'mimetype' => $va_rep['info']['original']['PROPERTIES']['mimetype'], 'annotation_type' => isset($va_annotation_type_mappings[$va_rep['info']['original']['PROPERTIES']['mimetype']]) ? $va_annotation_type_mappings[$va_rep['info']['original']['PROPERTIES']['mimetype']] : null, 'type' => $va_rep['info']['original']['PROPERTIES']['typename'], 'dimensions' => $va_rep['dimensions']['original'], 'filename' => $va_rep['info']['original_filename'] ? $va_rep['info']['original_filename'] : _t('Unknown'), 'num_multifiles' => $vn_num_multifiles ? $vn_num_multifiles == 1 ? _t('+ 1 additional preview') : _t('+ %1 additional previews', $vn_num_multifiles) : '', 'metadata' => $vs_extracted_metadata, 'md5' => $vs_md5 ? "{$vs_md5}" : "", 'typename' => $va_rep_type_list[$va_rep['type_id']]['name_singular'], 'fetched_from' => $va_rep['fetched_from'], 'fetched_on' => date('c', $va_rep['fetched_on']), 'fetched' => $va_rep['fetched_from'] ? _t("<h3>Fetched from:</h3> URL %1 on %2", '<a href="' . $va_rep['fetched_from'] . '" target="_ext" title="' . $va_rep['fetched_from'] . '">' . $va_rep['fetched_from'] . '</a>', date('c', $va_rep['fetched_on'])) : "");
                             $vn_i++;
                         }
                     }
                     return $va_initial_values;
                     break;
                 case 'ca_entities':
                 case 'ca_places':
                 case 'ca_occurrences':
                 case 'ca_objects':
                 case 'ca_collections':
                 case 'ca_list_items':
                 case 'ca_storage_locations':
                 case 'ca_loans':
                 case 'ca_movements':
                 case 'ca_tour_stops':
                     return $this->getRelatedBundleFormValues($pa_options['request'], $pa_options['formName'], $ps_bundle_name, $ps_placement_code, $pa_bundle_settings, $pa_options);
                     break;
                     # -------------------------------
                 # -------------------------------
                 case 'ca_object_lots':
                     break;
                     # -------------------------------
                 # -------------------------------
                 case 'ca_representation_annotations':
                     break;
                     # -------------------------------
                 # -------------------------------
                 default:
                     return null;
                     break;
                     # -------------------------------
             }
             break;
     }
     return null;
 }
Exemple #4
0
 /**
  * @param array $pa_options
  *		duplicate_media
  */
 public function duplicate($pa_options = null)
 {
     $vb_we_set_transaction = false;
     if (!$this->inTransaction()) {
         $this->setTransaction($o_t = new Transaction($this->getDb()));
         $vb_we_set_transaction = true;
     } else {
         $o_t = $this->getTransaction();
     }
     if ($t_dupe = parent::duplicate($pa_options)) {
         $vb_duplicate_media = isset($pa_options['duplicate_media']) && $pa_options['duplicate_media'];
         if ($vb_duplicate_media) {
             // Try to link representations
             $o_db = $this->getDb();
             $qr_res = $o_db->query("\n\t\t\t\t\tSELECT *\n\t\t\t\t\tFROM ca_objects_x_object_representations\n\t\t\t\t\tWHERE object_id = ?\n\t\t\t\t", (int) $this->getPrimaryKey());
             $va_reps = array();
             while ($qr_res->nextRow()) {
                 $va_reps[$qr_res->get('representation_id')] = $qr_res->getRow();
             }
             $t_object_x_rep = new ca_objects_x_object_representations();
             foreach ($va_reps as $vn_representation_id => $va_rep) {
                 $t_object_x_rep->setMode(ACCESS_WRITE);
                 $va_rep['object_id'] = $t_dupe->getPrimaryKey();
                 $t_object_x_rep->set($va_rep);
                 $t_object_x_rep->insert();
                 if ($t_object_x_rep->numErrors()) {
                     $this->errors = $t_object_x_rep->errors;
                     if ($vb_we_set_transaction) {
                         $o_t->rollback();
                     }
                     return false;
                 }
             }
         }
     } else {
         if ($vb_we_set_transaction) {
             $o_t->rollback();
         }
         return false;
     }
     if ($vb_we_set_transaction) {
         $o_t->commit();
     }
     return $t_dupe;
 }
Exemple #5
0
 /**
  * Override standard implementation to insert list_code for current list_id into returned data. The list_code is required for consumers of export data
  * when dealing with lists. 
  *
  * @param array $pa_options Array of options for BaseModel::getValuesForExport(). No additional options are defined by this subclass.
  * @return array Array of data as returned by BaseModel::getValuesForExport() except for added list_code value
  */
 public function getValuesForExport($pa_options = null)
 {
     $va_data = parent::getValuesForExport($pa_options);
     $t_list = new ca_lists($this->get('list_id'));
     $va_data['list_code'] = $t_list->get('list_code');
     return $va_data;
 }
 protected function initLabelDefinitions($pa_options = null)
 {
     parent::initLabelDefinitions($pa_options);
     $this->BUNDLES['ca_object_representations'] = array('type' => 'related_table', 'repeating' => true, 'label' => _t('Media representations'));
     $this->BUNDLES['ca_entities'] = array('type' => 'related_table', 'repeating' => true, 'label' => _t('Related entities'));
     $this->BUNDLES['ca_places'] = array('type' => 'related_table', 'repeating' => true, 'label' => _t('Related places'));
     $this->BUNDLES['ca_occurrences'] = array('type' => 'related_table', 'repeating' => true, 'label' => _t('Related occurrences'));
     $this->BUNDLES['ca_collections'] = array('type' => 'related_table', 'repeating' => true, 'label' => _t('Related collections'));
     $this->BUNDLES['ca_storage_locations'] = array('type' => 'related_table', 'repeating' => true, 'label' => _t('Related storage locations'));
     $this->BUNDLES['ca_loans'] = array('type' => 'related_table', 'repeating' => true, 'label' => _t('Related loans'));
     $this->BUNDLES['ca_movements'] = array('type' => 'related_table', 'repeating' => true, 'label' => _t('Related movements'));
     $this->BUNDLES['ca_object_lots'] = array('type' => 'related_table', 'repeating' => true, 'label' => _t('Related lots'));
     $this->BUNDLES['ca_list_items'] = array('type' => 'related_table', 'repeating' => true, 'label' => _t('Related vocabulary terms'));
     $this->BUNDLES['ca_sets'] = array('type' => 'special', 'repeating' => true, 'label' => _t('Sets'));
     $this->BUNDLES['ca_objects'] = array('type' => 'related_table', 'repeating' => true, 'label' => _t('Related objects'));
 }
 /**
  *
  */
 public function removeRelationship($pm_rel_table_name_or_num, $pn_relation_id)
 {
     $va_path = array_keys($this->getAppDatamodel()->getPath($this->tableName(), $pm_rel_table_name_or_num));
     $vn_rel_id = $t_rel_item = null;
     if (sizeof($va_path) == 3 && ($t_rel = $this->getAppDatamodel()->getInstance($va_path[1]))) {
         $t_rel->setTransaction($this->getTransaction());
         $t_rel_item = $this->getAppDatamodel()->getInstance($va_path[2], true);
         if ($t_rel->load($pn_relation_id)) {
             $vn_rel_id = $t_rel->get($t_rel_item->primaryKey());
         }
     }
     if ($vn_rc = parent::removeRelationship($pm_rel_table_name_or_num, $pn_relation_id)) {
         if ($vn_rel_id && $t_rel_item) {
             $this->_setCurrent($t_rel_item->tableName(), $vn_rel_id);
         }
     }
     return $vn_rc;
 }
Exemple #8
0
 /**
  * Override BaseModel::removeRelationships() to update current location fields in ca_objects
  *
  * @param mixed $pm_rel_table_name_or_num
  * @param mixed $pm_type_id
  *
  * @return int
  */
 public function removeRelationships($pm_rel_table_name_or_num, $pm_type_id = null)
 {
     if ($vn_rc = parent::removeRelationships($pm_rel_table_name_or_num, $pm_type_id)) {
         if ($this->relationshipChangeMayAffectCurrentLocation($pm_rel_table_name_or_num, null, $pm_type_id)) {
             $this->deriveCurrentLocationForBrowse();
         }
     }
     return $vn_rc;
 }
 /**
  * Returns number of representations attached to each item referenced by primary key in $pa_ids
  * 
  * @param array $pa_ids indexed array of primary key values to fetch labels for
  * @param array $pa_options
  * @return array List of representation counts indexed by primary key
  */
 public function getMediaCountsForIDs($pa_ids, $pa_options = null)
 {
     if (!is_array($pa_ids) || !sizeof($pa_ids)) {
         return array();
     }
     if (!is_array($pa_options)) {
         $pa_options = array();
     }
     $va_access_values = $pa_options["checkAccess"];
     if (isset($va_access_values) && is_array($va_access_values) && sizeof($va_access_values)) {
         $vs_access_where = ' AND orep.access IN (' . join(',', $va_access_values) . ')';
     }
     $o_db = $this->getDb();
     if (!($vs_linking_table = RepresentableBaseModel::getRepresentationRelationshipTableName($this->tableName()))) {
         return null;
     }
     $vs_pk = $this->primaryKey();
     $qr_res = $o_db->query("\n\t\t\t\tSELECT oxor.{$vs_pk}, count(*) c\n\t\t\t\tFROM ca_object_representations orep\n\t\t\t\tINNER JOIN {$vs_linking_table} AS oxor ON oxor.representation_id = orep.representation_id\n\t\t\t\tWHERE\n\t\t\t\t\t(oxor.{$vs_pk} IN (" . join(',', $pa_ids) . ")) AND orep.deleted = 0 {$vs_access_where}\n\t\t\t\tGROUP BY oxor.{$vs_pk}\n\t\t\t");
     $va_counts = array();
     while ($qr_res->nextRow()) {
         $va_counts[$qr_res->get($vs_pk)] = (int) $qr_res->get('c');
     }
     return $va_counts;
 }
 /**
  *
  */
 public function saveBundlesForScreen($pm_screen, $po_request, &$pa_options)
 {
     if ($vn_rc = parent::saveBundlesForScreen($pm_screen, $po_request, $pa_options)) {
         unset($pa_options['ui_instance']);
         // get list of objects currently associated with this storage location
         $va_object_ids = $this->getCurrentObjectIDs();
         $vs_movement_storage_location_relationship_type = $this->getAppConfig()->get('record_movement_information_when_moving_storage_location_movement_to_storage_location_relationship_type');
         $vs_movement_object_relationship_type = $this->getAppConfig()->get('record_movement_information_when_moving_storage_location_movement_to_object_relationship_type');
         foreach ($_REQUEST as $vs_key => $vs_val) {
             if (preg_match('!^(.*)_movement_form_name$!', $vs_key, $va_matches)) {
                 $vs_form_name = $po_request->getParameter($va_matches[1] . '_movement_form_name', pString);
                 $vs_screen = $po_request->getParameter($va_matches[1] . '_movement_screen', pString);
                 if (is_array($va_object_ids) && sizeof($va_object_ids)) {
                     $t_movement = new ca_movements();
                     $t_movement->set('type_id', $t_movement->getDefaultTypeID());
                     $va_movement_opts = array_merge($pa_options, array('formName' => $vs_form_name));
                     $t_movement->saveBundlesForScreen($vs_screen, $po_request, $va_movement_opts);
                     if ($vs_movement_storage_location_relationship_type) {
                         $t_movement->addRelationship('ca_storage_locations', $this->getPrimaryKey(), $vs_movement_storage_location_relationship_type);
                     }
                     if ($vs_movement_object_relationship_type) {
                         foreach ($va_object_ids as $vn_object_id) {
                             $t_movement->addRelationship('ca_objects', $vn_object_id, $vs_movement_object_relationship_type);
                         }
                     }
                 }
             }
         }
     }
     return $vn_rc;
 }
Exemple #11
0
/**
 * Returns associative array, keyed by primary key value with values being
 * the preferred label of the row from a suitable locale, ready for display 
 * 
 * @param array $pa_ids indexed array of primary key values to fetch labels for
 * @param array $pa_options
 * @return array List of media
 */
function caGetPrimaryRepresentationsForIDs($pa_ids, $pa_options = null)
{
    if (!is_array($pa_ids) && is_numeric($pa_ids) && $pa_ids > 0) {
        $pa_ids = array($pa_ids);
    }
    if (!is_array($pa_ids) || !sizeof($pa_ids)) {
        return array();
    }
    $pa_access_values = caGetOption("checkAccess", $pa_options, array());
    $pa_versions = caGetOption("versions", $pa_options, array(), array('castTo' => 'array'));
    $ps_table = caGetOption("table", $pa_options, 'ca_objects');
    $pa_return = caGetOption("return", $pa_options, array(), array('castTo' => 'array'));
    $vs_access_where = '';
    if (isset($pa_access_values) && is_array($pa_access_values) && sizeof($pa_access_values)) {
        $vs_access_where = ' AND orep.access IN (' . join(',', $pa_access_values) . ')';
    }
    $o_db = new Db();
    $o_dm = Datamodel::load();
    if (!($vs_linking_table = RepresentableBaseModel::getRepresentationRelationshipTableName($ps_table))) {
        return null;
    }
    $vs_pk = $o_dm->getTablePrimaryKeyName($ps_table);
    $qr_res = $o_db->query("\n\t\t\tSELECT oxor.{$vs_pk}, orep.media, orep.representation_id\n\t\t\tFROM ca_object_representations orep\n\t\t\tINNER JOIN {$vs_linking_table} AS oxor ON oxor.representation_id = orep.representation_id\n\t\t\tWHERE\n\t\t\t\t(oxor.{$vs_pk} IN (" . join(',', $pa_ids) . ")) AND oxor.is_primary = 1 AND orep.deleted = 0 {$vs_access_where}\n\t\t");
    $vb_return_tags = sizeof($pa_return) == 0 || in_array('tags', $pa_return);
    $vb_return_info = sizeof($pa_return) == 0 || in_array('info', $pa_return);
    $vb_return_urls = sizeof($pa_return) == 0 || in_array('urls', $pa_return);
    $va_media = array();
    while ($qr_res->nextRow()) {
        $va_media_tags = array();
        if ($pa_versions && is_array($pa_versions) && sizeof($pa_versions)) {
            $va_versions = $pa_versions;
        } else {
            $va_versions = $qr_res->getMediaVersions('media');
        }
        $vb_media_set = false;
        foreach ($va_versions as $vs_version) {
            if (!$vb_media_set && $qr_res->getMediaPath('ca_object_representations.media', $vs_version)) {
                $vb_media_set = true;
            }
            if ($vb_return_tags) {
                if (sizeof($va_versions) == 1) {
                    $va_media_tags['tags'] = $qr_res->getMediaTag('ca_object_representations.media', $vs_version);
                } else {
                    $va_media_tags['tags'][$vs_version] = $qr_res->getMediaTag('ca_object_representations.media', $vs_version);
                }
            }
            if ($vb_return_info) {
                if (sizeof($va_versions) == 1) {
                    $va_media_tags['info'] = $qr_res->getMediaInfo('ca_object_representations.media', $vs_version);
                } else {
                    $va_media_tags['info'][$vs_version] = $qr_res->getMediaInfo('ca_object_representations.media', $vs_version);
                }
            }
            if ($vb_return_urls) {
                if (sizeof($va_versions) == 1) {
                    $va_media_tags['urls'] = $qr_res->getMediaUrl('ca_object_representations.media', $vs_version);
                } else {
                    $va_media_tags['urls'][$vs_version] = $qr_res->getMediaUrl('ca_object_representations.media', $vs_version);
                }
            }
        }
        $va_media_tags['representation_id'] = $qr_res->get('ca_object_representations.representation_id');
        if (!$vb_media_set) {
            continue;
        }
        if (sizeof($pa_return) == 1) {
            $va_media_tags = $va_media_tags[$pa_return[0]];
        }
        $va_media[$qr_res->get($vs_pk)] = $va_media_tags;
    }
    // Return empty array when there's no media
    if (!sizeof($va_media)) {
        return array();
    }
    // Preserve order of input ids
    $va_media_sorted = array();
    foreach ($pa_ids as $vn_id) {
        if (!isset($va_media[$vn_id]) || !$va_media[$vn_id]) {
            continue;
        }
        $va_media_sorted[$vn_id] = $va_media[$vn_id];
    }
    return $va_media_sorted;
}