Changeset 19 for types/Date.php
- Timestamp:
- Oct 22, 2008, 9:12:20 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
types/Date.php
r14 r19 1 1 <?php 2 2 3 function TypeDateOnView($Item) 3 class TypeDate 4 4 { 5 global $MonthNames; 5 function OnView($Item) 6 { 7 global $MonthNames; 6 8 7 $Parts = explode('-', $Item['Value']);9 $Parts = explode('-', $Item['Value']); 8 10 9 $Output = ($Parts[2] * 1).'.'.$MonthNames[$Parts[1] * 1].' '.$Parts[0]; 10 return($Output); 11 $Output = ($Parts[2] * 1).'.'.$MonthNames[$Parts[1] * 1].' '.$Parts[0]; 12 return($Output); 13 } 14 15 function OnEdit($Item) 16 { 17 global $MonthNames; 18 19 $Parts = explode('-', $Item['Value']); 20 21 // Day 22 $Output = '<select name="'.$Item['Name'].'-day">'; 23 for($I = 1; $I <= 31; $I++) 24 { 25 if($Parts[2] == $I) $Selected = ' selected="1"'; else $Selected = ''; 26 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 27 } 28 $Output .= '</select>'; 29 // Month 30 $Output .= '<select name="'.$Item['Name'].'-month">'; 31 for($I = 1; $I <= 12; $I++) 32 { 33 if($Parts[1] == $I) $Selected = ' selected="1"'; else $Selected = ''; 34 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$MonthNames[$I].'</option>'; 35 } 36 $Output .= '</select>'; 37 // Year 38 $Output .= '<select name="'.$Item['Name'].'-year">'; 39 for($I = 1900; $I < 2100; $I++) 40 { 41 if($Parts[0] == $I) $Selected = ' selected="1"'; else $Selected = ''; 42 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 43 } 44 $Output .= '</select>'; 45 return($Output); 46 } 47 48 function OnLoad($Item) 49 { 50 return($_POST[$Item['Name'].'-year'].'-'.$_POST[$Item['Name'].'-month'].'-'.$_POST[$Item['Name'].'-day']); 51 } 11 52 } 12 53 13 function TypeDateOnEdit($Item) 14 { 15 global $MonthNames; 16 17 $Parts = explode('-', $Item['Value']); 18 19 // Day 20 $Output = '<select name="'.$Item['Name'].'-day">'; 21 for($I = 1; $I <= 31; $I++) 22 { 23 if($Parts[2] == $I) $Selected = ' selected="1"'; else $Selected = ''; 24 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 25 } 26 $Output .= '</select>'; 27 // Month 28 $Output .= '<select name="'.$Item['Name'].'-month">'; 29 for($I = 1; $I <= 12; $I++) 30 { 31 if($Parts[1] == $I) $Selected = ' selected="1"'; else $Selected = ''; 32 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$MonthNames[$I].'</option>'; 33 } 34 $Output .= '</select>'; 35 // Year 36 $Output .= '<select name="'.$Item['Name'].'-year">'; 37 for($I = 1900; $I < 2100; $I++) 38 { 39 if($Parts[0] == $I) $Selected = ' selected="1"'; else $Selected = ''; 40 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 41 } 42 $Output .= '</select>'; 43 return($Output); 44 } 45 46 function TypeDateOnLoad($Item) 47 { 48 return($_POST[$Item['Name'].'-year'].'-'.$_POST[$Item['Name'].'-month'].'-'.$_POST[$Item['Name'].'-day']); 49 } 54 $TypeDefinitionList['Date'] = new TypeDate; 50 55 51 56 ?>
Note:
See TracChangeset
for help on using the changeset viewer.