當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CRM_Core_SelectValues::boolean方法代碼示例

本文整理匯總了PHP中CRM_Core_SelectValues::boolean方法的典型用法代碼示例。如果您正苦於以下問題:PHP CRM_Core_SelectValues::boolean方法的具體用法?PHP CRM_Core_SelectValues::boolean怎麽用?PHP CRM_Core_SelectValues::boolean使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CRM_Core_SelectValues的用法示例。


在下文中一共展示了CRM_Core_SelectValues::boolean方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: 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

示例2: get

 /**
  * Low-level option getter, rarely accessed directly.
  * NOTE: Rather than calling this function directly use CRM_*_BAO_*::buildOptions()
  * @see http://wiki.civicrm.org/confluence/display/CRMDOC/Pseudoconstant+%28option+list%29+Reference
  *
  * @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|bool
  *   array on success, FALSE on error.
  *
  */
 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, FALSE, $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) : CRM_Core_SelectValues::boolean();
             }
         }
         CRM_Utils_Hook::customFieldOptions($customField->id, $options, FALSE);
         if ($options && $flip) {
             $options = array_flip($options);
         }
         $customField->free();
         return $options;
     }
     // Core field: load schema
     $dao = new $daoName();
     $fieldSpec = $dao->getFieldSpec($fieldName);
     $dao->free();
     // If neither worked then this field doesn't exist. Return false.
     if (empty($fieldSpec)) {
         return FALSE;
     } elseif (!empty($fieldSpec['pseudoconstant'])) {
         $pseudoconstant = $fieldSpec['pseudoconstant'];
         // if callback is specified..
         if (!empty($pseudoconstant['callback'])) {
             return call_user_func(Civi\Core\Resolver::singleton()->get($pseudoconstant['callback']));
         }
         // 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));
         if ($context == 'abbreviate') {
             switch ($fieldName) {
                 case 'state_province_id':
                     $params['labelColumn'] = 'abbreviation';
                     break;
                 case 'country_id':
                     $params['labelColumn'] = 'iso_code';
                     break;
                 default:
             }
         }
         // Fetch option group from option_value table
         if (!empty($pseudoconstant['optionGroupName'])) {
             if ($context == 'validate') {
                 $params['labelColumn'] = 'name';
             }
             if ($context == 'match') {
                 $params['keyColumn'] = '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'])) {
//.........這裏部分代碼省略.........
開發者ID:kidaa30,項目名稱:yes,代碼行數:101,代碼來源:PseudoConstant.php


注:本文中的CRM_Core_SelectValues::boolean方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。