本文整理汇总了PHP中CRM_Core_BAO_CustomField::dataToHtml方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_CustomField::dataToHtml方法的具体用法?PHP CRM_Core_BAO_CustomField::dataToHtml怎么用?PHP CRM_Core_BAO_CustomField::dataToHtml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_BAO_CustomField
的用法示例。
在下文中一共展示了CRM_Core_BAO_CustomField::dataToHtml方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCreateCustomValue
public function testCreateCustomValue()
{
$this->_populateOptionAndCustomGroup();
$customFieldDataType = CRM_Core_BAO_CustomField::dataType();
$dataToHtmlTypes = CRM_Core_BAO_CustomField::dataToHtml();
$count = 0;
foreach ($customFieldDataType as $dataType => $label) {
switch ($dataType) {
case 'Country':
case 'StateProvince':
$this->foreignKeyChecksOff();
case 'String':
case 'Link':
case 'Int':
case 'Float':
case 'Money':
case 'Date':
case 'Boolean':
//Based on the custom field data-type choose desired SQL operators(to test with) and basic $type
if (in_array($dataType, array('String', 'Link'))) {
$validSQLOperators = array('=', '!=', 'IN', 'NOT IN', 'LIKE', 'NOT LIKE', 'IS NOT NULL', 'IS NULL');
$type = 'string';
} elseif ($dataType == 'Boolean') {
$validSQLOperators = array('=', '!=', 'IS NOT NULL', 'IS NULL');
$type = 'boolean';
} else {
if ($dataType == 'Country') {
$type = 'country';
} elseif ($dataType == 'StateProvince') {
$type = 'state_province';
} elseif ($dataType == 'ContactReference') {
$type = 'contact';
} elseif ($dataType == 'Date') {
$type = 'date';
} else {
$type = $dataType == 'Int' ? 'integer' : 'number';
}
$validSQLOperators = array('=', '!=', 'IN', 'NOT IN', '<=', '>=', '>', '<', 'IS NOT NULL', 'IS NULL');
}
//Create custom field of $dataType and html-type $html
foreach ($dataToHtmlTypes[$count] as $html) {
$params = array('custom_group_id' => $this->ids[$type]['custom_group_id'], 'label' => "{$dataType} - {$html}", 'data_type' => $dataType, 'html_type' => $html, 'default_value' => NULL);
if (!in_array($html, array('Text', 'TextArea')) && !in_array($dataType, array('Link', 'Date', 'ContactReference', 'Boolean'))) {
$params += array('option_group_id' => $this->optionGroup[$type]['id']);
}
$customField = $this->customFieldCreate($params);
//Now test with $validSQLOperator SQL operators against its custom value(s)
$this->_testCustomValue($customField['values'][$customField['id']], $validSQLOperators, $type);
}
$count++;
break;
default:
// skipping File data-type
$count++;
break;
}
}
}
示例2: testCreateCustomValue
public function testCreateCustomValue()
{
$customFieldDataType = CRM_Core_BAO_CustomField::dataType();
$dataToHtmlTypes = CRM_Core_BAO_CustomField::dataToHtml();
$count = 0;
foreach ($customFieldDataType as $dataType => $label) {
switch ($dataType) {
case 'Date':
case 'StateProvince':
case 'String':
case 'Link':
case 'Int':
case 'Float':
case 'Money':
if (in_array($dataType, array('String', 'Link'))) {
$validSQLOperator = array('=', '!=', 'IN', 'NOT IN', 'LIKE', 'NOT LIKE', 'IS NOT NULL', 'IS NULL');
$type = 'string';
} else {
if ($dataType == 'Country') {
$type == 'country';
} elseif ($dataType == 'StateProvince') {
$type = 'state_province';
} elseif ($dataType == 'ContactReference') {
$type = 'contact';
} elseif ($dataType == 'Date') {
$type = 'date';
} else {
$type = $dataType == 'Int' ? 'integer' : 'number';
}
$validSQLOperator = array('=', '!=', 'IN', 'NOT IN', '<=', '>=', '>', '<', 'IS NOT NULL', 'IS NULL');
}
foreach ($dataToHtmlTypes[$count] as $html) {
$params = array('custom_group_id' => $this->ids[$type]['custom_group_id'], 'label' => "{$dataType} - {$html}", 'data_type' => $dataType, 'html_type' => $html, 'default_value' => NULL);
if (!in_array($html, array('Text', 'TextArea')) && !in_array($dataType, array('Link', 'Date', 'ContactReference'))) {
$params += array('option_group_id' => $this->optionGroup[$type]['id']);
}
$customField = $this->customFieldCreate($params);
$this->_testCustomValue($customField['values'][$customField['id']], $validSQLOperator, $type);
}
$count++;
break;
default:
//TODO: Test case of Country fields remain as it throws foreign key contraint ONLY in test environment
$count++;
break;
}
}
}
示例3: preProcess
/**
* Function to set variables up before form is built
*
* @param null
*
* @return void
* @access public
*/
public function preProcess()
{
if (!self::$_dataTypeKeys) {
self::$_dataTypeKeys = array_keys(CRM_Core_BAO_CustomField::dataType());
self::$_dataTypeValues = array_values(CRM_Core_BAO_CustomField::dataType());
}
if (!self::$_dataToHTML) {
self::$_dataToHTML = CRM_Core_BAO_CustomField::dataToHtml();
}
//custom group id
$this->_gid = CRM_Utils_Request::retrieve('gid', 'Positive', $this);
if ($isReserved = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $this->_gid, 'is_reserved', 'id')) {
CRM_Core_Error::fatal("You cannot add or edit fields in a reserved custom field-set.");
}
if ($this->_gid) {
$url = CRM_Utils_System::url('civicrm/admin/custom/group/field', "reset=1&action=browse&gid={$this->_gid}");
$session = CRM_Core_Session::singleton();
$session->pushUserContext($url);
}
//custom field id
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
//get the values form db if update.
$this->_values = array();
if ($this->_id) {
$params = array('id' => $this->_id);
CRM_Core_BAO_CustomField::retrieve($params, $this->_values);
// note_length is an alias for the text_length field
$this->_values['note_length'] = CRM_Utils_Array::value('text_length', $this->_values);
}
if (self::$_dataToLabels == NULL) {
self::$_dataToLabels = array(array('Text' => ts('Text'), 'Select' => ts('Select'), 'Radio' => ts('Radio'), 'CheckBox' => ts('CheckBox'), 'Multi-Select' => ts('Multi-Select'), 'AdvMulti-Select' => ts('Advanced Multi-Select'), 'Autocomplete-Select' => ts('Autocomplete Select')), array('Text' => ts('Text'), 'Select' => ts('Select'), 'Radio' => ts('Radio')), array('Text' => ts('Text'), 'Select' => ts('Select'), 'Radio' => ts('Radio')), array('Text' => ts('Text'), 'Select' => ts('Select'), 'Radio' => ts('Radio')), array('TextArea' => ts('TextArea'), 'RichTextEditor' => 'RichTextEditor'), array('Date' => ts('Select Date')), array('Radio' => ts('Radio')), array('StateProvince' => ts('Select State/Province'), 'Multi-Select' => ts('Multi-Select State/Province')), array('Country' => ts('Select Country'), 'Multi-Select' => ts('Multi-Select Country ')), array('File' => ts('Select File')), array('Link' => ts('Link')), array('ContactReference' => ts('Autocomplete Select')));
}
}
示例4: testCustomFieldCreateAllAvailableFormInputs
/**
* Check for Each data type: loop through available form input types
*/
public function testCustomFieldCreateAllAvailableFormInputs()
{
$gid = $this->customGroupCreate(array('extends' => 'Individual', 'title' => 'testAllFormInputs'));
$dtype = CRM_Core_BAO_CustomField::dataType();
$htype = CRM_Core_BAO_CustomField::dataToHtml();
$n = 0;
foreach ($dtype as $dkey => $dvalue) {
foreach ($htype[$n] as $hkey => $hvalue) {
//echo $dkey."][".$hvalue."\n";
$this->_loopingCustomFieldCreateTest($this->_buildParams($gid['id'], $hvalue, $dkey));
}
$n++;
}
}
示例5: testCreateCustomValue
public function testCreateCustomValue()
{
$this->_populateOptionAndCustomGroup();
$customFieldDataType = CRM_Core_BAO_CustomField::dataType();
$dataToHtmlTypes = CRM_Core_BAO_CustomField::dataToHtml();
$count = 0;
$optionSupportingHTMLTypes = array('Select', 'Radio', 'CheckBox', 'AdvMulti-Select', 'Autocomplete-Select', 'Multi-Select');
foreach ($customFieldDataType as $dataType => $label) {
switch ($dataType) {
// case 'Country':
// case 'StateProvince':
case 'String':
case 'Link':
case 'Int':
case 'Float':
case 'Money':
case 'Date':
case 'Boolean':
//Based on the custom field data-type choose desired SQL operators(to test with) and basic $type
if (in_array($dataType, array('String', 'Link'))) {
$validSQLOperators = array('=', '!=', 'IN', 'NOT IN', 'LIKE', 'NOT LIKE', 'IS NOT NULL', 'IS NULL');
$type = 'string';
} elseif ($dataType == 'Boolean') {
$validSQLOperators = array('=', '!=', 'IS NOT NULL', 'IS NULL');
$type = 'boolean';
} else {
if ($dataType == 'Country') {
$type = 'country';
} elseif ($dataType == 'StateProvince') {
$type = 'state_province';
} elseif ($dataType == 'ContactReference') {
$type = 'contact';
} elseif ($dataType == 'Date') {
$type = 'date';
} else {
$type = $dataType == 'Int' ? 'integer' : 'number';
}
$validSQLOperators = array('=', '!=', 'IN', 'NOT IN', '<=', '>=', '>', '<', 'IS NOT NULL', 'IS NULL');
}
//Create custom field of $dataType and html-type $html
foreach ($dataToHtmlTypes[$count] as $html) {
// per CRM-18568 the like operator does not currently work for fields with options.
// the LIKE operator could potentially bypass ACLs (as could IS NOT NULL) and some thought needs to be given
// to it.
if (in_array($html, $optionSupportingHTMLTypes)) {
$validSQLOperators = array_diff($validSQLOperators, array('LIKE', 'NOT LIKE'));
}
$params = array('custom_group_id' => $this->ids[$type]['custom_group_id'], 'label' => "{$dataType} - {$html}", 'data_type' => $dataType, 'html_type' => $html, 'default_value' => NULL);
if (!in_array($html, array('Text', 'TextArea')) && !in_array($dataType, array('Link', 'Date', 'ContactReference', 'Boolean'))) {
$params += array('option_group_id' => $this->optionGroup[$type]['id']);
}
$customField = $this->customFieldCreate($params);
//Now test with $validSQLOperator SQL operators against its custom value(s)
$this->_testCustomValue($customField['values'][$customField['id']], $validSQLOperators, $type);
}
$count++;
break;
default:
// skipping File data-type & state province due to caching issues
$count++;
break;
}
}
}