18 package org.turro.publication.www;
20 import com.sun.syndication.feed.synd.SyndContent;
21 import com.sun.syndication.feed.synd.SyndContentImpl;
22 import com.sun.syndication.feed.synd.SyndEntry;
23 import com.sun.syndication.feed.synd.SyndEntryImpl;
24 import java.io.IOException;
25 import java.io.PrintWriter;
26 import java.util.ArrayList;
27 import java.util.List;
28 import javax.servlet.ServletException;
29 import org.turro.string.ObjectString;
30 import org.turro.string.Strings;
31 import org.turro.collections.Tree;
32 import org.turro.elephant.context.ElephantContext;
33 import org.turro.elephant.context.IElement;
34 import org.turro.elephant.feed.IRSSable;
35 import org.turro.elephant.impl.abstracts.AbstractElement;
36 import org.turro.elephant.layout.IManageable;
37 import org.turro.elephant.layout.IRenderable;
38 import org.turro.elephant.search.FoundList;
39 import org.turro.elephant.search.ISearchable;
40 import org.turro.elephant.search.SearchFormatter;
41 import org.turro.elephant.security.IDefendable;
42 import org.turro.elephant.web.ElContext;
43 import org.turro.i18n.I_;
44 import org.turro.jpa.entity.EntityWebUrls;
45 import org.turro.jpa.search.DaoHtmlSearch;
46 import org.turro.publication.db.PublicationPU;
47 import org.turro.publication.entity.Publication;
48 import org.turro.publication.entity.PublicationCategory;
49 import org.turro.publication.util.PublicationCategories;
50 import org.turro.publication.zul.portal.PublicationContent;
58 protected String
sclass, contactId, onTop, onBottom, fullTemplate, summaryTemplate;
59 protected long groupId, categoryId, publicationId;
61 protected boolean showTitle, showDetails, showSummary, showBody, navigate, blogger;
69 public void loadData() throws ServletException, IOException {
71 fullTemplate =
getAttributes().getAttributeValue(
"attrib:fullTemplate",
"");
72 summaryTemplate =
getAttributes().getAttributeValue(
"attrib:summaryTemplate",
"");
73 contactId =
getAttributes().getAttributeValue(
"attrib:contactId",
null);
75 categoryId =
getAttributes().getAttributeIntegerValue(
"attrib:categoryId", 0);
76 publicationId =
getAttributes().getAttributeIntegerValue(
"attrib:publicationId", 0);
79 showDetails =
getAttributes().getAttributeBooleanValue(
"attrib:showDetails",
true);
80 showSummary =
getAttributes().getAttributeBooleanValue(
"attrib:showSummary",
true);
81 showBody =
getAttributes().getAttributeBooleanValue(
"attrib:showBody",
false);
82 navigate =
getAttributes().getAttributeBooleanValue(
"attrib:navigate",
false);
83 onTop =
getAttributes().getAttributeValue(
"attrib:onTop",
null);
84 onBottom =
getAttributes().getAttributeValue(
"attrib:onBottom",
null);
85 blogger =
getAttributes().getAttributeBooleanValue(
"attrib:blogger",
false);
88 }
else if(publicationId > 0) {
111 Tree<PublicationCategory, String> tree =
new Tree<PublicationCategory, String>() {
128 tree.addLeaf(
null,
I_.
get(
"All categories"));
130 tree.addLeaf(pc, pc.getName());
133 return "?category=" + (t.getValue() ==
null ?
"0" : ((
PublicationCategory) t.getValue()).getId());
143 if(!Strings.isBlank(onTop)) {
151 }
else if(publicationId > 0) {
157 if(categoryId == 0) {
170 if(!Strings.isBlank(onBottom)) {
180 return "<div class='" +
sclass +
"publication-web'>";
189 return pub !=
null &&
190 (publicationId == 0 || publicationId == pub.
getId()) &&
193 (Strings.isBlank(contactId) || contactId.equals(pub.
getIdContact()));
210 0,
groupId, categoryId, contactId,
true, extraSql);
240 contactId =
getAttributes().getAttributeValue(
"attrib:contactId",
null);
242 categoryId =
getAttributes().getAttributeIntegerValue(
"attrib:categoryId", 0);
244 SyndContent description;
245 List<SyndEntry> entries =
new ArrayList<>();
246 int rsscount = this.
getAttributes().getAttributeIntegerValue(
"attrib:rss_count", 10);
248 rsscount,
groupId, categoryId, contactId,
true);
251 entry =
new SyndEntryImpl();
254 entry.setPublishedDate(pub.
getDate());
256 description =
new SyndContentImpl();
257 description.setType(
"text/html");
259 if(!Strings.isBlank(summary)) {
260 summary = summary.replaceAll(
"href=\\'(?![a-z]+:)(\\/?)\\/?([^\\']*)\\'",
"href=\\'" + serverBase +
"$1$2\\'")
261 .replaceAll(
"src=\\'(?![a-z]+:)(\\/?)\\/?([^\\']*)\\'",
"src=\\'" + serverBase +
"$1$2\\'")
262 .replaceAll(
"href=\\\"(?![a-z]+:)(\\/?)\\/?([^\\\"]*)\\\"",
"href=\\\"" + serverBase +
"$1$2\\\"")
263 .replaceAll(
"src=\\\"(?![a-z]+:)(\\/?)\\/?([^\\\"]*)\\\"",
"src=\\\"" + serverBase +
"$1$2\\\"");
264 description.setValue(summary);
266 entry.setDescription(description);
277 return "?pubid=" + pub.
getId() +
"&item=" + pub.
getId();
281 private void renderRSSSynd() throws IOException {
283 out.print(
"<div class='rss_feed'>");
284 out.print(
"<a href='" + ElephantContext.getRootResourcePath() +
"/print_" +
context.
getPath() +
"?rss'>");
285 out.print(
"<img border='0' src='" + ElephantContext.getRootResourcePath() +
"/_internal/system/images/64/feed.png'/>");
static String getRootResourcePath()
static String getServerBase(String scheme)
static String getContextVariable(IConstructor constructor)
AttributeSupport getAttributes()
void addItem(String id, String link, String image, String title, String value, double similarity, String query)
void generateCategoriesChildren(Tree tree, Function< Item, String > onParam)
static String get(String msg)
static I18nApiWrapper api()
static String getUrlFromEntity(Object entity)
void setFullTemplate(String fullTemplate)
void setSearchEngine(DaoHtmlSearch searchEngine)
Collection< String > getMetas()
void setSummaryTemplate(String summaryTemplate)
static DaoHtmlSearch getInstance(IConstructor constructor, String context)
PublicationGroup getPublicationGroup()
PublicationCategory getPublicationCategory()
static Collection< PublicationCategory > getPublicCategories()
static List< Publication > getPublicationsBy(int max, long group, long category, String idContact, boolean accepted)
void setBlogger(boolean blogger)
void setLang(String lang)
void setContactId(String contactId)
void setCategoryId(long categoryId)
void setBlogger(boolean blogger)
void setCategoryFilter(CategoryFilter categoryFilter)
void setGroupId(long groupId)
FoundList search(String value, boolean ignoreCase)
void setRootCategories(ElContext root)
List< SyndEntry > getSyndEntries()
static String getPublicationStr(Publication publication, String sclass, boolean title, boolean details, boolean summary, boolean body, String path, boolean asMail, String readAll, IConstructor constructor)
String getParameter(String param)
void includeContent(String path)
void setTitle(String title)
IConstructor getConstructor()
void setMetas(Collection< String > metas)