Changeset 3294
- Timestamp:
- 01/16/07 07:53:15 (2 years ago)
- Files:
-
- trunk/data/generator/sfPropelAdmin/default/template/actions/actions.class.php (modified) (2 diffs)
- trunk/lib/helper/DateFormHelper.php (modified) (3 diffs)
- trunk/lib/helper/FormHelper.php (modified) (2 diffs)
- trunk/lib/helper/ObjectHelper.php (modified) (1 diff)
- trunk/test/functional/backend/timeTest.php (modified) (2 diffs)
- trunk/test/unit/helper/DateFormHelperTest.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/data/generator/sfPropelAdmin/default/template/actions/actions.class.php
r3293 r3294 250 250 { 251 251 $dateFormat = new sfDateFormat($this->getUser()->getCulture()); 252 <?php $inputPattern = ($type == CreoleTypes::DATE ? 'd' : 'g'); ?>253 <?php $outputPattern = ($type == CreoleTypes::DATE ? 'i' : 'I'); ?>252 <?php $inputPattern = $type == CreoleTypes::DATE ? 'd' : 'g'; ?> 253 <?php $outputPattern = $type == CreoleTypes::DATE ? 'i' : 'I'; ?> 254 254 if (!is_array($<?php echo $this->getSingularName() ?>['<?php echo $name ?>'])) 255 255 { … … 259 259 { 260 260 $value_array = $<?php echo $this->getSingularName() ?>['<?php echo $name ?>']; 261 $value = $value_array['year'].'-'.$value_array['month'].'-'.$value_array['day'] ;261 $value = $value_array['year'].'-'.$value_array['month'].'-'.$value_array['day'].(isset($value_array['hour']) ? ' '.$value_array['hour'].':'.$value_array['minute'].(isset($value_array['second']) ? ':'.$value_array['second'] : '') : ''); 262 262 } 263 263 $this-><?php echo $this->getSingularName() ?>->set<?php echo $column->getPhpName() ?>($value); trunk/lib/helper/DateFormHelper.php
r2849 r3294 588 588 $ampm_seperator = _get_option($options, 'ampm_seperator', ''); 589 589 $include_second = _get_option($options, 'include_second'); 590 $_12hour_time = _get_option($options, '12hour_time');591 592 $options['12hour_time'] = $_12hour_time; // set it back. hour tag needs it.590 $_12hour_time = _get_option($options, '12hour_time'); 591 592 $options['12hour_time'] = $_12hour_time; // set it back. hour tag needs it. 593 593 594 594 if ($include_custom = _get_option($options, 'include_custom')) … … 620 620 $tags = array(); 621 621 622 $hour_name = $name .'[hour]';623 $tags[] = select_hour_tag($hour_name, _parse_value_for_date($value, 'hour', ($_12hour_time)? 'h' : 'H'), $options + $include_custom_hour, $html_options);624 625 $minute_name = $name .'[minute]';622 $hour_name = $name.'[hour]'; 623 $tags[] = select_hour_tag($hour_name, _parse_value_for_date($value, 'hour', $_12hour_time ? 'h' : 'H'), $options + $include_custom_hour, $html_options); 624 625 $minute_name = $name.'[minute]'; 626 626 $tags[] = select_minute_tag($minute_name, _parse_value_for_date($value, 'minute', 'i'), $options + $include_custom_minute, $html_options); 627 627 628 628 if ($include_second) 629 629 { 630 $second_name = $name .'[second]';630 $second_name = $name.'[second]'; 631 631 $tags[] = select_second_tag($second_name, _parse_value_for_date($value, 'second', 's'), $options + $include_custom_second, $html_options); 632 632 } … … 636 636 if ($_12hour_time) 637 637 { 638 $ampm_name = $name . "[ampm]";639 $time .= $ampm_seperator .select_ampm_tag($ampm_name, _parse_value_for_date($value, 'ampm', 'A'), $options + $include_custom_ampm, $html_options);638 $ampm_name = $name.'[ampm]'; 639 $time .= $ampm_seperator.select_ampm_tag($ampm_name, _parse_value_for_date($value, 'ampm', 'A'), $options + $include_custom_ampm, $html_options); 640 640 } 641 641 trunk/lib/helper/FormHelper.php
r3290 r3294 619 619 $culture = _get_option($options, 'culture', $context->getUser()->getCulture()); 620 620 621 $withTime = _get_option($options, 'withtime', false); 622 621 623 // rich control? 622 624 if (!_get_option($options, 'rich', false)) … … 627 629 $options['culture'] = $culture; 628 630 629 return select_date_tag($name, $value, $options, isset($options['html']) ? $options['html'] : array()); 630 } 631 632 if ($withTime = _get_option($options, 'withtime', false)) 633 { 634 $pattern = 'g'; 635 } 636 else 637 { 638 $pattern = 'd'; 639 } 640 641 $pattern = _get_option($options, 'format', $pattern); 631 if ($withTime) 632 { 633 return select_datetime_tag($name, $value, $options, isset($options['html']) ? $options['html'] : array()); 634 } 635 else 636 { 637 return select_date_tag($name, $value, $options, isset($options['html']) ? $options['html'] : array()); 638 } 639 } 640 641 $pattern = _get_option($options, 'format', $withTime ? 'g' : 'd'); 642 642 643 643 $dateFormat = new sfDateFormat($culture); trunk/lib/helper/ObjectHelper.php
r3184 r3294 35 35 $options = _parse_attributes($options); 36 36 37 $value = _get_object_value($object, $method, $default_value, $param = 'Y-m-d ');37 $value = _get_object_value($object, $method, $default_value, $param = 'Y-m-d G:i'); 38 38 39 39 return input_date_tag(_convert_method_to_name($method, $options), $value, $options); trunk/test/functional/backend/timeTest.php
r3293 r3294 32 32 ; 33 33 34 // non rich date 35 $tomorrow = time() + 86400 ;34 // non rich date (without time) 35 $tomorrow = time() + 86400 + 3600; 36 36 $b-> 37 customizeGenerator(array('edit' => array('fields' => array('end_date' => array('params' => ' rich=false')))))->37 customizeGenerator(array('edit' => array('fields' => array('end_date' => array('params' => 'withtime=false rich=false')))))-> 38 38 39 39 post('/article/edit/id/1', array('article' => array('end_date' => array('day' => date('d', $tomorrow), 'month' => date('m', $tomorrow), 'year' => date('Y', $tomorrow)))))-> … … 46 46 checkResponseElement(sprintf('select[name="article[end_date][day]"] option[value="%s"][selected="selected"]', date('d', $tomorrow)))-> 47 47 checkResponseElement(sprintf('select[name="article[end_date][month]"] option[value="%s"][selected="selected"]', date('m', $tomorrow)))-> 48 checkResponseElement(sprintf('select[name="article[end_date][year]"] option[value="%s"][selected="selected"]', date('Y', $tomorrow))) 48 checkResponseElement(sprintf('select[name="article[end_date][year]"] option[value="%s"][selected="selected"]', date('Y', $tomorrow)))-> 49 checkResponseElement('select[name="article[end_date][hour]"]', false)-> 50 checkResponseElement('select[name="article[end_date][minute]"]', false) 49 51 ; 52 53 // non rich date (with time) 54 $b-> 55 customizeGenerator(array('edit' => array('fields' => array('end_date' => array('params' => 'withtime=true rich=false')))))-> 56 57 post('/article/edit/id/1', array('article' => array('end_date' => array('day' => date('d', $tomorrow), 'month' => date('m', $tomorrow), 'year' => date('Y', $tomorrow), 'hour' => date('G', $tomorrow), 'minute' => date('i', $tomorrow)))))-> 58 isStatusCode(302)-> 59 isRequestParameter('module', 'article')-> 60 isRequestParameter('action', 'edit')-> 61 62 isRedirected(true)-> 63 followRedirect()-> 64 checkResponseElement(sprintf('select[name="article[end_date][day]"] option[value="%s"][selected="selected"]', date('d', $tomorrow)))-> 65 checkResponseElement(sprintf('select[name="article[end_date][month]"] option[value="%s"][selected="selected"]', date('m', $tomorrow)))-> 66 checkResponseElement(sprintf('select[name="article[end_date][year]"] option[value="%s"][selected="selected"]', date('Y', $tomorrow)))-> 67 checkResponseElement(sprintf('select[name="article[end_date][hour]"] option[value="%s"][selected="selected"]', date('G', $tomorrow)))-> 68 checkResponseElement(sprintf('select[name="article[end_date][minute]"] option[value="%s"][selected="selected"]', date('i', $tomorrow))) 69 ; trunk/test/unit/helper/DateFormHelperTest.php
r2849 r3294 81 81 } 82 82 83 $t = new lime_test( 77, new lime_output_color());83 $t = new lime_test(81, new lime_output_color()); 84 84 85 85 $context = sfContext::getInstance(); … … 189 189 // select_time_tag() 190 190 $t->diag('select_time_tag()'); 191 $t->like(select_time_tag('time'), '/<select name="time\[hour\]" id="time_hour">/', 'select_time_tag() outputs a select tag for hours'); 192 $t->like(select_time_tag('time'), '/selected="selected">'.date('H').'/', 'select_time_tag() selects the current hours by default'); 193 $t->like(select_time_tag('time'), '/<select name="time\[minute\]" id="time_minute">/', 'select_time_tag() outputs a select tag for minutes'); 194 $t->like(select_time_tag('time'), '/selected="selected">'.date('i').'/', 'select_time_tag() selects the current minutes by default'); 191 195 $t->todo('select_time_tag()'); 192 196