Commit 2528830b by Tuomas Riihimäki

Add pagecontent localisation

1 parent 57236b3f
...@@ -32,7 +32,7 @@ public class BootstrapBean implements BootstrapBeanLocal { ...@@ -32,7 +32,7 @@ public class BootstrapBean implements BootstrapBeanLocal {
dbUpdates.add(new String[] { "ALTER TABLE tournaments ADD COLUMN max_participants integer NOT NULL DEFAULT 0" }); dbUpdates.add(new String[] { "ALTER TABLE tournaments ADD COLUMN max_participants integer NOT NULL DEFAULT 0" });
dbUpdates.add(new String[] { "ALTER TABLE tournament_participants ADD COLUMN tournament integer NOT NULL REFERENCES tournaments(id)" }); dbUpdates.add(new String[] { "ALTER TABLE tournament_participants ADD COLUMN tournament integer NOT NULL REFERENCES tournaments(id)" });
dbUpdates.add(new String[] { "DELETE FROM application_permissions WHERE application = 'MAP' and permission = 'RELEASE_PLACE'" }); dbUpdates.add(new String[] { "DELETE FROM application_permissions WHERE application = 'MAP' and permission = 'RELEASE_PLACE'" });
// dbUpdates.add(new String[] { "ALTER TABLE users ALTER COLUMN birthday TYPE date" }); dbUpdates.add(new String[] { "ALTER TABLE site_page_content ADD COLUMN locale varchar(10)" });
} }
@EJB @EJB
......
...@@ -165,6 +165,8 @@ public class MenuBean implements MenuBeanLocal { ...@@ -165,6 +165,8 @@ public class MenuBean implements MenuBeanLocal {
adminuser.addPage(menuitemfacade.findOrCreate("/useradmin/foodwaveProducts"), UserPermission.VIEW_ALL).setVisible(false); adminuser.addPage(menuitemfacade.findOrCreate("/useradmin/foodwaveProducts"), UserPermission.VIEW_ALL).setVisible(false);
adminuser.addPage(menuitemfacade.findOrCreate("/useradmin/showTakePicture"), UserPermission.VIEW_ALL).setVisible(false); adminuser.addPage(menuitemfacade.findOrCreate("/useradmin/showTakePicture"), UserPermission.VIEW_ALL).setVisible(false);
adminuser.addPage(menuitemfacade.findOrCreate("/useradmin/editAccountevent"), UserPermission.VIEW_ALL).setVisible(false);
MenuNavigation adminroles = adminuser.addPage(null, null); MenuNavigation adminroles = adminuser.addPage(null, null);
adminroles.setKey("subnavi.roles"); adminroles.setKey("subnavi.roles");
adminroles.addPage(menuitemfacade.findOrCreate("/role/list"), UserPermission.READ_ROLES); adminroles.addPage(menuitemfacade.findOrCreate("/role/list"), UserPermission.READ_ROLES);
......
...@@ -323,8 +323,7 @@ public class PlaceBean implements PlaceBeanLocal { ...@@ -323,8 +323,7 @@ public class PlaceBean implements PlaceBeanLocal {
freePlace.setProduct(prod); freePlace.setProduct(prod);
freePlace.setProvidesRole(prod.getProvides()); freePlace.setProvidesRole(prod.getProvides());
placeFacade.create(freePlace); placeFacade.create(freePlace);
} else if (prod.getPlaces() != null) } else if (prod.getPlaces() != null) {
{
for (Place p : prod.getPlaces()) { for (Place p : prod.getPlaces()) {
if (!p.isTaken()) { if (!p.isTaken()) {
freePlace = p; freePlace = p;
...@@ -511,14 +510,14 @@ public class PlaceBean implements PlaceBeanLocal { ...@@ -511,14 +510,14 @@ public class PlaceBean implements PlaceBeanLocal {
} }
return place; return place;
} }
@Override @Override
@RolesAllowed(MapPermission.S_MANAGE_MAPS) @RolesAllowed(MapPermission.S_MANAGE_MAPS)
public List<GroupMembership> matchGroupMembershipsByInviteToken(String token) { public List<GroupMembership> matchGroupMembershipsByInviteToken(String token) {
List<GroupMembership> gms = gmemfacade.matchByToken(token); List<GroupMembership> gms = gmemfacade.matchByToken(token);
return gms; return gms;
} }
@Override @Override
public GroupMembership findGroupMembershipsByToken(String token) { public GroupMembership findGroupMembershipsByToken(String token) {
return gmemfacade.findByToken(token); return gmemfacade.findByToken(token);
......
...@@ -3,6 +3,7 @@ package fi.codecrew.moya.beans; ...@@ -3,6 +3,7 @@ package fi.codecrew.moya.beans;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Locale;
import javax.annotation.security.DeclareRoles; import javax.annotation.security.DeclareRoles;
import javax.annotation.security.PermitAll; import javax.annotation.security.PermitAll;
...@@ -106,21 +107,20 @@ public class SitePageBean implements SitePageBeanLocal { ...@@ -106,21 +107,20 @@ public class SitePageBean implements SitePageBeanLocal {
@Override @Override
@PermitAll @PermitAll
public List<PageContent> findContentsForUser(Integer id) { public List<PageContent> findContentsForUser(Integer id, Locale locale) {
return getContentsForPage(sitepagefacade.find(id)); return getContentsForPage(sitepagefacade.find(id), locale);
} }
private List<PageContent> getContentsForPage(SitePage page) private List<PageContent> getContentsForPage(SitePage page, Locale locale)
{ {
List<Role> roles = userbean.localFindUsersRoles(permbean.getCurrentUser()); List<Role> roles = userbean.localFindUsersRoles(permbean.getCurrentUser());
List<PageContent> ret = null; List<PageContent> ret = null;
if (page != null && page.getAllowedRoles() != null) if (page != null && page.getAllowedRoles() != null) {
{
for (Role r : page.getAllowedRoles()) { for (Role r : page.getAllowedRoles()) {
if (roles.contains(r)) { if (roles.contains(r)) {
logger.debug("Has role for page {}, role {}", page, r); logger.debug("Has role for page {}, role {}", page, r);
ret = sitepagefacade.findContents(page, new Date()); ret = sitepagefacade.findContents(page, new Date(), locale);
break; break;
} }
} }
...@@ -129,9 +129,9 @@ public class SitePageBean implements SitePageBeanLocal { ...@@ -129,9 +129,9 @@ public class SitePageBean implements SitePageBeanLocal {
} }
@Override @Override
public List<PageContent> findContentsForUser(String name) { public List<PageContent> findContentsForUser(String name, Locale locale) {
SitePage page = sitepagefacade.find(name); SitePage page = sitepagefacade.find(name);
return getContentsForPage(page); return getContentsForPage(page, locale);
} }
@Override @Override
......
package fi.codecrew.moya.facade; package fi.codecrew.moya.facade;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Locale;
import javax.ejb.EJB; import javax.ejb.EJB;
import javax.ejb.Stateless; import javax.ejb.Stateless;
...@@ -12,20 +15,24 @@ import javax.persistence.criteria.Path; ...@@ -12,20 +15,24 @@ import javax.persistence.criteria.Path;
import javax.persistence.criteria.Predicate; import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root; import javax.persistence.criteria.Root;
import fi.codecrew.moya.model.PageContent_; import org.slf4j.Logger;
import fi.codecrew.moya.model.Role_; import org.slf4j.LoggerFactory;
import fi.codecrew.moya.model.SitePage_;
import fi.codecrew.moya.beans.EventBeanLocal; import fi.codecrew.moya.beans.EventBeanLocal;
import fi.codecrew.moya.model.EventUser; import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.PageContent; import fi.codecrew.moya.model.PageContent;
import fi.codecrew.moya.model.PageContent_;
import fi.codecrew.moya.model.Role; import fi.codecrew.moya.model.Role;
import fi.codecrew.moya.model.Role_;
import fi.codecrew.moya.model.SitePage; import fi.codecrew.moya.model.SitePage;
import fi.codecrew.moya.model.SitePage_;
@Stateless @Stateless
public class SitePageFacade extends IntegerPkGenericFacade<SitePage> { public class SitePageFacade extends IntegerPkGenericFacade<SitePage> {
@EJB @EJB
private EventBeanLocal eventbean; private EventBeanLocal eventbean;
private static final Logger logger = LoggerFactory.getLogger(SitePageFacade.class);
public SitePageFacade() { public SitePageFacade() {
...@@ -102,7 +109,10 @@ public class SitePageFacade extends IntegerPkGenericFacade<SitePage> { ...@@ -102,7 +109,10 @@ public class SitePageFacade extends IntegerPkGenericFacade<SitePage> {
} }
public List<PageContent> findContents(SitePage page, Date now) { public List<PageContent> findContents(SitePage page, Date now, Locale locale) {
logger.info("Getting pageContents for locale {}", locale);
CriteriaBuilder cb = getEm().getCriteriaBuilder(); CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<PageContent> cq = cb.createQuery(PageContent.class); CriteriaQuery<PageContent> cq = cb.createQuery(PageContent.class);
Root<PageContent> root = cq.from(PageContent.class); Root<PageContent> root = cq.from(PageContent.class);
...@@ -115,9 +125,24 @@ public class SitePageFacade extends IntegerPkGenericFacade<SitePage> { ...@@ -115,9 +125,24 @@ public class SitePageFacade extends IntegerPkGenericFacade<SitePage> {
cb.or(cb.isNull(publishpath), cb.greaterThan(publishpath, now)), cb.or(cb.isNull(publishpath), cb.greaterThan(publishpath, now)),
cb.or(cb.isNull(expirepath), cb.lessThan(expirepath, now)) cb.or(cb.isNull(expirepath), cb.lessThan(expirepath, now))
); );
cq.orderBy(cb.desc(root.get(PageContent_.sort)));
return getEm().createQuery(cq).getResultList();
ArrayList<PageContent> ret = new ArrayList<>(getEm().createQuery(cq).getResultList());
if (locale != null) {
final String localeLang = locale.getLanguage();
for (Iterator<PageContent> contIter = ret.iterator(); contIter.hasNext();) {
PageContent content = contIter.next();
// Show only if language equals or is null
Locale contLocale = content.getLocaleObject();
if (contLocale != null && !localeLang.equals(contLocale.getLanguage())) {
logger.info("Removing content with lang {} (comparing to {}) ", contLocale, locale);
contIter.remove();
}
}
}
return ret;
} }
public SitePage find(String name) { public SitePage find(String name) {
......
package fi.codecrew.moya.beans; package fi.codecrew.moya.beans;
import java.util.List; import java.util.List;
import java.util.Locale;
import javax.ejb.Local; import javax.ejb.Local;
...@@ -24,9 +25,9 @@ public interface SitePageBeanLocal { ...@@ -24,9 +25,9 @@ public interface SitePageBeanLocal {
SitePage find(Integer id); SitePage find(Integer id);
List<PageContent> findContentsForUser(Integer id); List<PageContent> findContentsForUser(Integer id, Locale locale);
List<PageContent> findContentsForUser(String name); List<PageContent> findContentsForUser(String name, Locale locale);
SitePage findSitename(String managedPage); SitePage findSitename(String managedPage);
......
package fi.codecrew.moya.model; package fi.codecrew.moya.model;
import java.util.Date; import java.util.Date;
import java.util.Locale;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
...@@ -37,6 +38,25 @@ public class PageContent extends GenericEntity { ...@@ -37,6 +38,25 @@ public class PageContent extends GenericEntity {
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
private Date expire; private Date expire;
@Column(length = 10)
private String locale;
public Locale getLocaleObject() {
Locale ret = null;
if (locale != null) {
ret = Locale.forLanguageTag(locale);
}
return ret;
}
public void setLocaleObject(Locale locale) {
String loc = null;
if (locale != null) {
loc = locale.toLanguageTag();
}
this.locale = loc;
}
public PageContent() { public PageContent() {
super(); super();
} }
...@@ -86,4 +106,12 @@ public class PageContent extends GenericEntity { ...@@ -86,4 +106,12 @@ public class PageContent extends GenericEntity {
this.expire = expire; this.expire = expire;
} }
public String getLocale() {
return locale;
}
public void setLocale(String locale) {
this.locale = locale;
}
} }
...@@ -16,9 +16,7 @@ ...@@ -16,9 +16,7 @@
<!-- Vector VE (VENEZUELA, BOLIVARIAN REPUBLIC OF) --> <!-- Vector VE (VENEZUELA, BOLIVARIAN REPUBLIC OF) -->
<locale-config> <locale-config>
<default-locale>fi_FI</default-locale> <default-locale>fi_FI</default-locale>
<supported-locale>fi_fi_XII</supported-locale> <supported-locale>en_UK</supported-locale>
<supported-locale>en_ST_v7</supported-locale>
<supported-locale>en_ST_nine</supported-locale>
</locale-config> </locale-config>
</application> </application>
...@@ -44,35 +42,35 @@ ...@@ -44,35 +42,35 @@
<!-- </navigation-case> --> <!-- </navigation-case> -->
<!-- </navigation-rule> --> <!-- </navigation-rule> -->
<!-- <navigation-rule> --> <!-- <navigation-rule> -->
<!-- <from-view-id>*</from-view-id> --> <!-- <from-view-id>*</from-view-id> -->
<!-- <navigation-case> --> <!-- <navigation-case> -->
<!-- <from-outcome>shopToUser</from-outcome> --> <!-- <from-outcome>shopToUser</from-outcome> -->
<!-- <to-view-id>/shop/shopToUser</to-view-id> --> <!-- <to-view-id>/shop/shopToUser</to-view-id> -->
<!-- <redirect /> --> <!-- <redirect /> -->
<!-- </navigation-case> --> <!-- </navigation-case> -->
<!-- <navigation-case> --> <!-- <navigation-case> -->
<!-- <from-outcome>logoutDone</from-outcome> --> <!-- <from-outcome>logoutDone</from-outcome> -->
<!-- <to-view-id>/auth/logoutResponse</to-view-id> --> <!-- <to-view-id>/auth/logoutResponse</to-view-id> -->
<!-- <redirect /> --> <!-- <redirect /> -->
<!-- </navigation-case> --> <!-- </navigation-case> -->
<!-- <navigation-case> --> <!-- <navigation-case> -->
<!-- <from-outcome>redirBillList</from-outcome> --> <!-- <from-outcome>redirBillList</from-outcome> -->
<!-- <to-view-id>/bill/list</to-view-id> --> <!-- <to-view-id>/bill/list</to-view-id> -->
<!-- <redirect /> --> <!-- <redirect /> -->
<!-- </navigation-case> --> <!-- </navigation-case> -->
<!-- </navigation-rule> --> <!-- </navigation-rule> -->
<!-- <navigation-rule> --> <!-- <navigation-rule> -->
<!-- <from-view-id>/news/editNews</from-view-id> --> <!-- <from-view-id>/news/editNews</from-view-id> -->
<!-- <navigation-case> --> <!-- <navigation-case> -->
<!-- <from-outcome>news/listAll</from-outcome> --> <!-- <from-outcome>news/listAll</from-outcome> -->
<!-- <to-view-id>/news/listAll</to-view-id> --> <!-- <to-view-id>/news/listAll</to-view-id> -->
<!-- <redirect /> --> <!-- <redirect /> -->
<!-- </navigation-case> --> <!-- </navigation-case> -->
<!-- </navigation-rule> --> <!-- </navigation-rule> -->
<!-- </navigation-rule> --> <!-- </navigation-rule> -->
......
...@@ -37,8 +37,28 @@ ...@@ -37,8 +37,28 @@
</div> </div>
</ui:fragment> </ui:fragment>
<ui:repeat rendered="#{!empty sitePageView.sitepage.contents}" value="#{sitePageView.sitepage.contents}" var="cont"> <ui:repeat id="contentRepeat" rendered="#{!empty sitePageView.sitepage.contents}" value="#{sitePageView.sitepage.contents}" var="cont">
<div> <div style="border-width: 1px; border-style: solid; margin: 1em 0 0 0; padding: 0.5em;">
<h:panelGrid columns="2">
<h:outputLabel value="#{i18n['sitepage.content.locale']}: " for="locale" />
<h:selectOneMenu id="locale" value="#{cont.localeObject}" converter="#{localeConverter}">
<f:selectItem itemValue="null" itemLabel="#{i18n['sitepage.content.showToAll']}" />
<f:selectItems value="#{localeSelectorView.availableLocales}" var="loc" itemValue="#{loc.locale}" itemLabel="#{loc.locale.displayName}" />
</h:selectOneMenu>
<h:outputLabel for="sort" value="#{i18n['sitepage.content.sort']}" />
<h:inputText id="sort" value="#{cont.sort}">
<f:convertNumber integerOnly="true" />
</h:inputText>
<h:outputLabel for="publish" value="#{i18n['sitepage.content.publish']}" />
<p:calendar id="publish" value="#{cont.publish}" pattern="#{sessionHandler.datetimeFormat}"/>
<h:outputLabel for="expire" value="#{i18n['sitepage.content.expire']}" />
<p:calendar id="expire" value="#{cont.publish}" pattern="#{sessionHandler.datetimeFormat}"/>
</h:panelGrid>
<p:editor value="#{cont.content}" /> <p:editor value="#{cont.content}" />
</div> </div>
</ui:repeat> </ui:repeat>
......
...@@ -35,12 +35,22 @@ ...@@ -35,12 +35,22 @@
<h:body> <h:body>
<script type="text/javascript"> <script type="text/javascript">
$( document ).ready(function() { $(document)
<ui:repeat value="#{localeSelectorView.availableLocales}" var="loc" varStatus="idx"> .ready(
$(".languageSelector .ui-button:eq(#{idx.index})").css("background", "url('#{request.contextPath}/resources/icons/flags/#{loc.locale.language}.png') no-repeat").css("width", "16px").css("height", "11px").css("padding", "0").css("margin-right", "5px").css("border-radius", "0") function() {
</ui:repeat> <ui:repeat value="#{localeSelectorView.availableLocales}" var="loc" varStatus="idx">
$(".languageSelector .ui-button-text").text(""); $(
}); ".languageSelector .ui-button:eq(#{idx.index})")
.css(
"background",
"url('#{request.contextPath}/resources/icons/flags/#{loc.locale.language}.png') no-repeat")
.css("width", "16px").css("height",
"11px").css("padding", "0")
.css("margin-right", "5px").css(
"border-radius", "0")
</ui:repeat>
$(".languageSelector .ui-button-text").text("");
});
</script> </script>
<!--[if lt IE 7]> <!--[if lt IE 7]>
<p class="chromeframe">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> or <a href="http://www.google.com/chromeframe/?redirect=true">activate Google Chrome Frame</a> to improve your experience.</p> <p class="chromeframe">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> or <a href="http://www.google.com/chromeframe/?redirect=true">activate Google Chrome Frame</a> to improve your experience.</p>
...@@ -65,12 +75,22 @@ ...@@ -65,12 +75,22 @@
</h:link> </h:link>
</div> </div>
<div id="header_center" class="flex1"> <div id="header_center" class="flex1">
<div>
<h:form id="selectLanguage">
<p:selectOneButton id="langselect" styleClass="languageSelector" value="#{sessionStore.locale}" onchange="this.form.submit()" converter="#{localeConverter}">
<f:selectItems value="#{localeSelectorView.availableLocales}" var="loc" itemValue="#{loc.locale}" itemLabel="#{loc.locale.displayName}" />
</p:selectOneButton>
</h:form>
</div>
<ui:fragment rendered="#{layoutView.canManageContent}">
<div>
<h:form>
<h:outputLabel for="manageBtn" value="#{i18n['content.showContentEditLinks']}" />
<h:selectBooleanCheckbox value="#{sessionStore.manageContentLinks}" onclick="this.form.submit()" />
</h:form>
</div>
</ui:fragment>
<h:form id="selectLanguage">
<p:selectOneButton id="langselect" styleClass="languageSelector" value="#{sessionStore.locale}" onchange="this.form.submit()" converter="#{localeConverter}">
<f:selectItems value="#{localeSelectorView.availableLocales}" var="loc" itemValue="#{loc.locale}" itemLabel="#{loc.locale.displayName}" />
</p:selectOneButton>
</h:form>
</div> </div>
<div id="header_right"> <div id="header_right">
<a href="http://www.codecrew.fi"><img src="#{request.contextPath}/resources/templates/template1/img/moya_logo.png" /> </a> <a href="http://www.codecrew.fi"><img src="#{request.contextPath}/resources/templates/template1/img/moya_logo.png" /> </a>
......
...@@ -5,6 +5,7 @@ import java.util.Locale; ...@@ -5,6 +5,7 @@ import java.util.Locale;
import javax.ejb.EJB; import javax.ejb.EJB;
import javax.enterprise.context.SessionScoped; import javax.enterprise.context.SessionScoped;
import javax.faces.context.FacesContext;
import javax.inject.Named; import javax.inject.Named;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -17,11 +18,12 @@ import fi.codecrew.moya.beans.EventBeanLocal; ...@@ -17,11 +18,12 @@ import fi.codecrew.moya.beans.EventBeanLocal;
public class SessionStore implements Serializable { public class SessionStore implements Serializable {
private static final long serialVersionUID = 594517648650107916L; private static final long serialVersionUID = 594517648650107916L;
private static final Locale DEFAULT_LOCALE = Locale.forLanguageTag("fi_FI"); private static final Locale DEFAULT_LOCALE = new Locale("fi");
@EJB @EJB
private EventBeanLocal eventbean; private EventBeanLocal eventbean;
private Locale locale; private Locale locale;
private boolean manageContentLinks = false;
private static final Logger logger = LoggerFactory.getLogger(SessionStore.class); private static final Logger logger = LoggerFactory.getLogger(SessionStore.class);
...@@ -38,10 +40,10 @@ public class SessionStore implements Serializable { ...@@ -38,10 +40,10 @@ public class SessionStore implements Serializable {
logger.warn("Error setting locale from current event for {}", retStr); logger.warn("Error setting locale from current event for {}", retStr);
ret = null; ret = null;
} }
}
if (ret == null) { if (ret == null) {
ret = DEFAULT_LOCALE; ret = DEFAULT_LOCALE;
}
} }
locale = ret; locale = ret;
} }
...@@ -51,6 +53,15 @@ public class SessionStore implements Serializable { ...@@ -51,6 +53,15 @@ public class SessionStore implements Serializable {
public void setLocale(Locale locale) public void setLocale(Locale locale)
{ {
this.locale = locale; this.locale = locale;
FacesContext.getCurrentInstance().getViewRoot().setLocale(locale);
}
public boolean isManageContentLinks() {
return manageContentLinks;
}
public void setManageContentLinks(boolean manageContentLinks) {
this.manageContentLinks = manageContentLinks;
} }
} }
...@@ -223,8 +223,8 @@ resetMail.username = Username ...@@ -223,8 +223,8 @@ resetMail.username = Username
resetmailSent.body = Email has been sent containing a link where you can change the password. resetmailSent.body = Email has been sent containing a link where you can change the password.
resetmailSent.header = Email sent resetmailSent.header = Email sent
submenu.NotImplementedYet = Not implemented submenu.NotImplementedYet = Not implemented
submenu.frontpage = Frontpage submenu.frontpage = Frontpage
subnavi.cards = \u0009\u0009 subnavi.cards = \u0009\u0009
......
...@@ -222,6 +222,8 @@ compofile.download = Download ...@@ -222,6 +222,8 @@ compofile.download = Download
compofile.download.header = Download file compofile.download.header = Download file
compofile.upload = Upload file compofile.upload = Upload file
content.showContentEditLinks = Show content edit links
discount.active = Active discount.active = Active
discount.amountMax = Max amount discount.amountMax = Max amount
discount.amountMin = Min amount discount.amountMin = Min amount
...@@ -881,12 +883,17 @@ sidebar.users = Users ...@@ -881,12 +883,17 @@ sidebar.users = Users
sidebar.utils.flushCache = Flush Cache sidebar.utils.flushCache = Flush Cache
sidebar.utils.testdata = Testdata sidebar.utils.testdata = Testdata
sitepage.addContent = Add content block sitepage.addContent = Add content block
sitepage.create = Create sitepage.content.expire = Expire time
sitepage.edit = Edit sitepage.content.locale = Show for language
sitepage.name = Page name sitepage.content.publish = Publish time
sitepage.roles = Visible for roles sitepage.content.showToAll = All languages
sitepage.save = Save sitepage.content.sort = Sorting number
sitepage.create = Create
sitepage.edit = Edit
sitepage.name = Page name
sitepage.roles = Visible for roles
sitepage.save = Save
sitepagelist.header = Site pages sitepagelist.header = Site pages
......
...@@ -224,6 +224,8 @@ compofile.download = lataa ...@@ -224,6 +224,8 @@ compofile.download = lataa
compofile.download.header = Lataa tiedosto compofile.download.header = Lataa tiedosto
compofile.upload = L\u00E4het\u00E4 tiedosto compofile.upload = L\u00E4het\u00E4 tiedosto
content.showContentEditLinks = N\u00E4yt\u00E4 sis\u00E4ll\u00F6nmuokkauslinkit
discount.active = Aktiivinen discount.active = Aktiivinen
discount.amountMax = Enimm\u00E4ism\u00E4\u00E4r\u00E4 discount.amountMax = Enimm\u00E4ism\u00E4\u00E4r\u00E4
discount.amountMin = V\u00E4himm\u00E4ism\u00E4\u00E4r\u00E4 discount.amountMin = V\u00E4himm\u00E4ism\u00E4\u00E4r\u00E4
...@@ -863,12 +865,17 @@ sidebar.users = K\u00E4ytt\u00E4j\u00E4t ...@@ -863,12 +865,17 @@ sidebar.users = K\u00E4ytt\u00E4j\u00E4t
sidebar.utils.flushCache = Flush Cache sidebar.utils.flushCache = Flush Cache
sidebar.utils.testdata = Testdata sidebar.utils.testdata = Testdata
sitepage.addContent = Lis\u00E4\u00E4 sis\u00E4lt\u00F6laatikko sitepage.addContent = Lis\u00E4\u00E4 sis\u00E4lt\u00F6laatikko
sitepage.create = Luo uusi sitepage.content.expire = Vanhenemisaika
sitepage.edit = Muokkaa sitepage.content.locale = N\u00E4yt\u00E4 kielell\u00E4
sitepage.name = Sivun nimi sitepage.content.publish = Julkaisuaika
sitepage.roles = N\u00E4ytet\u00E4\u00E4n rooleille sitepage.content.showToAll = Kaikki kielet
sitepage.save = Tallenna sitepage.content.sort = J\u00E4rjestysluku
sitepage.create = Luo uusi
sitepage.edit = Muokkaa
sitepage.name = Sivun nimi
sitepage.roles = N\u00E4ytet\u00E4\u00E4n rooleille
sitepage.save = Tallenna
sitepagelist.header = Sivuston sis\u00E4ll\u00F6t sitepagelist.header = Sivuston sis\u00E4ll\u00F6t
......
...@@ -5,6 +5,7 @@ import javax.enterprise.context.RequestScoped; ...@@ -5,6 +5,7 @@ import javax.enterprise.context.RequestScoped;
import javax.ws.rs.Consumes; import javax.ws.rs.Consumes;
import javax.ws.rs.GET; import javax.ws.rs.GET;
import javax.ws.rs.Path; import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces; import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
...@@ -36,4 +37,23 @@ public class ReaderRestView { ...@@ -36,4 +37,23 @@ public class ReaderRestView {
{ {
return new ReaderEventRestRoot(ReaderEventRestPojo.parse(readerbean.getLastReaderEvents())); return new ReaderEventRestRoot(ReaderEventRestPojo.parse(readerbean.getLastReaderEvents()));
} }
// @GET
// @Path("/RfidEvent/{reader}/{tagId}")
// public void createRfidEvent(@PathParam("reader") String reader, @PathParam("tagId") String tagId) {
//
// }
@GET
@Path("/EventRole/{reader}/{roleid}")
public void eventRole(@PathParam("reader") String reader, @PathParam("roleid") String roleId) {
}
@GET
@Path("/EventCard/{reader}/{cardid}")
public void eventCard(@PathParam("reader") String reader, @PathParam("cardid") String cardId) {
}
} }
...@@ -3,8 +3,8 @@ package fi.codecrew.moya.web; ...@@ -3,8 +3,8 @@ package fi.codecrew.moya.web;
import java.util.Locale; import java.util.Locale;
public enum ValidLocale { public enum ValidLocale {
FINNISH(new Locale("fi", "FI")), FINNISH(new Locale("fi")),
ENGLISH(new Locale("en", "US")); ENGLISH(new Locale("en"));
private final Locale locale; private final Locale locale;
......
...@@ -4,9 +4,11 @@ import java.util.List; ...@@ -4,9 +4,11 @@ import java.util.List;
import javax.ejb.EJB; import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped; import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.inject.Named; import javax.inject.Named;
import fi.codecrew.moya.beans.SitePageBeanLocal; import fi.codecrew.moya.beans.SitePageBeanLocal;
import fi.codecrew.moya.handler.SessionStore;
import fi.codecrew.moya.model.PageContent; import fi.codecrew.moya.model.PageContent;
import fi.codecrew.moya.web.cdiview.GenericCDIView; import fi.codecrew.moya.web.cdiview.GenericCDIView;
...@@ -18,6 +20,8 @@ public class PageOutputView extends GenericCDIView { ...@@ -18,6 +20,8 @@ public class PageOutputView extends GenericCDIView {
@EJB @EJB
private transient SitePageBeanLocal pagebean; private transient SitePageBeanLocal pagebean;
@Inject
private SessionStore store;
private Integer id; private Integer id;
private String name; private String name;
...@@ -28,6 +32,7 @@ public class PageOutputView extends GenericCDIView { ...@@ -28,6 +32,7 @@ public class PageOutputView extends GenericCDIView {
{ {
name = "/frontpage"; name = "/frontpage";
initView(); initView();
} }
public void initView(String name) public void initView(String name)
...@@ -38,13 +43,12 @@ public class PageOutputView extends GenericCDIView { ...@@ -38,13 +43,12 @@ public class PageOutputView extends GenericCDIView {
public void initView() { public void initView() {
if (name == null || name.isEmpty()) { if (name == null || name.isEmpty()) {
setContents(pagebean.findContentsForUser(id)); setContents(pagebean.findContentsForUser(id, store.getLocale()));
} else { } else {
setContents(pagebean.findContentsForUser(name)); setContents(pagebean.findContentsForUser(name, store.getLocale()));
} }
if (!requirePermissions(contents != null && !contents.isEmpty())) if (!requirePermissions(contents != null && !contents.isEmpty())) {
{
contents = null; contents = null;
} }
} }
...@@ -65,4 +69,12 @@ public class PageOutputView extends GenericCDIView { ...@@ -65,4 +69,12 @@ public class PageOutputView extends GenericCDIView {
this.contents = contents; this.contents = contents;
} }
public SessionStore getStore() {
return store;
}
public void setStore(SessionStore store) {
this.store = store;
}
} }
...@@ -21,6 +21,7 @@ import fi.codecrew.moya.beans.MenuBeanLocal; ...@@ -21,6 +21,7 @@ import fi.codecrew.moya.beans.MenuBeanLocal;
import fi.codecrew.moya.beans.PermissionBeanLocal; import fi.codecrew.moya.beans.PermissionBeanLocal;
import fi.codecrew.moya.beans.SitePageBeanLocal; import fi.codecrew.moya.beans.SitePageBeanLocal;
import fi.codecrew.moya.handler.NavigationHandler; import fi.codecrew.moya.handler.NavigationHandler;
import fi.codecrew.moya.handler.SessionStore;
import fi.codecrew.moya.model.MenuNavigation; import fi.codecrew.moya.model.MenuNavigation;
import fi.codecrew.moya.model.PageContent; import fi.codecrew.moya.model.PageContent;
import fi.codecrew.moya.web.helper.LayoutView; import fi.codecrew.moya.web.helper.LayoutView;
...@@ -37,6 +38,8 @@ public class MenuView { ...@@ -37,6 +38,8 @@ public class MenuView {
@Inject @Inject
private transient LayoutView layoutview; private transient LayoutView layoutview;
@Inject
private transient SessionStore sessionstore;
@Inject @Inject
private transient FacesContext context; private transient FacesContext context;
...@@ -63,7 +66,7 @@ public class MenuView { ...@@ -63,7 +66,7 @@ public class MenuView {
logger.debug("Getting pagecontent for key {}. Matches: {}", key, contents.containsKey(key)); logger.debug("Getting pagecontent for key {}. Matches: {}", key, contents.containsKey(key));
if (!contents.containsKey(key)) { if (!contents.containsKey(key)) {
contents.put(key, pagebean.findContentsForUser(key)); contents.put(key, pagebean.findContentsForUser(key, sessionstore.getLocale()));
} }
return contents.get(key); return contents.get(key);
} }
...@@ -253,4 +256,12 @@ public class MenuView { ...@@ -253,4 +256,12 @@ public class MenuView {
this.menuChange = menuChange; this.menuChange = menuChange;
} }
public SessionStore getSessionstore() {
return sessionstore;
}
public void setSessionstore(SessionStore sessionstore) {
this.sessionstore = sessionstore;
}
} }
...@@ -91,8 +91,9 @@ public class PrimeMenuView extends GenericCDIView { ...@@ -91,8 +91,9 @@ public class PrimeMenuView extends GenericCDIView {
{ {
menuModel = new DefaultMenuModel(); menuModel = new DefaultMenuModel();
MenuNavigation selectedTop = layoutview.getSelectedTopmenu(); MenuNavigation selectedTop = layoutview.getSelectedTopmenu();
if(selectedTop == null) return null; if (selectedTop == null)
return null;
for (MenuNavigation m : selectedTop.getChildren()) { for (MenuNavigation m : selectedTop.getChildren()) {
if (m.getItem() != null && m.getChildren().isEmpty()) { if (m.getItem() != null && m.getChildren().isEmpty()) {
DefaultMenuItem menuitem = mkMenuitem(m); DefaultMenuItem menuitem = mkMenuitem(m);
...@@ -108,10 +109,7 @@ public class PrimeMenuView extends GenericCDIView { ...@@ -108,10 +109,7 @@ public class PrimeMenuView extends GenericCDIView {
} }
// logger.info("Initialized menumodel for user {} with {} entries" ) // logger.info("Initialized menumodel for user {} with {} entries" )
} else {
logger.info("Not initializing menumodel with {} entries for user {}", menuModel.getElements().size());
} }
return menuModel; return menuModel;
} }
......
...@@ -18,7 +18,7 @@ public class LocaleConverter implements Converter { ...@@ -18,7 +18,7 @@ public class LocaleConverter implements Converter {
@Override @Override
public Object getAsObject(FacesContext context, UIComponent component, String value) { public Object getAsObject(FacesContext context, UIComponent component, String value) {
Locale ret = null; Locale ret = null;
if (value != null) { if (value != null && !value.isEmpty() && !"null".equals(value)) {
try { try {
ret = Locale.forLanguageTag(value); ret = Locale.forLanguageTag(value);
} catch (Throwable t) { } catch (Throwable t) {
...@@ -31,7 +31,7 @@ public class LocaleConverter implements Converter { ...@@ -31,7 +31,7 @@ public class LocaleConverter implements Converter {
@Override @Override
public String getAsString(FacesContext context, UIComponent component, Object value) { public String getAsString(FacesContext context, UIComponent component, Object value) {
String ret = null; String ret = "null";
if (value != null && value instanceof Locale) { if (value != null && value instanceof Locale) {
Locale loc = (Locale) value; Locale loc = (Locale) value;
ret = loc.toLanguageTag(); ret = loc.toLanguageTag();
......
...@@ -24,6 +24,7 @@ import fi.codecrew.moya.beans.EventBeanLocal; ...@@ -24,6 +24,7 @@ import fi.codecrew.moya.beans.EventBeanLocal;
import fi.codecrew.moya.beans.MenuBeanLocal; import fi.codecrew.moya.beans.MenuBeanLocal;
import fi.codecrew.moya.beans.PermissionBeanLocal; import fi.codecrew.moya.beans.PermissionBeanLocal;
import fi.codecrew.moya.enums.apps.ContentPermission; import fi.codecrew.moya.enums.apps.ContentPermission;
import fi.codecrew.moya.handler.SessionStore;
import fi.codecrew.moya.model.LanEventProperty; import fi.codecrew.moya.model.LanEventProperty;
import fi.codecrew.moya.model.LanEventPropertyKey; import fi.codecrew.moya.model.LanEventPropertyKey;
import fi.codecrew.moya.model.MenuNavigation; import fi.codecrew.moya.model.MenuNavigation;
...@@ -42,7 +43,8 @@ public class LayoutView { ...@@ -42,7 +43,8 @@ public class LayoutView {
private transient PermissionBeanLocal permbean; private transient PermissionBeanLocal permbean;
private StreamedContent headerimage; private StreamedContent headerimage;
private String headertext; private String headertext;
@Inject
private SessionStore sessionStore;
@EJB @EJB
private transient MenuBeanLocal menubean; private transient MenuBeanLocal menubean;
...@@ -52,8 +54,11 @@ public class LayoutView { ...@@ -52,8 +54,11 @@ public class LayoutView {
logger.info("Initialized layoutView"); logger.info("Initialized layoutView");
} }
public boolean isManageContent() public boolean isManageContent() {
{ return sessionStore.isManageContentLinks() && permbean.hasPermission(ContentPermission.MANAGE_PAGES);
}
public boolean isCanManageContent() {
return permbean.hasPermission(ContentPermission.MANAGE_PAGES); return permbean.hasPermission(ContentPermission.MANAGE_PAGES);
} }
...@@ -241,4 +246,12 @@ public class LayoutView { ...@@ -241,4 +246,12 @@ public class LayoutView {
return value; return value;
} }
public SessionStore getSessionStore() {
return sessionStore;
}
public void setSessionStore(SessionStore sessionStore) {
this.sessionStore = sessionStore;
}
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!