本文整理汇总了PHP中ca_list_items类的典型用法代码示例。如果您正苦于以下问题:PHP ca_list_items类的具体用法?PHP ca_list_items怎么用?PHP ca_list_items使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ca_list_items类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: info
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);
}
示例2: browseName
/**
* Returns string representing the name of the item the browse will return
*
* If $ps_mode is 'singular' [default] then the singular version of the name is returned, otherwise the plural is returned
*/
public function browseName($ps_mode = 'singular')
{
$vb_type_restriction_has_changed = false;
$vn_type_id = $this->opo_result_context->getTypeRestriction($vb_type_restriction_has_changed);
$t_list = new ca_lists();
$t_list->load(array('list_code' => 'occurrence_types'));
$t_list_item = new ca_list_items();
$t_list_item->load(array('list_id' => $t_list->getPrimaryKey(), 'parent_id' => null));
$va_hier = caExtractValuesByUserLocale($t_list_item->getHierarchyWithLabels());
if (!($vs_name = $ps_mode == 'singular' ? $va_hier[$vn_type_id]['name_singular'] : $va_hier[$vn_type_id]['name_plural'])) {
$vs_name = '???';
}
return $vs_name;
}
示例3: info
public function info($pa_parameters)
{
parent::info($pa_parameters);
$t_list = $this->view->getVar('t_item');
if ($t_list->getPrimaryKey()) {
$va_labels = $t_list->getDisplayLabels();
$this->view->setVar('labels', $t_list->getPrimaryKey() ? $va_labels : array());
$this->view->setVar('idno', $t_list->get('idno'));
}
$t_list_item = new ca_list_items();
$t_list_item->load(array('list_id' => $t_list->getPrimaryKey(), 'parent_id' => null));
$this->view->setVar('t_list_item', $t_list_item);
if ($vn_item_id = $t_list_item->getPrimaryKey()) {
$va_children = caExtractValuesByUserLocaleFromHierarchyChildList($t_list_item->getHierarchyChildren(null, array('additionalTableToJoin' => 'ca_list_item_labels', 'additionalTableJoinType' => 'LEFT', 'additionalTableSelectFields' => array('name_plural', 'locale_id'), 'additionalTableWheres' => array('(ca_list_item_labels.is_preferred = 1 OR ca_list_item_labels.is_preferred IS NULL)'))), 'item_id', 'name_plural', 'item_value');
$this->view->setVar('children', $va_children);
}
return $this->render('widget_list_info_html.php', true);
}
示例4: getListItemID
/**
* Returns or Creates a list item or list item id matching the parameters and options provided
* @param string/int $pm_list_code_or_id
* @param string $ps_item_idno
* @param string/int $pn_type_id
* @param int $pn_locale_id
* @param null/array $pa_values
* @param array $pa_options An optional array of options. See DataMigrationUtils::_getID() for a list.
* @return bool|ca_list_items|mixed|null
*
* @see DataMigrationUtils::_getID()
*/
static function getListItemID($pm_list_code_or_id, $ps_item_idno, $pn_type_id, $pn_locale_id, $pa_values = null, $pa_options = null)
{
if (!is_array($pa_options)) {
$pa_options = array();
}
$pb_output_errors = caGetOption('outputErrors', $pa_options, false);
$pa_match_on = caGetOption('matchOn', $pa_options, array('label', 'idno'), array('castTo' => "array"));
$vn_parent_id = caGetOption('parent_id', $pa_values, false);
$vs_singular_label = isset($pa_values['preferred_labels']['name_singular']) && $pa_values['preferred_labels']['name_singular'] ? $pa_values['preferred_labels']['name_singular'] : '';
if (!$vs_singular_label) {
$vs_singular_label = isset($pa_values['name_singular']) && $pa_values['name_singular'] ? $pa_values['name_singular'] : str_replace("_", " ", $ps_item_idno);
}
$vs_plural_label = isset($pa_values['preferred_labels']['name_plural']) && $pa_values['preferred_labels']['name_plural'] ? $pa_values['preferred_labels']['name_plural'] : '';
if (!$vs_plural_label) {
$vs_plural_label = isset($pa_values['name_plural']) && $pa_values['name_plural'] ? $pa_values['name_plural'] : str_replace("_", " ", $ps_item_idno);
}
if (!$vs_singular_label) {
$vs_singular_label = $vs_plural_label;
}
if (!$vs_plural_label) {
$vs_plural_label = $vs_singular_label;
}
if (!$ps_item_idno) {
$ps_item_idno = $vs_plural_label;
}
if (!isset($pa_options['cache'])) {
$pa_options['cache'] = true;
}
// Create cache key
$vs_cache_key = md5($pm_list_code_or_id . '/' . $ps_item_idno . '/' . $vn_parent_id . '/' . $vs_singular_label . '/' . $vs_plural_label . '/' . json_encode($pa_match_on));
$o_event = isset($pa_options['importEvent']) && $pa_options['importEvent'] instanceof ca_data_import_events ? $pa_options['importEvent'] : null;
$ps_event_source = isset($pa_options['importEventSource']) && $pa_options['importEventSource'] ? $pa_options['importEventSource'] : "?";
/** @var KLogger $o_log */
$o_log = isset($pa_options['log']) && $pa_options['log'] instanceof KLogger ? $pa_options['log'] : null;
if ($pa_options['cache'] && isset(DataMigrationUtils::$s_cached_list_item_ids[$vs_cache_key])) {
if (isset($pa_options['returnInstance']) && $pa_options['returnInstance']) {
$t_item = new ca_list_items(DataMigrationUtils::$s_cached_list_item_ids[$vs_cache_key]);
if (isset($pa_options['transaction']) && $pa_options['transaction'] instanceof Transaction) {
$t_item->setTransaction($pa_options['transaction']);
}
return $t_item;
}
if ($o_event) {
$o_event->beginItem($ps_event_source, 'ca_list_items', 'U');
$o_event->endItem(DataMigrationUtils::$s_cached_list_item_ids[$vs_cache_key], __CA_DATA_IMPORT_ITEM_SUCCESS__, '');
}
if ($o_log) {
$o_log->logDebug(_t("Found existing list item %1 (member of list %2) in DataMigrationUtils::getListItemID() using idno", $ps_item_idno, $pm_list_code_or_id));
}
return DataMigrationUtils::$s_cached_list_item_ids[$vs_cache_key];
}
if (!($vn_list_id = ca_lists::getListID($pm_list_code_or_id))) {
if ($pb_output_errors) {
print "[Error] " . _t("Could not find list with list code %1", $pm_list_code_or_id) . "\n";
}
if ($o_log) {
$o_log->logError(_t("Could not find list with list code %1", $pm_list_code_or_id));
}
return DataMigrationUtils::$s_cached_list_item_ids[$vs_cache_key] = null;
}
if (!$vn_parent_id && $vn_parent_id !== false) {
$vn_parent_id = caGetListRootID($pm_list_code_or_id);
}
$t_list = new ca_lists();
$t_item = new ca_list_items();
if (isset($pa_options['transaction']) && $pa_options['transaction'] instanceof Transaction) {
$t_list->setTransaction($pa_options['transaction']);
$t_item->setTransaction($pa_options['transaction']);
if ($o_event) {
$o_event->setTransaction($pa_options['transaction']);
}
}
$vn_item_id = null;
foreach ($pa_match_on as $vs_match_on) {
switch (strtolower($vs_match_on)) {
case 'label':
case 'labels':
if (trim($vs_singular_label) || trim($vs_plural_label)) {
$va_criteria = array('preferred_labels' => array('name_singular' => $vs_singular_label), 'list_id' => $vn_list_id);
if ($vn_parent_id !== false) {
$va_criteria['parent_id'] = $vn_parent_id;
}
if ($vn_item_id = ca_list_items::find($va_criteria, array('returnAs' => 'firstId', 'purifyWithFallback' => true, 'transaction' => $pa_options['transaction']))) {
if ($o_log) {
$o_log->logDebug(_t("Found existing list item %1 (member of list %2) in DataMigrationUtils::getListItemID() using singular label %3", $ps_item_idno, $pm_list_code_or_id, $vs_singular_label));
}
break 2;
} else {
//.........这里部分代码省略.........
示例5: indexRow
//.........这里部分代码省略.........
// 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];
示例6: array
$vn_col_span_xs = 6;
}
if ($vn_start < $qr_res->numHits()) {
$vn_c = 0;
$qr_res->seek($vn_start);
if ($vs_table != 'ca_objects') {
$va_ids = array();
while ($qr_res->nextHit() && $vn_c < $vn_hits_per_block) {
$va_ids[] = $qr_res->get($vs_pk);
$vn_c++;
}
$va_images = caGetDisplayImagesForAuthorityItems($vs_table, $va_ids, array('version' => 'small', 'relationshipTypes' => caGetOption('selectMediaUsingRelationshipTypes', $va_options, null), 'checkAccess' => $va_access_values));
$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 {
示例7: caMakeListItemIDList
/**
* Converts the given list of list idnos or item_ids into a list of numeric item_ids
*
* @param mixed $pm_list List code or list_id
* @param array $pa_list_items List of item idnos and/or item_ids
* @param array $pa_options Options include:
* transaction = transaction to execute queries within. [Default=null]
*
* @return array List of numeric item_ids
*/
function caMakeListItemIDList($pm_list, $pa_list_items, $pa_options = null)
{
if (!($vn_list_id = caGetListID($pm_list))) {
return array();
}
$t_item = new ca_list_items();
if ($o_trans = caGetOption('transaction', $pa_options, null)) {
$t_item->setTransaction($o_trans);
}
$va_ids = array();
foreach ($pa_list_items as $vm_item) {
if (is_numeric($vm_item) && (int) $vm_item > 0) {
$va_ids[(int) $vm_item] = true;
} else {
if ($vn_id = caGetListItemID($vn_list_id, $vm_item)) {
$va_ids[(int) $vn_id] = true;
}
}
}
return array_keys($va_ids);
}
示例8: getLabels
/**
* Returns labels associated with this row. By default all labels - preferred and non-preferred, and from all locales -
* are returned. You can limit the returned labels to specified locales by passing a list of locale_ids (numeric ids, *not* locale codes)
* in $pn_locale_ids. Similarly you can limit return labels to preferred on non-preferred by setting $pn_mode to __CA_LABEL_TYPE_PREFERRED__
* or __CA_LABEL_TYPE_NONPREFERRED__
*
* getLabels() returns an associated array keyed by the primary key of the item the label is attached to; each value is an array keyed by locale_id, the values of which
* is a list of associative arrays with the label table data. This return format is designed to be digested by the displayHelper function caExtractValuesByUserLocale()
*
* @param array $pa_locale_ids
* @param int $pn_mode
* @param boolean $pb_dont_cache
* @param array $pa_options Array of options. Supported options are:
* row_id = The row_id to return labels for. If omitted the id of the currently loaded row is used. If row_id is not set and now row is loaded then getLabels() will return null.
* restrict_to_types = an optional array of numeric type ids or alphanumeric type identifiers to restrict the returned labels to. The types are list items in a list specified in app.conf (or, if not defined there, by hardcoded constants in the model)
* restrictToTypes = synonym for restrict_to_types
* extractValuesByUserLocale = if set returned array of values is filtered to include only values appropriate for the current user's locale
* forDisplay = if true, a simple list of labels ready for display is returned; implies the extractValuesByUserLocale option
*
* @return array List of labels
*/
public function getLabels($pa_locale_ids = null, $pn_mode = __CA_LABEL_TYPE_ANY__, $pb_dont_cache = true, $pa_options = null)
{
if (isset($pa_options['restrictToTypes']) && (!isset($pa_options['restrict_to_types']) || !$pa_options['restrict_to_types'])) {
$pa_options['restrict_to_types'] = $pa_options['restrictToTypes'];
}
if (!($vn_id = $this->getPrimaryKey()) && !(isset($pa_options['row_id']) && ($vn_id = $pa_options['row_id']))) {
return null;
}
if (isset($pa_options['forDisplay']) && $pa_options['forDisplay']) {
$pa_options['extractValuesByUserLocale'] = true;
}
if ($pn_mode == __CA_LABEL_TYPE_ANY__ && caGetBundleAccessLevel($this->tableName(), 'preferred_labels') == __CA_BUNDLE_ACCESS_NONE__) {
$pn_mode = __CA_LABEL_TYPE_NONPREFERRED__;
}
if ($pn_mode == __CA_LABEL_TYPE_ANY__ && caGetBundleAccessLevel($this->tableName(), 'nonpreferred_labels') == __CA_BUNDLE_ACCESS_NONE__) {
$pn_mode = __CA_LABEL_TYPE_PREFERRED__;
}
if ($pn_mode == __CA_LABEL_TYPE_PREFERRED__ && caGetBundleAccessLevel($this->tableName(), 'preferred_labels') == __CA_BUNDLE_ACCESS_NONE__) {
return null;
}
if ($pn_mode == __CA_LABEL_TYPE_NONPREFERRED__ && caGetBundleAccessLevel($this->tableName(), 'nonpreferred_labels') == __CA_BUNDLE_ACCESS_NONE__) {
return null;
}
if (!is_array($pa_options)) {
$pa_options = array();
}
$vs_cache_key = caMakeCacheKeyFromOptions(array_merge($pa_options, array('table_name' => $this->tableName(), 'id' => $vn_id, 'mode' => (int) $pn_mode)));
if (!$pb_dont_cache && is_array($va_tmp = LabelableBaseModelWithAttributes::$s_label_cache[$this->tableName()][$vn_id][$vs_cache_key])) {
return $va_tmp;
}
if (!($t_label = $this->_DATAMODEL->getInstanceByTableName($this->getLabelTableName(), true))) {
return null;
}
if ($this->inTransaction()) {
$o_trans = $this->getTransaction();
$t_label->setTransaction($o_trans);
}
$vs_label_where_sql = 'WHERE (l.' . $this->primaryKey() . ' = ?)';
$vs_locale_join_sql = '';
if ($pa_locale_ids) {
$vs_label_where_sql .= ' AND (l.locale_id IN (' . join(',', $pa_locale_ids) . '))';
}
$vs_locale_join_sql = 'INNER JOIN ca_locales AS loc ON loc.locale_id = l.locale_id';
$vs_list_code = null;
if ($t_label->hasField('is_preferred')) {
switch ($pn_mode) {
case __CA_LABEL_TYPE_PREFERRED__:
$vs_list_code = $this->_CONFIG->get($this->tableName() . '_preferred_label_type_list');
$vs_label_where_sql .= ' AND (l.is_preferred = 1)';
break;
case __CA_LABEL_TYPE_NONPREFERRED__:
$vs_list_code = $this->_CONFIG->get($this->tableName() . '_nonpreferred_label_type_list');
$vs_label_where_sql .= ' AND (l.is_preferred = 0)';
break;
default:
$vs_list_code = $this->_CONFIG->get($this->tableName() . '_preferred_label_type_list');
break;
}
if (!$vs_list_code) {
if ($t_label_instance = $this->getLabelTableInstance()) {
$vs_list_code = $t_label_instance->getFieldInfo('type_id', 'LIST_CODE');
}
}
}
// limit related items to a specific type
$vs_restrict_to_type_sql = '';
if (isset($pa_options['restrict_to_type']) && $pa_options['restrict_to_type']) {
if (!isset($pa_options['restrict_to_types']) || !is_array($pa_options['restrict_to_types'])) {
$pa_options['restrict_to_types'] = array();
}
$pa_options['restrict_to_types'][] = $pa_options['restrict_to_type'];
}
if (isset($pa_options['restrict_to_types']) && $pa_options['restrict_to_types'] && is_array($pa_options['restrict_to_types']) && $vs_list_code) {
$t_list = new ca_lists();
$t_list_item = new ca_list_items();
$va_ids = array();
foreach ($pa_options['restrict_to_types'] as $vs_type) {
if (!($vn_restrict_to_type_id = (int) $t_list->getItemIDFromList($vs_list_code, $vs_type))) {
$vn_restrict_to_type_id = (int) $vs_type;
//.........这里部分代码省略.........
示例9: caMakeSourceIDList
/**
* Converts the given list of source names or source_ids into an expanded list of numeric source_ids suitable for enforcing source restrictions. Processing
* includes expansion of sources to include subsources and conversion of any source codes to source_ids.
*
* @param mixed $pm_table_name_or_num Table name or number to which sources apply
* @param array $pa_sources List of source codes and/or source_ids that are the basis of the list
* @param array $pa_options Array of options:
* dont_include_subsources_in_source_restriction = if set, returned list is not expanded to include subsources
* dontIncludeSubsourcesInSourceRestriction = synonym for dont_include_subsources_in_source_restriction
*
* @return array List of numeric source_ids
*/
function caMakeSourceIDList($pm_table_name_or_num, $pa_sources, $pa_options = null)
{
$o_dm = Datamodel::load();
if (isset($pa_options['dontIncludeSubsourcesInSourceRestriction']) && (!isset($pa_options['dont_include_subsources_in_source_restriction']) || !$pa_options['dont_include_subsources_in_source_restriction'])) {
$pa_options['dont_include_subsources_in_source_restriction'] = $pa_options['dontIncludeSubsourcesInSourceRestriction'];
}
if (isset($pa_options['dont_include_subsources_in_source_restriction']) && $pa_options['dont_include_subsources_in_source_restriction']) {
$pa_options['noChildren'] = true;
}
if (is_numeric($pm_table_name_or_num)) {
$vs_table_name = $o_dm->getTableName($pm_table_name_or_num);
} else {
$vs_table_name = $pm_table_name_or_num;
}
$t_instance = $o_dm->getInstanceByTableName($vs_table_name, true);
if (!$t_instance) {
return null;
}
// bad table
if (!($vs_source_list_code = $t_instance->getSourceListCode())) {
return null;
}
// table doesn't use sources
$va_source_ids = array();
$t_list = new ca_lists();
$t_item = new ca_list_items();
$vs_list_code = $t_instance->getSourceListCode();
foreach ($pa_sources as $vm_source) {
if (!$vm_source) {
continue;
}
$vn_source_id = null;
if (is_numeric($vm_source)) {
$vn_source_id = (int) $vm_source;
} else {
$vn_source_id = (int) $t_list->getItemIDFromList($vs_source_list_code, $vm_source);
}
if ($vn_source_id && !(isset($pa_options['noChildren']) || $pa_options['noChildren'])) {
if ($qr_children = $t_item->getHierarchy($vn_source_id, array())) {
while ($qr_children->nextRow()) {
$va_source_ids[$qr_children->get('item_id')] = true;
}
}
} else {
if ($vn_source_id) {
$va_source_ids[$vn_source_id] = true;
}
}
}
return array_keys($va_source_ids);
}
示例10: _convertSourceCodesToIDs
/**
*
*
* @param array $pa_source_codes_or_ids List of source codes or ids
* @param array $pa_options Options include
* includeSubsources = include any child sources in the restriction. Default is true.
* @return array List of source_ids
*/
private function _convertSourceCodesToIDs($pa_source_codes_or_ids, $pa_options = null)
{
$vs_md5 = caMakeCacheKeyFromOptions($pa_source_codes_or_ids);
if (isset(BrowseEngine::$s_source_id_cache[$vs_md5])) {
return BrowseEngine::$s_source_id_cache[$vs_md5];
}
if (isset($pa_options['instance']) && is_object($pa_options['instance'])) {
$t_instance = $pa_options['instance'];
} else {
$t_instance = $this->getSubjectInstance();
}
$va_source_ids = array();
if (!$pa_source_codes_or_ids) {
return false;
}
if (is_array($pa_source_codes_or_ids) && !sizeof($pa_source_codes_or_ids)) {
return false;
}
if (!is_array($pa_source_codes_or_ids)) {
$pa_source_codes_or_ids = array($pa_source_codes_or_ids);
}
$t_list = new ca_lists();
if (!method_exists($t_instance, 'getSourceListCode')) {
return false;
}
if (!($vs_list_name = $t_instance->getSourceListCode())) {
return false;
}
$va_source_list = $t_instance->getSourceList();
foreach ($pa_source_codes_or_ids as $vs_code_or_id) {
if (!trim($vs_code_or_id)) {
continue;
}
if (!is_numeric($vs_code_or_id)) {
$vn_source_id = $t_list->getItemIDFromList($vs_list_name, $vs_code_or_id);
} else {
$vn_source_id = (int) $vs_code_or_id;
}
if (!$vn_source_id) {
return false;
}
if (isset($va_source_list[$vn_source_id]) && $va_source_list[$vn_source_id]) {
// is valid source for this subject
// See if there are any child sources
if (caGetOption('includeSubsources', $pa_options, true) && $this->opb_dont_expand_source_restrictions) {
$t_item = new ca_list_items($vn_source_id);
$va_ids = $t_item->getHierarchyChildren(null, array('idsOnly' => true));
}
$va_ids[] = $vn_source_id;
$va_source_ids = array_merge($va_source_ids, $va_ids);
}
}
$va_source_ids = array_keys(array_flip($va_source_ids));
BrowseEngine::$s_source_id_cache[$vs_md5] = $va_source_ids;
return $va_source_ids;
}
示例11: saveInlineEdit
/**
* 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) {
//.........这里部分代码省略.........
示例12: _getListIDFromRequest
/**
* 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;
}
示例13: ca_sets
# --- set for featured member - set name assigned in app.conf - featured_member_set_name - this is an ENTITY set
$t_featured_member = new ca_sets();
$t_featured_member->load(array('set_code' => $this->request->config->get('featured_member_set_name')));
# Enforce access control on set
if (sizeof($va_access_values) == 0 || sizeof($va_access_values) && in_array($t_featured_member->get("access"), $va_access_values)) {
$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
示例14: processDisplays
public function processDisplays()
{
require_once __CA_MODELS_DIR__ . "/ca_bundle_displays.php";
require_once __CA_MODELS_DIR__ . "/ca_bundle_display_placements.php";
require_once __CA_MODELS_DIR__ . "/ca_bundle_display_type_restrictions.php";
$o_config = Configuration::load();
$vo_dm = Datamodel::load();
if ($this->ops_base_name) {
// "merge" profile and its base
$va_displays = array();
if ($this->opo_base->displays) {
foreach ($this->opo_base->displays->children() as $vo_display) {
$va_displays[self::getAttribute($vo_display, "code")] = $vo_display;
}
}
if ($this->opo_profile->displays) {
foreach ($this->opo_profile->displays->children() as $vo_display) {
$va_displays[self::getAttribute($vo_display, "code")] = $vo_display;
}
}
} else {
if ($this->opo_profile->displays) {
foreach ($this->opo_profile->displays->children() as $vo_display) {
$va_displays[self::getAttribute($vo_display, "code")] = $vo_display;
}
}
}
if (!is_array($va_displays) || sizeof($va_displays) == 0) {
return true;
}
foreach ($va_displays as $vo_display) {
$vs_display_code = self::getAttribute($vo_display, "code");
$vb_system = self::getAttribute($vo_display, "system");
$vs_table = self::getAttribute($vo_display, "type");
if ($o_config->get($vs_table . '_disable')) {
continue;
}
$t_display = $this->opb_updating ? ca_bundle_displays::find(array('code' => $vs_display_code, 'type' => $vs_table), array('returnAs' => 'firstModelInstance')) : false;
$t_display = $t_display ? $t_display : new ca_bundle_displays();
$t_display->setMode(ACCESS_WRITE);
$t_display->set("display_code", $vs_display_code);
$t_display->set("is_system", $vb_system);
$t_display->set("table_num", $vo_dm->getTableNum($vs_table));
$t_display->set("user_id", 1);
// let administrative user own these
$this->_processSettings($t_display, $vo_display->settings);
if ($t_display->getPrimaryKey()) {
$t_display->update();
} else {
$t_display->insert();
}
if ($t_display->numErrors()) {
$this->addError("There was an error while inserting display {$vs_display_code}: " . join(" ", $t_display->getErrors()));
} else {
self::addLabelsFromXMLElement($t_display, $vo_display->labels, $this->opa_locales);
if ($t_display->numErrors()) {
$this->addError("There was an error while inserting display label for {$vs_display_code}: " . join(" ", $t_display->getErrors()));
}
if (!$this->processDisplayPlacements($t_display, $vo_display->bundlePlacements, null)) {
return false;
}
}
if ($vo_display->typeRestrictions) {
foreach ($vo_display->typeRestrictions->children() as $vo_restriction) {
$t_list = new ca_lists();
$t_list_item = new ca_list_items();
$vs_restriction_code = trim((string) self::getAttribute($vo_restriction, "code"));
$vs_type = trim((string) self::getAttribute($vo_restriction, "type"));
$t_instance = $vo_dm->getInstanceByTableNum($vn_table_num = $vo_dm->getTableNum($vs_table));
$vs_type_list_name = $t_instance->getFieldListCode($t_instance->getTypeFieldName());
if ($vs_type) {
$t_list->load(array('list_code' => $vs_type_list_name));
$t_list_item->load(array('list_id' => $t_list->getPrimaryKey(), 'idno' => $vs_type));
}
$vn_type_id = $vs_type ? $t_list_item->getPrimaryKey() : null;
$t_restriction = $this->opb_updating ? ca_bundle_display_type_restrictions::find(array('table_num' => $vn_table_num, 'type_id' => $vn_type_id), array('returnAs' => 'firstModelInstance')) : false;
$t_restriction = $t_restriction ? $t_restriction : new ca_bundle_display_type_restrictions();
$t_restriction->setMode(ACCESS_WRITE);
$t_restriction->set('table_num', $vn_table_num);
$t_restriction->set('include_subtypes', (bool) $vo_restriction->includeSubtypes ? 1 : 0);
$t_restriction->set('type_id', $vn_type_id);
$t_restriction->set('display_id', $t_display->getPrimaryKey());
$this->_processSettings($t_restriction, $vo_restriction->settings);
if ($t_restriction->getPrimaryKey()) {
$t_restriction->update();
} else {
$t_restriction->insert();
}
if ($t_restriction->numErrors()) {
$this->addError("There was an error while inserting type restriction {$vs_restriction_code} in display {$vs_display_code}: " . join("; ", $t_restriction->getErrors()));
}
}
}
if ($vo_display->userAccess) {
$t_user = new ca_users();
$va_display_users = array();
foreach ($vo_display->userAccess->children() as $vo_permission) {
$vs_user = trim((string) self::getAttribute($vo_permission, "user"));
$vn_access = $this->_convertUserGroupAccessStringToInt(self::getAttribute($vo_permission, 'access'));
if ($vn_access && $t_user->load(array('user_name' => $vs_user))) {
//.........这里部分代码省略.........
示例15: getFacetHierarchyAncestorList
/**
* Given a item_id (request parameter 'id') returns a list of ancestors for use in the hierarchy browser
* Returned data is JSON format
*/
public function getFacetHierarchyAncestorList()
{
$pn_id = $this->request->getParameter('id', pInteger);
$ps_facet_name = $this->request->getParameter('facet', pString);
if (!is_array($va_facet_info = $this->opo_browse->getInfoForFacet($ps_facet_name))) {
return null;
}
$va_ancestors = array();
switch ($va_facet_info['type']) {
case 'attribute':
// is it a list attribute?
$t_element = new ca_metadata_elements();
if ($t_element->load(array('element_code' => $va_facet_info['element_code']))) {
if ($t_element->get('datatype') == 3) {
// 3=list
if (!$pn_id) {
$t_list = new ca_lists();
$pn_id = $t_list->getRootListItemID($t_element->get('list_id'));
}
$t_item = new ca_list_items($pn_id);
if ($t_item->getPrimaryKey()) {
$va_ancestors = array_reverse($t_item->getHierarchyAncestors(null, array('includeSelf' => true, 'idsOnly' => true)));
array_shift($va_ancestors);
}
}
}
break;
case 'label':
// label facet
$va_facet_info['table'] = $this->ops_tablename;
// fall through to default case
// fall through to default case
default:
$t_item = $this->opo_datamodel->getInstanceByTableName($va_facet_info['table']);
$t_item->load($pn_id);
if (method_exists($t_item, "getHierarchyList")) {
$va_access_values = caGetUserAccessValues($this->request);
$va_facet = $this->opo_browse->getFacet($ps_facet_name, array('sort' => 'name', 'checkAccess' => $va_access_values));
$va_hierarchy_list = $t_item->getHierarchyList(true);
$vn_hierarchies_in_use = 0;
foreach ($va_hierarchy_list as $vn_i => $va_item) {
if (isset($va_facet[$va_item[$t_item->primaryKey()]])) {
$vn_hierarchies_in_use++;
if ($vn_hierarchies_in_use > 1) {
break;
}
}
}
}
if ($t_item->getPrimaryKey()) {
$va_ancestors = array_reverse($t_item->getHierarchyAncestors(null, array('includeSelf' => true, 'idsOnly' => true)));
if (!is_array($va_ancestors)) {
$va_ancestors = array();
}
}
if ($vn_hierarchies_in_use <= 1) {
array_shift($va_ancestors);
}
break;
}
$this->view->setVar('ancestors', $va_ancestors);
return $this->render('Browse/facet_hierarchy_ancestors_json.php');
}