+--------------------------------------------------------------------+
| CiviCRM version 5 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2018 |
+ | Copyright CiviCRM LLC (c) 2004-2019 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2018
+ * @copyright CiviCRM LLC (c) 2004-2019
* $Id$
*
*/
/**
* Array of custom field values
+ * @var array
*/
protected $_values;
/**
* Mapper array of valid field type
+ * @var array
*/
protected $_htmlTypeTransitions;
$this, TRUE
);
- $this->_values = array();
- $params = array('id' => $this->_id);
+ $this->_values = [];
+ $params = ['id' => $this->_id];
CRM_Core_BAO_CustomField::retrieve($params, $this->_values);
$this->_htmlTypeTransitions = self::fieldTypeTransitions(CRM_Utils_Array::value('data_type', $this->_values),
$session->pushUserContext($url);
CRM_Utils_System::setTitle(ts('Change Field Type: %1',
- array(1 => $this->_values['label'])
+ [1 => $this->_values['label']]
));
}
$srcHtmlType = $this->add('select',
'src_html_type',
ts('Current HTML Type'),
- array($this->_values['html_type'] => $this->_values['html_type']),
+ [$this->_values['html_type'] => $this->_values['html_type']],
TRUE
);
$dstHtmlType = $this->add('select',
'dst_html_type',
ts('New HTML Type'),
- array(
+ [
'' => ts('- select -'),
- ) + $this->_htmlTypeTransitions,
+ ] + $this->_htmlTypeTransitions,
TRUE
);
- $this->addButtons(array(
- array(
- 'type' => 'next',
- 'name' => ts('Change Field Type'),
- 'isDefault' => TRUE,
- 'js' => array('onclick' => 'return checkCustomDataField();'),
- ),
- array(
- 'type' => 'cancel',
- 'name' => ts('Cancel'),
- ),
- )
- );
+ $this->addButtons([
+ [
+ 'type' => 'next',
+ 'name' => ts('Change Field Type'),
+ 'isDefault' => TRUE,
+ 'js' => ['onclick' => 'return checkCustomDataField();'],
+ ],
+ [
+ 'type' => 'cancel',
+ 'name' => ts('Cancel'),
+ ],
+ ]);
}
/**
'table_name'
);
- $singleValueOps = array(
+ $singleValueOps = [
'Text',
'Select',
'Radio',
'Autocomplete-Select',
- );
+ ];
- $mutliValueOps = array(
+ $mutliValueOps = [
'CheckBox',
'Multi-Select',
- );
+ ];
$srcHtmlType = $this->_values['html_type'];
$dstHtmlType = $params['dst_html_type'];
$customField->id = $this->_id;
$customField->find(TRUE);
- if ($dstHtmlType == 'Text' && in_array($srcHtmlType, array(
- 'Select',
- 'Radio',
- 'Autocomplete-Select',
- ))
- ) {
+ if ($dstHtmlType == 'Text' && in_array($srcHtmlType, [
+ 'Select',
+ 'Radio',
+ 'Autocomplete-Select',
+ ])) {
$customField->option_group_id = "NULL";
CRM_Core_BAO_CustomField::checkOptionGroup($this->_values['option_group_id']);
}
if (in_array($srcHtmlType, $mutliValueOps) &&
- in_array($dstHtmlType, $singleValueOps)
- ) {
+ in_array($dstHtmlType, $singleValueOps)) {
$this->flattenToFirstValue($tableName, $this->_values['column_name']);
}
elseif (in_array($srcHtmlType, $singleValueOps) &&
- in_array($dstHtmlType, $mutliValueOps)
- ) {
+ in_array($dstHtmlType, $mutliValueOps)) {
$this->firstValueToFlatten($tableName, $this->_values['column_name']);
}
CRM_Core_BAO_Cache::deleteGroup('contact fields');
CRM_Core_Session::setStatus(ts('Input type of custom field \'%1\' has been successfully changed to \'%2\'.',
- array(1 => $this->_values['label'], 2 => $dstHtmlType)
+ [1 => $this->_values['label'], 2 => $dstHtmlType]
), ts('Field Type Changed'), 'success');
}
return NULL;
}
- $singleValueOps = array(
+ $singleValueOps = [
'Text' => 'Text',
'Select' => 'Select',
'Radio' => 'Radio',
'Autocomplete-Select' => 'Autocomplete-Select',
- );
+ ];
- $mutliValueOps = array(
+ $mutliValueOps = [
'CheckBox' => 'CheckBox',
'Multi-Select' => 'Multi-Select',
- );
+ ];
switch ($dataType) {
case 'String':
break;
case 'Memo':
- $ops = array(
+ $ops = [
'TextArea' => 'TextArea',
'RichTextEditor' => 'RichTextEditor',
- );
+ ];
if (in_array($htmlType, array_keys($ops))) {
unset($ops[$htmlType]);
return $ops;
continue;
}
$value = CRM_Core_DAO::VALUE_SEPARATOR . $dao->{$column} . CRM_Core_DAO::VALUE_SEPARATOR;
- $params = array(
- 1 => array((string) $value, 'String'),
- 2 => array($dao->id, 'Integer'),
- );
+ $params = [
+ 1 => [(string) $value, 'String'],
+ 2 => [$dao->id, 'Integer'],
+ ];
CRM_Core_DAO::executeQuery($updateSql, $params);
}
}
$dao = CRM_Core_DAO::executeQuery($selectSql);
while ($dao->fetch()) {
$values = self::explode($dao->{$column});
- $params = array(
- 1 => array((string) array_shift($values), 'String'),
- 2 => array($dao->id, 'Integer'),
- );
+ $params = [
+ 1 => [(string) array_shift($values), 'String'],
+ 2 => [$dao->id, 'Integer'],
+ ];
CRM_Core_DAO::executeQuery($updateSql, $params);
}
}
*/
public static function explode($str) {
if (empty($str) || $str == CRM_Core_DAO::VALUE_SEPARATOR . CRM_Core_DAO::VALUE_SEPARATOR) {
- return array();
+ return [];
}
else {
return explode(CRM_Core_DAO::VALUE_SEPARATOR, trim($str, CRM_Core_DAO::VALUE_SEPARATOR));