<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.3 |
+ | CiviCRM version 4.5 |
+--------------------------------------------------------------------+
- | 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$
*
*/
$printLabel->id = $printLabelId;
$printLabel->delete();
}
+
+ /**
+ * get the list of print labels
+ *
+ * @return array list of labels
+ * @access public
+ * @static
+ */
+ 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
+ * @access 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;
+ }
+
+ /**
+ * Function to 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);
+ }
}