From: garvinhicking Date: Mon, 23 May 2005 19:24:56 +0000 (+0000) Subject: Jalalil and future other calendars support X-Git-Tag: 0.9~450 X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=a30d9af7cc636df3950ebb89797c5c47d1c199f8;p=s9y.git Jalalil and future other calendars support --- diff --git a/docs/NEWS b/docs/NEWS index da6c33e..3eaeb2a 100644 --- a/docs/NEWS +++ b/docs/NEWS @@ -3,6 +3,9 @@ Version 0.9 () ------------------------------------------------------------------------ + * New configuration item: Gregorian or Jalali Calendar output. + Patch by Omid Mottaghi + * New personal configuration item: "Forbid creating entries" to allow authors to be logged in, but not create any entries. Meant to be used in conjunction with serendipity_plugin_adduser for diff --git a/include/functions.inc.php b/include/functions.inc.php index eb2a7ed..f8c38ed 100644 --- a/include/functions.inc.php +++ b/include/functions.inc.php @@ -45,13 +45,28 @@ function serendipity_serverOffsetHour($timestamp = null, $negative = false) { } function serendipity_strftime($format, $timestamp = null, $useOffset = true) { - if ($timestamp == null) { - $timestamp = serendipity_serverOffsetHour(); - } elseif ($useOffset) { - $timestamp = serendipity_serverOffsetHour($timestamp); - } + global $serendipity; + + switch($serendipity['calendar']) { + default: + case 'gregorian': + if ($timestamp == null) { + $timestamp = serendipity_serverOffsetHour(); + } elseif ($useOffset) { + $timestamp = serendipity_serverOffsetHour($timestamp); + } + return strftime($format, $timestamp); + + case 'jalali-utf8': + if ($timestamp == null) { + $timestamp = serendipity_serverOffsetHour(); + } elseif ($useOffset) { + $timestamp = serendipity_serverOffsetHour($timestamp); + } - return strftime($format, $timestamp); + require_once S9Y_INCLUDE_PATH . 'include/functions_calendars.inc.php'; + return calendar_jalali_utf($format, $timestamp, $useOffset); + } } function serendipity_formatTime($format, $time, $useOffset = true) { diff --git a/include/functions_calendars.inc.php b/include/functions_calendars.inc.php new file mode 100644 index 0000000..53d5574 --- /dev/null +++ b/include/functions_calendars.inc.php @@ -0,0 +1,171 @@ + 'شنبه', + 'Sunday' => 'یک شنبه', + 'Monday' => 'دوشنبه', + 'Tuesday' => 'سه شنبه', + 'Wednesday' => 'چهارشنبه', + 'Thursday' => 'پنج شنبه', + 'Friday' => 'جمعه', + 'Sat' => 'ش', + 'Sun' => 'ی', + 'Mon' => 'د', + 'Tue' => 'س', + 'Wed' => 'چ', + 'Thu' => 'پ', + 'Fri' => 'ج'); + $j_week_number = array('Sat' => '1', + 'Sun' => '2', + 'Mon' => '3', + 'Tue' => '4', + 'Wed' => '5', + 'Thu' => '6', + 'Fri' => '7'); + + $gy = $g_y-1600; + $gm = $g_m-1; + $gd = $g_d-1; + + $g_day_no = 365*$gy+floor(($gy+3)/4)-floor(($gy+99)/100)+floor(($gy+399)/400); + + for ($i=0; $i < $gm; ++$i) { + $g_day_no += $g_days_in_month[$i]; + } + + if ($gm>1 && (($gy%4==0 && $gy%100!=0) || ($gy%400==0))) { + /* leap and after Feb */ + ++$g_day_no; + } + + $g_day_no += $gd; + $j_day_no = $g_day_no-79; + $j_np = floor($j_day_no/12053); + $j_day_no %= 12053; + $jy = 979+33*$j_np+4*floor($j_day_no/1461); + $j_day_no %= 1461; + + if ($j_day_no >= 366) { + $jy += floor(($j_day_no-1)/365); + $j_day_no = ($j_day_no-1)%365; + } + $j_all_days = $j_day_no+1; + + for ($i = 0; $i < 11 && $j_day_no >= $j_days_in_month[$i]; ++$i) { + $j_day_no -= $j_days_in_month[$i]; + } + + $jm = $i+1; + $jd = $j_day_no+1; + + // calculate string + $percent_sign=0; + $output_str=''; + + for ($i=0; $i \ No newline at end of file diff --git a/include/tpl/config_local.inc.php b/include/tpl/config_local.inc.php index 6d917a9..365fc26 100644 --- a/include/tpl/config_local.inc.php +++ b/include/tpl/config_local.inc.php @@ -283,6 +283,12 @@ 'default' => $serendipity['languages'], 'flags' => array('simpleInstall')), + array('var' => 'calendar', + 'title' => INSTALL_CAL, + 'description' => INSTALL_CAL_DESC, + 'type' => 'list', + 'default' => $serendipity['calendars']), + array('var' => 'lang_content_negotiation', 'title' => AUTOLANG, 'description' => AUTOLANG_DESC, diff --git a/lang/serendipity_lang_bg.inc.php b/lang/serendipity_lang_bg.inc.php index cd026b8..8033ed7 100644 --- a/lang/serendipity_lang_bg.inc.php +++ b/lang/serendipity_lang_bg.inc.php @@ -678,6 +678,8 @@ @define('INSTALL_PERMALINK_SEARCHPATH', 'Path to search'); @define('USERCONF_CREATE', 'Forbid creating entries?'); @define('USERCONF_CREATE_DESC', 'If selected, the user may not create new entries'); +@define('INSTALL_CAL', 'Calendar Type'); +@define('INSTALL_CAL_DESC', 'Choose your desired Calendar format'); /* vim: set sts=4 ts=4 expandtab : */ ?> diff --git a/lang/serendipity_lang_cn.inc.php b/lang/serendipity_lang_cn.inc.php index 078c607..edbcc51 100644 --- a/lang/serendipity_lang_cn.inc.php +++ b/lang/serendipity_lang_cn.inc.php @@ -692,6 +692,8 @@ @define('INSTALL_PERMALINK_SEARCHPATH', 'Path to search'); @define('USERCONF_CREATE', 'Forbid creating entries?'); @define('USERCONF_CREATE_DESC', 'If selected, the user may not create new entries'); +@define('INSTALL_CAL', 'Calendar Type'); +@define('INSTALL_CAL_DESC', 'Choose your desired Calendar format'); /* vim: set sts=4 ts=4 expandtab : */ ?> diff --git a/lang/serendipity_lang_cs.inc.php b/lang/serendipity_lang_cs.inc.php index 9d118f5..21db9b5 100644 --- a/lang/serendipity_lang_cs.inc.php +++ b/lang/serendipity_lang_cs.inc.php @@ -694,6 +694,8 @@ @define('INSTALL_PERMALINK_SEARCHPATH', 'Path to search'); @define('USERCONF_CREATE', 'Forbid creating entries?'); @define('USERCONF_CREATE_DESC', 'If selected, the user may not create new entries'); +@define('INSTALL_CAL', 'Calendar Type'); +@define('INSTALL_CAL_DESC', 'Choose your desired Calendar format'); /* vim: set sts=4 ts=4 expandtab : */ ?> \ No newline at end of file diff --git a/lang/serendipity_lang_cz.inc.php b/lang/serendipity_lang_cz.inc.php index 49b4e6f..315b006 100644 --- a/lang/serendipity_lang_cz.inc.php +++ b/lang/serendipity_lang_cz.inc.php @@ -694,6 +694,8 @@ @define('INSTALL_PERMALINK_SEARCHPATH', 'Path to search'); @define('USERCONF_CREATE', 'Forbid creating entries?'); @define('USERCONF_CREATE_DESC', 'If selected, the user may not create new entries'); +@define('INSTALL_CAL', 'Calendar Type'); +@define('INSTALL_CAL_DESC', 'Choose your desired Calendar format'); /* vim: set sts=4 ts=4 expandtab : */ ?> \ No newline at end of file diff --git a/lang/serendipity_lang_da.inc.php b/lang/serendipity_lang_da.inc.php index c5e613d..74caf15 100644 --- a/lang/serendipity_lang_da.inc.php +++ b/lang/serendipity_lang_da.inc.php @@ -694,6 +694,8 @@ @define('INSTALL_PERMALINK_SEARCHPATH', 'Path to search'); @define('USERCONF_CREATE', 'Forbid creating entries?'); @define('USERCONF_CREATE_DESC', 'If selected, the user may not create new entries'); +@define('INSTALL_CAL', 'Calendar Type'); +@define('INSTALL_CAL_DESC', 'Choose your desired Calendar format'); /* vim: set sts=4 ts=4 expandtab : */ ?> diff --git a/lang/serendipity_lang_de.inc.php b/lang/serendipity_lang_de.inc.php index 825c0f4..88d2f6d 100644 --- a/lang/serendipity_lang_de.inc.php +++ b/lang/serendipity_lang_de.inc.php @@ -693,6 +693,8 @@ @define('INSTALL_PERMALINK_SEARCHPATH', 'Path to search'); @define('USERCONF_CREATE', 'Forbid creating entries?'); @define('USERCONF_CREATE_DESC', 'If selected, the user may not create new entries'); +@define('INSTALL_CAL', 'Calendar Type'); +@define('INSTALL_CAL_DESC', 'Choose your desired Calendar format'); /* vim: set sts=4 ts=4 expandtab : */ ?> diff --git a/lang/serendipity_lang_en.inc.php b/lang/serendipity_lang_en.inc.php index c90aef5..00367aa 100644 --- a/lang/serendipity_lang_en.inc.php +++ b/lang/serendipity_lang_en.inc.php @@ -691,6 +691,8 @@ @define('INSTALL_PERMALINK_SEARCHPATH', 'Path to search'); @define('USERCONF_CREATE', 'Forbid creating entries?'); @define('USERCONF_CREATE_DESC', 'If selected, the user may not create new entries'); +@define('INSTALL_CAL', 'Calendar Type'); +@define('INSTALL_CAL_DESC', 'Choose your desired Calendar format'); /* vim: set sts=4 ts=4 expandtab : */ ?> diff --git a/lang/serendipity_lang_es.inc.php b/lang/serendipity_lang_es.inc.php index eb703dd..4a0a077 100644 --- a/lang/serendipity_lang_es.inc.php +++ b/lang/serendipity_lang_es.inc.php @@ -696,6 +696,8 @@ @define('INSTALL_PERMALINK_SEARCHPATH', 'Path to search'); @define('USERCONF_CREATE', 'Forbid creating entries?'); @define('USERCONF_CREATE_DESC', 'If selected, the user may not create new entries'); +@define('INSTALL_CAL', 'Calendar Type'); +@define('INSTALL_CAL_DESC', 'Choose your desired Calendar format'); /* vim: set sts=4 ts=4 expandtab : */ ?> \ No newline at end of file diff --git a/lang/serendipity_lang_fa.inc.php b/lang/serendipity_lang_fa.inc.php index e5478c2..df1ad5a 100644 --- a/lang/serendipity_lang_fa.inc.php +++ b/lang/serendipity_lang_fa.inc.php @@ -693,6 +693,8 @@ @define('INSTALL_PERMALINK_SEARCHPATH', 'Path to search'); @define('USERCONF_CREATE', 'Forbid creating entries?'); @define('USERCONF_CREATE_DESC', 'If selected, the user may not create new entries'); +@define('INSTALL_CAL', 'Calendar Type'); +@define('INSTALL_CAL_DESC', 'Choose your desired Calendar format'); /* vim: set sts=4 ts=4 expandtab : */ ?> diff --git a/lang/serendipity_lang_fi.inc.php b/lang/serendipity_lang_fi.inc.php index 43629c5..aa4f87e 100644 --- a/lang/serendipity_lang_fi.inc.php +++ b/lang/serendipity_lang_fi.inc.php @@ -691,6 +691,8 @@ @define('INSTALL_PERMALINK_SEARCHPATH', 'Path to search'); @define('USERCONF_CREATE', 'Forbid creating entries?'); @define('USERCONF_CREATE_DESC', 'If selected, the user may not create new entries'); +@define('INSTALL_CAL', 'Calendar Type'); +@define('INSTALL_CAL_DESC', 'Choose your desired Calendar format'); /* vim: set sts=4 ts=4 expandtab : */ ?> diff --git a/lang/serendipity_lang_fr.inc.php b/lang/serendipity_lang_fr.inc.php index 258c5ef..a9c6a30 100644 --- a/lang/serendipity_lang_fr.inc.php +++ b/lang/serendipity_lang_fr.inc.php @@ -699,6 +699,8 @@ @define('INSTALL_PERMALINK_SEARCHPATH', 'Path to search'); @define('USERCONF_CREATE', 'Forbid creating entries?'); @define('USERCONF_CREATE_DESC', 'If selected, the user may not create new entries'); +@define('INSTALL_CAL', 'Calendar Type'); +@define('INSTALL_CAL_DESC', 'Choose your desired Calendar format'); /* vim: set sts=4 ts=4 expandtab : */ ?> \ No newline at end of file diff --git a/lang/serendipity_lang_is.inc.php b/lang/serendipity_lang_is.inc.php index fb3d437..25db49b 100644 --- a/lang/serendipity_lang_is.inc.php +++ b/lang/serendipity_lang_is.inc.php @@ -691,6 +691,8 @@ @define('INSTALL_PERMALINK_SEARCHPATH', 'Path to search'); @define('USERCONF_CREATE', 'Forbid creating entries?'); @define('USERCONF_CREATE_DESC', 'If selected, the user may not create new entries'); +@define('INSTALL_CAL', 'Calendar Type'); +@define('INSTALL_CAL_DESC', 'Choose your desired Calendar format'); /* vim: set sts=4 ts=4 expandtab : */ ?> diff --git a/lang/serendipity_lang_it.inc.php b/lang/serendipity_lang_it.inc.php index b71b545..1b5d03d 100644 --- a/lang/serendipity_lang_it.inc.php +++ b/lang/serendipity_lang_it.inc.php @@ -693,6 +693,8 @@ @define('INSTALL_PERMALINK_SEARCHPATH', 'Path to search'); @define('USERCONF_CREATE', 'Forbid creating entries?'); @define('USERCONF_CREATE_DESC', 'If selected, the user may not create new entries'); +@define('INSTALL_CAL', 'Calendar Type'); +@define('INSTALL_CAL_DESC', 'Choose your desired Calendar format'); /* vim: set sts=4 ts=4 expandtab : */ ?> diff --git a/lang/serendipity_lang_ja.inc.php b/lang/serendipity_lang_ja.inc.php index 8301750..2f5529d 100644 --- a/lang/serendipity_lang_ja.inc.php +++ b/lang/serendipity_lang_ja.inc.php @@ -693,6 +693,8 @@ Serendipity のアップグレードステージを無視しました。正し @define('INSTALL_PERMALINK_SEARCHPATH', 'Path to search'); @define('USERCONF_CREATE', 'Forbid creating entries?'); @define('USERCONF_CREATE_DESC', 'If selected, the user may not create new entries'); +@define('INSTALL_CAL', 'Calendar Type'); +@define('INSTALL_CAL_DESC', 'Choose your desired Calendar format'); /* vim: set sts=4 ts=4 expandtab : */ ?> diff --git a/lang/serendipity_lang_ko.inc.php b/lang/serendipity_lang_ko.inc.php index 9252390..7e5616e 100644 --- a/lang/serendipity_lang_ko.inc.php +++ b/lang/serendipity_lang_ko.inc.php @@ -696,6 +696,8 @@ @define('INSTALL_PERMALINK_SEARCHPATH', 'Path to search'); @define('USERCONF_CREATE', 'Forbid creating entries?'); @define('USERCONF_CREATE_DESC', 'If selected, the user may not create new entries'); +@define('INSTALL_CAL', 'Calendar Type'); +@define('INSTALL_CAL_DESC', 'Choose your desired Calendar format'); /* vim: set sts=4 ts=4 expandtab : */ ?> diff --git a/lang/serendipity_lang_nl.inc.php b/lang/serendipity_lang_nl.inc.php index 849f6b4..2af7823 100644 --- a/lang/serendipity_lang_nl.inc.php +++ b/lang/serendipity_lang_nl.inc.php @@ -695,6 +695,8 @@ @define('INSTALL_PERMALINK_SEARCHPATH', 'Path to search'); @define('USERCONF_CREATE', 'Forbid creating entries?'); @define('USERCONF_CREATE_DESC', 'If selected, the user may not create new entries'); +@define('INSTALL_CAL', 'Calendar Type'); +@define('INSTALL_CAL_DESC', 'Choose your desired Calendar format'); /* vim: set sts=4 ts=4 expandtab : */ ?> diff --git a/lang/serendipity_lang_no.inc.php b/lang/serendipity_lang_no.inc.php index c92f593..94e56d9 100644 --- a/lang/serendipity_lang_no.inc.php +++ b/lang/serendipity_lang_no.inc.php @@ -694,5 +694,7 @@ @define('INSTALL_PERMALINK_SEARCHPATH', 'Path to search'); @define('USERCONF_CREATE', 'Forbid creating entries?'); @define('USERCONF_CREATE_DESC', 'If selected, the user may not create new entries'); +@define('INSTALL_CAL', 'Calendar Type'); +@define('INSTALL_CAL_DESC', 'Choose your desired Calendar format'); ?> diff --git a/lang/serendipity_lang_pt.inc.php b/lang/serendipity_lang_pt.inc.php index 3d35ca5..4805055 100644 --- a/lang/serendipity_lang_pt.inc.php +++ b/lang/serendipity_lang_pt.inc.php @@ -694,6 +694,8 @@ @define('INSTALL_PERMALINK_SEARCHPATH', 'Path to search'); @define('USERCONF_CREATE', 'Forbid creating entries?'); @define('USERCONF_CREATE_DESC', 'If selected, the user may not create new entries'); +@define('INSTALL_CAL', 'Calendar Type'); +@define('INSTALL_CAL_DESC', 'Choose your desired Calendar format'); /* vim: set sts=4 ts=4 expandtab : */ ?> diff --git a/lang/serendipity_lang_ro.inc.php b/lang/serendipity_lang_ro.inc.php index 85273a1..a1f4fd1 100644 --- a/lang/serendipity_lang_ro.inc.php +++ b/lang/serendipity_lang_ro.inc.php @@ -691,6 +691,8 @@ @define('INSTALL_PERMALINK_SEARCHPATH', 'Path to search'); @define('USERCONF_CREATE', 'Forbid creating entries?'); @define('USERCONF_CREATE_DESC', 'If selected, the user may not create new entries'); +@define('INSTALL_CAL', 'Calendar Type'); +@define('INSTALL_CAL_DESC', 'Choose your desired Calendar format'); /* vim: set sts=4 ts=4 expandtab : */ ?> diff --git a/lang/serendipity_lang_ru.inc.php b/lang/serendipity_lang_ru.inc.php index 4dd99c9..b02453e 100644 --- a/lang/serendipity_lang_ru.inc.php +++ b/lang/serendipity_lang_ru.inc.php @@ -694,6 +694,8 @@ @define('INSTALL_PERMALINK_SEARCHPATH', 'Path to search'); @define('USERCONF_CREATE', 'Forbid creating entries?'); @define('USERCONF_CREATE_DESC', 'If selected, the user may not create new entries'); +@define('INSTALL_CAL', 'Calendar Type'); +@define('INSTALL_CAL_DESC', 'Choose your desired Calendar format'); /* vim: set sts=4 ts=4 expandtab : */ ?> diff --git a/lang/serendipity_lang_tn.inc.php b/lang/serendipity_lang_tn.inc.php index 1b819a3..b36fad5 100644 --- a/lang/serendipity_lang_tn.inc.php +++ b/lang/serendipity_lang_tn.inc.php @@ -692,6 +692,8 @@ @define('INSTALL_PERMALINK_SEARCHPATH', 'Path to search'); @define('USERCONF_CREATE', 'Forbid creating entries?'); @define('USERCONF_CREATE_DESC', 'If selected, the user may not create new entries'); +@define('INSTALL_CAL', 'Calendar Type'); +@define('INSTALL_CAL_DESC', 'Choose your desired Calendar format'); /* vim: set sts=4 ts=4 expandtab : */ ?> diff --git a/lang/serendipity_lang_tw.inc.php b/lang/serendipity_lang_tw.inc.php index 4276827..3c6795a 100644 --- a/lang/serendipity_lang_tw.inc.php +++ b/lang/serendipity_lang_tw.inc.php @@ -692,5 +692,7 @@ @define('INSTALL_PERMALINK_SEARCHPATH', 'Path to search'); @define('USERCONF_CREATE', 'Forbid creating entries?'); @define('USERCONF_CREATE_DESC', 'If selected, the user may not create new entries'); +@define('INSTALL_CAL', 'Calendar Type'); +@define('INSTALL_CAL_DESC', 'Choose your desired Calendar format'); ?> diff --git a/lang/serendipity_lang_zh.inc.php b/lang/serendipity_lang_zh.inc.php index 5771899..861a545 100644 --- a/lang/serendipity_lang_zh.inc.php +++ b/lang/serendipity_lang_zh.inc.php @@ -692,6 +692,8 @@ @define('INSTALL_PERMALINK_SEARCHPATH', 'Path to search'); @define('USERCONF_CREATE', 'Forbid creating entries?'); @define('USERCONF_CREATE_DESC', 'If selected, the user may not create new entries'); +@define('INSTALL_CAL', 'Calendar Type'); +@define('INSTALL_CAL_DESC', 'Choose your desired Calendar format'); /* vim: set sts=4 ts=4 expandtab : */ ?> diff --git a/serendipity_config.inc.php b/serendipity_config.inc.php index 79144fc..04e1beb 100644 --- a/serendipity_config.inc.php +++ b/serendipity_config.inc.php @@ -95,6 +95,10 @@ $serendipity['languages'] = array('en' => 'English', 'ja' => 'Japanese', 'ko' => 'Korean'); +/* Available Calendars */ +$serendipity['calendars'] = array('gregorian' => 'Gregorian', + 'jalali-utf8' => 'Jalali (utf8)'); + /* * Load main language file */