Merge pull request #5044 from colemanw/Comment
[civicrm-core.git] / CRM / Utils / Address.php
index 6d166d62f2eab7cbf9303433515e2b2ff0883ff2..b4c3a209091e139a95f0738a7a1933c56fb6dbad 100644 (file)
@@ -23,7 +23,7 @@
  | GNU Affero General Public License or the licensing of CiviCRM,     |
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
-*/
+ */
 
 /**
  * Address utilties
@@ -38,36 +38,39 @@ class CRM_Utils_Address {
    * Format an address basing on the address fields provided.
    * Use Setting's address_format if there's no format specified.
    *
-   * @param array $fields the address fields
-   * @param string $format the desired address format
-   * @param boolean $microformat if true indicates, the address to be built in hcard-microformat standard.
-   * @param boolean $mailing if true indicates, the call has been made from mailing label
-   * @param boolean $individualFormat if true indicates, the call has been made for the contact of type 'individual'
+   * @param array $fields
+   *   The address fields.
+   * @param string $format
+   *   The desired address format.
+   * @param bool $microformat
+   *   If true indicates, the address to be built in hcard-microformat standard.
+   * @param bool $mailing
+   *   If true indicates, the call has been made from mailing label.
+   * @param bool $individualFormat
+   *   If true indicates, the call has been made for the contact of type 'individual'.
    *
    * @param null $tokenFields
    *
-   * @return string  formatted address string
+   * @return string
+   *   formatted address string
    *
-   * @static
    */
-  static function format(
+  public static function format(
     $fields,
-    $format           = NULL,
-    $microformat      = FALSE,
-    $mailing          = FALSE,
+    $format = NULL,
+    $microformat = FALSE,
+    $mailing = FALSE,
     $individualFormat = FALSE,
-    $tokenFields      = NULL
+    $tokenFields = NULL
   ) {
     static $config = NULL;
 
     if (!$format) {
-      $format =
-        CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'address_format');
+      $format = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'address_format');
     }
 
     if ($mailing) {
-      $format =
-        CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'mailing_format');
+      $format = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'mailing_format');
     }
 
     $formatted = $format;
@@ -105,7 +108,7 @@ class CRM_Utils_Address {
     }
 
     if (!$microformat) {
-        // replacements in case of Individual Name Format
+      // replacements in case of Individual Name Format
       $replacements = array(
         'contact.display_name' => CRM_Utils_Array::value('display_name', $fields),
         'contact.individual_prefix' => CRM_Utils_Array::value('individual_prefix', $fields),
@@ -140,7 +143,6 @@ class CRM_Utils_Address {
         'contact.birth_date' => CRM_Utils_Array::value('birth_date', $fields),
         'contact.gender' => CRM_Utils_Array::value('gender', $fields),
         'contact.is_opt_out' => CRM_Utils_Array::value('is_opt_out', $fields),
-        'contact.home_URL' => CRM_Utils_Array::value('home_URL', $fields),
         'contact.preferred_mail_format' => CRM_Utils_Array::value('preferred_mail_format', $fields),
         'contact.phone' => CRM_Utils_Array::value('phone', $fields),
         'contact.home_URL' => CRM_Utils_Array::value('home_URL', $fields),
@@ -249,8 +251,8 @@ class CRM_Utils_Address {
     else {
       // remove \n from each line and only add at the end
       // this hack solves formatting issue, when we convert nl2br
-      $lines          = array();
-      $count          = 1;
+      $lines = array();
+      $count = 1;
       $finalFormatted = NULL;
       $formattedArray = explode("\n", $formatted);
       $formattedArray = array_filter($formattedArray);
@@ -304,4 +306,5 @@ class CRM_Utils_Address {
     $newSequence = array_unique($newSequence);
     return $newSequence;
   }
+
 }