| [ Index ] |
|
Code source de Mantis 1.1.0rc3 |
1 <?php 2 # Mantis - a php based bugtracking system 3 4 # Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org 5 # Copyright (C) 2002 - 2007 Mantis Team - mantisbt-dev@lists.sourceforge.net 6 7 # Mantis is free software: you can redistribute it and/or modify 8 # it under the terms of the GNU General Public License as published by 9 # the Free Software Foundation, either version 2 of the License, or 10 # (at your option) any later version. 11 # 12 # Mantis is distributed in the hope that it will be useful, 13 # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 # GNU General Public License for more details. 16 # 17 # You should have received a copy of the GNU General Public License 18 # along with Mantis. If not, see <http://www.gnu.org/licenses/>. 19 20 # -------------------------------------------------------- 21 # $Id: date_api.php,v 1.8.2.1 2007-10-13 22:35:23 giallu Exp $ 22 # -------------------------------------------------------- 23 24 ### Date API ### 25 26 # -------------------- 27 # prints the date given the formating string 28 function print_date( $p_format, $p_date ) { 29 PRINT date( $p_format, $p_date ); 30 } 31 # -------------------- 32 function print_month_option_list( $p_month = 0 ) { 33 for ($i=1; $i<=12; $i++) { 34 $month_name = date( 'F', mktime(0,0,0,$i,1,2000) ); 35 if ( $i == $p_month ) { 36 PRINT "<option value=\"$i\" selected=\"selected\">$month_name</option>"; 37 } else { 38 PRINT "<option value=\"$i\">$month_name</option>"; 39 } 40 } 41 } 42 # -------------------- 43 function print_numeric_month_option_list( $p_month = 0 ) { 44 for ($i=1; $i<=12; $i++) { 45 if ($i == $p_month) { 46 PRINT "<option value=\"$i\" selected=\"selected\"> $i </option>" ; 47 } else { 48 PRINT "<option value=\"$i\"> $i </option>" ; 49 } 50 } 51 } 52 53 # -------------------- 54 function print_day_option_list( $p_day = 0 ) { 55 for ($i=1; $i<=31; $i++) { 56 if ( $i == $p_day ) { 57 PRINT "<option value=\"$i\" selected=\"selected\"> $i </option>"; 58 } else { 59 PRINT "<option value=\"$i\"> $i </option>"; 60 } 61 } 62 } 63 # -------------------- 64 function print_year_option_list( $p_year = 0 ) { 65 $current_year = date( "Y" ); 66 67 for ($i=$current_year; $i>1999; $i--) { 68 if ( $i == $p_year ) { 69 PRINT "<option value=\"$i\" selected=\"selected\"> $i </option>"; 70 } else { 71 PRINT "<option value=\"$i\"> $i </option>"; 72 } 73 } 74 } 75 # -------------------- 76 function print_year_range_option_list( $p_year = 0, $p_start = 0, $p_end = 0) { 77 $t_current = date( "Y" ) ; 78 $t_forward_years = config_get( 'forward_year_count' ) ; 79 80 $t_start_year = $p_start ; 81 if ($t_start_year == 0) { 82 $t_start_year = $t_current ; 83 } 84 if ( ( $p_year < $t_start_year ) && ( $p_year != 0 ) ) { 85 $t_start_year = $p_year ; 86 } 87 88 $t_end_year = $p_end ; 89 if ($t_end_year == 0) { 90 $t_end_year = $t_current + $t_forward_years ; 91 } 92 if ($p_year > $t_end_year) { 93 $t_end_year = $p_year + $t_forward_years ; 94 } 95 96 for ($i=$t_start_year; $i <= $t_end_year; $i++) { 97 if ($i == $p_year) { 98 PRINT "<option value=\"$i\" selected=\"selected\"> $i </option>" ; 99 } else { 100 PRINT "<option value=\"$i\"> $i </option>" ; 101 } 102 } 103 } 104 # -------------------- 105 106 function print_date_selection_set( $p_name, $p_format, $p_date=0, $p_default_disable=false, $p_allow_blank=false, $p_year_start=0, $p_year_end=0) { 107 $t_chars = preg_split('//', $p_format, -1, PREG_SPLIT_NO_EMPTY) ; 108 if ( $p_date != 0 ) { 109 $t_date = preg_split('/-/', date( 'Y-m-d', $p_date), -1, PREG_SPLIT_NO_EMPTY) ; 110 } else { 111 $t_date = array( 0, 0, 0 ); 112 } 113 114 $t_disable = '' ; 115 if ( $p_default_disable == true ) { 116 $t_disable = 'disabled' ; 117 } 118 $t_blank_line = '' ; 119 if ( $p_allow_blank == true ) { 120 $t_blank_line = "<option value=\"0\"></option>" ; 121 } 122 123 foreach( $t_chars as $t_char ) { 124 if (strcmp( $t_char, "M") == 0) { 125 echo "<select ", helper_get_tab_index(), " name=\"" . $p_name . "_month\" $t_disable>" ; 126 echo $t_blank_line ; 127 print_month_option_list( $t_date[1] ) ; 128 echo "</select>\n" ; 129 } 130 if (strcmp( $t_char, "m") == 0) { 131 echo "<select ", helper_get_tab_index(), " name=\"" . $p_name . "_month\" $t_disable>" ; 132 echo $t_blank_line ; 133 print_numeric_month_option_list( $t_date[1] ) ; 134 echo "</select>\n" ; 135 } 136 if (strcasecmp( $t_char, "D") == 0) { 137 echo "<select ", helper_get_tab_index(), " name=\"" . $p_name . "_day\" $t_disable>" ; 138 echo $t_blank_line ; 139 print_day_option_list( $t_date[2] ) ; 140 echo "</select>\n" ; 141 } 142 if (strcasecmp( $t_char, "Y") == 0) { 143 echo "<select ", helper_get_tab_index(), " name=\"" . $p_name . "_year\" $t_disable>" ; 144 echo $t_blank_line ; 145 print_year_range_option_list( $t_date[0], $p_year_start, $p_year_end ) ; 146 echo "</select>\n" ; 147 } 148 } 149 } 150 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Thu Nov 29 09:42:17 2007 | par Balluche grâce à PHPXref 0.7 |
|