19 package org.turro.forum.content;
21 import java.io.Writer;
22 import java.util.ArrayList;
23 import java.util.Arrays;
24 import java.util.Collection;
25 import java.util.Date;
26 import org.turro.string.Strings;
27 import org.turro.action.IEntityCtrl;
28 import org.turro.elephant.context.ElephantContext;
29 import org.turro.elephant.context.IConstructor;
30 import org.turro.elephant.db.ElephantPU;
31 import org.turro.elephant.db.WhereClause;
32 import org.turro.elephant.entities.db.Topic;
33 import org.turro.elephant.impl.repository.RepositoryFile;
34 import org.turro.elephant.web.SocialNet;
35 import org.turro.forum.Forums;
36 import org.turro.forum.www.ForumCtrl;
37 import org.turro.jpa.content.EntityDaoContentIterator;
38 import org.turro.jpa.content.SeenStatusCheck;
39 import org.turro.jpa.search.DaoHtmlSearch;
40 import org.turro.jpa.search.DaoSearchKey;
41 import org.turro.marker.ElephantMarker;
42 import org.turro.participation.ParticipationReason;
43 import org.turro.plugin.contacts.IContact;
51 private Date since =
null;
64 wc.
addClause(
"select distinct topic from Topic as topic");
66 wc.
addClause(
"on post.uniquePath like concat(topic.uniquePath, '%')");
68 wc.
addClause(
"order by topic.creation desc");
75 wc.
addClause(
"select count(distinct topic) from Topic as topic");
77 wc.
addClause(
"on post.uniquePath like concat(topic.uniquePath, '%')");
86 prepareValues(e, page);
94 prepareValues(e, page);
113 wc.
addClause(
"select distinct topic from Topic as topic");
115 wc.
addClause(
"on post.uniquePath like concat(topic.uniquePath, '%')");
134 dsk.
applyToQuery(wc, Arrays.asList(
"topic.text",
"post.text"),
false);
140 wc.
addClause(
"topic.authorId = :idContact");
141 wc.
addClause(
"or post.authorId = :idContact");
147 wc.
addClause(
"topic.creation >= :since");
148 wc.
addClause(
"or post.creation >= :since");
158 wc.
addClause(
"select ep.entityPath from EntityParticipation ep");
159 wc.
addClause(
"where ep.entityPath = concat('/topic/', topic.id)");
160 wc.
addClause(
"and ep.participatorPath = concat('/contact/', :participatorId)");
168 private void prepareValues(
final Topic topic,
int page) {
170 IEntityCtrl iec =
new ForumCtrl();
172 iec.setEntityPath(ElephantPU.getObjectPath(topic));
178 if(!Strings.isBlank(e.
getText())) {
179 return Strings.truncateAndWarn(e.
getText(), 100);
186 ArrayList<RepositoryFile> files =
new ArrayList<>();
201 return isMail() ?
"content/newsletter/sections/forums" :
"forum";
247 if(Strings.isBlank(path)) {
250 if(Strings.isBlank(path)) {
258 return "/user/forums";
static String getContextVariable(IConstructor constructor)
static String getEntityWebContext(String path)
void addClause(String clause)
void addNamedValue(String name, Object value)
IElephantEntity getEntity()
List< String > getMetas()
static void markAsSeenFor(ITreeEntity entity, IContact contact)
Object doVotesCtrl(Topic e)
WhereClause getCountClause()
Object doCommentsCtrl(Topic e)
void setSince(Date since)
Object doInterestCtrl(Topic e)
Object doAttachmentsCtrl(Topic e)
ForumContentIterator(IConstructor constructor, Writer writer, IContact contact, boolean mail, String pubPath)
Object doPollsCtrl(Topic e)
Object doFilesCtrl(Topic e)
void renderForbidden(ElephantMarker marker, int page)
void renderSummary(ElephantMarker marker, Topic e, int page)
Collection< String > metas(Topic e)
void renderItem(ElephantMarker marker, Topic e, int page)
String getRestrictedLink()
WhereClause getWhereClause()
Object doDescriptionsCtrl(Topic e)
String getItemLink(Topic e)
Object getSingleResultOrNull(SqlClause sc)
void prepareControls(E entity, int page)
SeenStatusCheck getSeenStatus()
String doItemLink(E entity, ID id, boolean obfuscated)
String getSummaryTemplate()
static DaoHtmlSearch getInstance(IConstructor constructor, String context)
boolean applyToQuery(WhereClause wc, List< String > fields, boolean withSynonyms)
void process(String rootTmpl, String tmpl)
Object put(Object key, Object value)
boolean canPublish(IContact contact)