public function Index() { $va_participate_ids = array(); $t_participate = new ca_sets(); # --- participate set - set name assigned in eastend.conf - plugin conf file $t_participate->load(array('set_code' => $this->opo_plugin_config->get('participate_set_name'))); # Enforce access control on set if (sizeof($this->opa_access_values) == 0 || sizeof($this->opa_access_values) && in_array($t_participate->get("access"), $this->opa_access_values)) { $this->view->setVar('participate_set_id', $t_participate->get("set_id")); $va_participate_ids = array_keys(is_array($va_tmp = $t_participate->getItemRowIDs(array('checkAccess' => $this->opa_access_values, 'shuffle' => 1))) ? $va_tmp : array()); // These are the entity ids in the set } # --- loop through featured ids and grab the object's image $t_object = new ca_objects(); $va_participate_images = array(); foreach ($va_participate_ids as $vn_participate_object_id) { $va_tmp = array(); $t_object->load($vn_participate_object_id); $va_tmp["object_id"] = $vn_participate_object_id; $va_image = $t_object->getPrimaryRepresentation(array("mediumlarge")); # --- don't show records with status ars/vaga don't show image if ($t_object->get("ca_objects.object_status") != 348) { if ($t_object->get("ca_objects.object_status") == 349) { $va_tmp["vaga_class"] = "vagaDisclaimer"; } $va_tmp["image"] = $va_image["tags"]["mediumlarge"]; $va_tmp["caption"] = $t_object->get("ca_objects.caption"); $va_tmp["title"] = $t_object->getLabelForDisplay(); } $va_participate_images[$vn_participate_object_id] = $va_tmp; } $this->view->setVar("participate_images", $va_participate_images); $this->render('participate_html.php'); }
public function testTest() { // establish everything went ok $this->assertEquals('TEST', $this->opt_set->get('set_code')); // should return primary label $this->assertEquals('Homer J. Simpson', $this->opt_set->get('ca_sets.entity_reference')); $this->assertEquals('Homer J. Simpson', $this->opt_set->getWithTemplate('^ca_sets.entity_reference')); }
/** * */ public function __call($ps_function, $pa_args) { AssetLoadManager::register("carousel"); $va_access_values = caGetUserAccessValues($this->request); $this->view->setVar('access_values', $va_access_values); # # --- if there is a set configured to show on the front page, load it now # $va_featured_ids = array(); if ($vs_set_code = $this->config->get("front_page_set_code")) { $t_set = new ca_sets(); $t_set->load(array('set_code' => $vs_set_code)); # Enforce access control on set if (sizeof($va_access_values) == 0 || sizeof($va_access_values) && in_array($t_set->get("access"), $va_access_values)) { $this->view->setVar('featured_set_id', $t_set->get("set_id")); $this->view->setVar('featured_set', $t_set); $va_featured_ids = array_keys(is_array($va_tmp = $t_set->getItemRowIDs(array('checkAccess' => $va_access_values, 'shuffle' => 1))) ? $va_tmp : array()); $this->view->setVar('featured_set_item_ids', $va_featured_ids); $this->view->setVar('featured_set_items_as_search_result', caMakeSearchResult('ca_objects', $va_featured_ids)); } } # # --- no configured set/items in set so grab random objects with media # if (sizeof($va_featured_ids) == 0) { $t_object = new ca_objects(); $va_featured_ids = array_keys($t_object->getRandomItems(10, array('checkAccess' => $va_access_values, 'hasRepresentations' => 1))); $this->view->setVar('featured_set_item_ids', $va_featured_ids); $this->view->setVar('featured_set_items_as_search_result', caMakeSearchResult('ca_objects', $va_featured_ids)); } $this->view->setVar('config', $this->config); $o_result_context = new ResultContext($this->request, 'ca_objects', 'front'); $this->view->setVar('result_context', $o_result_context); $o_result_context->setAsLastFind(); // // Try to load selected page if it exists in Front/, otherwise load default Front/front_page_html.php // $ps_function = preg_replace("![^A-Za-z0-9_\\-]+!", "", $ps_function); $vs_path = "Front/{$ps_function}_html.php"; if (file_exists(__CA_THEME_DIR__ . "/views/{$vs_path}")) { $this->render($vs_path); } else { $this->render("Front/front_page_html.php"); } }
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); }
/** * Export set items * * @param string $ps_exporter_code defines the exporter to use * @param int $pn_set_id primary key of set to export * @param string $ps_filename Destination filename (we can't keep everything in memory here) * @param array $pa_options * progressCallback = callback function for asynchronous UI status reporting * showCLIProgressBar = Show command-line progress bar. Default is false. * logDirectory = path to directory where logs should be written * logLevel = KLogger constant for minimum log level to record. Default is KLogger::INFO. * @return boolean success state */ public static function exportRecordsFromSet($ps_exporter_code, $pn_set_id, $ps_filename, $pa_options = null) { ca_data_exporters::$s_exporter_cache = array(); ca_data_exporters::$s_exporter_item_cache = array(); if (!($t_mapping = ca_data_exporters::loadExporterByCode($ps_exporter_code))) { return false; } if (sizeof(ca_data_exporters::checkMapping($ps_exporter_code)) > 0) { return false; } $t_set = new ca_sets(); if (!$t_set->load($pn_set_id)) { return false; } $va_row_ids = array_keys($t_set->getItems(array('returnRowIdsOnly' => true))); $o_result = $t_set->makeSearchResult($t_set->get('table_num'), $va_row_ids); return self::exportRecordsFromSearchResult($ps_exporter_code, $o_result, $ps_filename, $pa_options); }
/** * Returns content for overlay containing details for object representation linked to occurrence */ public function getSetsOverlay() { $this->view->setVar('display_type', 'media_overlay'); $pn_set_id = $this->request->getParameter('set_id', pInteger); $pn_object_id = $this->request->getParameter('object_id', pInteger); $this->view->setVar('object_id', $pn_object_id); $pn_representation_id = $this->request->getParameter('representation_id', pInteger); $this->opo_plugin_config = Configuration::load($this->request->getAppConfig()->get('application_plugins') . '/simpleGallery/conf/simpleGallery.conf'); $this->view->setVar('set_id', $pn_set_id); $t_set = new ca_sets($pn_set_id); $pn_set_item_id = $this->request->getParameter('set_item_id', pInteger); $this->view->setVar('set_item_id', $pn_set_item_id); $ps_set_item_description_code = $this->opo_plugin_config->get('set_item_description_element_code'); $this->view->setVar('set_item_description', $ps_set_item_description_code); $this->view->setVar('object_id', $pn_object_id); $t_object = new ca_objects($pn_object_id); $this->view->setVar('t_object', $t_object); $t_rep = new ca_object_representations($pn_representation_id); $this->view->setVar('representation_id', $pn_representation_id); $this->view->setVar('t_object_representation', $t_rep); if ($this->request->config->get("dont_enforce_access_settings")) { $va_access_values = array(); } else { $va_access_values = caGetUserAccessValues($this->request); } if (!$t_set->getPrimaryKey()) { die("Invalid set_id"); } if (!$t_object->getPrimaryKey()) { die("Invalid object_id"); } if (!$t_rep->getPrimaryKey()) { die("Invalid representation_id"); } if (sizeof($va_access_values) && !in_array($t_set->get('access'), $va_access_values)) { die("Invalid set_id"); } if (sizeof($va_access_values) && !in_array($t_object->get('access'), $va_access_values)) { die("Invalid object_id"); } if (sizeof($va_access_values) && !in_array($t_rep->get('access'), $va_access_values)) { die("Invalid rep_id"); } // Get media for display using configured rules $va_rep_display_info = caGetMediaDisplayInfo("media_overlay", $t_rep->getMediaInfo('media', 'INPUT', 'MIMETYPE')); // set version $this->view->setVar('version', $va_rep_display_info['display_version']); unset($va_display_info['display_version']); // set other options $this->view->setVar('display_options', $va_rep_display_info); if (!($ps_containerID = trim($this->request->getParameter('containerID', pString)))) { $ps_containerID = 'caMediaPanelContentArea'; } $this->view->setVar("containerID", $ps_containerID); // Get all objects asscoiated with this set and show primary reps as icons for navigation $va_set_items = $t_set->getItems(array("checkAccess" => $va_access_values)); #print "<pre>"; #print_r($va_set_items); #print "</pre>"; if (sizeof($va_set_items) > 0) { $t_image_objects = new ca_objects(); $i = 1; foreach ($va_set_items as $vn_rel_id => $va_inter) { foreach ($va_inter as $id => $va_info) { $t_image_objects->load($va_info["row_id"]); if ($t_primary_rep = $t_image_objects->getPrimaryRepresentationInstance()) { $va_temp = array(); if (!sizeof($va_access_values) || in_array($t_primary_rep->get('access'), $va_access_values)) { $va_temp["representation_id"] = $t_primary_rep->get("representation_id"); $va_temp["rep_icon"] = $t_primary_rep->getMediaTag('media', 'icon'); $va_temp["rep_tinyicon"] = $t_primary_rep->getMediaTag('media', 'tinyicon'); $va_temp["object_id"] = $va_info["object_id"]; $va_temp["set_item_id"] = $va_info['item_id']; $va_thumbnails[$va_info["object_id"]] = $va_temp; if ($vn_getNext == 1) { $this->view->setVar("next_object_id", $va_info["object_id"]); $this->view->setVar("next_representation_id", $t_primary_rep->get("representation_id")); $vn_getNext = 0; } if ($va_info["object_id"] == $pn_object_id) { $this->view->setVar("representation_index", $i); $this->view->setVar("previous_object_id", $vn_prev_obj_id); $this->view->setVar("previous_representation_id", $vn_prev_rep_id); $this->view->setVar("set_item_id", $va_info['item_id']); $vn_getNext = 1; } $vn_prev_obj_id = $va_info["object_id"]; $vn_prev_rep_id = $t_primary_rep->get("representation_id"); $i++; } } } } } $this->view->setVar('reps', $va_thumbnails); return $this->render($this->ops_theme . "/ajax_ca_sets_media_overlay_html.php"); }
* @package CollectiveAccess * @subpackage Core * @license http://www.gnu.org/copyleft/gpl.html GNU Public License version 3 * * ---------------------------------------------------------------------- */ ?> <div class="row"> <?php $va_access_values = $this->getVar("access_values"); $o_config = caGetFrontConfig(); # --- grab the set that has the featured $t_set = new ca_sets(); $t_set->load(array('set_code' => $o_config->get("front_page_exhibit_set_code"))); $t_exhibition = new ca_occurrences(); if (sizeof($va_access_values) == 0 || sizeof($va_access_values) && in_array($t_set->get("access"), $va_access_values)) { $va_exhibition_ids = array_keys(is_array($va_tmp = $t_set->getItemRowIDs(array('checkAccess' => $va_access_values, 'shuffle' => 1))) ? $va_tmp : array()); $t_exhibition->load($va_exhibition_ids[0]); } # --- check to see if there is an image set configured $t_set->load(array('set_code' => $o_config->get("front_page_set_code"))); if (sizeof($va_access_values) == 0 || sizeof($va_access_values) && in_array($t_set->get("access"), $va_access_values)) { $va_featured_ids = array_keys(is_array($va_tmp = $t_set->getItemRowIDs(array('checkAccess' => $va_access_values, 'shuffle' => 1))) ? $va_tmp : array()); $qr_res = caMakeSearchResult('ca_objects', $va_featured_ids); } if ($qr_res && $qr_res->numHits()) { $qr_res = $this->getVar('featured_set_items_as_search_result'); while ($qr_res->nextHit()) { if ($vs_media = $qr_res->getWithTemplate('^ca_object_representations.media.front', array("checkAccess" => $va_access_values))) { print "<div class='col-sm-12'><div class='frontSlide'>" . $vs_media . "</div></div>"; break;
public function Index() { if ($this->request->config->get("dont_enforce_access_settings")) { $va_access_values = array(); } else { $va_access_values = caGetUserAccessValues($this->request); } $t_object = new ca_objects(); $t_user_favs = new ca_sets(); // redirect user if not logged in if ($this->request->config->get('pawtucket_requires_login') && !$this->request->isLoggedIn() || $this->request->config->get('show_bristol_only') && !$this->request->isLoggedIn()) { $this->response->setRedirect(caNavUrl($this->request, "", "LoginReg", "form")); } elseif ($this->request->config->get('show_bristol_only') && $this->request->isLoggedIn()) { $this->response->setRedirect(caNavUrl($this->request, "bristol", "Show", "Index")); } # --- user favs - highest ranked $va_user_favs = array(); $va_user_favs_ids = $t_object->getHighestRated(true, 12, $va_access_values); if (is_array($va_user_favs_ids) && sizeof($va_user_favs_ids) > 0) { foreach ($va_user_favs_ids as $vn_uf_object_id) { $t_object = new ca_objects($vn_uf_object_id); $va_reps = $t_object->getPrimaryRepresentation(array('thumbnail', 'preview'), null, array('return_with_access' => $va_access_values)); $va_user_favs[$vn_uf_object_id] = $va_reps["tags"]["preview"]; } } else { # --- get random objects $this->view->setVar('user_favorites_is_random', 1); $va_random_ids = $t_object->getRandomItems(15, array('checkAccess' => $va_access_values, 'hasRepresentations' => 1)); if (is_array($va_random_ids) && sizeof($va_random_ids) > 0) { $va_random = array(); foreach ($va_random_ids as $va_item_info) { $vn_rand_object_id = $va_item_info['object_id']; $t_object->load($vn_rand_object_id); $va_reps = $t_object->getPrimaryRepresentation(array('thumbnail', 'preview'), null, array('return_with_access' => $va_access_values)); $va_random[$vn_rand_object_id] = $va_reps["tags"]["preview"]; } $va_user_favs = $va_random; } } $this->view->setVar('user_favs', $va_user_favs); # --- featured items set set_code defined in app.conf $t_featured = new ca_sets(); $t_featured->load(array('set_code' => $this->request->config->get('featured_set_name'))); # Enforce access control on set if (sizeof($va_access_values) && !in_array($t_featured->get("access"), $va_access_values)) { $t_featured = new ca_sets(); } $va_featured = array(); if (is_array($va_row_ids = $t_featured->getItemRowIDs(array('checkAccess' => $va_access_values)))) { $va_featured_ids = array_keys($va_row_ids); // These are the object ids in the set foreach ($va_featured_ids as $vn_f_object_id) { $t_object = new ca_objects($vn_f_object_id); $va_reps = $t_object->getPrimaryRepresentation(array('thumbnail', 'preview'), null, array('return_with_access' => $va_access_values)); $va_featured[$vn_f_object_id] = $va_reps["tags"]["preview"]; } } else { # --- get random objects $va_random_ids = $t_object->getRandomItems(15, array('checkAccess' => $va_access_values, 'hasRepresentations' => 1)); if (is_array($va_random_ids) && sizeof($va_random_ids) > 0) { $va_random = array(); foreach ($va_random_ids as $va_item_info) { $vn_rand_object_id = $va_item_info['object_id']; $t_object->load($vn_rand_object_id); $va_reps = $t_object->getPrimaryRepresentation(array('thumbnail', 'preview'), null, array('return_with_access' => $va_access_values)); $va_random[$vn_rand_object_id] = $va_reps["tags"]["preview"]; } $va_featured = $va_random; } } $this->view->setVar('featured', $va_featured); # --- most viewed $va_most_viewed_ids = $t_object->getMostViewedItems(15, array('checkAccess' => $va_access_values, 'hasRepresentations' => 1)); if (is_array($va_most_viewed_ids) && sizeof($va_most_viewed_ids) > 0) { $va_most_viewed = array(); foreach ($va_most_viewed_ids as $va_item_info) { $vn_r_object_id = $va_item_info['object_id']; $t_object->load($vn_r_object_id); $va_reps = $t_object->getPrimaryRepresentation(array('thumbnail', 'preview'), null, array('return_with_access' => $va_access_values)); $va_most_viewed[$vn_r_object_id] = $va_reps["tags"]["preview"]; } } $this->view->setVar('most_viewed', $va_most_viewed); # --- recently added $va_recently_added_ids = $t_object->getRecentlyAddedItems(15, array('checkAccess' => $va_access_values, 'hasRepresentations' => 1)); if (is_array($va_recently_added_ids) && sizeof($va_recently_added_ids) > 0) { $va_recently_added = array(); foreach ($va_recently_added_ids as $va_item_info) { $vn_r_object_id = $va_item_info['object_id']; $t_object->load($vn_r_object_id); $va_reps = $t_object->getPrimaryRepresentation(array('thumbnail', 'preview'), null, array('return_with_access' => $va_access_values)); $va_recently_added[$vn_r_object_id] = $va_reps["tags"]["preview"]; } } $this->view->setVar('recently_added', $va_recently_added); $this->render('Favorites/favorites_landing_html.php'); }
/** * Add items to specified set */ public function addToSet() { $vn_added_items_count = $vn_dupe_item_count = 0; $ps_rows = $this->request->getParameter('item_ids', pString); $pa_row_ids = explode(';', $ps_rows); if (!$ps_rows || !sizeof($pa_row_ids)) { $this->view->setVar('error', _t('Nothing was selected')); } else { $t_model = $this->opo_datamodel->getInstanceByTableName($this->ops_tablename, true); $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); $this->view->setVar('set_name', $t_set->getLabelForDisplay()); $this->view->setVar('error', ''); if ($t_set->getPrimaryKey() && $t_set->get('table_num') == $t_model->tableNum()) { $va_item_ids = $t_set->getItemRowIDs(array('user_id' => $this->request->getUserID())); foreach ($pa_row_ids as $vn_row_id) { if (!$vn_row_id) { continue; } if (isset($va_item_ids[$vn_row_id])) { $vn_dupe_item_count++; continue; } if ($t_set->addItem($vn_row_id, array(), $this->request->getUserID())) { $va_item_ids[$vn_row_id] = 1; $vn_added_items_count++; } else { $this->view->setVar('error', join('; ', $t_set->getErrors())); } } } else { $this->view->setVar('error', _t('Invalid set')); } } $this->view->setVar('num_items_added', $vn_added_items_count); $this->view->setVar('num_items_already_in_set', $vn_dupe_item_count); $this->render('Results/ajax_add_to_set_json.php'); }
<?php require_once __CA_MODELS_DIR__ . "/ca_objects.php"; require_once __CA_MODELS_DIR__ . "/ca_sets.php"; require_once __CA_APP_DIR__ . '/helpers/accessHelpers.php'; $t_object = new ca_objects(); $t_featured_obj = new ca_sets(); # --- load the featured items set - set name assigned in app.conf $t_featured_obj->load(array('set_code' => 'featured_object')); # --- Enforce access control on set if (sizeof($va_access_values) == 0 || sizeof($va_access_values) && in_array($t_featured_obj->get("access"), $va_access_values)) { $vn_featured_set_id = $t_featured_obj->get("set_id"); $va_featured_ids = array_keys(is_array($va_tmp = $t_featured_obj->getItemRowIDs(array('checkAccess' => $va_access_values, 'limit' => 1))) ? $va_tmp : array()); // These are the object ids in the set } if (is_array($va_featured_ids) && sizeof($va_featured_ids) > 0) { $t_object = new ca_objects($va_featured_ids[0]); $va_rep = $t_object->getPrimaryRepresentation(array('widepreview'), null, array('return_with_access' => $va_access_values)); $feat_obj_content_id = $va_featured_ids[0]; $feat_obj_content_widepreview = $va_rep["tags"]["widepreview"]; $vs_featured_content_label = $t_object->getLabelForDisplay(); } # --- Recently Added # --- get the 12 most recently added objects to display $va_recently_added_items = $t_object->getRecentlyAddedItems(12, array('checkAccess' => $va_access_values, 'hasRepresentations' => 1)); $va_labels = $t_object->getPreferredDisplayLabelsForIDs(array_keys($va_recently_added_items)); $va_media = $t_object->getPrimaryMediaForIDs(array_keys($va_recently_added_items), array('small', 'thumbnail', 'preview', 'widepreview'), array("checkAccess" => $va_access_values)); foreach ($va_recently_added_items as $vn_object_id => $va_object_info) { $va_object_info['title'] = $va_labels[$vn_object_id]; $va_object_info['media'] = $va_media[$vn_object_id]; $va_recently_added_objects[$vn_object_id] = $va_object_info;
function Index($pa_options = null) { // Remove any browse criteria previously set $this->opo_browse->removeAllCriteria(); parent::Index(array('dontRenderView' => true)); JavascriptLoadManager::register('imageScroller'); JavascriptLoadManager::register('browsable'); JavascriptLoadManager::register('tabUI'); JavascriptLoadManager::register('cycle'); $t_object = new ca_objects(); $t_featured = new ca_sets(); if ($this->request->config->get("dont_enforce_access_settings")) { $va_access_values = array(); } else { $va_access_values = caGetUserAccessValues($this->request); } $va_default_versions = array('thumbnail', 'icon', 'small', 'preview', 'medium', 'preview', 'widepreview'); # --- featured items set - set name assigned in app.conf $t_featured->load(array('set_code' => $this->request->config->get('featured_set_name'))); # Enforce access control on set if (sizeof($va_access_values) == 0 || sizeof($va_access_values) && in_array($t_featured->get("access"), $va_access_values)) { $this->view->setVar('featured_set_id', $t_featured->get("set_id")); $va_featured_ids = array_keys(is_array($va_tmp = $t_featured->getItemRowIDs(array('checkAccess' => $va_access_values, 'shuffle' => 1))) ? $va_tmp : array()); // These are the object ids in the set } if (!is_array($va_featured_ids) || sizeof($va_featured_ids) == 0) { # put a random object in the features variable $va_featured_ids = array_keys($t_object->getRandomItems(10, array('checkAccess' => $va_access_values, 'hasRepresentations' => 1))); } $t_object = new ca_objects($va_featured_ids[0]); $va_rep = $t_object->getPrimaryRepresentation(array('thumbnail', 'small', 'medium', 'mediumlarge', 'preview', 'widepreview'), null, array('return_with_access' => $va_access_values)); $this->view->setVar('featured_content_id', $va_featured_ids[0]); $this->view->setVar('featured_content_thumb', $va_rep["tags"]["thumbnail"]); $this->view->setVar('featured_content_small', $va_rep["tags"]["small"]); $this->view->setVar('featured_content_mediumlarge', $va_rep["tags"]["mediumlarge"]); $this->view->setVar('featured_content_medium', $va_rep["tags"]["medium"]); $this->view->setVar('featured_content_preview', $va_rep["tags"]["preview"]); $this->view->setVar('featured_content_widepreview', $va_rep["tags"]["widepreview"]); $this->view->setVar('featured_content_label', $t_object->getLabelForDisplay()); $this->view->setVar('featured_content_slideshow_id_list', $va_featured_ids); if (!(bool) $this->request->config->get("splash_disable_highest_rated_objects")) { if (!is_array($va_versions = $this->request->config->getList("splash_highest_rated_display_versions"))) { $va_versions = $va_default_versions; } # --- user favorites get the highest ranked objects to display $va_user_favorites_items = $t_object->getHighestRated(true, 12, $va_access_values); if (sizeof($va_user_favorites_items) > 0) { if (is_array($va_user_favorites_items) && sizeof($va_user_favorites_items) > 0) { $t_object = new ca_objects($va_user_favorites_items[0]); $va_rep = $t_object->getPrimaryRepresentation($va_versions, null, array('return_with_access' => $va_access_values)); $this->view->setVar('user_favorites_id', $va_user_favorites_items[0]); foreach ($va_versions as $vs_version) { $this->view->setVar('user_favorites_' . $vs_version, $va_rep['tags'][$vs_version]); } } } else { $this->view->setVar('user_favorites_is_random', 1); # if no ranks set, choose a random object $va_random_items = $t_object->getRandomItems(1, array('checkAccess' => $va_access_values, 'hasRepresentations' => 1)); $va_labels = $t_object->getPreferredDisplayLabelsForIDs(array_keys($va_random_items)); $va_media = $t_object->getPrimaryMediaForIDs(array_keys($va_random_items), $va_versions, array("checkAccess" => $va_access_values)); foreach ($va_random_items as $vn_object_id => $va_object_info) { $va_object_info['title'] = $va_labels[$vn_object_id]; $va_object_info['media'] = $va_media[$vn_object_id]; $va_random_items[$vn_object_id] = $va_object_info; } $this->view->setVar('random_objects', $va_random_items); if (is_array($va_random_items) && sizeof($va_random_items) > 0) { $va_object_info = reset($va_random_items); $this->view->setVar('user_favorites_id', $va_object_info['object_id']); foreach ($va_versions as $vs_version) { $this->view->setVar('user_favorites_' . $vs_version, $va_media[$va_object_info['object_id']]['tags'][$vs_version]); } } } } if (!(bool) $this->request->config->get("splash_disable_recently_added_objects")) { if (!is_array($va_versions = $this->request->config->getList("splash_recently_added_display_versions"))) { $va_versions = $va_default_versions; } # --- get the 12 most recently added objects to display $va_recently_added_items = $t_object->getRecentlyAddedItems(12, array('checkAccess' => $va_access_values, 'hasRepresentations' => 1)); $va_labels = $t_object->getPreferredDisplayLabelsForIDs(array_keys($va_recently_added_items)); $va_media = $t_object->getPrimaryMediaForIDs(array_keys($va_recently_added_items), $va_versions, array("checkAccess" => $va_access_values)); foreach ($va_recently_added_items as $vn_object_id => $va_object_info) { $va_object_info['title'] = $va_labels[$vn_object_id]; $va_object_info['media'] = $va_media[$vn_object_id]; $va_recently_added_objects[$vn_object_id] = $va_object_info; } $this->view->setVar('recently_added_objects', $va_recently_added_objects); if (is_array($va_recently_added_objects) && sizeof($va_recently_added_objects) > 0) { $va_object_info = reset($va_recently_added_objects); $this->view->setVar('recently_added_id', $va_object_info['object_id']); foreach ($va_versions as $vs_version) { $this->view->setVar('recently_added_' . $vs_version, $va_media[$va_object_info['object_id']]['tags'][$vs_version]); } } } else { $this->view->setVar('recently_added_objects', array()); } # --- get the 12 most viewed objects if (!(bool) $this->request->config->get("splash_disable_most_viewed_objects")) { if (!is_array($va_versions = $this->request->config->getList("splash_most_viewed_display_versions"))) { $va_versions = $va_default_versions; } $va_most_viewed_objects = $t_object->getMostViewedItems(12, array('checkAccess' => $va_access_values, 'hasRepresentations' => 1)); $va_labels = $t_object->getPreferredDisplayLabelsForIDs(array_keys($va_most_viewed_objects)); $va_media = $t_object->getPrimaryMediaForIDs(array_keys($va_most_viewed_objects), $va_versions, array("checkAccess" => $va_access_values)); foreach ($va_most_viewed_objects as $vn_object_id => $va_object_info) { $va_object_info['title'] = $va_labels[$vn_object_id]; $va_object_info['media'] = $va_media[$vn_object_id]; $va_most_viewed_objects[$vn_object_id] = $va_object_info; } $this->view->setVar('most_viewed_objects', $va_most_viewed_objects); if (is_array($va_most_viewed_objects) && sizeof($va_most_viewed_objects) > 0) { $va_object_info = reset($va_most_viewed_objects); $this->view->setVar('most_viewed_id', $va_object_info['object_id']); foreach ($va_versions as $vs_version) { $this->view->setVar('most_viewed_' . $vs_version, $va_media[$va_object_info['object_id']]['tags'][$vs_version]); } } } if (!(bool) $this->request->config->get("splash_disable_recently_viewed_objects")) { if (!is_array($va_versions = $this->request->config->getList("splash_recently_viewed_display_versions"))) { $va_versions = $va_default_versions; } # --- get the 12 recently viewed objects $va_recently_viewed_objects = $t_object->getRecentlyViewedItems(12, array('checkAccess' => $va_access_values, 'hasRepresentations' => 1)); $va_labels = $t_object->getPreferredDisplayLabelsForIDs($va_recently_viewed_objects); $va_media = $t_object->getPrimaryMediaForIDs($va_recently_viewed_objects, $va_versions, array("checkAccess" => $va_access_values)); $va_recently_viewed_objects_for_display = array(); foreach ($va_recently_viewed_objects as $vn_object_id) { $va_recently_viewed_objects_for_display[$vn_object_id] = array('object_id' => $vn_object_id, 'title' => $va_labels[$vn_object_id], 'media' => $va_media[$vn_object_id]); } $this->view->setVar('recently_viewed_objects', $va_recently_viewed_objects_for_display); if (is_array($va_recently_viewed_objects) && sizeof($va_recently_viewed_objects) > 0) { foreach ($va_recently_viewed_objects_for_display as $va_object_info) { if ($va_media[$va_object_info['object_id']]['tags'][$vs_version]) { $this->view->setVar('recently_viewed_id', $va_object_info['object_id']); foreach ($va_versions as $vs_version) { $this->view->setVar('recently_viewed_' . $vs_version, $va_media[$va_object_info['object_id']]['tags'][$vs_version]); } break; } } } } else { $this->view->setVar('recently_viewed_objects', array()); } if (!(bool) $this->request->config->get("splash_disable_random_objects")) { if (!is_array($va_versions = $this->request->config->getList("splash_random_display_versions"))) { $va_versions = $va_default_versions; } # --- get random objects $va_random_items = $t_object->getRandomItems(12, array('checkAccess' => $va_access_values, 'hasRepresentations' => 1)); $va_labels = $t_object->getPreferredDisplayLabelsForIDs(array_keys($va_random_items)); $va_media = $t_object->getPrimaryMediaForIDs(array_keys($va_random_items), $va_versions, array("checkAccess" => $va_access_values)); foreach ($va_random_items as $vn_object_id => $va_object_info) { $va_object_info['title'] = $va_labels[$vn_object_id]; $va_object_info['media'] = $va_media[$vn_object_id]; $va_random_items[$vn_object_id] = $va_object_info; } $this->view->setVar('random_objects', $va_random_items); if (is_array($va_random_items) && sizeof($va_random_items) > 0) { $va_object_info = array_shift($va_random_items); $this->view->setVar('random_object_id', $va_object_info['object_id']); foreach ($va_versions as $vs_version) { $this->view->setVar('random_object_' . $vs_version, $va_media[$va_object_info['object_id']]['tags'][$vs_version]); } } } else { $this->view->setVar('random_objects', array()); } $this->render('Splash/splash_html.php'); }
public function displaySet() { # --- set info $pn_set_id = $this->request->getParameter('set_id', pInteger); $t_set = new ca_sets($pn_set_id); $va_access_values = caGetUserAccessValues($this->request); # Enforce access control if (sizeof($va_access_values) && !in_array($t_set->get("access"), $va_access_values)) { $this->notification->addNotification(_t("This set is not available for view"), "message"); $this->response->setRedirect(caNavUrl($this->request, "", "", "", "")); return; } $this->view->setVar('t_set', $t_set); $va_items = caExtractValuesByUserLocale($t_set->getItems(array('thumbnailVersions' => array('widepreview', 'medium', 'setimage'), "checkAccess" => $va_access_values))); $this->view->setVar('items', $va_items); $va_row_ids = array(); foreach ($va_items as $vn_item_id => $va_item_info) { $va_row_ids[] = $va_item_info['row_id']; } # --- all featured sets - for display in right hand column // get sets for public display $t_list = new ca_lists(); $vn_public_set_type_id = $t_list->getItemIDFromList('set_types', $t_list->getAppConfig()->get('simpleGallery_set_type')); $t_set = new ca_sets($pn_set_id); $va_sets = caExtractValuesByUserLocale($t_set->getSets(array('table' => 'ca_objects', 'checkAccess' => $va_access_values, 'setType' => $vn_public_set_type_id))); $va_set_first_items = array(); $va_set_first_items = $t_set->getFirstItemsFromSets(array_keys($va_sets), array("version" => "icon", "checkAccess" => $va_access_values)); $this->view->setVar('sets', $va_sets); $this->view->setVar('first_items_from_sets', $va_set_first_items); $this->view->setVar('set_title', $t_set->getLabelForDisplay()); $this->view->setVar('set_description', $t_set->get($this->opo_plugin_config->get('set_description_element_code'), array('convertLinkBreaks' => true))); // Needed to figure out what result context to use on details $this->opo_result_context->setParameter('set_id', $pn_set_id); $this->opo_result_context->setResultList($va_row_ids); $this->opo_result_context->setAsLastFind(); $this->opo_result_context->saveContext(); $this->render($this->ops_theme . '/set_info_html.php'); }
public function getFeaturedArtistSlideshow() { $va_featured_ids = array(); $t_featured = new ca_sets(); # --- featured artists set - set name assigned in eastend.conf - plugin conf file $t_featured->load(array('set_code' => $this->opo_plugin_config->get('featured_artists_set_name'))); # Enforce access control on set if (sizeof($this->opa_access_values) == 0 || sizeof($this->opa_access_values) && in_array($t_featured->get("access"), $this->opa_access_values)) { $this->view->setVar('featured_set_id', $t_featured->get("set_id")); $va_featured_ids = array_keys(is_array($va_tmp = $t_featured->getItemRowIDs(array('checkAccess' => $this->opa_access_values, 'shuffle' => 1))) ? $va_tmp : array()); // These are the entity ids in the set } if (!is_array($va_featured_ids) || sizeof($va_featured_ids) == 0) { # put random entities in the features variable $o_db = new Db(); $q_entities = $o_db->query("SELECT e.entity_id from ca_entities e WHERE e.access IN (" . implode($this->opa_access_values, ", ") . ") ORDER BY RAND() LIMIT 10"); if ($q_entities->numRows() > 0) { while ($q_entities->nextRow()) { $va_featured_ids[] = $q_entities->get("entity_id"); } } } # --- loop through featured ids and grab the entity's name, portrait, lifespan -lifespans_date, indexing_notes (brief description abouthow they relate to the east end) $t_entity = new ca_entities(); $t_object = new ca_objects(); $va_featured_artists = array(); foreach ($va_featured_ids as $vn_featured_entity_id) { $va_tmp = array(); $t_entity->load($vn_featured_entity_id); $va_tmp["entity_id"] = $vn_featured_entity_id; $va_tmp["lifespan"] = $t_entity->get("lifespans_date"); $va_tmp["indexing_notes"] = $t_entity->get("indexing_notes"); $va_tmp["name"] = $t_entity->getLabelForDisplay(); $va_objects = $t_entity->get("ca_objects", array("returnAsArray" => 1, 'checkAccess' => $this->opa_access_values, 'restrict_to_relationship_types' => array('portrait'))); $va_object = array_shift($va_objects); $t_object->load($va_object["object_id"]); $va_portrait = $t_object->getPrimaryRepresentation(array("abSlideShow")); # --- don't show records with status ars/vaga don't show image if ($t_object->get("ca_objects.object_status") != 348) { if ($t_object->get("ca_objects.object_status") == 349) { $va_tmp["vaga_class"] = "vagaDisclaimer"; } $va_tmp["image"] = $va_portrait["tags"]["abSlideShow"]; $va_tmp["caption"] = $t_object->get("ca_objects.caption"); } $va_featured_artists[$vn_featured_entity_id] = $va_tmp; } $this->view->setVar("featured_artists", $va_featured_artists); $this->render('featured_artists_html.php'); }
public function AjaxAddItem() { if (!$this->request->isLoggedIn()) { $this->response->setRedirect(caNavUrl($this->request, '', 'LoginReg', 'loginForm')); return; } global $g_ui_locale_id; // current locale_id for user $va_errors = array(); $o_purifier = new HTMLPurifier(); # --- set_id is passed through form, otherwise we're saving a new set, and adding the item to it if ($this->request->getParameter('set_id', pInteger)) { $t_set = $this->_getSet(__CA_EDIT_READ_ACCESS__); if (!$t_set && ($t_set = $this->_getSet(__CA_SET_READ_ACCESS__))) { $va_errors["general"] = _t("You can not add items to this lightbox. You have read only access."); $this->view->setVar('errors', $va_errors); $this->addItemForm(); return; } } else { $t_set = new ca_sets(); # --- set name - if not sent, make a decent default $ps_name = $o_purifier->purify($this->request->getParameter('name', pString)); if (!$ps_name) { $ps_name = _t("Your lightbox"); } # --- set description - optional $ps_description = $o_purifier->purify($this->request->getParameter('description', pString)); $t_list = new ca_lists(); $vn_set_type_user = $t_list->getItemIDFromList('set_types', $this->request->config->get('user_set_type')); $t_object = new ca_objects(); $vn_object_table_num = $t_object->tableNum(); $t_set->setMode(ACCESS_WRITE); $t_set->set('access', 1); #$t_set->set('access', $this->request->getParameter('access', pInteger)); $t_set->set('table_num', $vn_object_table_num); $t_set->set('type_id', $vn_set_type_user); $t_set->set('user_id', $this->request->getUserID()); $t_set->set('set_code', $this->request->getUserID() . '_' . time()); # --- create new attribute if ($ps_description) { $t_set->addAttribute(array('description' => $ps_description, 'locale_id' => $g_ui_locale_id), 'description'); } $t_set->insert(); if ($t_set->numErrors()) { $va_errors["general"] = join("; ", $t_set->getErrors()); $this->view->setVar('errors', $va_errors); $this->addItemForm(); return; } else { # --- save name - add new label $t_set->addLabel(array('name' => $ps_name), $g_ui_locale_id, null, true); # --- select the current set $this->request->user->setVar('current_set_id', $t_set->get("set_id")); } } if ($t_set) { $pn_item_id = null; $pn_object_id = $this->request->getParameter('object_id', pInteger); if ($pn_object_id) { if (!$t_set->isInSet("ca_objects", $pn_object_id, $t_set->get("set_id"))) { if ($pn_item_id = $t_set->addItem($pn_object_id, array(), $this->request->getUserID())) { // // Select primary representation // $t_object = new ca_objects($pn_object_id); $vn_rep_id = $t_object->getPrimaryRepresentationID(); // get representation_id for primary $t_item = new ca_set_items($pn_item_id); $t_item->addSelectedRepresentation($vn_rep_id); // flag as selected in item vars $t_item->update(); $va_errors = array(); $this->view->setVar('message', _t("Successfully added item.")); $this->render("Form/reload_html.php"); } else { $va_errors["message"] = _t('Could not add item to lightbox'); $this->render("Form/reload_html.php"); } } else { $this->view->setVar('message', _t("Item already in lightbox.")); $this->render("Form/reload_html.php"); } } else { $this->view->setVar('message', _t("Object ID is not defined")); $this->render("Form/reload_html.php"); } } }
* the "license.txt" file for details, or visit the CollectiveAccess web site at * http://www.CollectiveAccess.org * * @package CollectiveAccess * @subpackage Core * @license http://www.gnu.org/copyleft/gpl.html GNU Public License version 3 * * ---------------------------------------------------------------------- */ # print $this->render("Front/featured_set_slideshow_html.php"); $va_featured_ids = array(); if ($vs_set_code = $this->request->config->get("front_page_set_code")) { $t_set = new ca_sets(); $t_set->load(array('set_code' => $vs_set_code)); # Enforce access control on set if (sizeof($va_access_values) == 0 || sizeof($va_access_values) && in_array($t_set->get("access"), $va_access_values)) { $vs_set_id = $t_set->get("set_id"); $va_featured_ids = array_keys(is_array($va_tmp = $t_set->getItemRowIDs(array('checkAccess' => $va_access_values, 'shuffle' => 1))) ? $va_tmp : array()); $featured_set_items_as_search_result = caMakeSearchResult('ca_occurrences', $va_featured_ids); } } ?> <div class="container"> <div class="row"> <div class="col-sm-8"> <h2>Selected exhibitions</h2> <?php if ($featured_set_items_as_search_result) { while ($featured_set_items_as_search_result->nextHit()) { $va_occurrence_id = $featured_set_items_as_search_result->get('ca_occurrences.occurrence_id'); $va_related_objects = $featured_set_items_as_search_result->get('ca_objects.object_id', array('returnAsArray' => true));
/** * Sets up view variables for upper-left-hand info panel (aka. "inspector"). Actual rendering is performed by calling sub-class. * * @param array $pa_parameters Array of parameters as specified in navigation.conf, including primary key value and type_id */ public function info($pa_parameters) { $vn_set_id = $this->request->getParameter('set_id', pInteger); $o_dm = Datamodel::load(); $t_set = new ca_sets($vn_set_id); if (!$t_set->getPrimaryKey()) { die("Invalid set"); } // Does user have access to set? if (!$t_set->haveAccessToSet($this->request->getUserID(), __CA_SET_READ_ACCESS__)) { die("You don't have access to the set"); } $t_item = $o_dm->getInstanceByTableNum($t_set->get('table_num'), true); $this->view->setVar('t_set', $t_set); $this->view->setVar('t_item', $t_item); $this->view->setVar('screen', $this->request->getActionExtra()); // name of screen $this->view->setVar('result_context', $this->getResultContext()); return $this->render('editor/widget_batch_info_html.php', true); }
/** * Returns content for overlay containing details for object representation linked to occurrence */ public function getSetsOverlay() { $pn_set_id = $this->request->getParameter('set_id', pInteger); $pn_object_id = $this->request->getParameter('object_id', pInteger); $this->view->setVar('object_id', $pn_object_id); $pn_representation_id = $this->request->getParameter('representation_id', pInteger); $this->view->setVar('set_id', $pn_set_id); $t_set = new ca_sets($pn_set_id); $pn_set_item_id = $this->request->getParameter('set_item_id', pInteger); $this->view->setVar('set_item_id', $pn_set_item_id); $this->view->setVar('object_id', $pn_object_id); $t_object = new ca_objects($pn_object_id); $this->view->setVar('t_object', $t_object); $t_rep = new ca_object_representations($pn_representation_id); $this->view->setVar('representation_id', $pn_representation_id); $this->view->setVar('t_object_representation', $t_rep); if ($this->request->config->get("dont_enforce_access_settings")) { $va_access_values = array(); } else { $va_access_values = caGetUserAccessValues($this->request); } if (!$t_set->getPrimaryKey()) { die("Invalid set_id"); } if (!$t_object->getPrimaryKey()) { die("Invalid object_id"); } if (!$t_rep->getPrimaryKey()) { die("Invalid representation_id"); } if (sizeof($va_access_values) && !in_array($t_set->get('access'), $va_access_values)) { die("Invalid set_id"); } if (sizeof($va_access_values) && !in_array($t_object->get('access'), $va_access_values)) { die("Invalid object_id"); } if (sizeof($va_access_values) && !in_array($t_rep->get('access'), $va_access_values)) { die("Invalid rep_id"); } // Get media for display using configured rules $va_rep_display_info = caGetMediaDisplayInfo("media_overlay", $t_rep->getMediaInfo('media', 'INPUT', 'MIMETYPE')); // set version $this->view->setVar('version', $va_rep_display_info['display_version']); unset($va_display_info['display_version']); // set poster frame URL //$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']); //$va_rep_display_info['viewer_base_url'] = $t_rep->getAppConfig()->get('ca_url_root'); // set other options $this->view->setVar('display_options', $va_rep_display_info); if (!($ps_display_type = trim($this->request->getParameter('display_type', pString)))) { $ps_display_type = 'media_overlay'; } if (!($ps_containerID = trim($this->request->getParameter('containerID', pString)))) { $ps_containerID = 'caMediaPanelContentArea'; } $this->view->setVar("display_type", $ps_display_type); $this->view->setVar("containerID", $ps_containerID); // Get all objects asscoiated with this set and show primary reps as icons for navigation //****THIS WONT WORK #$va_exhibition_images = $t_set->get("ca_objects", array('restrict_to_relationship_types' => array('describes'), "returnAsArray" => 1, 'checkAccess' => $va_access_values)); $va_exhibition_images = $t_set->getItems(array("checkAccess" => $va_access_values)); #print "<pre>"; #print_r($va_exhibition_images); #print "</pre>"; if (sizeof($va_exhibition_images) > 0) { $t_image_objects = new ca_objects(); $i = 1; foreach ($va_exhibition_images as $vn_rel_id => $va_inter) { foreach ($va_inter as $id => $va_info) { $t_image_objects->load($va_info["row_id"]); if ($t_primary_rep = $t_image_objects->getPrimaryRepresentationInstance()) { $va_temp = array(); if (!sizeof($va_access_values) || in_array($t_primary_rep->get('access'), $va_access_values)) { $va_temp["representation_id"] = $t_primary_rep->get("representation_id"); $va_temp["rep_icon"] = $t_primary_rep->getMediaTag('media', 'icon'); $va_temp["rep_tinyicon"] = $t_primary_rep->getMediaTag('media', 'tinyicon'); $va_temp["object_id"] = $va_info["object_id"]; $va_temp["set_item_id"] = $va_info['item_id']; $va_thumbnails[$va_info["object_id"]] = $va_temp; if ($vn_getNext == 1) { $this->view->setVar("next_object_id", $va_info["object_id"]); $this->view->setVar("next_representation_id", $t_primary_rep->get("representation_id")); $vn_getNext = 0; } if ($va_info["object_id"] == $pn_object_id) { $this->view->setVar("representation_index", $i); $this->view->setVar("previous_object_id", $vn_prev_obj_id); $this->view->setVar("previous_representation_id", $vn_prev_rep_id); $this->view->setVar("set_item_id", $va_info['item_id']); $vn_getNext = 1; } $vn_prev_obj_id = $va_info["object_id"]; $vn_prev_rep_id = $t_primary_rep->get("representation_id"); $i++; } } } } } $this->view->setVar('reps', $va_thumbnails); return $this->render("ns11mm/ajax_ca_sets_media_overlay_html.php"); }
print "<div>"; print "<div class='objectslidesHP'>" . caNavLink($this->request, $vs_featured_member_image, '', 'Detail', 'Entity', 'Show', array('entity_id' => $vn_featured_member_id)) . ""; print "<div class='objectslidesCaptionHP'><b>" . _t("Featured Member") . "</b><br/>" . caNavLink($this->request, $vs_featured_member_name, '', 'Detail', 'Entity', 'Show', array('entity_id' => $vn_featured_member_id)) . "</div></div>"; print "</div>"; } # --- share your knowledge if ($vs_featured_share_image) { print "<div>"; print "<div class='objectslidesHP'>" . caNavLink($this->request, $vs_featured_share_image, '', 'Detail', 'Object', 'Show', array('object_id' => $vn_featured_share_id)) . ""; print "<div class='objectslidesCaptionHP'><b>" . _t("Share Your Knowledge") . "</b><br/>" . caNavLink($this->request, _t("Help us improve this record. Do you know more about this item?"), '', 'Detail', 'Object', 'Show', array('object_id' => $vn_featured_share_id)) . "</div></div>"; print "</div>"; } ?> </div> <?php if ($t_featured_set->get("set_description")) { ?> <p class="setDescription"><?php print $t_featured_set->get("set_description"); ?> </p> <?php } ?> <!-- AddThis Button BEGIN --> <div class="HPshare"><a href="#" onclick="$('#shareWidgetsContainer').slideToggle(); return false;" class="shareButton">Share</a></div> <div id="shareWidgetsContainer"> <div class="addthis_toolbox addthis_default_style" style="padding-left:50px;"> <a class="addthis_button_pinterest_pinit"></a> <a class="addthis_button_facebook_like" fb:like:layout="button_count"></a>
public function process($pa_parameters) { $o_response = new ResponseHTTP(); $o_request = new RequestHTTP($o_response, array('simulateWith' => $x = array('POST' => $pa_parameters['values'], 'SCRIPT_NAME' => join('/', array(__CA_URL_ROOT__, 'index.php')), 'REQUEST_METHOD' => 'POST', 'REQUEST_URI' => join('/', array(__CA_URL_ROOT__, 'index.php', 'batch', 'Editor', 'Save', $pa_parameters['screen'], 'set_id', $pa_parameters['set_id'])), 'PATH_INFO' => '/' . join('/', array('batch', 'Editor', 'Save', $pa_parameters['screen'], 'set_id', $pa_parameters['set_id'])), 'REMOTE_ADDR' => $pa_parameters['ip_address'], 'HTTP_USER_AGENT' => 'batchEditor', 'user_id' => $pa_parameters['user_id']))); $o_app = AppController::getInstance($o_request, $o_response); $t_set = new ca_sets($pa_parameters['set_id']); $o_dm = Datamodel::load(); $t_subject = $o_dm->getInstanceByTableNum($t_set->get('table_num')); $va_report = BatchProcessor::saveBatchEditorFormForSet($o_request, $t_set, $t_subject, array('sendMail' => (bool) $pa_parameters['sendMail'], 'sendSMS' => (bool) $pa_parameters['sendSMS'])); return $va_report; }
/** * Download (accessible) media for all records in this set */ public function getSetMedia() { set_time_limit(600); // allow a lot of time for this because the sets can be potentially large $o_dm = Datamodel::load(); $t_set = new ca_sets($this->request->getParameter('set_id', pInteger)); if (!$t_set->getPrimaryKey()) { $this->notification->addNotification(_t('No set defined'), __NOTIFICATION_TYPE_ERROR__); $this->opo_response->setRedirect(caEditorUrl($this->opo_request, 'ca_sets', $t_set->getPrimaryKey())); return false; } $va_record_ids = array_keys($t_set->getItemRowIDs(array('limit' => 100000))); if (!is_array($va_record_ids) || !sizeof($va_record_ids)) { $this->notification->addNotification(_t('No media is available for download'), __NOTIFICATION_TYPE_ERROR__); $this->opo_response->setRedirect(caEditorUrl($this->opo_request, 'ca_sets', $t_set->getPrimaryKey())); return false; } $vs_subject_table = $o_dm->getTableName($t_set->get('table_num')); $t_instance = $o_dm->getInstanceByTableName($vs_subject_table); $qr_res = $vs_subject_table::createResultSet($va_record_ids); $qr_res->filterNonPrimaryRepresentations(false); $va_paths = array(); while ($qr_res->nextHit()) { $va_original_paths = $qr_res->getMediaPaths('ca_object_representations.media', 'original'); if (sizeof($va_original_paths) > 0) { $va_paths[$qr_res->get($t_instance->primaryKey())] = array('idno' => $qr_res->get($t_instance->getProperty('ID_NUMBERING_ID_FIELD')), 'paths' => $va_original_paths); } } if (sizeof($va_paths) > 0) { $vs_tmp_name = caGetTempFileName('DownloadSetMedia', 'zip'); $o_phar = new PharData($vs_tmp_name, null, null, Phar::ZIP); foreach ($va_paths as $vn_pk => $va_path_info) { $vn_c = 1; foreach ($va_path_info['paths'] as $vs_path) { if (!file_exists($vs_path)) { continue; } $vs_filename = $va_path_info['idno'] ? $va_path_info['idno'] : $vn_pk; $vs_filename .= "_{$vn_c}"; if ($vs_ext = pathinfo($vs_path, PATHINFO_EXTENSION)) { $vs_filename .= ".{$vs_ext}"; } $o_phar->addFile($vs_path, $vs_filename); $vn_c++; } } $o_view = new View($this->request, $this->request->getViewsDirectoryPath() . '/bundles/'); // send download $vs_set_code = $t_set->get('set_code'); $o_view->setVar('tmp_file', $vs_tmp_name); $o_view->setVar('download_name', 'media_for_' . mb_substr(preg_replace('![^A-Za-z0-9]+!u', '_', $vs_set_code ? $vs_set_code : $t_set->getPrimaryKey()), 0, 20) . '.zip'); $this->response->addContent($o_view->render('ca_sets_download_media.php')); return; } else { $this->notification->addNotification(_t('No media is available for download'), __NOTIFICATION_TYPE_ERROR__); $this->opo_response->setRedirect(caEditorUrl($this->opo_request, 'ca_sets', $t_set->getPrimaryKey())); return; } return $this->Edit(); }
public function Index() { JavascriptLoadManager::register('browsable'); JavascriptLoadManager::register('hierBrowser'); // Remove any browse criteria previously set $this->opo_browse->removeAllCriteria(); parent::Index(true); # --- get the featured collections $va_featured = array(); $va_access_values = caGetUserAccessValues($this->request); $t_featured = new ca_sets(); $t_featured->load(array('set_code' => "featured_collections")); # Enforce access control on set if (sizeof($va_access_values) == 0 || sizeof($va_access_values) && in_array($t_featured->get("access"), $va_access_values)) { $va_featured_collections = caExtractValuesByUserLocale($t_featured->getItems(array('checkAccess' => $va_access_values, 'shuffle' => 1))); // These are the collection ids in the set } if (is_array($va_featured_collections) && sizeof($va_featured_collections) > 0) { $va_featured_collections = array_slice($va_featured_collections, 0, 5); foreach ($va_featured_collections as $vn_i => $va_collection_info) { $va_temp = array(); $va_temp["idno"] = $va_collection_info["idno"]; $va_temp["collection_id"] = $va_collection_info["row_id"]; $va_temp["label"] = $va_collection_info["set_item_label"]; $va_featured[$va_collection_info["set_item_label"]] = $va_temp; } } arsort($va_featured); $this->view->setVar("featured_collections", $va_featured); $this->render('collections_landing_index_html.php'); }
/** * @link http://clangers.collectiveaccess.org/jira/browse/PROV-434 */ public function testAddAndGetSetItem() { $t_set = new ca_sets($this->opn_set_id); $t_set->setMode(ACCESS_WRITE); // "quick" add object (this method uses direct INSERT queries) $t_set->addItems(array($this->opn_object_id)); $va_set_items = $t_set->getItems(); // get rid of unneeded nesting in array. we should only have one label in one locale. $this->assertEquals(1, sizeof($va_set_items), 'Set should only have one item in one locale'); $va_set_items = array_shift($va_set_items); $this->assertEquals(1, sizeof($va_set_items), 'Set should only have one item in one locale'); $va_set_items = array_shift($va_set_items); // basic checks $this->assertArrayHasKey('caption', $va_set_items, 'Set item must have empty/blank label'); $this->assertEquals('[BLANK]', $va_set_items['caption'], 'Set item must have empty/blank label'); $this->assertArrayHasKey('row_id', $va_set_items, 'Set item must be related to object'); $this->assertEquals($this->opn_object_id, $va_set_items['row_id'], 'Set item must be related to object'); // // this is (hopefully was?) the actual PROV-434 bug // @see http://clangers.collectiveaccess.org/jira/browse/PROV-434 // $va_items = $t_set->get('ca_set_items', array('returnWithStructure' => true)); $this->assertEquals(1, sizeof($va_items)); $va_item = array_shift($va_items); $this->assertArrayHasKey('caption', $va_item, 'Set item must have empty/blank label'); $this->assertEquals('[BLANK]', $va_item['caption'], 'Set item must have empty/blank label'); $this->assertArrayHasKey('record_id', $va_item, 'Set item must be related to object'); $this->assertEquals($this->opn_object_id, $va_item['record_id'], 'Set item must be related to object'); // try text (no return as array) $vs_ret = $t_set->get('ca_set_items.item_id'); // what comes out is a string with the primary key $this->assertRegExp("/^[0-9]+\$/", $vs_ret); $vs_ret = $t_set->get('ca_set_items.preferred_labels'); $this->assertEquals("[BLANK]", $vs_ret); $vs_ret = $t_set->get('ca_set_items.row_id'); $this->assertEquals((string) $this->opn_object_id, $vs_ret); // remove item $t_set->removeItem($this->opn_object_id); $this->assertEmpty($t_set->getItems()); // re-add object using model method (as opposed to direct insert addItems() above) $t_set->addItem($this->opn_object_id); // basic checks (again) $va_set_items = $t_set->getItems(); // get rid of unneeded nesting in array. we should only have one label in one locale. $this->assertEquals(1, sizeof($va_set_items), 'Set should only have one item in one locale'); $va_set_items = array_shift($va_set_items); $this->assertEquals(1, sizeof($va_set_items), 'Set should only have one item in one locale'); $va_set_items = array_shift($va_set_items); $this->assertArrayHasKey('caption', $va_set_items, 'Set item must have empty/blank label'); $this->assertEquals('[BLANK]', $va_set_items['caption'], 'Set item must have empty/blank label'); $this->assertArrayHasKey('row_id', $va_set_items, 'Set item must be related to object'); $this->assertEquals($this->opn_object_id, $va_set_items['row_id'], 'Set item must be related to object'); // // this is (hopefully was?) the actual PROV-434 bug // @see http://clangers.collectiveaccess.org/jira/browse/PROV-434 // $va_items = $t_set->get('ca_set_items', array('returnWithStructure' => true)); $this->assertEquals(1, sizeof($va_items)); $va_item = array_shift($va_items); $this->assertArrayHasKey('caption', $va_item, 'Set item must have empty/blank label'); $this->assertEquals('[BLANK]', $va_item['caption'], 'Set item must have empty/blank label'); $this->assertArrayHasKey('record_id', $va_item, 'Set item must be related to object'); $this->assertEquals($this->opn_object_id, $va_item['record_id'], 'Set item must be related to object'); }
/** * */ public function insert($pa_options = null) { $t_trans = new ca_commerce_transactions($this->get('transaction_id')); if ($t_trans->getPrimaryKey()) { if ($vn_set_id = $t_trans->get('set_id')) { $t_set = new ca_sets($vn_set_id); if ($t_set->getPrimaryKey()) { $va_row_ids = $t_set->getItemRowIDs(); $this->set('set_snapshot', array('table_num' => $t_set->get('table_num'), 'set_id' => $vn_set_id, 'datetime' => time(), 'items' => $va_row_ids)); } } return parent::insert($pa_options); } else { $this->postError(1500, _t('Transaction does not exist'), 'ca_commerce_communications->insert()'); return false; } }
<div> <H1><?php print $this->getVar("section_name"); ?> </H1> <?php $o_config = caGetGalleryConfig(); $va_access_values = caGetUserAccessValues($this->request); $va_sets = $this->getVar("sets"); $va_first_items_from_set = $this->getVar("first_items_from_sets"); print "<div class='container'>"; if (is_array($va_sets) && sizeof($va_sets)) { $t_set = new ca_sets(); foreach ($va_sets as $vn_set_id => $va_set) { $t_set->load($vn_set_id); print "<div class='row'>"; print "<div class='col-sm-12 col-sm-offset-0 col-md-6 col-md-offset-3 col-lg-6 col-lg-offset-3'><div class='galleryListItem'>"; $va_first_item = array_shift(array_shift($t_set->getFirstItemsFromSets(array($vn_set_id), array("version" => "small", "checkAccess" => $va_access_values)))); print "<div class='galleryListItemImg'>" . $va_first_item["representation_tag"] . "</div>"; print "<H3>" . $t_set->getLabelForDisplay() . "</H3>"; print "<p class='count'>" . $t_set->getItemCount(array("checkAccess" => $va_access_values)) . " items</p>"; if ($vs_description = $t_set->get($o_config->get('gallery_set_description_element_code'))) { print "<p><strong>" . $vs_description . "</strong></p>"; } print caNavLink($this->request, "<span class='glyphicon glyphicon-th-large'></span>", "", "", "Gallery", $t_set->get("set_id")) . " " . caNavLink($this->request, "<strong>" . _t("VIEW GALLERY") . "</strong>", "", "", "Gallery", $t_set->get("set_id")); print "<div style='clear:both;'></div></div></div></div>\n"; } } print "</div>"; ?> </div>
/** * Determines if user has access to a set at a specified access level. * * @param int $pn_user_id user_id of user to check set access for * @param int $pn_access type of access required. Use __CA_SET_READ_ACCESS__ for read-only access or __CA_SET_EDIT_ACCESS__ for editing (full) access * @param int $pn_set_id The id of the set to check. If omitted then currently loaded set will be checked. * @param array $pa_options No options yet * @return bool True if user has access, false if not */ public function haveAccessToSet($pn_user_id, $pn_access, $pn_set_id = null, $pa_options = null) { if ($this->getAppConfig()->get('dont_enforce_access_control_for_ca_sets')) { return true; } if ($pn_set_id) { $vn_set_id = $pn_set_id; $t_set = new ca_sets($vn_set_id); $vn_set_user_id = $t_set->get('user_id'); } else { $t_set = $this; $vn_set_user_id = $t_set->get('user_id'); } if (!$vn_set_id && !($vn_set_id = $t_set->getPrimaryKey())) { return true; // new set } if ($t_set->get('deleted') != 0) { return false; } // set is deleted if (isset(ca_sets::$s_have_access_to_set_cache[$vn_set_id . '/' . $pn_user_id . '/' . $pn_access])) { return ca_sets::$s_have_access_to_set_cache[$vn_set_id . '/' . $pn_user_id . '/' . $pn_access]; } if ($vn_set_user_id == $pn_user_id) { // owners have all access return ca_sets::$s_have_access_to_set_cache[$vn_set_id . '/' . $pn_user_id . '/' . $pn_access] = true; } if ($t_set->get('access') > 0 && $pn_access == __CA_SET_READ_ACCESS__) { // public sets are readable by all return ca_sets::$s_have_access_to_set_cache[$vn_set_id . '/' . $pn_user_id . '/' . $pn_access] = true; } // // If user is admin or has set admin privs allow them access to the set // $t_user = new ca_users(); if ($t_user->load($pn_user_id) && ($t_user->canDoAction('is_administrator') || $t_user->canDoAction('can_administrate_sets'))) { return ca_sets::$s_have_access_to_set_cache[$vn_set_id . '/' . $pn_user_id . '/' . $pn_access] = true; } $o_db = $this->getDb(); $qr_res = $o_db->query($vs_sql = "\n\t\t\tSELECT sxg.set_id \n\t\t\tFROM ca_sets_x_user_groups sxg \n\t\t\tINNER JOIN ca_user_groups AS ug ON sxg.group_id = ug.group_id\n\t\t\tINNER JOIN ca_users_x_groups AS uxg ON uxg.group_id = ug.group_id\n\t\t\tWHERE \n\t\t\t\t(sxg.access >= ?) AND (uxg.user_id = ?) AND (sxg.set_id = ?)\n\t\t\t\tAND\n\t\t\t\t(\n\t\t\t\t\t(sxg.sdatetime <= " . time() . " AND sxg.edatetime >= " . time() . ")\n\t\t\t\t\tOR\n\t\t\t\t\t(sxg.sdatetime IS NULL and sxg.edatetime IS NULL)\n\t\t\t\t)\n\t\t", (int) $pn_access, (int) $pn_user_id, (int) $vn_set_id); if ($qr_res->numRows() > 0) { return ca_sets::$s_have_access_to_set_cache[$vn_set_id . '/' . $pn_user_id . '/' . $pn_access] = true; } $qr_res = $o_db->query("\n\t\t\tSELECT sxu.set_id \n\t\t\tFROM ca_sets_x_users sxu\n\t\t\tINNER JOIN ca_users AS u ON sxu.user_id = u.user_id\n\t\t\tWHERE \n\t\t\t\t(sxu.access >= ?) AND (u.user_id = ?) AND (sxu.set_id = ?)\n\t\t\t\tAND\n\t\t\t\t(\n\t\t\t\t\t(sxu.sdatetime <= " . time() . " AND sxu.edatetime >= " . time() . ")\n\t\t\t\t\tOR\n\t\t\t\t\tsxu.sdatetime IS NULL and sxu.edatetime IS NULL\n\t\t\t\t)\n\t\t", (int) $pn_access, (int) $pn_user_id, (int) $vn_set_id); if ($qr_res->numRows() > 0) { return ca_sets::$s_have_access_to_set_cache[$vn_set_id . '/' . $pn_user_id . '/' . $pn_access] = true; } return ca_sets::$s_have_access_to_set_cache[$vn_set_id . '/' . $pn_user_id . '/' . $pn_access] = false; }
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * This source code is free and modifiable under the terms of * GNU General Public License. (http://www.gnu.org/copyleft/gpl.html). See * the "license.txt" file for details, or visit the CollectiveAccess web site at * http://www.CollectiveAccess.org * * ---------------------------------------------------------------------- */ JavascriptLoadManager::register("cycle"); $t_object = new ca_objects(); $va_access_values = caGetUserAccessValues($this->request); $t_featured = new ca_sets(); $t_featured->load(array('set_code' => $this->request->config->get('featured_set_name'))); # Enforce access control on set if (sizeof($va_access_values) == 0 || sizeof($va_access_values) && in_array($t_featured->get("access"), $va_access_values)) { $va_featured_ids = array_keys(is_array($va_tmp = $t_featured->getItemRowIDs(array('checkAccess' => $va_access_values, 'shuffle' => 0))) ? $va_tmp : array()); // These are the object ids in the set } $va_item_ids = $va_featured_ids; $va_item_media = $t_object->getPrimaryMediaForIDs($va_item_ids, array("mediumlarge", "widepreview", "splashpic")); $va_item_labels = $t_object->getPreferredDisplayLabelsForIDs($va_item_ids); $title_id = array_shift(array_keys($va_item_media)); $t_object = new ca_objects($title_id); $va_artist_name = $t_object->get('ca_entities.preferred_labels.displayname', array('restrictToRelationshipTypes' => array('artist'), 'delimiter' => ' and ')); ?> <h1 class='results'>Featured Art: <?php print $va_artist_name; ?> </h1>
/** * */ public function addItem() { global $g_ui_locale_id; // current locale_id for user if (!$this->request->isLoggedIn()) { $this->response->setRedirect(caNavUrl($this->request, '', 'LoginReg', 'form')); return; } if (!($t_set = $this->_getSet(__CA_SET_EDIT_ACCESS__))) { if ($t_set = $this->_getSet(__CA_SET_READ_ACCESS__)) { $this->view->setVar('message', _t("You can not add items to this set. You have read only access.")); $this->index(); return; } # --- if there is not a set for this user, make a new set for them $t_new_set = new ca_sets(); $vn_new_set_id = null; $t_new_set->setMode(ACCESS_WRITE); $t_new_set->set('access', 0); $t_new_set->set('table_num', 57); // 57=ca_objects $t_list = new ca_lists(); $vn_set_id = $t_list->getItemIDFromList('set_types', $this->request->config->get('user_set_type')); $t_new_set->set('type_id', $vn_set_id); $t_new_set->set('user_id', $this->request->getUserID()); $t_new_set->set('set_code', $this->request->getUserID() . '_' . time()); // create new attribute $t_new_set->insert(); if (!$t_new_set->numErrors()) { if ($vn_new_set_id = $t_new_set->getPrimaryKey()) { $t_new_set->addLabel(array('name' => _t("Your first lightbox")), $g_ui_locale_id, null, true); // select the current set $this->request->user->setVar('current_set_id', $vn_new_set_id); //clear t_new_set object so form appears blank and load t_set so edit form is populated $t_new_set = new ca_sets(); $t_set = new ca_sets($vn_new_set_id); } } } if (!$t_set) { $va_errors[] = _t('Could not create lightbox for user'); } else { $pn_item_id = null; $pn_object_id = $this->request->getParameter('object_id', pInteger); if (!$t_set->isInSet("ca_objects", $pn_object_id, $t_set->get("set_id"))) { if ($pn_item_id = $t_set->addItem($pn_object_id, array(), $this->request->getUserID())) { // // Select primary representation // $t_object = new ca_objects($pn_object_id); $vn_rep_id = $t_object->getPrimaryRepresentationID(); // get representation_id for primary $t_item = new ca_set_items($pn_item_id); $t_item->addSelectedRepresentation($vn_rep_id); // flag as selected in item vars $t_item->update(); $va_errors = array(); $this->view->setVar('message', _t("Successfully added item. %1Click here to resume your search%2.", "<a href='" . caNavUrl($this->request, "Detail", "Object", "Show", array("object_id" => $pn_object_id)) . "'>", "</a>")); } else { $va_errors[] = _t('Could not add item to lightbox'); } } else { $this->view->setVar('message', _t("Item already in set. %1Click here to resume your search%2.", "<a href='" . caNavUrl($this->request, "Detail", "Object", "Show", array("object_id" => $pn_object_id)) . "'>", "</a>")); } } //$t_row = new ca_objects($pn_object_id); $this->view->setVar('errors', $va_errors); $this->index(); }