Invoker cleanup - Move profile() to its own class
[civicrm-core.git] / CRM / Core / SelectValues.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.4 |
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 */
38 class 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) {
100 $contactType = CRM_Contact_BAO_ContactType::basicTypePairs();
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 * membership type unit
130 * @static
131 */
132 static function membershipTypeUnitList( ) {
133 static $membershipTypeUnitList = NULL;
134 if (!$membershipTypeUnitList) {
135 $membershipTypeUnitList = self::unitList('duration');
136 }
137 return $membershipTypeUnitList;
138 }
139
140 /**
141 * various pre defined period types
142 * @static
143 */
144 static function &periodType() {
145 static $periodType = NULL;
146 if (!$periodType) {
147 $periodType = array(
148 '' => ts('- select -'),
149 'rolling' => ts('Rolling'),
150 'fixed' => ts('Fixed'),
151 );
152 }
153 return $periodType;
154 }
155
156 /**
157 * various pre defined member visibility options
158 * @static
159 */
160 static function &memberVisibility() {
161 static $visible = NULL;
162 if (!$visible) {
163 $visible = array(
164 'Public' => ts('Public'),
165 'Admin' => ts('Admin'),
166 );
167 }
168 return $visible;
169 }
170
171 /**
172 * various pre defined event dates
173 * @static
174 */
175 static function &eventDate() {
176 static $eventDate = NULL;
177 if (!$eventDate) {
178 $eventDate = array(
179 '' => ts('- select -'),
180 'start_date' => ts('start date'),
181 'end_date' => ts('end date'),
182 'join_date' => ts('member since'),
183 );
184 }
185 return $eventDate;
186 }
187
188 /**
189 * Extended property (custom field) data types
190 * @static
191 */
192 static function &customDataType() {
193 static $customDataType = NULL;
194 if (!$customDataType) {
195 $customDataType = array(
196 '' => ts('- select -'),
197 'String' => ts('Text'),
198 'Int' => ts('Integer'),
199 'Float' => ts('Decimal Number'),
200 'Money' => ts('Money'),
201 'Text' => ts('Memo'),
202 'Date' => ts('Date'),
203 'File' => ts('File'),
204 'Boolean' => ts('Yes/No'),
205 'Link' => ts('Link'),
206 'Auto-complete' => ts('Auto-complete'),
207 );
208 }
209 return $customDataType;
210 }
211
212 /**
213 * Custom form field types
214 * @static
215 */
216 static function &customHtmlType() {
217 static $customHtmlType = NULL;
218 if (!$customHtmlType) {
219 $customHtmlType = array(
220 '' => ts('- select -'),
221 'Text' => ts('Single-line input field (text or numeric)'),
222 'TextArea' => ts('Multi-line text box (textarea)'),
223 'Select' => ts('Drop-down (select list)'),
224 'Radio' => ts('Radio buttons'),
225 'Checkbox' => ts('Checkbox(es)'),
226 'Select Date' => ts('Date selector'),
227 'File' => ts('File'),
228 'Select State / Province' => ts('State / Province selector'),
229 'Select Country' => ts('Country selector'),
230 'RichTextEditor' => ts('Rich Text Editor'),
231 'Auto-complete' => ts('Contact Reference'),
232 );
233 }
234 return $customHtmlType;
235 }
236
237 /**
238 * various pre defined extensions for dynamic properties and groups
239 *
240 * @static
241 */
242 static function &customGroupExtends() {
243 static $customGroupExtends = NULL;
244 if (!$customGroupExtends) {
245 $customGroupExtends = array(
246 'Activity' => ts('Activities'),
247 'Relationship' => ts('Relationships'),
248 'Contribution' => ts('Contributions'),
249 'Group' => ts('Groups'),
250 'Membership' => ts('Memberships'),
251 'Event' => ts('Events'),
252 'Participant' => ts('Participants'),
253 'ParticipantRole' => ts('Participants (Role)'),
254 'ParticipantEventName' => ts('Participants (Event Name)'),
255 'ParticipantEventType' => ts('Participants (Event Type)'),
256 'Pledge' => ts('Pledges'),
257 'Grant' => ts('Grants'),
258 'Address' => ts('Addresses'),
259 'Campaign' => ts('Campaigns'),
260 );
261 $contactTypes = self::contactType();
262 $contactTypes = !empty($contactTypes) ? array('Contact' => 'Contacts') + $contactTypes : array();
263 $extendObjs = CRM_Core_OptionGroup::values('cg_extend_objects');
264 $customGroupExtends = array_merge($contactTypes, $customGroupExtends, $extendObjs);
265 }
266 return $customGroupExtends;
267 }
268
269 /**
270 * styles for displaying the custom data group
271 *
272 * @static
273 */
274 static function &customGroupStyle() {
275 static $customGroupStyle = NULL;
276 if (!$customGroupStyle) {
277 $customGroupStyle = array(
278 'Tab' => ts('Tab'),
279 'Inline' => ts('Inline'),
280 'Tab with table' => ts('Tab with table')
281 );
282 }
283 return $customGroupStyle;
284 }
285
286 /**
287 * for displaying the uf group types
288 *
289 * @static
290 */
291 static function &ufGroupTypes() {
292 static $ufGroupType = NULL;
293 if (!$ufGroupType) {
294 $ufGroupType = array(
295 'Profile' => ts('Standalone Form or Directory'),
296 'Search Profile' => ts('Search Views'),
297 );
298 $config = CRM_Core_Config::singleton();
299 if ($config->userSystem->supports_form_extensions) {
300 $ufGroupType += array(
301 'User Registration' => ts('Drupal User Registration'),
302 'User Account' => ts('View/Edit Drupal User Account'),
303 );
304 }
305 }
306 return $ufGroupType;
307 }
308
309 /**
310 * the status of a contact within a group
311 *
312 * @static
313 */
314 static function &groupContactStatus() {
315 static $groupContactStatus = NULL;
316 if (!$groupContactStatus) {
317 $groupContactStatus = array(
318 'Added' => ts('Added'),
319 'Removed' => ts('Removed'),
320 'Pending' => ts('Pending'),
321 );
322 }
323 return $groupContactStatus;
324 }
325
326 /**
327 * list of Group Types
328 * @static
329 */
330 static function &groupType() {
331 static $groupType = NULL;
332 if (!$groupType) {
333 $groupType = array(
334 'query' => ts('Dynamic'),
335 'static' => ts('Static'),
336 );
337 }
338 return $groupType;
339 }
340
341 /**
342 * compose the parameters for a date select object
343 *
344 * @param $type the type of date
345 * @param $format date format ( QF format)
346 *
347 * @return array the date array
348 * @static
349 */
350 static function &date($type = NULL, $format = NULL, $minOffset = NULL, $maxOffset = NULL) {
351
352 $date = array(
353 'addEmptyOption' => TRUE,
354 'emptyOptionText' => ts('- select -'),
355 'emptyOptionValue' => '',
356 );
357
358 if ($format) {
359 $date['format'] = $format;
360 }
361 else {
362 if ($type) {
363 $dao = new CRM_Core_DAO_PreferencesDate();
364 $dao->name = $type;
365 if (!$dao->find(TRUE)) {
366 CRM_Core_Error::fatal();
367 }
368 }
369
370 if ($type == 'creditCard') {
371 $minOffset = $dao->start;
372 $maxOffset = $dao->end;
373 $date['format'] = $dao->date_format;
374 $date['addEmptyOption'] = TRUE;
375 $date['emptyOptionText'] = ts('- select -');
376 $date['emptyOptionValue'] = '';
377 }
378
379 if (empty($date['format'])) {
380 $date['format'] = 'M d';
381 }
382 }
383
384 $year = date('Y');
385 $date['minYear'] = $year - $minOffset;
386 $date['maxYear'] = $year + $maxOffset;
387 return $date;
388 }
389
390 /**
391 * values for UF form visibility options
392 *
393 * @static
394 */
395 static function ufVisibility($isGroup = FALSE) {
396 static $_visibility = NULL;
397 if (!$_visibility) {
398 $_visibility = array(
399 'User and User Admin Only' => ts('User and User Admin Only'),
400 'Public Pages' => ts('Public Pages'),
401 'Public Pages and Listings' => ts('Public Pages and Listings'),
402 );
403 if ($isGroup) {
404 unset($_visibility['Public Pages and Listings']);
405 }
406 }
407 return $_visibility;
408 }
409
410 /**
411 * values for group form visibility options
412 *
413 * @static
414 */
415 static function groupVisibility() {
416 static $_groupVisibility = NULL;
417 if (!$_groupVisibility) {
418 $_groupVisibility = self::ufVisibility(true);
419 }
420 return $_groupVisibility;
421 }
422
423 /**
424 * different type of Mailing Components
425 *
426 * @static
427 * return array
428 */
429 static function &mailingComponents() {
430 static $components = NULL;
431
432 if (!$components) {
433 $components = array('Header' => ts('Header'),
434 'Footer' => ts('Footer'),
435 'Reply' => ts('Reply Auto-responder'),
436 'OptOut' => ts('Opt-out Message'),
437 'Subscribe' => ts('Subscription Confirmation Request'),
438 'Welcome' => ts('Welcome Message'),
439 'Unsubscribe' => ts('Unsubscribe Message'),
440 'Resubscribe' => ts('Resubscribe Message'),
441 );
442 }
443 return $components;
444 }
445
446 /**
447 * Function to get hours
448 *
449 *
450 * @static
451 */
452 function getHours() {
453 for ($i = 0; $i <= 6; $i++) {
454 $hours[$i] = $i;
455 }
456 return $hours;
457 }
458
459 /**
460 * Function to get minutes
461 *
462 *
463 * @static
464 */
465 function getMinutes() {
466 for ($i = 0; $i < 60; $i = $i + 15) {
467 $minutes[$i] = $i;
468 }
469 return $minutes;
470 }
471
472 /**
473 * Function to get the Map Provider
474 *
475 * @return array $map array of map providers
476 * @static
477 */
478 static function mapProvider() {
479 static $map = NULL;
480 if (!$map) {
481 return CRM_Utils_System::getPluginList('templates/CRM/Contact/Form/Task/Map', ".tpl");
482 }
483 return $map;
484 }
485
486 /**
487 * Function to get the Geocoding Providers from available plugins
488 *
489 * @return array $geo array of geocoder providers
490 * @static
491 */
492 static function geoProvider() {
493 static $geo = NULL;
494 if (!$geo) {
495 return CRM_Utils_System::getPluginList('CRM/Utils/Geocode');
496 }
497 return $geo;
498 }
499
500 /**
501 * Function to get the Address Standardization Providers from available
502 * plugins
503 *
504 * @return array $addr array of address standardization providers
505 * @static
506 */
507 static function addressProvider() {
508 static $addr = NULL;
509 if (!$addr) {
510 return CRM_Utils_System::getPluginList('CRM/Utils/Address',
511 '.php',
512 array('BatchUpdate')
513 );
514 }
515 return $addr;
516 }
517
518 /**
519 * different type of Mailing Tokens
520 *
521 * @static
522 * return array
523 */
524 static function &mailingTokens() {
525 static $tokens = NULL;
526
527 if (!$tokens) {
528 $tokens = array('{action.unsubscribe}' => ts('Unsubscribe via email'),
529 '{action.unsubscribeUrl}' => ts('Unsubscribe via web page'),
530 '{action.resubscribe}' => ts('Resubscribe via email'),
531 '{action.resubscribeUrl}' => ts('Resubscribe via web page'),
532 '{action.optOut}' => ts('Opt out via email'),
533 '{action.optOutUrl}' => ts('Opt out via web page'),
534 '{action.forward}' => ts('Forward this email (link)'),
535 '{action.reply}' => ts('Reply to this email (link)'),
536 '{action.subscribeUrl}' => ts('Subscribe via web page'),
537 '{domain.name}' => ts('Domain name'),
538 '{domain.address}' => ts('Domain (organization) address'),
539 '{domain.phone}' => ts('Domain (organization) phone'),
540 '{domain.email}' => ts('Domain (organization) email'),
541 '{mailing.name}' => ts('Mailing name'),
542 '{mailing.group}' => ts('Mailing group'),
543 '{mailing.viewUrl}' => ts('Mailing permalink'),
544 );
545 }
546 return $tokens;
547 }
548
549 /**
550 * different type of Activity Tokens
551 *
552 * @static
553 * return array
554 */
555 static function &activityTokens() {
556 static $tokens = NULL;
557
558 if (!$tokens) {
559 $tokens = array(
560 '{activity.activity_id}' => ts('Activity ID'),
561 '{activity.subject}' => ts('Activity Subject'),
562 '{activity.details}' => ts('Activity Details'),
563 '{activity.activity_date_time}' => ts('Activity Date Time'),
564 );
565 }
566 return $tokens;
567 }
568
569 /**
570 * different type of Membership Tokens
571 *
572 * @static
573 * return array
574 */
575 static function &membershipTokens() {
576 static $tokens = NULL;
577
578 if (!$tokens) {
579 $tokens = array(
580 '{membership.id}' => ts('Membership ID'),
581 '{membership.status}' => ts('Membership Status'),
582 '{membership.type}' => ts('Membership Type'),
583 '{membership.start_date}' => ts('Membership Start Date'),
584 '{membership.join_date}' => ts('Membership Join Date'),
585 '{membership.end_date}' => ts('Membership End Date'),
586 '{membership.fee}' => ts('Membership Fee'),
587 );
588 }
589 return $tokens;
590 }
591
592 /**
593 * different type of Event Tokens
594 *
595 * @static
596 * return array
597 */
598 static function &eventTokens() {
599 static $tokens = NULL;
600
601 if (!$tokens) {
602 $tokens = array(
603 '{event.event_id}' => ts('Event ID'),
604 '{event.title}' => ts('Event Title'),
605 '{event.start_date}' => ts('Event Start Date'),
606 '{event.end_date}' => ts('Event End Date'),
607 '{event.event_type}' => ts('Event Type'),
608 '{event.summary}' => ts('Event Summary'),
609 '{event.description}' => ts('Event Description'),
610 '{event.contact_email}' => ts('Event Contact Email'),
611 '{event.contact_phone}' => ts('Event Contact Phone'),
612 '{event.location}' => ts('Event Location'),
613 '{event.description}' => ts('Event Description'),
614 '{event.location}' => ts('Event Location'),
615 '{event.fee_amount}' => ts('Event Fees'),
616 '{event.info_url}' => ts('Event Info URL'),
617 '{event.registration_url}' => ts('Event Registration URL'),
618 '{event.balance}' => ts('Event Balance')
619 );
620 }
621 return $tokens;
622 }
623
624 /**
625 * different type of Event Tokens
626 *
627 * @static
628 * return array
629 */
630 static function &contributionTokens() {
631 static $tokens = NULL;
632
633 if (!$tokens) {
634 $tokens = array(
635 '{contribution.contribution_id}' => ts('Contribution ID'),
636 '{contribution.total_amount}' => ts('Total Amount'),
637 '{contribution.fee_amount}' => ts('Fee Amount'),
638 '{contribution.net_amount}' => ts('Net Amount'),
639 '{contribution.non_deductible_amount}' => ts('Non Deductible Amount'),
640 '{contribution.receive_date}' => ts('Contribution Receive Date'),
641 '{contribution.payment_instrument}' => ts('Payment Instrument'),
642 '{contribution.trxn_id}' => ts('Transaction ID'),
643 '{contribution.invoice_id}' => ts('Invoice ID'),
644 '{contribution.currency}' => ts('Currency'),
645 '{contribution.cancel_date}' => ts('Contribution Cancel Date'),
646 '{contribution.cancel_reason}' => ts('Contribution Cancel Reason'),
647 '{contribution.receipt_date}' => ts('Receipt Date'),
648 '{contribution.thankyou_date}' => ts('Thank You Date'),
649 '{contribution.contribution_source}' => ts('Contribution Source'),
650 '{contribution.amount_level}' => ts('Amount Level'),
651 //'{contribution.contribution_recur_id}' => ts('Contribution Recurring ID'),
652 //'{contribution.honor_contact_id}' => ts('Honor Contact ID'),
653 '{contribution.contribution_status_id}' => ts('Contribution Status'),
654 //'{contribution.honor_type_id}' => ts('Honor Type ID'),
655 //'{contribution.address_id}' => ts('Address ID'),
656 '{contribution.check_number}' => ts('Check Number'),
657 '{contribution.campaign}' => ts('Contribution Campaign'),
658 );
659 }
660 return $tokens;
661 }
662
663 /**
664 * different type of Contact Tokens
665 *
666 * @static
667 * return array
668 */
669 static function &contactTokens() {
670 static $tokens = NULL;
671 if (!$tokens) {
672 $additionalFields = array('checksum' => array('title' => ts('Checksum')),
673 'contact_id' => array('title' => ts('Internal Contact ID')),
674 );
675 $exportFields = array_merge(CRM_Contact_BAO_Contact::exportableFields(), $additionalFields);
676
677 $values = array_merge(array_keys($exportFields));
678 unset($values[0]);
679
680 //FIXME:skipping some tokens for time being.
681 $skipTokens = array(
682 'is_bulkmail', 'group', 'tag', 'contact_sub_type', 'note',
683 'is_deceased', 'deceased_date', 'legal_identifier', 'contact_sub_type', 'user_unique_id',
684 );
685
686 $customFields = CRM_Core_BAO_CustomField::getFields('Individual');
687 $customFieldsAddress = CRM_Core_BAO_CustomField::getFields('Address');
688 $customFields = $customFields + $customFieldsAddress;
689 $legacyTokenNames = array_flip(CRM_Utils_Token::legacyContactTokens());
690
691 foreach ($values as $val) {
692 if (in_array($val, $skipTokens)) {
693 continue;
694 }
695 //keys for $tokens should be constant. $token Values are changed for Custom Fields. CRM-3734
696 if ($customFieldId = CRM_Core_BAO_CustomField::getKeyID($val)) {
697 $tokens["{contact.$val}"] = !empty($customFields[$customFieldId]) ? $customFields[$customFieldId]['label'] . " :: " . $customFields[$customFieldId]['groupTitle'] : '';
698 }
699 else {
700 // Support legacy token names
701 $tokenName = CRM_Utils_Array::value($val, $legacyTokenNames, $val);
702 $tokens["{contact.$tokenName}"] = $exportFields[$val]['title'];
703 }
704 }
705
706 // might as well get all the hook tokens to
707 $hookTokens = array();
708 CRM_Utils_Hook::tokens($hookTokens);
709 foreach ($hookTokens as $category => $tokenValues) {
710 foreach ($tokenValues as $key => $value) {
711 if (is_numeric($key)) {
712 $key = $value;
713 }
714 if (!preg_match('/^\{[^\}]+\}$/', $key)) {
715 $key = '{' . $key . '}';
716 }
717 if (preg_match('/^\{([^\}]+)\}$/', $value, $matches)) {
718 $value = $matches[1];
719 }
720 $tokens[$key] = $value;
721 }
722 }
723 }
724
725 return $tokens;
726 }
727
728 /**
729 * different type of Participant Tokens
730 *
731 * @static
732 * return array
733 */
734 static function &participantTokens() {
735 static $tokens = NULL;
736 if (!$tokens) {
737 $exportFields = CRM_Event_BAO_Participant::exportableFields();
738
739 $values = array_merge(array_keys($exportFields));
740 unset($values[0]);
741
742 // skipping some tokens for time being.
743 $skipTokens = array(
744 'event_id', 'participant_is_pay_later', 'participant_is_test', 'participant_contact_id',
745 'participant_fee_currency', 'participant_campaign_id', 'participant_status', 'participant_discount_name',
746 );
747
748 $customFields = CRM_Core_BAO_CustomField::getFields('Participant');
749
750 foreach ($values as $key => $val) {
751 if (in_array($val, $skipTokens)) {
752 continue;
753 }
754 //keys for $tokens should be constant. $token Values are changed for Custom Fields. CRM-3734
755 if ($customFieldId = CRM_Core_BAO_CustomField::getKeyID($val)) {
756 $tokens["{participant.$val}"] = !empty($customFields[$customFieldId]) ? $customFields[$customFieldId]['label'] . " :: " . $customFields[$customFieldId]['groupTitle'] : '';
757 }
758 else {
759 $tokens["{participant.$val}"] = $exportFields[$val]['title'];
760 }
761 }
762 }
763 return $tokens;
764 }
765
766 /**
767 * get qf mappig for all date parts.
768 *
769 */
770 static function &qfDatePartsMapping() {
771 static $qfDatePartsMapping = NULL;
772 if (!$qfDatePartsMapping) {
773 $qfDatePartsMapping = array(
774 '%b' => 'M',
775 '%B' => 'F',
776 '%d' => 'd',
777 '%e' => 'j',
778 '%E' => 'j',
779 '%f' => 'S',
780 '%H' => 'H',
781 '%I' => 'h',
782 '%k' => 'G',
783 '%l' => 'g',
784 '%m' => 'm',
785 '%M' => 'i',
786 '%p' => 'a',
787 '%P' => 'A',
788 '%Y' => 'Y',
789 );
790 }
791
792 return $qfDatePartsMapping;
793 }
794
795 /**
796 * CiviCRM supported date input formats
797 */
798 static function getDatePluginInputFormats() {
799 $dateInputFormats = array(
800 "mm/dd/yy" => ts('mm/dd/yyyy (12/31/2009)'),
801 "dd/mm/yy" => ts('dd/mm/yyyy (31/12/2009)'),
802 "yy-mm-dd" => ts('yyyy-mm-dd (2009-12-31)'),
803 "dd-mm-yy" => ts('dd-mm-yyyy (31-12-2009)'),
804 'dd.mm.yy' => ts('dd.mm.yyyy (31.12.2009)'),
805 "M d, yy" => ts('M d, yyyy (Dec 31, 2009)'),
806 'd M yy' => ts('d M yyyy (31 Dec 2009)'),
807 "MM d, yy" => ts('MM d, yyyy (December 31, 2009)'),
808 'd MM yy' => ts('d MM yyyy (31 December 2009)'),
809 "DD, d MM yy" => ts('DD, d MM yyyy (Thursday, 31 December 2009)'),
810 "mm/dd" => ts('mm/dd (12/31)'),
811 "dd-mm" => ts('dd-mm (31-12)'),
812 "yy-mm" => ts('yyyy-mm (2009-12)'),
813 'M yy' => ts('M yyyy (Dec 2009)'),
814 "yy" => ts('yyyy (2009)'),
815 );
816
817 /*
818 Year greater than 2000 get wrong result for following format
819 echo date( 'Y-m-d', strtotime( '7 Nov, 2001') );
820 echo date( 'Y-m-d', strtotime( '7 November, 2001') );
821 Return current year
822 expected :: 2001-11-07
823 output :: 2009-11-07
824 However
825 echo date( 'Y-m-d', strtotime( 'Nov 7, 2001') );
826 echo date( 'Y-m-d', strtotime( 'November 7, 2001') );
827 gives proper result
828 */
829
830
831 return $dateInputFormats;
832 }
833
834 /**
835 * Map date plugin and actual format that is used by PHP
836 */
837 static function datePluginToPHPFormats() {
838 $dateInputFormats = array(
839 "mm/dd/yy" => 'm/d/Y',
840 "dd/mm/yy" => 'd/m/Y',
841 "yy-mm-dd" => 'Y-m-d',
842 "dd-mm-yy" => 'd-m-Y',
843 "dd.mm.yy" => 'd.m.Y',
844 "M d, yy" => 'M j, Y',
845 "d M yy" => 'j M Y',
846 "MM d, yy" => 'F j, Y',
847 "d MM yy" => 'j F Y',
848 "DD, d MM yy" => 'l, j F Y',
849 "mm/dd" => 'm/d',
850 "dd-mm" => 'd-m',
851 "yy-mm" => 'Y-m',
852 "M yy" => 'M Y',
853 "yy" => 'Y',
854 );
855 return $dateInputFormats;
856 }
857
858 /**
859 * Time formats
860 */
861 static function getTimeFormats() {
862 $timeFormats = array('1' => ts('12 Hours'),
863 '2' => ts('24 Hours'),
864 );
865 return $timeFormats;
866 }
867
868 /**
869 * Function to get numeric options
870 *
871 *
872 * @static
873 */
874 public static function getNumericOptions($start = 0, $end = 10) {
875 for ($i = $start; $i <= $end; $i++) {
876 $numericOptions[$i] = $i;
877 }
878 return $numericOptions;
879 }
880
881 /**
882 * barcode types
883 * @static
884 */
885 static function getBarcodeTypes() {
886 static $barcodeTypes = NULL;
887 if (!$barcodeTypes) {
888 $barcodeTypes = array(
889 'barcode' => ts('Linear (1D)'),
890 'qrcode' => ts('QR code'),
891 );
892 }
893 return $barcodeTypes;
894 }
895
896 /**
897 * dedupe rule types
898 */
899 static function getDedupeRuleTypes() {
900 static $dedupeRuleTypes = NULL;
901 if (!$dedupeRuleTypes) {
902 $dedupeRuleTypes = array(
903 'Unsupervised' => ts('Unsupervised'),
904 'Supervised' => ts('Supervised'),
905 'General' => ts('General'),
906 );
907 }
908 return $dedupeRuleTypes;
909 }
910
911 /**
912 * campaign group types
913 */
914 static function getCampaignGroupTypes() {
915 static $campaignGroupTypes = NULL;
916 if (!$campaignGroupTypes) {
917 $campaignGroupTypes = array(
918 'Include' => ts('Include'),
919 'Exclude' => ts('Exclude'),
920 );
921 }
922 return $campaignGroupTypes;
923 }
924
925 /**
926 * subscription history method
927 */
928 static function getSubscriptionHistoryMethods() {
929 static $subscriptionHistoryMethods = NULL;
930 if (!$subscriptionHistoryMethods) {
931 $subscriptionHistoryMethods = array(
932 'Admin' => ts('Admin'),
933 'Email' => ts('Email'),
934 'Web' => ts('Web'),
935 'API' => ts('API'),
936 );
937 }
938
939 return $subscriptionHistoryMethods;
940 }
941
942 /**
943 * premium units
944 */
945 static function getPremiumUnits() {
946 static $premiumUnits = NULL;
947 if (!$premiumUnits) {
948 $premiumUnits = array(
949 'day' => ts('Day'),
950 'week' => ts('Week'),
951 'month' => ts('Month'),
952 'year' => ts('Year'),
953 );
954 }
955
956 return $premiumUnits;
957 }
958
959 /**
960 * extension types
961 */
962 static function getExtensionTypes() {
963 static $extensionTypes = NULL;
964 if (!$extensionTypes) {
965 $extensionTypes = array(
966 'payment' => ts('Payment'),
967 'search' => ts('Search'),
968 'report' => ts('Report'),
969 'module' => ts('Module'),
970 'sms' => ts('SMS'),
971 );
972 }
973
974 return $extensionTypes;
975 }
976
977 /**
978 * job frequency
979 */
980 static function getJobFrequency() {
981 static $jobFrequency = NULL;
982 if (!$jobFrequency) {
983 $jobFrequency = array(
984 'Daily' => ts('Daily'),
985 'Hourly' => ts('Hourly'),
986 'Always' => ts('Every time cron job is run'),
987 );
988 }
989
990 return $jobFrequency;
991 }
992
993 /**
994 * Search builder operators
995 */
996 static function getSearchBuilderOperators() {
997 static $searchBuilderOperators = NULL;
998 if (!$searchBuilderOperators) {
999 $searchBuilderOperators = array(
1000 '=' => '=',
1001 '!=' => '≠',
1002 '>' => '>',
1003 '<' => '<',
1004 '>=' => '≥',
1005 '<=' => '≤',
1006 'IN' => ts('In'),
1007 'LIKE' => ts('Like'),
1008 'RLIKE' => ts('Regex'),
1009 'IS EMPTY' => ts('Is Empty'),
1010 'IS NOT EMPTY' => ts('Not Empty'),
1011 'IS NULL' => ts('Is Null'),
1012 'IS NOT NULL' => ts('Not Null'),
1013 );
1014 }
1015
1016 return $searchBuilderOperators;
1017 }
1018
1019 /**
1020 * profile group types
1021 *
1022 * @static
1023 */
1024 static function getProfileGroupType() {
1025 static $profileGroupType = NULL;
1026 if (!$profileGroupType) {
1027 $profileGroupType = array(
1028 'Activity' => ts('Activities'),
1029 'Contribution' => ts('Contributions'),
1030 'Membership' => ts('Memberships'),
1031 'Participant' => ts('Participants'),
1032 );
1033 $contactTypes = self::contactType();
1034 $contactTypes = !empty($contactTypes) ? array('Contact' => 'Contacts') + $contactTypes : array();
1035 $profileGroupType = array_merge($contactTypes, $profileGroupType );
1036 }
1037 return $profileGroupType;
1038 }
1039
1040
1041 /**
1042 * word replacement match type
1043 */
1044 static function getWordReplacementMatchType() {
1045 static $wordReplacementMatchType = NULL;
1046 if (!$wordReplacementMatchType) {
1047 $wordReplacementMatchType = array(
1048 'exactMatch' => ts('Exact Match'),
1049 'wildcardMatch' => ts('Wildcard Match'),
1050 );
1051 }
1052
1053 return $jobFrequency;
1054 }
1055
1056 /**
1057 * mailing group types
1058 */
1059 static function getMailingGroupTypes() {
1060 static $mailingGroupTypes = NULL;
1061 if (!$mailingGroupTypes) {
1062 $mailingGroupTypes = array(
1063 'Include' => ts('Include'),
1064 'Exclude' => ts('Exclude'),
1065 'Base' => ts('Base'),
1066 );
1067 }
1068 return $mailingGroupTypes;
1069 }
1070
1071 /**
1072 * Mailing Job Status
1073 */
1074 static function geMailingJobStatus() {
1075 static $mailingJobStatus = NULL;
1076 if (!$mailingJobStatus) {
1077 $mailingJobStatus = array(
1078 'Scheduled' => ts('Scheduled'),
1079 'Running' => ts('Running'),
1080 'Complete' => ts('Complete'),
1081 'Paused' => ts('Paused'),
1082 'Canceled' => ts('Canceled'),
1083 );
1084 }
1085
1086 return $mailingJobStatus;
1087 }
1088
1089 }
1090