Merge pull request #5513 from mallezie/contact-select-file-16178
[civicrm-core.git] / CRM / Utils / Migrate / Export.php
index 66ee4ba6f015298ed99f7a188abb7f85ebbbcec5..ccd31a2df9056d894544653cae23bdbef6cca566 100644 (file)
@@ -3,7 +3,7 @@
  +--------------------------------------------------------------------+
  | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014                                |
+ | Copyright CiviCRM LLC (c) 2004-2015                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
  | GNU Affero General Public License or the licensing of CiviCRM,     |
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
-*/
+ */
 
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2014
+ * @copyright CiviCRM LLC (c) 2004-2015
  * $Id$
  *
  */
@@ -53,7 +53,6 @@ class CRM_Utils_Migrate_Export {
   protected $_xml;
 
   /**
-   *
    */
   public function __construct() {
     $this->_xml = array(
@@ -75,7 +74,7 @@ class CRM_Utils_Migrate_Export {
         'mappedFields' => array(
           array('optionGroup', 'option_group_id', 'option_group_name'),
           array('customGroup', 'custom_group_id', 'custom_group_name'),
-        )
+        ),
       ),
       'optionGroup' => array(
         'data' => array(),
@@ -127,7 +126,7 @@ class CRM_Utils_Migrate_Export {
         'required' => FALSE,
         'idNameMap' => array(),
         'mappedFields' => array(
-          array('profileGroup', 'uf_group_id', 'profile_group_name')
+          array('profileGroup', 'uf_group_id', 'profile_group_name'),
         ),
       ),
       'profileJoin' => array(
@@ -137,7 +136,7 @@ class CRM_Utils_Migrate_Export {
         'required' => FALSE,
         'idNameMap' => array(),
         'mappedFields' => array(
-          array('profileGroup', 'uf_group_id', 'profile_group_name')
+          array('profileGroup', 'uf_group_id', 'profile_group_name'),
         ),
       ),
       'mappingGroup' => array(
@@ -149,7 +148,7 @@ class CRM_Utils_Migrate_Export {
         'idNameMap' => array(),
         'mappedFields' => array(
           array('optionValue', 'mapping_type_id', 'mapping_type_name', 'mapping_type'),
-        )
+        ),
       ),
       'mappingField' => array(
         'data' => array(),
@@ -267,7 +266,8 @@ class CRM_Utils_Migrate_Export {
   }
 
   /**
-   * @param array $customGroupIds list of custom groups to export
+   * @param array $customGroupIds
+   *   List of custom groups to export.
    * @return void
    */
   public function buildCustomGroups($customGroupIds) {
@@ -320,7 +320,8 @@ class CRM_Utils_Migrate_Export {
   }
 
   /**
-   * @param array $ufGroupIds list of custom groups to export
+   * @param array $ufGroupIds
+   *   List of custom groups to export.
    * @return void
    */
   public function buildUFGroups($ufGroupIds) {
@@ -359,7 +360,8 @@ class CRM_Utils_Migrate_Export {
   /**
    * Render the in-memory representation as XML
    *
-   * @return string XML
+   * @return string
+   *   XML
    */
   public function toXML() {
     $buffer = '<?xml version="1.0" encoding="iso-8859-1" ?>';
@@ -389,7 +391,7 @@ class CRM_Utils_Migrate_Export {
     $result = array();
     foreach (array_keys($this->_xml) as $key) {
       if (!empty($this->_xml[$key]['data'])) {
-        $result[ $this->_xml[$key]['name'] ] = array_values($this->_xml[$key]['data']);
+        $result[$this->_xml[$key]['name']] = array_values($this->_xml[$key]['data']);
       }
     }
     return $result;
@@ -429,9 +431,12 @@ class CRM_Utils_Migrate_Export {
   /**
    * Compute any fields of the entity defined by the $mappedFields specification
    *
-   * @param array $mappedFields each item is an array(0 => MappedEntityname, 1 => InputFieldName (id-field), 2 => OutputFieldName (name-field), 3 => OptionalPrefix)
-   * @param CRM_Core_DAO $dao the entity for which we want to prepare mapped fields
-   * @return array new fields
+   * @param array $mappedFields
+   *   Each item is an array(0 => MappedEntityname, 1 => InputFieldName (id-field), 2 => OutputFieldName (name-field), 3 => OptionalPrefix).
+   * @param CRM_Core_DAO $dao
+   *   The entity for which we want to prepare mapped fields.
+   * @return array
+   *   new fields
    */
   public function computeMappedFields($mappedFields, $dao) {
     $keyValues = array();
@@ -452,14 +457,15 @@ class CRM_Utils_Migrate_Export {
   }
 
   /**
-   * @param string $objectName business-entity/xml-tag name
+   * @param string $objectName
+   *   Business-entity/xml-tag name.
    * @param CRM_Core_DAO $object
    * @param $mappedFields
    *
    * @return array
    */
   public function exportDAO($objectName, $object, $mappedFields) {
-    $dbFields = & $object->fields();
+    $dbFields = &$object->fields();
 
     // Filter the list of keys and values so that we only export interesting stuff
     $keyValues = array();
@@ -471,7 +477,15 @@ class CRM_Utils_Migrate_Export {
       if (isset($object->$name) && $object->$name !== NULL) {
         // hack for extends_entity_column_value
         if ($name == 'extends_entity_column_value') {
-          if (in_array($object->extends, array('Event', 'Activity', 'Relationship', 'Individual', 'Organization', 'Household', 'Case'))) {
+          if (in_array($object->extends, array(
+              'Event',
+              'Activity',
+              'Relationship',
+              'Individual',
+              'Organization',
+              'Household',
+              'Case',
+            ))) {
             if ($object->extends == 'Event') {
               $key = 'event_type';
             }
@@ -481,7 +495,7 @@ class CRM_Utils_Migrate_Export {
             elseif ($object->extends == 'Relationship') {
               $key = 'relationship_type';
             }
-            elseif($object->extends == 'Case') {
+            elseif ($object->extends == 'Case') {
               $key = 'case_type';
             }
             $types = explode(CRM_Core_DAO::VALUE_SEPARATOR, substr($object->$name, 1, -1));
@@ -536,7 +550,8 @@ class CRM_Utils_Migrate_Export {
    * @param string $tagName
    * @param array $keyValues
    * @throws Exception
-   * @return string XML
+   * @return string
+   *   XML
    */
   public function renderKeyValueXML($tagName, $keyValues) {
     $xml = "    <$tagName>";
@@ -548,12 +563,15 @@ class CRM_Utils_Migrate_Export {
   }
 
   /**
-   * @param string $name tag name
-   * @param string $value text
+   * @param string $name
+   *   Tag name.
+   * @param string $value
+   *   Text.
    * @param string $prefix
    *
    * @throws Exception
-   * @return string XML
+   * @return string
+   *   XML
    */
   public function renderTextTag($name, $value, $prefix = '') {
     if (!preg_match('/^[a-zA-Z0-9\_]+$/', $name)) {
@@ -561,4 +579,5 @@ class CRM_Utils_Migrate_Export {
     }
     return $prefix . "<$name>" . htmlentities($value) . "</$name>";
   }
+
 }