00001 <?php
00002 # This file is part of the Savane project
00003 # <http://gna.org/projects/savane/>
00004 #
00005 # $Id: calendar.php 5187 2005-12-01 16:22:29Z yeupou $
00006 #
00007 # Took from Annif <http://gna.org/projects/annif/>
00008 # Copyright 2003 (c) Mathieu Roy <yeupou--at--gnu.org>
00009 #
00010 # The Savane project is free software; you can redistribute it and/or
00011 # modify it under the terms of the GNU General Public License
00012 # as published by the Free Software Foundation; either version 2
00013 # of the License, or (at your option) any later version.
00014 #
00015 # The Savane project is distributed in the hope that it will be useful,
00016 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00018 # GNU General Public License for more details.
00019 #
00020 # You should have received a copy of the GNU General Public License
00021 # along with the Savane project; if not, write to the Free Software
00022 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00023
00024 function calendar_month_name ($month)
00025 {
00026 switch ($month)
00027 {
00028 case '1':
00029 return _("January"); break;
00030 case '2':
00031 return _("February"); break;
00032 case '3':
00033 return _("March"); break;
00034 case '4':
00035 return _("April"); break;
00036 case '5':
00037 return _("May"); break;
00038 case '6':
00039 return _("June"); break;
00040 case '7':
00041 return _("July"); break;
00042 case '8':
00043 return _("August"); break;
00044 case '9':
00045 return _("September"); break;
00046 case '10':
00047 return _("October"); break;
00048 case '11':
00049 return _("November"); break;
00050 case '12':
00051 return _("December"); break;
00052 }
00053 }
00054
00055 function calendar_day_name ($day)
00056 {
00057 # Start monday, not sunday...
00058 switch ($day)
00059 {
00060 case '1':
00061 return _("Monday"); break;
00062 case '2':
00063 return _("Tuesday"); break;
00064 case '3':
00065 return _("Wednesday"); break;
00066 case '4':
00067 return _("Thursday"); break;
00068 case '5':
00069 return _("Friday"); break;
00070 case '6':
00071 return _("Saturday"); break;
00072 case '7':
00073 return _("Sunday"); break;
00074 }
00075 }
00076
00077
00078 function calendar_days_count ($month)
00079 {
00080 if ($month == '2')
00081 { return '29'; }
00082 elseif ($month == '4' ||
00083 $month == '6' ||
00084 $month == '9' ||
00085 $month == '11')
00086 { return '30'; }
00087 else
00088 { return '31'; }
00089 }
00090
00091 function calendar_selectbox ($level, $checked_val='xxaz', $inputname=false)
00092 {
00093 if (!$inputname)
00094 { $inputname = $level; }
00095
00096 # initialize array
00097 $text = array();
00098 $number = array();
00099
00100 if ($level == 'day')
00101 {
00102 for ($day = 1; $day <= calendar_days_count(1); $day++)
00103 {
00104 $number[] = $day;
00105 $text[] = $day;
00106 }
00107 }
00108 elseif ($level == 'month')
00109 {
00110 for ($month = 1; $month <= 12; $month++)
00111 {
00112 $number[] = $month;
00113 $text[] = calendar_month_name($month);
00114 }
00115 }
00116
00117
00118 return html_build_select_box_from_arrays($number,
00119 $text,
00120 $inputname,
00121 $checked_val,
00122 0);
00123 }
00124
00125 ?>