public function info($pa_parameters)
 {
     parent::info($pa_parameters);
     if ($t_item = $this->view->getVar('t_item')) {
         if (!($vn_tour_id = $t_item->get('tour_id'))) {
             $t_parent = new ca_list_items($this->request->getParameter('parent_id', pInteger));
             $vn_tour_id = $t_parent->get('tour_id');
         }
     }
     $t_tour = new ca_tours($vn_tour_id);
     $this->view->setVar('t_tour', $t_tour);
     return $this->render('widget_tour_stop_info_html.php', true);
 }
 public function getDisplaysAsXML()
 {
     $t_display = new ca_bundle_displays();
     /** @var Datamodel $o_dm */
     $o_dm = Datamodel::load();
     $this->opt_locale = new ca_locales();
     $va_displays = $t_display->getBundleDisplays();
     $vs_buf = "<displays>\n";
     foreach ($va_displays as $vn_i => $va_display_by_locale) {
         $va_locales = array_keys($va_display_by_locale);
         $va_info = $va_display_by_locale[$va_locales[0]];
         if (!$t_display->load($va_info['display_id'])) {
             continue;
         }
         $vs_buf .= "\t<display code='" . ($va_info['display_code'] && preg_match('!^[A-Za-z0-9_]+$!', $va_info['display_code']) ? $va_info['display_code'] : 'display_' . $va_info['display_id']) . "' type='" . $o_dm->getTableName($va_info['table_num']) . "' system='" . $t_display->get('is_system') . "'>\n";
         $vs_buf .= "\t\t<labels>\n";
         foreach ($va_display_by_locale as $vn_locale_id => $va_display_info) {
             if (strlen($this->opt_locale->localeIDToCode($vn_locale_id)) > 0) {
                 $vs_buf .= "\t\t\t<label locale='" . $this->opt_locale->localeIDToCode($vn_locale_id) . "'><name>" . caEscapeForXML($va_display_info['name']) . "</name></label>\n";
             }
         }
         $vs_buf .= "\t\t</labels>\n";
         $va_settings = $t_display->getSettings();
         if (sizeof($va_settings) > 0) {
             $vs_buf .= "\t\t<settings>\n";
             foreach ($va_settings as $vs_setting => $vm_val) {
                 if (is_array($vm_val)) {
                     foreach ($vm_val as $vn_i => $vn_val) {
                         $vs_buf .= "\t\t\t<setting name='{$vs_setting}'><![CDATA[" . $vn_val . "]]></setting>\n";
                     }
                 } else {
                     $vs_buf .= "\t\t\t<setting name='{$vs_setting}'><![CDATA[" . $vm_val . "]]></setting>\n";
                 }
             }
             $vs_buf .= "\t\t</settings>\n";
         }
         // User and group access
         $va_users = $t_display->getUsers();
         if (sizeof($va_users) > 0) {
             $vs_buf .= "\t\t<userAccess>\n";
             foreach ($va_users as $va_user_info) {
                 $vs_buf .= "\t\t\t<permission user='******' access='" . $this->_convertUserGroupAccessToString(intval($va_user_info['access'])) . "'/>\n";
             }
             $vs_buf .= "\t\t</userAccess>\n";
         }
         $va_groups = $t_display->getUserGroups();
         if (sizeof($va_groups) > 0) {
             $vs_buf .= "\t\t<groupAccess>\n";
             foreach ($va_groups as $va_group_info) {
                 $vs_buf .= "\t\t\t<permission group='" . $va_group_info["code"] . "' access='" . $this->_convertUserGroupAccessToString(intval($va_group_info['access'])) . "'/>\n";
             }
             $vs_buf .= "\t\t</groupAccess>\n";
         }
         $va_placements = $t_display->getPlacements();
         $vs_buf .= "<bundlePlacements>\n";
         foreach ($va_placements as $vn_placement_id => $va_placement_info) {
             $vs_buf .= "\t\t<placement code='" . preg_replace("![^A-Za-z0-9_]+!", "_", $va_placement_info['bundle_name']) . "'><bundle>" . $va_placement_info['bundle_name'] . "</bundle>\n";
             $va_settings = caUnserializeForDatabase($va_placement_info['settings']);
             if (is_array($va_settings)) {
                 $vs_buf .= "<settings>\n";
                 foreach ($va_settings as $vs_setting => $vm_value) {
                     switch ($vs_setting) {
                         case 'label':
                             if (is_array($vm_value)) {
                                 foreach ($vm_value as $vn_locale_id => $vm_locale_specific_value) {
                                     if (preg_match("/^[a-z]{2,3}\\_[A-Z]{2,3}\$/", $vn_locale_id)) {
                                         // locale code
                                         $vs_locale_code = $vn_locale_id;
                                     } else {
                                         if (!($vs_locale_code = $this->opt_locale->localeIDToCode($vn_locale_id))) {
                                             $vs_locale_code = 'en_US';
                                         }
                                     }
                                     $vs_buf .= "<setting name='label' locale='" . $vs_locale_code . "'>" . caEscapeForXML($vm_locale_specific_value) . "</setting>\n";
                                 }
                             }
                             break;
                         case 'restrict_to_relationship_types':
                             if (is_array($vm_value)) {
                                 foreach ($vm_value as $vn_val) {
                                     $t_rel_type = new ca_relationship_types($vn_val);
                                     if ($t_rel_type->getPrimaryKey()) {
                                         $vs_value = $t_rel_type->get('type_code');
                                         $vs_buf .= "\t\t\t\t<setting name='{$vs_setting}'><![CDATA[" . $vs_value . "]]></setting>\n";
                                     }
                                 }
                             }
                             break;
                         case 'restrict_to_types':
                             if (is_array($vm_value)) {
                                 foreach ($vm_value as $vn_val) {
                                     $t_item = new ca_list_items($vn_val);
                                     if ($t_item->getPrimaryKey()) {
                                         $vs_value = $t_item->get('idno');
                                         $vs_buf .= "\t\t\t\t<setting name='{$vs_setting}'><![CDATA[" . $vs_value . "]]></setting>\n";
                                     }
                                 }
                             }
                             break;
                         default:
                             if (is_array($vm_value)) {
                                 foreach ($vm_value as $vn_i => $vn_val) {
                                     $vs_buf .= "\t\t\t\t<setting name='{$vs_setting}'><![CDATA[" . $vn_val . "]]></setting>\n";
                                 }
                             } else {
                                 $vs_buf .= "\t\t\t\t<setting name='{$vs_setting}'><![CDATA[" . $vm_value . "]]></setting>\n";
                             }
                             break;
                     }
                 }
                 $vs_buf .= "</settings>\n";
             }
             $vs_buf .= "\t\t</placement>\n";
         }
         $vs_buf .= "</bundlePlacements>\n";
         $vs_buf .= "\t</display>\n";
     }
     $vs_buf .= "</displays>\n";
     return $vs_buf;
 }
Пример #3
0
 /**
  * @param mixed $ps_value
  * @param array $pa_element_info
  * @param array $pa_options Options are:
  *		alwaysTreatValueAsIdno = Always try to convert $ps_value to a list idno value, even if it is numeric
  *
  * @return array
  */
 public function parseValue($ps_value, $pa_element_info, $pa_options = null)
 {
     $vb_treat_value_as_idno = caGetOption('alwaysTreatValueAsIdno', $pa_options, false);
     $vb_require_value = is_null($pa_element_info['settings']['requireValue']) ? true : (bool) $pa_element_info['settings']['requireValue'];
     if ($vb_treat_value_as_idno || preg_match('![^\\d]+!', $ps_value)) {
         // try to convert idno to item_id
         if ($vn_id = ca_lists::getItemID($pa_element_info['list_id'], $ps_value)) {
             $ps_value = $vn_id;
         }
     }
     if (!$vb_require_value && !(int) $ps_value) {
         return array('value_longtext1' => null, 'item_id' => null);
     }
     if (strlen($ps_value) && !is_numeric($ps_value)) {
         $this->postError(1970, _t('Item_id %2 is not valid for element %1', $pa_element_info["element_code"], $ps_value), 'ListAttributeValue->parseValue()');
         return false;
     }
     $t_item = new ca_list_items((int) $ps_value);
     if (!$t_item->getPrimaryKey()) {
         if ($ps_value) {
             $this->postError(1970, _t('%1 is not a valid list item_id for %2 [%3]', $ps_value, $pa_element_info['displayLabel'], $pa_element_info['element_code']), 'ListAttributeValue->parseValue()');
         } else {
             //$this->postError(1970, _t('Value %1 [%2] cannot be blank', $pa_element_info['displayLabel'], $pa_element_info['element_code']), 'ListAttributeValue->parseValue()');
             return null;
         }
         return false;
     }
     if ((int) $t_item->get('list_id') != (int) $pa_element_info['list_id']) {
         $this->postError(1970, _t('Item is not in the correct list for element %1. List id is %2 but should be %3', $pa_element_info["element_code"], $t_item->get('list_id'), $pa_element_info['list_id']), 'ListAttributeValue->parseValue()');
         return false;
     }
     return array('value_longtext1' => $ps_value, 'item_id' => (int) $ps_value);
 }
Пример #4
0
                $va_resp['subList'] .= "<li><a href='#' onClick='\$(\"#tocSubList" . $vn_i . "\").toggle(); return false;'>+ " . $va_item['name_plural'] . "</a></li>\n";
                $va_resp['subList'] .= "<ul class='tocSubSubMenu' id='tocSubList" . $vn_i . "'>";
                foreach ($va_list_sub_sub_items as $vn_sub_i => $va_subitem) {
                    #$va_resp['subList'] .= "<li>".caNavLink($this->request, $va_subitem['name_plural'], '', '', 'Browse', 'Objects', array('facet' => 'term_facet', 'id' => $vn_sub_i))."</li>\n";
                    $va_resp['subList'] .= "<li>" . caNavLink($this->request, $va_subitem['name_plural'], '', '', 'MultiSearch', 'Index', array('search' => 'ca_list_items.item_id:' . $vn_sub_i)) . "</li>\n";
                }
                $va_resp['subList'] .= "</ul>";
            } else {
                #$va_resp['subList'] .= "<li>".caNavLink($this->request, $va_item['name_plural'], '', '', 'Browse', 'Objects', array('facet' => 'term_facet', 'id' => $vn_i))."</li>\n";
                $va_resp['subList'] .= "<li>" . caNavLink($this->request, $va_item['name_plural'], '', '', 'MultiSearch', 'Index', array('search' => 'ca_list_items.item_id:' . $vn_i)) . "</li>\n";
            }
        }
    }
    require_once __CA_MODELS_DIR__ . "/ca_list_items.php";
    $t_list_item = new ca_list_items($vn_item_id);
    $va_resp['selectedTitle'] = $t_list_item->get('ca_list_items.preferred_labels.name_plural');
    $va_resp['selectedDescription'] = $t_list_item->get('ca_list_items.preferred_labels.description') . "<br/><br>" . caNavLink($this->request, _t('View'), '', '', 'MultiSearch', 'Index', array('search' => 'ca_list_items.item_id:' . $vn_item_id));
    print json_encode($va_resp);
    return;
}
?>

