Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ecommerce/jscalendar/calendar.php
Go to the documentation of this file.
1 <?php
14 define('NEWLINE', "\n");
15
16 class DHTML_Calendar {
17 var $calendar_lib_path;
18
19 var $calendar_file;
20 var $calendar_lang_file;
21 var $calendar_setup_file;
22 var $calendar_theme_file;
23 var $calendar_options;
24
25 function DHTML_Calendar($calendar_lib_path = '/calendar/',
26 $lang = 'en',
27 $theme = 'calendar-win2k-1',
28 $stripped = true) {
29 if ($stripped) {
30 $this->calendar_file = 'calendar_stripped.js';
31 $this->calendar_setup_file = 'calendar-setup_stripped.js';
32 } else {
33 $this->calendar_file = 'calendar.js';
34 $this->calendar_setup_file = 'calendar-setup.js';
35 }
36 $this->calendar_lang_file = 'lang/calendar-' . $lang . '.js';
37 $this->calendar_theme_file = $theme.'.css';
38 $this->calendar_lib_path = preg_replace('/\/+$/', '/', $calendar_lib_path);
39 $this->calendar_options = array('ifFormat' => '%Y/%m/%d',
40 'daFormat' => '%Y/%m/%d');
41 }
42
43 function set_option($name, $value) {
44 $this->calendar_options[$name] = $value;
45 }
46
47 function load_files() {
48 echo $this->get_load_files_code();
49 }
50
51 function get_load_files_code() {
52 $code = ( '<link rel="stylesheet" type="text/css" media="all" href="' .
53 $this->calendar_lib_path . $this->calendar_theme_file .
54 '" />' . NEWLINE );
55 $code .= ( '<script type="text/javascript" src="' .
56 $this->calendar_lib_path . $this->calendar_file .
57 '"></script>' . NEWLINE );
58 $code .= ( '<script type="text/javascript" src="' .
59 $this->calendar_lib_path . $this->calendar_lang_file .
60 '"></script>' . NEWLINE );
61 $code .= ( '<script type="text/javascript" src="' .
62 $this->calendar_lib_path . $this->calendar_setup_file .
63 '"></script>' );
64 return $code;
65 }
66
67 function _make_calendar($other_options = array()) {
68 $js_options = $this->_make_js_hash(array_merge($this->calendar_options, $other_options));
69 $code = ( '<script type="text/javascript">Calendar.setup({' .
70 $js_options .
71 '});</script>' );
72 return $code;
73 }
74
75 function make_input_field($cal_options = array(), $field_attributes = array()) {
76 $id = $this->_gen_id();
77 $attrstr = $this->_make_html_attr(array_merge($field_attributes,
78 array('id' => $this->_field_id($id),
79 'type' => 'text')));
80 echo '<input ' . $attrstr .'/>';
81 echo '<a href="#" id="'. $this->_trigger_id($id) . '">' .
82 '<img align="middle" border="0" src="' . $this->calendar_lib_path . 'img.gif" alt="" /></a>';
83
84 $options = array_merge($cal_options,
85 array('inputField' => $this->_field_id($id),
86 'button' => $this->_trigger_id($id)));
87 echo $this->_make_calendar($options);
88 }
89
91
92 function _field_id($id) { return 'f-calendar-field-' . $id; }
93 function _trigger_id($id) { return 'f-calendar-trigger-' . $id; }
94 function _gen_id() { static $id = 0; return ++$id; }
95
96 function _make_js_hash($array) {
97 $jstr = '';
98 reset($array);
99 while (list($key, $val) = each($array)) {
100 if (is_bool($val))
101 $val = $val ? 'true' : 'false';
102 else if (!is_numeric($val))
103 $val = '"'.$val.'"';
104 if ($jstr) $jstr .= ',';
105 $jstr .= '"' . $key . '":' . $val;
106 }
107 return $jstr;
108 }
109
110 function _make_html_attr($array) {
111 $attrstr = '';
112 reset($array);
113 while (list($key, $val) = each($array)) {
114 $attrstr .= $key . '="' . $val . '" ';
115 }
116 return $attrstr;
117 }
118 };
119
120 ?>
DHTML_Calendar
Definition: ecommerce/jscalendar/calendar.php:16
DHTML_Calendar\_trigger_id
_trigger_id($id)
Definition: ecommerce/jscalendar/calendar.php:93
DHTML_Calendar\make_input_field
make_input_field($cal_options=array(), $field_attributes=array())
Definition: ecommerce/jscalendar/calendar.php:75
DHTML_Calendar\$calendar_setup_file
$calendar_setup_file
Definition: ecommerce/jscalendar/calendar.php:21
DHTML_Calendar\$calendar_lang_file
$calendar_lang_file
Definition: ecommerce/jscalendar/calendar.php:20
DHTML_Calendar\$calendar_lib_path
$calendar_lib_path
Definition: ecommerce/jscalendar/calendar.php:17
DHTML_Calendar\load_files
load_files()
Definition: ecommerce/jscalendar/calendar.php:47
DHTML_Calendar\set_option
set_option($name, $value)
Definition: ecommerce/jscalendar/calendar.php:43
DHTML_Calendar\_gen_id
_gen_id()
Definition: ecommerce/jscalendar/calendar.php:94
DHTML_Calendar\_field_id
_field_id($id)
PRIVATE SECTION.
Definition: ecommerce/jscalendar/calendar.php:92
DHTML_Calendar\DHTML_Calendar
DHTML_Calendar($calendar_lib_path='/calendar/', $lang='en', $theme='calendar-win2k-1', $stripped=true)
Definition: ecommerce/jscalendar/calendar.php:25
DHTML_Calendar\_make_js_hash
_make_js_hash($array)
Definition: ecommerce/jscalendar/calendar.php:96
DHTML_Calendar\_make_calendar
_make_calendar($other_options=array())
Definition: ecommerce/jscalendar/calendar.php:67
DHTML_Calendar\_make_html_attr
_make_html_attr($array)
Definition: ecommerce/jscalendar/calendar.php:110
DHTML_Calendar\$calendar_theme_file
$calendar_theme_file
Definition: ecommerce/jscalendar/calendar.php:22
DHTML_Calendar\get_load_files_code
get_load_files_code()
Definition: ecommerce/jscalendar/calendar.php:51
DHTML_Calendar\$calendar_options
$calendar_options
Definition: ecommerce/jscalendar/calendar.php:23
DHTML_Calendar\$calendar_file
$calendar_file
Definition: ecommerce/jscalendar/calendar.php:19
$name
$name
Definition: companytypelist.php:194
$id
$id
Definition: companytypelist.php:193
NEWLINE
const NEWLINE
Definition: ecommerce/jscalendar/calendar.php:14
$lang
$lang
Definition: ecommerce/jscalendar/test.php:4
$options
$options
Definition: optionlist.php:56
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.