public function Info($pa_parameters) { parent::info($pa_parameters); $vn_item_id = isset($pa_parameters['item_id']) ? $pa_parameters['item_id'] : null; $t_set_item = new ca_set_items($vn_item_id); $this->view->setVar('t_set', $t_set = new ca_sets($t_set_item->get('set_id'))); if ($t_set_item->getPrimaryKey()) { $t_row_instance = $this->opo_datamodel->getInstanceByTableNum($t_set->get('table_num'), true); $t_row_instance->load($t_set_item->get('row_id')); $this->view->setVar('t_row_instance', $t_row_instance); } return $this->render('widget_set_item_info_html.php', true); }
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"> <?php // return standard tag if (!is_array($va_display_options)) { $va_display_options = array(); } $vs_tag = $t_rep->getMediaTag('media', $vs_show_version, array_merge($va_display_options, array('id' => 'caMediaOverlayContentMedia', 'viewer_base_url' => $this->request->getBaseUrlPath())));
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'); }
public function getSetItemInfo() { $pn_item_id = $this->request->getParameter('item_id', pInteger); $pn_set_id = $this->request->getParameter('set_id', pInteger); $t_set = new ca_sets($pn_set_id); $t_set_item = new ca_set_items($pn_item_id); $t_object = new ca_objects($t_set_item->get("row_id")); $va_set_item_ids = array_keys($t_set->getItemIDs(array("checkAccess" => $this->opa_access_values))); $this->view->setVar("set_num_items", sizeof($va_set_item_ids)); $this->view->setVar("set_item_num", array_search($pn_item_id, $va_set_item_ids) + 1); $this->view->setVar("object", $t_object); $this->view->setVar("object_id", $t_set_item->get("row_id")); $this->view->setVar("label", $t_object->getLabelForDisplay()); // // Tag substitution // // Views can contain tags in the form {{{tagname}}}. Some tags, such as "label" are defined by // this controller. More usefully, you can pull data from the item being detailed by using a valid "get" expression // as a tag (Eg. {{{ca_objects.idno}}}. Even more usefully for some, you can also use a valid bundle display template // (see http://docs.collectiveaccess.org/wiki/Bundle_Display_Templates) as a tag. The template will be evaluated in the // context of the item being detailed. // $va_defined_vars = array_keys($this->view->getAllVars()); // get list defined vars (we don't want to copy over them) $va_tag_list = $this->getTagListForView("Gallery/set_item_info_html.php"); // get list of tags in view foreach ($va_tag_list as $vs_tag) { if (in_array($vs_tag, $va_defined_vars)) { continue; } if (strpos($vs_tag, "^") !== false || strpos($vs_tag, "<") !== false) { $this->view->setVar($vs_tag, $t_object->getWithTemplate($vs_tag, array('checkAccess' => $this->opa_access_values))); } elseif (strpos($vs_tag, ".") !== false) { $this->view->setVar($vs_tag, $t_object->get($vs_tag, array('checkAccess' => $this->opa_access_values))); } else { $this->view->setVar($vs_tag, "?{$vs_tag}"); } } $this->render("Gallery/set_item_info_html.php"); }
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'); }
$t_set = $this->getVar("set"); $vb_write_access = $this->getVar("write_access"); $va_lightbox_display_name = caGetSetDisplayName(); $vs_lightbox_display_name = $va_lightbox_display_name["singular"]; $vs_lightbox_display_name_plural = $va_lightbox_display_name["plural"]; $vn_object_table_num = $this->request->datamodel->getTableNum("ca_objects"); $vn_hits_per_block = (int) $this->getVar('hits_per_block'); // number of hits to display per block ?> <div class="row" id="sortable"> <?php if ($q_set_items->numHits()) { $vn_c = 0; while ($q_set_items->nextHit() && $vn_c < $vn_hits_per_block) { $t_set_item = new ca_set_items(array("row_id" => $q_set_items->get("object_id"), "set_id" => $t_set->get("set_id"), "table_num" => $vn_object_table_num)); if ($t_set_item->get("item_id")) { print "<div class='col-xs-6 col-sm-4 col-md-3 col-lg-3 lbItem" . $t_set_item->get("item_id") . "' id='row-" . $q_set_items->get("object_id") . "'><div class='lbItemContainer'>"; print caLightboxSetDetailItem($this->request, $q_set_items, $t_set_item, array("write_access" => $vb_write_access)); print "</div></div><!-- end col 3 -->"; $vn_c++; } } } else { print "<div class='col-sm-12'>" . _t("There are no items in this %1", $vs_lightbox_display_name) . "</div>"; } ?> </div><!-- end row --> <?php if ($vb_write_access) { ?> <script type='text/javascript'>
/** * Sets order of items in the currently loaded set to the order of row_ids as set in $pa_row_ids * * @param array $pa_row_ids A list of row_ids in the set, in the order in which they should be displayed in the set * @param array $pa_options An optional array of options. Supported options include: * user_id = the user_id of the current user; used to determine which sets the user has access to * treatRowIDsAsRIDs = assume combination row_id/item_id indices in $pa_row_ids array instead of solely row_ids. Since a set can potentially contain multiple instances of the same row_id, only "rIDs" – a combination of the row_id and the set item_id (row_id + "_" + item_id) – are guaranteed to be unique. [Default=false] * deleteExcludedItems = should the set items not passed in pa_row_ids be deleted? default is false * @return array An array of errors. If the array is empty then no errors occurred */ public function reorderItems($pa_row_ids, $pa_options = null) { if (!($vn_set_id = $this->getPrimaryKey())) { return null; } $vn_user_id = isset($pa_options['user_id']) ? (int) $pa_options['user_id'] : null; $vb_treat_row_ids_as_rids = caGetOption('treatRowIDsAsRIDs', $pa_options, false); $vb_delete_excluded_items = caGetOption('deleteExcludedItems', $pa_options, false); // does user have edit access to set? if ($vn_user_id && !$this->haveAccessToSet($vn_user_id, __CA_SET_EDIT_ACCESS__)) { return false; } $va_row_ranks = $this->getRowIDRanks($pa_options); // get current ranks $vn_i = 0; $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_set_item = new ca_set_items(); $t_set_item->setTransaction($o_trans); $t_set_item->setMode(ACCESS_WRITE); $va_errors = array(); // delete rows not present in $pa_row_ids $va_excluded_item_ids = array(); foreach ($va_row_ranks as $vn_row_id => $va_rank) { if (!in_array($vn_row_id, $pa_row_ids)) { if ($vb_treat_row_ids_as_rids) { $va_tmp = explode("_", $vn_row_id); if ($t_set_item->load(array('set_id' => $vn_set_id, 'row_id' => $va_tmp[0], 'item_id' => $va_tmp[1]))) { $va_excluded_item_ids[$t_set_item->get("rank")] = $t_set_item->get("item_id"); if ($vb_delete_excluded_items) { $t_set_item->delete(true); } } } else { if ($t_set_item->load(array('set_id' => $vn_set_id, 'row_id' => $vn_row_id))) { $va_excluded_item_ids[$t_set_item->get("rank")] = $t_set_item->get("item_id"); if ($vb_delete_excluded_items) { $t_set_item->delete(true); } } } if (($vn_k = array_search($pa_row_ids, $pa_row_ids)) !== false) { unset($pa_row_ids[$vn_k]); } unset($va_row_ranks[$vn_row_id]); } } // rewrite ranks $va_existing_ranks = array_values($va_row_ranks); $vn_rank_acc = end(array_values($va_row_ranks)); $va_rank_updates = array(); foreach ($pa_row_ids as $vn_rank => $vn_row_id) { if (isset($va_existing_ranks[$vn_rank])) { $vn_rank_inc = $va_existing_ranks[$vn_rank]; } else { $vn_rank_acc++; $vn_rank_inc = $vn_rank_acc; } if ($vb_treat_row_ids_as_rids) { $va_tmp = explode("_", $vn_row_id); } if (isset($va_row_ranks[$vn_row_id]) && $va_row_ranks[$vn_row_id] != $vn_rank_inc) { $va_rank_updates[$vn_row_id] = $vn_rank_inc; } elseif (!isset($va_row_ranks[$vn_row_id])) { // add item to set $this->addItem($vb_treat_row_ids_as_rids ? $va_tmp[0] : $vn_row_id, null, $vn_user_id, $vn_rank_inc); } } foreach ($va_rank_updates as $vn_row_id => $vn_new_rank) { if ($vb_treat_row_ids_as_rids) { $va_tmp = explode("_", $vn_row_id); $this->getDb()->query("UPDATE ca_set_items SET rank = ? WHERE set_id = ? AND row_id = ? AND item_id = ?", $x = array($vn_new_rank, $vn_set_id, $va_tmp[0], $va_tmp[1])); } else { $this->getDb()->query("UPDATE ca_set_items SET rank = ? WHERE set_id = ? AND row_id = ?", array($vn_set_id, $vn_new_rank)); } } if (sizeof($va_errors)) { if ($vb_web_set_transaction) { $o_trans->rollback(); } } else { if ($vb_web_set_transaction) { $o_trans->commit(); } } return $va_errors; }
/** * */ public function GetSelectedRepresentationCount() { $pn_item_id = $this->request->getParameter('item_id', pInteger); $t_set_item = new ca_set_items($pn_item_id); $t_set = new ca_sets($t_set_item->get('set_id')); if (!$t_set->getPrimaryKey() || !$t_set->haveAccessToSet($this->request->getUserID(), __CA_SET_EDIT_ACCESS__)) { // TODO: proper error reporting or redirect? return; } $vn_num_reps_selected = $t_set_item->getSelectedRepresentationCount(); $vn_num_reps = $t_set_item->getRepresentationCount(); $vs_msg = $vn_num_reps == 1 ? _t("%1/%2 page selected", $vn_num_reps_selected, $vn_num_reps) : _t("%1/%2 pages selected", $vn_num_reps_selected, $vn_num_reps); $this->response->addContent($vs_msg); }
public function RecordRepresentationSelection() { $pn_item_id = $this->request->getParameter('item_id', pInteger); $pn_representation_id = $this->request->getParameter('representation_id', pInteger); $pn_selected = $this->request->getParameter('selected', pInteger); $va_errors = array(); $t_set_item = new ca_set_items($pn_item_id); $t_set = new ca_sets($t_set_item->get('set_id')); if (!$t_set->getPrimaryKey() || !$t_set->haveAccessToSet($this->request->getUserID(), __CA_SET_EDIT_ACCESS__)) { // TODO: proper error reporting or redirect? return; } if (!$t_set_item->getPrimaryKey()) { $va_errors[] = _t("Invalid set item"); } if (!sizeof($va_errors)) { $t_set = new ca_sets($t_set_item->get('set_id')); if (!$t_set->getPrimaryKey()) { $va_errors[] = _t("Invalid set"); } if (!$t_set->haveAccessToSet($this->request->getUserID(), __CA_SET_EDIT_ACCESS__)) { $va_errors[] = _t("You do not have access to this set"); } if (!sizeof($va_errors)) { if ((bool) $pn_selected) { $t_set_item->addSelectedRepresentation($pn_representation_id); } else { $t_set_item->removeSelectedRepresentation($pn_representation_id); } $t_set_item->update(); $va_errors = $t_set_item->getErrors(); } } $this->view->setVar("errors", $va_errors); $this->view->setVar('representation_id', $pn_representation_id); $this->view->setVar('item_id', $pn_item_id); $this->render("ajax_select_representation_json.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"> </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')) { print "<a href='#' onClick='jQuery(\"#{$vs_container_id}\").load(\"" . caNavUrl($this->request, '', 'educational/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>";
$t_set = $this->getVar("set"); $vb_write_access = $this->getVar("write_access"); $va_lightbox_display_name = caGetSetDisplayName(); $vs_lightbox_display_name = $va_lightbox_display_name["singular"]; $vs_lightbox_display_name_plural = $va_lightbox_display_name["plural"]; $vn_object_table_num = $this->request->datamodel->getTableNum("ca_objects"); $vn_hits_per_block = (int) $this->getVar('hits_per_block'); // number of hits to display per block ?> <div class="row" id="sortable"> <?php if ($q_set_items->numHits()) { $vn_c = 0; while ($q_set_items->nextHit() && $vn_c < $vn_hits_per_block) { $t_set_item = new ca_set_items(array("row_id" => $q_set_items->get("object_id"), "set_id" => $t_set->get("set_id"), "table_num" => $vn_object_table_num)); if ($t_set_item->get("item_id")) { $vs_rep = $vs_caption = $vs_label_artist = $vs_label_detail_link = $vs_idno_detail_link = $vs_art_idno_link = $vs_library_info = ""; $vn_id = $q_set_items->get("ca_objects.object_id"); if ($q_set_items->get('ca_objects.type_id') == 30) { # --- library - book $vs_label_author = "<p class='artist'>" . caNavLink($this->request, $q_set_items->get("ca_entities.preferred_labels.name", array('restrictToRelationshipTypes' => 'author', 'delimiter' => '; ', 'template' => '^ca_entities.preferred_labels.forename ^ca_entities.preferred_labels.middlename ^ca_entities.preferred_labels.surname')), '', '', 'Detail', 'library/' . $vn_id) . "</p>"; $vs_label_detail = "<p style='text-decoration:underline;'>" . caNavLink($this->request, $q_set_items->get("ca_objects.preferred_labels.name"), '', '', 'Detail', 'library/' . $vn_id) . "</p>"; $vs_label_pub = "<p>" . $q_set_items->get("ca_objects.publication_description") . "</p>"; $vs_label_call = "<p>" . $q_set_items->get("ca_objects.call_number") . "</p>"; $vs_label_status = "<p>" . $q_set_items->get("ca_objects.purchase_status") . "</p>"; $vs_idno_detail_link = ""; $vs_library_info = $vs_label_detail . $vs_label_author . $vs_label_pub . $vs_label_call . $vs_label_status; } elseif ($q_set_items->get('ca_objects.type_id') == 1903) { # --- library - copy $vs_label_author = "<p class='artist'>" . caNavLink($this->request, $q_set_items->get("ca_entities.parent.preferred_labels.name", array('restrictToRelationshipTypes' => 'author', 'delimiter' => '; ', 'template' => '^ca_entities.parent.preferred_labels.forename ^ca_entities.parent.preferred_labels.middlename ^ca_entities.parent.preferred_labels.surname')), '', '', 'Detail', 'library/' . $q_set_items->get('ca_objects.parent_id')) . "</p>"; $vs_label_detail = "<p style='text-decoration:underline;'>" . caNavLink($this->request, $q_set_items->get("ca_objects.parent.preferred_labels.name"), '', '', 'Detail', 'library/' . $q_set_items->get('ca_objects.parent_id')) . "</p>";
$va_library_media = $t_object->getPrimaryMediaForIDs($va_library_item_ids, array("small"), array('checkAccess' => caGetUserAccessValues($this->request))); } } if ($vs_archive_set_code = $this->request->config->get("featured_archive_set")) { $t_archive_set = new ca_sets(); $t_archive_set->load(array('set_code' => $vs_archive_set_code)); # Enforce access control on set if (sizeof($va_access_values) == 0 || sizeof($va_access_values) && in_array($t_archive_set->get("access"), $va_access_values)) { $va_archive_item_ids = array_keys(is_array($va_tmp = $t_archive_set->getItemRowIDs(array('checkAccess' => $va_access_values, 'shuffle' => 0))) ? $va_tmp : array()); $va_archive_items = $t_archive_set->getItemIDs(); foreach ($va_archive_items as $va_archive_item => $va_archive) { $va_archive_set_item = $va_archive_item; break; } $t_archive_item = new ca_set_items($va_archive_set_item); $va_archive_caption = $t_archive_item->get('ca_set_items.caption'); } if (is_array($va_archive_item_ids) && sizeof($va_archive_item_ids)) { $t_object = new ca_objects(); $va_archive_media = $t_object->getPrimaryMediaForIDs($va_archive_item_ids, array("small"), array('checkAccess' => caGetUserAccessValues($this->request))); } } if ($this->request->config->get('pawtucket_requires_login') && !$this->request->isLoggedIn()) { print "<div id='homepageLogin'>"; print $this->render('LoginReg/form_login_html.php'); print "</div>"; } else { ?> <div class='row featuredItems'> <div class="col-sm-4"> <div class='item first' >
/** * Sets order of items in the currently loaded set to the order of row_ids as set in $pa_row_ids * * @param array $pa_row_ids A list of row_ids in the set, in the order in which they should be displayed in the set * @param array $pa_options An optional array of options. Supported options include: * user_id = the user_id of the current user; used to determine which sets the user has access to * treatRowIDsAsRIDs = assume combination row_id/item_id indices in $pa_row_ids array instead of solely row_ids. Since a set can potentially contain multiple instances of the same row_id, only "rIDs" – a combination of the row_id and the set item_id (row_id + "_" + item_id) – are guaranteed to be unique. [Default=false] * deleteExludedItems = should the set items not passed in pa_row_ids be deleted? default is false * @return array An array of errors. If the array is empty then no errors occurred */ public function reorderItems($pa_row_ids, $pa_options = null) { if (!($vn_set_id = $this->getPrimaryKey())) { return null; } $vn_user_id = isset($pa_options['user_id']) ? (int) $pa_options['user_id'] : null; $vb_treat_row_ids_as_rids = caGetOption('treatRowIDsAsRIDs', $pa_options, false); $vb_delete_excluded_items = caGetOption('deleteExludedItems', $pa_options, false); // does user have edit access to set? if ($vn_user_id && !$this->haveAccessToSet($vn_user_id, __CA_SET_EDIT_ACCESS__)) { return false; } $va_row_ranks = $this->getRowIDRanks($pa_options); // get current ranks $vn_i = 0; $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_set_item = new ca_set_items(); $t_set_item->setTransaction($o_trans); $t_set_item->setMode(ACCESS_WRITE); $va_errors = array(); // delete rows not present in $pa_row_ids $va_excluded_item_ids = array(); foreach ($va_row_ranks as $vn_row_id => $va_rank) { if (!in_array($vn_row_id, $pa_row_ids)) { if ($vb_treat_row_ids_as_rids) { $va_tmp = explode("_", $vn_row_id); if ($t_set_item->load(array('set_id' => $vn_set_id, 'row_id' => $va_tmp[0], 'item_id' => $va_tmp[1]))) { $va_excluded_item_ids[$t_set_item->get("rank")] = $t_set_item->get("item_id"); if ($vb_delete_excluded_items) { $t_set_item->delete(true); } } } else { if ($t_set_item->load(array('set_id' => $vn_set_id, 'row_id' => $vn_row_id))) { $va_excluded_item_ids[$t_set_item->get("rank")] = $t_set_item->get("item_id"); if ($vb_delete_excluded_items) { $t_set_item->delete(true); } } } } } // rewrite ranks foreach ($pa_row_ids as $vn_rank => $vn_row_id) { $vn_rank_inc = $vn_rank + 1; if ($vb_treat_row_ids_as_rids) { $va_tmp = explode("_", $vn_row_id); } if (isset($va_row_ranks[$vn_row_id]) && $t_set_item->load($vb_treat_row_ids_as_rids ? array('set_id' => $vn_set_id, 'row_id' => $va_tmp[0], 'item_id' => $va_tmp[1]) : array('set_id' => $vn_set_id, 'row_id' => $vn_row_id))) { if ($va_row_ranks[$vn_row_id] != $vn_rank_inc) { $t_set_item->set('rank', $vn_rank_inc); $t_set_item->update(); if ($t_set_item->numErrors()) { $va_errors[$vn_row_id] = _t('Could not reorder item %1: %2', $vn_row_id, join('; ', $t_set_item->getErrors())); } } } else { // add item to set $this->addItem($vb_treat_row_ids_as_rids ? $va_tmp[0] : $vn_row_id, null, $vn_user_id, $vn_rank_inc); } } if (!$vb_delete_excluded_items) { # --- don't delete items whose id's where not passed to this function, foreach ($va_excluded_item_ids as $vn_item_id) { $vn_rank_inc++; $t_set_item->load($vn_item_id); $t_set_item->set('rank', $vn_rank_inc); $t_set_item->update(); if ($t_set_item->numErrors()) { $va_errors[$vn_row_id] = _t('Could not reorder item %1: %2', $vn_row_id, join('; ', $t_set_item->getErrors())); } } } if (sizeof($va_errors)) { if ($vb_web_set_transaction) { $o_trans->rollback(); } } else { if ($vb_web_set_transaction) { $o_trans->commit(); } } return $va_errors; }
/** * Returns the info for each set item * * options: "write_access" = false * */ function caLightboxSetDetailItemOld($po_request, $va_set_item = array(), $pa_options = array()) { $t_set_item = new ca_set_items($va_set_item["item_id"]); if (!$t_set_item->get("item_id")) { return false; } $vb_write_access = false; if ($pa_options["write_access"]) { $vb_write_access = true; } $t_list_items = new ca_list_items($va_set_item["type_id"]); $vs_placeholder = getPlaceholder($t_list_items->get("idno"), "placeholder_media_icon"); $vs_caption = ""; $o_config = caGetSetsConfig(); $vs_caption_template = $o_config->get("caption_template"); if ($vs_caption_template) { $t_object = new ca_objects($va_set_item["row_id"]); $vs_caption = $t_object->getWithTemplate($vs_caption_template); } else { $vs_caption = $va_set_item["set_item_label"]; } $vs_set_item_display = ""; $vs_set_item_display .= "<div class='lbItem'><div class='lbItemContent'>\n"; #$vs_set_item_display .= "<div class='lbItem' onmouseover='jQuery(\"#lbExpandedInfo".$t_set_item->get("item_id")."\").show();' onmouseout='jQuery(\"#lbExpandedInfo".$t_set_item->get("item_id")."\").hide();'><div class='lbItemContent'>\n"; if ($va_set_item["representation_tag_medium"]) { $vs_set_item_display .= caDetailLink($po_request, "<div class='lbItemImg'>" . $va_set_item["representation_tag_medium"] . "</div>", '', 'ca_objects', $va_set_item["row_id"]); } else { $vs_set_item_display .= caDetailLink($po_request, "<div class='lbItemImg lbSetImgPlaceholder'>" . $vs_placeholder . "</div>", '', 'ca_objects', $va_set_item["row_id"]); } $vs_set_item_display .= "<div id='comment" . $t_set_item->get("item_id") . "' class='lbSetItemComment'><!-- load comments here --></div>\n"; $vs_set_item_display .= "<div class='caption'>" . $vs_caption . "</div>\n"; $vs_set_item_display .= "</div><!-- end lbItemContent -->\n"; $vs_set_item_display .= "<div class='lbExpandedInfo' id='lbExpandedInfo" . $t_set_item->get("item_id") . "'>\n<hr>\n"; if ($vb_write_access) { $vs_set_item_display .= "<div class='pull-right'><a href='#' class='lbItemDeleteButton' id='lbItemDelete" . $t_set_item->get("item_id") . "' title='" . _t("Remove") . "'><span class='glyphicon glyphicon-trash'></span></a></div>\n"; } $vs_set_item_display .= "<div>" . caDetailLink($po_request, "<span class='glyphicon glyphicon-file'></span>", '', 'ca_objects', $va_set_item["row_id"], "", array("title" => _t("View Item Detail"))) . "\n"; if ($va_set_item["representation_id"]) { $vs_set_item_display .= " <a href='#' title='" . _t("Enlarge Image") . "' onclick='caMediaPanel.showPanel(\"" . caNavUrl($po_request, '', 'Detail', 'GetRepresentationInfo', array('object_id' => $t_set_item->get("row_id"), 'representation_id' => $va_set_item["representation_id"], 'overlay' => 1)) . "\"); return false;' ><span class='glyphicon glyphicon-zoom-in'></span></a>\n"; } $vs_set_item_display .= " <a href='#' title='" . _t("Comments") . "' onclick='jQuery(\"#comment" . $t_set_item->get("item_id") . "\").load(\"" . caNavUrl($po_request, '', 'Sets', 'AjaxListComments', array('item_id' => $t_set_item->get("item_id"), 'tablename' => 'ca_set_items', 'set_id' => $t_set_item->get("set_id"))) . "\", function(){jQuery(\"#comment" . $t_set_item->get("item_id") . "\").show();}); return false;'><span class='glyphicon glyphicon-comment'></span> <small>" . $t_set_item->getNumComments() . "</small></a></div>\n"; $vs_set_item_display .= "</div><!-- end lbExpandedInfo --></div><!-- end lbItem -->\n"; return $vs_set_item_display; }
} ?> <!-- Controls - ONLY for media overlay --> <div class="caMediaOverlayControls"> <div class='close'><a href="#" onclick="caMediaPanel.hidePanel(); return false;" title="close"> </a></div> <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); print "<div class='captionLeft' >"; if ($va_set_caption = $t_set_item->getLabelForDisplay()) { print $va_set_caption; } print "</div>"; print "<div class='captionRight' >" . $t_set_item->get("ca_set_items.{$va_set_description_code}") . "</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, '', '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>";