<script type="text/javascript">
	function caFrontLoadSubList(item_id) {
		jQuery.getJSON('<?php 
print caNavUrl($this->request, '*', '*', '*');
?>
', {item_id: item_id}, function(data) {
			console.log("data", data);
			jQuery("#tocTopTitle").html(data['selectedTitle']);
			
Пример #5
0
/**
 * 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 .= "&nbsp;<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 .= "&nbsp;&nbsp;<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;
}
Пример #6
0
 /**
  * Get a record summary that is easier to parse when importing to another system
  */
 private function getItemInfoForImport()
 {
     if (!($t_instance = $this->_getTableInstance($this->ops_table, $this->opn_id))) {
         return false;
     }
     $o_dm = Datamodel::load();
     $t_list = new ca_lists();
     $t_locales = new ca_locales();
     //
     // Options
     //
     if (!($vs_delimiter = $this->opo_request->getParameter('delimiter', pString))) {
         $vs_delimiter = "; ";
     }
     if (!($vs_flatten = $this->opo_request->getParameter('flatten', pString))) {
         $vs_flatten = null;
     }
     $va_flatten = preg_split("![ ]*[;]+[ ]*!", $vs_flatten);
     $va_flatten = array_flip($va_flatten);
     $va_locales = $t_locales->getLocaleList(array("available_for_cataloguing_only" => true));
     $va_return = array();
     // allow user-defined template to be passed; allows flexible formatting of returned "display" value
     if (!($vs_template = $this->opo_request->getParameter('template', pString))) {
         $vs_template = '';
     }
     if ($vs_template) {
         $va_return['display'] = caProcessTemplateForIDs($vs_template, $this->ops_table, array($this->opn_id));
     }
     // "intrinsic" fields
     foreach ($t_instance->getFieldsArray() as $vs_field_name => $va_field_info) {
         $vs_list = null;
         if (!is_null($vs_val = $t_instance->get($vs_field_name))) {
             if (preg_match("/^hier\\_/", $vs_field_name)) {
                 continue;
             }
             if (preg_match("/\\_sort\$/", $vs_field_name)) {
                 continue;
             }
             if ($vs_field_name == $t_instance->primaryKey()) {
                 continue;
             }
             if (isset($va_field_info["LIST_CODE"])) {
                 // typical example: type_id
                 $va_item = $t_list->getItemFromListByItemID($va_field_info["LIST_CODE"], $vs_val);
                 if ($t_item = new ca_list_items($va_item["item_id"])) {
                     $vs_val = $t_item->get('idno');
                 }
             }
             $va_return['intrinsic'][$vs_field_name] = $vs_val;
         }
     }
     // preferred labels
     $va_labels = $t_instance->get($this->ops_table . ".preferred_labels", array("returnAllLocales" => true));
     $va_labels = end($va_labels);
     $vs_display_field_name = $t_instance->getLabelDisplayField();
     if (is_array($va_labels)) {
         foreach ($va_labels as $vn_locale_id => $va_labels_by_locale) {
             foreach ($va_labels_by_locale as $va_tmp) {
                 $va_label = array();
                 $va_label['locale'] = $va_locales[$vn_locale_id]["code"];
                 // add only UI fields to return
                 foreach (array_merge($t_instance->getLabelUIFields(), array('type_id')) as $vs_label_fld) {
                     $va_label[$vs_label_fld] = $va_tmp[$vs_label_fld];
                 }
                 $va_label[$vs_label_fld] = $va_tmp[$vs_label_fld];
                 $va_label['label'] = $va_tmp[$vs_display_field_name];
                 $va_return["preferred_labels"][$va_label['locale']] = $va_label;
             }
         }
         if (isset($va_flatten['locales'])) {
             $va_return["preferred_labels"] = array_pop(caExtractValuesByUserLocale(array($va_return["preferred_labels"])));
         }
     }
     // nonpreferred labels
     $va_labels = $t_instance->get($this->ops_table . ".nonpreferred_labels", array("returnAllLocales" => true));
     $va_labels = end($va_labels);
     if (is_array($va_labels)) {
         foreach ($va_labels as $vn_locale_id => $va_labels_by_locale) {
             foreach ($va_labels_by_locale as $va_tmp) {
                 $va_label = array();
                 $va_label['locale'] = $va_locales[$vn_locale_id]["code"];
                 // add only UI fields to return
                 foreach (array_merge($t_instance->getLabelUIFields(), array('type_id')) as $vs_label_fld) {
                     $va_label[$vs_label_fld] = $va_tmp[$vs_label_fld];
                 }
                 $va_return["nonpreferred_labels"][$va_label['locale']] = $va_label;
             }
         }
         if (isset($va_flatten['locales'])) {
             $va_return["nonpreferred_labels"] = array_pop(caExtractValuesByUserLocale(array($va_return["nonpreferred_labels"])));
         }
     }
     // attributes
     $va_codes = $t_instance->getApplicableElementCodes();
     foreach ($va_codes as $vs_code) {
         if ($va_vals = $t_instance->get($this->ops_table . "." . $vs_code, array("convertCodesToDisplayText" => false, "returnAllLocales" => true))) {
             $va_vals_as_text = end($t_instance->get($this->ops_table . "." . $vs_code, array("convertCodesToDisplayText" => true, "returnAllLocales" => true)));
             $va_vals_by_locale = end($va_vals);
             foreach ($va_vals_by_locale as $vn_locale_id => $va_locale_vals) {
                 foreach ($va_locale_vals as $vs_val_id => $va_actual_data) {
                     if (!is_array($va_actual_data)) {
                         continue;
                     }
                     $vs_locale_code = isset($va_locales[$vn_locale_id]["code"]) ? $va_locales[$vn_locale_id]["code"] : "none";
                     foreach ($va_actual_data as $vs_f => $vs_v) {
                         if (isset($va_vals_as_text[$vn_locale_id][$vs_val_id][$vs_f]) && $vs_v != $va_vals_as_text[$vn_locale_id][$vs_val_id][$vs_f]) {
                             $va_actual_data[$vs_f . '_display'] = $va_vals_as_text[$vn_locale_id][$vs_val_id][$vs_f];
                             if ($vs_item_idno = caGetListItemIdno($va_actual_data[$vs_f])) {
                                 $va_actual_data[$vs_f] = $vs_item_idno;
                             }
                         }
                     }
                     $va_return['attributes'][$vs_code][$vs_locale_code][] = array_merge(array('locale' => $vs_locale_code), $va_actual_data);
                 }
             }
         }
     }
     if (isset($va_flatten['locales'])) {
         $va_return['attributes'] = caExtractValuesByUserLocale($va_return['attributes']);
     }
     // relationships
     // yes, not all combinations between these tables have
     // relationships but it also doesn't hurt to query
     foreach ($this->opa_valid_tables as $vs_rel_table) {
         $t_rel = $o_dm->getInstanceByTableName($vs_rel_table, true);
         //
         // set-related hacks
         if ($this->ops_table == "ca_sets" && $vs_rel_table == "ca_tours") {
             // throw SQL error in getRelatedItems
             continue;
         }
         $va_related_items = $t_instance->get($vs_rel_table, array("returnAsArray" => true, 'returnLocaleCodes' => true, 'groupFields' => true));
         if ($this->ops_table == "ca_objects" && $vs_rel_table == "ca_object_representations") {
             $va_versions = $t_instance->getMediaVersions('media');
             if (isset($va_flatten['all'])) {
                 $va_reps = $t_instance->getRepresentations(array('original'));
                 $va_urls = array();
                 foreach ($va_reps as $vn_i => $va_rep) {
                     $va_urls[] = $va_rep['urls']['original'];
                 }
                 $va_return['representations'] = join($vs_delimiter, $va_urls);
             } else {
                 $va_return['representations'] = $t_instance->getRepresentations($va_versions);
             }
             foreach ($va_return['representations'] as $vn_i => $va_rep) {
                 unset($va_return['representations'][$vn_i]['media']);
                 unset($va_return['representations'][$vn_i]['media_metadata']);
             }
         }
         if (is_array($va_related_items) && sizeof($va_related_items) > 0) {
             foreach ($va_related_items as $va_rel_item) {
                 $va_item_add = array();
                 foreach ($va_rel_item as $vs_fld => $vs_val) {
                     if (!is_array($vs_val) && strlen(trim($vs_val)) > 0) {
                         // rewrite and ignore certain field names
                         switch ($vs_fld) {
                             case 'item_type_id':
                                 $va_item_add[$vs_fld] = $vs_val;
                                 $va_item_add['type_id'] = $vs_val;
                                 break;
                             default:
                                 $va_item_add[$vs_fld] = $vs_val;
                                 break;
                         }
                     } else {
                         if (in_array($vs_fld, array('preferred_labels', 'intrinsic'))) {
                             $va_item_add[$vs_fld] = $vs_val;
                         }
                     }
                 }
                 if ($vs_rel_table == "ca_object_representations") {
                     $t_rep = new ca_object_representations($va_rel_item['representation_id']);
                     $va_item_add['media'] = $t_rep->getMediaUrl('media', 'original');
                 }
                 $va_return["related"][$vs_rel_table][] = $va_item_add;
             }
         }
     }
     return $va_return;
 }
Пример #7
0
    /**
     * Indexes single row in a table; this is the public call when one needs to index content.
     * indexRow() will analyze the dependencies of the row being indexed and automatically
     * apply the indexing of the row to all dependent rows in other tables.  (Note that while I call this
     * a "public" call in fact you shouldn't need to call this directly. BaseModel.php does this for you
     * during insert() and update().)
     *
     * For example, if you are indexing a row in table 'entities', then indexRow()
     * will automatically apply the indexing not just to the entities record, but also
     * to all objects, place_names, occurrences, lots, etc. that reference the entity.
     * The dependencies are configured in the search_indices.conf configuration file.
     *
     * "subject" tablenum/row_id refer to the row **to which the indexing is being applied**. This may be the row being indexed
     * or it may be a dependent row. The "content" tablenum/fieldnum/row_id parameters define the specific row and field being indexed.
     * This is always the actual row being indexed. $pm_content is the content to be indexed and $pa_options is an optional associative
     * array of indexing options passed through from the search_indices.conf (no options are defined yet - but will be soon)
     */
    public function indexRow($pn_subject_tablenum, $pn_subject_row_id, $pa_field_data, $pb_reindex_mode = false, $pa_exclusion_list = null, $pa_changed_fields = null, $pa_old_values = null, $pa_options = null)
    {
        if (!$pb_reindex_mode && is_array($pa_changed_fields) && !sizeof($pa_changed_fields)) {
            return;
        }
        // don't bother indexing if there are no changed fields
        $vs_subject_tablename = $this->opo_datamodel->getTableName($pn_subject_tablenum);
        $t_subject = $this->getTableInstance($vs_subject_tablename, true);
        // Prevent endless recursive reindexing
        if (is_array($pa_exclusion_list[$pn_subject_tablenum]) && isset($pa_exclusion_list[$pn_subject_tablenum][$pn_subject_row_id])) {
            return;
        }
        $vb_reindex_children = false;
        $vs_subject_pk = $t_subject->primaryKey();
        if (!is_array($pa_changed_fields)) {
            $pa_changed_fields = array();
        }
        foreach ($pa_changed_fields as $vs_k => $vb_bool) {
            if (!isset($pa_field_data[$vs_k])) {
                $pa_field_data[$vs_k] = null;
            }
        }
        $vb_can_do_incremental_indexing = $this->opo_engine->can('incremental_reindexing') ? true : false;
        // can the engine do incremental indexing? Or do we need to reindex the entire row every time?
        foreach ($this->opo_search_config->get('search_indexing_replacements') as $vs_to_replace => $vs_replacement) {
            foreach ($pa_field_data as $vs_k => &$vs_value) {
                if ($vs_replacement == "nothing") {
                    $vs_replacement = "";
                }
                $vs_value = str_replace($vs_to_replace, $vs_replacement, $vs_value);
            }
        }
        if (!$pa_exclusion_list) {
            $pa_exclusion_list = array();
        }
        $pa_exclusion_list[$pn_subject_tablenum][$pn_subject_row_id] = true;
        //
        // index fields in subject table itself
        //
        $va_fields_to_index = $this->getFieldsToIndex($pn_subject_tablenum);
        if (is_array($va_fields_to_index)) {
            foreach ($va_fields_to_index as $vs_k => $va_data) {
                if (preg_match('!^ca_attribute_(.*)$!', $vs_k, $va_matches)) {
                    if (!is_numeric($va_matches[1])) {
                        if ($vn_x = $this->_getElementID($va_matches[1])) {
                            $va_matches[1] = $vn_x;
                        } else {
                            unset($va_fields_to_index[$vs_k]);
                            continue;
                        }
                    }
                    unset($va_fields_to_index[$vs_k]);
                    if ($va_data['DONT_INDEX']) {
                        // remove attribute from indexing list
                        unset($va_fields_to_index['_ca_attribute_' . $va_matches[1]]);
                    } else {
                        $va_fields_to_index['_ca_attribute_' . $va_matches[1]] = $va_data;
                    }
                }
            }
        }
        //
        // If location in hierarchy has changed we need to reindex this record and all of its children
        //
        if ($t_subject->isHierarchical() && isset($pa_changed_fields['parent_id']) && $pa_changed_fields['parent_id'] && method_exists($t_subject, "makeSearchResult")) {
            $pb_reindex_mode = true;
            $vb_reindex_children = true;
        }
        $vb_started_indexing = false;
        if (is_array($va_fields_to_index)) {
            $this->opo_engine->startRowIndexing($pn_subject_tablenum, $pn_subject_row_id);
            $vb_started_indexing = true;
            foreach ($va_fields_to_index as $vs_field => $va_data) {
                if (substr($vs_field, 0, 14) === '_ca_attribute_') {
                    //
                    // Is attribute
                    //
                    $vs_v = $pa_field_data[$vs_field];
                    if (!preg_match('!^_ca_attribute_(.*)$!', $vs_field, $va_matches)) {
                        continue;
                    }
                    if ($vb_can_do_incremental_indexing && !$pb_reindex_mode && (!isset($pa_changed_fields[$vs_field]) || !$pa_changed_fields[$vs_field])) {
                        continue;
                        // skip unchanged attribute value
                    }
                    if ($va_data['DONT_INDEX'] && is_array($va_data['DONT_INDEX'])) {
                        $vb_cont = false;
                        foreach ($va_data["DONT_INDEX"] as $vs_exclude_type) {
                            if ($this->_getElementID($vs_exclude_type) == intval($va_matches[1])) {
                                $vb_cont = true;
                                break;
                            }
                        }
                        if ($vb_cont) {
                            continue;
                        }
                        // skip excluded attribute type
                    }
                    $va_data['datatype'] = (int) $this->_getElementDataType($va_matches[1]);
                    switch ($va_data['datatype']) {
                        case 0:
                            // container
                            // index components of complex multi-value attributes
                            $va_attributes = $t_subject->getAttributesByElement($va_matches[1], array('row_id' => $pn_subject_row_id));
                            if (sizeof($va_attributes)) {
                                foreach ($va_attributes as $vo_attribute) {
                                    /* index each element of the container */
                                    foreach ($vo_attribute->getValues() as $vo_value) {
                                        $vn_list_id = $this->_getElementListID($vo_value->getElementID());
                                        $this->opo_engine->indexField($pn_subject_tablenum, 'A' . $vo_value->getElementID(), $vo_attribute->getAttributeID(), $vo_value->getDisplayValue($vn_list_id), $va_data);
                                    }
                                }
                            } else {
                                // we are deleting a container so cleanup existing sub-values
                                $va_sub_elements = $this->opo_metadata_element->getElementsInSet($va_matches[1]);
                                foreach ($va_sub_elements as $vn_i => $va_element_info) {
                                    $this->opo_engine->indexField($pn_subject_tablenum, 'A' . $va_element_info['element_id'], $va_element_info['element_id'], '', $va_data);
                                }
                            }
                            break;
                        case 3:
                            // list
                            // We pull the preferred labels of list items for indexing here. We do so for all languages. Note that
                            // this only done for list attributes that are standalone and not a sub-element in a container. Perhaps
                            // we should also index the text of sub-element lists, but it's not clear that it is a good idea yet. The list_id's of
                            // sub-elements *are* indexed however, so advanced search forms passing ids instead of text will work.
                            $va_tmp = array();
                            if (is_array($va_attributes = $t_subject->getAttributesByElement($va_matches[1], array('row_id' => $pn_subject_row_id)))) {
                                foreach ($va_attributes as $vo_attribute) {
                                    foreach ($vo_attribute->getValues() as $vo_value) {
                                        $va_tmp[$vo_attribute->getAttributeID()] = $vo_value->getDisplayValue();
                                    }
                                }
                            }
                            $va_new_values = array();
                            $t_item = new ca_list_items();
                            $va_labels = $t_item->getPreferredDisplayLabelsForIDs($va_tmp, array('returnAllLocales' => true));
                            foreach ($va_labels as $vn_row_id => $va_labels_per_row) {
                                foreach ($va_labels_per_row as $vn_locale_id => $va_label_list) {
                                    foreach ($va_label_list as $vs_label) {
                                        $va_new_values[$vn_row_id][$vs_label] = true;
                                    }
                                }
                            }
                            foreach ($va_tmp as $vn_attribute_id => $vn_item_id) {
                                if (!$vn_item_id) {
                                    continue;
                                }
                                if (!isset($va_new_values[$vn_item_id]) || !is_array($va_new_values[$vn_item_id])) {
                                    continue;
                                }
                                $vs_v = join(' ;  ', array_merge(array($vn_item_id), array_keys($va_new_values[$vn_item_id])));
                                $this->opo_engine->indexField($pn_subject_tablenum, 'A' . $va_matches[1], $vn_attribute_id, $vs_v, $va_data);
                            }
                            break;
                        default:
                            $va_attributes = $t_subject->getAttributesByElement($va_matches[1], array('row_id' => $pn_subject_row_id));
                            if (!is_array($va_attributes)) {
                                break;
                            }
                            foreach ($va_attributes as $vo_attribute) {
                                foreach ($vo_attribute->getValues() as $vo_value) {
                                    //if the field is a daterange type get content from start and end fields
                                    $va_field_list = $t_subject->getFieldsArray();
                                    if (in_array($va_field_list[$vs_field]['FIELD_TYPE'], array(FT_DATERANGE, FT_HISTORIC_DATERANGE))) {
                                        $start_field = $va_field_list[$vs_field]['START'];
                                        $end_field = $va_field_list[$vs_field]['END'];
                                        $pn_content = $pa_field_data[$start_field] . " - " . $pa_field_data[$end_field];
                                    } else {
                                        $pn_content = $vo_value->getDisplayValue();
                                    }
                                    $this->opo_engine->indexField($pn_subject_tablenum, 'A' . $va_matches[1], $vo_attribute->getAttributeID(), $pn_content, $va_data);
                                }
                            }
                            break;
                    }
                } else {
                    //
                    // Plain old field
                    //
                    if ($vb_can_do_incremental_indexing && !$pb_reindex_mode && !isset($pa_changed_fields[$vs_field]) && $vs_field != $vs_subject_pk) {
                        // skip unchanged
                        continue;
                    }
                    if (!($vn_fld_num = $t_subject->fieldNum($vs_field))) {
                        continue;
                    }
                    //
                    // Hierarchical indexing in primary table
                    //
                    if (isset($va_data['INDEX_ANCESTORS']) && $va_data['INDEX_ANCESTORS'] || in_array('INDEX_ANCESTORS', $va_data)) {
                        if ($t_subject && $t_subject->isHierarchical()) {
                            $vn_fld_num = $t_subject->fieldNum($vs_field);
                            if ($va_hier_values = $this->_genHierarchicalPath($pn_subject_row_id, $vs_field, $t_subject, $va_data)) {
                                $this->opo_engine->indexField($pn_subject_tablenum, 'I' . $vn_fld_num, $pn_subject_row_id, join(" ", $va_hier_values['values']), $va_data);
                                if (caGetOption('INDEX_ANCESTORS_AS_PATH_WITH_DELIMITER', $va_data, false) !== false) {
                                    $this->opo_engine->indexField($pn_subject_tablenum, 'I' . $vn_fld_num, $pn_subject_row_id, $va_hier_values['path'], array_merge($va_data, array('DONT_TOKENIZE' => 1)));
                                }
                            }
                            $va_children_ids = $t_subject->getHierarchyAsList($pn_subject_row_id, array('idsOnly' => true));
                            if (!$pb_reindex_mode && is_array($va_children_ids) && sizeof($va_children_ids) > 0) {
                                // trigger reindexing of children
                                $o_indexer = new SearchIndexer($this->opo_db);
                                $qr_children_res = $t_subject->makeSearchResult($vs_subject_tablename, $va_children_ids);
                                while ($qr_children_res->nextHit()) {
                                    $o_indexer->indexRow($pn_subject_tablenum, $vn_id = $qr_children_res->get($vs_subject_pk), array($vs_subject_pk => $vn_id, 'parent_id' => $qr_children_res->get('parent_id'), $vs_field => $qr_children_res->get($vs_field)), false, $pa_exclusion_list, array($vs_field => true), null);
                                }
                            }
                            continue;
                        }
                    }
                    // specialized identifier (idno) processing; used IDNumbering plugin to generate searchable permutations of identifier
                    if ((isset($va_data['INDEX_AS_IDNO']) && $va_data['INDEX_AS_IDNO'] || in_array('INDEX_AS_IDNO', $va_data)) && method_exists($t_subject, "getIDNoPlugInInstance") && ($o_idno = $t_subject->getIDNoPlugInInstance())) {
                        $va_values = $o_idno->getIndexValues($pa_field_data[$vs_field]);
                        $vn_fld_num = $t_subject->fieldNum($vs_field);
                        $this->opo_engine->indexField($pn_subject_tablenum, 'I' . $vn_fld_num, $pn_subject_row_id, join(" ", $va_values), $va_data);
                        continue;
                    }
                    $va_field_list = $t_subject->getFieldsArray();
                    if (in_array($va_field_list[$vs_field]['FIELD_TYPE'], array(FT_DATERANGE, FT_HISTORIC_DATERANGE))) {
                        // if the field is a daterange type get content from start and end fields
                        $start_field = $va_field_list[$vs_field]['START'];
                        $end_field = $va_field_list[$vs_field]['END'];
                        $pn_content = $pa_field_data[$start_field] . " - " . $pa_field_data[$end_field];
                    } else {
                        $va_content = array();
                        if (isset($va_field_list[$vs_field]['LIST_CODE']) && $va_field_list[$vs_field]['LIST_CODE']) {
                            // Is reference to list item so index preferred label values
                            $t_item = new ca_list_items((int) $pa_field_data[$vs_field]);
                            $va_labels = $t_item->getPreferredDisplayLabelsForIDs(array((int) $pa_field_data[$vs_field]), array('returnAllLocales' => true));
                            foreach ($va_labels as $vn_label_row_id => $va_labels_per_row) {
                                foreach ($va_labels_per_row as $vn_locale_id => $va_label_list) {
                                    foreach ($va_label_list as $vs_label) {
                                        $va_content[$vs_label] = true;
                                    }
                                }
                            }
                            $va_content[$t_item->get('idno')] = true;
                        } else {
                            // is this field related to something?
                            if (is_array($va_rels = $this->opo_datamodel->getManyToOneRelations($vs_subject_tablename)) && $va_rels[$vs_field]) {
                                if (isset($va_rels[$vs_field])) {
                                    if ($pa_changed_fields[$vs_field]) {
                                        $pb_reindex_mode = true;
                                        // trigger full reindex of record so it reflects text of related item (if so indexed)
                                    }
                                }
                                $this->opo_engine->indexField($pn_subject_tablenum, 'I' . $vn_fld_num, $pn_subject_row_id, $pn_content, $va_data);
                            }
                        }
                        $va_content[$pa_field_data[$vs_field]] = true;
                        $this->opo_engine->indexField($pn_subject_tablenum, 'I' . $vn_fld_num, $pn_subject_row_id, join(" ", array_keys($va_content)), $va_data);
                        continue;
                    }
                    $this->opo_engine->indexField($pn_subject_tablenum, 'I' . $vn_fld_num, $pn_subject_row_id, $pn_content, $va_data);
                }
            }
        }
        // -------------------------------------
        //
        // index related fields
        //
        // Here's where we generate indexing on the subject from content in related rows (data stored externally to the subject row)
        // If the underlying engine doesn't support incremental indexing (if it can't change existing indexing for a row in-place, in other words)
        // then we need to do this every time we update the indexing for a row; if the engine *does* support incremental indexing then
        // we can just update the existing indexing with content from the changed fields.
        //
        // We also do this indexing if we're in "reindexing" mode. When reindexing is indicated it means that we need to act as if
        // we're indexing this row for the first time, and all indexing should be performed.
        if (!$vb_can_do_incremental_indexing || $pb_reindex_mode) {
            if (is_array($va_related_tables = $this->getRelatedIndexingTables($pn_subject_tablenum))) {
                if (!$vb_started_indexing) {
                    $this->opo_engine->startRowIndexing($pn_subject_tablenum, $pn_subject_row_id);
                    $vb_started_indexing = true;
                }
                foreach ($va_related_tables as $vs_related_table) {
                    $vn_related_tablenum = $this->opo_datamodel->getTableNum($vs_related_table);
                    $vs_related_pk = $this->opo_datamodel->getTablePrimaryKeyName($vn_related_tablenum);
                    $t_rel = $this->opo_datamodel->getInstanceByTableNum($vn_related_tablenum, true);
                    $va_fields_to_index = $this->getFieldsToIndex($pn_subject_tablenum, $vs_related_table);
                    $va_table_info = $this->getTableIndexingInfo($pn_subject_tablenum, $vs_related_table);
                    $va_field_list = array_keys($va_fields_to_index);
                    $va_table_list_list = array();
                    //$va_table_info['tables'];
                    $va_table_key_list = array();
                    //$va_table_info['keys'];
                    if (isset($va_table_info['key']) && $va_table_info['key']) {
                        $va_table_list_list = array('key' => array($vs_related_table));
                        $va_table_key_list = array();
                    } else {
                        if ($pb_reindex_mode || !$vb_can_do_incremental_indexing) {
                            $va_table_list_list = isset($va_table_info['tables']) ? $va_table_info['tables'] : null;
                            $va_table_key_list = isset($va_table_info['keys']) ? $va_table_info['keys'] : null;
                        }
                    }
                    if (!is_array($va_table_list_list) || !sizeof($va_table_list_list)) {
                        continue;
                    }
                    //$va_table_list_list = array($vs_related_table => array()); }
                    foreach ($va_table_list_list as $vs_list_name => $va_linking_tables) {
                        array_push($va_linking_tables, $vs_related_table);
                        $vs_left_table = $vs_subject_tablename;
                        $va_joins = array();
                        foreach ($va_linking_tables as $vs_right_table) {
                            if (is_array($va_table_key_list) && (isset($va_table_key_list[$vs_list_name][$vs_right_table][$vs_left_table]) || isset($va_table_key_list[$vs_list_name][$vs_left_table][$vs_right_table]))) {
                                // are the keys for this join specified in the indexing config?
                                if (isset($va_table_key_list[$vs_list_name][$vs_left_table][$vs_right_table])) {
                                    $va_key_spec = $va_table_key_list[$vs_list_name][$vs_left_table][$vs_right_table];
                                    $vs_join = 'INNER JOIN ' . $vs_right_table . ' ON (' . $vs_right_table . '.' . $va_key_spec['right_key'] . ' = ' . $vs_left_table . '.' . $va_key_spec['left_key'];
                                    if ($va_key_spec['left_table_num'] || $va_key_spec['right_table_num']) {
                                        if ($va_key_spec['right_table_num']) {
                                            $vs_join .= ' AND ' . $vs_right_table . '.' . $va_key_spec['right_table_num'] . ' = ' . $this->opo_datamodel->getTableNum($vs_left_table);
                                        } else {
                                            $vs_join .= ' AND ' . $vs_left_table . '.' . $va_key_spec['left_table_num'] . ' = ' . $this->opo_datamodel->getTableNum($vs_right_table);
                                        }
                                    }
                                    $vs_join .= ")";
                                } else {
                                    $va_key_spec = $va_table_key_list[$vs_list_name][$vs_right_table][$vs_left_table];
                                    $vs_join = 'INNER JOIN ' . $vs_right_table . ' ON (' . $vs_right_table . '.' . $va_key_spec['left_key'] . ' = ' . $vs_left_table . '.' . $va_key_spec['right_key'];
                                    if ($va_key_spec['left_table_num'] || $va_key_spec['right_table_num']) {
                                        if ($va_key_spec['right_table_num']) {
                                            $vs_join .= ' AND ' . $vs_left_table . '.' . $va_key_spec['right_table_num'] . ' = ' . $this->opo_datamodel->getTableNum($vs_right_table);
                                        } else {
                                            $vs_join .= ' AND ' . $vs_right_table . '.' . $va_key_spec['left_table_num'] . ' = ' . $this->opo_datamodel->getTableNum($vs_left_table);
                                        }
                                    }
                                    $vs_join .= ")";
                                }
                                $va_joins[] = $vs_join;
                            } else {
                                if ($va_rel = $this->opo_datamodel->getOneToManyRelations($vs_left_table, $vs_right_table)) {
                                    $va_joins[] = 'INNER JOIN ' . $va_rel['many_table'] . ' ON ' . $va_rel['one_table'] . '.' . $va_rel['one_table_field'] . ' = ' . $va_rel['many_table'] . '.' . $va_rel['many_table_field'];
                                } else {
                                    if ($va_rel = $this->opo_datamodel->getOneToManyRelations($vs_right_table, $vs_left_table)) {
                                        $va_joins[] = 'INNER JOIN ' . $va_rel['one_table'] . ' ON ' . $va_rel['one_table'] . '.' . $va_rel['one_table_field'] . ' = ' . $va_rel['many_table'] . '.' . $va_rel['many_table_field'];
                                    }
                                }
                            }
                            $vs_left_table = $vs_right_table;
                        }
                        $va_proc_field_list = array();
                        $vn_field_list_count = sizeof($va_field_list);
                        for ($vn_i = 0; $vn_i < $vn_field_list_count; $vn_i++) {
                            if ($va_field_list[$vn_i] == '_count') {
                                continue;
                            }
                            if (substr($va_field_list[$vn_i], 0, 14) === '_ca_attribute_') {
                                continue;
                            }
                            if (!trim($va_field_list[$vn_i])) {
                                continue;
                            }
                            $va_proc_field_list[$vn_i] = $vs_related_table . '.' . $va_field_list[$vn_i];
                        }
                        $va_proc_field_list[] = $vs_related_table . '.' . $vs_related_pk;
                        if (isset($va_rel['many_table']) && $va_rel['many_table']) {
                            $va_proc_field_list[] = $va_rel['many_table'] . '.' . $va_rel['many_table_field'];
                        }
                        $vs_sql = "\n\t\t\t\t\t\tSELECT " . join(",", $va_proc_field_list) . "\n\t\t\t\t\t\tFROM " . $vs_subject_tablename . "\n\t\t\t\t\t\t" . join("\n", $va_joins) . "\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t(" . $vs_subject_tablename . '.' . $vs_subject_pk . ' = ?)
					';
                        $qr_res = $this->opo_db->query($vs_sql, $pn_subject_row_id);
                        if ($this->opo_db->numErrors()) {
                            // Shouldn't ever happen
                            throw new Exception(_t("SQL error while getting content for index of related fields: %1; SQL was %2", $this->opo_db->getErrors(), $vs_sql));
                        }
                        while ($qr_res->nextRow()) {
                            $va_field_data = $qr_res->getRow();
                            $vn_row_id = $qr_res->get($vs_related_pk);
                            foreach ($va_fields_to_index as $vs_rel_field => $va_rel_field_info) {
                                //
                                // BEGIN: Index attributes in related tables
                                //
                                $vb_is_attr = false;
                                if (substr($vs_rel_field, 0, 14) === '_ca_attribute_') {
                                    if (!preg_match('!^_ca_attribute_(.*)$!', $vs_rel_field, $va_matches)) {
                                        continue;
                                    }
                                    if ($va_rel_field_info['DONT_INDEX'] && is_array($va_rel_field_info['DONT_INDEX'])) {
                                        $vb_cont = false;
                                        foreach ($va_rel_field_info["DONT_INDEX"] as $vs_exclude_type) {
                                            if ($this->_getElementID($vs_exclude_type) == intval($va_matches[1])) {
                                                $vb_cont = true;
                                                break;
                                            }
                                        }
                                        if ($vb_cont) {
                                            continue;
                                        }
                                        // skip excluded attribute type
                                    }
                                    $vb_is_attr = true;
                                    $va_rel_field_info['datatype'] = (int) $this->_getElementDataType($va_matches[1]);
                                    switch ($va_rel_field_info['datatype']) {
                                        case 0:
                                            // container
                                            // index components of complex multi-value attributes
                                            $va_attributes = $t_rel->getAttributesByElement($va_matches[1], array('row_id' => $vn_row_id));
                                            if (sizeof($va_attributes)) {
                                                foreach ($va_attributes as $vo_attribute) {
                                                    foreach ($vo_attribute->getValues() as $vo_value) {
                                                        $vn_list_id = $this->_getElementListID($vo_value->getElementID());
                                                        $this->opo_engine->indexField($vn_related_tablenum, 'A' . $vo_value->getElementID(), $vo_attribute->getAttributeID(), $vo_value->getDisplayValue($vn_list_id), $va_rel_field_info);
                                                        // 4 = ca_attributes
                                                    }
                                                }
                                            } else {
                                                // we are deleting a container so cleanup existing sub-values
                                                $va_sub_elements = $this->opo_metadata_element->getElementsInSet($va_matches[1]);
                                                foreach ($va_sub_elements as $vn_i => $va_element_info) {
                                                    $this->opo_engine->indexField($vn_related_tablenum, 'A' . $va_element_info['element_id'], $va_element_info['element_id'], '', $va_rel_field_info);
                                                }
                                            }
                                            break;
                                        case 3:
                                            // list
                                            // We pull the preferred labels of list items for indexing here. We do so for all languages. Note that
                                            // this only done for list attributes that are standalone and not a sub-element in a container. Perhaps
                                            // we should also index the text of sub-element lists, but it's not clear that it is a good idea yet. The list_id's of
                                            // sub-elements *are* indexed however, so advanced search forms passing ids instead of text will work.
                                            $va_tmp = array();
                                            if (is_array($va_attributes = $t_rel->getAttributesByElement($va_matches[1], array('row_id' => $vn_row_id)))) {
                                                foreach ($va_attributes as $vo_attribute) {
                                                    foreach ($vo_attribute->getValues() as $vo_value) {
                                                        $va_tmp[$vo_attribute->getAttributeID()] = $vo_value->getDisplayValue();
                                                    }
                                                }
                                            }
                                            $va_new_values = array();
                                            $t_item = new ca_list_items();
                                            $va_labels = $t_item->getPreferredDisplayLabelsForIDs($va_tmp, array('returnAllLocales' => true));
                                            foreach ($va_labels as $vn_label_row_id => $va_labels_per_row) {
                                                foreach ($va_labels_per_row as $vn_locale_id => $va_label_list) {
                                                    foreach ($va_label_list as $vs_label) {
                                                        $va_new_values[$vn_label_row_id][$vs_label] = true;
                                                    }
                                                }
                                            }
                                            foreach ($va_tmp as $vn_attribute_id => $vn_item_id) {
                                                if (!$vn_item_id) {
                                                    continue;
                                                }
                                                if (!isset($va_new_values[$vn_item_id]) || !is_array($va_new_values[$vn_item_id])) {
                                                    continue;
                                                }
                                                $vs_v = join(' ;  ', array_merge(array($vn_item_id), array_keys($va_new_values[$vn_item_id])));
                                                $this->opo_engine->indexField($vn_related_tablenum, 'A' . $va_matches[1], $vn_attribute_id, $vs_v, $va_rel_field_info);
                                            }
                                            break;
                                        default:
                                            $va_attributes = $t_rel->getAttributesByElement($va_matches[1], array('row_id' => $vn_row_id));
                                            if (!is_array($va_attributes)) {
                                                break;
                                            }
                                            foreach ($va_attributes as $vo_attribute) {
                                                foreach ($vo_attribute->getValues() as $vo_value) {
                                                    $pn_content = $vo_value->getDisplayValue();
                                                    $this->opo_engine->indexField($vn_related_tablenum, 'A' . $va_matches[1], $vo_attribute->getAttributeID(), $pn_content, $va_rel_field_info);
                                                }
                                            }
                                            break;
                                    }
                                }
                                $vs_fld_data = trim($va_field_data[$vs_rel_field]);
                                //
                                // Hierarchical indexing in related tables
                                //
                                if (isset($va_rel_field_info['INDEX_ANCESTORS']) && $va_rel_field_info['INDEX_ANCESTORS'] || in_array('INDEX_ANCESTORS', $va_rel_field_info)) {
                                    // is this current field a label?
                                    $t_hier_rel = $t_rel;
                                    $vn_fld_num = $t_rel->fieldNum($vs_rel_field);
                                    $vn_id = $vn_row_id;
                                    $vb_is_label = false;
                                    if (is_subclass_of($t_hier_rel, "BaseLabel")) {
                                        $t_hier_rel->load($vn_row_id);
                                        $t_hier_rel = $t_hier_rel->getSubjectTableInstance();
                                        $vn_id = $t_hier_rel->getPrimaryKey();
                                        $vb_is_label = true;
                                    }
                                    if ($t_hier_rel && $t_hier_rel->isHierarchical()) {
                                        // get hierarchy
                                        if ($va_hier_values = $this->_genHierarchicalPath($vn_id, $vb_is_label ? "preferred_labels." . $vs_rel_field : $vs_rel_field, $t_hier_rel, $va_rel_field_info)) {
                                            $this->opo_engine->indexField($vn_related_tablenum, 'I' . $vn_fld_num, $vn_id, $vs_fld_data . ' ' . join(" ", $va_hier_values['values']), $va_rel_field_info);
                                            if (caGetOption('INDEX_ANCESTORS_AS_PATH_WITH_DELIMITER', $va_rel_field_info, false) !== false) {
                                                $this->opo_engine->indexField($vn_related_tablenum, 'I' . $vn_fld_num, $vn_id, $va_hier_values['path'], array_merge($va_rel_field_info, array('DONT_TOKENIZE' => 1)));
                                            }
                                        }
                                        $va_children_ids = $t_hier_rel->getHierarchyAsList($vn_row_id, array('idsOnly' => true));
                                        if (!$pb_reindex_mode && is_array($va_children_ids) && sizeof($va_children_ids) > 0) {
                                            // trigger reindexing of children
                                            $o_indexer = new SearchIndexer($this->opo_db);
                                            $qr_children_res = $t_hier_rel->makeSearchResult($t_hier_rel->tableName(), $va_children_ids);
                                            $vs_pk = $t_hier_rel->primaryKey();
                                            $vn_table_num = $t_hier_rel->tableNum();
                                            while ($qr_children_res->nextHit()) {
                                                $vn_id = $qr_children_res->get($vs_pk);
                                                if ($vn_id == $vn_row_id) {
                                                    continue;
                                                }
                                                $o_indexer->indexRow($vn_table_num, $vn_id, array($vs_pk => $vn_id, 'parent_id' => $qr_children_res->get('parent_id'), $vs_rel_field => $qr_children_res->get($vs_rel_field)), false, $pa_exclusion_list, array($vs_rel_field => true), null);
                                            }
                                        }
                                        continue;
                                    }
                                }
                                switch ($vs_rel_field) {
                                    case '_count':
                                        // noop
                                        break;
                                    default:
                                        if ($vb_is_attr) {
                                            $this->opo_engine->indexField($vn_related_tablenum, 'A' . $va_matches[1], $qr_res->get($vs_related_pk), $vs_fld_data, $va_rel_field_info);
                                        } else {
                                            $this->opo_engine->indexField($vn_related_tablenum, 'I' . $this->opo_datamodel->getFieldNum($vs_related_table, $vs_rel_field), $qr_res->get($vs_related_pk), $vs_fld_data, $va_rel_field_info);
                                        }
                                        break;
                                }
                                //
                                // END: Index attributes in related tables
                                //
                            }
                        }
                        //if (isset($va_fields_to_index['_count'])) {
                        //$this->opo_engine->indexField($pn_subject_tablenum, '_count', $pn_subject_row_id, $qr_res->numRows(), array());
                        //}
                    }
                }
            }
        }
        // save indexing on subject
        if ($vb_started_indexing) {
            $this->opo_engine->commitRowIndexing();
        }
        if (!$pb_reindex_mode && sizeof($pa_changed_fields) > 0) {
            //
            // When not reindexing then we consider the effect of the change on this row upon related rows that use it
            // in their indexing. This means figuring out which related tables have indexing that depend upon the subject row.
            //
            // We deal with this by pulling up a dependency map generated from the search_indexing.conf file and then reindexing
            // those rows
            //
            $va_deps = $this->getDependencies($vs_subject_tablename);
            $va_changed_field_nums = array();
            foreach (array_keys($pa_changed_fields) as $vs_f) {
                if ($t_subject->hasField($vs_f)) {
                    $va_changed_field_nums[$vs_f] = 'I' . $t_subject->fieldNum($vs_f);
                } else {
                    if (preg_match('!^_ca_attribute_([\\d]+)$!', $vs_f, $va_matches)) {
                        $va_changed_field_nums[$vs_f] = 'A' . $this->_getElementListCode($va_matches[1]);
                    }
                }
            }
            //
            // reindex rows in dependent tables that use the subject_row_id
            //
            $va_rows_to_reindex = $this->_getDependentRowsForSubject($pn_subject_tablenum, $pn_subject_row_id, $va_deps, $va_changed_field_nums);
            if ($vb_can_do_incremental_indexing) {
                $va_rows_to_reindex_by_row_id = array();
                foreach ($va_rows_to_reindex as $vs_key => $va_row_to_reindex) {
                    foreach ($va_row_to_reindex['field_nums'] as $vs_fld_name => $vn_fld_num) {
                        $vs_new_key = $va_row_to_reindex['table_num'] . '/' . $va_row_to_reindex['field_table_num'] . '/' . $vn_fld_num . '/' . $va_row_to_reindex['field_row_id'];
                        if (!isset($va_rows_to_reindex_by_row_id[$vs_new_key])) {
                            $va_rows_to_reindex_by_row_id[$vs_new_key] = array('table_num' => $va_row_to_reindex['table_num'], 'row_ids' => array(), 'field_table_num' => $va_row_to_reindex['field_table_num'], 'field_num' => $vn_fld_num, 'field_name' => $vs_fld_name, 'field_row_id' => $va_row_to_reindex['field_row_id'], 'field_values' => $va_row_to_reindex['field_values'], 'indexing_info' => $va_row_to_reindex['indexing_info'][$vs_fld_name]);
                        }
                        $va_rows_to_reindex_by_row_id[$vs_new_key]['row_ids'][] = $va_row_to_reindex['row_id'];
                    }
                }
                $o_indexer = new SearchIndexer($this->opo_db);
                foreach ($va_rows_to_reindex_by_row_id as $va_row_to_reindex) {
                    if ($va_row_to_reindex['field_table_num'] === 4) {
                        // is attribute
                        $va_row_to_reindex['indexing_info']['datatype'] = $this->_getElementDataType($va_row_to_reindex['field_num']);
                    }
                    if (isset($va_row_to_reindex['indexing_info']['INDEX_ANCESTORS']) && $va_row_to_reindex['indexing_info']['INDEX_ANCESTORS'] || in_array('INDEX_ANCESTORS', $va_row_to_reindex['indexing_info'])) {
                        if (!is_array($va_row_to_reindex['row_ids'])) {
                            continue;
                        }
                        $va_content = $this->_genHierarchicalPath($va_row_to_reindex['field_row_id'], $va_row_to_reindex['field_name'], $this->opo_datamodel->getInstanceByTableNum($va_row_to_reindex['field_table_num'], true), array());
                        $vs_content = is_array($va_content['values']) ? join(" ", $va_content['values']) : "";
                        $this->opo_engine->updateIndexingInPlace($va_row_to_reindex['table_num'], $va_row_to_reindex['row_ids'], $va_row_to_reindex['field_table_num'], $va_row_to_reindex['field_num'], $va_row_to_reindex['field_row_id'], $vs_content, array_merge($va_row_to_reindex['indexing_info'], array('literalContent' => $va_content['path'])));
                        //
                        // THE FOLLOWING CODE IS TOO SLOW - 	updateIndexingInPlace() call following the commented-out block of code
                        //										replaces this and is much faster... but we need to validate that it works reliably
                        //
                        // 						foreach($va_row_to_reindex['row_ids'] as $vn_row_to_reindex_id) {
                        // 							if ($t_dep = $this->getTableInstance($va_row_to_reindex['table_num'], true)) {
                        // 								$va_dep_ids = $t_dep->getHierarchyAsList($vn_row_to_reindex_id, array('idsOnly' => true, 'includeSelf' => true));
                        //
                        // 								$va_dep_values = BaseModel::getFieldValueArraysForIDs($va_dep_ids, $t_dep->tableName());
                        //
                        // 								foreach($va_dep_values as $vn_dep_id => $va_dep_value) {
                        // 									$o_indexer->indexRow($va_row_to_reindex['table_num'], $vn_dep_id, $va_dep_value, true, $pa_exclusion_list, null, null);
                        // 								}
                        // 							}
                        // 						}
                    } else {
                        $this->opo_engine->updateIndexingInPlace($va_row_to_reindex['table_num'], $va_row_to_reindex['row_ids'], $va_row_to_reindex['field_table_num'], $va_row_to_reindex['field_num'], $va_row_to_reindex['field_row_id'], $va_row_to_reindex['field_values'][$va_row_to_reindex['field_name']], $va_row_to_reindex['indexing_info']);
                    }
                }
            } else {
                //
                // If the underlying engine doesn't support incremental indexing then
                // we fall back to reindexing each dependenting row completely and independently.
                // This can be *really* slow for subjects with many dependent rows (for example, a ca_list_item value used as a type for many ca_objects rows)
                // and we need to think about how to optimize this for such engines; ultimately since no matter how you slice it in such
                // engines you're going to have a lot of reindexing going on, we may just have to construct a facility to handle large
                // indexing tasks in a separate process when the number of dependent rows exceeds a certain threshold
                //
                $o_indexer = new SearchIndexer($this->opo_db);
                foreach ($va_rows_to_reindex as $va_row_to_reindex) {
                    if (!$t_dep || $t_dep->tableNum() != $va_row_to_reindex['table_num']) {
                        $t_dep = $this->opo_datamodel->getInstanceByTableNum($va_row_to_reindex['table_num']);
                    }
                    $vb_support_attributes = is_subclass_of($t_dep, 'BaseModelWithAttributes') ? true : false;
                    if (is_array($pa_exclusion_list[$va_row_to_reindex['table_num']]) && isset($pa_exclusion_list[$va_row_to_reindex['table_num']][$va_row_to_reindex['row_id']])) {
                        continue;
                    }
                    // trigger reindexing
                    if ($vb_support_attributes) {
                        if ($t_dep->load($va_row_to_reindex['row_id'])) {
                            //
                            $o_indexer->indexRow($va_row_to_reindex['table_num'], $va_row_to_reindex['row_id'], $t_dep->getFieldValuesArray(), true, $pa_exclusion_list);
                        }
                    } else {
                        $o_indexer->indexRow($va_row_to_reindex['table_num'], $va_row_to_reindex['row_id'], $va_row_to_reindex['field_values'], true, $pa_exclusion_list);
                    }
                }
                $o_indexer = null;
            }
        }
        if ($vb_reindex_children && method_exists($t_subject, "makeSearchResult")) {
            //
            // Force reindexing of children of this record, typically because the record has shifted location in the hierarchy and is hierarchically indexed
            //
            $va_children_ids = $t_subject->getHierarchyAsList($pn_subject_row_id, array('idsOnly' => true));
            if (is_array($va_children_ids) && sizeof($va_children_ids) > 0) {
                // trigger reindexing of children
                $o_indexer = new SearchIndexer($this->opo_db);
                $qr_children_res = $t_subject->makeSearchResult($vs_subject_tablename, $va_children_ids);
                while ($qr_children_res->nextHit()) {
                    $o_indexer->indexRow($pn_subject_tablenum, $vn_id = $qr_children_res->get($vs_subject_pk), array($vs_subject_pk => $vn_id, 'parent_id' => $qr_children_res->get('parent_id')), true, $pa_exclusion_list, array(), null);
                }
            }
        }
    }
Пример #8
0
    $vn_featured_member_set_id = $t_featured_member->get("set_id");
    $va_featured_member_ids = array_keys(is_array($va_tmp = $t_featured_member->getItemRowIDs(array('checkAccess' => $va_access_values, 'shuffle' => 1))) ? $va_tmp : array());
    // These are the entity ids in the set
}
$t_entity = new ca_entities($va_featured_member_ids[0]);
$vn_featured_member_id = $va_featured_member_ids[0];
$vs_featured_member_image = $t_entity->get("mem_inst_image", array("version" => "frontpage", "return" => "tag"));
$vs_featured_member_name = $t_entity->getLabelForDisplay();
# --- canned browses
$va_browse_codes = $this->request->config->get('hp_category_browse_codes');
$t_list_item = new ca_list_items();
$va_browses = array();
if (is_array($va_browse_codes) && sizeof($va_browse_codes)) {
    foreach ($va_browse_codes as $vs_item_code) {
        $t_list_item->load(array('idno' => $vs_item_code));
        $va_browses[$t_list_item->get("item_id")] = array("idno" => $vs_item_code, "name" => $t_list_item->getLabelForDisplay());
    }
}
if ($this->getVar("featured_set_id")) {
    $t_featured_set = new ca_sets($this->getVar("featured_set_id"));
    ?>
		<div id="contentcontainer">
			<div id="objectcontainerHP">
				<div class="homeIntro">Navigate through some of the collections of Nova Scotia's community museums to learn about the province's past, and share your own stories and information about what is important to you.</div><!-- end home intro -->
				<div id="objectslidesContainerHP">
<?php 
    # --- featured objects
    foreach ($va_item_media as $vn_object_id => $va_media) {
        if ($va_media['urls']['frontpage']) {
            $vs_image_tag = $va_media["tags"]["frontpage"];
            $t_title_object = new ca_objects($vn_object_id);
Пример #9
0
 public function getUIsAsDOM()
 {
     $t_list = new ca_lists();
     $vo_uis = $this->opo_dom->createElement("userInterfaces");
     $qr_uis = $this->opo_db->query("SELECT * FROM ca_editor_uis ORDER BY ui_id");
     while ($qr_uis->nextRow()) {
         $vo_ui = $this->opo_dom->createElement("userInterface");
         $vs_type = $this->opo_dm->getTableName($qr_uis->get("editor_type"));
         if (strlen($vs_code = $qr_uis->get("editor_code")) > 0) {
             $vo_ui->setAttribute("code", $this->makeIDNO($vs_code));
         } else {
             $vo_ui->setAttribute("code", "standard_{$vs_type}_ui");
         }
         $vo_ui->setAttribute("type", $vs_type);
         $vo_labels = $this->opo_dom->createElement("labels");
         $qr_ui_labels = $this->opo_db->query("SELECT * FROM ca_editor_ui_labels WHERE ui_id=?", $qr_uis->get("ui_id"));
         if ($qr_ui_labels->numRows() > 0) {
             while ($qr_ui_labels->nextRow()) {
                 if ($vs_locale = $this->opt_locale->localeIDToCode($qr_ui_labels->get("locale_id"))) {
                     $vo_label = $this->opo_dom->createElement("label");
                     $vo_label->setAttribute("locale", $vs_locale);
                     $vo_label->appendChild($this->opo_dom->createElement("name", caEscapeForXML($qr_ui_labels->get("name"))));
                     $vo_labels->appendChild($vo_label);
                 }
             }
         } else {
             $vo_label = $this->opo_dom->createElement("label");
             $vo_label->setAttribute("locale", "en_US");
             $vo_label->appendChild($this->opo_dom->createElement("name", caEscapeForXML($vs_code)));
             $vo_labels->appendChild($vo_label);
         }
         $vo_ui->appendChild($vo_labels);
         $vo_screens = $this->opo_dom->createElement("screens");
         $qr_screens = $this->opo_db->query("SELECT * FROM ca_editor_ui_screens WHERE parent_id IS NOT NULL AND ui_id=? ORDER BY screen_id", $qr_uis->get("ui_id"));
         while ($qr_screens->nextRow()) {
             $t_screen = new ca_editor_ui_screens($qr_screens->get("screen_id"));
             $vo_screen = $this->opo_dom->createElement("screen");
             if ($vs_idno = $qr_screens->get("idno")) {
                 $vo_screen->setAttribute("idno", $this->makeIDNO($vs_idno));
             }
             $vo_screen->setAttribute("default", $qr_screens->get("is_default"));
             $vo_labels = $this->opo_dom->createElement("labels");
             $qr_screen_labels = $this->opo_db->query("SELECT * FROM ca_editor_ui_screen_labels WHERE screen_id=?", $qr_screens->get("screen_id"));
             if ($qr_ui_labels->numRows() > 0) {
                 while ($qr_screen_labels->nextRow()) {
                     if ($vs_locale = $this->opt_locale->localeIDToCode($qr_screen_labels->get("locale_id"))) {
                         $vo_label = $this->opo_dom->createElement("label");
                         $vo_label->setAttribute("locale", $vs_locale);
                         $vo_label->appendChild($this->opo_dom->createElement("name", caEscapeForXML($qr_screen_labels->get("name"))));
                         if (strlen(trim($qr_screen_labels->get("description"))) > 0) {
                             $vo_label->appendChild($this->opo_dom->createElement("description", caEscapeForXML($qr_screen_labels->get("description"))));
                         }
                         $vo_labels->appendChild($vo_label);
                     }
                 }
             } else {
                 $vo_label = $this->opo_dom->createElement("label");
                 $vo_label->setAttribute("locale", "en_US");
                 $vo_label->appendChild($this->opo_dom->createElement("name", caEscapeForXML($vs_code)));
                 $vo_labels->appendChild($vo_label);
             }
             $vo_screen->appendChild($vo_labels);
             if (is_array($t_screen->getTypeRestrictions()) && sizeof($t_screen->getTypeRestrictions()) > 0) {
                 $vo_type_restrictions = $this->opo_dom->createElement("typeRestrictions");
                 foreach ($t_screen->getTypeRestrictions() as $va_restriction) {
                     $vo_type_restriction = $this->opo_dom->createElement("restriction");
                     $t_instance = $this->opo_dm->getInstanceByTableNum($va_restriction["table_num"]);
                     $vs_type_code = $t_instance->getTypeListCode();
                     $va_item = $t_list->getItemFromListByItemID($vs_type_code, $va_restriction["type_id"]);
                     $vo_type_restriction->setAttribute("type", $va_item["idno"]);
                     $vo_type_restrictions->appendChild($vo_type_restriction);
                 }
                 $vo_screen->appendChild($vo_type_restrictions);
             }
             $vo_placements = $this->opo_dom->createElement("bundlePlacements");
             $va_placements = $t_screen->getPlacementsInScreen();
             if (is_array($va_placements)) {
                 foreach ($va_placements as $va_placement) {
                     $vo_placement = $this->opo_dom->createElement("placement");
                     $vo_placements->appendChild($vo_placement);
                     $vo_placement->setAttribute("code", $this->makeIDNO($va_placement["placement_code"]));
                     $vo_placement->appendChild($this->opo_dom->createElement("bundle", caEscapeForXML($va_placement["bundle"])));
                     if (is_array($va_placement["settings"])) {
                         $vo_settings = $this->opo_dom->createElement("settings");
                         foreach ($va_placement["settings"] as $vs_setting => $va_values) {
                             if (is_null($va_values)) {
                                 continue;
                             }
                             if (!is_array($va_values)) {
                                 $va_values = array($va_values);
                             }
                             // account for legacy settings
                             if ($vs_setting == "restrict_to_type") {
                                 $vs_setting = "restrict_to_types";
                             }
                             foreach ($va_values as $vs_key => $vs_value) {
                                 switch ($vs_setting) {
                                     case 'restrict_to_types':
                                         $t_item = new ca_list_items($vs_value);
                                         if ($t_item->getPrimaryKey()) {
                                             $vs_value = $t_item->get('idno');
                                         }
                                         break;
                                     case 'restrict_to_lists':
                                         $t_list = new ca_lists($vs_value);
                                         if ($t_list->getPrimaryKey()) {
                                             $vs_value = $t_list->get('list_code');
                                         }
                                         break;
                                     case 'restrict_to_relationship_types':
                                         $t_rel_type = new ca_relationship_types($vs_value);
                                         if ($t_rel_type->getPrimaryKey()) {
                                             $vs_value = $t_rel_type->get('type_code');
                                         }
                                         break;
                                 }
                                 if (strlen($vs_value) > 0) {
                                     if ($vs_value === 0 || $vs_value === "0") {
                                         // caExcapeForXML mangles zero values for some reason -> catch them here.
                                         $vs_setting_val = $vs_value;
                                     } else {
                                         $vs_setting_val = caEscapeForXML($vs_value);
                                     }
                                     $vo_setting = @$this->opo_dom->createElement("setting", $vs_setting_val);
                                     $vo_setting->setAttribute("name", $vs_setting);
                                     if ($vs_setting == "label" || $vs_setting == "add_label" || $vs_setting == "description") {
                                         if (preg_match("/^[a-z]{2,3}\\_[A-Z]{2,3}\$/", $vs_key)) {
                                             $vo_setting->setAttribute("locale", $vs_key);
                                         } else {
                                             continue;
                                         }
                                     }
                                     $vo_settings->appendChild($vo_setting);
                                 }
                             }
                         }
                         $vo_placement->appendChild($vo_settings);
                     }
                 }
             }
             $vo_screen->appendChild($vo_placements);
             $vo_screens->appendChild($vo_screen);
         }
         $vo_ui->appendChild($vo_screens);
         $vo_uis->appendChild($vo_ui);
     }
     return $vo_uis;
 }
Пример #10
0
function caGetListItemIdno($pn_item_id)
{
    global $g_list_item_idno_cache;
    if (isset($g_list_item_idno_cache[$pn_item_id])) {
        return $g_list_item_idno_cache[$pn_item_id];
    }
    $t_item = new ca_list_items($pn_item_id);
    return $g_list_item_idno_cache[$pn_item_id] = $t_item->get('idno');
}
Пример #11
0
 /**
  * When returning text will return plural value of list item unless useSingular option is set to true, in which case singular version of list item label will be used.
  *
  * @param array Optional array of options. Support options are:
  * 			list_id = if set then the numeric item_id value is translated into label text in the current locale. If not set then the numeric item_id is returned.
  *			useSingular = If list_id is set then by default the returned text is the plural label. Setting this option to true will force use of the singular label. [Default is false]
  *			showHierarchy = If true then hierarchical parents of list item will be returned and hierarchical options described below will be used to control the output [Default is false]
  *			returnIdno = If true list item idno is returned rather than preferred label [Default is false]
  *			idsOnly = Return numeric item_id only [Default is false]
  *			alwaysReturnItemID = Synonym for idsOnly [Default is false]
  *			output = what value for the list to return. Valid values are text [display text], idno [identifier; same as returnIdno option], value [numeric item_id; same as idsOnly option]. [Default is value]
  *
  *			HIERARCHICAL OPTIONS:
  *				direction - For hierarchy specifications (eg. ca_objects.hierarchy) this determines the order in which the hierarchy is returned. ASC will return the hierarchy root first while DESC will return it with the lowest node first. Default is ASC.
  *				top - For hierarchy specifications (eg. ca_objects.hierarchy) this option, if set, will limit the returned hierarchy to the first X nodes from the root down. Default is to not limit.
  *				bottom - For hierarchy specifications (eg. ca_objects.hierarchy) this option, if set, will limit the returned hierarchy to the first X nodes from the lowest node up. Default is to not limit.
  * 				hierarchicalDelimiter - Text to place between items in a hierarchy for a hierarchical specification (eg. ca_objects.hierarchy) when returning as a string
  *				removeFirstItems - If set to a non-zero value, the specified number of items at the top of the hierarchy will be omitted. For example, if set to 2, the root and first child of the hierarchy will be omitted. Default is zero (don't delete anything).
  *				transaction = the transaction to execute database actions within. [Default is null]
  * @return string The value
  */
 public function getDisplayValue($pa_options = null)
 {
     if (isset($pa_options['output'])) {
         switch (strtolower($pa_options['output'])) {
             case 'idno':
                 $pa_options['returnIdno'] = true;
                 break;
             case 'text':
                 $pa_options['returnIdno'] = false;
                 $pa_options['idsOnly'] = false;
                 break;
             default:
                 $pa_options['idsOnly'] = true;
                 break;
         }
     }
     if ($vb_return_idno = isset($pa_options['returnIdno']) && (bool) $pa_options['returnIdno']) {
         return caGetListItemIdno($this->opn_item_id);
     }
     if (is_null($vb_ids_only = isset($pa_options['idsOnly']) ? (bool) $pa_options['idsOnly'] : null)) {
         $vb_ids_only = isset($pa_options['alwaysReturnItemID']) ? (bool) $pa_options['alwaysReturnItemID'] : false;
     }
     if ($vb_ids_only) {
         return (int) $this->opn_item_id;
     }
     $vn_list_id = is_array($pa_options) && isset($pa_options['list_id']) ? (int) $pa_options['list_id'] : null;
     if ($vn_list_id > 0) {
         $t_list = new ca_lists();
         if ($o_trans = isset($pa_options['transaction']) ? $pa_options['transaction'] : null) {
             $t_list->setTransaction($o_trans);
         }
         $t_item = new ca_list_items();
         if ($pa_options['showHierarchy'] || $vb_return_idno) {
             if ($o_trans) {
                 $t_item->setTransaction($o_trans);
             }
         }
         $vs_get_spec = isset($pa_options['useSingular']) && $pa_options['useSingular'] ? 'preferred_labels.name_singular' : 'preferred_labels.name_plural';
         // do we need to get the hierarchy?
         if ($pa_options['showHierarchy']) {
             $t_item->load((int) $this->opn_item_id);
             return $t_item->get('ca_list_items.hierarchy.' . $vs_get_spec, array_merge(array('removeFirstItems' => 1, 'delimiter' => ' ➔ ', $pa_options)));
         }
         return $t_list->getItemFromListForDisplayByItemID($vn_list_id, $this->opn_item_id, isset($pa_options['useSingular']) && $pa_options['useSingular'] ? false : true);
     }
     return $this->ops_text_value;
 }
Пример #12
0
 /**
  * Returns COinS tags for inclusion in page
  *
  * @param SearchResult_or_BundleableLabelableBaseModelWithAttributes_subclass $pm_instance_or_result
  * @param string $ps_output_type
  * @param array $pa_options
  */
 public static function getTags($pm_instance_or_result, $ps_output_type = null, $pa_options = null)
 {
     $va_config = COinS::_getConfig($vs_table_name = $pm_instance_or_result->tableName(), $ps_output_type);
     $va_urls = array();
     if (is_subclass_of($pm_instance_or_result, 'BaseModel')) {
         $qr_res = $pm_instance_or_result->makeSearchResult($pm_instance_or_result->tableName(), array($pm_instance_or_result->getPrimaryKey()));
     } else {
         $qr_res = $pm_instance_or_result;
     }
     $o_dm = Datamodel::load();
     $t_instance = $o_dm->getInstanceByTableName($vs_table_name, true);
     $vs_type_fld_name = $t_instance->getTypeFieldName();
     $t_item = new ca_list_items();
     while ($qr_res->nextHit()) {
         $vs_type_name = null;
         if ($vn_type_id = $qr_res->get($vs_type_fld_name)) {
             if ($t_item->load($vn_type_id)) {
                 $vs_type_name = $t_item->get('idno');
             }
         }
         $va_mappings = isset($va_config[$vs_type_name]) ? $va_config[$vs_type_name] : $va_config['__default__'];
         $va_people_mappings = $va_mappings['People'];
         unset($va_mappings['People']);
         $va_item = $va_people = array();
         foreach ($va_mappings as $vs_key => $va_mapping) {
             if (!is_array($va_mapping)) {
                 $vs_static = (string) $va_mapping;
             } else {
                 $vs_static = $va_mapping['value'];
                 $vs_bundle = $va_mapping['bundle'];
                 $va_options = $va_mapping['options'];
             }
             if ($vs_bundle) {
                 $va_item[$vs_key] = $qr_res->get($vs_bundle, $va_options);
             } else {
                 $va_item[$vs_key] = $vs_static;
             }
         }
         if (is_array($va_people_mappings)) {
             foreach ($va_people_mappings as $vn_person_type => $va_mapping) {
                 if (!is_array($va_mapping)) {
                     $vs_static = (string) $va_mapping;
                 } else {
                     $vs_static = $va_mapping['value'];
                     $vs_forename_bundle = $va_mapping['forename'];
                     $vs_surname_bundle = $va_mapping['surname'];
                     $va_options = $va_mapping['options'];
                 }
                 $vs_forename = $qr_res->get($vs_forename_bundle, $va_options);
                 $vs_surname = $qr_res->get($vs_surname_bundle, $va_options);
                 if ($vs_forename || $vs_surname) {
                     $va_people[] = array('DocRelationship' => $vn_person_type, 'FirstName' => $vs_forename, 'LastName' => $vs_surname);
                 }
             }
         }
         $va_urls[] = $vs_url = COinS::_CreateOpenURL($va_item, $va_people);
         $va_tags[] = "<span class='Z3988' title='{$vs_url}'></span>";
     }
     $vb_return_urls = isset($pa_options['returnUrls']) && $pa_options['returnUrls'];
     if (isset($pa_options['returnAsArray']) && $pa_options['returnAsArray']) {
         return $vb_return_urls ? $va_urls : $va_tags;
     } else {
         $vs_delimiter = isset($pa_options['delimiter']) ? $pa_options['delimiter'] : "\n";
         return join($vs_delimiter, $vb_return_urls ? $va_urls : $va_tags);
     }
 }
Пример #13
0
        }
        print "<br/>";
    }
    print "</H5>";
}
?>
		<HR/>
<?php 
$va_classification_links = array();
$t_list_item = new ca_list_items();
$va_decorative_types = $t_object->get("ca_objects.decorative_types", array("returnAsArray" => true));
if (sizeof($va_decorative_types)) {
    foreach ($va_decorative_types as $va_decorative_type) {
        $vn_decorative_type = $va_decorative_type["decorative_types"];
        $t_list_item->load($vn_decorative_type);
        if (trim($t_list_item->get("ca_list_item_labels.name_singular"))) {
            $va_classification_links[] = caNavLink($this->request, $t_list_item->get("ca_list_item_labels.name_singular"), "", "", "Browse", "Objects", array("facet" => "decorative_types_facet", "id" => $vn_decorative_type));
        }
    }
    if (sizeof($va_classification_links)) {
        print "<H6>Classification</H6>";
        print join(", ", $va_classification_links);
    }
}
$va_documentation_types = $t_object->get("ca_objects.documentation_types", array("returnAsArray" => true));
if (sizeof($va_documentation_types)) {
    foreach ($va_documentation_types as $va_documentation_type) {
        $vn_documentation_type = $va_documentation_type["documentation_types"];
        $t_list_item->load($vn_documentation_type);
        if (trim($t_list_item->get("ca_list_item_labels.name_singular"))) {
            $va_classification_links[] = caNavLink($this->request, $t_list_item->get("ca_list_item_labels.name_singular"), "", "", "Browse", "Objects", array("facet" => "documentation_types_facet", "id" => $vn_documentation_type));
Пример #14
0
function caGetListItemIdno($pn_item_id, $pa_options = null)
{
    global $g_list_item_idno_cache;
    if (isset($g_list_item_idno_cache[$pn_item_id])) {
        return $g_list_item_idno_cache[$pn_item_id];
    }
    $t_item = new ca_list_items();
    if ($o_trans = caGetOption('transaction', $pa_options, null)) {
        $t_item->setTransaction($o_trans);
    }
    $t_item->load($pn_item_id);
    return $g_list_item_idno_cache[$pn_item_id] = $t_item->get('idno');
}
Пример #15
0
/**
 * Fetch idno for item with specified item_id in list
 *
 * @param int $pn_item_id item_id to get idno for
 * @return string idno of list item or null if no matching item was found
 */
function caGetListItemIdno($pn_item_id)
{
    $t_item = new ca_list_items($pn_item_id);
    return $t_item->get('idno');
}
Пример #16
0
 /**
  * Helper to extract the list a new item is about to be inserted in from the request.
  * This is usually not passed as simple list_id parameter by the UI but through the parent_id.
  */
 private function _getListIDFromRequest($po_request)
 {
     if ($vn_list_id = $po_request->getParameter('list_id', pInteger)) {
         return $vn_list_id;
     }
     if ($vn_parent_id = $po_request->getParameter('parent_id', pInteger)) {
         $t_item = new ca_list_items($vn_parent_id);
         if ($t_item->getPrimaryKey()) {
             return $t_item->get('list_id');
         }
     }
     return false;
 }
Пример #17
0
 /**
  * Returns list items below the specified item in the specified list
  *
  * Options:
  * 		includeSelf - if true, the specified item is included in the returned set of items; [default is false]
  *		directChildrenOnly - if true, only children immediately below the specified item are returned; [default is false]
  */
 public function getChildItemsForList($pm_list_name_or_id, $pn_item_id, $pa_options = null)
 {
     if ($pm_list_name_or_id) {
         $vn_list_id = $this->_getListID($pm_list_name_or_id);
         $this->load($vn_list_id);
     }
     if (!($vn_list_id = $this->getPrimaryKey())) {
         return null;
     }
     $o_db = $this->getDb();
     $t_item = new ca_list_items($pn_item_id);
     if (!$t_item->getPrimaryKey() || $t_item->get('list_id') != $vn_list_id) {
         return null;
     }
     $vs_order_by = '';
     switch ($this->get('default_sort')) {
         case __CA_LISTS_SORT_BY_LABEL__:
             // by label
             $vs_order_by = 'clil.name_plural';
             break;
         case __CA_LISTS_SORT_BY_RANK__:
             // by rank
             $vs_order_by = 'cli.rank';
             break;
         case __CA_LISTS_SORT_BY_VALUE__:
             // by value
             $vs_order_by = 'cli.item_value';
             break;
         case __CA_LISTS_SORT_BY_IDENTIFIER__:
             // by identifier
             $vs_order_by = 'cli.idno_sort';
             break;
     }
     $vs_order_by = "ORDER BY {$vs_order_by}";
     $qr_res = $o_db->query("\n\t\t\tSELECT *\n\t\t\tFROM ca_list_items cli\n\t\t\tINNER JOIN ca_list_item_labels AS clil ON clil.item_id = cli.item_id\n\t\t\tWHERE\n\t\t\t\t(cli.deleted = 0) AND (clil.is_preferred = 1) AND (cli.list_id = ?) AND (cli.hier_left >= ? AND cli.hier_right <= ?)\n\t\t\t{$vs_order_by}\n\t\t", (int) $vn_list_id, floatval($t_item->get('hier_left')), floatval($t_item->get('hier_right')));
     $va_items = array();
     while ($qr_res->nextRow()) {
         $vn_item_id = $qr_res->get('item_id');
         if ((!isset($pa_options['includeSelf']) || !$pa_options['includeSelf']) && $vn_item_id == $pn_item_id) {
             continue;
         }
         if (isset($pa_options['directChildrenOnly']) && $pa_options['directChildrenOnly'] && $qr_res->get('parent_id') != $pn_item_id) {
             continue;
         }
         $va_items[$vn_item_id][$qr_res->get('locale_id')] = $qr_res->getRow();
     }
     return $va_items;
 }
Пример #18
0
 * the "license.txt" file for details, or visit the CollectiveAccess web site at
 * http://www.CollectiveAccess.org
 *
 * ----------------------------------------------------------------------
 */
require_once __CA_MODELS_DIR__ . '/ca_list_items.php';
$t_object_event = $this->getVar('t_subject');
$vn_event_id = $this->getVar('subject_id');
$t_ui = $this->getVar('t_ui');
$vb_can_edit = $t_object_event->isSaveable($this->request);
$vb_can_delete = $t_object_event->isDeletable($this->request);
//get a screen name from the type_id
$type_list_item = new ca_list_items($this->request->getParameter('type_id', 1));
$screens = $t_ui->getScreens($this->request);
foreach ($screens as $screen) {
    if ($screen['idno'] == $type_list_item->get('idno')) {
        $screen_from_type = 'Screen' . $screen['screen_id'];
    }
}
$screen_name = $screen_from_type ? $screen_from_type : $this->request->getActionExtra();
if ($vb_can_edit) {
    print $vs_control_box = caFormControlBox(caFormSubmitButton($this->request, __CA_NAV_BUTTON_SAVE__, _t("Save"), 'ObjectEventEditorForm') . ' ' . caNavButton($this->request, __CA_NAV_BUTTON_CANCEL__, _t("Cancel"), 'editor/object_events', 'ObjectEventEditor', 'Edit/' . $this->request->getActionExtra(), array('event_id' => $vn_event_id)), '', intval($vn_event_id) > 0 && $vb_can_delete ? caNavButton($this->request, __CA_NAV_BUTTON_DELETE__, _t("Delete"), 'editor/object_events', 'ObjectEventEditor', 'Delete/' . $this->request->getActionExtra(), array('event_id' => $vn_event_id)) : '');
}
?>
	<div class="sectionBox">
<?php 
print caFormTag($this->request, 'Save/' . $this->request->getActionExtra() . '/event_id/' . $vn_event_id, 'ObjectEventEditorForm', null, 'POST', 'multipart/form-data');
$va_form_elements = $t_object_event->getBundleFormHTMLForScreen($screen_name, array('request' => $this->request, 'formName' => 'ObjectEventEditorForm'));
print join("\n", $va_form_elements);
if ($vb_can_edit) {
    print $vs_control_box;
Пример #19
0
     $vs_caption .= $vs_label;
 }
 # --- get the height of the image so can calculate padding needed to center vertically
 $va_media_info = $qr_hits->getMediaInfo('ca_object_representations.media', 'thumbnail');
 $vn_padding_top = 0;
 $vn_padding_top_bottom = (130 - $va_media_info["HEIGHT"]) / 2;
 $vs_image = $qr_hits->getMediaTag('ca_object_representations.media', 'thumbnail');
 if (!$vs_image) {
     # --- get the placeholder graphic from the novamuse theme
     $va_themes = caExtractValuesByUserLocale($qr_hits->get("novastory_category", array("returnAsArray" => true)));
     $vs_placeholder = "";
     if (sizeof($va_themes)) {
         $t_list_item = new ca_list_items();
         foreach ($va_themes as $k => $vs_list_item_id) {
             $t_list_item->load($vs_list_item_id);
             if (file_exists($this->request->getThemeDirectoryPath() . "/graphics/novamuse/placeholders/small/" . $t_list_item->get("idno") . ".png")) {
                 $vs_image = "<img src='" . $this->request->getThemeUrlPath() . "/graphics/novamuse/placeholders/small/" . $t_list_item->get("idno") . ".png'>";
                 $vn_padding_top_bottom = 5;
             }
         }
     }
     if (!$vs_image) {
         $vs_image = "<img src='" . $this->request->getThemeUrlPath() . "/graphics/novamuse/placeholders/small/placeholder.png'>";
         $vn_padding_top_bottom = 5;
     }
 }
 print "<td align='center' valign='top' class='searchResultTd'><div class='searchThumbBg searchThumbnail" . $vn_object_id . "' style='padding: " . $vn_padding_top_bottom . "px 0px " . $vn_padding_top_bottom . "px 0px;'>";
 if ($this->request->config->get('allow_detail_for_ca_objects')) {
     print caNavLink($this->request, $vs_image, '', 'Detail', 'Object', 'Show', array('object_id' => $qr_hits->get('ca_objects.object_id')));
 } else {
     print $vs_image;
Пример #20
0
 /**
  * Save edits from "spreadsheet" (editable results) mode
  *
  */
 public function saveInlineEdit($pa_options = null)
 {
     global $g_ui_locale_id;
     $pa_changes = $this->request->getParameter("changes", pArray);
     $vs_resp = array();
     $o_dm = Datamodel::load();
     if (!is_array($pa_changes) || !sizeof($pa_changes)) {
         $va_resp['messages'][0] = _t("Nothing to save");
     } else {
         foreach ($pa_changes as $vn_i => $pa_change) {
             $ps_table = $pa_change['table'];
             $pa_bundle = explode("-", $ps_bundle = $pa_change['bundle']);
             $pn_id = (int) $pa_change['id'];
             $ps_val = $pa_change['value'];
             if (!($t_instance = $o_dm->getInstanceByTableName($ps_table, true))) {
                 $va_resp['errors'][$pn_id] = array('error' => 100, 'message' => _t('Invalid table: %1', $ps_table));
             } else {
                 if (!$t_instance->load($pn_id)) {
                     $va_resp['errors'][$pn_id] = array('error' => 100, 'message' => _t('Invalid id: %1', $pn_id));
                 } else {
                     if (!$t_instance->isSaveable($this->request)) {
                         $va_resp['errors'][$pn_id] = array('error' => 100, 'message' => _t('You are not allowed to edit this.'));
                     } elseif ($pa_bundle[0] == 'preferred_labels') {
                         if ($this->request->user->getBundleAccessLevel($ps_table, $pa_bundle[0]) != __CA_BUNDLE_ACCESS_EDIT__) {
                             $va_resp['errors'][$pn_id] = array('error' => 100, 'message' => _t('You are not allowed to edit this.'));
                         } else {
                             $vn_label_id = $t_instance->getPreferredLabelID($g_ui_locale_id);
                             $va_label_values = array();
                             if (sizeof($pa_bundle) == 1) {
                                 // is generic "preferred_labels"
                                 $va_label_values[$t_instance->getLabelDisplayField()] = $ps_val;
                             } else {
                                 $vs_preferred_label_element = $pa_bundle[1];
                                 $va_label_values[$vs_preferred_label_element] = $ps_val;
                             }
                             if ($vn_label_id) {
                                 $t_instance->editLabel($vn_label_id, $va_label_values, $g_ui_locale_id, null, true);
                                 // TODO: what about type?
                             } else {
                                 $t_instance->addLabel($va_label_values, $g_ui_locale_id, null, true);
                             }
                             if ($t_instance->numErrors()) {
                                 $va_resp['errors'][$pn_id] = array('error' => 100, 'message' => _t('Could not set preferred label %1 to %2: %3', $ps_bundle, $ps_val, join("; ", $t_instance->getErrors())));
                             } else {
                                 $va_resp['messages'][$pn_id] = array('message' => _t('Set preferred label %1 to %2', $ps_bundle, $ps_val), 'value' => $ps_val);
                             }
                         }
                     } elseif ($t_instance->hasField($ps_bundle)) {
                         if ($this->request->user->getBundleAccessLevel($ps_table, $ps_bundle) != __CA_BUNDLE_ACCESS_EDIT__) {
                             $va_resp['errors'][$pn_id] = array('error' => 100, 'message' => _t('You are not allowed to edit this.'));
                         } else {
                             // is it a list?
                             $t_list = new ca_lists();
                             $t_instance->setMode(ACCESS_WRITE);
                             if (($vs_list_code = $t_instance->getFieldInfo($ps_bundle, 'LIST')) && ($va_item = $t_list->getItemFromListByLabel($vs_list_code, $ps_val))) {
                                 $t_instance->set($ps_bundle, $va_item['item_value']);
                             } elseif (($vs_list_code = $t_instance->getFieldInfo($ps_bundle, 'LIST_CODE')) && ($vn_item_id = $t_list->getItemIDFromListByLabel($vs_list_code, $ps_val))) {
                                 $t_instance->set($ps_bundle, $vn_item_id);
                             } else {
                                 $t_instance->set($ps_bundle, $ps_val);
                             }
                             $t_instance->update();
                             if ($t_instance->numErrors()) {
                                 $va_resp['errors'][$pn_id] = array('error' => 100, 'message' => _t('Could not set %1 to %2: %3', $ps_bundle, $ps_val, join("; ", $t_instance->getErrors())));
                             } else {
                                 $va_resp['messages'][$pn_id] = array('message' => _t('Set %1 to %2', $ps_bundle, $ps_val), 'value' => $ps_val);
                             }
                         }
                     } elseif ($t_instance->hasElement($ps_bundle)) {
                         $vn_datatype = ca_metadata_elements::getElementDatatype($ps_bundle);
                         // Check if it repeats?
                         if ($vn_count = $t_instance->getAttributeCountByElement($ps_bundle) > 1) {
                             $va_resp['errors'][$pn_id] = array('error' => 100, 'message' => _t('Cannot edit <em>%1</em> here because it has multiple values. Try editing it directly.', mb_strtolower($t_instance->getDisplayLabel("{$ps_table}.{$ps_bundle}"))));
                         } elseif (!in_array($vn_datatype, array(1, 2, 3, 5, 6, 8, 9, 10, 11, 12))) {
                             // Check if it's a supported type?
                             $va_resp['errors'][$pn_id] = array('error' => 100, 'message' => _t('Cannot edit <em>%1</em> here. Try editing it directly.', mb_strtolower($t_instance->getDisplayLabel("{$ps_table}.{$ps_bundle}"))));
                         } elseif ($this->request->user->getBundleAccessLevel($ps_table, $ps_bundle) != __CA_BUNDLE_ACCESS_EDIT__) {
                             $va_resp['errors'][$pn_id] = array('error' => 100, 'message' => _t('You are not allowed to edit this.'));
                         } else {
                             // Do edit
                             $t_instance->setMode(ACCESS_WRITE);
                             $vs_val_proc = null;
                             if ($vn_datatype == 3) {
                                 if ($vn_id = ca_list_items::find(array('preferred_labels' => array('name_plural' => $ps_val)), array('returnAs' => 'firstId'))) {
                                     $t_instance->replaceAttribute(array('locale_id' => $g_ui_locale_id, $ps_bundle => $vn_id), $ps_bundle);
                                     // convert list codes to display text
                                     $t_list_item = new ca_list_items((int) $vn_id);
                                     if ($t_list_item->getPrimaryKey()) {
                                         $vs_val_proc = $t_list_item->get('ca_list_items.preferred_labels.name_plural');
                                     }
                                 }
                             } else {
                                 $t_instance->replaceAttribute(array('locale_id' => $g_ui_locale_id, $ps_bundle => $ps_val), $ps_bundle);
                             }
                             $t_instance->update();
                             if (!$vs_val_proc) {
                                 $vs_val_proc = $t_instance->get($ps_table . '.' . $ps_bundle);
                             }
                             if ($t_instance->numErrors()) {
                                 $va_resp['errors'][$pn_id] = array('error' => 100, 'message' => _t('Could not set %1 to %2: %3', $ps_bundle, $ps_val, join("; ", $t_instance->getErrors())));
                             } else {
                                 $va_resp['messages'][$pn_id] = array('message' => _t('Set %1 to %2', $ps_bundle, $ps_val), 'value' => $vs_val_proc);
                             }
                         }
                     } else {
                         $va_resp['errors'][$pn_id] = array('error' => 100, 'message' => _t('Invalid bundle: %1', $ps_bundle));
                     }
                 }
             }
         }
     }
     $this->view->setVar('results', $va_resp);
     $this->render('Results/ajax_save_inline_edit_json.php');
 }
Пример #21
0
 /**
  * Will return plural value of list item unless useSingular option is set to true, in which case singular version of list item label will be used.
  *
  * @param array Optional array of options. Support options are:
  * 			list_id = if set then the numeric item_id value is translated into label text in the current locale. If not set then the numeric item_id is returned.
  *			useSingular = If list_id is set then by default the returned text is the plural label. Setting this option to true will force use of the singular label. [Default is false]
  *			showHierarchy = If true then hierarchical parents of list item will be returned and hierarchical options described below will be used to control the output [Default is false]
  *			returnIdno = If true list item idno is returned rather than preferred label [Default is false]
  *			idsOnly = Return numeric item_id only [Default is false]
  *			HIERARCHICAL OPTIONS: 
  *				direction - For hierarchy specifications (eg. ca_objects.hierarchy) this determines the order in which the hierarchy is returned. ASC will return the hierarchy root first while DESC will return it with the lowest node first. Default is ASC.
  *				top - For hierarchy specifications (eg. ca_objects.hierarchy) this option, if set, will limit the returned hierarchy to the first X nodes from the root down. Default is to not limit.
  *				bottom - For hierarchy specifications (eg. ca_objects.hierarchy) this option, if set, will limit the returned hierarchy to the first X nodes from the lowest node up. Default is to not limit.
  * 				hierarchicalDelimiter - Text to place between items in a hierarchy for a hierarchical specification (eg. ca_objects.hierarchy) when returning as a string
  *				removeFirstItems - If set to a non-zero value, the specified number of items at the top of the hierarchy will be omitted. For example, if set to 2, the root and first child of the hierarchy will be omitted. Default is zero (don't delete anything).
  *				transaction = the transaction to execute database actions within. [Default is null]
  * @return string The value
  */
 public function getDisplayValue($pa_options = null)
 {
     if ($vb_return_idno = isset($pa_options['returnIdno']) && (bool) $pa_options['returnIdno']) {
         return caGetListItemIdno($this->ops_text_value);
     }
     $vb_ids_only = (bool) caGetOption('idsOnly', $pa_options, false);
     if ($vb_ids_only) {
         return (int) $this->ops_text_value;
     }
     $vn_list_id = is_array($pa_options) && isset($pa_options['list_id']) ? (int) $pa_options['list_id'] : null;
     if ($vn_list_id > 0) {
         $t_list = new ca_lists();
         if ($o_trans = caGetOption('transaction', $pa_options, null)) {
             $t_list->setTransaction($o_trans);
         }
         $t_item = new ca_list_items();
         if ($pa_options['showHierarchy'] || $vb_return_idno) {
             if ($o_trans) {
                 $t_item->setTransaction($o_trans);
             }
         }
         $vs_get_spec = isset($pa_options['useSingular']) && $pa_options['useSingular'] ? 'name_singular' : 'name_plural';
         // do we need to get the hierarchy?
         if ($pa_options['showHierarchy']) {
             $t_item->load($this->ops_text_value);
             return $t_item->get('ca_list_items.hierarchy.' . $vs_get_spec, $pa_options);
         }
         return $t_list->getItemFromListForDisplayByItemID($vn_list_id, $this->ops_text_value, isset($pa_options['useSingular']) && $pa_options['useSingular'] ? false : true);
     }
     return $this->ops_text_value;
 }
     $vn_c = 0;
     $qr_res->seek($vn_start);
 }
 $t_list_item = new ca_list_items();
 $vs_add_to_lightbox_msg = addslashes(_t('Add to lightbox'));
 while ($qr_res->nextHit() && $vn_c < $vn_hits_per_block) {
     $vn_id = $qr_res->get("{$vs_table}.{$vs_pk}");
     $vs_idno_detail_link = caDetailLink($this->request, $qr_res->get("{$vs_table}.idno"), '', $vs_table, $vn_id);
     $vs_label_detail_link = caDetailLink($this->request, $qr_res->get("{$vs_table}.preferred_labels.name"), '', $vs_table, $vn_id);
     $vs_thumbnail = "";
     $vs_type_placeholder = "";
     $vs_typecode = "";
     if ($vs_table == 'ca_objects') {
         if (!($vs_thumbnail = $qr_res->getMediaTag('ca_object_representations.media', 'medium', array("checkAccess" => $va_access_values)))) {
             $t_list_item->load($qr_res->get("type_id"));
             $vs_typecode = $t_list_item->get("idno");
             if ($vs_type_placeholder = getPlaceholder($vs_typecode, "placeholder_media_icon")) {
                 $vs_thumbnail = "<div class='bResultItemImgPlaceholder'>" . $vs_type_placeholder . "</div>";
             } else {
                 $vs_thumbnail = $vs_default_placeholder_tag;
             }
         }
         $vs_rep_detail_link = caDetailLink($this->request, $vs_thumbnail, '', $vs_table, $vn_id);
     } else {
         if ($va_images[$vn_id]) {
             $vs_thumbnail = $va_images[$vn_id];
         } else {
             $vs_thumbnail = $vs_default_placeholder_tag;
         }
         $vs_rep_detail_link = caDetailLink($this->request, $vs_thumbnail, '', $vs_table, $vn_id);
     }
Пример #23
0
$vn_object_id = $t_object->get('object_id');
$vs_title = $this->getVar('label');
$va_access_values = $this->getVar('access_values');
$t_rep = $this->getVar('t_primary_rep');
$vn_num_reps = $t_object->getRepresentationCount(array("return_with_access" => $va_access_values));
$vs_display_version = $this->getVar('primary_rep_display_version');
$va_display_options = $this->getVar('primary_rep_display_options');
$va_theme_info = array();
$va_themes = caExtractValuesByUserLocale($t_object->get("novastory_category", array("returnAsArray" => true)));
$vs_placeholder = "";
if (sizeof($va_themes)) {
    $t_list_item = new ca_list_items();
    foreach ($va_themes as $k => $vs_list_item_id) {
        $t_list_item->load($vs_list_item_id);
        $va_theme_info["name"] = $t_list_item->getLabelForDisplay();
        if (file_exists($this->request->getThemeDirectoryPath() . "/graphics/novamuse/" . $t_list_item->get("idno") . ".png")) {
            $va_theme_info["icon"] = $this->request->getThemeUrlPath() . "/graphics/novamuse/" . $t_list_item->get("idno") . ".png";
        }
        if (file_exists($this->request->getThemeDirectoryPath() . "/graphics/novamuse/placeholders/" . $t_list_item->get("idno") . ".png")) {
            $vs_placeholder = $this->request->getThemeUrlPath() . "/graphics/novamuse/placeholders/" . $t_list_item->get("idno") . ".png";
        }
        $va_theme_info["id"] = $t_list_item->get("item_id");
        $va_themes_info[] = $va_theme_info;
    }
}
if (!$vs_placeholder) {
    $vs_placeholder = $this->request->getThemeUrlPath() . "/graphics/novamuse/placeholders/placeholder.png";
}
# --- get similar items by category
$va_categories = explode(",", $t_object->get('ns_category'));
$va_sim_items = array();