本文整理汇总了PHP中caGetListItemID函数的典型用法代码示例。如果您正苦于以下问题:PHP caGetListItemID函数的具体用法?PHP caGetListItemID怎么用?PHP caGetListItemID使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了caGetListItemID函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: refine
/**
*
*/
public function refine(&$pa_destination_data, $pa_group, $pa_item, $pa_source_data, $pa_options = null)
{
$o_log = isset($pa_options['log']) && is_object($pa_options['log']) ? $pa_options['log'] : null;
// Set place hierarchy
if ($vs_hierarchy = $pa_item['settings']['placeSplitter_placeHierarchy']) {
$vn_hierarchy_id = caGetListItemID('place_hierarchies', $vs_hierarchy);
} else {
// Default to first place hierarchy
$t_list = new ca_lists();
$va_hierarchy_ids = $t_list->getItemsForList('place_hierarchies', array('idsOnly' => true));
$vn_hierarchy_id = array_shift($va_hierarchy_ids);
}
if (!$vn_hierarchy_id) {
if ($o_log) {
$o_log->logError(_t('[placeSplitterRefinery] No place hierarchies are defined'));
}
return array();
}
$pa_options['hierarchyID'] = $vn_hierarchy_id;
$t_place = new ca_places();
if ($t_place->load(array('parent_id' => null, 'hierarchy_id' => $vn_hierarchy_id))) {
$pa_options['defaultParentID'] = $t_place->getPrimaryKey();
}
return caGenericImportSplitter('placeSplitter', 'place', 'ca_places', $this, $pa_destination_data, $pa_group, $pa_item, $pa_source_data, $pa_options);
}
示例2: setUp
public function setUp()
{
// don't forget to call parent so that request is set up correctly
parent::setUp();
// search subject table
$this->setPrimaryTable('ca_objects');
/**
* @see http://docs.collectiveaccess.org/wiki/Web_Service_API#Creating_new_records
* @see https://gist.githubusercontent.com/skeidel/3871797/raw/item_request.json
*/
$vn_test_vocab_item_id = caGetListItemID('test_vocab', 'test');
$this->assertGreaterThan(0, $vn_test_vocab_item_id);
$vn_image_id = $this->addTestRecord('ca_objects', array('intrinsic_fields' => array('type_id' => 'image'), 'preferred_labels' => array(array("locale" => "en_US", "name" => "Just an image")), 'related' => array('ca_list_items' => array(array('item_id' => $vn_test_vocab_item_id, 'type_id' => 'depicts')))));
$this->assertGreaterThan(0, $vn_image_id);
// search queries
$this->setSearchQueries(array('Just an image' => 1, 'Foo' => 1, '"Foo"' => 1, 'Bar' => 1, '"Bar"' => 1, 'ca_list_item_labels.name_singular:"Foo"' => 1, 'ca_list_item_labels.name_singular:"Bar"' => 1, 'Baz' => 0, '"Baz"' => 0, 'ca_list_item_labels.name_singular:"Baz"' => 0));
}
示例3: getRelatedItems
//.........这里部分代码省略.........
unset($va_rels[$vs_v][$vs_field]);
}
unset($va_rels[$vs_v]['_key']);
unset($va_rels[$vs_v]['row_id']);
}
}
if (!isset($pa_options['idsOnly']) || !$pa_options['idsOnly']) {
// Set 'label' entry - display label in current user's locale
foreach ($va_rels as $vs_v => $va_rel) {
$va_tmp = array(0 => $va_rel['labels']);
$va_tmp2 = caExtractValuesByUserLocale($va_tmp);
$va_rels[$vs_v]['label'] = array_shift($va_tmp2);
}
}
//
// END - non-self relation
//
}
}
// Apply restrictToBundleValues
$va_filters = isset($pa_options['restrictToBundleValues']) ? $pa_options['restrictToBundleValues'] : null;
if (is_array($va_filters) && sizeof($va_filters) > 0) {
foreach ($va_rels as $vn_pk => $va_related_item) {
foreach ($va_filters as $vs_filter => $va_filter_vals) {
if (!$vs_filter) {
continue;
}
if (!is_array($va_filter_vals)) {
$va_filter_vals = array($va_filter_vals);
}
foreach ($va_filter_vals as $vn_index => $vs_filter_val) {
// is value a list attribute idno?
$va_tmp = explode('.', $vs_filter);
$vs_element = array_pop($va_tmp);
if (!is_numeric($vs_filter_val) && (($t_element = $t_rel_item->_getElementInstance($vs_element)) && $t_element->get('datatype') == 3)) {
$va_filter_vals[$vn_index] = caGetListItemID($t_element->get('list_id'), $vs_filter_val);
}
}
$t_rel_item->load($va_related_item[$t_rel_item->primaryKey()]);
$va_filter_values = $t_rel_item->get($vs_filter, array('returnAsArray' => true, 'alwaysReturnItemID' => true));
$vb_keep = false;
if (is_array($va_filter_values)) {
foreach ($va_filter_values as $vm_filtered_val) {
if (!is_array($vm_filtered_val)) {
$vm_filtered_val = array($vm_filtered_val);
}
foreach ($vm_filtered_val as $vs_val) {
if (in_array($vs_val, $va_filter_vals)) {
// one match is enough to keep it
$vb_keep = true;
}
}
}
}
if (!$vb_keep) {
unset($va_rels[$vn_pk]);
}
}
}
}
//
// Sort on fields if specified
//
if (is_array($va_sort_fields) && sizeof($va_rels)) {
$va_ids = array();
$vs_rel_pk = $t_rel_item->primaryKey();
foreach ($va_rels as $vn_i => $va_rel) {
$va_ids[] = $va_rel[$vs_rel_pk];
}
// Handle sorting on attribute values
$vs_rel_pk = $t_rel_item->primaryKey();
foreach ($va_sort_fields as $vn_x => $vs_sort_field) {
if ($vs_sort_field == 'relation_id') {
// sort by relationship primary key
if ($t_item_rel) {
$va_sort_fields[$vn_x] = $vs_sort_field = $t_item_rel->tableName() . '.' . $t_item_rel->primaryKey();
}
continue;
}
$va_tmp = explode('.', $vs_sort_field);
if ($va_tmp[0] == $vs_related_table_name) {
$qr_rel = $t_rel_item->makeSearchResult($va_tmp[0], $va_ids);
$vs_table = array_shift($va_tmp);
$vs_key = join(".", $va_tmp);
while ($qr_rel->nextHit()) {
$vn_pk_val = $qr_rel->get($vs_table . "." . $vs_rel_pk);
foreach ($va_rels as $vn_rel_id => $va_rel) {
if ($va_rel[$vs_rel_pk] == $vn_pk_val) {
$va_rels[$vn_rel_id][$vs_key] = $qr_rel->get($vs_sort_field, array("delimiter" => ";", 'sortable' => 1));
break;
}
}
}
}
}
// Perform sort
$va_rels = caSortArrayByKeyInValue($va_rels, $va_sort_fields, $vs_sort_direction);
}
return $va_rels;
}
示例4: _processBrowseSettings
/**
* Rewrite browse config settings as needed before starting actual processing of browse
*/
private function _processBrowseSettings()
{
$va_revised_facets = array();
foreach ($this->opa_browse_settings['facets'] as $vs_facet_name => $va_facet_info) {
// generate_facets_for_types config directive triggers auto-generation of facet config for each type of an authority item
// it's typically employed to provide browsing of occurrences where the various types are unrelated
// you can also use this on other authorities to provide a finer-grained browse without having to know the type hierarchy ahead of time
if ($va_facet_info['type'] === 'authority' && isset($va_facet_info['generate_facets_for_types']) && $va_facet_info['generate_facets_for_types']) {
// get types for authority
$t_table = $this->opo_datamodel->getInstanceByTableName($va_facet_info['table'], true);
$va_type_list = $t_table->getTypeList();
// auto-generate facets
foreach ($va_type_list as $vn_type_id => $va_type_info) {
if ($va_type_info['is_enabled']) {
$va_facet_info = array_merge($va_facet_info, array('label_singular' => $va_type_info['name_singular'], 'label_singular_with_indefinite_article' => _t('a') . ' ' . $va_type_info['name_singular'], 'label_plural' => $va_type_info['name_plural'], 'restrict_to_types' => array($va_type_info['item_id'])));
$va_revised_facets[$vs_facet_name . '_' . $vn_type_id] = $va_facet_info;
}
}
} else {
$va_revised_facets[$vs_facet_name] = $va_facet_info;
}
}
// rewrite single_value settings for attribute and fieldList facets
foreach ($va_revised_facets as $vs_facet => $va_facet_info) {
if (!(isset($va_facet_info['single_value']) && strlen($va_facet_info['single_value']))) {
continue;
}
switch ($va_facet_info['type']) {
case 'attribute':
$t_element = new ca_metadata_elements();
if ($t_element->load(array('element_code' => $va_facet_info['element_code']))) {
if ($t_element->get('datatype') == __CA_ATTRIBUTE_VALUE_LIST__ && ($vn_list_id = $t_element->get('list_id'))) {
if ($vn_item_id = caGetListItemID($vn_list_id, $va_facet_info['single_value'])) {
$va_revised_facets[$vs_facet]['single_value'] = $vn_item_id;
}
}
}
break;
case 'fieldList':
$t_instance = $this->opo_datamodel->getInstanceByTableName($this->ops_browse_table_name, true);
if ($vn_item_id = caGetListItemID($t_instance->getFieldInfo($va_facet_info['field'], 'LIST_CODE'), $va_facet_info['single_value'])) {
$va_revised_facets[$vs_facet]['single_value'] = $vn_item_id;
}
break;
}
}
$this->opa_browse_settings['facets'] = $va_revised_facets;
}
示例5: array
//print caBusyIndicatorIcon($this->request).' '.addslashes(_t('Loading...'));
$va_rel_ids = $t_item->get('ca_objects_x_entities.relation_id', array('returnAsArray' => true));
$qr_rels = caMakeSearchResult('ca_objects_x_entities', $va_rel_ids, array('sort' => 'ca_objects_x_entities.date_out'));
// set all of the page object_ids
$va_page_ids = array();
while ($qr_rels->nextHit()) {
$va_page_ids[] = $qr_rels->get("ca_objects_x_entities.see_original_link", array('idsOnly' => 1));
}
$qr_pages = caMakeSearchResult('ca_objects', $va_page_ids);
$va_parents = array();
while ($qr_pages->nextHit()) {
$va_parents[$qr_pages->get('ca_objects.object_id')] = $qr_pages->get('ca_objects.parent.preferred_labels.name');
}
$qr_rels->seek(0);
// reset the result to the beginning so we can run through it again
$vn_page_type_id = caGetListItemID('object_types', 'page');
$vn_i = 0;
while ($qr_rels->nextHit()) {
if ($qr_rels->get('ca_objects.type_id') == $vn_page_type_id) {
continue;
}
print "<div class='row ledgerRow'>";
print "<div class='col-xs-3 col-sm-3 col-md-3 col-lg-3' id='book" . $vn_i . "'>";
if ($qr_rels->get("ca_objects.parent.preferred_labels")) {
$va_label_trunk = explode(':', $qr_rels->get("ca_objects.parent.preferred_labels"));
print caNavLink($this->request, $va_label_trunk[0], '', '', 'Detail', 'objects/' . $qr_rels->get("ca_objects.parent.object_id"));
} else {
$va_label_trunk = explode(':', $qr_rels->get("ca_objects.preferred_labels"));
print caNavLink($this->request, $va_label_trunk[0], '', '', 'Detail', 'objects/' . $qr_rels->get("ca_objects.object_id"));
}
$va_book_info = array();
示例6: runSearchEndpoint
/**
* @param array $pa_config
* @param RequestHTTP $po_request
* @return array
* @throws Exception
*/
private static function runSearchEndpoint($pa_config, $po_request)
{
$o_dm = Datamodel::load();
// load blank instance
$t_instance = $o_dm->getInstance($pa_config['table']);
if (!$t_instance instanceof BundlableLabelableBaseModelWithAttributes) {
throw new Exception('invalid table');
}
if (!($ps_q = $po_request->getParameter('q', pString))) {
throw new Exception('No query specified');
}
$o_search = caGetSearchInstance($pa_config['table']);
// restrictToTypes
if ($pa_config['restrictToTypes'] && is_array($pa_config['restrictToTypes']) && sizeof($pa_config['restrictToTypes']) > 0) {
$va_type_filter = array();
foreach ($pa_config['restrictToTypes'] as $vs_type_code) {
$va_type_filter[] = caGetListItemID($t_instance->getTypeListCode(), $vs_type_code);
}
$o_search->addResultFilter($t_instance->tableName() . '.type_id', 'IN', join(",", $va_type_filter));
}
$o_res = $o_search->search($ps_q, array('sort' => $po_request->getParameter('sort', pString), 'sortDirection' => $po_request->getParameter('sortDirection', pString), 'start' => $po_request->getParameter('start', pInteger), 'limit' => $po_request->getParameter('limit', pInteger), 'checkAccess' => $pa_config['checkAccess']));
$va_return = array();
while ($o_res->nextHit()) {
$va_hit = array();
foreach ($pa_config['content'] as $vs_key => $vs_template) {
$va_hit[self::sanitizeKey($vs_key)] = $o_res->getWithTemplate($vs_template);
}
$va_return[$o_res->get($t_instance->primaryKey(true))] = $va_hit;
}
return $va_return;
}
示例7: get
//.........这里部分代码省略.........
* excludeRelationshipTypes = For bundles referencing data in related tables (ex. calling ca_entities.idno from a ca_objects result) will restrict returned items to those *not* related using the specified relationship types. An array of relationship type idnos and/or type_ids may be specified. [Default is null]
* restrictToType = Synonym for restrictToTypes. [Default is null]
* restrictToRelationshipType = Synonym for restrictToRelationshipTypes. [Default is null]
* excludeType = Synonym for excludeTypes. [Default is null]
* excludeRelationshipType = Synonym for excludeRelationshipTypes. [Default is null]
* filters = Array list of elements to filter returned values on. The element must be part of the container being fetched from. For example, when fetching a value from a container element (ex. ca_objects.dates.date_value) you can filter on any other subelement in that container by passing the name of the subelement and a value (ex. "date_type" => "copyright"). Pass only the name of the subelement, not the full path that includes the table and container element. You may filter on multiple subelements by passing each subelement as a key in the array. Only values that match all filters are returned. You can filter on multiple values for a subelement by passing an array of values rather than a scalar (Eg. "date_type" => array("copyright", "patent")). Values that match *any* of the values will be returned. Only simple equivalance is supported. NOTE: Filters are only available when returnAsArray or returnWithStructure are set. [Default is null]
* assumeDisplayField = For returnWithStructure, return display field for ambiguous preferred label specifiers (ex. ca_entities.preferred_labels => ca_entities.preferred_labels.displayname). If set to false an array with all label fields is returned. [Default is true]
* returnURL = When fetching intrinsic value of type FT_MEDIA return URL to media rather than HTML tag. [Default is false]
* returnPath = When fetching intrinsic value of type FT_MEDIA return path to media rather than HTML tag. [Default is false]
* unserialize = When fetching intrinsic value of type FT_VARS (serialized variables) return unserialized value. [Default is false]
*
* [Formatting options for strings and arrays]
* template = Display template use when formatting return values. @see http://docs.collectiveaccess.org/wiki/Display_Templates. [Default is null]
* delimiter = Characters to place in between repeating values when returning a string
* makeLink = Return value as a link to the relevant editor (Providence) or detail (Pawtucket) when bundle references data in a related table; return value as HTML link when value is URL type. [Default is false]
* returnAsLink = Synonym for makeLink. [Default is false]
* convertCodesToDisplayText = Convert list item_ids text in the user's preferred locale for display. [Default is false]
* convertCodesToIdno = Convert list item_ids to idno's (ca_list_items.idno). If convertCodesToDisplayText is also set then it will take precedence. [Default is false]
* output = Convert list item_ids to display text in user's preferred locale ("text") or idno ("idno"). This is an easier to type alternative to the convertCodesToDisplayText and convertCodesToIdno options. [Default is null]
* sort = Array list of bundles to sort returned values on. Currently sort is only supported when getting related values via simple related <table_name> and <table_name>.related bundle specifiers. Eg. from a ca_objects results you can sort when fetching 'ca_entities', 'ca_entities.related', 'ca_objects.related', etc.. The sortable bundle specifiers are fields with or without tablename. Only those fields returned for the related tables (intrinsics and label fields) are sortable. You cannot currenty sort on attributes. [Default is null]
*
* [Formatting options for hierarchies]
* maxLevelsFromTop = Restrict the number of levels returned to the top-most beginning with the root. [Default is null]
* maxLevelsFromBottom = Restrict the number of levels returned to the bottom-most starting with the lowest leaf node. [Default is null]
* maxLevels = synonym for maxLevelsFromBottom. [Default is null]
* hierarchyDirection = Order in which to return hierarchical levels. Set to either "asc" or "desc". "Asc"ending returns hierarchy beginning with the root; "desc"ending begins with the child furthest from the root. [Default is asc]
* allDescendants = Return all items from the full depth of the hierarchy when fetching children. By default only immediate children are returned. [Default is false]
*
* [Front-end access control]
* checkAccess = Array of access values to filter returned values on. Available for any table with an "access" field (ca_objects, ca_entities, etc.). If omitted no filtering is performed. [Default is null]
*
*
* @param string $ps_field
* @param array $pa_options Options as described above
* @return mixed String or array
*/
public function get($ps_field, $pa_options = null)
{
if (!is_array($pa_options)) {
$pa_options = array();
}
$vb_return_as_array = isset($pa_options['returnAsArray']) ? (bool) $pa_options['returnAsArray'] : false;
$va_filters = is_array($pa_options['filters']) ? $pa_options['filters'] : array();
// Add table name to field specs that lack it
if (strpos($ps_field, '.') === false && !$this->opo_datamodel->tableExists($ps_field)) {
$va_tmp = array($this->ops_table_name, $ps_field);
$ps_field = $this->ops_table_name . ".{$ps_field}";
}
if (isset($pa_options['template']) && $pa_options['template']) {
return $this->getWithTemplate($pa_options['template'], $pa_options);
}
$vm_val = self::_get($ps_field, $pa_options);
if ($vb_return_as_array && sizeof($va_filters)) {
$va_tmp = explode(".", $ps_field);
if (sizeof($va_tmp) > 1) {
array_pop($va_tmp);
}
if (!($t_instance = SearchResult::$s_instance_cache[$va_tmp[0]])) {
$t_instance = SearchResult::$s_instance_cache[$va_tmp[0]] = $this->opo_datamodel->getInstanceByTableName($va_tmp[0], true);
}
if ($t_instance) {
$va_keepers = array();
foreach ($va_filters as $vs_filter => $va_filter_vals) {
if (!$vs_filter) {
continue;
}
if (!is_array($va_filter_vals)) {
$va_filter_vals = array($va_filter_vals);
}
foreach ($va_filter_vals as $vn_index => $vs_filter_val) {
// is value a list attribute idno?
if (!is_numeric($vs_filter_val) && (($t_element = $t_instance->_getElementInstance($vs_filter)) && $t_element->get('datatype') == 3)) {
$va_filter_vals[$vn_index] = caGetListItemID($t_element->get('list_id'), $vs_filter_val);
}
}
$va_filter_values = $this->get(join(".", $va_tmp) . ".{$vs_filter}", array('returnAsArray' => true, 'alwaysReturnItemID' => true));
if (is_array($va_filter_values)) {
foreach ($va_filter_values as $vn_id => $vm_filtered_val) {
if ((!isset($va_keepers[$vn_id]) || $va_keepers[$vn_id]) && in_array($vm_filtered_val, $va_filter_vals)) {
// any match for the element counts
$va_keepers[$vn_id] = true;
} else {
// if no match on any criteria kill it
$va_keepers[$vn_id] = false;
}
}
}
}
$va_filtered_vals = array();
foreach ($va_keepers as $vn_id => $vb_include) {
if (!$vb_include) {
continue;
}
$va_filtered_vals[$vn_id] = $vm_val[$vn_id];
}
return $va_filtered_vals;
}
}
return $vm_val;
}
示例8: 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);
}
示例9: search
protected function search($pa_bundles = null)
{
$va_return = parent::search($pa_bundles);
if ($this->getTableName() == 'ca_entities' && is_array($va_return['results']) && sizeof($va_return['results']) > 0) {
$o_db = new Db();
$t_element = new ca_metadata_elements();
$t_element->load(array('element_code' => 'is_index_display'));
$vn_element_id = $t_element->getPrimaryKey();
if (!$vn_element_id) {
return $va_return;
}
$vn_yes_id = caGetListItemID('yn', 'yes');
foreach ($va_return['results'] as &$va_result) {
$vn_entity_id = $va_result['entity_id'];
$qr_objects = $o_db->query("\n\t\t\t\t\tSELECT DISTINCT ca_objects.object_id FROM ca_entities, ca_objects_x_entities, ca_objects, ca_attributes, ca_attribute_values\n\t\t\t\t\tWHERE ca_entities.entity_id = ca_objects_x_entities.entity_id\n\t\t\t\t\tAND ca_attributes.row_id = ca_objects.object_id\n\t\t\t\t\tAND ca_attribute_values.attribute_id = ca_attributes.attribute_id\n\t\t\t\t\tAND ca_objects_x_entities.object_id = ca_objects.object_id\n\t\t\t\t\tAND ca_attribute_values.element_id = ?\n\t\t\t\t\tAND ca_entities.entity_id = ?\n\t\t\t\t\tAND ca_attribute_values.item_id = ?\n\t\t\t\t\tAND ca_objects.deleted = 0\n\t\t\t\t", $vn_element_id, $vn_entity_id, $vn_yes_id);
while ($qr_objects->nextRow()) {
$va_object_info = array();
$vn_object_id = $qr_objects->get('ca_objects.object_id');
if (MemoryCache::contains($vn_object_id, 'AboutDrawingServices')) {
$va_object_info = MemoryCache::fetch($vn_object_id, 'AboutDrawingServices');
} else {
$va_object_info['object_id'] = $vn_object_id;
$qr_labels = $o_db->query("\n\t\t\t\t\t\t\tSELECT ca_object_labels.* FROM ca_object_labels, ca_objects\n\t\t\t\t\t\t\tWHERE ca_object_labels.object_id = ca_objects.object_id\n\t\t\t\t\t\t\tAND ca_objects.object_id = ?\n\t\t\t\t\t\t", $vn_object_id);
$vs_label = '';
while ($qr_labels->nextRow()) {
$va_object_info['labels'][] = $qr_labels->getRow();
$vs_label = $qr_labels->get('name');
// keep the last label around
}
$va_object_info['label'] = $vs_label;
$qr_reps = $o_db->query("\n\t\t\t\t\t\t\tSELECT ca_object_representations.* FROM ca_object_representations, ca_objects_x_object_representations, ca_objects\n\t\t\t\t\t\t\tWHERE ca_object_representations.representation_id = ca_objects_x_object_representations.representation_id\n\t\t\t\t\t\t\tAND ca_objects_x_object_representations.object_id = ca_objects.object_id\n\t\t\t\t\t\t\tAND ca_objects.object_id = ?\n\t\t\t\t\t\t\tAND ca_objects.deleted = 0 AND ca_object_representations.deleted = 0\n\t\t\t\t\t\t", $vn_object_id);
while ($qr_reps->nextRow()) {
$va_object_info['representations'][] = array('representation_id' => $qr_reps->get('representation_id'), 'icon' => $qr_reps->getMediaUrl('media', 'icon'), 'preview170' => $qr_reps->getMediaUrl('media', 'preview170'), 'medium' => $qr_reps->getMediaUrl('media', 'medium'), 'original' => $qr_reps->getMediaUrl('media', 'original'));
}
MemoryCache::save($vn_object_id, $va_object_info, 'AboutDrawingServices');
}
$va_result['ca_objects'][] = $va_object_info;
}
/* the old&simple, but very slow code
$t_entity = new ca_entities($va_result['entity_id']);
$va_objects = $t_entity->getRelatedItems('ca_objects');
foreach($va_objects as $va_object) {
$t_object = new ca_objects($va_object['object_id']);
$va_reps = $t_object->getRepresentations(array('icon', 'preview170', 'medium', 'original'));
$va_representation_info = array();
foreach($va_reps as $va_rep) {
$va_representation_info[] = array(
'representation_id' => $va_rep['representation_id'],
'urls' => $va_rep['urls'],
);
}
$va_object_info = array();
$va_object_info['object_id'] = $va_object['object_id'];
$va_object_info['labels'] = $va_object['labels'];
$va_object_info['label'] = $va_object['label'];
$va_object_info['representations'] = $va_representation_info;
$va_result['ca_objects'][] = $va_object_info;
}*/
}
}
return $va_return;
}
示例10: parseValue
/**
* @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
* matchOn =
*
* @return array
*/
public function parseValue($ps_value, $pa_element_info, $pa_options = null)
{
$vb_treat_value_as_idno = caGetOption('alwaysTreatValueAsIdno', $pa_options, false);
$va_match_on = caGetOption('matchOn', $pa_options, null);
if ($va_match_on && !is_array($va_match_on)) {
$va_match_on = array($va_match_on);
}
if (!is_array($va_match_on) && $vb_treat_value_as_idno) {
$va_match_on = array('idno', 'item_id');
}
if ((!is_array($va_match_on) || !sizeof($va_match_on)) && preg_match('![^\\d]+!', $ps_value)) {
$va_match_on = array('idno', 'item_id');
}
if ($vb_treat_value_as_idno && !in_array('idno', $va_match_on)) {
array_push($va_match_on, 'idno');
}
if (!is_array($va_match_on) || !sizeof($va_match_on)) {
$va_match_on = array('item_id');
}
$o_trans = caGetOption('transaction', $pa_options, null);
$vb_require_value = is_null($pa_element_info['settings']['requireValue']) ? false : (bool) $pa_element_info['settings']['requireValue'];
$ps_orig_value = $ps_value;
$vn_id = null;
$t_item = new ca_list_items();
if ($o_trans) {
$t_item->setTransaction($o_trans);
}
foreach ($va_match_on as $vs_match_on) {
switch ($vs_match_on) {
case 'idno':
// try to convert idno to item_id
if ($vn_id = caGetListItemID($pa_element_info['list_id'], $ps_value, $pa_options)) {
break 2;
}
break;
case 'label':
case 'labels':
// try to convert label to item_id
if ($vn_id = caGetListItemIDForLabel($pa_element_info['list_id'], $ps_value, $pa_options)) {
break 2;
}
break;
case 'item_id':
default:
if ($vn_id = ca_list_items::find(array('item_id' => (int) $ps_value, 'list_id' => $pa_element_info['list_id']), array('returnAs' => 'firstId'))) {
break 2;
//} else {
//$this->postError(1970, _t('Value with item_id %1 does not exist in list %2', $ps_value, $pa_element_info['list_id']), 'ListAttributeValue->parseValue()');
}
break;
}
}
if (!$vb_require_value && !$vn_id) {
return array('value_longtext1' => null, 'item_id' => null);
} elseif ($vb_require_value && !$vn_id && !strlen($ps_value)) {
$this->postError(1970, _t('Value for %1 [%2] cannot be blank', $pa_element_info['displayLabel'], $pa_element_info['element_code']), 'ListAttributeValue->parseValue()');
return false;
} elseif ($vb_require_value && !$vn_id) {
$this->postError(1970, _t('Value %3 for %1 [%2] is invalid', $pa_element_info['displayLabel'], $pa_element_info['element_code'], $ps_value), 'ListAttributeValue->parseValue()');
return false;
}
return array('value_longtext1' => (int) $vn_id, 'item_id' => (int) $vn_id);
}
示例11: get
//.........这里部分代码省略.........
// [PRIMARY TABLE] Preferred/nonpreferred labels
//
if (in_array($va_path_components['field_name'], array('preferred_labels', 'nonpreferred_labels')) && $t_instance instanceof LabelableBaseModelWithAttributes) {
$vs_label_table_name = $t_instance->getLabelTableName();
if (!isset(self::$s_prefetch_cache[$vs_label_table_name][$vn_row_id][$vs_opt_md5])) {
$this->prefetchLabels($va_path_components['table_name'], $this->opo_engine_result->currentRow(), $this->getOption('prefetch'), $pa_options);
}
$vm_val = $this->_getLabelValue(self::$s_prefetch_cache[$vs_label_table_name][$vn_row_id][$vs_opt_md5], $t_instance, $va_val_opts);
goto filter;
}
if ($t_instance->hasField($va_path_components['field_name'])) {
$va_val_opts['fieldInfo'] = $t_instance->getFieldInfo($va_path_components['field_name']);
//
// [PRIMARY TABLE] Plain old intrinsic
//
if (!isset(self::$s_prefetch_cache[$va_path_components['table_name']][$vn_row_id][$vs_opt_md5])) {
$this->prefetch($va_path_components['table_name'], $this->opo_engine_result->currentRow(), $this->getOption('prefetch'), $pa_options);
}
$vm_val = $this->_getIntrinsicValue(self::$s_prefetch_cache[$va_path_components['table_name']][$vn_row_id][$vs_opt_md5], $t_instance, $va_val_opts);
goto filter;
} elseif (method_exists($t_instance, 'isValidBundle') && !$t_instance->hasElement($va_path_components['field_name'], null, false, array('dontCache' => false)) && $t_instance->isValidBundle($va_path_components['field_name'])) {
//
// [PRIMARY TABLE] Special bundle
//
if (!isset(self::$s_prefetch_cache[$va_path_components['table_name']][$vn_row_id][$vs_opt_md5])) {
$this->prefetch($va_path_components['table_name'], $this->opo_engine_result->currentRow(), $this->getOption('prefetch'), $pa_options);
}
$vm_val = $t_instance->renderBundleForDisplay($va_path_components['field_name'], $vn_row_id, self::$s_prefetch_cache[$va_path_components['table_name']][$vn_row_id][$vs_opt_md5], $va_val_opts);
goto filter;
} else {
//
// [PRIMARY TABLE] Metadata attribute
//
if ($t_instance instanceof BaseModelWithAttributes && isset($va_path_components['field_name']) && $va_path_components['field_name'] && ($t_element = $t_instance->_getElementInstance($va_path_components['field_name']))) {
$vn_element_id = $t_element->getPrimaryKey();
} else {
return $pa_options['returnAsArray'] ? array() : null;
}
if (!isset(ca_attributes::$s_get_attributes_cache[(int) $this->opn_table_num . '/' . (int) $vn_row_id][(int) $vn_element_id])) {
$va_element_ids = $vn_element_id ? array($vn_element_id) : null;
if (is_array($va_prefetch_attributes = $this->getOption('prefetchAttributes')) && sizeof($va_prefetch_attributes)) {
$va_element_ids = array_unique($va_element_ids + $va_prefetch_attributes);
}
ca_attributes::prefetchAttributes($this->opo_subject_instance->getDb(), $this->opn_table_num, $this->getRowIDsToPrefetch($this->opo_engine_result->currentRow(), $this->getOption('prefetch')), $va_element_ids, array('dontFetchAlreadyCachedValues' => true));
}
$va_attributes = ca_attributes::getAttributes($this->opo_subject_instance->getDb(), $this->opn_table_num, $vn_row_id, array($vn_element_id), array());
$vm_val = $this->_getAttributeValue($va_attributes[$vn_element_id], $t_instance, $va_val_opts);
goto filter;
}
}
}
filter:
if ($vb_return_as_array && sizeof($va_filters)) {
$va_tmp = explode(".", $ps_field);
if (sizeof($va_tmp) > 1) {
array_pop($va_tmp);
}
if (!($t_instance = SearchResult::$s_instance_cache[$va_tmp[0]])) {
$t_instance = SearchResult::$s_instance_cache[$va_tmp[0]] = SearchResult::$opo_datamodel->getInstanceByTableName($va_tmp[0], true);
}
if ($t_instance) {
$va_keepers = array();
foreach ($va_filters as $vs_filter => $va_filter_vals) {
if (!$vs_filter) {
continue;
}
if (!is_array($va_filter_vals)) {
$va_filter_vals = array($va_filter_vals);
}
foreach ($va_filter_vals as $vn_index => $vs_filter_val) {
// is value a list attribute idno?
if (!is_numeric($vs_filter_val) && (($t_element = $t_instance->_getElementInstance($vs_filter)) && $t_element->get('datatype') == 3)) {
$va_filter_vals[$vn_index] = caGetListItemID($t_element->get('list_id'), $vs_filter_val);
}
}
$va_filter_values = $this->get(join(".", $va_tmp) . ".{$vs_filter}", array('returnAsArray' => true, 'alwaysReturnItemID' => true));
if (is_array($va_filter_values)) {
foreach ($va_filter_values as $vn_id => $vm_filtered_val) {
if ((!isset($va_keepers[$vn_id]) || $va_keepers[$vn_id]) && in_array($vm_filtered_val, $va_filter_vals)) {
// any match for the element counts
$va_keepers[$vn_id] = true;
} else {
// if no match on any criteria kill it
$va_keepers[$vn_id] = false;
}
}
}
}
$va_filtered_vals = array();
foreach ($va_keepers as $vn_id => $vb_include) {
if (!$vb_include) {
continue;
}
$va_filtered_vals[$vn_id] = $vm_val[$vn_id];
}
return $va_filtered_vals;
}
}
return $vm_val;
}
示例12: join
if (!$t_list->load(array('list_code' => 'place_hierarchies'))) {
$t_list->setMode(ACCESS_WRITE);
$t_list->set('list_code', 'place_hierarchies');
$t_list->set('is_system_list', 1);
$t_list->set('is_hierarchical', 1);
$t_list->set('use_as_vocabulary', 0);
$t_list->insert();
if ($t_list->numErrors()) {
print "[Error] couldn't create ca_list row for place hierarchies: " . join('; ', $t_list->getErrors()) . "\n";
die;
}
$t_list->addLabel(array('name' => 'Place hierarchies'), $pn_en_locale_id, null, true);
}
$vn_list_id = $t_list->getPrimaryKey();
// create place hierarchy
if (!($vn_tgn_id = caGetListItemID('place_hierarchies', 'tgn'))) {
$t_tgn = $t_list->addItem('tgn', true, false, null, null, 'tgn');
$t_tgn->addLabel(array('name_singular' => 'Thesaurus of Geographic Names', 'name_plural' => 'Thesaurus of Geographic Names'), $pn_en_locale_id, null, true);
$vn_tgn_id = $t_tgn->getPrimaryKey();
} else {
$t_tgn = new ca_list_items($vn_tgn_id);
}
// Create list for place types (if it doesn't exist already)
$t_place_types = new ca_lists();
if (!$t_place_types->load(array('list_code' => 'tgn_place_types'))) {
$t_place_types->setMode(ACCESS_WRITE);
$t_place_types->set('list_code', 'tgn_place_types');
$t_place_types->set('is_system_list', 1);
$t_place_types->set('is_hierarchical', 1);
$t_place_types->set('use_as_vocabulary', 1);
$t_place_types->insert();
示例13: get
/**
* Returns a value from the query result. This can be a single value if it is a field in the subject table (eg. objects table in an objects search), or
* perhaps multiple related values (eg. related entities in an objects search). By default get() always returns a single value; for fields with multiple values
* the value will be the first value encountered when loading the field data.
*
* You can fetch the values of attributes attached to the subject row (ie. if you're searching for ca_objects rows, the subject row is the ca_objects row)
* by use the "virtual" field name <subject_table_name>.<element_code> (ex. ca_objects.date_created)
* If the attribute is a multi-value container then you can fetch a specific value using the format <subject_table_name>.<attribute_element_code>/<value_element_code>
* For example, if you want to get the "date_value" value out of a "date" attribute attached to a ca_objects row, then you'd call get()
* with this fieldname: ca_objects.date/date_value
*
* If you want to get the other values for a multiple-value fields use the following options:
*
* returnAsArray = if true, return an array, otherwise return a string (default is false)
* template = formats attribute values; precede element codes with a caret ("^"). Eg. "^address1<br/>^city, ^state ^postalcode ^country"; only used when returnAsArray is false and a scalar is therefore to be returned.
* delimiter =
* returnAllLocales =
* convertCodesToDisplayText = if true then item_ids are automatically converted to display text in the current locale; default is false (return item_ids raw)
*
* restrict_to_type = restricts returned items to those of the specified type; only supports a single type which can be specified as a list item_code or item_id
* restrictToType = synonym for restrict_to_type
* restrict_to_types = restricts returned items to those of the specified types; pass an array of list item_codes or item_ids
* restrictToTypes = synonym for restrict_to_types
* restrict_to_relationship_types = restricts returned items to those related to the current row by the specified relationship type(s). You can pass either an array of types or a single type. The types can be relationship type_code's or type_id's.
* restrictToRelationshipTypes = synonym for restrict_to_relationship_types
*
* exclude_relationship_types = omits any items related to the current row with any of the specified types from the returned set of its. You can pass either an array of types or a single type. The types can be relationship type_code's or type_id's.
* excludeRelationshipTypes = synonym for exclude_relationship_types
*
* returnAsLink = if true and $ps_field is set to a specific field in a related table, or $ps_field is set to a related table
* (eg. ca_entities or ca_entities.related) AND the template option is set and returnAllLocales is not set, then returned values will be links. The destination of the link will be the appropriate editor when executed within Providence or the appropriate detail page when executed within Pawtucket or another front-end. Default is false.
* If $ps_field is set to refer to a URL metadata element and returnAsLink is set then the returned values will be HTML links using the URL value.
* returnAsLinkText = text to use a content of HTML link. If omitted the url itself is used as the link content.
* returnAsLinkAttributes = array of attributes to include in link <a> tag. Use this to set class, alt and any other link attributes.
* returnAsLinkTarget = Optional link target. If any plugin implementing hookGetAsLink() responds to the specified target then the plugin will be used to generate the links rather than CA's default link generator.
*
* sort = optional array of bundles to sort returned values on. Currently only supported when getting related values via simple related <table_name> and <table_name>.related invokations. Eg. from a ca_objects results you can use the 'sort' option got get('ca_entities'), get('ca_entities.related') or get('ca_objects.related'). The bundle specifiers are fields with or without tablename. Only those fields returned for the related tables (intrinsics and label fields) are sortable. You cannot sort on attributes.
* filter = optional array of elements to filter returned values on. The element must be part off the container being fetched from. For example, if you're get()'ing a value from a container element (Eg. ca_objects.dates.date_value) you can filter on any other subelement in that container by passing the name of the subelement and a value (Eg. "date_type" => "copyright"). Pass only the name of the subelement, not the full path that includes the table and container element. You can filter on multiple subelements by passing each subelement as a key in the array. Only values that match all filters are returned. You can filter on multiple values for a subelement by passing an array of values rather than a scalar (Eg. "date_type" => array("copyright", "patent")). Values that match *any* of the values will be returned. Only simple equivalance is supported. NOTE: Filters are only available when returnAsArray is set. They will be ignored if returnAsArray is not set.
*
* maxLevelsFromTop = for hierarchical gets, restricts the number of levels returned to the top-most starting with the root.
* maxLevelsFromBottom = for hierarchical gets, restricts the number of levels returned to the bottom-most starting with the lowest leaf node.
* maxLevels = synonym for maxLevelsFromBottom
*/
public function get($ps_field, $pa_options = null)
{
$vb_return_as_array = caGetOption('returnAsArray', $pa_options, false, array('castTo' => 'bool'));
$va_filters = caGetOption('filters', $pa_options, array(), array('castTo' => 'array'));
$vm_val = self::_get($ps_field, $pa_options);
if ($vb_return_as_array && sizeof($va_filters)) {
$va_tmp = explode(".", $ps_field);
if (sizeof($va_tmp) > 1) {
array_pop($va_tmp);
}
if ($t_instance = $this->opo_datamodel->getInstanceByTableName($va_tmp[0], true)) {
$va_keepers = array();
foreach ($va_filters as $vs_filter => $va_filter_vals) {
if (!is_array($va_filter_vals)) {
$va_filter_vals = array($va_filter_vals);
}
foreach ($va_filter_vals as $vn_index => $vs_filter_val) {
// is value a list attribute idno?
if (!is_numeric($vs_filter_val) && (($t_element = $t_instance->_getElementInstance($vs_filter)) && $t_element->get('datatype') == 3)) {
$va_filter_vals[$vn_index] = caGetListItemID($t_element->get('list_id'), $vs_filter_val);
}
}
$va_filter_values = $this->get(join(".", $va_tmp) . ".{$vs_filter}", array('returnAsArray' => true, 'alwaysReturnItemID' => true));
foreach ($va_filter_values as $vn_id => $vm_filtered_val) {
if ((!isset($va_keepers[$vn_id]) || $va_keepers[$vn_id]) && in_array($vm_filtered_val, $va_filter_vals)) {
// any match for the element counts
$va_keepers[$vn_id] = true;
} else {
// if no match on any criteria kill it
$va_keepers[$vn_id] = false;
}
}
}
$va_filtered_vals = array();
foreach ($va_keepers as $vn_id => $vb_include) {
if (!$vb_include) {
continue;
}
$va_filtered_vals[$vn_id] = $vm_val[$vn_id];
}
return $va_filtered_vals;
}
}
return $vm_val;
}
示例14: getPresetsJavascript
/**
*
*/
public function getPresetsJavascript($ps_field_prefix, $pa_options = null)
{
if (!($vn_element_id = $this->getPrimaryKey())) {
return null;
}
// element must be loaded
$o_presets = Configuration::load(__CA_APP_DIR__ . "/conf/attributePresets.conf");
if ($va_presets = $o_presets->getAssoc($this->get('element_code'))) {
$va_elements = $this->getElementsInSet();
$va_element_code_to_ids = $va_element_info = array();
foreach ($va_elements as $va_element) {
$va_element_code_to_ids[$va_element['element_code']] = $va_element['element_id'];
$va_element_info[$va_element['element_code']] = $va_element;
}
foreach ($va_presets as $vs_code => $va_preset) {
foreach ($va_preset['values'] as $vs_k => $vs_v) {
if (!$va_element_code_to_ids[$vs_k]) {
continue;
}
switch ((int) $va_element_info[$vs_k]['datatype']) {
case 3:
$va_presets[$vs_code]['values'][$va_element_code_to_ids[$vs_k]] = caGetListItemID($va_element_info[$vs_k]['list_id'], $vs_v);
break;
default:
$va_presets[$vs_code]['values'][$va_element_code_to_ids[$vs_k]] = $vs_v;
break;
}
unset($va_presets[$vs_code]['values'][$vs_k]);
}
}
$vs_buf .= "\n\n\tfunction caHandlePresets_{$ps_field_prefix}_(s, n) {\n\t\tvar presets = " . json_encode($va_presets) . ";\n\t\tif (presets[s]){ \n\t\t\tfor(var k in presets[s]['values']) {\n\t\t\t\tif (!presets[s]['values'][k]) { continue; }\n\t\t\t\tjQuery('#{$ps_field_prefix}' + '_' + k + '_' + n + '').val(presets[s]['values'][k]);\n\t\t\t}\n\t\t}\n\t}\n";
return $vs_buf;
}
return null;
}
示例15: getSets
//.........这里部分代码省略.........
} else {
$vs_sql = "(cs.user_id = {$pn_user_id})";
}
$vs_sql .= " OR (cs.set_id IN (\n\t\t\t\t\t\t\t\t\t\t\tSELECT set_id \n\t\t\t\t\t\t\t\t\t\t\tFROM ca_sets_x_users \n\t\t\t\t\t\t\t\t\t\t\tWHERE \n\t\t\t\t\t\t\t\t\t\t\t\tuser_id = {$pn_user_id} {$vs_access_sql}\n\t\t\t\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t\t\t\t\t (sdatetime IS NULL AND edatetime IS NULL)\n\t\t\t\t\t\t\t\t\t\t\t\t\t OR \n\t\t\t\t\t\t\t\t\t\t\t\t\t (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tsdatetime <= " . time() . " AND edatetime >= " . time() . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t)";
$va_sql_wheres[] = "({$vs_sql})";
}
}
}
if (!is_null($pa_public_access) && is_array($pa_public_access) && sizeof($pa_public_access)) {
$va_sql_wheres[] = "(cs.access IN (?))";
$va_sql_params[] = $pa_public_access;
}
if (isset($pm_type) && $pm_type) {
if (is_numeric($pm_type)) {
$va_sql_wheres[] = "(cs.type_id = ?)";
$va_sql_params[] = (int) $pm_type;
} else {
# --- look up code of set type
$t_list = new ca_lists();
$vn_type_id = $t_list->getItemIDFromList("set_types", $pm_type);
if ($vn_type_id) {
$va_sql_wheres[] = "(cs.type_id = ?)";
$va_sql_params[] = (int) $vn_type_id;
}
}
}
if ($va_restrict_to_types = caGetOption('restrict_to_types', $pa_options, false)) {
$va_restrict_to_type_ids = array();
foreach ($va_restrict_to_types as $vm_type) {
if (is_numeric($vm_type)) {
$va_restrict_to_type_ids[] = (int) $vm_type;
} else {
# --- look up code of set type
$vn_type_id = caGetListItemID('set_types', $pm_type);
if ($vn_type_id) {
$va_restrict_to_type_ids[] = (int) $vn_type_id;
}
}
}
if (sizeof($va_restrict_to_type_ids)) {
$va_sql_wheres[] = "(cs.type_id IN (?))";
$va_sql_params[] = $va_restrict_to_type_ids;
}
}
if ($pn_row_id > 0) {
$va_sql_wheres[] = "((csi.row_id = ?) AND (csi.table_num = ?))";
$va_extra_joins[] = "INNER JOIN ca_set_items AS csi ON cs.set_id = csi.set_id";
$va_sql_selects[] = 'csi.item_id';
$va_sql_params[] = (int) $pn_row_id;
$va_sql_params[] = (int) $vn_table_num;
}
if ($ps_set_name) {
$va_sql_wheres[] = "(csl.name = ?)";
$va_sql_params[] = (string) $ps_set_name;
}
if (!$pb_set_ids_only && !$pb_omit_counts) {
// get set item counts
$qr_table_nums = $o_db->query("\n\t\t\t\tSELECT DISTINCT cs.table_num \n\t\t\t\tFROM ca_sets cs\n\t\t\t\tINNER JOIN ca_set_items AS csi ON cs.set_id = csi.set_id\n\t\t\t\t" . (sizeof($va_sql_wheres) ? 'WHERE ' : '') . "\n\t\t\t\t" . join(' AND ', $va_sql_wheres) . "\n\t\t\t", $va_sql_params);
$va_item_counts = array();
while ($qr_table_nums->nextRow()) {
$o_dm = $this->getAppDatamodel();
$t_instance = $o_dm->getInstanceByTableNum($vn_table_num = (int) $qr_table_nums->get('table_num'), true);
if (!$t_instance) {
continue;
}
$va_item_sql_params = $va_sql_params;