Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Antti Väyrynen
/
Moya
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 2528830b
authored
Nov 24, 2013
by
Tuomas Riihimäki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add pagecontent localisation
1 parent
57236b3f
Show whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
242 additions
and
70 deletions
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/BootstrapBean.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/MenuBean.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/PlaceBean.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/SitePageBean.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/facade/SitePageFacade.java
code/MoyaBeansClient/ejbModule/fi/codecrew/moya/beans/SitePageBeanLocal.java
code/MoyaDatabase/src/fi/codecrew/moya/model/PageContent.java
code/MoyaWeb/WebContent/WEB-INF/faces-config.xml
code/MoyaWeb/WebContent/resources/cditools/pages/edit.xhtml
code/MoyaWeb/WebContent/resources/templates/template1/template.xhtml
code/MoyaWeb/src/fi/codecrew/moya/handler/SessionStore.java
code/MoyaWeb/src/fi/codecrew/moya/resources/i18n.properties
code/MoyaWeb/src/fi/codecrew/moya/resources/i18n_en.properties
code/MoyaWeb/src/fi/codecrew/moya/resources/i18n_fi.properties
code/MoyaWeb/src/fi/codecrew/moya/rest/ReaderRestView.java
code/MoyaWeb/src/fi/codecrew/moya/web/ValidLocale.java
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/content/PageOutputView.java
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/menu/MenuView.java
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/menu/PrimeMenuView.java
code/MoyaWeb/src/fi/codecrew/moya/web/converter/LocaleConverter.java
code/MoyaWeb/src/fi/codecrew/moya/web/helper/LayoutView.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/BootstrapBean.java
View file @
2528830
...
@@ -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
...
...
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/MenuBean.java
View file @
2528830
...
@@ -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
);
...
...
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/PlaceBean.java
View file @
2528830
...
@@ -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
;
...
...
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/SitePageBean.java
View file @
2528830
...
@@ -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
...
...
code/MoyaBeans/ejbModule/fi/codecrew/moya/facade/SitePageFacade.java
View file @
2528830
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
)
{
...
...
code/MoyaBeansClient/ejbModule/fi/codecrew/moya/beans/SitePageBeanLocal.java
View file @
2528830
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
);
...
...
code/MoyaDatabase/src/fi/codecrew/moya/model/PageContent.java
View file @
2528830
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
;
}
}
}
code/MoyaWeb/WebContent/WEB-INF/faces-config.xml
View file @
2528830
...
@@ -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> -->
...
...
code/MoyaWeb/WebContent/resources/cditools/pages/edit.xhtml
View file @
2528830
...
@@ -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>
...
...
code/MoyaWeb/WebContent/resources/templates/template1/template.xhtml
View file @
2528830
...
@@ -35,9 +35,19 @@
...
@@ -35,9 +35,19 @@
<h:body>
<h:body>
<script
type=
"text/javascript"
>
<script
type=
"text/javascript"
>
$
(
document
).
ready
(
function
()
{
$
(
document
)
.
ready
(
function
()
{
<
ui
:
repeat
value
=
"#{localeSelectorView.availableLocales}"
var
=
"loc"
varStatus
=
"idx"
>
<
ui
:
repeat
value
=
"#{localeSelectorView.availableLocales}"
var
=
"loc"
varStatus
=
"idx"
>
$
(
".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"
)
$
(
".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
>
<
/ui:repeat
>
$
(
".languageSelector .ui-button-text"
).
text
(
""
);
$
(
".languageSelector .ui-button-text"
).
text
(
""
);
});
});
...
@@ -65,13 +75,23 @@
...
@@ -65,13 +75,23 @@
</h:link>
</h:link>
</div>
</div>
<div
id=
"header_center"
class=
"flex1"
>
<div
id=
"header_center"
class=
"flex1"
>
<div>
<h:form
id=
"selectLanguage"
>
<h:form
id=
"selectLanguage"
>
<p:selectOneButton
id=
"langselect"
styleClass=
"languageSelector"
value=
"#{sessionStore.locale}"
onchange=
"this.form.submit()"
converter=
"#{localeConverter}"
>
<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}"
/>
<f:selectItems
value=
"#{localeSelectorView.availableLocales}"
var=
"loc"
itemValue=
"#{loc.locale}"
itemLabel=
"#{loc.locale.displayName}"
/>
</p:selectOneButton>
</p:selectOneButton>
</h:form>
</h:form>
</div>
</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>
</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>
</div>
</div>
...
...
code/MoyaWeb/src/fi/codecrew/moya/handler/SessionStore.java
View file @
2528830
...
@@ -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,11 +40,11 @@ public class SessionStore implements Serializable {
...
@@ -38,11 +40,11 @@ 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
;
}
}
return
ret
;
return
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
;
}
}
}
}
code/MoyaWeb/src/fi/codecrew/moya/resources/i18n.properties
View file @
2528830
code/MoyaWeb/src/fi/codecrew/moya/resources/i18n_en.properties
View file @
2528830
...
@@ -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
...
@@ -882,6 +884,11 @@ sidebar.utils.flushCache = Flush Cache
...
@@ -882,6 +884,11 @@ sidebar.utils.flushCache = Flush Cache
sidebar.utils.testdata
=
Testdata
sidebar.utils.testdata
=
Testdata
sitepage.addContent
=
Add content block
sitepage.addContent
=
Add content block
sitepage.content.expire
=
Expire time
sitepage.content.locale
=
Show for language
sitepage.content.publish
=
Publish time
sitepage.content.showToAll
=
All languages
sitepage.content.sort
=
Sorting number
sitepage.create
=
Create
sitepage.create
=
Create
sitepage.edit
=
Edit
sitepage.edit
=
Edit
sitepage.name
=
Page name
sitepage.name
=
Page name
...
...
code/MoyaWeb/src/fi/codecrew/moya/resources/i18n_fi.properties
View file @
2528830
...
@@ -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
\u
00E4het
\u
00E4 tiedosto
compofile.upload
=
L
\u
00E4het
\u
00E4 tiedosto
content.showContentEditLinks
=
N
\u
00E4yt
\u
00E4 sis
\u
00E4ll
\u
00F6nmuokkauslinkit
discount.active
=
Aktiivinen
discount.active
=
Aktiivinen
discount.amountMax
=
Enimm
\u
00E4ism
\u
00E4
\u
00E4r
\u
00E4
discount.amountMax
=
Enimm
\u
00E4ism
\u
00E4
\u
00E4r
\u
00E4
discount.amountMin
=
V
\u
00E4himm
\u
00E4ism
\u
00E4
\u
00E4r
\u
00E4
discount.amountMin
=
V
\u
00E4himm
\u
00E4ism
\u
00E4
\u
00E4r
\u
00E4
...
@@ -864,6 +866,11 @@ sidebar.utils.flushCache = Flush Cache
...
@@ -864,6 +866,11 @@ sidebar.utils.flushCache = Flush Cache
sidebar.utils.testdata
=
Testdata
sidebar.utils.testdata
=
Testdata
sitepage.addContent
=
Lis
\u
00E4
\u
00E4 sis
\u
00E4lt
\u
00F6laatikko
sitepage.addContent
=
Lis
\u
00E4
\u
00E4 sis
\u
00E4lt
\u
00F6laatikko
sitepage.content.expire
=
Vanhenemisaika
sitepage.content.locale
=
N
\u
00E4yt
\u
00E4 kielell
\u
00E4
sitepage.content.publish
=
Julkaisuaika
sitepage.content.showToAll
=
Kaikki kielet
sitepage.content.sort
=
J
\u
00E4rjestysluku
sitepage.create
=
Luo uusi
sitepage.create
=
Luo uusi
sitepage.edit
=
Muokkaa
sitepage.edit
=
Muokkaa
sitepage.name
=
Sivun nimi
sitepage.name
=
Sivun nimi
...
...
code/MoyaWeb/src/fi/codecrew/moya/rest/ReaderRestView.java
View file @
2528830
...
@@ -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
)
{
}
}
}
code/MoyaWeb/src/fi/codecrew/moya/web/ValidLocale.java
View file @
2528830
...
@@ -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
;
...
...
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/content/PageOutputView.java
View file @
2528830
...
@@ -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
;
}
}
}
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/menu/MenuView.java
View file @
2528830
...
@@ -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
;
}
}
}
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/menu/PrimeMenuView.java
View file @
2528830
...
@@ -91,7 +91,8 @@ public class PrimeMenuView extends GenericCDIView {
...
@@ -91,7 +91,8 @@ 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
())
{
...
@@ -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
;
}
}
...
...
code/MoyaWeb/src/fi/codecrew/moya/web/converter/LocaleConverter.java
View file @
2528830
...
@@ -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
();
...
...
code/MoyaWeb/src/fi/codecrew/moya/web/helper/LayoutView.java
View file @
2528830
...
@@ -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
;
}
}
}
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment