Merge pull request #4865 from eileenmcnaughton/my-first-factory
[civicrm-core.git] / CRM / Custom / Form / Field.php
index 8deb783b2eb7fb8d6de86c91823686dd5bd149a0..b40f7ddb85931b806d8d2de0fd8253a8cad0931d 100644 (file)
@@ -47,7 +47,6 @@ class CRM_Custom_Form_Field extends CRM_Core_Form {
    * The custom group id saved to the session for an update
    *
    * @var int
-   * @access protected
    */
   protected $_gid;
 
@@ -55,7 +54,6 @@ class CRM_Custom_Form_Field extends CRM_Core_Form {
    * The field id, used when editing the field
    *
    * @var int
-   * @access protected
    */
   protected $_id;
 
@@ -63,7 +61,6 @@ class CRM_Custom_Form_Field extends CRM_Core_Form {
    * The default custom data/input types, when editing the field
    *
    * @var array
-   * @access protected
    */
   protected $_defaultDataType;
 
@@ -91,7 +88,6 @@ class CRM_Custom_Form_Field extends CRM_Core_Form {
    * @param null
    *
    * @return void
-   * @access public
    */
   public function preProcess() {
     if (!(self::$_dataTypeKeys)) {
@@ -136,18 +132,28 @@ class CRM_Custom_Form_Field extends CRM_Core_Form {
 
     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'),
         ),
-        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('Rich Text Editor')),
@@ -169,9 +175,8 @@ class CRM_Custom_Form_Field extends CRM_Core_Form {
    * @param null
    *
    * @return array    array of default values
-   * @access public
    */
-  function setDefaultValues() {
+  public function setDefaultValues() {
     $defaults = $this->_values;
 
     if ($this->_id) {
@@ -275,7 +280,6 @@ class CRM_Custom_Form_Field extends CRM_Core_Form {
    * @param null
    *
    * @return void
-   * @access public
    */
   public function buildQuickForm() {
     if ($this->_gid) {
@@ -328,7 +332,8 @@ class CRM_Custom_Form_Field extends CRM_Core_Form {
       $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'),
       );
 
@@ -347,7 +352,6 @@ class CRM_Custom_Form_Field extends CRM_Core_Form {
         'onclick' => "showOptionSelect();"), '<br/>'
     );
 
-
     $contactGroups = CRM_Core_PseudoConstant::group();
     asort($contactGroups);
 
@@ -561,7 +565,8 @@ class CRM_Custom_Form_Field extends CRM_Core_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
@@ -569,9 +574,8 @@ class CRM_Custom_Form_Field extends CRM_Core_Form {
    * @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();
@@ -581,9 +585,10 @@ class CRM_Custom_Form_Field extends CRM_Core_Form {
     $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) {
@@ -895,7 +900,6 @@ AND    option_group_id = %2";
    * @param null
    *
    * @return void
-   * @access public
    */
   public function postProcess() {
     // store the submitted values in an array
@@ -1016,4 +1020,3 @@ SELECT id
     $this->ajaxResponse['customField'] = $customField->toArray();
   }
 }
-