Merge pull request #5479 from eileenmcnaughton/4.6
[civicrm-core.git] / CRM / Core / BAO / PdfFormat.php
index 94eb28ddaedecf6a1ab7eedc04493091a7d9f583..6f1fbced8408a51ec8a4f161f3965a6ffb5f6e9b 100644 (file)
@@ -24,7 +24,7 @@
  | GNU Affero General Public License or the licensing of CiviCRM,     |
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
-*/
+ */
 
 /**
  *
@@ -40,7 +40,7 @@
 class CRM_Core_BAO_PdfFormat extends CRM_Core_DAO_OptionValue {
 
   /**
-   * Static holder for the PDF Page Formats Option Group ID
+   * Static holder for the PDF Page Formats Option Group ID.
    */
   private static $_gid = NULL;
 
@@ -55,7 +55,7 @@ class CRM_Core_BAO_PdfFormat extends CRM_Core_DAO_OptionValue {
     ),
     'stationery' => array(
       'name' => 'stationery',
-      'type' =>CRM_Utils_Type::T_STRING,
+      'type' => CRM_Utils_Type::T_STRING,
       'default' => '',
     ),
     'orientation' => array(
@@ -97,10 +97,8 @@ class CRM_Core_BAO_PdfFormat extends CRM_Core_DAO_OptionValue {
   /**
    * Get page orientations recognized by the DOMPDF package used to create PDF letters.
    *
-   * @param void
-   *
-   * @return array   array of page orientations
-   * @access public
+   * @return array
+   *   array of page orientations
    */
   public static function getPageOrientations() {
     return array(
@@ -112,10 +110,8 @@ class CRM_Core_BAO_PdfFormat extends CRM_Core_DAO_OptionValue {
   /**
    * Get measurement units recognized by the DOMPDF package used to create PDF letters.
    *
-   * @param void
-   *
-   * @return array   array of measurement units
-   * @access public
+   * @return array
+   *   array of measurement units
    */
   public static function getUnits() {
     return array(
@@ -127,12 +123,10 @@ class CRM_Core_BAO_PdfFormat extends CRM_Core_DAO_OptionValue {
   }
 
   /**
-   * Get Option Group ID for PDF Page Formats
-   *
-   * @param void
+   * Get Option Group ID for PDF Page Formats.
    *
-   * @return int  Group ID (null if Group ID doesn't exist)
-   * @access private
+   * @return int
+   *   Group ID (null if Group ID doesn't exist)
    */
   private static function _getGid() {
     if (!self::$_gid) {
@@ -145,14 +139,13 @@ class CRM_Core_BAO_PdfFormat extends CRM_Core_DAO_OptionValue {
   }
 
   /**
-   * Add ordering fields to Page Format list
+   * Add ordering fields to Page Format list.
    *
-   * @param array (reference)   $list         List of PDF Page Formats
-   * @param string              $returnURL    URL of page calling this function
+   * @param array (reference) $list List of PDF Page Formats
+   * @param string $returnURL
+   *   URL of page calling this function.
    *
    * @return void
-   * @static
-   * @access public
    */
   public static function addOrder(&$list, $returnURL) {
     $filter = "option_group_id = " . self::_getGid();
@@ -162,11 +155,11 @@ class CRM_Core_BAO_PdfFormat extends CRM_Core_DAO_OptionValue {
   /**
    * Get list of PDF Page Formats.
    *
-   * @param bool    $namesOnly    return simple list of names
+   * @param bool $namesOnly
+   *   Return simple list of names.
    *
-   * @return array  (reference)   PDF Page Format list
-   * @static
-   * @access public
+   * @return array
+   *   (reference)   PDF Page Format list
    */
   public static function &getList($namesOnly = FALSE) {
     static $list = array();
@@ -190,13 +183,10 @@ class CRM_Core_BAO_PdfFormat extends CRM_Core_DAO_OptionValue {
   }
 
   /**
-   * Get the default PDF Page Format values
+   * Get the default PDF Page Format values.
    *
-   * @param NULL
-   *
-   * @return array   Name/value pairs containing the default PDF Page Format values.
-   * @static
-   * @access public
+   * @return array
+   *   Name/value pairs containing the default PDF Page Format values.
    */
   public static function &getDefaultValues() {
     $params = array('is_active' => 1, 'is_default' => 1);
@@ -215,13 +205,15 @@ class CRM_Core_BAO_PdfFormat extends CRM_Core_DAO_OptionValue {
   }
 
   /**
-   * Get PDF Page Format from the DB
+   * Get PDF Page Format from the DB.
    *
-   * @param string $field   Field name to search by
-   * @param int    $val     Field value to search for
+   * @param string $field
+   *   Field name to search by.
+   * @param int $val
+   *   Field value to search for.
    *
-   * @return array  $values (reference) associative array of name/value pairs
-   * @access public
+   * @return array
+   *   (reference) associative array of name/value pairs
    */
   public static function &getPdfFormat($field, $val) {
     $params = array('is_active' => 1, $field => $val);
@@ -235,47 +227,48 @@ class CRM_Core_BAO_PdfFormat extends CRM_Core_DAO_OptionValue {
   }
 
   /**
-   * Get PDF Page Format by Name
+   * Get PDF Page Format by Name.
    *
-   * @param int    $name   PDF Page Format name. Empty = get default PDF Page Format
+   * @param int $name
+   *   PDF Page Format name. Empty = get default PDF Page Format.
    *
-   * @return array  $values (reference) associative array of name/value pairs
-   * @access public
+   * @return array
+   *   (reference) associative array of name/value pairs
    */
   public static function &getByName($name) {
     return self::getPdfFormat('name', $name);
   }
 
   /**
-   * Get PDF Page Format by ID
+   * Get PDF Page Format by ID.
    *
-   * @param int    $id   PDF Page Format id. 0 = get default PDF Page Format
+   * @param int $id
+   *   PDF Page Format id. 0 = get default PDF Page Format.
    *
-   * @return array  $values (reference) associative array of name/value pairs
-   * @access public
+   * @return array
+   *   (reference) associative array of name/value pairs
    */
   public static function &getById($id) {
     return self::getPdfFormat('id', $id);
   }
 
   /**
-   * Get PDF Page Format field from associative array
+   * Get PDF Page Format field from associative array.
    *
-   * @param string $field name of a PDF Page Format field
+   * @param string $field
+   *   Name of a PDF Page Format field.
    * @param array (reference) $values associative array of name/value pairs containing
    *                                           PDF Page Format field selections
    *
    * @param null $default
    *
    * @return value
-   * @access public
-   * @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.
@@ -283,7 +276,7 @@ class CRM_Core_BAO_PdfFormat extends CRM_Core_DAO_OptionValue {
           $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);
     }
@@ -291,16 +284,16 @@ class CRM_Core_BAO_PdfFormat extends CRM_Core_DAO_OptionValue {
   }
 
   /**
-   * Takes a bunch of params that are needed to match certain criteria and
-   * retrieves the relevant objects. Typically the valid params are only
-   * format 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 array $values   (reference ) an assoc array to hold the flattened values
+   * @param array $params
+   *   (reference ) an assoc array of name/value pairs.
+   * @param array $values
+   *   (reference ) an assoc array to hold the flattened values.
    *
-   * @return CRM_Core_DAO_OptionValue object
-   * @access public
-   * @static
+   * @return CRM_Core_DAO_OptionValue
    */
   public static function retrieve(&$params, &$values) {
     $optionValue = new CRM_Core_DAO_OptionValue();
@@ -329,13 +322,13 @@ class CRM_Core_BAO_PdfFormat extends CRM_Core_DAO_OptionValue {
   }
 
   /**
-   * Save the PDF Page Format in the DB
+   * Save the PDF Page Format in the DB.
    *
-   * @param array (reference)   $values    associative array of name/value pairs
-   * @param int                 $id        id of the database record (null = new record)
+   * @param array (reference) $values associative array of name/value pairs
+   * @param int $id
+   *   Id of the database record (null = new record).
    *
    * @return void
-   * @access public
    */
   public function savePdfFormat(&$values, $id = NULL) {
     // get the Option Group ID for PDF Page Formats (create one if it doesn't exist)
@@ -385,12 +378,11 @@ class CRM_Core_BAO_PdfFormat extends CRM_Core_DAO_OptionValue {
   }
 
   /**
-   * Delete a PDF Page Format
+   * Delete a PDF Page Format.
    *
-   * @param  int  $id     ID of the PDF Page Format to be deleted.
+   * @param int $id
+   *   ID of the PDF Page Format to be deleted.
    *
-   * @access public
-   * @static
    */
   public static function del($id) {
     if ($id) {
@@ -407,5 +399,5 @@ class CRM_Core_BAO_PdfFormat extends CRM_Core_DAO_OptionValue {
     }
     CRM_Core_Error::fatal(ts('Invalid value passed to delete function.'));
   }
-}
 
+}