function controlToHTML($name) { // initialize the time if none was set on instantiation if ($this->default == 0) { $this->default = time(); } //get only the time part of the timestamp $myDate = getdate($this->default); $this->default = $myDate["hours"] * 60 * 60 + $myDate["minutes"] * 60; $template = new ControlTemplate("TimeControl"); $template->assign('name', $name); $template->assign('timestamp', $this->default); $template->assign('hourformat', exponent_datetime_getHourFormat()); $template->assign('showcontrol', $this->showControl ? "true" : "false"); return $template->render(); }
function controlToHTML($name) { ob_start(); if ($this->default == 0) { $this->default = time(); } $imgsrc = PATH_RELATIVE . "external/jscalendar/img.gif"; if (is_readable(THEME_ABSOLUTE . "icons/calendar_trigger.gif")) { $imgsrc = THEME_RELATIVE . "icons/calendar_trigger.gif"; } if (is_readable(THEME_ABSOLUTE . "css/PopupDateTimeControl.css")) { echo '<style type="text/css"> @import url(' . THEME_RELATIVE . 'subsystems/forms/controls/PopupDateTimeControl/css/Default.css);</style>'; } else { echo '<style type="text/css"> @import url(' . PATH_RELATIVE . 'subsystems/forms/controls/PopupDateTimeControl/css/Default.css);</style>'; } $default = ""; if ($this->default == null) { $this->default = time; } $default = strftime("%m/%d/%Y %H:%M", $this->default); echo '<input type="hidden" name="' . $name . '_hidden" id="' . $name . '_hidden" value="' . $default . '" />'; echo '<span class="'; if ($this->disabled) { echo 'datefield_disabled'; } else { echo 'datefield'; } echo '" id="' . $name . '_span">'; if ($this->default == null) { echo '<No Date Selected>'; } else { if ($this->showtime) { echo strftime("%A, %B %d, %Y %l:%M %P", $this->default); } else { echo strftime("%A, %B %d, %Y", $this->default); } } echo '</span>'; echo '<img align="texttop" src="' . $imgsrc . '" id="' . $name . '_trigger" '; if ($this->disabled) { echo 'style="visibility: hidden;" '; } else { echo 'style="cursor: pointer;" '; } echo 'title="Date selector" onclick="initPopupDateTimeControl_' . $name . '();" class="highlight_on_hover"/>'; if ($this->disable_text != "") { // PopupDateTimeControl_enable(this.form,\''.$name.'\'); echo '<input align="texttop" style="margin-top: -2px;" type="checkbox" name="' . $name . '_disabled" onChange="PopupDateTimeControl_enable(this.form,\'' . $name . '\');" onClick="PopupDateTimeControl_enable(this.form,\'' . $name . '\');" '; if ($this->disabled) { echo ' checked="checked"'; } echo '/>' . $this->disable_text; } else { # $html .= '<input type="hidden" name="'.$name.'_enabled" value="1" />'; } ?> <script type="text/javascript"> Exponent.includeOnce("jscalendar1", "<?php echo PATH_RELATIVE; ?> external/jscalendar/calendar.js"); Exponent.includeOnce("jscalendar2", "<?php echo PATH_RELATIVE; ?> external/jscalendar/lang/calendar-<?php echo LANG; ?> .js"); Exponent.includeOnce("jscalendar3", "<?php echo PATH_RELATIVE; ?> external/jscalendar/calendar-setup.js"); Exponent.includeOnce("PopupDateTimeControl", "<?php echo PATH_RELATIVE; ?> subsystems/forms/controls/PopupDateTimeControl/js/Default.js"); function initPopupDateTimeControl<?php echo "_" . $name; ?> () { Calendar.setup({ inputField : "<?php echo $name; ?> _hidden", ifFormat : "%m/%d/%Y %H:%M", displayArea : "<?php echo $name; ?> _span", <?php if ($this->showtime) { ?> daFormat : "%A, %B %d, %Y %l:%M %P", showsTime : true, singleClick : false, <?php } else { ?> daFormat : "%A, %B %d, %Y", singleClick : true, <?php } ?> timeFormat : "<?php echo exponent_datetime_getHourFormat(); ?> ", button : "<?php echo $name; ?> _trigger", align : "Tl", //TODO: write proper timezone handling for Exponent date : new Date(<?php echo $this->default * 1000; ?> + (new Date().getTimezoneOffset() * 60 * 1000)), step : 1, firstDay : <?php echo DISPLAY_WEEKS_START_ON; ?> }) } Exponent.register('initPopupDateTimeControl<?php echo "_" . $name; ?> ()'); </script> <?php $html = ob_get_contents(); ob_end_clean(); return $html; }