Exemplo n.º 1
0
 /**
  *
  */
 private function _getActionsCollection($pn_collection_id, $pn_start = 0, $pn_num_actions = 10)
 {
     $o_search = new OccurrenceSearch();
     $o_search->setTypeRestrictions(array($this->opn_context_type_id, $this->opn_action_type_id));
     $o_search->addResultFilter("ca_occurrences.access", "IN", join(',', $this->opa_access_values));
     $qr_res = $o_search->search("ca_collections.collection_id:{$pn_collection_id}", array('sort' => 'ca_occurrences.date.dates_value', 'sort_direction' => 'asc'));
     $qr_res->seek($pn_start);
     $va_actions = array();
     $vn_c = 0;
     $t_occ = new ca_occurrences();
     while ($qr_res->nextHit()) {
         if (!($vs_date = trim($qr_res->get('ca_occurrences.date.dates_value', array('dateFormat' => 'delimited'))))) {
             continue;
         }
         if ($vs_date == 'present') {
             continue;
         }
         $va_silos = array();
         $va_projects = array();
         $t_occ->load($qr_res->get('ca_occurrences.occurrence_id'));
         $va_silos = $t_occ->get("ca_collections", array("restrictToTypes" => array("silo"), "returnAsArray" => 1, 'checkAccess' => $this->opa_access_values));
         # --- format silo icons here
         $vs_silos = "";
         if (is_array($va_silos) && sizeof($va_silos) > 0) {
             $vs_silos = "<div class='actionSiloIcons'>";
             foreach ($va_silos as $vn_i => $va_silo_info) {
                 $vs_bgColor = "";
                 switch ($va_silo_info["collection_id"]) {
                     case $this->request->config->get('silo_strawberry_flag'):
                         $vs_bgColor = $this->request->config->get('silo_strawberry_flag_bg');
                         break;
                         # --------------------------------------
                     # --------------------------------------
                     case $this->request->config->get('silo_silver_water'):
                         $vs_bgColor = $this->request->config->get('silo_silver_water_bg');
                         break;
                         # --------------------------------------
                     # --------------------------------------
                     default:
                         $vs_bgColor = "#000000";
                         break;
                 }
                 $vs_silos .= caNavLink($this->request, "<div class='actionSiloIcon siloIcon" . $va_silo_info["collection_id"] . "' style='background-color:" . $vs_bgColor . "'><!-- empty --></div>", '', 'Detail', 'Collection', 'Show', array('collection_id' => $va_silo_info["collection_id"]), array("title" => $va_silo_info["label"]));
             }
             $vs_silos .= "</div>";
         }
         $va_projects = $t_occ->get("ca_collections", array("restrictToTypes" => array("project"), "returnAsArray" => 1, 'checkAccess' => $this->opa_access_values));
         $va_timestamps = array_shift($qr_res->get('ca_occurrences.date.dates_value', array('rawDate' => true, 'returnAsArray' => true)));
         $va_actions[$vn_id = $qr_res->get('ca_occurrences.occurrence_id')] = array('occurrence_id' => $vn_id, 'label' => $qr_res->get('ca_occurrences.preferred_labels.name'), 'idno' => $qr_res->get('ca_occurrences.idno'), 'date' => $vs_date, 'timestamp' => $va_timestamps['start'], 'location' => $qr_res->get('ca_occurrences.georeference.geocode'), 'silos' => $va_silos, 'silos_formatted' => $vs_silos, 'projects' => $va_projects);
         $vn_c++;
         if ($vn_c >= $pn_num_actions) {
             break;
         }
     }
     return $va_actions;
 }
 *
 * ----------------------------------------------------------------------
 */
$t_entity = $this->getVar('t_item');
$vn_entity_id = $t_entity->getPrimaryKey();
$vs_title = $this->getVar('label');
$va_access_values = $this->getVar('access_values');
require_once __CA_LIB_DIR__ . '/ca/Search/OccurrenceSearch.php';
# --- get all actions associated with the entity so can visualize in chronology timeline
JavascriptLoadManager::register('jcarousel');
$t_list = new ca_lists();
$vn_action_type_id = $t_list->getItemIDFromList('occurrence_types', 'action');
$vn_context_type_id = $t_list->getItemIDFromList('occurrence_types', 'context');
$o_search = new OccurrenceSearch();
$o_search->setTypeRestrictions(array($vn_context_type_id, $vn_action_type_id));
$o_search->addResultFilter("ca_occurrences.access", "IN", join(',', $va_access_values));
$qr_res = $o_search->search("ca_entities.entity_id:{$vn_entity_id}", array('sort' => 'ca_occurrences.date.dates_value', 'sort_direction' => 'asc'));
$va_actions = array();
$va_action_map = array();
if ($qr_res->numHits() > 0) {
    $t_occ = new ca_occurrences();
    $i = 0;
    while ($qr_res->nextHit() && $i <= 25) {
        $va_silos = array();
        $va_projects = array();
        $t_occ->load($qr_res->get('ca_occurrences.occurrence_id'));
        $va_silos = $t_occ->get("ca_collections", array("restrictToTypes" => array("silo"), "returnAsArray" => 1, 'checkAccess' => $va_access_values));
        $va_projects = $t_occ->get("ca_collections", array("restrictToTypes" => array("project"), "returnAsArray" => 1, 'checkAccess' => $va_access_values));
        if (!($vs_date = trim($qr_res->get('ca_occurrences.date.dates_value', array('dateFormat' => 'delimited'))))) {
            continue;
        }