1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15:
16: class Horde_Core_Ui_JsCalendar
17: {
18: 19: 20: 21: 22:
23: static protected $_initRun = false;
24:
25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44:
45: static public function init(array $params = array())
46: {
47: if (self::$_initRun) {
48: return;
49: }
50: self::$_initRun = true;
51:
52: $params = array_merge(array(
53: 'click_month' => false,
54: 'click_week' => false,
55: 'click_year' => false,
56: 'full_weekdays' => false,
57: 'short_weekdays' => false
58: ), $params);
59:
60: $weekdays = self::weekdays();
61: if ($params['short_weekdays']) {
62: foreach ($weekdays as &$day) {
63: $day = Horde_String::substr($day, 0, 1);
64: }
65: }
66:
67: $js = array(
68: '-Horde_Calendar.click_month' => intval($params['click_month']),
69: '-Horde_Calendar.click_week' => intval($params['click_week']),
70: '-Horde_Calendar.click_year' => intval($params['click_year']),
71: '-Horde_Calendar.firstDayOfWeek' => intval($GLOBALS['prefs']->getValue('first_week_day')),
72: 'Horde_Calendar.months' => self::months(),
73: 'Horde_Calendar.weekdays' => $weekdays
74: );
75: if ($params['full_weekdays']) {
76: $js['Horde_Calendar.fullweekdays'] = self::fullWeekdays();
77: }
78:
79: Horde::addScriptFile('calendar.js', 'horde');
80: Horde::addInlineJsVars($js);
81: }
82:
83: 84: 85: 86: 87:
88: static public function weekdays()
89: {
90: return array(
91: Horde_Core_Translation::t("Su"),
92: Horde_Core_Translation::t("Mo"),
93: Horde_Core_Translation::t("Tu"),
94: Horde_Core_Translation::t("We"),
95: Horde_Core_Translation::t("Th"),
96: Horde_Core_Translation::t("Fr"),
97: Horde_Core_Translation::t("Sa")
98: );
99: }
100:
101: 102: 103: 104: 105:
106: static public function fullWeekdays()
107: {
108: return array(
109: Horde_Core_Translation::t("Sunday"),
110: Horde_Core_Translation::t("Monday"),
111: Horde_Core_Translation::t("Tuesday"),
112: Horde_Core_Translation::t("Wednesday"),
113: Horde_Core_Translation::t("Thursday"),
114: Horde_Core_Translation::t("Friday"),
115: Horde_Core_Translation::t("Saturday"),
116: );
117: }
118:
119: 120: 121: 122: 123:
124: static public function months()
125: {
126: return array(
127: Horde_Core_Translation::t("January"),
128: Horde_Core_Translation::t("February"),
129: Horde_Core_Translation::t("March"),
130: Horde_Core_Translation::t("April"),
131: Horde_Core_Translation::t("May"),
132: Horde_Core_Translation::t("June"),
133: Horde_Core_Translation::t("July"),
134: Horde_Core_Translation::t("August"),
135: Horde_Core_Translation::t("September"),
136: Horde_Core_Translation::t("October"),
137: Horde_Core_Translation::t("November"),
138: Horde_Core_Translation::t("December")
139: );
140: }
141:
142: }
143: