if ($this->getVar('previous_representation_id')) {
    print "<a href='#' onClick='jQuery(\"#{$vs_container_id}\").load(\"" . caNavUrl($this->request, '', 'simpleGallery/SetsOverlay', 'getSetsOverlay', array('representation_id' => (int) $this->getVar('previous_representation_id'), 'object_id' => (int) $this->getVar('previous_object_id'), 'set_id' => (int) $pn_set_id)) . "\");'>←</a>";
}
if (sizeof($va_reps) > 1) {
    print ' ' . _t("%1 of %2", $this->getVar('representation_index'), sizeof($va_reps)) . ' ';
}
if ($this->getVar('next_representation_id')) {
    print "<a href='#' onClick='jQuery(\"#{$vs_container_id}\").load(\"" . caNavUrl($this->request, '', 'simpleGallery/SetsOverlay', 'getSetsOverlay', array('representation_id' => (int) $this->getVar('next_representation_id'), 'object_id' => (int) $this->getVar('next_object_id'), 'set_id' => (int) $pn_set_id)) . "\");'>→</a>";
}
?>
		</div>
<?php 
# --- caption text
$va_object_title = $t_object->get('ca_objects.preferred_labels');
$t_set_item = new ca_set_items($pn_set_item_id);
if ($vs_set_caption = $t_set_item->getLabelForDisplay()) {
    print "<div class='simpleGalleryCaption'>";
    print $vs_set_caption;
    print "</div>";
}
print "<div class='simpleGallerySetItemDescription'>";
if ($t_set_item->get("ca_set_items.{$ps_set_description_code}")) {
    print $t_set_item->get("ca_set_items.{$ps_set_description_code}") . "<br/><br/>";
}
print "<b>" . _t('View this Object in the Collection') . ":</b> " . caNavLink($this->request, $va_object_title, '', 'Detail', 'Object', 'Show', array('object_id' => $pn_object_id));
print "</div>";
?>
			
	</div><!-- end caMediaOverlayControls -->

	<div id="caMediaOverlayContent">
Ejemplo n.º 2
0
 public function setItemInfo()
 {
     $va_access_values = caGetUserAccessValues($this->request);
     $pn_set_id = $this->request->getParameter('set_id', pInteger);
     $t_set = new ca_sets($pn_set_id);
     $this->view->setVar('set_id', $pn_set_id);
     $pn_set_item_id = $this->request->getParameter('set_item_id', pInteger);
     $t_set_item = new ca_set_items($pn_set_item_id);
     $va_set_item_info = array();
     $va_items = $t_set->getItemIDs(array("checkAccess" => $va_access_values));
     $pn_previous_id = "";
     foreach ($va_items as $vn_item_id => $va_item_info) {
         if ($va_set_item_info["item_id"]) {
             $va_set_item_info["next_id"] = $vn_item_id;
             break;
         }
         if ($pn_set_item_id == $vn_item_id) {
             $va_set_item_info["previous_id"] = $pn_previous_id;
             $va_set_item_info["item_id"] = $vn_item_id;
         }
         $pn_previous_id = $vn_item_id;
     }
     $va_set_item_info["item_id"] = $t_set_item->get("item_id");
     $va_reps = $t_set_item->getRepresentations(array("mediumlarge", "small"), null, array("return_with_access" => $va_access_values));
     $va_rep = array_shift($va_rep);
     $this->view->setVar('t_object_representation', $t_rep = new ca_object_representations($va_rep['representation_id']));
     $va_rep_display_info = caGetMediaDisplayInfo('cropped_gallery_media_overlay', $t_rep->getMediaInfo('media', 'INPUT', 'MIMETYPE'));
     $this->view->setVar('rep_display_version', $va_rep_display_info['display_version']);
     unset($va_display_info['display_version']);
     $va_rep_display_info['poster_frame_url'] = $t_rep->getMediaUrl('media', $va_rep_display_info['poster_frame_version']);
     unset($va_display_info['poster_frame_version']);
     $this->view->setVar('rep_display_options', $va_rep_display_info);
     $va_set_item_info["info"] = $va_rep['info'];
     $va_set_item_info["label"] = $t_set_item->getLabelForDisplay();
     $va_set_item_info["description"] = $t_set_item->get($this->opo_plugin_config->get('set_description_element_code'), array('convertLineBreaks' => true));
     $va_set_item_info["item_description"] = $t_set_item->get($this->opo_plugin_config->get('set_item_description_element_code'), array('convertLineBreaks' => true));
     $va_set_item_info["row_id"] = $t_set_item->get("row_id");
     $va_set_item_info["lesson"] = $t_set_item->get('set_item_description');
     $t_object = new ca_objects($t_set_item->get("row_id"));
     $va_set_item_info["object_label"] = $t_object->getLabelForDisplay();
     $this->view->setVar('item_info', $va_set_item_info);
     $this->render($this->ops_theme . '/ajax_item_info_html.php');
 }
Ejemplo n.º 3
0
 /**
  * Returns information on items in current set
  *
  * @param array $pa_options Optional array of options. Supported options are:
  *			user_id = user_id of the current user; used to determine what may be shown
  *			thumbnailVersions = A list of of a media versions to return with each item. Only used if the set content type is ca_objects.
  *			thumbnailVersion = Same as 'thumbnailVersions' except it is a single value. (Maintained for compatibility with older code.)
  *			limit = Limits the total number of records to be returned
  *			checkAccess = An array of row-level access values to check set members for, often produced by the caGetUserAccessValues() helper. Set members with access values not in the list will be omitted. If this option is not set or left null no access checking is done.
  *			returnRowIdsOnly = If true a simple array of row_ids (keys of the set members) for members of the set is returned rather than full item-level info for each set member. IDs are keys in the returned array.
  *			returnItemIdsOnly = If true a simple array of item_ids (keys for the ca_set_items rows themselves) is returned rather than full item-level info for each set member.
  *			returnItemAttributes = A list of attribute element codes for the ca_set_item record to return values for.
  *			idsOnly = Return a simple numerically indexed array of row_ids
  * 			template =
  *
  * @return array An array of items. The format varies depending upon the options set. If returnRowIdsOnly or returnItemIdsOnly are set then the returned array is a 
  *			simple list of ids. The full return array is key'ed on ca_set_items.item_id and then on locale_id. The values are arrays with keys set to a number of fields including:
  *			set_id, item_id, row_id, rank, label_id, locale_id, caption (from the ca_set_items label), all instrinsic field content from the row_id, the display label of the row
  *			as 'set_item_label'. 
  *			If 'thumbnailVersion' is set then additional keys will be available for the selected media version:
  *				representation_tag, representation_url, representation_width and representation_height (the HTML tag, URL, pixel width and pixel height of the representation respectively)
  *			If 'thumbnailVersions' is set then additional keys will be available for the selected media versions:
  *				representation_tag_<version_name>, representation_url_<version_name>, representation_width_<version_name> and representation_height_<version_name> (the HTML tag, URL, pixel width and pixel height of the representation respectively)
  *			If 'returnItemAttributes' is set then there will be an additional key for each element_code prefixed with 'ca_attribute_' to ensure it doesn't conflict with any other key in the array.		
  *			
  */
 public function getItems($pa_options = null)
 {
     if (!($vn_set_id = $this->getPrimaryKey())) {
         return null;
     }
     if (!is_array($pa_options)) {
         $pa_options = array();
     }
     if ($pa_options['user_id'] && !$this->haveAccessToSet($pa_options['user_id'], __CA_SET_READ_ACCESS__)) {
         return false;
     }
     $o_db = $this->getDb();
     $o_dm = $this->getAppDatamodel();
     $t_rel_label_table = null;
     if (!($t_rel_table = $o_dm->getInstanceByTableNum($this->get('table_num'), true))) {
         return null;
     }
     if (method_exists($t_rel_table, 'getLabelTableName')) {
         if ($vs_label_table_name = $t_rel_table->getLabelTableName()) {
             $t_rel_label_table = $o_dm->getInstanceByTableName($vs_label_table_name, true);
         }
     }
     $vs_label_join_sql = '';
     if ($t_rel_label_table) {
         if ($t_rel_label_table->hasField("is_preferred")) {
             $vs_preferred_sql = " AND rel_label.is_preferred = 1 ";
         }
         $vs_label_join_sql = "LEFT JOIN " . $t_rel_label_table->tableName() . " AS rel_label ON rel." . $t_rel_table->primaryKey() . " = rel_label." . $t_rel_table->primaryKey() . " {$vs_preferred_sql}\n";
     }
     $vs_limit_sql = '';
     if (isset($pa_options['limit']) && $pa_options['limit'] > 0) {
         $vs_limit_sql = "LIMIT " . $pa_options['limit'];
     }
     // get set items
     $vs_access_sql = '';
     if (isset($pa_options['checkAccess']) && is_array($pa_options['checkAccess']) && sizeof($pa_options['checkAccess']) && $t_rel_table->hasField('access')) {
         $vs_access_sql = ' AND rel.access IN (' . join(',', $pa_options['checkAccess']) . ')';
     }
     $vs_deleted_sql = '';
     if ($t_rel_table->hasField('deleted')) {
         $vs_deleted_sql = ' AND rel.deleted = 0';
     }
     $va_representation_counts = array();
     $vs_rep_join_sql = $vs_rep_where_sql = $vs_rep_select = '';
     if ($t_rel_table->tableName() === 'ca_objects' && (isset($pa_options['thumbnailVersion']) || isset($pa_options['thumbnailVersions']))) {
         $vs_rep_join_sql = "LEFT JOIN ca_objects_x_object_representations AS coxor ON rel.object_id = coxor.object_id\nLEFT JOIN ca_object_representations AS cor ON coxor.representation_id = cor.representation_id\n";
         $vs_rep_where_sql = " AND (coxor.is_primary = 1 OR coxor.is_primary IS NULL)";
         $vs_rep_select = ', coxor.*, cor.media, cor.access rep_access';
         // get representation counts
         $qr_rep_counts = $o_db->query("\n\t\t\t\tSELECT \n\t\t\t\t\trel.object_id, count(*) c\n\t\t\t\tFROM ca_set_items casi\n\t\t\t\tINNER JOIN ca_objects AS rel ON rel.object_id = casi.row_id\n\t\t\t\tINNER JOIN ca_objects_x_object_representations AS coxor ON coxor.object_id = rel.object_id\n\t\t\t\tWHERE\n\t\t\t\t\tcasi.set_id = ? {$vs_access_sql} {$vs_deleted_sql}\n\t\t\t\tGROUP BY\n\t\t\t\t\trel.object_id\n\t\t\t", (int) $vn_set_id);
         while ($qr_rep_counts->nextRow()) {
             $va_representation_counts[(int) $qr_rep_counts->get('object_id')] = (int) $qr_rep_counts->get('c');
         }
     }
     // get row labels
     $qr_res = $o_db->query("\n\t\t\tSELECT \n\t\t\t\tcasi.set_id, casi.item_id, casi.row_id, casi.rank,\n\t\t\t\trel_label." . $t_rel_label_table->getDisplayField() . ", rel_label.locale_id\n\t\t\tFROM ca_set_items casi\n\t\t\tINNER JOIN " . $t_rel_table->tableName() . " AS rel ON rel." . $t_rel_table->primaryKey() . " = casi.row_id\n\t\t\t{$vs_label_join_sql}\n\t\t\tWHERE\n\t\t\t\tcasi.set_id = ? {$vs_access_sql} {$vs_deleted_sql}\n\t\t\tORDER BY \n\t\t\t\tcasi.rank ASC\n\t\t\t{$vs_limit_sql}\n\t\t", (int) $vn_set_id);
     $va_labels = array();
     while ($qr_res->nextRow()) {
         $va_labels[$qr_res->get('item_id')][$qr_res->get('locale_id')] = $qr_res->getRow();
     }
     $va_labels = caExtractValuesByUserLocale($va_labels);
     // get set items
     $vs_access_sql = '';
     if (isset($pa_options['checkAccess']) && is_array($pa_options['checkAccess']) && sizeof($pa_options['checkAccess']) && $t_rel_table->hasField('access')) {
         $vs_access_sql = ' AND rel.access IN (' . join(',', $pa_options['checkAccess']) . ')';
     }
     // list items happen to have the same primary key name as set items, which leads to weird side-effects
     // in the code below. so instead of getting rel.* we explicitly list the fields for ca_list_items and
     // rename cli.item_id to list_item_id so that any get('item_id') calls below refer to the set item id
     if ($t_rel_table->tableName() === 'ca_list_items') {
         $va_rel_field_list = array();
         foreach ($t_rel_table->getFields() as $vs_rel_field) {
             if ($vs_rel_field == $t_rel_table->primaryKey()) {
                 $va_rel_field_list[] = "rel.{$vs_rel_field} as list_{$vs_rel_field}";
             } else {
                 $va_rel_field_list[] = "rel.{$vs_rel_field}";
             }
         }
         $vs_rel_field_list_sql = join(', ', $va_rel_field_list);
     } else {
         $vs_rel_field_list_sql = 'rel.*';
     }
     $qr_res = $o_db->query("\n\t\t\tSELECT \n\t\t\t\tcasi.set_id, casi.item_id, casi.row_id, casi.rank, casi.vars,\n\t\t\t\tcasil.label_id, casil.caption, casil.locale_id set_item_label_locale_id,\n\t\t\t\t{$vs_rel_field_list_sql}, rel_label." . $t_rel_label_table->getDisplayField() . " set_item_label, rel_label.locale_id rel_locale_id\n\t\t\t\t{$vs_rep_select}\n\t\t\tFROM ca_set_items casi\n\t\t\tLEFT JOIN ca_set_item_labels AS casil ON casi.item_id = casil.item_id\n\t\t\tINNER JOIN " . $t_rel_table->tableName() . " AS rel ON rel." . $t_rel_table->primaryKey() . " = casi.row_id\n\t\t\t{$vs_label_join_sql}\n\t\t\t{$vs_rep_join_sql}\n\t\t\tWHERE\n\t\t\t\tcasi.set_id = ? {$vs_rep_where_sql} {$vs_access_sql} {$vs_deleted_sql}\n\t\t\tORDER BY \n\t\t\t\tcasi.rank ASC\n\t\t\t{$vs_limit_sql}\n\t\t", (int) $vn_set_id);
     if ($ps_template = caGetOption('template', $pa_options, null)) {
         $qr_ids = $o_db->query("SELECT row_id FROM ca_set_items WHERE set_id = ? ORDER BY rank ASC", $this->getPrimaryKey());
         $va_processed_templates = caProcessTemplateForIDs($ps_template, $t_rel_table->tableName(), $qr_ids->getAllFieldValues('row_id'), array('returnAsArray' => true));
     }
     $va_items = array();
     while ($qr_res->nextRow()) {
         $va_row = $qr_res->getRow();
         unset($va_row['media']);
         if (isset($pa_options['returnRowIdsOnly']) && $pa_options['returnRowIdsOnly'] || isset($pa_options['idsOnly']) && $pa_options['idsOnly']) {
             $va_items[$qr_res->get('row_id')] = true;
             continue;
         }
         if (isset($pa_options['returnItemIdsOnly']) && $pa_options['returnItemIdsOnly']) {
             $va_items[$qr_res->get('item_id')] = true;
             continue;
         }
         $va_vars = caUnserializeForDatabase($va_row['vars']);
         $vb_has_access_to_media = true;
         if ($vs_rep_join_sql && isset($pa_options['checkAccess']) && is_array($pa_options['checkAccess']) && sizeof($pa_options['checkAccess'])) {
             $vb_has_access_to_media = in_array($va_row['rep_access'], $pa_options['checkAccess']);
         }
         if ($vs_rep_join_sql && $vb_has_access_to_media) {
             if (isset($pa_options['thumbnailVersion'])) {
                 $va_row['representation_tag'] = $qr_res->getMediaTag('media', $pa_options['thumbnailVersion']);
                 $va_row['representation_url'] = $qr_res->getMediaUrl('media', $pa_options['thumbnailVersion']);
                 $va_row['representation_width'] = $qr_res->getMediaInfo('media', $pa_options['thumbnailVersion'], 'WIDTH');
                 $va_row['representation_height'] = $qr_res->getMediaInfo('media', $pa_options['thumbnailVersion'], 'HEIGHT');
             }
             if (isset($pa_options['thumbnailVersions']) && is_array($pa_options['thumbnailVersions'])) {
                 foreach ($pa_options['thumbnailVersions'] as $vs_version) {
                     $va_row['representation_tag_' . $vs_version] = $qr_res->getMediaTag('media', $vs_version);
                     $va_row['representation_url_' . $vs_version] = $qr_res->getMediaUrl('media', $vs_version);
                     $va_row['representation_width_' . $vs_version] = $qr_res->getMediaInfo('media', $vs_version, 'WIDTH');
                     $va_row['representation_height_' . $vs_version] = $qr_res->getMediaInfo('media', $vs_version, 'HEIGHT');
                 }
             }
         }
         if ($t_rel_table->tableName() === 'ca_objects') {
             if (isset($va_vars['selected_services'])) {
                 $va_row['selected_services'] = array_keys($va_vars['selected_services']);
             } else {
                 $va_row['selected_services'] = array();
             }
             if (isset($va_vars['selected_representations'])) {
                 $va_row['selected_representations'] = array_keys($va_vars['selected_representations']);
             } else {
                 $va_row['selected_representations'] = array();
             }
             $va_row['representation_count'] = (int) $va_representation_counts[$qr_res->get('row_id')];
         }
         if (is_array($va_labels[$vn_item_id = $qr_res->get('item_id')])) {
             $va_row = array_merge($va_row, $va_labels[$vn_item_id]);
         }
         if (isset($pa_options['returnItemAttributes']) && is_array($pa_options['returnItemAttributes']) && sizeof($pa_options['returnItemAttributes'])) {
             // TODO: doing a load for each item is inefficient... must replace with a query
             $t_item = new ca_set_items($va_row['item_id']);
             foreach ($pa_options['returnItemAttributes'] as $vs_element_code) {
                 $va_row['ca_attribute_' . $vs_element_code] = $t_item->getAttributesForDisplay($vs_element_code);
             }
             $va_row['set_item_label'] = $t_item->getLabelForDisplay(false);
         }
         if ($ps_template) {
             $va_row['displayTemplate'] = array_shift($va_processed_templates);
         }
         $va_items[$qr_res->get('item_id')][$qr_res->get('rel_locale_id') ? $qr_res->get('rel_locale_id') : 0] = $va_row;
     }
     if (caGetOption('idsOnly', $pa_options, false)) {
         return array_keys($va_items);
     }
     return $va_items;
 }
