Merge branch 'getting_started' of https://github.com/cividesk/civicrm-core into civid...
[civicrm-core.git] / CRM / Core / BAO / PaperSize.php
index 5efc8783e249c5886644bb6c91225b86f4253eef..a9e814827536604719ac200e870e5977094b6be9 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.6                                                |
+ | CiviCRM version 4.7                                                |
  +--------------------------------------------------------------------+
  | Copyright (C) 2011 Marty Wright                                    |
  | Licensed to CiviCRM under the Academic Free License version 3.0.   |
  | 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$
  *
  */
@@ -40,7 +40,7 @@
 class CRM_Core_BAO_PaperSize extends CRM_Core_DAO_OptionValue {
 
   /**
-   * Static holder for the Paper Size Option Group ID
+   * Static holder for the Paper Size Option Group ID.
    */
   private static $_gid = NULL;
 
@@ -68,12 +68,10 @@ class CRM_Core_BAO_PaperSize extends CRM_Core_DAO_OptionValue {
   );
 
   /**
-   * Get Option Group ID for Paper Sizes
-   *
-   * @param void
+   * Get Option Group ID for Paper Sizes.
    *
-   * @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) {
@@ -86,16 +84,14 @@ class CRM_Core_BAO_PaperSize extends CRM_Core_DAO_OptionValue {
   }
 
   /**
-   * Add ordering fields to Paper Size list
+   * Add ordering fields to Paper Size list.
    *
-   * @param array (reference)   $list         List of Paper Sizes
-   * @param string              $returnURL    URL of page calling this function
+   * @param array (reference) $list List of Paper Sizes
+   * @param string $returnURL
+   *   URL of page calling this function.
    *
-   * @return array  (reference)   List of Paper Sizes
-   * @static
-   * @access public
    */
-  static function &addOrder(&$list, $returnURL) {
+  public static function &addOrder(&$list, $returnURL) {
     $filter = "option_group_id = " . self::_getGid();
     CRM_Utils_Weight::addOrder($list, 'CRM_Core_DAO_OptionValue', 'id', $returnURL, $filter);
   }
@@ -103,13 +99,13 @@ class CRM_Core_BAO_PaperSize extends CRM_Core_DAO_OptionValue {
   /**
    * Retrieve list of Paper Sizes.
    *
-   * @param bool    $namesOnly    return simple list of names
+   * @param bool $namesOnly
+   *   Return simple list of names.
    *
-   * @return array  (reference)   Paper Size list
-   * @static
-   * @access public
+   * @return array
+   *   (reference)   Paper Size list
    */
-  static function &getList($namesOnly = FALSE) {
+  public static function &getList($namesOnly = FALSE) {
     static $list = array();
     if (self::_getGid()) {
       // get saved Paper Sizes from Option Value table
@@ -131,15 +127,12 @@ class CRM_Core_BAO_PaperSize extends CRM_Core_DAO_OptionValue {
   }
 
   /**
-   * Retrieve the default Paper Size values
-   *
-   * @param NULL
+   * Retrieve the default Paper Size values.
    *
-   * @return array   Name/value pairs containing the default Paper Size values.
-   * @static
-   * @access public
+   * @return array
+   *   Name/value pairs containing the default Paper Size values.
    */
-  static function &getDefaultValues() {
+  public static function &getDefaultValues() {
     $params = array('is_active' => 1, 'is_default' => 1);
     $defaults = array();
     if (!self::retrieve($params, $defaults)) {
@@ -153,15 +146,17 @@ class CRM_Core_BAO_PaperSize extends CRM_Core_DAO_OptionValue {
   }
 
   /**
-   * Get Paper Size from the DB
+   * Get Paper Size 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
    */
-  static function &getPaperFormat($field, $val) {
+  public static function &getPaperFormat($field, $val) {
     $params = array('is_active' => 1, $field => $val);
     $paperFormat = array();
     if (self::retrieve($params, $paperFormat)) {
@@ -173,47 +168,48 @@ class CRM_Core_BAO_PaperSize extends CRM_Core_DAO_OptionValue {
   }
 
   /**
-   * Get Paper Size by Name
+   * Get Paper Size by Name.
    *
-   * @param int    $name   Paper Size name. Empty = get default Paper Size
+   * @param int $name
+   *   Paper Size name. Empty = get default Paper Size.
    *
-   * @return array  $values (reference) associative array of name/value pairs
-   * @access public
+   * @return array
+   *   (reference) associative array of name/value pairs
    */
-  static function &getByName($name) {
+  public static function &getByName($name) {
     return self::getPaperFormat('name', $name);
   }
 
   /**
-   * Get Paper Size by ID
+   * Get Paper Size by ID.
    *
-   * @param int    $id   Paper Size id. 0 = get default Paper Size
+   * @param int $id
+   *   Paper Size id. 0 = get default Paper Size.
    *
-   * @return array  $values (reference) associative array of name/value pairs
-   * @access public
+   * @return array
+   *   (reference) associative array of name/value pairs
    */
-  static function &getById($id) {
+  public static function &getById($id) {
     return self::getPaperFormat('id', $id);
   }
 
   /**
-   * Get Paper Size field from associative array
+   * Get Paper Size field from associative array.
    *
-   * @param string $field name of a Paper Size field
+   * @param string $field
+   *   Name of a Paper Size field.
    * @param array (reference) $values associative array of name/value pairs containing
    *                                           Paper Size field selections
    *
    * @param null $default
    *
    * @return value
-   * @access public
-   * @static
    */
-  static function getValue($field, &$values, $default = NULL) {
+  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.
@@ -221,7 +217,7 @@ class CRM_Core_BAO_PaperSize 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);
     }
@@ -229,18 +225,18 @@ class CRM_Core_BAO_PaperSize 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
-   * paper size id. It also stores all the retrieved values in the default array.
+   * Retrieve DB object based on input parameters.
    *
-   * @param array $params   (reference ) an assoc array of name/value pairs
-   * @param array $values   (reference ) an assoc array to hold the flattened values
+   * It also stores all the retrieved values in the default array.
    *
-   * @return CRM_Core_DAO_OptionValue object
-   * @access public
-   * @static
+   * @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
    */
-  static function retrieve(&$params, &$values) {
+  public static function retrieve(&$params, &$values) {
     $optionValue = new CRM_Core_DAO_OptionValue();
     $optionValue->copyValues($params);
     $optionValue->option_group_id = self::_getGid();
@@ -267,15 +263,15 @@ class CRM_Core_BAO_PaperSize extends CRM_Core_DAO_OptionValue {
   }
 
   /**
-   * Save the Paper Size in the DB
+   * Save the Paper Size 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
    */
-  function savePaperSize(&$values, $id) {
+  public function savePaperSize(&$values, $id) {
     // get the Option Group ID for Paper Sizes (create one if it doesn't exist)
     $group_id = self::_getGid(TRUE);
 
@@ -327,14 +323,13 @@ class CRM_Core_BAO_PaperSize extends CRM_Core_DAO_OptionValue {
   }
 
   /**
-   * Delete a Paper Size
+   * Delete a Paper Size.
    *
-   * @param  int  $id     ID of the Paper Size to be deleted.
+   * @param int $id
+   *   ID of the Paper Size to be deleted.
    *
-   * @access public
-   * @static
    */
-  static function del($id) {
+  public static function del($id) {
     if ($id) {
       $dao = new CRM_Core_DAO_OptionValue();
       $dao->id = $id;
@@ -349,5 +344,5 @@ class CRM_Core_BAO_PaperSize extends CRM_Core_DAO_OptionValue {
     }
     CRM_Core_Error::fatal(ts('Invalid value passed to delete function.'));
   }
-}
 
+}