From 6f4e181f0a03b4b190922bd5f8bd97fb9fdb206e Mon Sep 17 00:00:00 2001
From: Ugnich Anton
Date: Sun, 25 Dec 2011 15:56:30 +0700
Subject: Initial commit
---
src/java/com/juick/http/www/PageTemplates.java | 377 +++++++++++++++++++++++++
1 file changed, 377 insertions(+)
create mode 100644 src/java/com/juick/http/www/PageTemplates.java
(limited to 'src/java/com/juick/http/www/PageTemplates.java')
diff --git a/src/java/com/juick/http/www/PageTemplates.java b/src/java/com/juick/http/www/PageTemplates.java
new file mode 100644
index 00000000..94561dfd
--- /dev/null
+++ b/src/java/com/juick/http/www/PageTemplates.java
@@ -0,0 +1,377 @@
+/*
+ * Juick
+ * Copyright (C) 2008-2011, Ugnich Anton
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see
" + description + "
$1"); + msg = msg.replaceAll("
", "\n"); + + msg = msg.replaceAll("\n", "
\n"); + return msg; + } + + public static void printMessages(PrintWriter out, Connection sql, ArrayListmids, Locale locale) { + ResourceBundle rb = ResourceBundle.getBundle("Global", locale); + + PreparedStatement stmt = null; + ResultSet rs = null; + try { + stmt = sql.prepareStatement("SELECT STRAIGHT_JOIN messages.message_id,messages.user_id,users.nick,messages_txt.tags,messages.readonly,messages.privacy,messages_txt.txt,TIMESTAMPDIFF(MINUTE,messages.ts,NOW()),messages.ts,messages.replies,messages_txt.repliesby,messages.attach,messages.place_id,places.name,messages.lat,messages.lon FROM ((messages INNER JOIN messages_txt ON messages.message_id=messages_txt.message_id) INNER JOIN users ON messages.user_id=users.id) LEFT JOIN places ON messages.place_id=places.place_id WHERE messages.message_id IN (" + Utils.convertArray2String(mids) + ") ORDER BY messages.message_id DESC"); + rs = stmt.executeQuery(); + rs.beforeFirst(); + while (rs.next()) { + int mid = rs.getInt(1); + int uid = rs.getInt(2); + String uname = rs.getString(3); + String tags = rs.getString(4); + String txt = rs.getString(7); + // timediff + // timestamp + // replies + // 11 repliesby + // attach + // pid + // pname + // lat + // lon + + tags = (tags != null) ? formatTags(tags) : ""; + if (rs.getInt(5) == 1) { + tags += " *readonly"; + } + switch (rs.getInt(6)) { + case 2: + tags += " *public"; + break; + case -1: + tags += " *friends"; + break; + case -2: + tags += " *private"; + break; + } + + txt = formatMessage(txt); + + if (mid == mids.get(0)) { + out.println(" "); + } else { + out.println(" "); + } + + if (rs.getString(12) != null) { + if (rs.getString(12).equals("jpg")) { + out.println(" "); + } else { + out.println(" "); + } + } catch (SQLException e) { + System.err.println(e); + } finally { + Utils.finishSQL(rs, stmt); + } + } +} -- cgit v1.2.3"); + out.println(" "); + } + } + + out.println(" "); + out.println(" "); + out.println("Attachment: Video@" + uname + ":" + tags + ""); + out.println("" + txt + ""); + + if (rs.getInt(10) > 0) { + String repliesby = rs.getString(11); + if (repliesby == null) { + repliesby = "..."; + } + out.println("" + formatReplies(rs.getInt(10), locale) + " " + rb.getString("(replies) by") + " " + repliesby + ""); + } else { + out.println(" "); + } + out.println("