<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.5 |
+ | CiviCRM version 4.6 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
/**
* Constants for number of options for data types of multiple option.
*/
- CONST NUM_OPTION = 11;
+ const NUM_OPTION = 11;
/**
- * the custom group id saved to the session for an update
+ * The custom group id saved to the session for an update
*
* @var int
- * @access protected
*/
protected $_gid;
* The field id, used when editing the field
*
* @var int
- * @access protected
*/
protected $_id;
* The default custom data/input types, when editing the field
*
* @var array
- * @access protected
*/
protected $_defaultDataType;
/**
- * array of custom field values if update mode
+ * Array of custom field values if update mode
*/
protected $_values;
private static $_dataToLabels = NULL;
/**
- * Function to set variables up before form is built
+ * Set variables up before form is built
*
* @param null
*
* @return void
- * @access public
*/
public function preProcess() {
if (!(self::$_dataTypeKeys)) {
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'),
+ array(
+ 'Text' => ts('Text'),
+ 'Select' => ts('Select'),
+ 'Radio' => ts('Radio'),
+ 'CheckBox' => ts('CheckBox'),
+ 'Multi-Select' => ts('Multi-Select'),
'AdvMulti-Select' => ts('Adv Multi-Select (obsolete)'),
- 'Autocomplete-Select' => ts('Autocomplete Select'),
+ 'Autocomplete-Select' => ts('Autocomplete-Select'),
),
- array('Text' => ts('Text'), 'Select' => ts('Select'),
+ array(
+ 'Text' => ts('Text'),
+ 'Select' => ts('Select'),
'Radio' => ts('Radio'),
),
- array('Text' => ts('Text'), 'Select' => ts('Select'),
+ array(
+ 'Text' => ts('Text'),
+ 'Select' => ts('Select'),
'Radio' => ts('Radio'),
),
- array('Text' => ts('Text'), 'Select' => ts('Select'),
+ array(
+ 'Text' => ts('Text'),
+ 'Select' => ts('Select'),
'Radio' => ts('Radio'),
),
- array('TextArea' => ts('TextArea'), 'RichTextEditor' => ts('RichTextEditor')),
+ array('TextArea' => ts('TextArea'), 'RichTextEditor' => ts('Rich Text Editor')),
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('Country' => ts('Select Country'), 'Multi-Select' => ts('Multi-Select Country')),
array('File' => ts('Select File')),
array('Link' => ts('Link')),
- array('ContactReference' => ts('Autocomplete Select')),
+ array('ContactReference' => ts('Autocomplete-Select')),
);
}
}
/**
- * This function sets the default values for the form. Note that in edit/view mode
+ * Set default values for the form. Note that in edit/view mode
* the default values are retrieved from the database
*
* @param null
*
* @return array array of default values
- * @access public
*/
- function setDefaultValues() {
+ public function setDefaultValues() {
$defaults = $this->_values;
if ($this->_id) {
}
/**
- * Function to actually build the form
+ * Build the form object
*
* @param null
*
* @return void
- * @access public
*/
public function buildQuickForm() {
if ($this->_gid) {
$optionTypes = array('1' => ts('Create a new set of options'));
}
else {
- $optionTypes = array('1' => ts('Create a new set of options'),
+ $optionTypes = array(
+ '1' => ts('Create a new set of options'),
'2' => ts('Reuse an existing set'),
);
'onclick' => "showOptionSelect();"), '<br/>'
);
-
$contactGroups = CRM_Core_PseudoConstant::group();
asort($contactGroups);
}
/**
- * global validation rules for the form
+ * Global validation rules for the form
*
- * @param array $fields posted values of the form
+ * @param array $fields
+ * Posted values of the form.
*
* @param $files
* @param $self
* @return array if errors then list of errors to be posted back to the form,
* true otherwise
* @static
- * @access public
*/
- static function formRule($fields, $files, $self) {
+ public static function formRule($fields, $files, $self) {
$default = CRM_Utils_Array::value('default_value', $fields);
$errors = array();
$name = CRM_Utils_String::munge($title, '_', 64);
$gId = $self->_gid; // CRM-7564
$query = 'select count(*) from civicrm_custom_field where ( name like %1 OR label like %2 ) and id != %3 and custom_group_id = %4';
- $fldCnt = CRM_Core_DAO::singleValueQuery($query, array(1 => array($name, 'String'),
+ $fldCnt = CRM_Core_DAO::singleValueQuery($query, array(
+ 1 => array($name, 'String'),
2 => array($title, 'String'),
- 3 => array((int)$self->_id, 'Integer'),
+ 3 => array((int) $self->_id, 'Integer'),
4 => array($gId, 'Integer'),
));
if ($fldCnt) {
// gives the ascii value
$asciiValue = ord($title{0});
if ($asciiValue >= 48 && $asciiValue <= 57) {
- $errors['label'] = ts("Field's Name should not start with digit");
+ $errors['label'] = ts("Name cannot not start with a digit");
}
}
switch ($dataType) {
case 'Int':
if (!CRM_Utils_Rule::integer($default)) {
- $errors['default_value'] = ts('Please enter a valid integer as default value.');
+ $errors['default_value'] = ts('Please enter a valid integer.');
}
break;
case 'Float':
if (!CRM_Utils_Rule::numeric($default)) {
- $errors['default_value'] = ts('Please enter a valid number as default value.');
+ $errors['default_value'] = ts('Please enter a valid number.');
}
break;
case 'Money':
if (!CRM_Utils_Rule::money($default)) {
- $errors['default_value'] = ts('Please enter a valid number value.');
+ $errors['default_value'] = ts('Please enter a valid number.');
}
break;
* @param null
*
* @return void
- * @access public
*/
public function postProcess() {
// store the submitted values in an array
$this->ajaxResponse['customField'] = $customField->toArray();
}
}
-