本文整理汇总了PHP中Debug::msg方法的典型用法代码示例。如果您正苦于以下问题:PHP Debug::msg方法的具体用法?PHP Debug::msg怎么用?PHP Debug::msg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Debug
的用法示例。
在下文中一共展示了Debug::msg方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepopulateFields
/**
* Prepopulate record fields according to rules in prepopulate.conf
*
* @param array $pa_options Options array. Available options are:
* prepopulateConfig = override path to prepopulate.conf, e.g. for testing purposes
* @return bool success or not
*/
public function prepopulateFields($pa_options = null)
{
if (!$this->getPrimaryKey()) {
return false;
}
if (!($vs_prepopulate_cfg = caGetOption('prepopulateConfig', $pa_options, null))) {
$vs_prepopulate_cfg = $this->getAppConfig()->get('prepopulate_config');
}
$o_prepopulate_conf = Configuration::load($vs_prepopulate_cfg);
if (!($o_prepopulate_conf->get('prepopulate_fields_on_save') || $o_prepopulate_conf->get('prepopulate_fields_on_load'))) {
return false;
}
$va_rules = $o_prepopulate_conf->get('prepopulate_rules');
if (!$va_rules || !is_array($va_rules) || sizeof($va_rules) < 1) {
return false;
}
global $g_ui_locale_id;
// we need to unset the form timestamp to disable the 'Changes have been made since you loaded this data' warning when we update() $this
// the warning makes sense because an update()/insert() is called before we arrive here but after the form_timestamp ... but we chose to ignore it
$vn_timestamp = $_REQUEST['form_timestamp'];
unset($_REQUEST['form_timestamp']);
$vb_we_set_transaction = true;
if (!$this->inTransaction()) {
$this->setTransaction(new Transaction($this->getDb()));
$vb_we_set_transaction = true;
}
// process rules
$va_expression_vars = array();
// we only process those if and when we need them
foreach ($va_rules as $vs_rule_key => $va_rule) {
if ($this->tableName() != $va_rule['table']) {
continue;
}
// check target
$vs_target = $va_rule['target'];
if (strlen($vs_target) < 1) {
Debug::msg("[prepopulateFields()] skipping rule {$vs_rule_key} because target is not set");
continue;
}
// check template
$vs_template = $va_rule['template'];
if (strlen($vs_template) < 1) {
Debug::msg("[prepopulateFields()] skipping rule {$vs_rule_key} because template is not set");
continue;
}
$vs_mode = caGetOption('mode', $va_rule, 'merge');
// respect restrictToTypes option
if ($va_rule['restrictToTypes'] && is_array($va_rule['restrictToTypes']) && sizeof($va_rule['restrictToTypes']) > 0) {
if (!in_array($this->getTypeCode(), $va_rule['restrictToTypes'])) {
Debug::msg("[prepopulateFields()] skipping rule {$vs_rule_key} because current record type " . $this->getTypeCode() . " is not in restrictToTypes");
continue;
}
}
// skip this rule if expression is true
if ($va_rule['skipIfExpression'] && strlen($va_rule['skipIfExpression']) > 0) {
$va_tags = caGetTemplateTags($va_rule['skipIfExpression']);
foreach ($va_tags as $vs_tag) {
if (!isset($va_expression_vars[$vs_tag])) {
$va_expression_vars[$vs_tag] = $this->get($vs_tag, array('returnIdno' => true, 'delimiter' => ';'));
}
}
if (ExpressionParser::evaluate($va_rule['skipIfExpression'], $va_expression_vars)) {
Debug::msg("[prepopulateFields()] skipping rule {$vs_rule_key} because skipIfExpression evaluated true");
continue;
}
}
// evaluate template
$vs_value = caProcessTemplateForIDs($vs_template, $this->tableNum(), array($this->getPrimaryKey()), array('path' => true));
Debug::msg("[prepopulateFields()] processed template for rule {$vs_rule_key} value is: " . $vs_value);
// inject into target
$va_parts = explode('.', $vs_target);
// intrinsic or simple (non-container) attribute
if (sizeof($va_parts) == 2) {
// intrinsic
if ($this->hasField($va_parts[1])) {
switch (strtolower($vs_mode)) {
case 'overwrite':
// always set
$this->set($va_parts[1], $vs_value);
break;
case 'addifempty':
default:
if (!$this->get($va_parts[1])) {
$this->set($va_parts[1], $vs_value);
} else {
Debug::msg("[prepopulateFields()] rule {$vs_rule_key}: intrinsic skipped because it already has value and mode is addIfEmpty or merge");
}
break;
}
// attribute/element
} elseif ($this->hasElement($va_parts[1])) {
$va_attributes = $this->getAttributesByElement($va_parts[1]);
if (sizeof($va_attributes) > 1) {
//.........这里部分代码省略.........
示例2: getMenu
function getMenu($menu_id)
{
if ($menu_id == null) {
Debug::msg('Error', __FILE__, __LINE__);
return;
}
$arrSubmenus = $this->SelectOrder('mm_menu_submenu', 'submenu_id', 'orden', "menu_id = {$menu_id}");
if ($this->hasError() || count($arrSubmenus) == 0 || $arrSubmenus[0]['mm_menu_submenu.submenu_id'] == null) {
return null;
}
for ($i = 0; $i < count($arrSubmenus); $i++) {
$submenu_id = $arrSubmenus[$i]['mm_menu_submenu.submenu_id'];
$aux = $this->Select('mm_submenu', 'name', "submenu_id = {$submenu_id}");
$ret_val[$i]['name'] = $aux[0]['mm_submenu.name'];
$ret_val[$i]['submenu_id'] = $arrSubmenus[$i]['mm_menu_submenu.submenu_id'];
$arrOptions = $this->getSubmenu($arrSubmenus[$i]['mm_menu_submenu.submenu_id']);
for ($j = 0; $j < count($arrOptions); $j++) {
$ret_val[$i][$j]['name'] = $arrOptions[$j]['name'];
$ret_val[$i][$j]['param'] = $arrOptions[$j]['param'];
$ret_val[$i][$j]['option_id'] = $arrOptions[$j]['option_id'];
$ret_val[$i][$j]['module_name'] = $arrOptions[$j]['module_name'];
}
}
return $ret_val;
}
示例3: doSearch
/**
* Performs a search by calling the search() method on the underlying search engine plugin
* Information about all searches is logged to ca_search_log
*
* @param string $ps_search The search to perform; engine takes Lucene syntax query
* @param SearchResult $po_result A newly instantiated sub-class of SearchResult to place search results into and return. If this is not set, then a generic SearchResults object will be returned.
* @param array $pa_options Optional array of options for the search. Options include:
*
* sort = field or attribute to sort on in <table name>.<field or attribute name> format (eg. ca_objects.idno); default is to sort on relevance (aka. sort='_natural')
* sortDirection = direction to sort results by, either 'asc' for ascending order or 'desc' for descending order; default is 'asc'
* no_cache = if true, search is performed regardless of whether results for the search are already cached; default is false
* limit = if set then search results will be limited to the quantity specified. If not set then all results are returned.
* form_id = optional form identifier string to record in log for search
* log_details = optional form description to record in log for search
* search_source = optional source indicator text to record in log for search
* checkAccess = optional array of access values to filter results on
* showDeleted = if set to true, related items that have been deleted are returned. Default is false.
* deletedOnly = if set to true, only deleted items are returned. Default is false.
* limitToModifiedOn = if set returned results will be limited to rows modified within the specified date range. The value should be a date/time expression parse-able by TimeExpressionParser
* sets = if value is a list of set_ids, only rows that are members of those sets will be returned
* user_id = If set item level access control is performed relative to specified user_id, otherwise defaults to logged in user
* dontFilterByACL = if true ACL checking is not performed on results
* appendToSearch =
* restrictSearchToFields =
*
* @return SearchResult Results packages in a SearchResult object, or sub-class of SearchResult if an instance was passed in $po_result
* @uses TimeExpressionParser::parse
*/
public function doSearch($ps_search, $po_result = null, $pa_options = null)
{
$t = new Timer();
global $AUTH_CURRENT_USER_ID;
if ($vs_append_to_search = isset($pa_options['appendToSearch']) ? ' ' . $pa_options['appendToSearch'] : '') {
$ps_search .= $vs_append_to_search;
}
$ps_search = str_replace("[BLANK]", '"[BLANK]"', $ps_search);
// the special [BLANK] search term, which returns records that have *no* content in a specific fields, has to be quoted in order to protect the square brackets from the parser.
if (!is_array($pa_options)) {
$pa_options = array();
}
if (($vn_limit = caGetOption('limit', $pa_options, null, array('castTo' => 'int'))) < 0) {
$vn_limit = null;
}
$vs_sort = caGetOption('sort', $pa_options, null);
$vs_sort_direction = strtolower(caGetOption('sortDirection', $pa_options, caGetOption('sort_direction', $pa_options, null)));
//print "QUERY=$ps_search<br>";
//
// Note that this is *not* misplaced code that should be in the Lucene plugin!
//
// We are using the Lucene syntax as our query syntax regardless the of back-end search engine.
// The Lucene calls below just parse the query and then rewrite access points as-needed; the result
// is a Lucene-compliant query ready-to-roll that is passed to the engine plugin. Of course, the Lucene
// plugin just uses the string as-is... other plugins my choose to parse it however they wish to.
//
//
// Process suffixes list... if search conforms to regex then we append a suffix.
// This is useful, for example, to allow auto-wildcarding of accession numbers: if the search looks like an accession regex-wise we can append a "*"
//
$va_suffixes = $this->opo_search_config->getAssoc('search_suffixes');
if (is_array($va_suffixes) && sizeof($va_suffixes) && !preg_match('!"!', $ps_search)) {
// don't add suffix wildcards when quoting
foreach ($va_suffixes as $vs_preg => $vs_suffix) {
if (preg_match("!{$vs_preg}!", $ps_search)) {
$ps_search = preg_replace("!({$vs_preg})[\\*]*!", "\$1{$vs_suffix}", $ps_search);
}
}
}
$vb_no_cache = isset($pa_options['no_cache']) ? $pa_options['no_cache'] : false;
unset($pa_options['no_cache']);
$vn_cache_timeout = (int) $this->opo_search_config->get('cache_timeout');
if ($vn_cache_timeout == 0) {
$vb_no_cache = true;
}
// don't try to cache if cache timeout is 0 (0 means disabled)
$t_table = $this->opo_datamodel->getInstanceByTableName($this->ops_tablename, true);
$vs_cache_key = md5($ps_search . "/" . print_R($this->getTypeRestrictionList(), true));
$o_cache = new SearchCache();
$vb_from_cache = false;
if (!$vb_no_cache && $o_cache->load($vs_cache_key, $this->opn_tablenum, $pa_options)) {
$vn_created_on = $o_cache->getParameter('created_on');
if (time() - $vn_created_on < $vn_cache_timeout) {
Debug::msg('SEARCH cache hit for ' . $vs_cache_key);
$va_hits = $o_cache->getResults();
if ($vs_sort != '_natural') {
$va_hits = $this->sortHits($va_hits, $this->ops_tablename, $vs_sort, $vs_sort_direction);
} elseif ($vs_sort == '_natural' && $vs_sort_direction == 'desc') {
$va_hits = array_reverse($va_hits);
}
$o_res = new WLPlugSearchEngineCachedResult($va_hits, $this->opn_tablenum);
$vb_from_cache = true;
} else {
Debug::msg('cache expire for ' . $vs_cache_key);
$o_cache->remove();
}
}
if (!$vb_from_cache) {
Debug::msg('SEARCH cache miss for ' . $vs_cache_key);
$vs_char_set = $this->opo_app_config->get('character_set');
$o_query_parser = new LuceneSyntaxParser();
$o_query_parser->setEncoding($vs_char_set);
//.........这里部分代码省略.........
示例4: getExtraInfo
public function getExtraInfo($pa_settings, $ps_url)
{
$vs_lang = caGetOption('lang', $pa_settings, 'en');
// readable version of get parameters
$va_get_params = array('action' => 'query', 'titles' => self::getPageTitleFromURI($ps_url), 'prop' => 'pageimages|info|extracts', 'inprop' => 'url', 'piprop' => 'name|thumbnail', 'pithumbsize' => '200px', 'format' => 'json');
$vs_content = caQueryExternalWebservice('https://' . $vs_lang . '.wikipedia.org/w/api.php?' . caConcatGetParams($va_get_params));
$va_content = @json_decode($vs_content, true);
if (!is_array($va_content) || !isset($va_content['query']['pages'])) {
return array();
}
// the top two levels are 'query' and 'pages'
$va_results = $va_content['query']['pages'];
if (sizeof($va_results) > 1) {
Debug::msg('[Wikipedia] Found multiple results for page title ' . self::getPageTitleFromURI($ps_url));
}
if (sizeof($va_results) == 0) {
Debug::msg('[Wikipedia] Couldnt find any results for page title ' . self::getPageTitleFromURI($ps_url));
return null;
}
$va_result = array_shift($va_results);
// try to extract the first paragraph (usually an abstract/summary of the article)
$vs_abstract = preg_replace("/\\s+<p><\\/p>\\s+<h2>.+\$/ms", "", $va_result['extract']);
return array('image_thumbnail' => $va_result['thumbnail']['source'], 'image_thumbnail_width' => $va_result['thumbnail']['width'], 'image_thumbnail_height' => $va_result['thumbnail']['height'], 'image_viewer_url' => $va_result['fullurl'] . '#/media/File:' . $va_result['pageimage'], 'title' => $va_result['title'], 'pageid' => $va_result['page_id'], 'fullurl' => $va_result['fullurl'], 'canonicalurl' => $va_result['canonicalurl'], 'extract' => $va_result['extract'], 'abstract' => $vs_abstract);
}
示例5: search
//.........这里部分代码省略.........
$o_lucene_query_element = new Zend_Search_Lucene_Search_Query_Term(new Zend_Search_Lucene_Index_Term('[' . $va_coords['min_latitude'] . ',' . $va_coords['min_longitude'] . " TO " . $va_coords['max_latitude'] . ',' . $va_coords['max_longitude'] . ']', $vs_table . '.' . $vs_fld_num));
}
break;
case 6:
// currency
$t_cur = new CurrencyAttributeValue();
$va_parsed_value = $t_cur->parseValue($vs_term, $t_element->getFieldValuesArray());
$vn_amount = (double) $va_parsed_value['value_decimal1'];
$vs_currency = preg_replace('![^A-Z0-9]+!', '', $va_parsed_value['value_longtext1']);
$o_lucene_query_element = new Zend_Search_Lucene_Search_Query_Term(new Zend_Search_Lucene_Index_Term($vn_amount, $vs_table . '.' . $vs_fld_num));
break;
case 8:
// length
$t_len = new LengthAttributeValue();
$va_parsed_value = $t_len->parseValue($vs_term, $t_element->getFieldValuesArray());
$vn_len = (double) $va_parsed_value['value_decimal1'];
// this is always in meters so we can compare this value to the one in the database
$o_lucene_query_element = new Zend_Search_Lucene_Search_Query_Term(new Zend_Search_Lucene_Index_Term($vn_len, $vs_table . '.' . $vs_fld_num));
break;
case 9:
// weight
$t_weight = new WeightAttributeValue();
$va_parsed_value = $t_weight->parseValue($vs_term, $t_element->getFieldValuesArray());
$vn_weight = (double) $va_parsed_value['value_decimal1'];
// this is always in kilograms so we can compare this value to the one in the database
$o_lucene_query_element = new Zend_Search_Lucene_Search_Query_Term(new Zend_Search_Lucene_Index_Term($vn_weight, $vs_table . '.' . $vs_fld_num));
break;
case 10:
// timecode
$t_timecode = new TimecodeAttributeValue();
$va_parsed_value = $t_timecode->parseValue($vs_term, $t_element->getFieldValuesArray());
$vn_timecode = (double) $va_parsed_value['value_decimal1'];
$o_lucene_query_element = new Zend_Search_Lucene_Search_Query_Term(new Zend_Search_Lucene_Index_Term($vn_timecode, $vs_table . '.' . $vs_fld_num));
break;
case 11:
// integer
$o_lucene_query_element = new Zend_Search_Lucene_Search_Query_Term(new Zend_Search_Lucene_Index_Term((double) $vs_term, $vs_table . '.' . $vs_fld_num));
break;
case 12:
// decimal
$o_lucene_query_element = new Zend_Search_Lucene_Search_Query_Term(new Zend_Search_Lucene_Index_Term((double) $vs_term, $vs_table . '.' . $vs_fld_num));
break;
default:
// everything else
$o_lucene_query_element->getTerm()->field = $vs_table . '.' . $vs_fld_num;
break;
}
} else {
$vn_fld_num = false;
$vs_fld_num = $vs_field;
}
}
}
}
}
}
}
break;
}
$va_terms[] = $o_lucene_query_element;
$va_signs[] = is_array($va_old_signs) ? array_key_exists($vn_i, $va_old_signs) ? $va_old_signs[$vn_i] : true : true;
$vn_i++;
}
$o_rewritten_query = new Zend_Search_Lucene_Search_Query_Boolean($va_terms, $va_signs);
$ps_search_expression = $this->_queryToString($o_rewritten_query);
}
if (is_array($pa_filters) && sizeof($pa_filters) && ($vs_filter_query = $this->_filterValueToQueryValue($pa_filters))) {
$ps_search_expression = "({$ps_search_expression}) AND ({$vs_filter_query})";
}
if (preg_match_all("!([A-Za-z0-9_\\-\\.]+)[/]{1}([A-Za-z0-9_\\-]+):(\"[^\"]*\")!", $ps_search_expression, $va_matches) || preg_match_all("!([A-Za-z0-9_\\-\\.]+)[/]{1}([A-Za-z0-9_\\-]+):([^ ]*)!", $ps_search_expression, $va_matches)) {
foreach ($va_matches[0] as $vn_i => $vs_element) {
$vs_fld = $va_matches[1][$vn_i];
if (!($vs_rel_type = trim($va_matches[2][$vn_i]))) {
continue;
}
$va_tmp = explode(".", $vs_fld);
$vs_rel_table = caGetRelationshipTableName($pn_subject_tablenum, $va_tmp[0]);
$va_rel_type_ids = $vs_rel_type && $vs_rel_table ? caMakeRelationshipTypeIDList($vs_rel_table, array($vs_rel_type)) : null;
$va_new_elements = array();
foreach ($va_rel_type_ids as $vn_rel_type_id) {
$va_new_elements[] = "(" . $va_matches[1][$vn_i] . "/" . $vn_rel_type_id . ":" . $va_matches[3][$vn_i] . ")";
}
$ps_search_expression = str_replace($vs_element, "(" . join(" OR ", $va_new_elements) . ")", $ps_search_expression);
}
}
$ps_search_expression = str_replace("/", '\\/', $ps_search_expression);
// escape forward slashes used to delimit relationship type qualifier
Debug::msg("[SOLR] Running query {$ps_search_expression}");
try {
$vo_http_client = new Zend_Http_Client();
$vo_http_client->setUri($this->ops_search_solr_url . "/" . $this->opo_datamodel->getTableName($pn_subject_tablenum) . "/select");
$vo_http_client->setParameterGet($va_get = array('q' => utf8_decode($ps_search_expression), 'wt' => 'json', 'fl' => $this->opo_datamodel->getTablePrimaryKeyName($pn_subject_tablenum), 'start' => $this->getOption('start'), 'rows' => $this->getOption('limit')));
$vo_http_response = $vo_http_client->request();
$va_result = json_decode($vo_http_response->getBody(), true);
} catch (Exception $e) {
caLogEvent('ERR', _t('Could not connect to SOLR server: %1', $e->getMessage()), 'Solr->search()');
$va_result["response"]["docs"] = array();
}
return new WLPlugSearchEngineSolrResult($va_result["response"]["docs"], $pn_subject_tablenum);
}
示例6: execute
/**
* Perform the browse using currently applied criteria, calculating the result set and browse facets
* required for subsequent browse refinement. You need to call execute() after setting up your browse
* criteria and options to:
* • Get the result set reflecting the current browse state
* • Fetch browse facets that reflect the current browse state
*
* @param array $pa_options Options include:
* checkAccess = array of access values to filter facets that have an 'access' field by
* noCache = don't use cached browse results
* showDeleted = if set to true, related items that have been deleted are returned. Default is false.
* limitToModifiedOn = if set returned results will be limited to rows modified within the specified date range. The value should be a date/time expression parse-able by TimeExpressionParser
* user_id = If set item level access control is performed relative to specified user_id, otherwise defaults to logged in user
*
* @return bool True on success, null if the browse could not be executed (Eg. no settings), false no error
*/
public function execute($pa_options = null)
{
global $AUTH_CURRENT_USER_ID;
if (!is_array($this->opa_browse_settings)) {
return null;
}
if (!is_array($pa_options)) {
$pa_options = array();
}
$vn_user_id = caGetOption('user_id', $pa_options, $AUTH_CURRENT_USER_ID, array('castTo' => 'int'));
$vb_no_cache = caGetOption('noCache', $pa_options, caGetOption('no_cache', $pa_options, false, array('castTo' => 'bool')), array('castTo' => 'bool'));
$va_params = $this->opo_ca_browse_cache->getParameters();
$vb_need_to_cache_facets = false;
$vb_results_cached = false;
$vb_need_to_save_in_cache = false;
$vs_cache_key = $this->opo_ca_browse_cache->getCurrentCacheKey();
if ($this->opo_ca_browse_cache->load($vs_cache_key)) {
$vn_created_on = $this->opo_ca_browse_cache->getParameter('created_on');
//$t_new_browse->get('created_on', array('getDirectDate' => true));
$va_criteria = $this->getCriteria();
if (!$vb_no_cache && intval(time() - $vn_created_on) < $this->opo_ca_browse_config->get('cache_timeout')) {
$vb_results_cached = true;
$this->opo_ca_browse_cache->setParameter('created_on', time() + $this->opo_ca_browse_config->get('cache_timeout'));
$vb_need_to_save_in_cache = true;
Debug::msg("Cache hit for {$vs_cache_key}");
} else {
$va_criteria = $this->getCriteria();
//$this->opo_ca_browse_cache->remove();
//$this->opo_ca_browse_cache->setParameter('criteria', $va_criteria);
$vb_need_to_save_in_cache = true;
$vb_need_to_cache_facets = true;
Debug::msg("Cache expire for {$vs_cache_key}");
}
} else {
$va_criteria = $this->getCriteria();
$vb_need_to_save_in_cache = true;
Debug::msg("Cache miss for {$vs_cache_key}");
}
if (!$vb_results_cached) {
$this->opo_ca_browse_cache->setParameter('sort', null);
$this->opo_ca_browse_cache->setParameter('created_on', time());
$this->opo_ca_browse_cache->setParameter('table_num', $this->opn_browse_table_num);
$vb_need_to_cache_facets = true;
}
$this->opb_criteria_have_changed = false;
$t_item = $this->opo_datamodel->getInstanceByTableName($this->ops_browse_table_name, true);
$va_results = array();
if (is_array($va_criteria) && sizeof($va_criteria) > 0) {
if (!$vb_results_cached) {
$va_acc = array();
$vn_i = 0;
foreach ($va_criteria as $vs_facet_name => $va_row_ids) {
$vs_target_browse_table_name = $t_item->tableName();
$vs_target_browse_table_num = $t_item->tableNum();
$vs_target_browse_table_pk = $t_item->primaryKey();
$va_facet_info = $this->getInfoForFacet($vs_facet_name);
$va_row_ids = array_keys($va_row_ids);
$vs_relative_to_join = '';
switch ($va_facet_info['type']) {
# -----------------------------------------------------
case 'has':
$vs_rel_table_name = $va_facet_info['table'];
$va_joins = array();
if ($va_facet_info['relative_to']) {
if ($va_relative_execute_sql_data = $this->_getRelativeExecuteSQLData($va_facet_info['relative_to'], $pa_options)) {
$va_joins = array_merge($va_joins, $va_relative_execute_sql_data['relative_joins']);
$vs_target_browse_table_name = $va_relative_execute_sql_data['target_table_name'];
$vs_target_browse_table_num = $va_relative_execute_sql_data['target_table_num'];
$vs_target_browse_table_pk = $va_relative_execute_sql_data['target_table_pk'];
}
}
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'];
$vn_state = array_pop($va_row_ids);
if ($vn_state == 0) {
$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 {
$va_joins[] = "INNER JOIN ca_attributes AS caa ON caa.row_id = " . $this->ops_browse_table_name . '.' . $t_item->primaryKey() . " AND caa.table_num = " . $t_item->tableNum();
$va_wheres[] = "caa.element_id = " . $t_element->getPrimaryKey();
}
//.........这里部分代码省略.........
示例7: search
//.........这里部分代码省略.........
if ($this->opo_tep->parse($vs_term)) {
// TODO: fix date handling to reflect distinctions in ranges
$o_lucene_query_element = new Zend_Search_Lucene_Search_Query_Term(new Zend_Search_Lucene_Index_Term('[' . $this->opo_tep->getText(array('start_as_iso8601' => true)) . " TO " . $this->opo_tep->getText(array('end_as_iso8601' => true)) . ']', $vs_access_point));
}
} else {
if ($this->opo_tep->parse($vs_term)) {
// TODO: fix date handling to reflect distinctions in ranges
$o_lucene_query_element = new Zend_Search_Lucene_Search_Query_Term(new Zend_Search_Lucene_Index_Term('[' . $this->opo_tep->getText(array('start_as_iso8601' => true)) . " TO " . $this->opo_tep->getText(array('end_as_iso8601' => true)) . ']', $vs_access_point));
}
}
break;
case 4:
// geocode
$t_geocode = new GeocodeAttributeValue();
if ($va_coords = caParseGISSearch($vs_term)) {
$o_lucene_query_element = new Zend_Search_Lucene_Search_Query_Term(new Zend_Search_Lucene_Index_Term('[' . $va_coords['min_latitude'] . ',' . $va_coords['min_longitude'] . " TO " . $va_coords['max_latitude'] . ',' . $va_coords['max_longitude'] . ']', $vs_access_point));
}
break;
case 6:
// currency
$t_cur = new CurrencyAttributeValue();
$va_parsed_value = $t_cur->parseValue($vs_term, $t_element->getFieldValuesArray());
$vn_amount = (double) $va_parsed_value['value_decimal1'];
$vs_currency = preg_replace('![^A-Z0-9]+!', '', $va_parsed_value['value_longtext1']);
$o_lucene_query_element = new Zend_Search_Lucene_Search_Query_Term(new Zend_Search_Lucene_Index_Term($vn_amount, $vs_access_point));
break;
case 8:
// length
$t_len = new LengthAttributeValue();
$va_parsed_value = $t_len->parseValue($vs_term, $t_element->getFieldValuesArray());
$vn_len = (double) $va_parsed_value['value_decimal1'];
// this is always in meters so we can compare this value to the one in the database
$o_lucene_query_element = new Zend_Search_Lucene_Search_Query_Term(new Zend_Search_Lucene_Index_Term($vn_len, $vs_access_point));
break;
case 9:
// weight
$t_weight = new WeightAttributeValue();
$va_parsed_value = $t_weight->parseValue($vs_term, $t_element->getFieldValuesArray());
$vn_weight = (double) $va_parsed_value['value_decimal1'];
// this is always in kilograms so we can compare this value to the one in the database
$o_lucene_query_element = new Zend_Search_Lucene_Search_Query_Term(new Zend_Search_Lucene_Index_Term($vn_weight, $vs_access_point));
break;
case 10:
// timecode
$t_timecode = new TimecodeAttributeValue();
$va_parsed_value = $t_timecode->parseValue($vs_term, $t_element->getFieldValuesArray());
$vn_timecode = (double) $va_parsed_value['value_decimal1'];
$o_lucene_query_element = new Zend_Search_Lucene_Search_Query_Term(new Zend_Search_Lucene_Index_Term($vn_timecode, $vs_access_point));
break;
case 11:
// integer
$o_lucene_query_element = new Zend_Search_Lucene_Search_Query_Term(new Zend_Search_Lucene_Index_Term((double) $vs_term, $vs_access_point));
break;
case 12:
// decimal
$o_lucene_query_element = new Zend_Search_Lucene_Search_Query_Term(new Zend_Search_Lucene_Index_Term((double) $vs_term, $vs_access_point));
break;
}
}
}
}
}
}
break;
}
$va_terms[] = $o_lucene_query_element;
$va_signs[] = is_array($va_old_signs) ? array_key_exists($vn_i, $va_old_signs) ? $va_old_signs[$vn_i] : true : true;
$vn_i++;
}
$o_rewritten_query = new Zend_Search_Lucene_Search_Query_Boolean($va_terms, $va_signs);
$ps_search_expression = $this->_queryToString($o_rewritten_query);
if ($vs_filter_query = $this->_filterValueToQueryValue($pa_filters)) {
$ps_search_expression = "({$ps_search_expression}) AND ({$vs_filter_query})";
}
$vo_http_client = new Zend_Http_Client();
$vo_http_client->setUri($this->ops_elasticsearch_base_url . "/" . $this->ops_elasticsearch_index_name . "/" . $this->opo_datamodel->getTableName($pn_subject_tablenum) . "/" . "_search");
if (preg_match_all("!([A-Za-z0-9_\\-\\.]+)[/]{1}([A-Za-z0-9_\\-]+):(\"[^\"]*\")!", $ps_search_expression, $va_matches) || preg_match_all("!([A-Za-z0-9_\\-\\.]+)[/]{1}([A-Za-z0-9_\\-]+):([^ ]*)!", $ps_search_expression, $va_matches)) {
foreach ($va_matches[0] as $vn_i => $vs_element) {
$vs_fld = $va_matches[1][$vn_i];
if (!($vs_rel_type = trim($va_matches[2][$vn_i]))) {
continue;
}
$va_tmp = explode(".", $vs_fld);
$vs_rel_table = caGetRelationshipTableName($pn_subject_tablenum, $va_tmp[0]);
$va_rel_type_ids = $vs_rel_type && $vs_rel_table ? caMakeRelationshipTypeIDList($vs_rel_table, array($vs_rel_type)) : null;
$va_new_elements = array();
foreach ($va_rel_type_ids as $vn_rel_type_id) {
$va_new_elements[] = "(" . $va_matches[1][$vn_i] . "/" . $vn_rel_type_id . ":" . $va_matches[3][$vn_i] . ")";
}
$ps_search_expression = str_replace($vs_element, "(" . join(" OR ", $va_new_elements) . ")", $ps_search_expression);
}
}
$ps_search_expression = str_replace("/", '\\/', $ps_search_expression);
// escape forward slashes used to delimit relationship type qualifier
Debug::msg("[ElasticSearch] Running query {$ps_search_expression}");
$vo_http_client->setParameterGet(array('size' => intval($this->opa_options["limit"]), 'q' => $ps_search_expression, 'fields' => ''));
$vo_http_response = $vo_http_client->request();
$va_result = json_decode($vo_http_response->getBody(), true);
return new WLPlugSearchEngineElasticSearchResult($va_result["hits"]["hits"], $pn_subject_tablenum);
}
示例8: updateIndexingInPlace
/**
*
*
* @param int $pn_subject_tablenum
* @param array $pa_subject_row_ids
* @param int $pn_content_tablenum
* @param string $ps_content_fieldnum
* @param int $pn_content_row_id
* @param string $ps_content
* @param array $pa_options
* literalContent = array of text content to be applied without tokenization
* BOOST = Indexing boost to apply
* PRIVATE = Set indexing to private
*/
public function updateIndexingInPlace($pn_subject_tablenum, $pa_subject_row_ids, $pn_content_tablenum, $ps_content_fieldnum, $pn_content_row_id, $ps_content, $pa_options = null)
{
// Find existing indexing for this subject and content
foreach ($pa_subject_row_ids as $vn_subject_row_id) {
$this->removeRowIndexing($pn_subject_tablenum, $vn_subject_row_id, $pn_content_tablenum, $ps_content_fieldnum, $pn_content_row_id);
}
if (caGetOption("DONT_TOKENIZE", $pa_options, false) || in_array('DONT_TOKENIZE', $pa_options)) {
$va_words = array($ps_content);
} else {
$va_words = $this->_tokenize($ps_content);
}
if (caGetOption("INDEX_AS_IDNO", $pa_options, false) || in_array('INDEX_AS_IDNO', $pa_options)) {
$t_content = $this->opo_datamodel->getInstanceByTableNum($pn_content_tablenum, true);
if (method_exists($t_content, "getIDNoPlugInInstance") && ($o_idno = $t_content->getIDNoPlugInInstance())) {
$va_values = $o_idno->getIndexValues($ps_content);
$va_words += $va_values;
}
}
$va_literal_content = caGetOption("literalContent", $pa_options, null);
if ($va_literal_content && !is_array($va_literal_content)) {
$va_literal_content = array($va_literal_content);
}
$vn_boost = 1;
if (isset($pa_options['BOOST'])) {
$vn_boost = intval($pa_options['BOOST']);
}
if (!isset($pa_options['PRIVATE'])) {
$pa_options['PRIVATE'] = 0;
}
if (in_array('PRIVATE', $pa_options, true)) {
$pa_options['PRIVATE'] = 1;
}
$vn_private = $pa_options['PRIVATE'] ? 1 : 0;
$vn_rel_type_id = (int) caGetOption('relationship_type_id', $pa_options, 0);
$va_row_insert_sql = array();
$pn_subject_tablenum = (int) $pn_subject_tablenum;
$vn_row_id = (int) $vn_row_id;
$pn_content_tablenum = (int) $pn_content_tablenum;
$pn_content_row_id = (int) $pn_content_row_id;
$vn_boost = (int) $vn_boost;
$vn_access = (int) $vn_access;
foreach ($pa_subject_row_ids as $vn_row_id) {
if (!$vn_row_id) {
if ($this->debug) {
Debug::msg("[SqlSearchDebug] Cannot index row because row id is missing!");
}
continue;
}
$vn_seq = 0;
foreach ($va_words as $vs_word) {
if (!($vn_word_id = $this->getWordID($vs_word))) {
continue;
}
$va_row_insert_sql[] = "({$pn_subject_tablenum}, {$vn_row_id}, {$pn_content_tablenum}, '{$ps_content_fieldnum}', {$pn_content_row_id}, {$vn_word_id}, {$vn_boost}, {$vn_private}, {$vn_rel_type_id})";
$vn_seq++;
}
if (is_array($va_literal_content)) {
foreach ($va_literal_content as $vs_literal) {
if (!($vn_word_id = $this->getWordID($vs_literal))) {
continue;
}
$va_row_insert_sql[] = "({$pn_subject_tablenum}, {$vn_row_id}, {$pn_content_tablenum}, '{$ps_content_fieldnum}', {$pn_content_row_id}, {$vn_word_id}, {$vn_boost}, {$vn_private}, {$vn_rel_type_id})";
$vn_seq++;
}
}
}
// do insert
if (sizeof($va_row_insert_sql)) {
$vs_sql = $this->ops_insert_word_index_sql . "\n" . join(",", $va_row_insert_sql);
$this->opo_db->query($vs_sql);
if ($this->debug) {
Debug::msg("[SqlSearchDebug] Commit row indexing");
}
}
}
示例9: getObjectHistory
//.........这里部分代码省略.........
foreach ($va_occurrence_types as $vn_type_id) {
if (!is_array($va_date_elements = caGetOption("ca_occurrences_{$va_occurrence_type_info[$vn_type_id]['idno']}_dateElement", $pa_bundle_settings, null)) && $va_date_elements) {
$va_date_elements = array($va_date_elements);
}
if (!$va_date_elements) {
continue;
}
$va_date_elements_by_type[$vn_type_id] = $va_date_elements;
}
while ($qr_occurrences->nextHit()) {
$vn_occurrence_id = $qr_occurrences->get('occurrence_id');
if ((string) $qr_occurrences->get('ca_occurrences.deleted') !== '0') {
continue;
}
// filter out deleted
$vn_type_id = $qr_occurrences->get('type_id');
$va_dates = array();
if (is_array($va_date_elements_by_type[$vn_type_id]) && sizeof($va_date_elements_by_type[$vn_type_id])) {
foreach ($va_date_elements_by_type[$vn_type_id] as $vs_date_element) {
$va_dates[] = array('sortable' => $qr_occurrences->get("ca_occurrences.{$vs_date_element}", array('getDirectDate' => true)), 'display' => $qr_occurrences->get("ca_occurrences.{$vs_date_element}"));
}
}
if (!sizeof($va_dates)) {
$va_dates[] = array('sortable' => $vn_date = caUnixTimestampToHistoricTimestamps($qr_occurrences->get('lastModified')), 'display' => caGetLocalizedDate($vn_date));
}
$vs_default_display_template = '^ca_occurrences.preferred_labels.name (^ca_occurrences.idno)';
$vs_display_template = $pb_display_label_only ? $vs_default_display_template : caGetOption("ca_occurrences_{$va_occurrence_type_info[$vn_type_id]['idno']}_displayTemplate", $pa_bundle_settings, $vs_default_display_template);
foreach ($va_dates as $va_date) {
if (!$va_date['sortable']) {
continue;
}
if (!in_array($vn_type_id, $va_occurrence_types)) {
continue;
}
if ($pb_get_current_only && $va_date['sortable'] > $vn_current_date) {
continue;
}
$vs_color = $va_occurrence_type_info[$vn_type_id]['color'];
if (!$vs_color || $vs_color == '000000') {
$vs_color = caGetOption("ca_occurrences_{$va_occurrence_type_info[$vn_type_id]['idno']}_color", $pa_bundle_settings, 'ffffff');
}
$va_history[$va_date['sortable']][] = array('type' => 'ca_occurrences', 'id' => $vn_occurrence_id, 'display' => $qr_occurrences->getWithTemplate($vs_display_template), 'color' => $vs_color, 'icon_url' => $vs_icon_url = $o_media_coder->getMediaTag($va_occurrence_type_info[$vn_type_id]['icon'], 'icon'), 'typename_singular' => $vs_typename = $va_occurrence_type_info[$vn_type_id]['name_singular'], 'typename_plural' => $va_occurrence_type_info[$vn_type_id]['name_plural'], 'type_id' => $vn_type_id, 'icon' => '<div class="caUseHistoryIconContainer" style="background-color: #' . $vs_color . '"><div class="caUseHistoryIcon">' . ($vs_icon_url ? $vs_icon_url : '<div class="caUseHistoryIconText">' . $vs_typename . '</div>') . '</div></div>', 'date' => $va_date['display']);
}
}
}
// Storage locations
$va_locations = $this->get('ca_objects_x_storage_locations.relation_id', array('returnAsArray' => true));
if (is_array($va_location_types = caGetOption('ca_storage_locations_showRelationshipTypes', $pa_bundle_settings, null)) && is_array($va_locations) && sizeof($va_locations)) {
$t_location = new ca_storage_locations();
$va_location_type_info = $t_location->getTypeList();
$vs_name_singular = $t_location->getProperty('NAME_SINGULAR');
$vs_name_plural = $t_location->getProperty('NAME_PLURAL');
$qr_locations = caMakeSearchResult('ca_objects_x_storage_locations', $va_locations);
$vs_default_display_template = '^ca_storage_locations.parent.preferred_labels.name ➜ ^ca_storage_locations.preferred_labels.name (^ca_storage_locations.idno)';
$vs_display_template = $pb_display_label_only ? $vs_default_display_template : caGetOption('ca_storage_locations_displayTemplate', $pa_bundle_settings, $vs_default_display_template);
Debug::msg($qr_locations->numHits());
while ($qr_locations->nextHit()) {
$vn_location_id = $qr_locations->get('ca_objects_x_storage_locations.location_id');
if ((string) $qr_locations->get('ca_storage_locations.deleted') !== '0') {
continue;
}
// filter out deleted
$va_date = array('sortable' => $qr_locations->get("ca_objects_x_storage_locations.effective_date", array('getDirectDate' => true)), 'display' => $qr_locations->get("ca_objects_x_storage_locations.effective_date"));
if (!$va_date['sortable']) {
continue;
}
if (!in_array($vn_rel_type_id = $qr_locations->get('ca_objects_x_storage_locations.type_id'), $va_location_types)) {
continue;
}
$vn_type_id = $qr_locations->get('ca_storage_locations.type_id');
if ($pb_get_current_only && $va_date['sortable'] > $vn_current_date) {
continue;
}
$vs_color = $va_location_type_info[$vn_type_id]['color'];
if (!$vs_color || $vs_color == '000000') {
$vs_color = caGetOption("ca_storage_locations_color", $pa_bundle_settings, 'ffffff');
}
$va_history[$va_date['sortable']][] = array('type' => 'ca_storage_locations', 'id' => $vn_location_id, 'relation_id' => $qr_locations->get('relation_id'), 'display' => $qr_locations->getWithTemplate("<unit relativeTo='ca_storage_locations'>{$vs_display_template}</unit>"), 'color' => $vs_color, 'icon_url' => $vs_icon_url = $o_media_coder->getMediaTag($va_location_type_info[$vn_type_id]['icon'], 'icon'), 'typename_singular' => $vs_name_singular, 'typename_plural' => $vs_name_plural, 'type_id' => $vn_type_id, 'rel_type_id' => $vn_rel_type_id, 'icon' => '<div class="caUseHistoryIconContainer" style="background-color: #' . $vs_color . '"><div class="caUseHistoryIcon">' . ($vs_icon_url ? $vs_icon_url : '<div class="caUseHistoryIconText">' . $vs_name_singular . '</div>') . '</div></div>', 'date' => $va_date['display']);
}
}
// Deaccession
if ($this->get('is_deaccessioned') && caGetOption('showDeaccessionInformation', $pa_bundle_settings, false)) {
$vs_color = caGetOption('deaccession_color', $pa_bundle_settings, 'cccccc');
$vn_date = $this->get('deaccession_date', array('getDirectDate' => true));
$vs_default_display_template = '^ca_objects.deaccession_notes';
$vs_display_template = $pb_display_label_only ? $vs_default_display_template : caGetOption('deaccession_displayTemplate', $pa_bundle_settings, $vs_default_display_template);
if (!($pb_get_current_only && $vn_date > $vn_current_date)) {
$va_history[$vn_date][] = array('type' => 'ca_objects_deaccession', 'id' => $this->getPrimaryKey(), 'display' => $this->getWithTemplate("<unit>{$vs_display_template}</unit>"), 'color' => $vs_color, 'icon_url' => '', 'typename_singular' => $vs_name_singular = _t('deaccession'), 'typename_plural' => $vs_name_plural = _t('deaccessions'), 'type_id' => null, 'icon' => '<div class="caUseHistoryIconContainer" style="background-color: #' . $vs_color . '"><div class="caUseHistoryIcon"><div class="caUseHistoryIconText">' . $vs_name_singular . '</div>' . '</div></div>', 'date' => $this->get('deaccession_date'));
}
}
ksort($va_history);
$va_history = array_reverse($va_history);
if ($pn_limit > 0) {
$va_history = array_slice($va_history, 0, $pn_limit);
}
if (sizeof(ca_objects::$s_object_use_cache[$vs_cache_key]) > 100) {
ca_objects::$s_object_use_cache[$vs_cache_key] = array_slice(ca_objects::$s_object_use_cache[$vs_cache_key], 0, 50);
}
return ca_objects::$s_object_use_cache[$vs_cache_key] = $va_history;
}
示例10: Save
/**
* Saves the content of a form editing new or existing records. It returns the same form + status messages rendered into the current view, inherited from ActionController
*
* @param array $pa_options Array of options passed through to _initView and saveBundlesForScreen()
*/
public function Save($pa_options = null)
{
list($vn_subject_id, $t_subject, $t_ui, $vn_parent_id, $vn_above_id, $vs_rel_table, $vn_rel_type_id, $vn_rel_id) = $this->_initView($pa_options);
if (!is_array($pa_options)) {
$pa_options = array();
}
if (!$this->_checkAccess($t_subject)) {
return false;
}
if ($vn_above_id) {
// Convert "above" id (the id of the record we're going to make the newly created record parent of
if (($t_instance = $this->opo_datamodel->getInstanceByTableName($this->ops_table_name)) && $t_instance->load($vn_above_id)) {
$vn_parent_id = $t_instance->get($vs_parent_id_fld = $t_instance->getProperty('HIERARCHY_PARENT_ID_FLD'));
$this->request->setParameter($vs_parent_id_fld, $vn_parent_id);
$this->view->setVar('parent_id', $vn_parent_id);
}
}
if (in_array($this->ops_table_name, array('ca_representation_annotations'))) {
$vs_auth_table_name = 'ca_objects';
}
if (!sizeof($_POST)) {
$this->notification->addNotification(_t("Cannot save using empty request. Are you using a bookmark?"), __NOTIFICATION_TYPE_ERROR__);
$this->render('screen_html.php');
return;
}
// set "context" id from those editors that need to restrict idno lookups to within the context of another field value (eg. idno's for ca_list_items are only unique within a given list_id)
$vn_context_id = null;
if ($vs_idno_context_field = $t_subject->getProperty('ID_NUMBERING_CONTEXT_FIELD')) {
if ($vn_subject_id > 0) {
$this->view->setVar('_context_id', $vn_context_id = $t_subject->get($vs_idno_context_field));
} else {
if ($vn_parent_id > 0) {
$t_parent = $this->opo_datamodel->getInstanceByTableName($this->ops_table_name);
if ($t_parent->load($vn_parent_id)) {
$this->view->setVar('_context_id', $vn_context_id = $t_parent->get($vs_idno_context_field));
}
}
}
if ($vn_context_id) {
$t_subject->set($vs_idno_context_field, $vn_context_id);
}
}
if (!($vs_type_name = $t_subject->getTypeName())) {
$vs_type_name = $t_subject->getProperty('NAME_SINGULAR');
}
if ($vn_subject_id && !$t_subject->getPrimaryKey()) {
$this->notification->addNotification(_t("%1 does not exist", $vs_type_name), __NOTIFICATION_TYPE_ERROR__);
return;
}
$vb_is_insert = !$t_subject->getPrimaryKey();
# trigger "BeforeSaveItem" hook
$this->opo_app_plugin_manager->hookBeforeSaveItem(array('id' => $vn_subject_id, 'table_num' => $t_subject->tableNum(), 'table_name' => $t_subject->tableName(), 'instance' => $t_subject, 'is_insert' => $vb_is_insert));
$vb_save_rc = false;
$va_opts = array_merge($pa_options, array('ui_instance' => $t_ui));
if ($this->_beforeSave($t_subject, $vb_is_insert)) {
if ($vb_save_rc = $t_subject->saveBundlesForScreen($this->request->getActionExtra(), $this->request, $va_opts)) {
$this->_afterSave($t_subject, $vb_is_insert);
}
}
$this->view->setVar('t_ui', $t_ui);
if (!$vn_subject_id) {
// this was an insert
$vn_subject_id = $t_subject->getPrimaryKey();
if (!$vb_save_rc) {
// failed insert
$vs_message = _t("Could not save %1", $vs_type_name);
} else {
// ok insert
$vs_message = _t("Added %1", $vs_type_name);
$this->request->setParameter($t_subject->primaryKey(), $vn_subject_id, 'GET');
$this->view->setVar($t_subject->primaryKey(), $vn_subject_id);
$this->view->setVar('subject_id', $vn_subject_id);
$this->request->session->setVar($this->ops_table_name . '_browse_last_id', $vn_subject_id);
// set last edited
// relate newly created record if requested
if ($vs_rel_table && $vn_rel_type_id && $vn_rel_id) {
if ($this->opo_datamodel->tableExists($vs_rel_table)) {
Debug::msg("[Save()] Relating new record using parameters from request: {$vs_rel_table} / {$vn_rel_type_id} / {$vn_rel_id}");
$t_subject->addRelationship($vs_rel_table, $vn_rel_id, $vn_rel_type_id);
}
}
// Set ACL for newly created record
if ($t_subject->getAppConfig()->get('perform_item_level_access_checking') && !$t_subject->getAppConfig()->get("{$this->ops_table_name}_dont_do_item_level_access_control")) {
$t_subject->setACLUsers(array($this->request->getUserID() => __CA_ACL_EDIT_DELETE_ACCESS__));
$t_subject->setACLWorldAccess($t_subject->getAppConfig()->get('default_item_access_level'));
}
// If "above_id" is set then, we want to load the record pointed to by it and set its' parent to be the newly created record
// The newly created record's parent is already set to be the current parent of the "above_id"; the net effect of all of this
// is to insert the newly created record between the "above_id" record and its' current parent.
if ($vn_above_id && ($t_instance = $this->opo_datamodel->getInstanceByTableName($this->ops_table_name, true)) && $t_instance->load($vn_above_id)) {
$t_instance->setMode(ACCESS_WRITE);
$t_instance->set('parent_id', $vn_subject_id);
$t_instance->update();
if ($t_instance->numErrors()) {
$this->notification->addNotification($t_instance->getErrorDescription(), __NOTIFICATION_TYPE_ERROR__);
//.........这里部分代码省略.........
示例11: search
/**
* Do search
*
* @param int $pn_subject_tablenum
* @param string $ps_search_expression
* @param array $pa_filters
* @param null|Zend_Search_Lucene_Search_Query_Boolean $po_rewritten_query
* @return WLPlugSearchEngineElasticSearchResult
*/
public function search($pn_subject_tablenum, $ps_search_expression, $pa_filters = array(), $po_rewritten_query = null)
{
Debug::msg("[ElasticSearch] incoming search query is: {$ps_search_expression}");
Debug::msg("[ElasticSearch] incoming query filters are: " . print_r($pa_filters, true));
$o_query = new ElasticSearch\Query($pn_subject_tablenum, $ps_search_expression, $po_rewritten_query, $pa_filters);
$vs_query = $o_query->getSearchExpression();
Debug::msg("[ElasticSearch] actual search query sent to ES: {$vs_query}");
$va_search_params = array('index' => $this->getIndexName(), 'type' => $this->opo_datamodel->getTableName($pn_subject_tablenum), 'body' => array('from' => 0, 'size' => 2147483647, 'query' => array('bool' => array('must' => array('query_string' => array('query' => $vs_query))))));
// apply additional filters that may have been set by the query
if (($va_additional_filters = $o_query->getAdditionalFilters()) && is_array($va_additional_filters) && sizeof($va_additional_filters) > 0) {
foreach ($va_additional_filters as $vs_filter_name => $va_filter) {
$va_search_params['body']['query']['bool']['filter'][$vs_filter_name] = $va_filter;
}
}
Debug::msg("[ElasticSearch] actual query filters are: " . print_r($va_additional_filters, true));
$va_results = $this->getClient()->search($va_search_params);
return new WLPlugSearchEngineElasticSearchResult($va_results['hits']['hits'], $pn_subject_tablenum);
}