本文整理汇总了PHP中ca_metadata_elements::getPrimaryKey方法的典型用法代码示例。如果您正苦于以下问题:PHP ca_metadata_elements::getPrimaryKey方法的具体用法?PHP ca_metadata_elements::getPrimaryKey怎么用?PHP ca_metadata_elements::getPrimaryKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ca_metadata_elements
的用法示例。
在下文中一共展示了ca_metadata_elements::getPrimaryKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Get
public function Get($pa_additional_query_params = null, $pa_options = null)
{
$ps_query = $this->request->getParameter('term', pString);
$ps_bundle = $this->request->getParameter('bundle', pString);
$va_tmp = explode('.', $ps_bundle);
$o_dm = Datamodel::load();
if (!($t_table = $o_dm->getInstanceByTableName($va_tmp[0], true))) {
// bad table name
print _t("Invalid table name");
return null;
}
$t_element = new ca_metadata_elements();
if (!$t_element->load(array('element_code' => $va_tmp[1]))) {
print _t("Invalid element code");
return null;
}
if ((int) $t_element->getSetting('suggestExistingValues') !== 1) {
print _t("Value suggestion is not supported for this metadata element");
return null;
}
if ($this->request->user->getBundleAccessLevel($va_tmp[0], $va_tmp[1]) == __CA_BUNDLE_ACCESS_NONE__) {
print _t("You do not have access to this bundle");
return null;
}
$va_type_restrictions = $t_element->getTypeRestrictions($t_table->tableNum());
if (!$va_type_restrictions || !is_array($va_type_restrictions) || !sizeof($va_type_restrictions)) {
print _t("Element code is not bound to the specified table");
return null;
}
$o_db = new Db();
switch ($t_element->getSetting('suggestExistingValueSort')) {
case 'recent':
// date/time entered
$vs_sort_field = 'value_id DESC';
$vn_max_returned_values = 10;
break;
default:
// alphabetically
$vs_sort_field = 'value_longtext1 ASC';
$vn_max_returned_values = 50;
break;
}
$qr_res = $o_db->query("\n\t\t\t\tSELECT DISTINCT value_longtext1\n\t\t\t\tFROM ca_attribute_values\n\t\t\t\tWHERE\n\t\t\t\t\telement_id = ?\n\t\t\t\t\tAND\n\t\t\t\t\t(value_longtext1 LIKE ?)\n\t\t\t\tORDER BY\n\t\t\t\t\t{$vs_sort_field}\n\t\t\t\tLIMIT {$vn_max_returned_values}\n\t\t\t", (int) $t_element->getPrimaryKey(), (string) $ps_query . '%');
$this->view->setVar('attribute_value_list', $qr_res->getAllFieldValues('value_longtext1'));
return $this->render('ajax_attribute_value_list_html.php');
}
示例2: getInstance
/**
* @param string $ps_table
* @param string $ps_content_fieldname
* @return \ElasticSearch\FieldTypes\FieldType
*/
public static function getInstance($ps_table, $ps_content_fieldname)
{
if ($ps_table == 'created' || $ps_table == 'modified') {
return new Timestamp($ps_table);
}
// if this is an indexing field name, rewrite it
if (preg_match("/^(I|A)[0-9]+\$/", $ps_content_fieldname)) {
if ($ps_content_fieldname[0] === 'A') {
// Metadata attribute
$vn_field_num_proc = (int) substr($ps_content_fieldname, 1);
$t_element = new \ca_metadata_elements($vn_field_num_proc);
if (!$t_element->getPrimaryKey()) {
return null;
}
$ps_content_fieldname = $t_element->get('element_code');
} else {
// Plain intrinsic
$vn_field_num_proc = (int) substr($ps_content_fieldname, 1);
$ps_content_fieldname = \Datamodel::load()->getFieldName($ps_table, $vn_field_num_proc);
}
}
if ($vn_datatype = \ca_metadata_elements::getDataTypeForElementCode($ps_content_fieldname)) {
switch ($vn_datatype) {
case 2:
return new DateRange($ps_table, $ps_content_fieldname);
case 4:
return new Geocode($ps_table, $ps_content_fieldname);
case 6:
return new Currency($ps_table, $ps_content_fieldname);
case 8:
return new Length($ps_table, $ps_content_fieldname);
case 9:
return new Weight($ps_table, $ps_content_fieldname);
case 10:
return new Timecode($ps_table, $ps_content_fieldname);
case 11:
return new Integer($ps_table, $ps_content_fieldname);
case 12:
return new Float($ps_table, $ps_content_fieldname);
default:
return new GenericElement($ps_table, $ps_content_fieldname);
}
} else {
return new Intrinsic($ps_table, $ps_content_fieldname);
}
}
示例3: caNavLink
$va_facet_info = $this->getVar('facet_info');
$va_types = $this->getVar('type_list');
$va_relationship_types = $this->getVar('relationship_type_list');
if (!is_array($va_other_params = $this->getVar('other_parameters'))) {
$va_other_params = array();
}
$vs_grouping_field = $this->getVar('grouping');
if ((!isset($va_facet_info['groupings'][$vs_grouping_field]) || !$va_facet_info['groupings'][$vs_grouping_field]) && is_array($va_facet_info['groupings'])) {
$va_tmp = array_keys($va_facet_info['groupings']);
$vs_grouping_field = $va_tmp[0];
}
$vn_element_datatype = null;
if ($vs_grouping_attribute_element_code = preg_match('!^ca_attribute_([\\w]+)!', $vs_grouping_field, $va_matches) ? $va_matches[1] : null) {
$t_element = new ca_metadata_elements();
$t_element->load(array('element_code' => $vs_grouping_attribute_element_code));
$vn_grouping_attribute_id = $t_element->getPrimaryKey();
$vn_element_datatype = $t_element->get('datatype');
}
$vs_group_mode = $this->getVar('group_mode');
if (!$va_facet || !$vs_facet_name) {
print 'No facet defined';
return;
}
if (!($vm_modify_id = $this->getVar('modify'))) {
$vm_modify_id = '0';
}
?>
<div id="facetList">
<div id="facetTitle">
<?php
print caNavLink($this->request, _t('start over') . " ›", '', '', 'Browse', 'clearCriteria', array());
示例4: _doQueriesForSqlSearch
//.........这里部分代码省略.........
$va_ft_stem_terms[] = "'" . $this->opo_db->escape($vs_stem) . "'";
} else {
$va_ft_terms[] = '"' . $this->opo_db->escape($vs_term) . '"';
}
} else {
$va_ft_terms[] = '"' . $this->opo_db->escape($vs_term) . '"';
}
$vb_output_term = true;
}
}
if ($vb_output_term) {
$va_raw_terms[] = $vs_term;
} else {
$vn_i--;
}
break;
}
$vs_fld_num = $vs_table_num = $t_table = null;
$vb_ft_bit_optimization = false;
if ($vs_access_point) {
list($vs_table, $vs_field, $vs_sub_field) = explode('.', $vs_access_point);
if (in_array($vs_table, array('created', 'modified'))) {
$o_tep = new TimeExpressionParser();
$vs_date = join(' ', $va_raw_terms);
if (!$o_tep->parse($vs_date)) {
break;
}
$va_range = $o_tep->getUnixTimestamps();
$vn_user_id = null;
if ($vs_field = trim($vs_field)) {
if (!is_int($vs_field)) {
$t_user = new ca_users();
if ($t_user->load(array("user_name" => $vs_field))) {
$vn_user_id = (int) $t_user->getPrimaryKey();
}
} else {
$vn_user_id = (int) $vs_field;
}
}
$vs_user_sql = $vn_user_id ? " AND (ccl.user_id = " . (int) $vn_user_id . ")" : "";
switch ($vs_table) {
case 'created':
$vs_direct_sql_query = "\n\t\t\t\t\t\t\t\t\t\t\tSELECT ccl.logged_row_id, 1\n\t\t\t\t\t\t\t\t\t\t\tFROM ca_change_log ccl\n\t\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\t\t(ccl.log_datetime BETWEEN " . (int) $va_range['start'] . " AND " . (int) $va_range['end'] . ")\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(ccl.logged_table_num = ?)\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(ccl.changetype = 'I')\n\t\t\t\t\t\t\t\t\t\t\t\t{$vs_user_sql}\n\t\t\t\t\t\t\t\t\t\t";
break;
case 'modified':
$vs_direct_sql_query = "\n\t\t\t\t\t\t\t\t\t\t\tSELECT ccl.logged_row_id, 1\n\t\t\t\t\t\t\t\t\t\t\tFROM ca_change_log ccl\n\t\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\t\t(ccl.log_datetime BETWEEN " . (int) $va_range['start'] . " AND " . (int) $va_range['end'] . ")\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(ccl.logged_table_num = ?)\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(ccl.changetype = 'U')\n\t\t\t\t\t\t\t\t\t\t\t\t{$vs_user_sql}\n\t\t\t\t\t\t\t\t\t\tUNION\n\t\t\t\t\t\t\t\t\t\t\tSELECT ccls.subject_row_id, 1\n\t\t\t\t\t\t\t\t\t\t\tFROM ca_change_log ccl\n\t\t\t\t\t\t\t\t\t\t\tINNER JOIN ca_change_log_subjects AS ccls ON ccls.log_id = ccl.log_id\n\t\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\t\t(ccl.log_datetime BETWEEN " . (int) $va_range['start'] . " AND " . (int) $va_range['end'] . ")\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(ccls.subject_table_num = {$pn_subject_tablenum})\n\t\t\t\t\t\t\t\t\t\t\t\t{$vs_user_sql}\n\t\t\t\t\t\t\t\t\t\t";
break;
}
} else {
if ($vs_table && $vs_field) {
$t_table = $this->opo_datamodel->getInstanceByTableName($vs_table, true);
if ($t_table) {
$vs_table_num = $t_table->tableNum();
if (is_numeric($vs_field)) {
$vs_fld_num = 'I' . $vs_field;
$vn_fld_num = (int) $vs_field;
} else {
$vn_fld_num = $this->getFieldNum($vs_table, $vs_field);
$vs_fld_num = 'I' . $vn_fld_num;
if (!strlen($vn_fld_num)) {
$t_element = new ca_metadata_elements();
if ($t_element->load(array('element_code' => $vs_sub_field ? $vs_sub_field : $vs_field))) {
$vn_fld_num = $t_element->getPrimaryKey();
$vs_fld_num = 'A' . $vn_fld_num;
if (!$vb_is_blank_search) {
//
示例5: getFacetContent
/**
* Return list of items from the specified table that are related to the current browse set. This is the method that actually
* pulls the facet content, regardless of whether the facet is cached yet or not. If you want to use the facet cache, call
* BrowseEngine::getFacet()
*
* @see BrowseEngine::getFacet()
* Options:
* checkAccess = array of access values to filter facets that have an 'access' field by
* checkAvailabilityOnly = if true then content is not actually fetch - only the availablility of content is verified
* user_id = If set item level access control is performed relative to specified user_id, otherwise defaults to logged in user
*/
public function getFacetContent($ps_facet_name, $pa_options = null)
{
global $AUTH_CURRENT_USER_ID;
$vs_browse_table_name = $this->ops_browse_table_name;
$vs_browse_table_num = $this->opn_browse_table_num;
$vn_user_id = isset($pa_options['user_id']) && (int) $pa_options['user_id'] ? (int) $pa_options['user_id'] : (int) $AUTH_CURRENT_USER_ID;
$vb_show_if_no_acl = (bool) ($this->opo_config->get('default_item_access_level') > __CA_ACL_NO_ACCESS__);
$t_user = new ca_users($vn_user_id);
if (is_array($va_groups = $t_user->getUserGroups()) && sizeof($va_groups)) {
$va_group_ids = array_keys($va_groups);
} else {
$va_group_ids = array();
}
if (!is_array($this->opa_browse_settings)) {
return null;
}
if (!isset($this->opa_browse_settings['facets'][$ps_facet_name])) {
return null;
}
if (!is_array($pa_options)) {
$pa_options = array();
}
$vb_check_availability_only = isset($pa_options['checkAvailabilityOnly']) ? (bool) $pa_options['checkAvailabilityOnly'] : false;
$va_all_criteria = $this->getCriteria();
$va_criteria = $this->getCriteria($ps_facet_name);
$va_facet_info = $this->opa_browse_settings['facets'][$ps_facet_name];
$t_subject = $this->getSubjectInstance();
if ($va_facet_info['relative_to']) {
$vs_browse_table_name = $va_facet_info['relative_to'];
$vs_browse_table_num = $this->opo_datamodel->getTableNum($vs_browse_table_name);
}
$vs_browse_type_limit_sql = '';
if (($va_browse_type_ids = $this->getTypeRestrictionList()) && sizeof($va_browse_type_ids)) {
// type restrictions
$vs_browse_type_limit_sql = '(' . $t_subject->tableName() . '.' . $t_subject->getTypeFieldName() . ' IN (' . join(', ', $va_browse_type_ids) . ')' . ($t_subject->getFieldInfo('type_id', 'IS_NULL') ? " OR (" . $this->ops_browse_table_name . '.' . $t_subject->getTypeFieldName() . " IS NULL)" : '') . ')';
if (is_array($va_facet_info['type_restrictions'])) {
// facet type restrictions bind a facet to specific types; we check them here
$va_restrict_to_types = $this->_convertTypeCodesToIDs($va_facet_info['type_restrictions']);
$vb_is_ok_to_browse = false;
foreach ($va_browse_type_ids as $vn_type_id) {
if (in_array($vn_type_id, $va_restrict_to_types)) {
$vb_is_ok_to_browse = true;
break;
}
}
if (!$vb_is_ok_to_browse) {
return array();
}
}
}
// Values to exclude from list attributes and authorities; can be idnos or ids
$va_exclude_values = caGetOption('exclude_values', $va_facet_info, array(), array('castTo' => 'array'));
$va_results = $this->opo_ca_browse_cache->getResults();
$vb_single_value_is_present = false;
$vs_single_value = isset($va_facet_info['single_value']) ? $va_facet_info['single_value'] : null;
$va_wheres = array();
switch ($va_facet_info['type']) {
# -----------------------------------------------------
case 'has':
$vn_state = null;
if (isset($va_all_criteria[$ps_facet_name])) {
break;
}
// only one instance of this facet allowed per browse
if (!($t_item = $this->opo_datamodel->getInstanceByTableName($vs_browse_table_name, true))) {
break;
}
$vs_yes_text = isset($va_facet_info['label_yes']) && $va_facet_info['label_yes'] ? $va_facet_info['label_yes'] : _t('Yes');
$vs_no_text = isset($va_facet_info['label_no']) && $va_facet_info['label_no'] ? $va_facet_info['label_no'] : _t('No');
$va_facet_values = array('yes' => array('id' => 1, 'label' => $vs_yes_text), 'no' => array('id' => 0, 'label' => $vs_no_text));
// Actually check that both yes and no values will result in something
if ($va_facet_info['element_code']) {
$t_element = new ca_metadata_elements();
if (!$t_element->load(array('element_code' => $va_facet_info['element_code']))) {
break;
}
$vs_element_code = $va_facet_info['element_code'];
$va_facet = array();
$va_counts = array();
foreach ($va_facet_values as $vs_state_name => $va_state_info) {
$va_wheres = array();
$va_joins = array();
if (!(bool) $va_state_info['id']) {
// no option
$va_wheres[] = $this->ops_browse_table_name . '.' . $t_item->primaryKey() . " NOT IN (select row_id from ca_attributes where table_num = " . $t_item->tableNum() . " AND element_id = " . $t_element->getPrimaryKey() . ")";
} else {
// yes option
$va_joins[] = "LEFT JOIN ca_attributes AS caa ON " . $this->ops_browse_table_name . '.' . $t_item->primaryKey() . " = caa.row_id AND " . $t_item->tableNum() . " = caa.table_num";
$va_wheres[] = "caa.element_id = " . $t_element->getPrimaryKey();
//.........这里部分代码省略.........
示例6: settingHTMLFormElement
//.........这里部分代码省略.........
$va_opts['value'] = array_pop($vs_value);
} else {
if ($vs_value) {
$va_opts['value'] = $vs_value;
} else {
$va_opts['value'] = null;
}
}
}
if ($vs_list_code) {
$t_list = new ca_lists();
if (!isset($va_opts['value'])) {
$va_opts['value'] = -1;
}
// make sure default list item is never selected
$vs_select_element = $t_list->getListAsHTMLFormElement($vs_list_code, $vs_input_name, $va_attr, $va_opts);
} else {
if (!isset($va_opts['value'])) {
$va_opts['value'] = -1;
}
// make sure default list item is never selected
$vs_select_element = caHTMLSelect($vs_input_name, $va_rel_opts, $va_attr, $va_opts);
}
} else {
if (strlen($va_properties['showSortableBundlesFor']) > 0) {
require_once __CA_MODELS_DIR__ . '/ca_metadata_elements.php';
$o_dm = Datamodel::load();
if (!($t_rel = $o_dm->getInstanceByTableName($va_properties['showSortableBundlesFor'], true))) {
break;
}
$va_elements = ca_metadata_elements::getSortableElements($va_properties['showSortableBundlesFor']);
$va_select_opts = array(_t('User defined sort order') => '', _t('Order created') => 'relation_id', _t('Preferred label') => $va_properties['showSortableBundlesFor'] . ".preferred_labels." . $t_rel->getLabelDisplayField());
foreach ($va_elements as $vn_element_id => $va_element) {
if (!$va_element['display_label']) {
continue;
}
$va_select_opts[_t('Element: %1', $va_element['display_label'])] = $va_properties['showSortableBundlesFor'] . "." . $va_element['element_code'];
}
$va_opts = array('id' => $vs_input_id, 'width' => $vn_width, 'height' => $vn_height, 'value' => is_array($vs_value) ? $vs_value[0] : $vs_value, 'values' => is_array($vs_value) ? $vs_value : array($vs_value));
$vs_select_element = caHTMLSelect($vs_input_name, $va_select_opts, array(), $va_opts);
} elseif ((int) $va_properties['showSortableElementsFor'] > 0) {
require_once __CA_MODELS_DIR__ . '/ca_metadata_elements.php';
$t_element = new ca_metadata_elements($va_properties['showSortableElementsFor']);
if (!$t_element->getPrimaryKey()) {
return '';
}
$va_elements = $t_element->getElementsInSet();
$va_select_opts = array(_t('Order created') => '');
foreach ($va_elements as $vn_i => $va_element) {
if ((int) $va_element['element_id'] == (int) $va_properties['showSortableElementsFor']) {
continue;
}
if (!$va_element['display_label']) {
continue;
}
$va_select_opts[_t('Element: %1', $va_element['display_label'])] = $va_element['element_code'];
}
$va_opts = array('id' => $vs_input_id, 'width' => $vn_width, 'height' => $vn_height, 'value' => is_array($vs_value) ? $vs_value[0] : $vs_value, 'values' => is_array($vs_value) ? $vs_value : array($vs_value));
$vs_select_element = caHTMLSelect($vs_input_name, $va_select_opts, array(), $va_opts);
} elseif ((int) $va_properties['showMetadataElementsWithDataType'] > 0) {
require_once __CA_MODELS_DIR__ . '/ca_metadata_elements.php';
$va_rep_elements = ca_metadata_elements::getElementsAsList(true, $va_properties['table'], null, true, false, true, array($va_properties['showMetadataElementsWithDataType']));
if (is_array($va_rep_elements)) {
$va_select_opts = array();
foreach ($va_rep_elements as $vs_element_code => $va_element_info) {
$va_select_opts[$va_element_info['display_label']] = $vs_element_code;
}
$va_opts = array('id' => $vs_input_id, 'width' => $vn_width, 'height' => $vn_height, 'value' => is_array($vs_value) ? $vs_value[0] : $vs_value, 'values' => is_array($vs_value) ? $vs_value : array($vs_value));
$vs_select_element = caHTMLSelect($vs_input_name, $va_select_opts, array(), $va_opts);
}
} else {
// Regular drop-down with configured options
if ($vn_height > 1) {
$va_attr['multiple'] = 1;
$vs_input_name .= '[]';
}
$va_opts = array('id' => $vs_input_id, 'width' => $vn_width, 'height' => $vn_height, 'value' => is_array($vs_value) ? $vs_value[0] : $vs_value, 'values' => is_array($vs_value) ? $vs_value : array($vs_value));
if (!isset($va_opts['value'])) {
$va_opts['value'] = -1;
}
// make sure default list item is never selected
$vs_select_element = caHTMLSelect($vs_input_name, $va_properties['options'], array(), $va_opts);
}
}
if ($vs_select_element) {
$vs_return .= $vs_select_element;
} else {
return '';
}
break;
# --------------------------------------------
# --------------------------------------------
default:
break;
# --------------------------------------------
}
$vs_return .= '</div>' . "\n";
TooltipManager::add('.' . $vs_label_id, "<h3>" . $va_properties["label"] . "</h3>" . $va_properties["description"]);
return $vs_return;
}
示例7: getElementType
private static function getElementType($pa_element_info)
{
$va_table_fields = $va_element_opts = array();
$vn_element_id = $pa_element_info['element_id'];
switch ($pa_element_info['datatype']) {
case 0:
//container
/* Retrieve child elements of the container. */
$t_element = new ca_metadata_elements((int) $pa_element_info['element_id']);
if ($t_element->getPrimaryKey()) {
$va_children = $t_element->getElementsInSet();
foreach ($va_children as $va_child) {
if ($va_child['element_id'] == $vn_element_id) {
continue;
}
$va_table_fields += SolrConfiguration::getElementType($va_child);
}
}
break;
case 1:
// text
// text
case 3:
// list
// list
case 5:
// url
// url
case 6:
// currency
// currency
case 8:
// length
// length
case 9:
// weight
// weight
case 13:
// LCSH
// LCSH
case 14:
// geonames
// geonames
case 15:
// file
// file
case 16:
// media
// media
case 19:
// taxonomy
// taxonomy
case 20:
// information service
$va_element_opts['type'] = 'text';
break;
case 2:
// daterange
$va_element_opts['type'] = 'daterange';
$va_table_fields['_ca_attribute_' . $vn_element_id . '_text'] = array('type' => 'text');
break;
case 4:
// geocode
$va_element_opts['type'] = 'geocode';
$va_table_fields['_ca_attribute_' . $vn_element_id . '_text'] = array('type' => 'text');
break;
case 10:
// timecode
// timecode
case 12:
// numeric/float
$va_element_opts['type'] = 'float';
break;
case 11:
// integer
$va_element_opts['type'] = 'int';
break;
default:
$va_element_opts['type'] = 'text';
break;
}
$va_table_fields['_ca_attribute_' . $vn_element_id] = $va_element_opts;
return $va_table_fields;
}
示例8: _getMetadataElement
private function _getMetadataElement($ps_element_code)
{
if (isset(WLPlugSearchEngineSolr::$s_element_code_cache[$ps_element_code])) {
return WLPlugSearchEngineSolr::$s_element_code_cache[$ps_element_code];
}
$t_element = new ca_metadata_elements($ps_element_code);
if (!($vn_element_id = $t_element->getPrimaryKey())) {
return WLPlugSearchEngineSolr::$s_element_code_cache[$ps_element_code] = null;
}
return WLPlugSearchEngineSolr::$s_element_code_cache[$ps_element_code] = array('element_id' => $vn_element_id, 'element_code' => $t_element->get('element_code'), 'datatype' => $t_element->get('datatype'));
}
示例9: sortHits
/**
* @param $pa_hits Array of row_ids to sort. *MUST HAVE row_ids AS KEYS, NOT VALUES*
*/
public function sortHits($pa_hits, $ps_field, $ps_direction = 'asc', $pa_options = null)
{
if (!in_array(strtolower($ps_direction), array('asc', 'desc'))) {
$ps_direction = 'asc';
}
if (!is_array($pa_hits) || !sizeof($pa_hits)) {
return $pa_hits;
}
$vs_search_tmp_table = $this->loadListIntoTemporaryResultTable($pa_hits, $pa_options['search']);
$t_table = $this->opo_datamodel->getInstanceByTableNum($this->opn_tablenum, true);
$vs_table_pk = $t_table->primaryKey();
$vs_table_name = $this->ops_tablename;
$va_fields = explode(';', $ps_field);
$va_sorted_hits = array();
$vn_num_locales = ca_locales::numberOfCataloguingLocales();
foreach ($va_fields as $vs_field) {
$va_joins = $va_orderbys = array();
$vs_locale_where = $vs_is_preferred_sql = '';
$va_tmp = explode('.', $vs_field);
// Rewrite for <table>.preferred_labels.* syntax
if ($va_tmp[1] == 'preferred_labels') {
if ($t_labeled_item_table = $this->opo_datamodel->getInstanceByTableName($va_tmp[0], true)) {
if ($t_label_table = $t_labeled_item_table->getLabelTableInstance()) {
$va_tmp2 = array($t_label_table->tableName());
if (isset($va_tmp[2]) && $t_label_table->hasField($va_tmp[2])) {
$va_tmp2[] = $va_tmp[2];
} else {
$va_tmp2[] = $t_labeled_item_table->getLabelDisplayField();
}
$va_tmp = $va_tmp2;
$vs_field = join(".", $va_tmp);
}
}
}
if ($va_tmp[0] == $vs_table_name) {
//
// sort field is in search table
//
if (!$t_table->hasField($va_tmp[1])) {
//
// is it an attribute?
//
$t_element = new ca_metadata_elements();
$vs_sort_element_code = array_pop($va_tmp);
if ($t_element->load(array('element_code' => $vs_sort_element_code))) {
$vn_element_id = $t_element->getPrimaryKey();
if (!($vs_sortable_value_fld = Attribute::getSortFieldForDatatype($t_element->get('datatype')))) {
return $pa_hits;
}
if ((int) $t_element->get('datatype') == 3) {
$vs_sortable_value_fld = 'lil.name_plural';
$vs_sort_field = array_pop(explode('.', $vs_sortable_value_fld));
$vs_locale_where = $vn_num_locales > 1 ? ', lil.locale_id' : '';
$vs_sql = "\n\t\t\t\t\t\t\t\tSELECT attr.row_id, lil.locale_id, lower({$vs_sortable_value_fld}) {$vs_sort_field}\n\t\t\t\t\t\t\t\tFROM ca_attributes attr\n\t\t\t\t\t\t\t\tINNER JOIN ca_attribute_values AS attr_vals ON attr_vals.attribute_id = attr.attribute_id\n\t\t\t\t\t\t\t\tINNER JOIN ca_list_item_labels AS lil ON lil.item_id = attr_vals.item_id\n\t\t\t\t\t\t\t\tINNER JOIN {$vs_browse_tmp_table} ON {$vs_browse_tmp_table}.row_id = attr.row_id\n\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t(attr_vals.element_id = ?) AND (attr.table_num = ?) AND (lil.{$vs_sort_field} IS NOT NULL)\n\t\t\t\t\t\t\t\tORDER BY lil.{$vs_sort_field}\n\t\t\t\t\t\t\t";
} else {
$vs_sortable_value_fld = 'attr_vals.' . $vs_sortable_value_fld;
$vs_sort_field = array_pop(explode('.', $vs_sortable_value_fld));
$vs_locale_where = $vn_num_locales > 1 ? 'attr.locale_id' : '';
$vs_sql = "\n\t\t\t\t\t\t\t\tSELECT attr.row_id, attr.locale_id, lower({$vs_sortable_value_fld}) {$vs_sort_field}\n\t\t\t\t\t\t\t\tFROM ca_attributes attr\n\t\t\t\t\t\t\t\tINNER JOIN ca_attribute_values AS attr_vals ON attr_vals.attribute_id = attr.attribute_id\n\t\t\t\t\t\t\t\tINNER JOIN {$vs_search_tmp_table} ON {$vs_search_tmp_table}.row_id = attr.row_id\n\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t(attr_vals.element_id = ?) AND (attr.table_num = ?) AND (attr_vals.{$vs_sort_field} IS NOT NULL)\n\t\t\t\t\t\t\t\tORDER BY attr_vals.{$vs_sort_field}\n\t\t\t\t\t\t\t";
//print $vs_sql." ; $vn_element_id/; ".$this->opn_tablenum."<br>";
}
$qr_sort = $this->opo_db->query($vs_sql, (int) $vn_element_id, (int) $this->opn_tablenum);
while ($qr_sort->nextRow()) {
$va_row = $qr_sort->getRow();
if (!$va_row['row_id']) {
continue;
}
if ($vn_num_locales > 1) {
$va_sorted_hits[$va_row['row_id']][$va_row['locale_id']] .= trim(str_replace(array("'", '"'), array('', ''), $va_row[$vs_sort_field]));
} else {
$va_sorted_hits[$va_row['row_id']] .= trim(str_replace(array("'", '"'), array('', ''), $va_row[$vs_sort_field]));
}
unset($pa_hits[$va_row['row_id']]);
}
// Add on hits that aren't sorted because they don't have an attribute associated
foreach ($pa_hits as $vn_id => $va_row) {
if (!is_array($va_row)) {
$va_row = array();
}
if ($vn_num_locales > 1) {
$va_sorted_hits[$vn_id][1] = $va_row;
} else {
$va_sorted_hits[$vn_id] = $va_row;
}
}
}
continue;
} else {
$va_field_info = $t_table->getFieldInfo($va_tmp[1]);
if ($va_field_info['START'] && $va_field_info['END']) {
$va_orderbys[] = $va_field_info['START'] . ' ' . $ps_direction;
$va_orderbys[] = $va_field_info['END'] . ' ' . $ps_direction;
} else {
$va_orderbys[] = $vs_field . ' ' . $ps_direction;
}
if ($t_table->hasField('locale_id')) {
$vs_locale_where = ", " . $vs_table_name . ".locale_id";
//.........这里部分代码省略.........
示例10: _doQueriesForSqlSearch
//.........这里部分代码省略.........
}
$va_ft_stem_terms[] = "'" . $this->opo_db->escape($vs_stem) . "'";
} else {
$va_ft_terms[] = '"' . $this->opo_db->escape($vs_term) . '"';
}
} else {
$va_ft_terms[] = '"' . $this->opo_db->escape($vs_term) . '"';
}
}
$vb_output_term = true;
}
if ($vb_output_term) {
$va_raw_terms[] = $vs_term;
}
}
break;
}
$vs_fld_num = $vs_table_num = $t_table = null;
$vb_ft_bit_optimization = false;
if ($vs_access_point) {
list($vs_table, $vs_field, $vs_sub_field) = explode('.', $vs_access_point);
if (in_array($vs_table, array('created', 'modified'))) {
$o_tep = new TimeExpressionParser();
$vs_date = join(' ', $va_raw_terms);
if (!$o_tep->parse($vs_date)) {
break;
}
$va_range = $o_tep->getUnixTimestamps();
$vn_user_id = null;
if ($vs_field = trim($vs_field)) {
if (!is_int($vs_field)) {
$t_user = new ca_users();
if ($t_user->load(array("user_name" => $vs_field))) {
$vn_user_id = (int) $t_user->getPrimaryKey();
}
} else {
$vn_user_id = (int) $vs_field;
}
}
$vs_user_sql = $vn_user_id ? " AND (ccl.user_id = " . (int) $vn_user_id . ")" : "";
switch ($vs_table) {
case 'created':
$vs_direct_sql_query = "\n\t\t\t\t\t\t\t\t\t\t\tSELECT ccl.logged_row_id row_id, 1\n\t\t\t\t\t\t\t\t\t\t\tFROM ca_change_log ccl\n\t\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\t\t(ccl.log_datetime BETWEEN " . (int) $va_range['start'] . " AND " . (int) $va_range['end'] . ")\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(ccl.logged_table_num = ?)\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(ccl.changetype = 'I')\n\t\t\t\t\t\t\t\t\t\t\t\t{$vs_user_sql}\n\t\t\t\t\t\t\t\t\t\t";
break;
case 'modified':
$vs_direct_sql_query = "\n\t\t\t\t\t\t\t\t\t\t\tSELECT ccl.logged_row_id row_id, 1\n\t\t\t\t\t\t\t\t\t\t\tFROM ca_change_log ccl\n\t\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\t\t(ccl.log_datetime BETWEEN " . (int) $va_range['start'] . " AND " . (int) $va_range['end'] . ")\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(ccl.logged_table_num = ?)\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(ccl.changetype = 'U')\n\t\t\t\t\t\t\t\t\t\t\t\t{$vs_user_sql}\n\t\t\t\t\t\t\t\t\t\tUNION\n\t\t\t\t\t\t\t\t\t\t\tSELECT ccls.subject_row_id row_id, 1\n\t\t\t\t\t\t\t\t\t\t\tFROM ca_change_log ccl\n\t\t\t\t\t\t\t\t\t\t\tINNER JOIN ca_change_log_subjects AS ccls ON ccls.log_id = ccl.log_id\n\t\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\t\t(ccl.log_datetime BETWEEN " . (int) $va_range['start'] . " AND " . (int) $va_range['end'] . ")\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(ccls.subject_table_num = {$pn_subject_tablenum})\n\t\t\t\t\t\t\t\t\t\t\t\t{$vs_user_sql}\n\t\t\t\t\t\t\t\t\t\t";
break;
}
} else {
if ($vs_table && $vs_field && ($t_table = $this->opo_datamodel->getInstanceByTableName($vs_table, true))) {
$vs_table_num = $t_table->tableNum();
if (is_numeric($vs_field)) {
$vs_fld_num = 'I' . $vs_field;
$vn_fld_num = (int) $vs_field;
} else {
$vn_fld_num = $this->getFieldNum($vs_table, $vs_field);
$vs_fld_num = 'I' . $vn_fld_num;
$vn_direct_sql_target_table_num = $vs_table_num;
if (!strlen($vn_fld_num)) {
$t_element = new ca_metadata_elements();
if ($t_element->load(array('element_code' => $vs_sub_field ? $vs_sub_field : $vs_field))) {
$va_indexed_fields = $o_base->getFieldsToIndex($pn_subject_tablenum, $vn_direct_sql_target_table_num);
$vn_fld_num = $t_element->getPrimaryKey();
$vn_root_element_id = $t_element->get('hier_element_id');
if (!isset($va_indexed_fields['_ca_attribute_' . $vn_fld_num]) && (!$vn_root_element_id || $vn_root_element_id && !isset($va_indexed_fields['_ca_attribute_' . $vn_root_element_id]))) {
break 2;
示例11: getElementInstance
/**
*
*/
public static function getElementInstance($pm_element_code_or_id)
{
if (isset(ca_attributes::$s_ca_attributes_element_instance_cache[$pm_element_code_or_id])) {
return ca_attributes::$s_ca_attributes_element_instance_cache[$pm_element_code_or_id];
}
//require_once(__CA_MODELS_DIR__.'/ca_metadata_elements.php'); // defer inclusion until runtime to ensure baseclasses are already loaded, otherwise you get circular dependencies
$t_element = new ca_metadata_elements();
if (!is_numeric($pm_element_code_or_id)) {
if ($t_element->load(array('element_code' => $pm_element_code_or_id))) {
return ca_attributes::$s_ca_attributes_element_instance_cache[$pm_element_code_or_id] = ca_attributes::$s_ca_attributes_element_instance_cache[$t_element->getPrimaryKey()] = $t_element;
}
}
if ($t_element->load($pm_element_code_or_id)) {
return ca_attributes::$s_ca_attributes_element_instance_cache[$pm_element_code_or_id] = $t_element;
} else {
//$this->postError(1950, _t("Element code or id is invalid"), "ca_attributes::getElementInstance()");
return false;
}
}
示例12: sortHits
/**
*
*/
public function sortHits(&$pa_hits, $ps_table, $ps_field, $ps_key, $ps_direction = 'asc', $pa_options = null)
{
//$t= new Timer();
$vs_browse_tmp_table = $this->loadListIntoTemporaryResultTable($pa_hits, $ps_key);
if (!in_array(strtolower($ps_direction), array('asc', 'desc'))) {
$ps_direction = 'asc';
}
if (!is_array($pa_hits) || !sizeof($pa_hits)) {
return $pa_hits;
}
$t_table = $this->opo_datamodel->getInstanceByTableName($ps_table, true);
$vs_table_pk = $t_table->primaryKey();
$vn_table_num = $t_table->tableNum();
$va_sort_tmp = explode('/', $ps_field);
$ps_field = $va_sort_tmp[0];
$vs_rel_type = sizeof($va_sort_tmp) > 1 ? $va_sort_tmp[1] : null;
$va_fields = explode(';', $ps_field);
$va_sorted_hits = array();
$va_joins = array();
$vs_locale_where = $vs_is_preferred_sql = '';
$vs_primary_sort_field = array_shift($va_fields);
$va_primary_sort_field = explode('.', $vs_primary_sort_field);
$va_additional_sort_fields = array();
foreach ($va_fields as $vs_additional_sort_field) {
$va_tmp = explode('.', $vs_additional_sort_field);
if ($va_tmp[0] == $va_primary_sort_field[0]) {
$va_additional_sort_fields[] = $va_tmp;
}
}
if ($va_primary_sort_field[0] == $ps_table) {
//
// sort field is in search table
//
if (!$t_table->hasField($va_primary_sort_field[1])) {
//
// is it an attribute?
//
$t_element = new ca_metadata_elements();
$vs_sort_element_code = array_pop($va_primary_sort_field);
if ($t_element->load(array('element_code' => $vs_sort_element_code))) {
$vn_element_id = $t_element->getPrimaryKey();
if (!($vs_sortable_value_fld = Attribute::getSortFieldForDatatype($t_element->get('datatype')))) {
return $pa_hits;
}
if ((int) $t_element->get('datatype') == __CA_ATTRIBUTE_VALUE_LIST__) {
$vs_sortable_value_fld = 'lil.name_plural';
$vs_sort_field = array_pop(explode('.', $vs_sortable_value_fld));
$vs_sql = "\n\t\t\t\t\t\t\t\tSELECT attr.row_id, lil.locale_id, lower({$vs_sortable_value_fld}) {$vs_sort_field}\n\t\t\t\t\t\t\t\tFROM ca_attributes attr\n\t\t\t\t\t\t\t\tINNER JOIN ca_attribute_values AS attr_vals ON attr_vals.attribute_id = attr.attribute_id\n\t\t\t\t\t\t\t\tINNER JOIN ca_list_item_labels AS lil ON lil.item_id = attr_vals.item_id\n\t\t\t\t\t\t\t\tINNER JOIN {$vs_browse_tmp_table} ON {$vs_browse_tmp_table}.row_id = attr.row_id\n\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t(attr_vals.element_id = ?) AND (attr.table_num = ?) AND (lil.{$vs_sort_field} IS NOT NULL)\n\t\t\t\t\t\t\t\tORDER BY lil.{$vs_sort_field} {$ps_direction}\n\t\t\t\t\t\t\t";
} elseif ((int) $t_element->get('datatype') == __CA_ATTRIBUTE_VALUE_DATERANGE__) {
$vs_sortable_value_fld = 'attr_vals.' . $vs_sortable_value_fld;
$vs_sort_field = array_pop(explode('.', $vs_sortable_value_fld));
$vs_sql = "\n\t\t\t\t\t\t\t\tSELECT attr.row_id, attr.locale_id, {$vs_sortable_value_fld}\n\t\t\t\t\t\t\t\tFROM ca_attributes attr\n\t\t\t\t\t\t\t\tINNER JOIN ca_attribute_values AS attr_vals ON attr_vals.attribute_id = attr.attribute_id\n\t\t\t\t\t\t\t\tINNER JOIN {$vs_browse_tmp_table} ON {$vs_browse_tmp_table}.row_id = attr.row_id\n\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t(attr_vals.element_id = ?) AND (attr.table_num = ?) AND (attr_vals.{$vs_sort_field} IS NOT NULL)\n\t\t\t\t\t\t\t\tORDER BY attr_vals.{$vs_sort_field} {$ps_direction}, attr.row_id\n\t\t\t\t\t\t\t";
} else {
$vs_sortable_value_fld = 'attr_vals.' . $vs_sortable_value_fld;
$vs_sort_field = array_pop(explode('.', $vs_sortable_value_fld));
$vs_sql = "\n\t\t\t\t\t\t\t\tSELECT attr.row_id, attr.locale_id, lower({$vs_sortable_value_fld}) {$vs_sort_field}\n\t\t\t\t\t\t\t\tFROM ca_attributes attr\n\t\t\t\t\t\t\t\tINNER JOIN ca_attribute_values AS attr_vals ON attr_vals.attribute_id = attr.attribute_id\n\t\t\t\t\t\t\t\tINNER JOIN {$vs_browse_tmp_table} ON {$vs_browse_tmp_table}.row_id = attr.row_id\n\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t(attr_vals.element_id = ?) AND (attr.table_num = ?) AND (attr_vals.{$vs_sort_field} IS NOT NULL)\n\t\t\t\t\t\t\t\tORDER BY attr_vals.{$vs_sort_field} {$ps_direction}, attr.row_id\n\t\t\t\t\t\t\t";
}
$qr_sort = $this->opo_db->query($vs_sql, (int) $vn_element_id, (int) $vn_table_num);
$va_sorted_hits = $qr_sort->getAllFieldValues('row_id');
// Add on hits that aren't sorted because they don't have an attribute associated
$va_missing_items = array_diff($pa_hits, $va_sorted_hits);
$va_sorted_hits = array_merge($va_sorted_hits, $va_missing_items);
}
return $va_sorted_hits;
} else {
$va_field_info = $t_table->getFieldInfo($va_primary_sort_field[1]);
if ($va_field_info['START'] && $va_field_info['END']) {
$vs_sortable_value_fld = $vs_primary_sort_field;
$va_additional_sort_fields[] = $va_field_info['END'];
} else {
$vs_sortable_value_fld = $vs_primary_sort_field;
}
}
} else {
// sort field is in related table
$va_path = $this->opo_datamodel->getPath($ps_table, $va_primary_sort_field[0]);
if (sizeof($va_path) > 2) {
// many-many
$vs_last_table = null;
// generate related joins
foreach ($va_path as $vs_table => $va_info) {
$t_table = $this->opo_datamodel->getInstanceByTableName($vs_table, true);
$vs_rel_type_sql = null;
if ($t_table->isRelationship() && $vs_rel_type) {
if (is_array($va_rel_types = caMakeRelationshipTypeIDList($vs_table, array($vs_rel_type))) && sizeof($va_rel_types)) {
$vs_rel_type_sql = " AND {$vs_table}.type_id IN (" . join(",", $va_rel_types) . ")";
}
}
if ($vs_last_table) {
$va_rels = $this->opo_datamodel->getOneToManyRelations($vs_last_table, $vs_table);
if (!sizeof($va_rels)) {
$va_rels = $this->opo_datamodel->getOneToManyRelations($vs_table, $vs_last_table);
}
if ($vs_table == $va_rels['one_table']) {
$va_joins[$vs_table] = "INNER JOIN " . $va_rels['one_table'] . " ON " . $va_rels['one_table'] . "." . $va_rels['one_table_field'] . " = " . $va_rels['many_table'] . "." . $va_rels['many_table_field'] . $vs_rel_type_sql;
} else {
$va_joins[$vs_table] = "INNER JOIN " . $va_rels['many_table'] . " ON " . $va_rels['many_table'] . "." . $va_rels['many_table_field'] . " = " . $va_rels['one_table'] . "." . $va_rels['one_table_field'] . $vs_rel_type_sql;
//.........这里部分代码省略.........
示例13: GetDetail
/**
* Fetch details on an item from a remote data source and output results of the 'display' key in the response.
*
*/
public function GetDetail()
{
$pn_element_id = $this->request->getParameter('element_id', pInteger);
$t_element = new ca_metadata_elements($pn_element_id);
$va_data = array();
if (!$t_element->getPrimaryKey()) {
// error
$va_items['error'] = array('label' => _t('ERROR: Invalid element_id'), 'idno' => '');
} else {
$vs_service = $t_element->getSetting('service');
$va_settings = $t_element->getSettings();
$pn_attribute_id = $this->request->getParameter('id', pInteger);
$t_attr_val = new ca_attribute_values();
if ($t_attr_val->load(array('attribute_id' => $pn_attribute_id, 'element_id' => $pn_element_id))) {
$t_attr = new ca_attributes();
if ($t_attr->load($pn_attribute_id)) {
if (!caCanRead($this->request->getUserID(), $t_attr->get('table_num'), $t_attr->get('row_id'), $t_element->get('element_code'))) {
$va_items['error'] = array('label' => _t('ERROR: You do not have access to this item'), 'idno' => '');
} else {
$vs_url = $t_attr_val->get('value_longtext2');
if (!($o_plugin = InformationServiceManager::getInformationServiceInstance($vs_service))) {
$va_items['error'] = array('label' => _t('ERROR: Invalid service'), 'idno' => '');
} else {
$vs_cache_key = md5(print_r($va_settings, true) . $vs_url);
if (CompositeCache::contains($vs_cache_key, 'InformationServiceExtendedInfo')) {
$va_data = CompositeCache::fetch($vs_cache_key, 'InformationServiceExtendedInfo');
} else {
$va_data = $o_plugin->getExtendedInformation($va_settings, $vs_url);
CompositeCache::save($vs_cache_key, $va_data, 'InformationServiceExtendedInfo');
}
}
}
}
}
}
$this->view->setVar('detail', $va_data);
return $this->render('ajax_information_service_detail_html.php');
}
示例14: getInstance
/**
*
*/
public static function getInstance($pm_element_code_or_id)
{
if (isset(ca_metadata_elements::$s_element_instance_cache[$pm_element_code_or_id])) {
return ca_metadata_elements::$s_element_instance_cache[$pm_element_code_or_id];
}
$t_element = new ca_metadata_elements(is_numeric($pm_element_code_or_id) ? $pm_element_code_or_id : null);
if (!($vn_element_id = $t_element->getPrimaryKey())) {
if ($t_element->load(array('element_code' => $pm_element_code_or_id))) {
return ca_metadata_elements::$s_element_instance_cache[$t_element->getPrimaryKey()] = ca_metadata_elements::$s_element_instance_cache[$t_element->get('element_code')] = $t_element;
}
} else {
return ca_metadata_elements::$s_element_instance_cache[$vn_element_id] = ca_metadata_elements::$s_element_instance_cache[$t_element->get('element_code')] = $t_element;
}
return null;
}
示例15: getInstance
/**
*
*/
public static function getInstance($pm_element_code_or_id)
{
if (!$pm_element_code_or_id) {
return null;
}
if (MemoryCache::contains($pm_element_code_or_id, 'ElementInstances')) {
return MemoryCache::fetch($pm_element_code_or_id, 'ElementInstances');
}
$t_element = new ca_metadata_elements(is_numeric($pm_element_code_or_id) ? $pm_element_code_or_id : null);
if (!($vn_element_id = $t_element->getPrimaryKey())) {
if ($t_element->load(array('element_code' => $pm_element_code_or_id))) {
MemoryCache::save($t_element->getPrimaryKey(), $t_element, 'ElementInstances');
MemoryCache::save($t_element->get('element_code'), $t_element, 'ElementInstances');
return $t_element;
}
} else {
MemoryCache::save($vn_element_id, $t_element, 'ElementInstances');
MemoryCache::save($t_element->get('element_code'), $t_element, 'ElementInstances');
return $t_element;
}
return null;
}