Commit 17164ee3 by Anton Sudak

Introducte _pageBase template in order to generalize templates for both…

Introducte _pageBase template in order to generalize templates for both PageBlock and StandalonePage classes without using class casting
parent 04e01476
......@@ -29,10 +29,17 @@ import java.util.List;
*/
public interface Page {
public MString getPageTitle();
public MString getMetaTitle();
public MString getPageDescription();
public List<PageBlock> getSubPages();
public String alternateLanguageUrl(String key);
public String getKey();
boolean isSearchable();
MString getPageTitle();
MString getMetaTitle();
MString getPageDescription();
List<PageBlock> getSubPages();
String alternateLanguageUrl(String key);
String getKey();
}
......@@ -22,7 +22,6 @@ import org.slf4j.Logger;
import play.Play;
import play.i18n.Lang;
import play.i18n.Messages;
import play.i18n.MessagesApi;
import java.util.ArrayList;
......@@ -34,7 +33,7 @@ import java.util.List;
* to pass values to shared templates.
*
*/
public class StandalonePage implements Page {
public class StandalonePage implements Page {
private final static Logger logger = LoggerFactory.getLogger(StandalonePage.class);
protected String key;
......@@ -74,6 +73,11 @@ public class StandalonePage implements Page {
}
@Override
public boolean isSearchable() {
return false;
}
@Override
public MString getPageTitle() {
return fromMessage(titleKey);
}
......@@ -98,18 +102,16 @@ public class StandalonePage implements Page {
@Override
public List<PageBlock> getSubPages() {
return new ArrayList<PageBlock>();
return new ArrayList<>();
}
@Override
public String alternateLanguageUrl(String lang) {
if(alternateLanguageUrls.get(lang) != null) {
return alternateLanguageUrls.get(lang);
} else {
try {
return PageBlock.find.byKey(PageBlock.KEY_HOMEPAGE).getNavItem(lang).getURL();
} catch (Exception e) {
logger.error("alternateLanguageUrl: Error while trying to find homepage with key " + PageBlock.KEY_HOMEPAGE + " in language: " + lang + ". This means your setup is not correct.", e);
e.printStackTrace();
......
@import ch.insign.cms.models.PageBlock
@import ch.insign.cms.views.html._blockBase
@import ch.insign.cms.models.Template
@import ch.insign.cms.views.html.{_loginFormModal, deleteBlockModal, restrictBlockModal, unrestrictBlockModal}
@import ch.insign.cms.controllers.AuthController
@import ch.insign.playauth.views.helper.hasPermission
@import ch.insign.cms.permissions.BlockPermission
@(
page: ch.insign.cms.models.Page,
add: Boolean = false,
edit: Boolean = true,
delete: Boolean = true,
restrict: Boolean = false,
name: String = "",
color: String = "gray",
sortableContainer: Boolean = false,
CssClass: String = ""
)(content: Html)
<body @hasPermission(BlockPermission.MODIFY){class="fe-admin"}>
@Some(page).map {
case cmsManaged: PageBlock => {
@_loginFormModal(AuthController.LOGIN_FORM, flash.get("backUrl"), Messages("frontend.login.modal.title"))
@_blockBase(cmsManaged, add, edit, delete, restrict, name, color, sortableContainer, CssClass)(content)
@if(!Template.isIndexer && cmsManaged.canModify) {
@deleteBlockModal()
@restrictBlockModal()
@unrestrictBlockModal()
}
}
case _ => {
@*Here could be any standalone specific code*@
@content
}
}
</body>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment