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


PHP QuickSearchDefaults::loadQSObject方法代码示例

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


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

示例1: createQuickSearchCode

 /**
  * createQuickSearchCode
  * This function creates the $sqs_objects array that will be used by the quicksearch Javascript
  * code.  The $sqs_objects array is wrapped in a $json->encode call.
  *
  * @param $def The vardefs.php definitions
  * @param $defs2 The Meta-Data file definitions
  *
  */
 function createQuickSearchCode($defs, $defs2, $view = '', $module = '')
 {
     $sqs_objects = array();
     require_once 'include/QuickSearchDefaults.php';
     $qsd = new QuickSearchDefaults();
     $qsd->setFormName($view);
     if (preg_match('/^SearchForm_.+/', $view)) {
         if (strpos($view, 'popup_query_form')) {
             $qsd->setFormName('popup_query_form');
             $parsedView = 'advanced';
         } else {
             $qsd->setFormName('search_form');
             $parsedView = preg_replace("/^SearchForm_/", "", $view);
         }
         //Loop through the Meta-Data fields to see which ones need quick search support
         foreach ($defs as $f) {
             $field = $f;
             $name = $qsd->form_name . '_' . $field['name'];
             if ($field['type'] == 'relate' && isset($field['module']) && preg_match('/_name$|_c$/si', $name)) {
                 if (preg_match('/^(Campaigns|Teams|Users|Contacts|Accounts)$/si', $field['module'], $matches)) {
                     if ($matches[0] == 'Campaigns') {
                         $sqs_objects[$name . '_' . $parsedView] = $qsd->loadQSObject('Campaigns', 'Campaign', $field['name'], $field['id_name'], $field['id_name']);
                     } else {
                         if ($matches[0] == 'Users') {
                             if (!empty($f['name']) && !empty($f['id_name'])) {
                                 $sqs_objects[$name . '_' . $parsedView] = $qsd->getQSUser($f['name'], $f['id_name']);
                             } else {
                                 $sqs_objects[$name . '_' . $parsedView] = $qsd->getQSUser();
                             }
                         } else {
                             if ($matches[0] == 'Campaigns') {
                                 $sqs_objects[$name . '_' . $parsedView] = $qsd->loadQSObject('Campaigns', 'Campaign', $field['name'], $field['id_name'], $field['id_name']);
                             } else {
                                 if ($matches[0] == 'Accounts') {
                                     $nameKey = $name;
                                     $idKey = isset($field['id_name']) ? $field['id_name'] : 'account_id';
                                     //There are billingKey, shippingKey and additionalFields entries you can define in editviewdefs.php
                                     //entry to allow quick search to autocomplete fields with a suffix value of the
                                     //billing/shippingKey value (i.e. 'billingKey' => 'primary' in Contacts will populate
                                     //primary_XXX fields with the Account's billing address values).
                                     //addtionalFields are key/value pair of fields to fill from Accounts(key) to Contacts(value)
                                     $billingKey = isset($f['displayParams']['billingKey']) ? $f['displayParams']['billingKey'] : null;
                                     $shippingKey = isset($f['displayParams']['shippingKey']) ? $f['displayParams']['shippingKey'] : null;
                                     $additionalFields = isset($f['displayParams']['additionalFields']) ? $f['displayParams']['additionalFields'] : null;
                                     $sqs_objects[$name . '_' . $parsedView] = $qsd->getQSAccount($nameKey, $idKey, $billingKey, $shippingKey, $additionalFields);
                                 } else {
                                     if ($matches[0] == 'Contacts') {
                                         $sqs_objects[$name . '_' . $parsedView] = $qsd->getQSContact($field['name'], $field['id_name']);
                                     }
                                 }
                             }
                         }
                     }
                 } else {
                     $sqs_objects[$name . '_' . $parsedView] = $qsd->getQSParent($field['module']);
                     if (!isset($field['field_list']) && !isset($field['populate_list'])) {
                         $sqs_objects[$name . '_' . $parsedView]['populate_list'] = array($field['name'], $field['id_name']);
                         $sqs_objects[$name . '_' . $parsedView]['field_list'] = array('name', 'id');
                     } else {
                         $sqs_objects[$name . '_' . $parsedView]['populate_list'] = $field['field_list'];
                         $sqs_objects[$name . '_' . $parsedView]['field_list'] = $field['populate_list'];
                     }
                 }
             } else {
                 if ($field['type'] == 'parent') {
                     $sqs_objects[$name . '_' . $parsedView] = $qsd->getQSParent();
                 }
             }
             //if-else
         }
         //foreach
         foreach ($sqs_objects as $name => $field) {
             foreach ($field['populate_list'] as $key => $fieldname) {
                 $sqs_objects[$name]['populate_list'][$key] = $sqs_objects[$name]['populate_list'][$key] . '_' . $parsedView;
             }
         }
     } else {
         //Loop through the Meta-Data fields to see which ones need quick search support
         foreach ($defs2 as $f) {
             if (!isset($defs[$f['name']])) {
                 continue;
             }
             $field = $defs[$f['name']];
             if ($view == "ConvertLead") {
                 $field['name'] = $module . $field['name'];
                 if (!empty($field['id_name'])) {
                     $field['id_name'] = $field['name'] . "_" . $field['id_name'];
                 }
             }
             $name = $qsd->form_name . '_' . $field['name'];
             if ($field['type'] == 'relate' && isset($field['module']) && (preg_match('/_name$|_c$/si', $name) || !empty($field['quicksearch']))) {
//.........这里部分代码省略.........
开发者ID:netconstructor,项目名称:sugarcrm_dev,代码行数:101,代码来源:TemplateHandler.php


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