Ejemplo n.º 4
0
 public function setItemInfo()
 {
     $va_access_values = caGetUserAccessValues($this->request);
     $pn_set_id = $this->request->getParameter('set_id', pInteger);
     $t_set = new ca_sets($pn_set_id);
     $this->view->setVar('set_id', $pn_set_id);
     $pn_set_item_id = $this->request->getParameter('set_item_id', pInteger);
     $t_set_item = new ca_set_items($pn_set_item_id);
     $va_set_item_info = array();
     $va_items = $t_set->getItemIDs(array("checkAccess" => $va_access_values));
     $pn_previous_id = "";
     foreach ($va_items as $vn_item_id => $va_item_info) {
         if ($va_set_item_info["item_id"]) {
             $va_set_item_info["next_id"] = $vn_item_id;
             break;
         }
         if ($pn_set_item_id == $vn_item_id) {
             $va_set_item_info["previous_id"] = $pn_previous_id;
             $va_set_item_info["item_id"] = $vn_item_id;
         }
         $pn_previous_id = $vn_item_id;
     }
     $va_set_item_info["item_id"] = $t_set_item->get("item_id");
     $va_set_item_info["info"] = $va_rep[0]['info'];
     $va_set_item_info["label"] = $t_set_item->getLabelForDisplay();
     $va_set_item_info["description"] = $t_set_item->get($this->opo_plugin_config->get('set_description_element_code'), array('convertLineBreaks' => true));
     $va_set_item_info["row_id"] = $t_set_item->get("row_id");
     $t_occurrence = new ca_occurrences($t_set_item->get("row_id"));
     $va_set_item_info["label"] = $t_occurrence->getLabelForDisplay();
     $va_mediumlarge_stills = $t_occurrence->get('ca_occurrences.ic_stills.ic_stills_media', array('version' => "mediumlarge", "showMediaInfo" => false, "returnAsArray" => true));
     if (sizeof($va_mediumlarge_stills) > 0) {
         $va_set_item_info["media_still"] = array_shift($va_mediumlarge_stills);
         $va_image_caption = $t_occurrence->get('ca_occurrences.ic_stills.ic_stills_credit', array("returnAsArray" => true));
         $vs_image_caption = array_shift($va_image_caption);
         if ($vs_image_caption) {
             $va_set_item_info["media_still_caption"] = $vs_image_caption;
         }
     }
     if ($vs_video = $t_occurrence->get('ca_occurrences.ic_moving_images.ic_moving_images_media', array('version' => 'original', 'showMediaInfo' => false, 'viewer_width' => 580, 'viewer_height' => 450, 'poster_frame_version' => 'mediumlarge'))) {
         $va_set_item_info["media_video"] = $vs_video;
         if ($vs_video_caption = $t_occurrence->get('ca_occurrences.ic_moving_images.ic_moving_images_credit')) {
             $va_set_item_info["media_video_caption"] = $vs_video_caption;
         }
     }
     $this->view->setVar('item_info', $va_set_item_info);
     $this->render('Exhibits/ajax_item_info_html.php');
 }
            }
        }
        ?>
		</div><!-- end caMediaOverlayRepThumbs -->
