+ /**
+ * get the list of print labels
+ *
+ * @return array list of labels
+ * @static
+ */
+ public static function getList() {
+ $printLabel = new CRM_Core_DAO_PrintLabel();
+ $printLabel->find();
+
+ $labels = array();
+ while($printLabel->fetch()) {
+ $labels[$printLabel->id] = $printLabel->title;
+ }
+ return $labels;
+ }
+
+ /**
+ * Build layout structure
+ *
+ * @param array $params associated array of submitted values
+ *
+ * @return array $formattedLayout array formatted array
+ */
+ 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'] = json_decode($formatProperties, true);
+ $layoutInfo['data'] = CRM_Badge_BAO_Layout::getDecodedData($layoutInfo['data']);
+ return $layoutInfo;
+ }
+
+ /**
+ * Decode encoded data and return as an array
+ *
+ * @param json $jsonData json object
+ *
+ * @return array associated array of decoded elements
+ * @static
+ */
+ static public function getDecodedData($jsonData) {
+ return json_decode($jsonData, true);
+ }
+}