use of web.HTMLWriter in project common by zenlunatics.
the class CalendarView method writeComponent.
// --------------------------------------------------------------------------
public void writeComponent(boolean show_head, Request request) throws IOException {
HTMLWriter writer = request.writer;
writer.write("<div id=\"calendar\">");
if (show_head)
writeHead(request);
Person user = request.getUser();
boolean controls_on_top = user != null && user.testData("calendar controls on top");
if (!(this instanceof ListView) && controls_on_top)
writeControls("top", request);
writer.write("<div id=\"calendar_view\" class=\"calendar_component\">");
java.util.Calendar c = request.site.newCalendar();
write(c.get(Calendar.YEAR), c.get(Calendar.MONTH), c.get(Calendar.DATE), null, null, request);
writer.write("</div>");
if (!(this instanceof ListView) && !controls_on_top)
writeControls("bottom", request);
writer.write("<div id=\"calendar_after_view\"></div>");
writer.write("</div>");
String js = "new Calendar('" + HTMLWriter.escapeJSString(m_event_provider.getName()) + "', '" + getView().toString() + "');";
String locale = request.site.getSettings().getString("xdate locale");
if (locale != null)
js = "XDate.defaultLocale = '" + locale + "';" + js;
writer.js("JS.get('calendar',function(){" + js + "});");
if (request.getUser() != null) {
String edit = request.getParameter("edit");
if (edit != null) {
int last_comma = edit.lastIndexOf(',');
String calendar_name = edit.substring(1, last_comma - 1);
int index = calendar_name.indexOf('%');
while (index != -1) {
calendar_name = URLDecoder.decode(calendar_name, "UTF-8");
index = calendar_name.indexOf('%');
}
EventProvider event_provider = (EventProvider) request.site.getModule(calendar_name);
if (event_provider != null)
writer.scriptOpen().write("window.addEventListener('load',function(){$('calendar').calendar.edit(").jsString(calendar_name).comma().jsString(event_provider.getDisplayName()).comma().write(edit.substring(last_comma + 1)).write(");});").scriptClose();
}
}
}
use of web.HTMLWriter in project common by zenlunatics.
the class CalendarView method writeControls.
// --------------------------------------------------------------------------
private void writeControls(String position, Request request) throws IOException {
HTMLWriter writer = request.writer;
writer.write("<div id=\"calendar_foot\" data-position=\"").write(position).write("\">");
writer.write("<div style=\"float:right;\">");
m_event_provider.writeControlButtons(request);
writer.setAttribute("title", "calendar for printing");
writer.setAttribute("style", "margin-left:2px");
writer.buttonIconOnClick("print", "calendar_print_window()");
Person user = request.getUser();
if (user != null) {
boolean controls_on_top = user.testData("calendar controls on top");
writer.setAttribute("id", "calendar_position");
writer.setAttribute("style", "margin-left:2px");
writer.setAttribute("title", controls_on_top ? "move controls below calendar" : "move controls above calendar");
writer.buttonIconOnClick(controls_on_top ? "arrow-down" : "arrow-up", "$('calendar').calendar.move_controls()");
}
writer.write("</div>");
if (request.getUser() != null) {
CalendarPicker calendar_picker = m_event_provider.getCalendarPicker();
if (calendar_picker != null) {
writer.write("<div id=\"calendar_checkboxes\" class=\"form-inline\" style=\"padding:3px 0 5px;\">");
calendar_picker.writeCheckBoxes(request);
writer.write("</div>");
}
}
m_event_provider.writeFilters(request);
writer.write("</div>");
}
use of web.HTMLWriter in project common by zenlunatics.
the class DaysView method writeTimes.
// --------------------------------------------------------------------------
private void writeTimes(int start_minutes, int end_minutes, int height, Request request) throws IOException {
HTMLWriter writer = request.writer;
if (start_minutes >= end_minutes)
return;
int minutes = start_minutes;
writer.write("<div style=\"position:relative;width:80px;height:");
writer.write(height + 30);
writer.write("px\">");
while (minutes < end_minutes) {
writer.write("<div style=\"text-align:right;width:80px;height:30px;position:absolute;right:3px;top:");
writer.write(minutes - start_minutes);
writer.write("px\">");
writer.write(request.date_time_formatter.getTime(minutes, true));
writer.write("</div>");
minutes += m_event_provider.getDailyResolution();
}
writer.write("<div style=\"text-align:right;width:80px;height:30px;position:absolute;right:3px;top:");
writer.write(minutes - start_minutes);
writer.write("px\">");
writer.write(request.date_time_formatter.getTime(minutes, true));
writer.write("</div></div>");
}
use of web.HTMLWriter in project common by zenlunatics.
the class EventProvider method writeAutomaticReminders.
// --------------------------------------------------------------------------
public void writeAutomaticReminders(View view, Request request) throws IOException {
if (m_support_reminders) {
HTMLWriter writer = request.writer;
ResultSet rs = request.db.select(new Select("*").from(m_events_table + "_reminders").where(m_events_table + "_id IS NULL"));
try {
if (rs.isBeforeFirst()) {
writer.h4("Automatic Reminders");
Table table = new Table(writer).addClass("table").addClass("table-bordered").addClass("table-condensed").open();
table.tr().th("send to").th("when").th("note");
while (rs.next()) {
table.tr().td(rs.getString("email"));
table.td();
int num = rs.getInt("num");
String repeat_days = null;
String unit = rs.getString("unit");
if (m_events_can_repeat)
repeat_days = rs.getString("repeat_days");
if (num == 0 && "day".equals(unit))
writer.write(repeat_days == null ? "on the day" : "on the day of");
else {
writer.write(num).space().write(unit);
if (num != 1)
writer.write('s');
writer.write(rs.getBoolean("before") ? " before" : " after");
}
if (m_events_can_repeat)
if (repeat_days != null && !"never".equals(repeat_days))
writer.space().write(repeat_days);
table.td(rs.getString("note"));
}
rs.getStatement().close();
table.close();
}
} catch (SQLException e) {
}
}
}
use of web.HTMLWriter in project common by zenlunatics.
the class EventProvider method writeSettingsInput.
// --------------------------------------------------------------------------
@Override
protected void writeSettingsInput(Field field, Map<String, Field> fields, Request request) throws IOException {
String field_name = field.getName();
if (field_name.equals("m_display_items"))
request.writer.choicesInput("display_items", m_display_items, getFieldOptions("m_display_items"));
else if (field_name.equals("m_tooltip_items"))
request.writer.choicesInput("tooltip_items", m_tooltip_items, getFieldOptions("m_tooltip_items"));
else if (field_name.equals("m_uuid"))
request.writer.aOnClick("see public url", "dialog_alert('Public URL','To embed this calendar on a public web page, use the following URL:<br><br>https://' + domain + context + '/" + HTMLWriter.escapeJSString(m_name) + "/public/" + getUUID(request.db) + "')");
else {
super.writeSettingsInput(field, fields, request);
if ("m_events_have_category".equals(field_name)) {
HTMLWriter writer = request.writer;
writer.write("<div style=\"padding-left:20px\">");
super.writeSettingsInput(fields.get("m_only_admins_can_edit_categories"), fields, request);
writer.write("</div>");
} else if ("m_events_have_location".equals(field_name)) {
HTMLWriter writer = request.writer;
writer.write("<div style=\"padding-left:20px\">");
super.writeSettingsInput(fields.get("m_only_admins_can_edit_locations"), fields, request);
writer.write("</div>");
} else if ("m_events_have_start_time".equals(field_name)) {
HTMLWriter writer = request.writer;
writer.write("<div style=\"padding-left:20px\"><span class=\"form_label\">default start time</span>");
super.writeSettingsInput(fields.get("m_default_start_time"), fields, request);
writer.write("</div><div style=\"padding-left:20px\"><span class=\"form_label\">default end time</span>");
super.writeSettingsInput(fields.get("m_default_end_time"), fields, request);
writer.write("</div>");
}
}
}
Aggregations