View source
<?php
require_once 'datex_api.class.inc';
require_once 'DatexJalali.inc';
function _datex_api_available_calendars() {
return array(
'jalali',
);
}
function datex_get_all_dummy_names() {
foreach (_datex_api_available_calendars() as $cal) {
$function = '_datex_dummy_translation_function_' . $cal;
$function();
}
}
function _datex_api_css_files_list() {
$css = array(
'ui-black-tie.calendars.picker.css',
'ui-blitzer.calendars.picker.css',
'ui-cupertino.calendars.picker.css',
'ui-dark-hive.calendars.picker.css',
'ui-dot-luv.calendars.picker.css',
'ui-eggplant.calendars.picker.css',
'ui-excite-bike.calendars.picker.css',
'ui-flick.calendars.picker.css',
'ui-hot-sneaks.calendars.picker.css',
'ui-humanity.calendars.picker.css',
'ui-le-frog.calendars.picker.css',
'ui-mint-choc.calendars.picker.css',
'ui-overcast.calendars.picker.css',
'ui-pepper-grinder.calendars.picker.css',
'ui-redmond.calendars.picker.css',
'ui-smoothness.calendars.picker.css',
'ui-south-street.calendars.picker.css',
'ui-start.calendars.picker.css',
'ui-sunny.calendars.picker.css',
'ui-swanky-purse.calendars.picker.css',
'ui-trontastic.calendars.picker.css',
'ui-ui-darkness.calendars.picker.css',
'ui-ui-lightness.calendars.picker.css',
'ui-vader.calendars.picker.css',
'ui.calendars.picker.css',
'flora.calendars.picker.css',
'humanity.calendars.picker.css',
'jquery.calendars.picker.css',
'redmond.calendars.picker.css',
'smoothness.calendars.picker.css',
);
return $css;
}
function datex_api_libraries_info() {
$libraries['jquery.calendars'] = array(
'vendor url' => 'http://keith-wood.info',
'download url' => 'http://keith-wood.name/zip/jquery.calendars.package-1.2.1.zip',
'name' => t('jQuery calendars'),
'version arguments' => array(
'file' => 'jquery.calendars.all.js',
'pattern' => '#v(\\d\\.\\d\\.\\d)\\.#',
'lines' => 2,
),
'files' => array(
'js' => array(
'jquery.calendars.all.min.js',
'jquery.calendars.lang.min.js',
'jquery.calendars.picker.lang.min.js',
'jquery.calendars.persian.min.js',
'jquery.calendars.persian-fa.js',
),
),
'variants' => array(
'normal' => array(
'files' => array(
'js' => array(
'jquery.calendars.all.js',
'jquery.calendars.lang.js',
'jquery.calendars.picker.lang.js',
'jquery.calendars.persian.js',
'jquery.calendars.persian-fa.js',
),
),
),
),
);
return $libraries;
}
function _datex_api_get_language_locale_calendar($language) {
if ($language === TRUE) {
$language = $GLOBALS['language']->language;
}
$calendars = array(
'persian' => array(
'fa',
'jalali',
'persian',
'iranian',
),
'gregorian' => array(
'en',
'gregorian',
),
);
foreach ($calendars as $calendar => $langs) {
if (in_array($language, $langs)) {
return $calendar;
}
}
return FALSE;
}
function _datex_api_add_l10n($l10n, $translation = NULL, $zip = 'pack') {
static $loaded = array();
if (!module_exists('libraries')) {
return;
}
if ($zip === 'min' || $zip === 'pack') {
$zip = '.' . $zip . '.js';
}
else {
$zip = '.js';
}
$base_path = libraries_get_path('jquery.calendars') . '/';
$name = 'jquery.calendars.' . $l10n;
if (!isset($loaded['l10n'][$l10n])) {
drupal_add_js($base_path . $name . $zip);
$loaded['l10n'][$l10n] = TRUE;
}
if ($translation && !isset($loaded['translation'][$translation])) {
$name = "{$name}-{$translation}.js";
drupal_add_js($base_path . $name);
$loaded['translation'][$translation] = TRUE;
}
}
function datex_format_date($locale, $datetime, $format, $tz = NULL, $intl = NULL) {
if (!$tz) {
$tz = drupal_get_user_timezone();
}
if (!$intl) {
$intl = _datex_cfg('useintl');
}
return datex_format($locale, $datetime, $format, $tz, $intl);
}
function _datex_calendar_is_valid($calendar) {
switch (_datex_get_calendar_name_from_name($calendar)) {
case 'jalali':
return TRUE;
break;
default:
return FALSE;
}
}
function _datex_get_calendar_name_from_name($name) {
switch (strtolower($name)) {
case 'fa':
case 'farsi':
case 'parsi':
case 'persian':
case 'jalali':
case 'shamsi':
case 'iran':
case 'iranian':
return 'jalali';
break;
default:
return '';
}
}