* @license http://www.contenido.org/license/LIZENZ.txt * @link http://www.4fb.de * @link http://www.contenido.org * * {@internal * created * * $Id: class.widgets.datechooser.php 2 2011-07-20 12:00:48Z oldperl $: * }} * */ if (!defined('CON_FRAMEWORK')) { die('Illegal call'); } class cDateChooser extends cDatefield { var $_oCalendar; var $_oImage; var $_oButton; function __construct($name, $initValue = false) { parent::__construct($name, ""); $this->_oImage = new cHTMLImage; $this->_oImage->setSrc("images/pfeil_runter.gif"); $this->_oImage->setStyle("margin-left: 2px; cursor: pointer;"); $this->_oCalendar = new cCalendarControl; $this->_oDate->setSourceFormat(cDateTime_ISO); $this->_oDate->setTargetFormat(cDateTime_Locale_DateOnly); if ($initValue === false) { $this->_oDate->set(date("Y-m-d H:i:s")); } else { $this->_oDate->set($initValue); } $this->_aSelectIDs = array(); } function setSelectsToHide($aSelectIDs) { if (!is_array($aSelectIDs)) { return; } foreach ($aSelectIDs as $key => $data) { $aSelectIDs[$key] = '"' . $data . '"'; } $this->_aSelectIDs = $aSelectIDs; } function setReadOnly($bReadOnly = true) { $this->_bReadOnly = $bReadOnly; } function render() { if ($this->_bReadOnly) { $this->updateAttributes(array("readonly" => "readonly")); } $sDatefield = parent::render(); $sTimeformat = getEffectiveSetting("backend", "timeformat_date", "Y-m-d"); $parseScript = ' '; $sEventRegister = ''; $clickScript = "if (!document.getElementById('{wid}').disabled) { if (document.getElementById('{did}_display').style.display == 'none') { {wid}_passToWidget('" . getEffectiveSetting("backend", "timeformat_date", "Y-m-d") . "', document.getElementById('" . $this->getId() . "').value); document.getElementById('{did}_display').style.display = 'block'; {wid}_hideselects(true); } else { document.getElementById('{did}_display').style.display = 'none'; {wid}_hideselects(false); } }"; $div = new cHTMLDiv; $this->_oImage->setEvent("click", $clickScript); $final = $parseScript . '
' . $sDatefield . '' . $this->_oImage->render() . '
' . $sEventRegister; $final = str_replace("{wid}", $this->getId(), $final); $final = str_replace("{cid}", $this->_oCalendar->getId(), $final); $final = str_replace("{did}", $div->getId(), $final); return ($final); } }