BrightSide Workbench Full Report + Source Code
org.turro.www.commentit.CommentItCtrl Class Reference

Public Member Functions

 CommentItCtrl (IConstructor constructor)
 
void setEntityPath (String entityPath)
 
void setReadOnly (boolean readOnly)
 
void renderTemplateComments (boolean container)
 
void renderComments (boolean container)
 
String getSubmitUrl (String id)
 
String getRemoveUrl (String commentId, String id)
 
String toHTML (String value)
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 43 of file CommentItCtrl.java.

Constructor & Destructor Documentation

◆ CommentItCtrl()

org.turro.www.commentit.CommentItCtrl.CommentItCtrl ( IConstructor  constructor)

Definition at line 50 of file CommentItCtrl.java.

50  {
51  this.constructor = constructor;
52  }

Member Function Documentation

◆ getRemoveUrl()

String org.turro.www.commentit.CommentItCtrl.getRemoveUrl ( String  commentId,
String  id 
)

Definition at line 135 of file CommentItCtrl.java.

135  {
136  return "$.post(\"" + ElephantContext.getRootWebPath() + "/xpaction/contact\"," +
137  "{ action: \"comment-it\", id: \"" + commentId + "\", remove: true, domid: \"" + id + "\" })" +
138  ".done(function(data) { $(\"#" + id + "\").html(data); });";
139  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getSubmitUrl()

String org.turro.www.commentit.CommentItCtrl.getSubmitUrl ( String  id)

Definition at line 128 of file CommentItCtrl.java.

128  {
129  return "$.post(\"" + ElephantContext.getRootWebPath() + "/xpaction/contact\"," +
130  "$(\"#form_" + id + "\").serialize())" +
131  ".done(function(data) { $(\"#" + id + "\").html(data); });" +
132  "return false;";
133  }
Here is the call graph for this function:

◆ renderComments()

void org.turro.www.commentit.CommentItCtrl.renderComments ( boolean  container)

Definition at line 85 of file CommentItCtrl.java.

85  {
86  if(ElephantMarker.existsTemplate(constructor, false, "widgets/webcomp", "commentIt")) {
87  renderTemplateComments(container);
88  return;
89  }
90  IContact contact = Authentication.getIContact();
91  SoftContact scontact = new SoftContact();
92  scontact.contact = contact;
93  scontact.author_ip = constructor.getRequest().getRemoteAddr();
94  Collection<CommentIt> comments = CommentItUtil.comments(entityPath, scontact);
95  html = new HTMLHelper(constructor);
96  String id = container ? "cic_" + IdGenerator.generate() : constructor.getParameter("domid");
97  if(container) {
98  html.startTag("div", "id='" + id + "'");
99  }
100  for(CommentIt ci : comments) {
101  String cid = "cid" + ci.getId();
102  html.startTag("div", "class='commentit-comment' id='" + cid + "'")
103  .startTag("div", "class='commentit-details'")
104  .startTag("span", "class='author'")
105  .write(ci.getName())
106  .endTag()
107  .startTag("span", "class='date'")
108  .write(DateFormats.format(ci.getDateCreation(), DateFormat.SHORT, DateFormat.SHORT, I_.api().used()))
109  .endTag()
110  .startTag("span", "class='web'")
111  .write(ci.getWeb())
112  .endTag()
113  .startTag("a", "onClick='" + getRemoveUrl(ci.getId(), cid) + "' style='display:" + (ci.isAccepted() ? "none" : "") + "'")
114  .doTag("img", "src='" + ElephantContext.getRootWebPath() + "/_internal/system/images/delete.png'")
115  .endTag()
116  .endTag()
117  .startTag("div", "class='body'")
118  .write(StringParser.toHTML(ci.getBody()))
119  .endTag()
120  .endTag();
121  }
122  if(!readOnly) {
123  renderNewComment(html, id, contact);
124  }
125  html.endAllTags();
126  }
HTMLGenerator write(String value)
HTMLGenerator doTag(String tag)
HTMLGenerator startTag(String tag)
String getRemoveUrl(String commentId, String id)
void renderTemplateComments(boolean container)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ renderTemplateComments()

void org.turro.www.commentit.CommentItCtrl.renderTemplateComments ( boolean  container)

Definition at line 62 of file CommentItCtrl.java.

62  {
63  IContact contact = Authentication.getIContact();
64  SoftContact scontact = new SoftContact();
65  scontact.contact = contact;
66  scontact.author_ip = constructor.getRequest().getRemoteAddr();
67  Collection<CommentIt> comments = CommentItUtil.comments(entityPath, scontact);
68  String id = container ? "cic_" + IdGenerator.generate() : constructor.getParameter("domid");
69  ElephantMarker em = new ElephantMarker(constructor);
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()) {
78  em.put("name", contact.getName());
79  em.put("email", contact.getConnector(IUser.CONNECTOR_EMAIL));
80  em.put("web", contact.getConnector("Web"));
81  }
82  em.process("widgets/webcomp", "commentIt");
83  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setEntityPath()

void org.turro.www.commentit.CommentItCtrl.setEntityPath ( String  entityPath)

Definition at line 54 of file CommentItCtrl.java.

54  {
55  this.entityPath = entityPath;
56  }
Here is the caller graph for this function:

◆ setReadOnly()

void org.turro.www.commentit.CommentItCtrl.setReadOnly ( boolean  readOnly)

Definition at line 58 of file CommentItCtrl.java.

58  {
59  this.readOnly = readOnly;
60  }

◆ toHTML()

String org.turro.www.commentit.CommentItCtrl.toHTML ( String  value)

Definition at line 141 of file CommentItCtrl.java.

141  {
142  return StringParser.toHTML(value);
143  }
Here is the call graph for this function:

The documentation for this class was generated from the following file: