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


PHP CRM_Utils_Hook::customFieldOptions方法代码示例

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


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

示例1:

 static function &valuesByID($customFieldID, $optionGroupID = NULL)
 {
     if (!$optionGroupID) {
         $optionGroupID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', $customFieldID, 'option_group_id');
     }
     $options = CRM_Core_OptionGroup::valuesByID($optionGroupID);
     CRM_Utils_Hook::customFieldOptions($customFieldID, $options, FALSE);
     return $options;
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:9,代码来源:CustomOption.php

示例2: get

 /**
  * Low-level option getter, rarely accessed directly.
  * NOTE: Rather than calling this function directly use CRM_*_BAO_*::buildOptions()
  *
  * @param String $daoName
  * @param String $fieldName
  * @param Array $params
  * - name       string  name of the option group
  * - flip       boolean results are return in id => label format if false
  *                            if true, the results are reversed
  * - grouping   boolean if true, return the value in 'grouping' column (currently unsupported for tables other than option_value)
  * - localize   boolean if true, localize the results before returning
  * - condition  string|array add condition(s) to the sql query - will be concatenated using 'AND'
  * - keyColumn  string the column to use for 'id'
  * - labelColumn string the column to use for 'label'
  * - orderColumn string the column to use for sorting, defaults to 'weight' column if one exists, else defaults to labelColumn
  * - onlyActive boolean return only the action option values
  * - fresh      boolean ignore cache entries and go back to DB
  * @param String $context: Context string
  *
  * @return Array on success, FALSE on error.
  *
  * @static
  */
 public static function get($daoName, $fieldName, $params = array(), $context = NULL)
 {
     CRM_Core_DAO::buildOptionsContext($context);
     $flip = !empty($params['flip']);
     // Merge params with defaults
     $params += array('grouping' => FALSE, 'localize' => FALSE, 'onlyActive' => $context == 'validate' || $context == 'get' ? FALSE : TRUE, 'fresh' => FALSE);
     // Custom fields are not in the schema
     if (strpos($fieldName, 'custom_') === 0 && is_numeric($fieldName[7])) {
         $customField = new CRM_Core_DAO_CustomField();
         $customField->id = (int) substr($fieldName, 7);
         $customField->find(TRUE);
         $options = FALSE;
         if (!empty($customField->option_group_id)) {
             $options = CRM_Core_OptionGroup::valuesByID($customField->option_group_id, $flip, $params['grouping'], $params['localize'], CRM_Utils_Array::value('labelColumn', $params, 'label'), $params['onlyActive'], $params['fresh']);
         } else {
             if ($customField->data_type === 'StateProvince') {
                 $options = self::stateProvince();
             } elseif ($customField->data_type === 'Country') {
                 $options = $context == 'validate' ? self::countryIsoCode() : self::country();
             } elseif ($customField->data_type === 'Boolean') {
                 $options = $context == 'validate' ? array(0, 1) : array(1 => ts('Yes'), 0 => ts('No'));
             }
             $options = $options && $flip ? array_flip($options) : $options;
         }
         if ($options !== FALSE) {
             CRM_Utils_Hook::customFieldOptions($customField->id, $options, FALSE);
         }
         $customField->free();
         return $options;
     }
     // Core field: load schema
     $dao = new $daoName();
     $fields = $dao->fields();
     $fieldKeys = $dao->fieldKeys();
     $dao->free();
     // Support "unique names" as well as sql names
     $fieldKey = $fieldName;
     if (empty($fields[$fieldKey])) {
         $fieldKey = CRM_Utils_Array::value($fieldName, $fieldKeys);
     }
     // If neither worked then this field doesn't exist. Return false.
     if (empty($fields[$fieldKey])) {
         return FALSE;
     }
     $fieldSpec = $fields[$fieldKey];
     // If the field is an enum, explode the enum definition and return the array.
     if (isset($fieldSpec['enumValues'])) {
         // use of a space after the comma is inconsistent in xml
         $enumStr = str_replace(', ', ',', $fieldSpec['enumValues']);
         $output = explode(',', $enumStr);
         return array_combine($output, $output);
     } elseif (!empty($fieldSpec['pseudoconstant'])) {
         $pseudoconstant = $fieldSpec['pseudoconstant'];
         // Merge params with schema defaults
         $params += array('condition' => CRM_Utils_Array::value('condition', $pseudoconstant, array()), 'keyColumn' => CRM_Utils_Array::value('keyColumn', $pseudoconstant), 'labelColumn' => CRM_Utils_Array::value('labelColumn', $pseudoconstant));
         // Fetch option group from option_value table
         if (!empty($pseudoconstant['optionGroupName'])) {
             if ($context == 'validate') {
                 $params['labelColumn'] = 'name';
             }
             // Call our generic fn for retrieving from the option_value table
             return CRM_Core_OptionGroup::values($pseudoconstant['optionGroupName'], $flip, $params['grouping'], $params['localize'], $params['condition'] ? ' AND ' . implode(' AND ', (array) $params['condition']) : NULL, $params['labelColumn'] ? $params['labelColumn'] : 'label', $params['onlyActive'], $params['fresh'], $params['keyColumn'] ? $params['keyColumn'] : 'value');
         }
         // Fetch options from other tables
         if (!empty($pseudoconstant['table'])) {
             // Normalize params so the serialized cache string will be consistent.
             CRM_Utils_Array::remove($params, 'flip', 'fresh');
             ksort($params);
             $cacheKey = $daoName . $fieldName . serialize($params);
             // Retrieve cached options
             if (isset(self::$cache[$cacheKey]) && empty($params['fresh'])) {
                 $output = self::$cache[$cacheKey];
             } else {
                 $daoName = CRM_Core_DAO_AllCoreTables::getClassForTable($pseudoconstant['table']);
                 if (!class_exists($daoName)) {
                     return FALSE;
//.........这里部分代码省略.........
开发者ID:TheCraftyCanvas,项目名称:aegir-platforms,代码行数:101,代码来源:PseudoConstant.php

示例3: buildOption

 static function buildOption($field, &$options)
 {
     $options['attributes'] = array('label' => $field['label'], 'data_type' => $field['data_type'], 'html_type' => $field['html_type']);
     $optionGroupID = null;
     if ($field['html_type'] == 'CheckBox' || $field['html_type'] == 'Radio' || $field['html_type'] == 'Select' || $field['html_type'] == 'AdvMulti-Select' || $field['html_type'] == 'Multi-Select' || $field['html_type'] == 'Autocomplete-Select' && $field['data_type'] != 'ContactReference') {
         if ($field['option_group_id']) {
             $optionGroupID = $field['option_group_id'];
         } else {
             if ($field['data_type'] != 'Boolean') {
                 CRM_Core_Error::fatal();
             }
         }
     }
     // build the cache for custom values with options (label => value)
     if ($optionGroupID != null) {
         $query = "\nSELECT label, value\n  FROM civicrm_option_value\n WHERE option_group_id = {$optionGroupID}\n";
         $dao =& CRM_Core_DAO::executeQuery($query);
         while ($dao->fetch()) {
             if ($field['data_type'] == 'Int' || $field['data_type'] == 'Float') {
                 $num = round($dao->value, 2);
                 $options["{$num}"] = $dao->label;
             } else {
                 $options[$dao->value] = $dao->label;
             }
         }
         require_once 'CRM/Utils/Hook.php';
         CRM_Utils_Hook::customFieldOptions($field['id'], $options);
     }
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:29,代码来源:CustomField.php

示例4: buildOption

 /**
  * @param $field
  * @param $options
  *
  * @throws Exception
  */
 public static function buildOption($field, &$options)
 {
     // Fixme - adding anything but options to the $options array is a bad idea
     // What if an option had the key 'attributes'?
     $options['attributes'] = array('label' => $field['label'], 'data_type' => $field['data_type'], 'html_type' => $field['html_type']);
     $optionGroupID = NULL;
     if ($field['html_type'] == 'CheckBox' || $field['html_type'] == 'Radio' || $field['html_type'] == 'Select' || $field['html_type'] == 'AdvMulti-Select' || $field['html_type'] == 'Multi-Select' || $field['html_type'] == 'Autocomplete-Select' && $field['data_type'] != 'ContactReference') {
         if ($field['option_group_id']) {
             $optionGroupID = $field['option_group_id'];
         } elseif ($field['data_type'] != 'Boolean') {
             CRM_Core_Error::fatal();
         }
     }
     // build the cache for custom values with options (label => value)
     if ($optionGroupID != NULL) {
         $query = "\nSELECT label, value\n  FROM civicrm_option_value\n WHERE option_group_id = {$optionGroupID}\n";
         $dao = CRM_Core_DAO::executeQuery($query);
         while ($dao->fetch()) {
             if ($field['data_type'] == 'Int' || $field['data_type'] == 'Float') {
                 $num = round($dao->value, 2);
                 $options["{$num}"] = $dao->label;
             } else {
                 $options[$dao->value] = $dao->label;
             }
         }
         CRM_Utils_Hook::customFieldOptions($field['id'], $options);
     }
 }
开发者ID:Hack4Eugene,项目名称:Hack4Cause2016,代码行数:34,代码来源:CustomField.php

示例5: __construct

 /**
  * Class constructor.
  *
  * Takes in a set of custom field ids andsets up the data structures to
  * generate a query
  *
  * @param array $ids
  *   The set of custom field ids.
  *
  * @param bool $contactSearch
  * @param array $locationSpecificFields
  */
 public function __construct($ids, $contactSearch = FALSE, $locationSpecificFields = array())
 {
     $this->_ids =& $ids;
     $this->_locationSpecificCustomFields = $locationSpecificFields;
     $this->_select = array();
     $this->_element = array();
     $this->_tables = array();
     $this->_whereTables = array();
     $this->_where = array();
     $this->_qill = array();
     $this->_options = array();
     $this->_fields = array();
     $this->_contactSearch = $contactSearch;
     if (empty($this->_ids)) {
         return;
     }
     // initialize the field array
     $tmpArray = array_keys($this->_ids);
     $idString = implode(',', $tmpArray);
     $query = "\nSELECT f.id, f.label, f.data_type,\n       f.html_type, f.is_search_range,\n       f.option_group_id, f.custom_group_id,\n       f.column_name, g.table_name,\n       f.date_format,f.time_format\n  FROM civicrm_custom_field f,\n       civicrm_custom_group g\n WHERE f.custom_group_id = g.id\n   AND g.is_active = 1\n   AND f.is_active = 1\n   AND f.id IN ( {$idString} )";
     $dao = CRM_Core_DAO::executeQuery($query);
     while ($dao->fetch()) {
         // get the group dao to figure which class this custom field extends
         $extends = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $dao->custom_group_id, 'extends');
         if (array_key_exists($extends, self::$extendsMap)) {
             $extendsTable = self::$extendsMap[$extends];
         } elseif (in_array($extends, CRM_Contact_BAO_ContactType::subTypes())) {
             // if $extends is a subtype, refer contact table
             $extendsTable = self::$extendsMap['Contact'];
         }
         $this->_fields[$dao->id] = array('id' => $dao->id, 'label' => $dao->label, 'extends' => $extendsTable, 'data_type' => $dao->data_type, 'html_type' => $dao->html_type, 'is_search_range' => $dao->is_search_range, 'column_name' => $dao->column_name, 'table_name' => $dao->table_name, 'option_group_id' => $dao->option_group_id);
         // store it in the options cache to make things easier
         // during option lookup
         $this->_options[$dao->id] = array();
         $this->_options[$dao->id]['attributes'] = array('label' => $dao->label, 'data_type' => $dao->data_type, 'html_type' => $dao->html_type);
         $optionGroupID = NULL;
         $htmlTypes = array('CheckBox', 'Radio', 'Select', 'Multi-Select', 'AdvMulti-Select', 'Autocomplete-Select');
         if (in_array($dao->html_type, $htmlTypes) && $dao->data_type != 'ContactReference') {
             if ($dao->option_group_id) {
                 $optionGroupID = $dao->option_group_id;
             } elseif ($dao->data_type != 'Boolean') {
                 $errorMessage = ts("The custom field %1 is corrupt. Please delete and re-build the field", array(1 => $dao->label));
                 CRM_Core_Error::fatal($errorMessage);
             }
         } elseif ($dao->html_type == 'Select Date') {
             $this->_options[$dao->id]['attributes']['date_format'] = $dao->date_format;
             $this->_options[$dao->id]['attributes']['time_format'] = $dao->time_format;
         }
         // build the cache for custom values with options (label => value)
         if ($optionGroupID != NULL) {
             $query = "\nSELECT label, value\n  FROM civicrm_option_value\n WHERE option_group_id = {$optionGroupID}\n";
             $option = CRM_Core_DAO::executeQuery($query);
             while ($option->fetch()) {
                 $dataType = $this->_fields[$dao->id]['data_type'];
                 if ($dataType == 'Int' || $dataType == 'Float') {
                     $num = round($option->value, 2);
                     $this->_options[$dao->id]["{$num}"] = $option->label;
                 } else {
                     $this->_options[$dao->id][$option->value] = $option->label;
                 }
             }
             $options = $this->_options[$dao->id];
             //unset attributes to avoid confussion
             unset($options['attributes']);
             CRM_Utils_Hook::customFieldOptions($dao->id, $options, FALSE);
         }
     }
 }
开发者ID:utkarshsharma,项目名称:civicrm-core,代码行数:80,代码来源:CustomQuery.php

示例6: formatCustomValues


//.........这里部分代码省略.........
         case 'String':
         case 'Int':
             if (in_array($htmlType, array('Text', 'TextArea'))) {
                 $retValue = $value;
                 break;
             }
         case 'StateProvince':
         case 'Country':
             //added check for Multi-Select in the below if-statement
             $customData[] = $value;
             //form custom data for multiple-valued custom data
             switch ($htmlType) {
                 case 'Multi-Select Country':
                 case 'Select Country':
                     $customData = $value;
                     if (!is_array($value)) {
                         $customData = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value);
                     }
                     $query = "\n                    SELECT id as value, name as label  \n                    FROM civicrm_country";
                     $coDAO = CRM_Core_DAO::executeQuery($query);
                     break;
                 case 'Select State/Province':
                 case 'Multi-Select State/Province':
                     $customData = $value;
                     if (!is_array($value)) {
                         $customData = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value);
                     }
                     $query = "\n                    SELECT id as value, name as label  \n                    FROM civicrm_state_province";
                     $coDAO = CRM_Core_DAO::executeQuery($query);
                     break;
                 case 'Select':
                     $customData = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value);
                     if ($option_group_id) {
                         $query = "\n                        SELECT label, value\n                        FROM civicrm_option_value\n                        WHERE option_group_id = %1\n                        ORDER BY weight ASC, label ASC";
                         $params = array(1 => array($option_group_id, 'Integer'));
                         $coDAO = CRM_Core_DAO::executeQuery($query, $params);
                     }
                     break;
                 case 'CheckBox':
                 case 'AdvMulti-Select':
                 case 'Multi-Select':
                     $customData = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value);
                 default:
                     if ($option_group_id) {
                         $query = "\n                        SELECT label, value\n                        FROM civicrm_option_value\n                        WHERE option_group_id = %1\n                        ORDER BY weight ASC, label ASC";
                         $params = array(1 => array($option_group_id, 'Integer'));
                         $coDAO = CRM_Core_DAO::executeQuery($query, $params);
                     }
             }
             $options = array();
             if (is_object($coDAO)) {
                 while ($coDAO->fetch()) {
                     $options[$coDAO->value] = $coDAO->label;
                 }
             } else {
                 CRM_Core_Error::fatal(ts('You have hit issue CRM-4716. Please post a report with as much detail as possible on the CiviCRM forums. You can truncate civicr_cache to get around this problem'));
             }
             require_once 'CRM/Utils/Hook.php';
             CRM_Utils_Hook::customFieldOptions($field['id'], $options, false);
             $retValue = null;
             foreach ($options as $optionValue => $optionLabel) {
                 //to show only values that are checked
                 if (in_array((string) $optionValue, $customData)) {
                     $checked = in_array($optionValue, $customData) ? $freezeStringChecked : $freezeString;
                     if (!$optionPerLine || $dncOptionPerLine) {
                         if ($retValue) {
                             $retValue .= ", ";
                         }
                         $retValue .= $checked . $optionLabel;
                     } else {
                         $retValue[] = $checked . $optionLabel;
                     }
                 }
             }
             break;
     }
     //special case for option per line formatting
     if ($optionPerLine > 1 && is_array($retValue)) {
         $rowCounter = 0;
         $fieldCounter = 0;
         $displayValues = array();
         $displayString = null;
         foreach ($retValue as $val) {
             if ($displayString) {
                 $displayString .= ", ";
             }
             $displayString .= $val;
             $rowCounter++;
             $fieldCounter++;
             if ($rowCounter == $optionPerLine || $fieldCounter == count($retValue)) {
                 $displayValues[] = $displayString;
                 $displayString = null;
                 $rowCounter = 0;
             }
         }
         $retValue = $displayValues;
     }
     $retValue = isset($retValue) ? $retValue : null;
     return $retValue;
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:101,代码来源:CustomGroup.php

示例7:

 static function &valuesByID($customFieldID, $optionGroupID = null)
 {
     if (!$optionGroupID) {
         $optionGroupID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', $customFieldID, 'option_group_id');
     }
     require_once 'CRM/Core/OptionGroup.php';
     $options =& CRM_Core_OptionGroup::valuesByID($optionGroupID);
     require_once 'CRM/Utils/Hook.php';
     CRM_Utils_Hook::customFieldOptions($customFieldID, $options, false);
     return $options;
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:11,代码来源:CustomOption.php

示例8: addCustomDataToColumns

 /**
  * Add custom data to the columns.
  *
  * @param bool $addFields
  * @param array $permCustomGroupIds
  */
 public function addCustomDataToColumns($addFields = TRUE, $permCustomGroupIds = array())
 {
     if (empty($this->_customGroupExtends)) {
         return;
     }
     if (!is_array($this->_customGroupExtends)) {
         $this->_customGroupExtends = array($this->_customGroupExtends);
     }
     $customGroupWhere = '';
     if (!empty($permCustomGroupIds)) {
         $customGroupWhere = "cg.id IN (" . implode(',', $permCustomGroupIds) . ") AND";
     }
     $sql = "\nSELECT cg.table_name, cg.title, cg.extends, cf.id as cf_id, cf.label,\n       cf.column_name, cf.data_type, cf.html_type, cf.option_group_id, cf.time_format\nFROM   civicrm_custom_group cg\nINNER  JOIN civicrm_custom_field cf ON cg.id = cf.custom_group_id\nWHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND\n      {$customGroupWhere}\n      cg.is_active = 1 AND\n      cf.is_active = 1 AND\n      cf.is_searchable = 1\nORDER BY cg.weight, cf.weight";
     $customDAO = CRM_Core_DAO::executeQuery($sql);
     $curTable = NULL;
     while ($customDAO->fetch()) {
         if ($customDAO->table_name != $curTable) {
             $curTable = $customDAO->table_name;
             $curFields = $curFilters = array();
             // dummy dao object
             $this->_columns[$curTable]['dao'] = 'CRM_Contact_DAO_Contact';
             $this->_columns[$curTable]['extends'] = $customDAO->extends;
             $this->_columns[$curTable]['grouping'] = $customDAO->table_name;
             $this->_columns[$curTable]['group_title'] = $customDAO->title;
             foreach (array('fields', 'filters', 'group_bys') as $colKey) {
                 if (!array_key_exists($colKey, $this->_columns[$curTable])) {
                     $this->_columns[$curTable][$colKey] = array();
                 }
             }
         }
         $fieldName = 'custom_' . $customDAO->cf_id;
         if ($addFields) {
             // this makes aliasing work in favor
             $curFields[$fieldName] = array('name' => $customDAO->column_name, 'title' => $customDAO->label, 'dataType' => $customDAO->data_type, 'htmlType' => $customDAO->html_type);
         }
         if ($this->_customGroupFilters) {
             // this makes aliasing work in favor
             $curFilters[$fieldName] = array('name' => $customDAO->column_name, 'title' => $customDAO->label, 'dataType' => $customDAO->data_type, 'htmlType' => $customDAO->html_type);
         }
         switch ($customDAO->data_type) {
             case 'Date':
                 // filters
                 $curFilters[$fieldName]['operatorType'] = CRM_Report_Form::OP_DATE;
                 $curFilters[$fieldName]['type'] = CRM_Utils_Type::T_DATE;
                 // CRM-6946, show time part for datetime date fields
                 if ($customDAO->time_format) {
                     $curFields[$fieldName]['type'] = CRM_Utils_Type::T_TIMESTAMP;
                 }
                 break;
             case 'Boolean':
                 $curFilters[$fieldName]['operatorType'] = CRM_Report_Form::OP_SELECT;
                 $curFilters[$fieldName]['options'] = array('' => ts('- select -'), 1 => ts('Yes'), 0 => ts('No'));
                 $curFilters[$fieldName]['type'] = CRM_Utils_Type::T_INT;
                 break;
             case 'Int':
                 $curFilters[$fieldName]['operatorType'] = CRM_Report_Form::OP_INT;
                 $curFilters[$fieldName]['type'] = CRM_Utils_Type::T_INT;
                 break;
             case 'Money':
                 $curFilters[$fieldName]['operatorType'] = CRM_Report_Form::OP_FLOAT;
                 $curFilters[$fieldName]['type'] = CRM_Utils_Type::T_MONEY;
                 break;
             case 'Float':
                 $curFilters[$fieldName]['operatorType'] = CRM_Report_Form::OP_FLOAT;
                 $curFilters[$fieldName]['type'] = CRM_Utils_Type::T_FLOAT;
                 break;
             case 'String':
                 $curFilters[$fieldName]['type'] = CRM_Utils_Type::T_STRING;
                 if (!empty($customDAO->option_group_id)) {
                     if (in_array($customDAO->html_type, array('Multi-Select', 'AdvMulti-Select', 'CheckBox'))) {
                         $curFilters[$fieldName]['operatorType'] = CRM_Report_Form::OP_MULTISELECT_SEPARATOR;
                     } else {
                         $curFilters[$fieldName]['operatorType'] = CRM_Report_Form::OP_MULTISELECT;
                     }
                     if ($this->_customGroupFilters) {
                         $curFilters[$fieldName]['options'] = array();
                         $ogDAO = CRM_Core_DAO::executeQuery("SELECT ov.value, ov.label FROM civicrm_option_value ov WHERE ov.option_group_id = %1 ORDER BY ov.weight", array(1 => array($customDAO->option_group_id, 'Integer')));
                         while ($ogDAO->fetch()) {
                             $curFilters[$fieldName]['options'][$ogDAO->value] = $ogDAO->label;
                         }
                         CRM_Utils_Hook::customFieldOptions($customDAO->cf_id, $curFilters[$fieldName]['options'], FALSE);
                     }
                 }
                 break;
             case 'StateProvince':
                 if (in_array($customDAO->html_type, array('Multi-Select State/Province'))) {
                     $curFilters[$fieldName]['operatorType'] = CRM_Report_Form::OP_MULTISELECT_SEPARATOR;
                 } else {
                     $curFilters[$fieldName]['operatorType'] = CRM_Report_Form::OP_MULTISELECT;
                 }
                 $curFilters[$fieldName]['options'] = CRM_Core_PseudoConstant::stateProvince();
                 break;
             case 'Country':
                 if (in_array($customDAO->html_type, array('Multi-Select Country'))) {
//.........这里部分代码省略.........
开发者ID:vincent1892,项目名称:contact_report,代码行数:101,代码来源:Form.php

示例9: getOptions

 /**
  * @param string $context
  * @return array|bool
  */
 public function getOptions($context = NULL)
 {
     CRM_Core_DAO::buildOptionsContext($context);
     if (!$this->id) {
         return FALSE;
     }
     if (!$this->data_type || !$this->custom_group_id) {
         $this->find(TRUE);
     }
     if (!empty($this->option_group_id)) {
         $options = CRM_Core_OptionGroup::valuesByID($this->option_group_id, FALSE, FALSE, FALSE, 'label', !($context == 'validate' || $context == 'get'));
     } elseif ($this->data_type === 'StateProvince') {
         $options = CRM_Core_Pseudoconstant::stateProvince();
     } elseif ($this->data_type === 'Country') {
         $options = $context == 'validate' ? CRM_Core_Pseudoconstant::countryIsoCode() : CRM_Core_Pseudoconstant::country();
     } elseif ($this->data_type === 'Boolean') {
         $options = $context == 'validate' ? array(0, 1) : CRM_Core_SelectValues::boolean();
     } else {
         return FALSE;
     }
     CRM_Utils_Hook::customFieldOptions($this->id, $options, FALSE);
     CRM_Utils_Hook::fieldOptions($this->getEntity(), "custom_{$this->id}", $options, array('context' => $context));
     return $options;
 }
开发者ID:saurabhbatra96,项目名称:civicrm-core,代码行数:28,代码来源:CustomField.php

示例10: formatCustomValues


//.........这里部分代码省略.........
         case 'Country':
             $options = array();
             $coDAO = NULL;
             //added check for Multi-Select in the below if-statement
             $customData[] = $value;
             //form custom data for multiple-valued custom data
             switch ($htmlType) {
                 case 'Multi-Select Country':
                 case 'Select Country':
                     $customData = $value;
                     if (!is_array($value)) {
                         $customData = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value);
                     }
                     $query = "\n                    SELECT id as value, name as label\n                    FROM civicrm_country";
                     $coDAO = CRM_Core_DAO::executeQuery($query);
                     break;
                 case 'Select State/Province':
                 case 'Multi-Select State/Province':
                     $customData = $value;
                     if (!is_array($value)) {
                         $customData = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value);
                     }
                     $query = "\n                    SELECT id as value, name as label\n                    FROM civicrm_state_province";
                     $coDAO = CRM_Core_DAO::executeQuery($query);
                     break;
                 case 'Select':
                     $customData = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value);
                     if ($option_group_id) {
                         $options = CRM_Core_BAO_OptionValue::getOptionValuesAssocArray($option_group_id);
                     }
                     break;
                 case 'CheckBox':
                 case 'AdvMulti-Select':
                 case 'Multi-Select':
                     $customData = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value);
                 default:
                     if ($option_group_id) {
                         $options = CRM_Core_BAO_OptionValue::getOptionValuesAssocArray($option_group_id);
                     }
             }
             if (is_object($coDAO)) {
                 while ($coDAO->fetch()) {
                     if ($dataType == 'Country') {
                         // NB: using ts() on a variable here is OK, since the value is pre-determined, not variable
                         // and already extracted to .pot files.
                         $options[$coDAO->value] = ts($coDAO->label, array('context' => 'country'));
                     } elseif ($dataType == 'StateProvince') {
                         $options[$coDAO->value] = ts($coDAO->label, array('context' => 'province'));
                     } else {
                         $options[$coDAO->value] = $coDAO->label;
                     }
                 }
             }
             CRM_Utils_Hook::customFieldOptions($field['id'], $options, FALSE);
             $retValue = NULL;
             foreach ($options as $optionValue => $optionLabel) {
                 if ($dataType == 'Money') {
                     foreach ($customData as $k => $v) {
                         $customData[] = CRM_Utils_Money::format($v, NULL, '%a');
                     }
                 }
                 //to show only values that are checked
                 if (in_array((string) $optionValue, $customData)) {
                     $checked = in_array($optionValue, $customData) ? $freezeStringChecked : $freezeString;
                     if (!$optionPerLine || $dncOptionPerLine) {
                         if ($retValue) {
                             $retValue .= ", ";
                         }
                         $retValue .= $checked . $optionLabel;
                     } else {
                         $retValue[] = $checked . $optionLabel;
                     }
                 }
             }
             break;
     }
     //special case for option per line formatting
     if ($optionPerLine > 1 && is_array($retValue)) {
         $rowCounter = 0;
         $fieldCounter = 0;
         $displayValues = array();
         $displayString = '';
         foreach ($retValue as $val) {
             if ($displayString) {
                 $displayString .= ", ";
             }
             $displayString .= $val;
             $rowCounter++;
             $fieldCounter++;
             if ($rowCounter == $optionPerLine || $fieldCounter == count($retValue)) {
                 $displayValues[] = $displayString;
                 $displayString = '';
                 $rowCounter = 0;
             }
         }
         $retValue = $displayValues;
     }
     $retValue = isset($retValue) ? $retValue : NULL;
     return $retValue;
 }
开发者ID:hguru,项目名称:224Civi,代码行数:101,代码来源:CustomGroup.php


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