| 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$
*
*/
class CRM_Core_BAO_LabelFormat extends CRM_Core_DAO_OptionValue {
/**
- * Static holder for the Label Formats Option Group ID
+ * Static holder for the Label Formats Option Group ID.
*/
private static $_gid = NULL;
/**
* Get page orientations recognized by the DOMPDF package used to create PDF letters.
*
- * @param void
- *
* @return array
* array of page orientations
- * @static
*/
public static function getPageOrientations() {
return array(
*
* @return array
* array of font names
- * @static
*/
public static function getFontNames($name = 'label_format') {
$label = new CRM_Utils_PDF_Label(self::getDefaultValues($name));
/**
* Get font sizes supported by the TCPDF package used to create PDF labels.
*
- * @param void
- *
* @return array
* array of font sizes
- * @static
*/
public static function getFontSizes() {
$fontSizes = array();
/**
* Get measurement units recognized by the TCPDF package used to create PDF labels.
*
- * @param void
- *
* @return array
* array of measurement units
- * @static
*/
public static function getUnits() {
return array(
/**
* Get text alignment recognized by the TCPDF package used to create PDF labels.
*
- * @param void
- *
* @return array
* array of alignments
- * @static
*/
public static function getTextAlignments() {
return array(
/**
* Get text alignment recognized by the TCPDF package used to create PDF labels.
*
- * @param void
- *
* @return array
* array of alignments
- * @static
*/
public static function getFontStyles() {
return array(
}
/**
- * Get Option Group ID for Label Formats
+ * Get Option Group ID for Label Formats.
*
* @param string $name
*
}
/**
- * Add ordering fields to Label Format list
+ * Add ordering fields to Label Format list.
*
* @param array (reference) $list List of Label Formats
* @param string $returnURL
*
* @return array
* (reference) List of Label Formats
- * @static
*/
public static function addOrder(&$list, $returnURL) {
$filter = "option_group_id = " . self::_getGid();
CRM_Utils_Weight::addOrder($list, 'CRM_Core_DAO_OptionValue', 'id', $returnURL, $filter);
+ return $list;
}
/**
*
* @return array
* (reference) label format list
- * @static
*/
public static function &getList($namesOnly = FALSE, $groupName = 'label_format') {
static $list = array();
}
/**
- * Retrieve the default Label Format values
+ * Retrieve the default Label Format values.
*
* @param string $groupName
* Label format group name.
*
* @return array
* Name/value pairs containing the default Label Format values.
- * @static
*/
public static function &getDefaultValues($groupName = 'label_format') {
$params = array('is_active' => 1, 'is_default' => 1);
}
/**
- * Get Label Format from the DB
+ * Get Label Format from the DB.
*
* @param string $field
* Field name to search by.
}
/**
- * Get Label Format by Name
+ * Get Label Format by Name.
*
* @param int $name
* Label format name. Empty = get default label format.
}
/**
- * Get Label Format by ID
+ * Get Label Format by ID.
*
* @param int $id
* Label format id. 0 = get default label format.
}
/**
- * Get Label Format field from associative array
+ * Get Label Format field from associative array.
*
* @param string $field
* Name of a label format field.
* @param null $default
*
* @return value
- * @static
*/
public static function getValue($field, &$values, $default = NULL) {
if (array_key_exists($field, self::$optionValueFields)) {
switch (self::$optionValueFields[$field]['type']) {
case CRM_Utils_Type::T_INT:
- return (int)CRM_Utils_Array::value($field, $values, $default);
+ return (int) CRM_Utils_Array::value($field, $values, $default);
case CRM_Utils_Type::T_FLOAT:
// Round float values to three decimal places and trim trailing zeros.
$f = sprintf('%05.3f', $values[$field]);
$f = rtrim($f, '0');
$f = rtrim($f, '.');
- return (float)(empty($f) ? '0' : $f);
+ return (float) (empty($f) ? '0' : $f);
}
return CRM_Utils_Array::value($field, $values, $default);
}
}
/**
- * Takes a bunch of params that are needed to match certain criteria and
- * retrieves the relevant objects. Typically the valid params are only
- * label id. It also stores all the retrieved values in the default array.
+ * Retrieve DB object based on input parameters.
+ *
+ * It also stores all the retrieved values in the default array.
*
* @param array $params
* (reference ) an assoc array of name/value pairs.
*
* @param string $groupName
*
- * @return CRM_Core_DAO_OptionValue object
- * @static
+ * @return CRM_Core_DAO_OptionValue
*/
public static function retrieve(&$params, &$values, $groupName = 'label_format') {
$optionValue = new CRM_Core_DAO_OptionValue();
}
/**
- * Return the name of the group for customized labels
- *
- * @param void
+ * Return the name of the group for customized labels.
*
* @return void
*/
}
/**
- * Save the Label Format in the DB
+ * Save the Label Format in the DB.
*
* @param array (reference) $values associative array of name/value pairs
* @param int $id
}
else {
// new record
- $list = self::getList(TRUE,$groupName);
+ $list = self::getList(TRUE, $groupName);
$cnt = 1;
- while (array_key_exists("custom_$cnt", $list)) $cnt++;
+ while (array_key_exists("custom_$cnt", $list)) {
+ $cnt++;
+ }
$values['name'] = "custom_$cnt";
$values['grouping'] = self::customGroupName();
}
}
/**
- * Delete a Label Format
+ * Delete a Label Format.
*
* @param int $id
* ID of the label format to be deleted.
* @param string $groupName
* Group name.
- * @static
*/
public static function del($id, $groupName) {
if ($id) {
}
CRM_Core_Error::fatal(ts('Invalid value passed to delete function.'));
}
+
}