19 package org.turro.polls;
21 import java.util.ArrayList;
22 import java.util.Collection;
23 import org.turro.string.Strings;
24 import org.turro.attach.www.AttachCtrl;
25 import org.turro.auth.Authentication;
26 import org.turro.collections.CollectionHtmlIterator;
27 import org.turro.elephant.context.IConstructor;
28 import org.turro.elephant.db.ElephantPU;
29 import org.turro.elephant.entities.db.Poll;
30 import org.turro.elephant.entities.db.PollOption;
31 import org.turro.elephant.impl.repository.Repository;
32 import org.turro.elephant.impl.repository.RepositoryFile;
33 import org.turro.elephant.web.SocialImageMap;
34 import org.turro.elephant.web.SocialNet;
35 import org.turro.file.util.FileAttach;
36 import org.turro.mail.recipients.MailContact;
37 import org.turro.marker.ElephantMarker;
45 private String pubPath, actualParameters;
46 private boolean restricted, publicOnly, activeOnly;
51 this.pubPath = pubPath;
60 this.publicOnly = publicOnly;
68 this.activeOnly = activeOnly;
76 this.restricted = restricted;
83 public Collection<Poll>
items() {
88 return Strings.isBlank(actualParameters) ?
"?a=b" : actualParameters;
104 return "quadrantOption";
106 return "doodleOption";
115 prepareValues(e, page,
false);
118 actualParameters = getPageLink(page);
124 prepareValues(e, page,
false);
126 actualParameters = getPageLink(page);
136 if(restricted && e !=
null) {
139 return super.isValid(e);
143 private void prepareValues(
Poll poll,
int page,
boolean asMail) {
145 if(asMail && pubPath !=
null) {
150 if(pubPath !=
null) {
151 marker.
put(
"path", getItemLink(poll, page));
154 if(!Strings.isBlank(pubPath)) {
155 marker.
put(
"readall", getItemLink(poll, page));
159 ac.setEntityPath(ElephantPU.getObjectPath(poll));
160 ac.setPublicOnly(publicOnly);
169 private String getItemLink(Poll poll,
int page) {
170 return pubPath +
"?item=" + poll.getId() +
"&page=" + page;
173 private String getPageLink(
int page) {
174 return pubPath +
"?page=" + page;
184 ArrayList<RepositoryFile> files =
new ArrayList<>();
185 String path = getItemLink(e, 0);
static IContact getIContact()
String getSummaryTemplate()
List< E > getTotalItems()
static String getObjectPath(Object object)
boolean isAllowNegatives()
boolean isShowParticipants()
Set< RepositoryFile > getRepositoryFiles(String pattern)
static boolean hasImage(String url)
List< String > getMetas()
Repository getPublishableRepository(IConstructor constructor)
void process(String rootTmpl, String tmpl)
Object put(Object key, Object value)
static String createURL(PollOption option, IContact contact, int vote)
Collection< Poll > items()
String getActualParameters()
static String getOptionTemplate(Poll poll)
String getVoteURL(PollOption option, int vote)
PollIterator(IConstructor constructor, String pubPath)
void setActiveOnly(boolean activeOnly)
void renderItem(ElephantMarker marker, Poll e, int page)
void setPublicOnly(boolean publicOnly)
void renderSummary(ElephantMarker marker, Poll e, int page)
Collection< String > metas(Poll e)
void setRestricted(boolean restricted)
static Set< Poll > getMyPolls(IContact contact)