Merge pull request #6539 from joannechester/CRM-16185-rename-date-filters
[civicrm-core.git] / CRM / Core / Form / Date.php
index 5ddb2a6592bf68ccc4c4b2a921af112b01918702..0c8cc01d8fd759e1ab59c6f6c243100d966fd73f 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.6                                                |
+ | CiviCRM version 4.7                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014                                |
+ | Copyright CiviCRM LLC (c) 2004-2015                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
  | 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_Form_Date {
 
   /**
-   * Various Date Formats
+   * Various Date Formats.
    */
   const DATE_yyyy_mm_dd = 1, DATE_mm_dd_yy = 2, DATE_mm_dd_yyyy = 4, DATE_Month_dd_yyyy = 8, DATE_dd_mon_yy = 16, DATE_dd_mm_yyyy = 32;
 
@@ -86,17 +86,15 @@ class CRM_Core_Form_Date {
    * @param string $dateFormat
    * @param bool|string $displayTime
    *
-   *
    */
-
-  static function buildDateRange(
+  public static function buildDateRange(
     &$form, $fieldName, $count = 1,
     $from = '_from', $to = '_to', $fromLabel = 'From:',
     $required = FALSE, $operators = array(),
     $dateFormat = 'searchDate', $displayTime = FALSE
   ) {
-    $selector =
-      CRM_Core_Form_Date::returnDateRangeSelector(
+    $selector
+      CRM_Core_Form_Date::returnDateRangeSelector(
         $form, $fieldName, $count,
         $from, $to, $fromLabel,
         $required, $operators,
@@ -110,7 +108,7 @@ class CRM_Core_Form_Date {
   }
 
   /**
-   * build the date range array that will provide the form option values
+   * build the date range array that will provide the form option values.
    * It can be - relative or absolute
    *
    * @param CRM_Core_Form $form
@@ -128,77 +126,75 @@ class CRM_Core_Form_Date {
    * @return array
    *   Values for Selector
    */
-  static function returnDateRangeSelector(
+  public static function returnDateRangeSelector(
     &$form, $fieldName, $count = 1,
     $from = '_from', $to = '_to', $fromLabel = 'From:',
     $required = FALSE, $operators = array(),
     $dateFormat = 'searchDate', $displayTime = FALSE
   ) {
-    $selector =
-      array(
-        '' => ts('- any -'),
-        0 => ts('Choose Date Range'),
-        'previous_2.year' => ts('Previous 2 Years'),
-        'previous_2.quarter' => ts('Previous 2 Quarters'),
-        'previous_2.month' => ts('Previous 2 Months'),
-        'previous_2.week' => ts('Previous 2 Weeks'),
-        'previous_2.day' => ts('Previous 2 Days'),
-        'previous_before.year' => ts('Prior to Previous Year'),
-        'previous_before.quarter' => ts('Prior to Previous Quarter'),
-        'previous_before.month' => ts('Prior to Previous Month'),
-        'previous_before.week' => ts('Prior to Previous Week'),
-        'previous_before.day' => ts('Prior to Previous Day'),
-        'previous.year' => ts('Previous Year'),
-        'previous.fiscal_year' => ts('Previous Fiscal Year'),
-        'previous.quarter' => ts('Previous Quarter'),
-        'previous.month' => ts('Previous Month'),
-        'previous.week' => ts('Previous Week'),
-        'earlier.year' => ts('To End of Previous Year'),
-        'earlier.quarter' => ts('To End of Previous Quarter'),
-        'earlier.month' => ts('To End of Previous Month'),
-        'earlier.week' => ts('To End of Previous Week'),
-        'earlier.day' => ts('To End of Previous Day'),
-        'greater_previous.year' => ts('From End of Previous Year'),
-        'greater_previous.quarter' => ts('From End of Previous Quarter'),
-        'greater_previous.month' => ts('From End of Previous Month'),
-        'greater_previous.week' => ts('From End of Previous Week'),
-        'greater.year' => ts('From Start of Current Year'),
-        'greater.quarter' => ts('From Start of Current Quarter'),
-        'greater.month' => ts('From Start of Current Month'),
-        'greater.week' => ts('From Start of Current Week'),
-        'greater.day' => ts('From Start of Current Day'),
-        'current.year' => ts('Current Year to-date'),
-        'current.quarter' => ts('Current Quarter to-date'),
-        'current.month' => ts('Current Month to-date'),
-        'current.week' => ts('Current Week to-date'),
-        'ending_3.year' => ts('Last 3 Years'),
-        'ending_2.year' => ts('Last 2 Years'),
-        'ending.year' => ts('Last 12 Months'),
-        'ending.quarter' => ts('Last 3 Months'),
-        'ending.month' => ts('Last Month'),
-        'ending.week' => ts('Last 7 days'),
-        'previous.day' => ts('Yesterday'),
-        'this.year' => ts('This Year'),
-        'this.fiscal_year' => ts('This Fiscal Year'),
-        'this.quarter' => ts('This Quarter'),
-        'this.month' => ts('This Month'),
-        'this.week' => ts('This Week'),
-        'this.day' => ts('Today'),
-        'starting.day' => ts('Tomorrow'),
-        'starting.week' => ts('Upcoming 7 days'),
-        'starting.month' => ts('Upcoming Month'),
-        'starting.year' => ts('Upcoming 12 Months'),
-        'less.year' => ts('To End of Current Year'),
-        'less.quarter' => ts('To End of Current Quarter'),
-        'less.month' => ts('To End of Current Month'),
-        'less.week' => ts('To End of Current Week'),
-        'next.week' => ts('Next Week'),
-        'next.month' => ts('Next Month'),
-        'next.quarter' => ts('Next Quarter'),
-        'next.fiscal_year' => ts('Next Fiscal Year'),
-        'next.year' => ts('Next Year'),
-
-      );
+    $selector = array(
+      '' => ts('- any -'),
+      0 => ts('Choose Date Range'),
+      'previous_2.year' => ts('Previous 2 calendar years'),
+      'previous_2.quarter' => ts('Previous 2 quarters'),
+      'previous_2.month' => ts('Previous 2 calendar months'),
+      'previous_2.week' => ts('Previous 2 weeks'),
+      'previous_2.day' => ts('Previous 2 days'),
+      'previous_before.year' => ts('Year prior to previous calendar year'),
+      'previous_before.quarter' => ts('Quarter prior to previous quarter'),
+      'previous_before.month' => ts('Month prior to previous calendar month'),
+      'previous_before.week' => ts('Week prior to previous week'),
+      'previous_before.day' => ts('Day prior to previous day'),
+      'previous.year' => ts('Previous calendar year'),
+      'previous.fiscal_year' => ts('Previous fiscal year'),
+      'previous.quarter' => ts('Previous quarter'),
+      'previous.month' => ts('Previous calendar month'),
+      'previous.week' => ts('Previous week'),
+      'earlier.year' => ts('To end of previous calendar year'),
+      'earlier.quarter' => ts('To end of previous quarter'),
+      'earlier.month' => ts('To end of previous calendar month'),
+      'earlier.week' => ts('To end of previous week'),
+      'earlier.day' => ts('To end of previous day'),
+      'greater_previous.year' => ts('From end of previous calendar year'),
+      'greater_previous.quarter' => ts('From end of previous quarter'),
+      'greater_previous.month' => ts('From end of previous calendar month'),
+      'greater_previous.week' => ts('From end of previous week'),
+      'greater.year' => ts('From start of current calendar year'),
+      'greater.quarter' => ts('From start of current quarter'),
+      'greater.month' => ts('From start of current calendar month'),
+      'greater.week' => ts('From start of current week'),
+      'greater.day' => ts('From start of current day'),
+      'current.year' => ts('Current calendar year to-date'),
+      'current.quarter' => ts('Current quarter to-date'),
+      'current.month' => ts('Current calendar month to-date'),
+      'current.week' => ts('Current week to-date'),
+      'ending_3.year' => ts('Last 3 years including today'),
+      'ending_2.year' => ts('Last 2 years including today'),
+      'ending.year' => ts('Last 12 months including today'),
+      'ending.quarter' => ts('Last 3 months including today'),
+      'ending.month' => ts('Last 30 days including today'),
+      'ending.week' => ts('Last 7 days including today'),
+      'previous.day' => ts('Yesterday'),
+      'this.year' => ts('This calendar year'),
+      'this.fiscal_year' => ts('This fiscal year'),
+      'this.quarter' => ts('This quarter'),
+      'this.month' => ts('This calendar month'),
+      'this.week' => ts('This week'),
+      'this.day' => ts('Today'),
+      'starting.day' => ts('Tomorrow'),
+      'starting.week' => ts('Next 7 days including today'),
+      'starting.month' => ts('Next month including today'),
+      'starting.year' => ts('Next 12 months including today'),
+      'less.year' => ts('To end of current calendar year'),
+      'less.quarter' => ts('To end of current quarter'),
+      'less.month' => ts('To end of current calendar month'),
+      'less.week' => ts('To end of current week'),
+      'next.week' => ts('Next week'),
+      'next.month' => ts('Next calendar month'),
+      'next.quarter' => ts('Next quarter'),
+      'next.fiscal_year' => ts('Next fiscal year'),
+      'next.year' => ts('Next calendar year'),
+    );
 
     if (is_array($operators)) {
       $selector = array_merge($selector, $operators);
@@ -229,8 +225,6 @@ class CRM_Core_Form_Date {
    * @param bool $required
    * @param string $dateFormat
    * @param bool $displayTime
-   *
-   * @return null
    */
   public static function addDateRangeToForm(&$form, $fieldName, $selector, $from = '_from', $to = '_to', $fromLabel = 'From:', $required = FALSE, $dateFormat = 'searchDate', $displayTime = FALSE) {
     $form->add('select',