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 setOption($name, $value)
{
$this->calendar_options[$name] = $value;
}
function loadFiles()
{
static $rendered = false;
$code = '';
if(!$rendered)
{
$code = '' . $this->newline;
$code .= '' . $this->newline;
$code .= '' . $this->newline;
$code .= '';
}
$rendered = true;
return $code;
}
function makeButton($field_id, $cal_options = array(), $field_attributes = array())
{
$id = $this->_genId();
if(isset($field_attributes['src']) && $field_attributes['src'])
$src = $field_attributes['src'];
else
$src = $this->calendar_lib_path . 'img.gif';
$out = '' .
'
';
$options = array_merge($cal_options,
array('inputField' => $field_id,
'button' => $this->_triggerId($id)));
return $out . $this->_makeCalendar($options);
}
function _makeCalendar($other_options = array())
{
$js_options = $this->_makeJsHash(array_merge($this->calendar_options, $other_options));
$code = '';
return $code;
}
function _fieldId($id) { return 'f-calendar-field-' . $id; }
function _triggerId($id) { return 'f-calendar-trigger-' . $id; }
function _genId() { static $id = 0; return ++$id; }
function _makeJsHash($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 _makeHtmlAttr($array)
{
$attrstr = '';
reset($array);
while(list($key, $val) = each($array))
{
$attrstr .= $key . '="' . $val . '" ';
}
return $attrstr;
}
}
?>