mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Removed depreciated calls to FormHelper::labelTag();
Added fixes from 1.1.x.x to HtmlHelper::dateTimeOptionTag(); git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@3320 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
06f8fbb7c9
commit
fc431393fb
2 changed files with 50 additions and 25 deletions
|
@ -286,7 +286,7 @@ class FormHelper extends Helper {
|
||||||
*/
|
*/
|
||||||
function generateTime($tagName, $prompt, $required = false, $errorMsg = null, $size = 20, $htmlOptions = null, $selected = null) {
|
function generateTime($tagName, $prompt, $required = false, $errorMsg = null, $size = 20, $htmlOptions = null, $selected = null) {
|
||||||
$str = $this->Html->dateTimeOptionTag($tagName, 'NONE', '24', $selected, $htmlOptions);
|
$str = $this->Html->dateTimeOptionTag($tagName, 'NONE', '24', $selected, $htmlOptions);
|
||||||
$strLabel = $this->labelTag($tagName, $prompt);
|
$strLabel = $this->label($tagName, $prompt);
|
||||||
$divClass = "optional";
|
$divClass = "optional";
|
||||||
if ($required) {
|
if ($required) {
|
||||||
$divClass = "required";
|
$divClass = "required";
|
||||||
|
|
|
@ -1029,7 +1029,6 @@ class HtmlHelper extends Helper {
|
||||||
* @return string The HTML formatted OPTION element
|
* @return string The HTML formatted OPTION element
|
||||||
*/
|
*/
|
||||||
function dateTimeOptionTag($tagName, $dateFormat = 'DMY', $timeFormat = '12', $selected = null, $selectAttr = null, $optionAttr = null, $showEmpty = true) {
|
function dateTimeOptionTag($tagName, $dateFormat = 'DMY', $timeFormat = '12', $selected = null, $selectAttr = null, $optionAttr = null, $showEmpty = true) {
|
||||||
|
|
||||||
$day = null;
|
$day = null;
|
||||||
$month = null;
|
$month = null;
|
||||||
$year = null;
|
$year = null;
|
||||||
|
@ -1045,19 +1044,20 @@ class HtmlHelper extends Helper {
|
||||||
|
|
||||||
if (is_int($selected)) {
|
if (is_int($selected)) {
|
||||||
$selected = strftime('%G-%m-%d %T', $selected);
|
$selected = strftime('%G-%m-%d %T', $selected);
|
||||||
|
$selected = strftime('%G-%m-%d %H:%M:%S', $selected);
|
||||||
}
|
}
|
||||||
|
|
||||||
$meridian = 'am';
|
$meridian = 'am';
|
||||||
$selected = trim($selected);
|
$pos = strpos($selected, '-');
|
||||||
if (strpos($selected, ' ') === false) {
|
if($pos !== false){
|
||||||
$selected = '0000-00-00 ' . $selected;
|
$date = explode('-', $selected);
|
||||||
|
$days = explode(' ', $date[2]);
|
||||||
|
$day = $days[0];
|
||||||
|
$month = $date[1];
|
||||||
|
$year = $date[0];
|
||||||
|
} else {
|
||||||
|
$days[1] = $selected;
|
||||||
}
|
}
|
||||||
$date = explode('-', $selected);
|
|
||||||
$days = explode(' ', $date[2]);
|
|
||||||
|
|
||||||
$day = $days[0];
|
|
||||||
$month = $date[1];
|
|
||||||
$year = $date[0];
|
|
||||||
|
|
||||||
if ($timeFormat != 'NONE' && !empty($timeFormat)) {
|
if ($timeFormat != 'NONE' && !empty($timeFormat)) {
|
||||||
$time = explode(':', $days[1]);
|
$time = explode(':', $days[1]);
|
||||||
|
@ -1074,19 +1074,44 @@ class HtmlHelper extends Helper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$elements = array('Day','Month','Year','Hour','Minute','Meridian');
|
||||||
|
if (isset($selectAttr['id'])) {
|
||||||
|
if (is_string($selectAttr['id'])) {
|
||||||
|
// build out an array version
|
||||||
|
foreach ($elements as $element) {
|
||||||
|
$selectAttrName = 'select' . $element . 'Attr';
|
||||||
|
${$selectAttrName} = $selectAttr;
|
||||||
|
${$selectAttrName}['id'] = $selectAttr['id'] . $element;
|
||||||
|
}
|
||||||
|
} elseif (is_array($selectAttr['id'])) {
|
||||||
|
// check for missing ones and build selectAttr for each element
|
||||||
|
foreach ($elements as $element) {
|
||||||
|
$selectAttrName = 'select' . $element . 'Attr';
|
||||||
|
${$selectAttrName} = $selectAttr;
|
||||||
|
${$selectAttrName}['id'] = $selectAttr['id'][strtolower($element)];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// build the selectAttrName with empty id's to pass
|
||||||
|
foreach ($elements as $element) {
|
||||||
|
$selectAttrName = 'select' . $element . 'Attr';
|
||||||
|
${$selectAttrName} = $selectAttr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch($dateFormat) {
|
switch($dateFormat) {
|
||||||
case 'DMY':
|
case 'DMY': // so uses the new selex
|
||||||
$opt = $this->dayOptionTag($tagName, null, $day, $selectAttr, $optionAttr, $showEmpty) . '-' .
|
$opt = $this->dayOptionTag($tagName, null, $day, $selectDayAttr, $optionAttr, $showEmpty) . '-' .
|
||||||
$this->monthOptionTag($tagName, null, $month, $selectAttr, $optionAttr, $showEmpty) . '-' . $this->yearOptionTag($tagName, null, null, null, $year, $selectAttr, $optionAttr, $showEmpty);
|
$this->monthOptionTag($tagName, null, $month, $selectMonthAttr, $optionAttr, $showEmpty) . '-' . $this->yearOptionTag($tagName, null, null, null, $year, $selectYearAttr, $optionAttr, $showEmpty);
|
||||||
break;
|
break;
|
||||||
case 'MDY':
|
case 'MDY':
|
||||||
$opt = $this->monthOptionTag($tagName, null, $month, $selectAttr, $optionAttr, $showEmpty) . '-' .
|
$opt = $this->monthOptionTag($tagName, null, $month, $selectMonthAttr, $optionAttr, $showEmpty) . '-' .
|
||||||
$this->dayOptionTag($tagName, null, $day, $selectAttr, $optionAttr, $showEmpty) . '-' . $this->yearOptionTag($tagName, null, null, null, $year, $selectAttr, $optionAttr, $showEmpty);
|
$this->dayOptionTag($tagName, null, $day, $selectDayAttr, $optionAttr, $showEmpty) . '-' . $this->yearOptionTag($tagName, null, null, null, $year, $selectYearAttr, $optionAttr, $showEmpty);
|
||||||
break;
|
break;
|
||||||
case 'YMD':
|
case 'YMD':
|
||||||
$opt = $this->yearOptionTag($tagName, null, null, null, $year, $selectAttr, $optionAttr, $showEmpty) . '-' .
|
$opt = $this->yearOptionTag($tagName, null, null, null, $year, $selectYearAttr, $optionAttr, $showEmpty) . '-' .
|
||||||
$this->monthOptionTag($tagName, null, $month, $selectAttr, $optionAttr, $showEmpty) . '-' .
|
$this->monthOptionTag($tagName, null, $month, $selectMonthAttr, $optionAttr, $showEmpty) . '-' .
|
||||||
$this->dayOptionTag($tagName, null, $day, $selectAttr, $optionAttr, $showEmpty);
|
$this->dayOptionTag($tagName, null, $day, $selectDayAttr, $optionAttr, $showEmpty);
|
||||||
break;
|
break;
|
||||||
case 'NONE':
|
case 'NONE':
|
||||||
default:
|
default:
|
||||||
|
@ -1096,13 +1121,13 @@ class HtmlHelper extends Helper {
|
||||||
|
|
||||||
switch($timeFormat) {
|
switch($timeFormat) {
|
||||||
case '24':
|
case '24':
|
||||||
$opt .= $this->hourOptionTag($tagName, null, true, $hour, $selectAttr, $optionAttr, $showEmpty) . ':' .
|
$opt .= $this->hourOptionTag($tagName, null, true, $hour, $selectHourAttr, $optionAttr, $showEmpty) . ':' .
|
||||||
$this->minuteOptionTag($tagName, null, $min, $selectAttr, $optionAttr, $showEmpty);
|
$this->minuteOptionTag($tagName, null, $min, $selectMinuteAttr, $optionAttr, $showEmpty);
|
||||||
break;
|
break;
|
||||||
case '12':
|
case '12':
|
||||||
$opt .= $this->hourOptionTag($tagName, null, false, $hour, $selectAttr, $optionAttr, $showEmpty) . ':' .
|
$opt .= $this->hourOptionTag($tagName, null, false, $hour, $selectHourAttr, $optionAttr, $showEmpty) . ':' .
|
||||||
$this->minuteOptionTag($tagName, null, $min, $selectAttr, $optionAttr, $showEmpty) . ' ' .
|
$this->minuteOptionTag($tagName, null, $min, $selectMinuteAttr, $optionAttr, $showEmpty) . ' ' .
|
||||||
$this->meridianOptionTag($tagName, null, $meridian, $selectAttr, $optionAttr, $showEmpty);
|
$this->meridianOptionTag($tagName, null, $meridian, $selectMeridianAttr, $optionAttr, $showEmpty);
|
||||||
break;
|
break;
|
||||||
case 'NONE':
|
case 'NONE':
|
||||||
default:
|
default:
|
||||||
|
@ -1113,4 +1138,4 @@ class HtmlHelper extends Helper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
Loading…
Add table
Reference in a new issue