From 8df3db566a3a937b45ebf11adb90d265e6f5e2d4 Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Sun, 17 Nov 2019 20:45:02 +0100 Subject: initial checking of customized version 1.0rc9 --- js/jscalendar/calendar.php | 119 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 js/jscalendar/calendar.php (limited to 'js/jscalendar/calendar.php') diff --git a/js/jscalendar/calendar.php b/js/jscalendar/calendar.php new file mode 100644 index 0000000..5b9120d --- /dev/null +++ b/js/jscalendar/calendar.php @@ -0,0 +1,119 @@ +calendar_file = 'calendar_stripped.js'; + $this->calendar_setup_file = 'calendar-setup_stripped.js'; + } else { + $this->calendar_file = 'calendar.js'; + $this->calendar_setup_file = 'calendar-setup.js'; + } + $this->calendar_lang_file = 'lang/calendar-' . $lang . '.js'; + $this->calendar_theme_file = $theme.'.css'; + $this->calendar_lib_path = preg_replace('/\/+$/', '/', $calendar_lib_path); + $this->calendar_options = array('ifFormat' => '%Y/%m/%d', + 'daFormat' => '%Y/%m/%d'); + } + + function set_option($name, $value) { + $this->calendar_options[$name] = $value; + } + + function load_files() { + echo $this->get_load_files_code(); + } + + function get_load_files_code() { + $code = ( '' . NEWLINE ); + $code .= ( '' . NEWLINE ); + $code .= ( '' . NEWLINE ); + $code .= ( '' ); + return $code; + } + + function _make_calendar($other_options = array()) { + $js_options = $this->_make_js_hash(array_merge($this->calendar_options, $other_options)); + $code = ( '' ); + return $code; + } + + function make_input_field($cal_options = array(), $field_attributes = array()) { + $id = $this->_gen_id(); + $attrstr = $this->_make_html_attr(array_merge($field_attributes, + array('id' => $this->_field_id($id), + 'type' => 'text'))); + echo ''; + echo '' . + ''; + + $options = array_merge($cal_options, + array('inputField' => $this->_field_id($id), + 'button' => $this->_trigger_id($id))); + echo $this->_make_calendar($options); + } + + /// PRIVATE SECTION + + function _field_id($id) { return 'f-calendar-field-' . $id; } + function _trigger_id($id) { return 'f-calendar-trigger-' . $id; } + function _gen_id() { static $id = 0; return ++$id; } + + function _make_js_hash($array) { + $jstr = ''; + reset($array); + while (list($key, $val) = each($array)) { + if (is_bool($val)) + $val = $val ? 'true' : 'false'; + else if (!is_numeric($val)) + $val = '"'.$val.'"'; + if ($jstr) $jstr .= ','; + $jstr .= '"' . $key . '":' . $val; + } + return $jstr; + } + + function _make_html_attr($array) { + $attrstr = ''; + reset($array); + while (list($key, $val) = each($array)) { + $attrstr .= $key . '="' . $val . '" '; + } + return $attrstr; + } +}; + +?> \ No newline at end of file -- cgit v1.2.3-54-g00ecf