XOOPS 2.5.6  Final
 All Classes Namespaces Files Functions Variables Pages
formtextdateselect.php
Go to the documentation of this file.
1 <?php
21 defined('XOOPS_ROOT_PATH') or die("XOOPS root path not defined");
22 
28 {
29 
30  function XoopsFormTextDateSelect($caption, $name, $size = 15, $value = 0)
31  {
32  $value = !is_numeric($value) ? time() : intval($value);
33  $value = ($value == 0) ? time() : $value;
34  $this->XoopsFormText($caption, $name, $size, 25, $value);
35  }
36 
37  function render()
38  {
39  static $included = false;
40  include_once XOOPS_ROOT_PATH . '/language/' . $GLOBALS['xoopsConfig']['language'] . '/calendar.php';
41 
42  $ele_name = $this->getName();
43  $ele_value = $this->getValue(false);
44  if (is_string($ele_value)) {
45  $display_value = $ele_value;
46  $ele_value = time();
47  } else {
48  $display_value = date(_CAL_FORMAT, $ele_value);
49  }
50 
51  $jstime = formatTimestamp($ele_value, _CAL_FORMAT);
52  if (is_object($GLOBALS['xoTheme'])) {
53  $GLOBALS['xoTheme']->addScript('include/calendar.js');
54  $GLOBALS['xoTheme']->addStylesheet('include/calendar-blue.css');
55  if (!$included) {
56  $included = true;
57  $GLOBALS['xoTheme']->addScript('','', '
58  var calendar = null;
59 
60  function selected(cal, date) {
61  cal.sel.value = date;
62  }
63 
64  function closeHandler(cal) {
65  cal.hide();
66  Calendar.removeEvent(document, "mousedown", checkCalendar);
67  }
68 
69  function checkCalendar(ev) {
70  var el = Calendar.is_ie ? Calendar.getElement(ev) : Calendar.getTargetElement(ev);
71  for (; el != null; el = el.parentNode)
72  if (el == calendar.element || el.tagName == "A") break;
73  if (el == null) {
74  calendar.callCloseHandler(); Calendar.stopEvent(ev);
75  }
76  }
77  function showCalendar(id) {
78  var el = xoopsGetElementById(id);
79  if (calendar != null) {
80  calendar.hide();
81  } else {
82  var cal = new Calendar(true, "' . $jstime . '", selected, closeHandler);
83  calendar = cal;
84  cal.setRange(1900, 2100);
85  calendar.create();
86  }
87  calendar.sel = el;
88  calendar.parseDate(el.value);
89  calendar.showAtElement(el);
90  Calendar.addEvent(document, "mousedown", checkCalendar);
91  return false;
92  }
93 
94  Calendar._DN = new Array
95  ("' . _CAL_SUNDAY . '",
96  "' . _CAL_MONDAY . '",
97  "' . _CAL_TUESDAY . '",
98  "' . _CAL_WEDNESDAY . '",
99  "' . _CAL_THURSDAY . '",
100  "' . _CAL_FRIDAY . '",
101  "' . _CAL_SATURDAY . '",
102  "' . _CAL_SUNDAY . '");
103  Calendar._MN = new Array
104  ("' . _CAL_JANUARY . '",
105  "' . _CAL_FEBRUARY . '",
106  "' . _CAL_MARCH . '",
107  "' . _CAL_APRIL . '",
108  "' . _CAL_MAY . '",
109  "' . _CAL_JUNE . '",
110  "' . _CAL_JULY . '",
111  "' . _CAL_AUGUST . '",
112  "' . _CAL_SEPTEMBER . '",
113  "' . _CAL_OCTOBER . '",
114  "' . _CAL_NOVEMBER . '",
115  "' . _CAL_DECEMBER . '");
116 
117  Calendar._TT = {};
118  Calendar._TT["TOGGLE"] = "' . _CAL_TGL1STD . '";
119  Calendar._TT["PREV_YEAR"] = "' . _CAL_PREVYR . '";
120  Calendar._TT["PREV_MONTH"] = "' . _CAL_PREVMNTH . '";
121  Calendar._TT["GO_TODAY"] = "' . _CAL_GOTODAY . '";
122  Calendar._TT["NEXT_MONTH"] = "' . _CAL_NXTMNTH . '";
123  Calendar._TT["NEXT_YEAR"] = "' . _CAL_NEXTYR . '";
124  Calendar._TT["SEL_DATE"] = "' . _CAL_SELDATE . '";
125  Calendar._TT["DRAG_TO_MOVE"] = "' . _CAL_DRAGMOVE . '";
126  Calendar._TT["PART_TODAY"] = "(' . _CAL_TODAY . ')";
127  Calendar._TT["MON_FIRST"] = "' . _CAL_DISPM1ST . '";
128  Calendar._TT["SUN_FIRST"] = "' . _CAL_DISPS1ST . '";
129  Calendar._TT["CLOSE"] = "' . _CLOSE . '";
130  Calendar._TT["TODAY"] = "' . _CAL_TODAY . '";
131 
132  // date formats
133  Calendar._TT["DEF_DATE_FORMAT"] = "' . _CAL_FORMAT . '";
134  Calendar._TT["TT_DATE_FORMAT"] = "' . _CAL_FORMAT . '";
135 
136  Calendar._TT["WK"] = "";
137  ');
138  }
139  }
140  return "<input type='text' name='" . $ele_name . "' id='" . $ele_name . "' size='" . $this->getSize() . "' maxlength='" . $this->getMaxlength() . "' value='" . $display_value . "'" . $this->getExtra() . " /><input type='reset' value=' ... ' onclick='return showCalendar(\"" . $ele_name . "\");'>";
141  }
142 }
143 
144 ?>