/** * Returns complete formatted date * * @Args : formname -> name of the inputfield * content -> value of textfield * type_config -> array with values from the CMS:tag * cms_side['view'] -> the current view of the user, 'edit' or 'preview' * ['edit'] -> 'true' if user set the mod in templateconfig as active * if user set inactiv var is not set * @Return String HTML fields * @Access public */ function type_form_date($formname, $content, $type_config, $cms_side) { global $cfg_cms, $sess; include_once 'HTML/QuickForm.php'; if (!_type_check_editable($cms_side['edit'], $type_config['editable'], $cms_side['view'])) { return _type_get_element_hidden($formname, $content); } if (empty($content)) { $content = time(); } $optionfields = ""; // Datumsangaben für Ausgabe formatieren if (!(empty($type_config['formdateformat']) || $type_config['formdateformat'] == '')) { if ($type_config['formdateformat'] == "default-cms-date-format") { $type_config['formdateformat'] = $cfg_cms['FormatDate']; } if ($type_config['formdateformat'] == "default-cms-time-format") { $type_config['formdateformat'] = $cfg_cms['FormatTime']; } if ($type_config['formdateformat'] == "default-cms-format") { $type_config['formdateformat'] = $cfg_cms['FormatDate'] . " " . $cfg_cms['FormatTime']; } $form = new HTML_QuickForm(''); $form->setDefaults(array($formname => $content)); $dateOptions = array('format' => $type_config['formdateformat'], 'language' => 'de', 'optionIncrement' => array('i' => 5)); $contentYear = date("Y", $content); if (!empty($type_config['minyear'])) { $dateOptions['minYear'] = $type_config['minyear']; } else { $dateOptions['minYear'] = date("Y") - 5; } if ($dateOptions['minYear'] > $contentYear) { $dateOptions['minYear'] = $contentYear; } if (!empty($type_config['maxyear'])) { $dateOptions['maxYear'] = $type_config['maxyear']; } else { $dateOptions['maxYear'] = date("Y") + 5; } if ($dateOptions['maxYear'] < $contentYear) { $dateOptions['maxYear'] = $contentYear; } $form->addElement('date', $formname, 'Date2:', $dateOptions); $temp_fileds = $form->toArray(); $optionfields .= $temp_fileds[elements][0][html]; $optionfields .= ' ' . date($type_config['formdateformat'], $content); } else { $type_config['formdateformat'] = 'd.m.Y'; $startdate = date($type_config['formdateformat'], $content); $content = getdate($content); // Datumsangaben für Ausgabe formatieren $optionfields .= _type_get_element_hidden($formname . '[0]', 'd.m.Y'); $optionfields .= '<input type="text" id="' . $formname . '" name="' . $formname . '[1]" value="' . $startdate . '" size="10" maxlength="10" style="width: 85px;">'; $optionfields .= ' <script language="JavaScript1.2"> function callback_' . $formname . '(date, month, year) { if (String(month).length == 1) { month = "0" + month; } if (String(date).length == 1) { date = "0" + date; } document.getElementById("' . $formname . '").value = date + "." + month + "." + year; } calendar' . $formname . ' = new dynCalendar("calendar' . $formname . '", "callback_' . $formname . '", "' . $cfg_cms['cms_html_path'] . '/tpl/standard/img/"); calendar' . $formname . '.setMonthCombo(true); calendar' . $formname . '.setYearCombo(true); </script>'; $optionfields .= ' dd.mm.yyyy'; $optionfields .= ' ' . date($type_config['formdateformat']); } return '<td> ' . $optionfields . ' </td>' . "\n"; }
/** * Returns complete formatted date * * @Args : formname -> name of the inputfield * content -> value of textfield * type_config -> array with values from the CMS:tag * cms_side['view'] -> the current view of the user, 'edit' or 'preview' * ['edit'] -> 'true' if user set the mod in templateconfig as active * if user set inactiv var is not set * @Return String HTML fields * @Access public */ function type_form_date($formname, $content, $type_config) { global $cfg_cms, $sess; if (!_type_check_editable($type_config['editable'])) { return _type_get_element_hidden($formname, $content); } if (empty($content)) { $content = time(); } $startdate = date($cfg_cms['format_date'], $content); $starttime = date($cfg_cms['format_time'], $content); $content = getdate($content); $optionfields = ""; $optionfields .= _type_get_element_hidden($formname . '[0]', $cfg_cms['format_date']); $optionfields .= '<input type="text" id="' . $formname . '_1" name="' . $formname . '[1]" value="' . $startdate . '" size="10" maxlength="10" style="width: 85px;" class="sfDatepicker">'; $optionfields .= ' '; $optionfields .= _type_get_element_hidden($formname . '[2]', $cfg_cms['format_time']); $optionfields .= '<input type="text" id="' . $formname . '_3" name="' . $formname . '[3]" value="' . $starttime . '" size="8" maxlength="8" style="width: 55px;">'; return '<td> ' . $optionfields . ' </td>' . "\n"; }