本文整理汇总了PHP中SearchResult::currentIndex方法的典型用法代码示例。如果您正苦于以下问题:PHP SearchResult::currentIndex方法的具体用法?PHP SearchResult::currentIndex怎么用?PHP SearchResult::currentIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SearchResult
的用法示例。
在下文中一共展示了SearchResult::currentIndex方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _getValues
//.........这里部分代码省略.........
$va_tag_vals[$vn_index][$vs_tag] = $vs_val;
}
}
}
if (isset($pa_options['sort']) && is_array($pa_options['sort']) && sizeof($pa_options['sort'])) {
$va_sortables = array();
foreach ($pa_options['sort'] as $vs_sort_spec) {
$va_sortables[] = $pr_res->get($vs_sort_spec, ['sortable' => true, 'returnAsArray' => true, 'returnBlankValues' => true]);
}
if (($vn_start > 0 || $vn_length > 0) && $vn_start < sizeof($va_sortables) && (!$vn_length || $vn_start + $vn_length <= sizeof($va_sortables))) {
$va_sortables = array_slice($va_sortables, $vn_start, $vn_length > 0 ? $vn_length : null);
}
if (is_array($va_sortables)) {
foreach ($va_sortables as $i => $va_sort_values) {
if (!is_array($va_sort_values)) {
continue;
}
foreach ($va_sort_values as $vn_index => $vs_sort_value) {
$va_tag_vals[$vn_index]['__sort__'] .= $vs_sort_value;
}
}
}
}
DisplayTemplateParser::$value_cache[$vs_cache_key] = $va_tag_vals;
DisplayTemplateParser::$value_count_cache[$vs_cache_key] = $vn_count = sizeof($va_tag_vals);
}
if (strlen($pn_index)) {
$va_tag_vals = $va_tag_vals[$pn_index];
$vs_relative_to_container = null;
}
}
$va_vals = [];
for ($vn_c = 0; $vn_c < $vn_count; $vn_c++) {
foreach (array_keys($pa_tags) as $vs_tag) {
$vs_get_spec = $va_get_specs[$vs_tag]['spec'];
$va_parsed_tag_opts = $va_get_specs[$vs_tag]['parsed'];
switch (strtolower($vs_get_spec)) {
case 'relationship_typename':
$va_val_list = $pr_res->get('ca_relationship_types.preferred_labels.' . (caGetOption('orientation', $pa_options, 'LTOR') == 'LTOR' ? 'typename' : 'typename_reverse'), $va_opts = array_merge($pa_options, $va_parsed_tag_opts['options'], ['returnAsArray' => true, 'returnWithStructure' => false]));
break;
case 'relationship_type_id':
$va_val_list = $pr_res->get('ca_relationship_types.type_id', $va_opts = array_merge($pa_options, $va_parsed_tag_opts['options'], ['returnAsArray' => true, 'returnWithStructure' => false]));
break;
case 'relationship_typecode':
case 'relationship_type_code':
$va_val_list = $pr_res->get('ca_relationship_types.type_code', $va_opts = array_merge($pa_options, $va_parsed_tag_opts['options'], ['returnAsArray' => true, 'returnWithStructure' => false]));
break;
case 'date':
// allows embedding of current date
$va_val_list = [date(caGetOption('format', $va_parsed_tag_opts['options'], 'd M Y'))];
break;
case 'primary':
$va_val_list = [$pr_res->tableName()];
break;
case 'count':
$va_val_list = [$pr_res->numHits()];
break;
case 'omitcount':
$va_val_list = [(int) $pr_res->numHits() - ($vn_length - $vn_start)];
break;
case 'index':
$va_val_list = [$pr_res->currentIndex() + 1];
break;
default:
if (isset($pa_options['forceValues'][$vs_get_spec][$pr_res->getPrimaryKey()])) {
$va_val_list = [$pa_options['forceValues'][$vs_get_spec][$pr_res->getPrimaryKey()]];
} elseif ($vs_relative_to_container) {
$va_val_list = [$va_tag_vals[$vn_c][$vs_tag]];
} elseif (strlen($pn_index)) {
$va_val_list = [$va_tag_vals[$vs_tag]];
} else {
$va_val_list = $pr_res->get($vs_get_spec, $va_opts = array_merge($pa_options, $va_parsed_tag_opts['options'], ['returnAsArray' => true, 'returnWithStructure' => false]));
if (!is_array($va_val_list)) {
$va_val_list = array();
}
if (($vn_start > 0 || $vn_length > 0) && $vn_start < sizeof($va_val_list) && (!$vn_length || $vn_start + $vn_length <= sizeof($va_val_list))) {
$va_val_list = array_slice($va_val_list, $vn_start, $vn_length > 0 ? $vn_length : null);
}
}
break;
}
$ps_delimiter = caGetOption('delimiter', $va_opts, ';');
if ($vs_relative_to_container) {
$va_vals[$vn_c][$vs_tag] = join($ps_delimiter, $va_val_list);
if (isset($va_tag_vals[$vn_c]['__sort__'])) {
$va_vals[$vn_c]['__sort__'] = $va_tag_vals[$vn_c]['__sort__'];
}
} else {
if (!$pb_include_blanks) {
$va_val_list = array_filter($va_val_list, 'strlen');
}
$va_vals[$vs_tag] = join($ps_delimiter, $va_val_list);
if (isset($va_tag_vals[$vn_c]['__sort__'])) {
$va_vals['__sort__'] = $va_tag_vals[$vn_c]['__sort__'];
}
}
}
}
return $va_vals;
}
示例2: canHandle
/**
* Determines if there is any data in the data set that can be visualized by this plugin using the provided settings
*
* @param SearchResult $po_data
* @param array $pa_viz_settings Visualization settings
*
* @return bool True if data can be visualized
*/
public function canHandle($po_data, $pa_viz_settings)
{
$vn_cur_pos = $po_data->currentIndex();
if ($vn_cur_pos < 0) {
$vn_cur_pos = 0;
}
$po_data->seek(0);
$o_dm = Datamodel::load();
//
// Make sure sources actually exist
//
$va_sources = $pa_viz_settings['sources'];
foreach ($va_sources as $vs_source_code => $va_source_info) {
$va_tmp = explode('.', $va_source_info['data']);
$t_instance = $o_dm->getInstanceByTableName($va_tmp[0], true);
if (!($t_instance = $o_dm->getInstanceByTableName($va_tmp[0], true))) {
unset($va_sources[$vs_source_code]);
continue;
}
if (!$t_instance->hasField($va_tmp[1]) && !$t_instance->hasElement($va_tmp[1])) {
unset($va_sources[$vs_source_code]);
}
}
$vn_c = 0;
//
// Only check the first 10,000 returned rows before giving up, to avoid timeouts
//
while ($po_data->nextHit() && $vn_c < 10000) {
foreach ($va_sources as $vs_source_code => $va_source_info) {
if (trim($po_data->get($va_source_info['data']))) {
$po_data->seek($vn_cur_pos);
return true;
}
}
$vn_c++;
}
$po_data->seek($vn_cur_pos);
return false;
}
示例3: canHandle
/**
* Determines if there is any data in the data set that can be visualized by this plugin using the provided settings
*
* @param SearchResult $po_data
* @param array $pa_viz_settings Visualization settings
*
* @return bool True if data can be visualized
*/
public function canHandle($po_data, $pa_viz_settings)
{
$vn_cur_pos = $po_data->currentIndex();
if ($vn_cur_pos < 0) {
$vn_cur_pos = 0;
}
$po_data->seek(0);
$va_sources = $pa_viz_settings['sources'];
while ($po_data->nextHit()) {
foreach ($va_sources as $vs_source_code => $va_source_info) {
if (trim($po_data->get($va_source_info['data']))) {
$po_data->seek($vn_cur_pos);
return true;
}
}
}
$po_data->seek($vn_cur_pos);
return false;
}