19 package org.turro.www.commentit;
21 import java.text.DateFormat;
22 import java.util.Collection;
23 import org.amic.util.date.DateFormats;
24 import org.turro.string.Strings;
25 import org.turro.auth.Authentication;
26 import org.turro.commentit.CommentItUtil;
27 import org.turro.contacts.CommentIt;
28 import org.turro.elephant.context.ElephantContext;
29 import org.turro.elephant.context.IConstructor;
30 import org.turro.elephant.impl.util.StringParser;
31 import org.turro.elephant.security.IUser;
32 import org.turro.html.HTMLHelper;
33 import org.turro.i18n.I_;
34 import org.turro.marker.ElephantMarker;
35 import org.turro.plugin.contacts.IContact;
36 import org.turro.plugin.contacts.SoftContact;
37 import org.turro.util.IdGenerator;
46 private String entityPath;
48 private boolean readOnly;
51 this.constructor = constructor;
55 this.entityPath = entityPath;
59 this.readOnly = readOnly;
68 String
id = container ?
"cic_" + IdGenerator.generate() : constructor.
getParameter(
"domid");
70 em.
put(
"control",
this);
71 em.
put(
"contact", contact);
72 em.
put(
"controlId",
id);
73 em.
put(
"container", container);
74 em.
put(
"comments", comments);
75 em.
put(
"entityPath", entityPath);
76 em.
put(
"readOnly", readOnly);
77 if(contact !=
null && contact.
isValid()) {
82 em.
process(
"widgets/webcomp",
"commentIt");
96 String
id = container ?
"cic_" + IdGenerator.generate() : constructor.
getParameter(
"domid");
98 html.
startTag(
"div",
"id='" +
id +
"'");
101 String cid =
"cid" + ci.getId();
102 html.
startTag(
"div",
"class='commentit-comment' id='" + cid +
"'")
103 .
startTag(
"div",
"class='commentit-details'")
108 .
write(DateFormats.format(ci.getDateCreation(), DateFormat.SHORT, DateFormat.SHORT,
I_.
api().used()))
113 .
startTag(
"a",
"onClick='" +
getRemoveUrl(ci.getId(), cid) +
"' style='display:" + (ci.isAccepted() ?
"none" :
"") +
"'")
123 renderNewComment(html,
id, contact);
130 "$(\"#form_" +
id +
"\").serialize())" +
131 ".done(function(data) { $(\"#" +
id +
"\").html(data); });" +
137 "{ action: \"comment-it\", id: \"" + commentId +
"\", remove: true, domid: \"" +
id +
"\" })" +
138 ".done(function(data) { $(\"#" +
id +
"\").html(data); });";
146 String name =
null, email =
null, web =
null;
147 if(contact !=
null && contact.
isValid()) {
152 html.
startTag(
"form",
"class='commentit-new' id='form_" +
id +
"'")
155 .
write(I_.get(
"Name"))
157 .
doTag(
"input",
"name='author' value='" +
158 (!Strings.isBlank(name) ? name :
"") +
"' style='width:100%'")
161 .
write(I_.get(
"Email"))
163 .
doTag(
"input",
"name='author_email' value='" +
164 (!Strings.isBlank(email) ? email :
"") +
"' style='width:100%'")
167 .
write(I_.get(
"Site"))
169 .
doTag(
"input",
"name='author_web' value='" +
170 (!Strings.isBlank(web) ? web :
"") +
"' style='width:100%'")
173 .
startTag(
"textarea",
"name='body' rows='8' style='width:100%'").
endTag()
176 .
doTag(
"input",
"type='hidden' name='action' value='comment-it'")
177 .
doTag(
"input",
"type='hidden' name='path' value='" + entityPath +
"'")
178 .
doTag(
"input",
"type='hidden' name='domid' value='" +
id +
"'")
180 .
write(I_.get(
"Add comment"))
static IContact getIContact()
static String getRootWebPath()
static String toHTML(String value)
HTMLGenerator endAllTags()
HTMLGenerator write(String value)
HTMLGenerator doTag(String tag)
HTMLGenerator endTableRow()
HTMLGenerator startTag(String tag)
HTMLGenerator startTableCol(String attributes)
HTMLGenerator startTable(String attributes)
static I18nApiWrapper api()
void process(String rootTmpl, String tmpl)
static boolean existsTemplate(IConstructor constructor, boolean mail, String root, String name)
Object put(Object key, Object value)
HttpServletRequest getRequest()
String getParameter(String param)
static final String CONNECTOR_EMAIL