CRM-15105 fix for erroneous setting of status
[civicrm-core.git] / CRM / Core / SelectValues.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
232624b1 4 | CiviCRM version 4.4 |
6a488035
TO
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13 | |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
18 | |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
26*/
27
28/**
29 * One place to store frequently used values in Select Elements. Note that
30 * some of the below elements will be dynamic, so we'll probably have a
31 * smart caching scheme on a per domain basis
32 *
33 * @package CRM
34 * @copyright CiviCRM LLC (c) 2004-2013
35 * $Id$
36 *
37 */
38class CRM_Core_SelectValues {
39
40 /**CRM/Core/SelectValues.php
41 * different types of phones
42 * @static
43 */
44 static function &phoneType() {
45 static $phoneType = NULL;
46 if (!$phoneType) {
47 $phoneType = array(
48 '' => ts('- select -'),
49 'Phone' => ts('Phone'),
50 'Mobile' => ts('Mobile'),
51 'Fax' => ts('Fax'),
52 'Pager' => ts('Pager'),
53 );
54 }
55 return $phoneType;
56 }
57
58 /**
59 * preferred mail format
60 * @static
61 */
62 static function &pmf() {
63 static $pmf = NULL;
64 if (!$pmf) {
65 $pmf = array(
66 'Both' => ts('Both'),
67 'HTML' => ts('HTML'),
68 'Text' => ts('Text'),
69 );
70 }
71 return $pmf;
72 }
73
74 /**
75 * privacy options
76 * @static
77 */
78 static function &privacy() {
79 static $privacy = NULL;
80 if (!$privacy) {
81 $privacy = array(
82 'do_not_phone' => ts('Do not phone'),
83 'do_not_email' => ts('Do not email'),
84 'do_not_mail' => ts('Do not mail'),
85 'do_not_sms' => ts('Do not sms'),
86 'do_not_trade' => ts('Do not trade'),
87 'is_opt_out' => ts('No bulk emails (User Opt Out)'),
88 );
89 }
90 return $privacy;
91 }
92
93 /**
94 * various pre defined contact super types
95 * @static
96 */
97 static function &contactType() {
98 static $contactType = NULL;
99 if (!$contactType) {
694e78fd 100 $contactType = CRM_Contact_BAO_ContactType::basicTypePairs();
6a488035
TO
101 }
102 return $contactType;
103 }
104
105 /**
106 * various pre defined unit list
107 * @static
108 */
109 static function &unitList($unitType = NULL) {
110 static $unitList = NULL;
111 if (!$unitList) {
112 $unitList = array(
113 '' => ts('- select -'),
114 'day' => ts('day'),
115 'month' => ts('month'),
116 'year' => ts('year'),
117 );
118 if ($unitType == 'duration') {
119 $unitAdd = array(
120 'lifetime' => ts('lifetime'),
121 );
122 $unitList = array_merge($unitList, $unitAdd);
123 }
124 }
125 return $unitList;
126 }
127
128 /**
129 * various pre defined period types
130 * @static
131 */
132 static function &periodType() {
133 static $periodType = NULL;
134 if (!$periodType) {
135 $periodType = array(
136 '' => ts('- select -'),
137 'rolling' => ts('rolling'),
138 'fixed' => ts('fixed'),
139 );
140 }
141 return $periodType;
142 }
143
144 /**
145 * various pre defined member visibility options
146 * @static
147 */
148 static function &memberVisibility() {
149 static $visible = NULL;
150 if (!$visible) {
151 $visible = array(
152 'Public' => ts('Public'),
153 'Admin' => ts('Admin'),
154 );
155 }
156 return $visible;
157 }
158
159 /**
160 * various pre defined event dates
161 * @static
162 */
163 static function &eventDate() {
164 static $eventDate = NULL;
165 if (!$eventDate) {
166 $eventDate = array(
167 '' => ts('- select -'),
168 'start_date' => ts('start date'),
169 'end_date' => ts('end date'),
170 'join_date' => ts('member since'),
171 );
172 }
173 return $eventDate;
174 }
175
176 /**
177 * Extended property (custom field) data types
178 * @static
179 */
180 static function &customDataType() {
181 static $customDataType = NULL;
182 if (!$customDataType) {
183 $customDataType = array(
184 '' => ts('- select -'),
185 'String' => ts('Text'),
186 'Int' => ts('Integer'),
187 'Float' => ts('Decimal Number'),
188 'Money' => ts('Money'),
189 'Text' => ts('Memo'),
190 'Date' => ts('Date'),
191 'File' => ts('File'),
192 'Boolean' => ts('Yes/No'),
193 'Link' => ts('Link'),
194 'Auto-complete' => ts('Auto-complete'),
195 );
196 }
197 return $customDataType;
198 }
199
200 /**
201 * Custom form field types
202 * @static
203 */
204 static function &customHtmlType() {
205 static $customHtmlType = NULL;
206 if (!$customHtmlType) {
207 $customHtmlType = array(
208 '' => ts('- select -'),
209 'Text' => ts('Single-line input field (text or numeric)'),
210 'TextArea' => ts('Multi-line text box (textarea)'),
211 'Select' => ts('Drop-down (select list)'),
212 'Radio' => ts('Radio buttons'),
213 'Checkbox' => ts('Checkbox(es)'),
214 'Select Date' => ts('Date selector'),
215 'File' => ts('File'),
216 'Select State / Province' => ts('State / Province selector'),
217 'Select Country' => ts('Country selector'),
218 'RichTextEditor' => ts('Rich Text Editor'),
219 'Auto-complete' => ts('Contact Reference'),
220 );
221 }
222 return $customHtmlType;
223 }
224
225 /**
226 * various pre defined extensions for dynamic properties and groups
227 *
228 * @static
229 */
230 static function &customGroupExtends() {
231 static $customGroupExtends = NULL;
232 if (!$customGroupExtends) {
233 $customGroupExtends = array(
234 'Activity' => ts('Activities'),
235 'Relationship' => ts('Relationships'),
236 'Contribution' => ts('Contributions'),
237 'Group' => ts('Groups'),
238 'Membership' => ts('Memberships'),
239 'Event' => ts('Events'),
240 'Participant' => ts('Participants'),
241 'ParticipantRole' => ts('Participants (Role)'),
242 'ParticipantEventName' => ts('Participants (Event Name)'),
243 'ParticipantEventType' => ts('Participants (Event Type)'),
244 'Pledge' => ts('Pledges'),
245 'Grant' => ts('Grants'),
246 'Address' => ts('Addresses'),
247 'Campaign' => ts('Campaigns'),
248 );
249 $contactTypes = self::contactType();
6a488035
TO
250 $contactTypes = !empty($contactTypes) ? array('Contact' => 'Contacts') + $contactTypes : array();
251 $extendObjs = CRM_Core_OptionGroup::values('cg_extend_objects');
252 $customGroupExtends = array_merge($contactTypes, $customGroupExtends, $extendObjs);
253 }
254 return $customGroupExtends;
255 }
256
257 /**
258 * styles for displaying the custom data group
259 *
260 * @static
261 */
262 static function &customGroupStyle() {
263 static $customGroupStyle = NULL;
264 if (!$customGroupStyle) {
265 $customGroupStyle = array(
266 'Tab' => ts('Tab'),
267 'Inline' => ts('Inline'),
268 );
269 }
270 return $customGroupStyle;
271 }
272
273 /**
274 * for displaying the uf group types
275 *
276 * @static
277 */
278 static function &ufGroupTypes() {
279 static $ufGroupType = NULL;
280 if (!$ufGroupType) {
281 $ufGroupType = array(
282 'Profile' => ts('Standalone Form or Directory'),
283 'Search Profile' => ts('Search Views'),
284 );
285 $config = CRM_Core_Config::singleton();
286 if ($config->userSystem->supports_form_extensions) {
287 $ufGroupType += array(
288 'User Registration' => ts('Drupal User Registration'),
289 'User Account' => ts('View/Edit Drupal User Account'),
290 );
291 }
292 }
293 return $ufGroupType;
294 }
295
296 /**
297 * the status of a contact within a group
298 *
299 * @static
300 */
301 static function &groupContactStatus() {
302 static $groupContactStatus = NULL;
303 if (!$groupContactStatus) {
304 $groupContactStatus = array(
305 'Added' => ts('Added'),
306 'Removed' => ts('Removed'),
307 'Pending' => ts('Pending'),
308 );
309 }
310 return $groupContactStatus;
311 }
312
313 /**
314 * list of Group Types
315 * @static
316 */
317 static function &groupType() {
318 static $groupType = NULL;
319 if (!$groupType) {
320 $groupType = array(
321 'query' => ts('Dynamic'),
322 'static' => ts('Static'),
323 );
324 }
325 return $groupType;
326 }
327
328 /**
329 * compose the parameters for a date select object
330 *
331 * @param $type the type of date
332 * @param $format date format ( QF format)
333 *
334 * @return array the date array
335 * @static
336 */
337 static function &date($type = NULL, $format = NULL, $minOffset = NULL, $maxOffset = NULL) {
338
339 $date = array(
340 'addEmptyOption' => TRUE,
341 'emptyOptionText' => ts('- select -'),
342 'emptyOptionValue' => '',
343 );
344
345 if ($format) {
346 $date['format'] = $format;
347 }
348 else {
349 if ($type) {
350 $dao = new CRM_Core_DAO_PreferencesDate();
351 $dao->name = $type;
352 if (!$dao->find(TRUE)) {
353 CRM_Core_Error::fatal();
354 }
355 }
356
357 if ($type == 'creditCard') {
358 $minOffset = $dao->start;
359 $maxOffset = $dao->end;
360 $date['format'] = $dao->date_format;
361 $date['addEmptyOption'] = TRUE;
362 $date['emptyOptionText'] = ts('- select -');
363 $date['emptyOptionValue'] = '';
364 }
365
366 if (!CRM_Utils_Array::value('format', $date)) {
367 $date['format'] = 'M d';
368 }
369 }
370
371 $year = date('Y');
372 $date['minYear'] = $year - $minOffset;
373 $date['maxYear'] = $year + $maxOffset;
374 return $date;
375 }
376
377 /**
378 * values for UF form visibility options
379 *
380 * @static
381 */
382 static function ufVisibility($isGroup = FALSE) {
383 static $_visibility = NULL;
384 if (!$_visibility) {
385 $_visibility = array(
386 'User and User Admin Only' => ts('User and User Admin Only'),
387 'Public Pages' => ts('Public Pages'),
388 'Public Pages and Listings' => ts('Public Pages and Listings'),
389 );
390 if ($isGroup) {
391 unset($_visibility['Public Pages and Listings']);
392 }
393 }
394 return $_visibility;
395 }
396
397 /**
398 * different type of Mailing Components
399 *
400 * @static
401 * return array
402 */
403 static function &mailingComponents() {
404 static $components = NULL;
405
406 if (!$components) {
407 $components = array('Header' => ts('Header'),
408 'Footer' => ts('Footer'),
409 'Reply' => ts('Reply Auto-responder'),
410 'OptOut' => ts('Opt-out Message'),
411 'Subscribe' => ts('Subscription Confirmation Request'),
412 'Welcome' => ts('Welcome Message'),
413 'Unsubscribe' => ts('Unsubscribe Message'),
414 'Resubscribe' => ts('Resubscribe Message'),
415 );
416 }
417 return $components;
418 }
419
420 /**
421 * Function to get hours
422 *
423 *
424 * @static
425 */
426 function getHours() {
427 for ($i = 0; $i <= 6; $i++) {
428 $hours[$i] = $i;
429 }
430 return $hours;
431 }
432
433 /**
434 * Function to get minutes
435 *
436 *
437 * @static
438 */
439 function getMinutes() {
440 for ($i = 0; $i < 60; $i = $i + 15) {
441 $minutes[$i] = $i;
442 }
443 return $minutes;
444 }
445
446 /**
447 * Function to get the Map Provider
448 *
449 * @return array $map array of map providers
450 * @static
451 */
452 static function mapProvider() {
453 static $map = NULL;
454 if (!$map) {
455 return CRM_Utils_System::getPluginList('templates/CRM/Contact/Form/Task/Map', ".tpl");
456 }
457 return $map;
458 }
459
460 /**
461 * Function to get the Geocoding Providers from available plugins
462 *
463 * @return array $geo array of geocoder providers
464 * @static
465 */
466 static function geoProvider() {
467 static $geo = NULL;
468 if (!$geo) {
469 return CRM_Utils_System::getPluginList('CRM/Utils/Geocode');
470 }
471 return $geo;
472 }
473
474 /**
475 * Function to get the Address Standardization Providers from available
476 * plugins
477 *
478 * @return array $addr array of address standardization providers
479 * @static
480 */
481 static function addressProvider() {
482 static $addr = NULL;
483 if (!$addr) {
484 return CRM_Utils_System::getPluginList('CRM/Utils/Address',
485 '.php',
486 array('BatchUpdate')
487 );
488 }
489 return $addr;
490 }
491
492 /**
493 * different type of Mailing Tokens
494 *
495 * @static
496 * return array
497 */
498 static function &mailingTokens() {
499 static $tokens = NULL;
500
501 if (!$tokens) {
502 $tokens = array('{action.unsubscribe}' => ts('Unsubscribe via email'),
503 '{action.unsubscribeUrl}' => ts('Unsubscribe via web page'),
504 '{action.resubscribe}' => ts('Resubscribe via email'),
505 '{action.resubscribeUrl}' => ts('Resubscribe via web page'),
506 '{action.optOut}' => ts('Opt out via email'),
507 '{action.optOutUrl}' => ts('Opt out via web page'),
508 '{action.forward}' => ts('Forward this email (link)'),
509 '{action.reply}' => ts('Reply to this email (link)'),
510 '{action.subscribeUrl}' => ts('Subscribe via web page'),
511 '{domain.name}' => ts('Domain name'),
512 '{domain.address}' => ts('Domain (organization) address'),
513 '{domain.phone}' => ts('Domain (organization) phone'),
514 '{domain.email}' => ts('Domain (organization) email'),
515 '{mailing.name}' => ts('Mailing name'),
516 '{mailing.group}' => ts('Mailing group'),
517 '{mailing.viewUrl}' => ts('Mailing permalink'),
518 );
519 }
520 return $tokens;
521 }
522
523 /**
524 * different type of Activity Tokens
525 *
526 * @static
527 * return array
528 */
529 static function &activityTokens() {
530 static $tokens = NULL;
531
532 if (!$tokens) {
533 $tokens = array(
534 '{activity.activity_id}' => ts('Activity ID'),
535 '{activity.subject}' => ts('Activity Subject'),
536 '{activity.details}' => ts('Activity Details'),
537 '{activity.activity_date_time}' => ts('Activity Date Time'),
538 );
539 }
540 return $tokens;
541 }
542
543 /**
544 * different type of Membership Tokens
545 *
546 * @static
547 * return array
548 */
549 static function &membershipTokens() {
550 static $tokens = NULL;
551
552 if (!$tokens) {
553 $tokens = array(
554 '{membership.id}' => ts('Membership ID'),
555 '{membership.status}' => ts('Membership Status'),
556 '{membership.type}' => ts('Membership Type'),
557 '{membership.start_date}' => ts('Membership Start Date'),
558 '{membership.join_date}' => ts('Membership Join Date'),
559 '{membership.end_date}' => ts('Membership End Date'),
560 '{membership.fee}' => ts('Membership Fee'),
561 );
562 }
563 return $tokens;
564 }
565
566 /**
567 * different type of Event Tokens
568 *
569 * @static
570 * return array
571 */
572 static function &eventTokens() {
573 static $tokens = NULL;
574
575 if (!$tokens) {
576 $tokens = array(
577 '{event.event_id}' => ts('Event ID'),
578 '{event.title}' => ts('Event Title'),
579 '{event.start_date}' => ts('Event Start Date'),
580 '{event.end_date}' => ts('Event End Date'),
581 '{event.event_type}' => ts('Event Type'),
582 '{event.summary}' => ts('Event Summary'),
583 '{event.description}' => ts('Event Description'),
584 '{event.contact_email}' => ts('Event Contact Email'),
585 '{event.contact_phone}' => ts('Event Contact Phone'),
586 '{event.location}' => ts('Event Location'),
587 '{event.description}' => ts('Event Description'),
588 '{event.location}' => ts('Event Location'),
589 '{event.fee_amount}' => ts('Event Fees'),
590 '{event.info_url}' => ts('Event Info URL'),
591 '{event.registration_url}' => ts('Event Registration URL'),
592 );
593 }
594 return $tokens;
595 }
596
597 /**
598 * different type of Event Tokens
599 *
600 * @static
601 * return array
602 */
603 static function &contributionTokens() {
604 static $tokens = NULL;
605
606 if (!$tokens) {
607 $tokens = array(
608 '{contribution.contribution_id}' => ts('Contribution ID'),
609 '{contribution.total_amount}' => ts('Total Amount'),
610 '{contribution.fee_amount}' => ts('Fee Amount'),
611 '{contribution.net_amount}' => ts('Net Amount'),
612 '{contribution.non_deductible_amount}' => ts('Non Deductible Amount'),
613 '{contribution.receive_date}' => ts('Contribution Receive Date'),
614 '{contribution.payment_instrument}' => ts('Payment Instrument'),
615 '{contribution.trxn_id}' => ts('Transaction ID'),
616 '{contribution.invoice_id}' => ts('Invoice ID'),
617 '{contribution.currency}' => ts('Currency'),
618 '{contribution.cancel_date}' => ts('Contribution Cancel Date'),
619 '{contribution.cancel_reason}' => ts('Contribution Cancel Reason'),
620 '{contribution.receipt_date}' => ts('Receipt Date'),
621 '{contribution.thankyou_date}' => ts('Thank You Date'),
622 '{contribution.contribution_source}' => ts('Contribution Source'),
623 '{contribution.amount_level}' => ts('Amount Level'),
624 //'{contribution.contribution_recur_id}' => ts('Contribution Recurring ID'),
625 //'{contribution.honor_contact_id}' => ts('Honor Contact ID'),
626 '{contribution.contribution_status_id}' => ts('Contribution Status'),
627 //'{contribution.honor_type_id}' => ts('Honor Type ID'),
628 //'{contribution.address_id}' => ts('Address ID'),
629 '{contribution.check_number}' => ts('Check Number'),
630 '{contribution.campaign}' => ts('Contribution Campaign'),
631 );
632 }
633 return $tokens;
634 }
635
636 /**
637 * different type of Contact Tokens
638 *
639 * @static
640 * return array
641 */
642 static function &contactTokens() {
643 static $tokens = NULL;
644 if (!$tokens) {
645 $additionalFields = array('checksum' => array('title' => ts('Checksum')),
646 'contact_id' => array('title' => ts('Internal Contact ID')),
647 );
648 $exportFields = array_merge(CRM_Contact_BAO_Contact::exportableFields(), $additionalFields);
649
650 $values = array_merge(array_keys($exportFields));
651 unset($values[0]);
652
653 //FIXME:skipping some tokens for time being.
654 $skipTokens = array(
655 'is_bulkmail', 'group', 'tag', 'contact_sub_type', 'note',
656 'is_deceased', 'deceased_date', 'legal_identifier', 'contact_sub_type', 'user_unique_id',
657 );
ea921622 658
6a488035
TO
659 $customFields = CRM_Core_BAO_CustomField::getFields('Individual');
660 $customFieldsAddress = CRM_Core_BAO_CustomField::getFields('Address');
661 $customFields = $customFields + $customFieldsAddress;
cc615373 662 $legacyTokenNames = array_flip(CRM_Utils_Token::legacyContactTokens());
6a488035 663
cc615373 664 foreach ($values as $val) {
6a488035
TO
665 if (in_array($val, $skipTokens)) {
666 continue;
667 }
668 //keys for $tokens should be constant. $token Values are changed for Custom Fields. CRM-3734
669 if ($customFieldId = CRM_Core_BAO_CustomField::getKeyID($val)) {
670 $tokens["{contact.$val}"] = CRM_Utils_Array::value($customFieldId, $customFields) ? $customFields[$customFieldId]['label'] . " :: " . $customFields[$customFieldId]['groupTitle'] : '';
671 }
672 else {
cc615373
CW
673 // Support legacy token names
674 $tokenName = CRM_Utils_Array::value($val, $legacyTokenNames, $val);
675 $tokens["{contact.$tokenName}"] = $exportFields[$val]['title'];
6a488035
TO
676 }
677 }
678
679 // might as well get all the hook tokens to
680 $hookTokens = array();
681 CRM_Utils_Hook::tokens($hookTokens);
682 foreach ($hookTokens as $category => $tokenValues) {
683 foreach ($tokenValues as $key => $value) {
684 if (is_numeric($key)) {
685 $key = $value;
686 }
687 if (!preg_match('/^\{[^\}]+\}$/', $key)) {
688 $key = '{' . $key . '}';
689 }
690 if (preg_match('/^\{([^\}]+)\}$/', $value, $matches)) {
691 $value = $matches[1];
692 }
693 $tokens[$key] = $value;
694 }
695 }
696 }
697
698 return $tokens;
699 }
700
ea921622
KJ
701 /**
702 * different type of Participant Tokens
703 *
704 * @static
705 * return array
706 */
707 static function &participantTokens() {
708 static $tokens = NULL;
709 if (!$tokens) {
710 $exportFields = CRM_Event_BAO_Participant::exportableFields();
711
712 $values = array_merge(array_keys($exportFields));
713 unset($values[0]);
714
715 // skipping some tokens for time being.
716 $skipTokens = array(
717 'event_id', 'participant_is_pay_later', 'participant_is_test', 'participant_contact_id',
718 'participant_fee_currency', 'participant_campaign_id', 'participant_status', 'participant_discount_name',
719 );
720
721 $customFields = CRM_Core_BAO_CustomField::getFields('Participant');
722
723 foreach ($values as $key => $val) {
724 if (in_array($val, $skipTokens)) {
725 continue;
726 }
727 //keys for $tokens should be constant. $token Values are changed for Custom Fields. CRM-3734
728 if ($customFieldId = CRM_Core_BAO_CustomField::getKeyID($val)) {
729 $tokens["{participant.$val}"] = CRM_Utils_Array::value($customFieldId, $customFields) ? $customFields[$customFieldId]['label'] . " :: " . $customFields[$customFieldId]['groupTitle'] : '';
730 }
731 else {
732 $tokens["{participant.$val}"] = $exportFields[$val]['title'];
733 }
734 }
735 }
736 return $tokens;
737 }
738
6a488035
TO
739 /**
740 * get qf mappig for all date parts.
741 *
742 */
743 static function &qfDatePartsMapping() {
744 static $qfDatePartsMapping = NULL;
745 if (!$qfDatePartsMapping) {
746 $qfDatePartsMapping = array(
747 '%b' => 'M',
748 '%B' => 'F',
749 '%d' => 'd',
750 '%e' => 'j',
751 '%E' => 'j',
752 '%f' => 'S',
753 '%H' => 'H',
754 '%I' => 'h',
755 '%k' => 'G',
756 '%l' => 'g',
757 '%m' => 'm',
758 '%M' => 'i',
759 '%p' => 'a',
760 '%P' => 'A',
761 '%Y' => 'Y',
762 );
763 }
764
765 return $qfDatePartsMapping;
766 }
767
768 /**
769 * CiviCRM supported date input formats
770 */
771 static function getDatePluginInputFormats() {
772 $dateInputFormats = array(
773 "mm/dd/yy" => ts('mm/dd/yyyy (12/31/2009)'),
774 "dd/mm/yy" => ts('dd/mm/yyyy (31/12/2009)'),
775 "yy-mm-dd" => ts('yyyy-mm-dd (2009-12-31)'),
776 "dd-mm-yy" => ts('dd-mm-yyyy (31-12-2009)'),
777 'dd.mm.yy' => ts('dd.mm.yyyy (31.12.2009)'),
778 "M d, yy" => ts('M d, yyyy (Dec 31, 2009)'),
779 'd M yy' => ts('d M yyyy (31 Dec 2009)'),
780 "MM d, yy" => ts('MM d, yyyy (December 31, 2009)'),
781 'd MM yy' => ts('d MM yyyy (31 December 2009)'),
782 "DD, d MM yy" => ts('DD, d MM yyyy (Thursday, 31 December 2009)'),
783 "mm/dd" => ts('mm/dd (12/31)'),
784 "dd-mm" => ts('dd-mm (31-12)'),
785 "yy-mm" => ts('yyyy-mm (2009-12)'),
786 'M yy' => ts('M yyyy (Dec 2009)'),
787 "yy" => ts('yyyy (2009)'),
788 );
789
790 /*
791 Year greater than 2000 get wrong result for following format
792 echo date( 'Y-m-d', strtotime( '7 Nov, 2001') );
793 echo date( 'Y-m-d', strtotime( '7 November, 2001') );
794 Return current year
795 expected :: 2001-11-07
796 output :: 2009-11-07
797 However
798 echo date( 'Y-m-d', strtotime( 'Nov 7, 2001') );
799 echo date( 'Y-m-d', strtotime( 'November 7, 2001') );
800 gives proper result
801 */
802
803
804 return $dateInputFormats;
805 }
806
807 /**
808 * Map date plugin and actual format that is used by PHP
809 */
810 static function datePluginToPHPFormats() {
811 $dateInputFormats = array(
812 "mm/dd/yy" => 'm/d/Y',
813 "dd/mm/yy" => 'd/m/Y',
814 "yy-mm-dd" => 'Y-m-d',
815 "dd-mm-yy" => 'd-m-Y',
816 "dd.mm.yy" => 'd.m.Y',
817 "M d, yy" => 'M j, Y',
818 "d M yy" => 'j M Y',
819 "MM d, yy" => 'F j, Y',
820 "d MM yy" => 'j F Y',
821 "DD, d MM yy" => 'l, j F Y',
822 "mm/dd" => 'm/d',
823 "dd-mm" => 'd-m',
824 "yy-mm" => 'Y-m',
825 "M yy" => 'M Y',
826 "yy" => 'Y',
827 );
828 return $dateInputFormats;
829 }
830
831 /**
832 * Time formats
833 */
834 static function getTimeFormats() {
835 $timeFormats = array('1' => ts('12 Hours'),
836 '2' => ts('24 Hours'),
837 );
838 return $timeFormats;
839 }
840
841 /**
842 * Function to get numeric options
843 *
844 *
845 * @static
846 */
847 public static function getNumericOptions($start = 0, $end = 10) {
848 for ($i = $start; $i <= $end; $i++) {
849 $numericOptions[$i] = $i;
850 }
851 return $numericOptions;
852 }
f38395f7
KJ
853
854 /**
855 * barcode types
856 * @static
857 */
858 static function getBarcodeTypes() {
859 static $barcodeTypes = NULL;
860 if (!$barcodeTypes) {
861 $barcodeTypes = array(
862 'barcode' => ts('Linear (1D)'),
863 'qrcode' => ts('QR code'),
864 );
865 }
866 return $barcodeTypes;
867 }
6a488035
TO
868}
869