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


PHP UnifiedSearchAdvanced::getUnifiedSearchModules方法代码示例

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


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

示例1: globalSearchSpot

 /**
  * This function is used to hand off the global search to the built-in SugarSearchEngine (aka SugarSpot)
  * @param $api ServiceBase The API class of the request
  * @param $args array The arguments array passed in from the API
  * @param $searchEngine SugarSearchEngine The SugarSpot search engine created using the Factory in the caller
  * @param $options array An array of options to pass through to the search engine, they get translated to the $searchOptions array so you can see exactly what gets passed through
  * @return array Two elements, 'records' the list of returned records formatted through FormatBean, and 'next_offset' which will indicate to the user if there are additional records to be returned.
  */
 public function globalSearchSpot(ServiceBase $api, array $args, $searchEngine, array $options)
 {
     require_once 'modules/Home/UnifiedSearchAdvanced.php';
     $searchOptions = array('modules' => $options['moduleList'], 'current_module' => $options['primaryModule'], 'return_beans' => true, 'my_items' => $options['my_items'], 'favorites' => $options['favorites'], 'orderBy' => $options['orderBy'], 'fields' => $options['fieldFilters'], 'selectFields' => $options['selectFields'], 'limitPerModule' => $options['limitPerModule'], 'allowEmptySearch' => true, 'distinct' => 'DISTINCT', 'return_beans' => true);
     if (isset($options['deleted'])) {
         $searchOptions['deleted'] = $options['deleted'];
     }
     $multiModule = false;
     if (empty($options['moduleList']) || count($options['moduleList']) == 0 || count($options['moduleList']) > 1) {
         $multiModule = true;
     }
     if (empty($options['moduleList'])) {
         require_once 'modules/ACL/ACLController.php';
         $usa = new UnifiedSearchAdvanced();
         $moduleList = $usa->getUnifiedSearchModules();
         // get the module names [array keys]
         $moduleList = array_keys($moduleList);
         // filter based on User Access if Blank
         $ACL = new ACLController();
         // moduleList is passed by reference
         $ACL->filterModuleList($moduleList);
         $searchOptions['modules'] = $options['moduleList'] = $moduleList;
     }
     if (!empty($options['searchFields'])) {
         $customWhere = array();
         foreach ($options['moduleList'] as $module) {
             $seed = BeanFactory::getBean($module);
             $fields = array_keys($seed->field_defs);
             $existingfields = array_intersect($fields, $options['searchFields']);
             if (!empty($existingfields)) {
                 $customTable = $seed->get_custom_table_name();
                 $table = $seed->table_name;
                 foreach ($existingfields as $field) {
                     if (!isset($seed->field_defs[$field]['unified_search']) || $seed->field_defs[$field]['unified_search'] !== true) {
                         continue;
                     }
                     $prefix = $table;
                     if (isset($GLOBALS['dictionary'][$seed->object_name]['custom_fields'][$field])) {
                         $prefix = $customTable;
                     }
                     if (!isset($seed->field_defs[$field]['source']) || $seed->field_defs[$field]['source'] != 'non-db') {
                         $customWhere[$module][] = "{$prefix}.{$field} LIKE '{$options['query']}%'";
                     }
                 }
                 if (isset($customWhere[$module])) {
                     $searchOptions['custom_where_module'][$module] = '(' . implode(' OR ', $customWhere[$module]) . ')';
                 }
             }
         }
     }
     $offset = $options['offset'];
     // One for luck.
     // Well, actually it's so that we know that there are additional results
     $limit = $options['limit'] + 1;
     if ($multiModule && $options['offset'] != 0) {
         // With more than one module, there is no way to do offsets for real, so we have to fake it.
         $limit = $limit + $offset;
         $offset = 0;
     }
     if (!$multiModule) {
         // It's not multi-module, the per-module limit should be the same as the master limit
         $searchOptions['limitPerModule'] = $limit;
     }
     if (isset($options['custom_select'])) {
         $searchOptions['custom_select'] = $options['custom_select'];
     }
     if (isset($options['custom_from'])) {
         $searchOptions['custom_from'] = $options['custom_from'];
     }
     if (isset($options['custom_where'])) {
         $searchOptions['custom_where'] = $options['custom_where'];
     }
     $results = $searchEngine->search($options['query'], $offset, $limit, $searchOptions);
     $returnedRecords = array();
     $api->action = 'list';
     foreach ($results as $module => $moduleResults) {
         if (!is_array($moduleResults['data'])) {
             continue;
         }
         $moduleArgs = $args;
         // Need to override the filter arg so that it looks like something formatBean expects
         if (!empty($options['fieldFilters'][$module])) {
             $moduleFields = $options['fieldFilters'][$module];
         } else {
             if (!empty($options['fieldFilters']['_default'])) {
                 $moduleFields = $options['fieldFilters']['_default'];
             } else {
                 $moduleFields = array();
             }
         }
         $moduleArgs['fields'] = implode(',', $moduleFields);
         foreach ($moduleResults['data'] as $record) {
//.........这里部分代码省略.........
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:101,代码来源:UnifiedSearchApi.php


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