function datex_factory in Datex 7.3
Same name and namespace in other branches
- 8 datex.module \datex_factory()
- 7.2 datex_api/datex_api.class.inc \datex_factory()
Creates a new datex calendar object.
16 calls to datex_factory()
- datex_block_view in ./
datex.module - Implements hook_block_view().
- datex_format in ./
datex.module - Deprecated but kept from datex 2.
- datex_form_alter in ./
datex.module - Implements hook_form_alter().
- datex_popup_date_popup_process_alter in datex_popup/
datex_popup.module - Implements hook_date_popup_process_alter().
- datex_preprocess_comment in ./
datex.module - Implements hook_preprocess_comment().
File
- ./
datex.module, line 277 - Datex main module file, Datex adds php-intl support to drupal.
Code
function datex_factory($tz = NULL, $calendar_name = NULL, $lang_code = NULL) {
// COPY FROM common.inc::format_date() (drupal).
static $drupal_static_fast;
if (!isset($drupal_static_fast)) {
$drupal_static_fast['timezones'] =& drupal_static('format_date');
}
$timezones =& $drupal_static_fast['timezones'];
if (!$tz) {
$tz = drupal_get_user_timezone();
}
if (is_string($tz)) {
if (!isset($timezones[$tz])) {
$timezones[$tz] = timezone_open($tz);
}
$tz = $timezones[$tz];
}
if (!$calendar_name) {
$calendar_name = _datex_language_calendar_name();
}
if (!$calendar_name) {
return NULL;
}
if (!$lang_code) {
if (count(language_list()) === 1) {
$lang_code = 'fa';
}
else {
$lang_code = $GLOBALS['language']->language;
}
}
if (!DATEX_USE_INTL) {
switch ($calendar_name) {
case 'persian':
require_once 'src/Datex/DatexPoorMansJaliliCalendar.php';
return new DatexPoorMansJaliliCalendar($tz, $lang_code);
default:
require_once 'src/Datex/DatexPoorMansGregorianCalendar.php';
return new DatexPoorMansGregorianCalendar($tz, $lang_code);
}
}
switch ($calendar_name) {
case 'persian':
return new DatexPersianIntlCalendar($tz, $calendar_name, $lang_code);
default:
return new DatexIntlCalendar($tz, $calendar_name, $lang_code);
}
}