row.addChild("th", l10n().getString("SelectBoardsPage.BoardTableHeader.Subscribe"));
row.addChild("th", l10n().getString("SelectBoardsPage.BoardTableHeader.Unsubscribe"));
DateFormat dateFormat = DateFormat.getInstance();
MessageManager messageManager = mFreetalk.getMessageManager();
final boolean languageFiltered = mRequest.isPartSet("BoardLanguage");
final String languageFilter = mRequest.getPartAsStringFailsafe("BoardLanguage", Board.MAX_BOARDNAME_TEXT_LENGTH);
final ISO639_3.LanguageCode languageFilterCode = Board.getAllowedLanguages().get(languageFilter);
synchronized(messageManager) {
for(final Board board : messageManager.boardIteratorSortedByName()) {
if(languageFiltered && board.getLanguage() != languageFilterCode)
continue;
row = boardsTable.addChild("tr", "id", board.getName());
// Language
row.addChild("td", "class", "language-cell", board.getLanguage().referenceName);
// Name
HTMLNode nameCell = row.addChild("th", "class", "name-cell");
//.addChild(new HTMLNode("a", "href", Freetalk.PLUGIN_URI + "/SubscribeToBoard?identity=" + mOwnIdentity.getID() + "&name=" + board.getName(),
// board.getName()));
// Description
row.addChild("td", "class", "description-cell", board.getDescription(mOwnIdentity));
// First seen
row.addChild("td", "class", "first-seen-cell", dateFormat.format(board.getFirstSeenDate()));
// Latest message
HTMLNode latestMessageCell = row.addChild("td", "class", "latest-message-cell");
// Message count
HTMLNode messageCountCell = row.addChild("td", "class", "message-count-cell");
HTMLNode subscribeCell = row.addChild("td", new String[] { "align" }, new String[] { "center" });
HTMLNode unsubscribeCell = row.addChild("td", new String[] { "align" }, new String[] { "center" });
try {
SubscribedBoard subscribedBoard = messageManager.getSubscription(mOwnIdentity, board.getName());
// We are subscribed to that board so we can display some more information.
nameCell.addChild(new HTMLNode("a", "href", BoardPage.getURI(board), board.getName()));
try {
latestMessageCell.addChild("#", dateFormat.format(subscribedBoard.getLatestMessage().getMessageDate()));
} catch(NoSuchMessageException e) {
latestMessageCell.addChild("#", "-");
}
messageCountCell.addChild("#", Integer.toString(subscribedBoard.messageCount()));
HTMLNode unsubscribeForm = addFormChild(unsubscribeCell, Freetalk.PLUGIN_URI + "/SelectBoards" + "#" + board.getName(), "Unsubscribe");
unsubscribeForm.addChild("input", new String[] {"type", "name", "value"}, new String[] { "hidden", "OwnIdentityID", mOwnIdentity.getID()});
unsubscribeForm.addChild("input", new String[] {"type", "name", "value"}, new String[] { "hidden", "BoardName", board.getName()});
if(languageFiltered) unsubscribeForm.addChild("input", new String[] {"type", "name", "value"}, new String[] { "hidden", "BoardLanguage", languageFilter});
unsubscribeForm.addChild("input", new String[] {"type", "name", "value"}, new String[] { "submit", "Unsubscribe", l10n().getString("SelectBoardsPage.BoardTable.UnsubscribeButton") });
} catch(NoSuchBoardException e) {
// We are not subscribed to that board so we cannot fill all cells with information.
nameCell.addChild(new HTMLNode("a", "href", NotFetchedMessagesPage.getURI(board), board.getName()));
latestMessageCell.addChild("#", "-");
messageCountCell.addChild("#", l10n().getString("Common.EstimationPrefix") + " " + messageManager.getDownloadableMessageCount(board));
HTMLNode subscribeForm = addFormChild(subscribeCell, Freetalk.PLUGIN_URI + "/SelectBoards" + "#" + board.getName(), "Subscribe");
subscribeForm.addChild("input", new String[] {"type", "name", "value"}, new String[] { "hidden", "OwnIdentityID", mOwnIdentity.getID()});
subscribeForm.addChild("input", new String[] {"type", "name", "value"}, new String[] { "hidden", "BoardName", board.getName()});
if(languageFiltered) subscribeForm.addChild("input", new String[] {"type", "name", "value"}, new String[] { "hidden", "BoardLanguage", languageFilter});