* @return array
* the date array
*/
- public static function date($type = NULL, $format = NULL, $minOffset = NULL, $maxOffset = NULL) {
+ public static function date($type = NULL, $format = NULL, $minOffset = NULL, $maxOffset = NULL, $context = 'display') {
+ // These options are deprecated. Definitely not used in datepicker. Possibly not even in jcalendar+addDateTime.
$date = array(
'addEmptyOption' => TRUE,
'emptyOptionText' => ts('- select -'),
if (!$dao->find(TRUE)) {
CRM_Core_Error::fatal();
}
- }
+ if (!$maxOffset) {
+ $maxOffset = $dao->end;
+ }
+ if (!$minOffset) {
+ $minOffset = $dao->start;
+ }
- if ($type == 'creditCard') {
- $minOffset = $dao->start;
- $maxOffset = $dao->end;
$date['format'] = $dao->date_format;
- $date['addEmptyOption'] = TRUE;
- $date['emptyOptionText'] = ts('- select -');
- $date['emptyOptionValue'] = '';
+ $date['time'] = (bool) $dao->time_format;
}
if (empty($date['format'])) {
- $date['format'] = 'M d';
+ if ($context == 'Input') {
+ $date['format'] = Civi::settings()->get('dateInputFormat');
+ }
+ else {
+ $date['format'] = 'M d';
+ }
}
}
+ $date['smarty_view_format'] = CRM_Utils_Date::getDateFieldViewFormat($date['format']);
+ if (!isset($date['time'])) {
+ $date['time'] = FALSE;
+ }
+
$year = date('Y');
- $date['minYear'] = $year - $minOffset;
- $date['maxYear'] = $year + $maxOffset;
+ $date['minYear'] = $year - (int) $minOffset;
+ $date['maxYear'] = $year + (int) $maxOffset;
return $date;
}
* @return array
*/
public static function contributionTokens() {
- return array(
+ return array_merge(array(
'{contribution.contribution_id}' => ts('Contribution ID'),
'{contribution.total_amount}' => ts('Total Amount'),
'{contribution.fee_amount}' => ts('Fee Amount'),
//'{contribution.address_id}' => ts('Address ID'),
'{contribution.check_number}' => ts('Check Number'),
'{contribution.campaign}' => ts('Contribution Campaign'),
- );
+ ), CRM_Utils_Token::getCustomFieldTokens('contribution', TRUE));
}
/**
return $dateInputFormats;
}
- /**
- * Map date plugin and actual format that is used by PHP.
- *
- * @return array
- */
- public static function datePluginToPHPFormats() {
- $dateInputFormats = array(
- "mm/dd/yy" => 'm/d/Y',
- "dd/mm/yy" => 'd/m/Y',
- "yy-mm-dd" => 'Y-m-d',
- "dd-mm-yy" => 'd-m-Y',
- "dd.mm.yy" => 'd.m.Y',
- "M d, yy" => 'M j, Y',
- "d M yy" => 'j M Y',
- "MM d, yy" => 'F j, Y',
- "d MM yy" => 'j F Y',
- "DD, d MM yy" => 'l, j F Y',
- "mm/dd" => 'm/d',
- "dd-mm" => 'd-m',
- "yy-mm" => 'Y-m',
- "M yy" => 'M Y',
- "yy" => 'Y',
- );
- return $dateInputFormats;
- }
-
/**
* Time formats.
*