Source for file function.pnformdateinput.php
Documentation is available at function.pnformdateinput.php
* @copyright (c) 2006, Zikula Development Team
* @link http://www.zikula.org
* @version $Id: function.pnformdateinput.php 24425 2008-07-02 12:13:57Z markwest $
* @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html
* @package Zikula_Template_Plugins
/** Make sure to use require_once() instead of Loader::requireOnce() since "function.pnformtextinput.php"
is loaded by Smarty (the base render class) with the use of require_once(). We do not want to
get in conflict with that.*/
require_once('system/pnForm/plugins/function.pnformtextinput.php');
* The date input plugin is a text input plugin that only allows dates to be posted. The value
* returned from {@link pnForm::pnFormGetValues()} is although a string of the format 'YYYY-MM-DD'
* since this is the standard internal Zikula format for dates.
* You can also use all of the features from the pnFormTextInput plugin since the date input
* Enable or disable input of time in addition to the date
* This parameter enables the input to be pre-filled with the current date or similar other well defined
* You can set the default value to be one of the following:
* - now: current date and time
* - monthstart: first day in current month
* - monthend: last day in current month
* - yearstart: first day in the year
* - yearend: last day in the year
return __FILE__ ; // FIXME: may be found in smarty's data???
function create(&$render, &$params)
$params['width'] = ($this->includeTime ? '10em' : '8em');;
parent::create($render, $params);
$this->cssClass .= ' date';
static $firstTime = true;
if (!empty($this->defaultValue) && !$render->pnFormIsPostBack())
$d = strtolower($this->defaultValue);
$date = mktime(0,0,0, $now['mon'], $now['mday'], $now['year']);
else if ($d == 'monthstart')
$date = mktime(0,0,0, $now['mon'], 1, $now['year']);
else if ($d == 'monthend')
$daysInMonth = date('t');
$date = mktime(0,0,0, $now['mon'], $daysInMonth, $now['year']);
else if ($d == 'yearstart')
$date = mktime(0,0,0, 1, 1, $now['year']);
else if ($d == 'yearend')
$date = mktime(0,0,0, 12, 31, $now['year']);
$this->text = 'Unknown default date';
$result = '<span class="date" style="white-space: nowrap">';
$result .= parent::render($render);
$result .= " <img id=\"{$this->id}_img\" src=\"javascript/jscalendar/img.gif\" style=\"vertical-align: middle\" class=\"clickable\" alt=\" $txt\" /></span> ";
$headers[] = 'javascript/jscalendar/calendar.js';
$headers[] = "javascript/jscalendar/lang/calendar-$lang.js";
$headers[] = 'javascript/jscalendar/calendar-setup.js';
PageUtil::addVar('stylesheet', 'javascript/jscalendar/calendar-win2k-cold-2.css');
$this->initDate = str_replace('-',',', $this->initDate);
$result .= "<script type=\"text/javascript\">
inputField : \"{$this->id}\",
ifFormat : \"%Y-%m-%d %H:%M\",
button : \"{$this->id}_img\",
$result .= "<script type=\"text/javascript\">
inputField : \"{$this->id}\",
button : \"{$this->id}_img\",
parent::validate($render);
return $render->pnFormRegisterPlugin('pnFormDateInput', $params);
|