blob: 7d37ecde57ce20ac88e330b834bf90210c535129 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
<?php
namespace Bitweaver\Plugins;
use Bitweaver\BitDate;
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
*/
/**
* Smarty {jscalendar} plugin
*
* Type: function<br>
* Name: jscalendar<br>
* Purpose: Prints the dropdowns for date selection.
*
* ChangeLog:<br>
* - 1.0 initial release
* @version 1.0
* @author Stephan Borg
* @param array
* @param array Smarty
* @return string
*/
function smarty_function_jscalendar($params, &$gBitSmarty) {
global $gBitSystem;
if( $gBitSystem->isFeatureActive( 'site_use_jscalendar' ) ) {
// Default values
$inputField = ''; // ID of the input field
$fieldFormat = '%s'; // format of the input field
$electric = 'false'; // ID of the span where the date is to be shown
$time = time(); // override the currently set date
$onUpdate = ''; // execute the following javascript function when a link is pressed
$daFormat = $gBitSystem->getConfig( 'site_short_date_format' ).' '.$gBitSystem->getConfig( 'site_short_time_format' ); // format of output date
$displayArea = '';
// override default values
extract( $params );
$time = $gBitSystem->mServerTimestamp->getDisplayDateFromUTC( $time );
$time = BitDate::strftime( "%m/%d/%Y %H:%M", $time );
$html_result = $readonly ? $time
: "<script type=\"text/javascript\">//<![CDATA[
Calendar.setup({
date : \"$time\",
inputField : \"$inputField\",
ifFormat : \"$fieldFormat\",
daFormat : \"$daFormat\",
displayArea : \"$displayArea\",
electric : $electric,
onUpdate : $onUpdate
});
//]]></script>";
return $html_result;
} else {
return '';
}
}
|