当前位置: 首页>>代码示例>>PHP>>正文


PHP SearchResult::tableName方法代码示例

本文整理汇总了PHP中SearchResult::tableName方法的典型用法代码示例。如果您正苦于以下问题:PHP SearchResult::tableName方法的具体用法?PHP SearchResult::tableName怎么用?PHP SearchResult::tableName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SearchResult的用法示例。


在下文中一共展示了SearchResult::tableName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _getValues

 /**
  *
  */
 private static function _getValues(SearchResult $pr_res, array $pa_tags, array $pa_options = null)
 {
     unset($pa_options['returnAsArray']);
     unset($pa_options['returnWithStructure']);
     $vn_start = caGetOption('unitStart', $pa_options, 0, ['castTo' => 'int']);
     $vn_length = caGetOption('unitLength', $pa_options, 0, ['castTo' => 'int']);
     $o_dm = Datamodel::load();
     $pb_include_blanks = caGetOption('includeBlankValuesInArray', $pa_options, false);
     $ps_prefix = caGetOption(['placeholderPrefix', 'relativeTo', 'prefix'], $pa_options, null);
     $pn_index = caGetOption('index', $pa_options, null);
     $vs_cache_key = md5($pr_res->tableName() . "/" . $pr_res->getPrimaryKey() . "/" . print_r($pa_tags, true) . "/" . print_r($pa_options, true));
     $va_get_specs = [];
     foreach (array_keys($pa_tags) as $vs_tag) {
         // Apply placeholder prefix to any tag except the "specials"
         if (!in_array(strtolower($vs_tag), ['relationship_typename', 'relationship_type_id', 'relationship_typecode', 'relationship_type_code', 'date', 'primary', 'count', 'index', 'omitcount'])) {
             $va_tag = explode(".", $vs_tag);
             $vs_get_spec = $vs_tag;
             if ($ps_prefix && !$o_dm->tableExists($va_tag[0]) && !preg_match("!^" . preg_quote($ps_prefix, "!") . "\\.!", $vs_tag) && sizeof($va_tag) > 0) {
                 $vs_get_spec = "{$ps_prefix}." . array_shift($va_tag);
                 if (sizeof($va_tag) > 0) {
                     $vs_get_spec .= "." . join(".", $va_tag);
                 }
             }
         } else {
             $vs_get_spec = $vs_tag;
         }
         // Get trailing options (eg. ca_entities.preferred_labels.displayname%delimiter=;_)
         if (is_array($va_parsed_tag_opts = DisplayTemplateParser::_parseTagOpts($vs_get_spec))) {
             $vs_get_spec = $va_parsed_tag_opts['tag'];
         }
         $va_get_specs[$vs_tag] = ['spec' => $vs_get_spec, 'parsed' => $va_parsed_tag_opts];
     }
     $vn_count = 1;
     $va_tag_vals = null;
     if ($vs_relative_to_container = caGetOption('relativeToContainer', $pa_options, null)) {
         if (DisplayTemplateParser::$value_cache[$vs_cache_key]) {
             $va_tag_vals = DisplayTemplateParser::$value_cache[$vs_cache_key];
             $vn_count = DisplayTemplateParser::$value_count_cache[$vs_cache_key];
         } else {
             $va_tag_vals = [];
             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'];
                 $va_vals = $pr_res->get($vs_get_spec, array_merge($pa_options, $va_parsed_tag_opts['options'], ['returnAsArray' => true, 'returnBlankValues' => true]));
                 if (is_array($va_vals)) {
                     if (($vn_start > 0 || $vn_length > 0) && $vn_start < sizeof($va_vals) && (!$vn_length || $vn_start + $vn_length <= sizeof($va_vals))) {
                         $va_vals = array_slice($va_vals, $vn_start, $vn_length > 0 ? $vn_length : null);
                     }
                     foreach ($va_vals as $vn_index => $vs_val) {
                         $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':
//.........这里部分代码省略.........
开发者ID:samrahman,项目名称:providence,代码行数:101,代码来源:DisplayTemplateParser.php


注:本文中的SearchResult::tableName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。