<?php 
    }
    ?>
	<!-- Controls - ONLY for media overlay -->
	<div class="caMediaOverlayControls">
			<div class='close'><a href="#" onclick="caMediaPanel.hidePanel(); return false;" title="close">&nbsp;&nbsp;&nbsp;</a></div>
			<div >
<?php 
    # --- caption text - Noguchi NCR specific!
    $t_set_item = new ca_set_items($pn_set_item_id);
    $va_object_title = $t_object->get('ca_objects.preferred_labels');
    print "<div class='captionLeft' >" . $t_set_item->getLabelForDisplay() . "</div>";
    print "<div class='captionRight' >" . $t_set_item->get("ca_set_items.set_item_description") . "</div>";
    print "<div class='recordLink'>" . _t('View this Object in the Collection') . ": " . caNavLink($this->request, $va_object_title, '', 'Detail', 'Object', 'Show', array('object_id' => $pn_object_id)) . "</div>";
    ?>
			
			</div>

			<div class='repNav'>
<?php 
    if ($this->getVar('previous_representation_id')) {
        print "<a href='#' onClick='jQuery(\"#{$vs_container_id}\").load(\"" . caNavUrl($this->request, '', 'educational/SetsOverlay', 'getSetsOverlay', array('representation_id' => (int) $this->getVar('previous_representation_id'), 'object_id' => (int) $this->getVar('previous_object_id'), 'set_id' => (int) $pn_set_id)) . "\");'>←</a>";
    }
    if (sizeof($va_reps) > 1) {
        print ' ' . _t("%1 of %2", $this->getVar('representation_index'), sizeof($va_reps)) . ' ';
    }
    if ($this->getVar('next_representation_id')) {