Merge pull request #4822 from kurund/indentation-fixes
[civicrm-core.git] / CRM / Badge / BAO / Layout.php
index 02d8e9141dfe7a71319d8184dd370ad658b61135..0bbe2ce1fc71c79ee12a5f7cdd808d770746a06f 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.4                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013                                |
+ | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
  * $Id$
  *
  */
 class CRM_Badge_BAO_Layout extends CRM_Core_DAO_PrintLabel {
 
   /**
-   * class constructor
+   * Class constructor
    */
-  function __construct() {
+  public function __construct() {
     parent::__construct();
   }
 
@@ -49,11 +49,10 @@ class CRM_Badge_BAO_Layout extends CRM_Core_DAO_PrintLabel {
    * @param array $params   (reference ) an assoc array of name/value pairs
    * @param array $defaults (reference ) an assoc array to hold the flattened values
    *
-   * @return object CRM_Core_DAO_PrintLabel object on success, null otherwise
-   * @access public
+   * @return CRM_Core_DAO_PrintLabel object on success, null otherwise
    * @static
    */
-  static function retrieve(&$params, &$defaults) {
+  public static function retrieve(&$params, &$defaults) {
     $printLabel = new CRM_Core_DAO_PrintLabel();
     $printLabel->copyValues($params);
     if ($printLabel->find(TRUE)) {
@@ -64,32 +63,29 @@ class CRM_Badge_BAO_Layout extends CRM_Core_DAO_PrintLabel {
   }
 
   /**
-   * update the is_active flag in the db
+   * Update the is_active flag in the db
    *
    * @param int $id        id of the database record
    * @param boolean $is_active value we want to set the is_active field
    *
    * @return Object             DAO object on success, null otherwise
    *
-   * @access public
    * @static
    */
-  static function setIsActive($id, $is_active) {
+  public static function setIsActive($id, $is_active) {
     return CRM_Core_DAO::setFieldValue('CRM_Core_DAO_PrintLabel', $id, 'is_active', $is_active);
   }
 
   /**
-   * Function to add a name label
+   * Add a name label
    *
    * @param array $params reference array contains the values submitted by the form
-   * @param array $ids    reference array contains the id
    *
-   * @access public
    * @static
    *
    * @return object
    */
-  static function create(&$params) {
+  public static function create(&$params) {
     $params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE);
     $params['is_default'] = CRM_Utils_Array::value('is_default', $params, FALSE);
     $params['is_reserved'] = CRM_Utils_Array::value('is_reserved', $params, FALSE);
@@ -122,14 +118,13 @@ class CRM_Badge_BAO_Layout extends CRM_Core_DAO_PrintLabel {
   }
 
   /**
-   * Function to delete name labels
+   * Delete name labels
    *
    * @param  int $printLabelId ID of the name label to be deleted.
    *
-   * @access public
    * @static
    */
-  static function del($printLabelId) {
+  public static function del($printLabelId) {
     $printLabel = new CRM_Core_DAO_PrintLabel();
     $printLabel->id = $printLabelId;
     $printLabel->delete();
@@ -139,10 +134,9 @@ class CRM_Badge_BAO_Layout extends CRM_Core_DAO_PrintLabel {
    *  get the list of print labels
    *
    * @return array list of labels
-   * @access public
    * @static
    */
-  static function getList() {
+  public static function getList() {
     $printLabel = new CRM_Core_DAO_PrintLabel();
     $printLabel->find();
 
@@ -154,47 +148,31 @@ class CRM_Badge_BAO_Layout extends CRM_Core_DAO_PrintLabel {
   }
 
   /**
-   * build layout structure
+   * Build layout structure
    *
    * @param array $params associated array of submitted values
    *
    * @return array $formattedLayout array formatted array
-   * @access public
    */
-  static function buildLayout(&$params) {
+  public static function buildLayout(&$params) {
     $layoutParams = array('id' => $params['badge_id']);
     CRM_Badge_BAO_Layout::retrieve($layoutParams, $layoutInfo);
 
     $formatProperties = CRM_Core_OptionGroup::getValue('name_badge', $layoutInfo['label_format_name'], 'name');
-    $layoutInfo['format'] = get_object_vars(json_decode($formatProperties));
+    $layoutInfo['format'] = json_decode($formatProperties, true);
     $layoutInfo['data'] = CRM_Badge_BAO_Layout::getDecodedData($layoutInfo['data']);
     return $layoutInfo;
   }
 
   /**
-   * Function to decode encoded data and return as an array
+   * Decode encoded data and return as an array
    *
    * @param json $jsonData json object
    *
-   * @return array $dataValues associated array of decoded elements
+   * @return array associated array of decoded elements
    * @static
    */
   static public function getDecodedData($jsonData) {
-    $data = get_object_vars(json_decode($jsonData));
-
-    $specialFields = array('token', 'font_name', 'font_size', 'text_alignment');
-    foreach($specialFields as $field) {
-      $dataValues[$field] = get_object_vars($data[$field]);
-    }
-
-    $dataValues['add_barcode'] = CRM_Utils_Array::value('add_barcode', $data);
-    $dataValues['barcode_alignment'] = CRM_Utils_Array::value('barcode_alignment', $data);
-    $dataValues['barcode_type'] = CRM_Utils_Array::value('barcode_type', $data);
-
-    $dataValues['image_1'] = CRM_Utils_Array::value('image_1', $data);
-    $dataValues['image_2'] = CRM_Utils_Array::value('image_2', $data);
-
-    return $dataValues;
+    return json_decode($jsonData, true);
   }
 }
-