diff --git a/ccm-cms/src/main/java/org/librecms/pages/CmsPageRenderer.java b/ccm-cms/src/main/java/org/librecms/pages/CmsPageRenderer.java index 677422a65..5a73a92fa 100644 --- a/ccm-cms/src/main/java/org/librecms/pages/CmsPageRenderer.java +++ b/ccm-cms/src/main/java/org/librecms/pages/CmsPageRenderer.java @@ -18,6 +18,7 @@ */ package org.librecms.pages; +import org.libreccm.categorization.CategoryManager; import org.libreccm.pagemodel.AbstractPageRenderer; import org.libreccm.pagemodel.PageRenderer; @@ -25,10 +26,11 @@ import java.util.HashMap; import java.util.Map; import javax.enterprise.context.RequestScoped; +import javax.inject.Inject; /** * Implementation of {@link PageRenderer} for CMS pages. - * + * * @author Jens Pelzetter */ @RequestScoped @@ -36,7 +38,7 @@ public class CmsPageRenderer extends AbstractPageRenderer { @Override public Map renderPage(final Map parameters) { - + final Map result = new HashMap<>(); result.put("application", Pages.class.getName()); if (parameters.containsKey(PagesRouter.SITE_INFO)) { @@ -44,10 +46,8 @@ public class CmsPageRenderer extends AbstractPageRenderer { PagesRouter.SITE_INFO, parameters.get(PagesRouter.SITE_INFO) ); } + return result; - } - - - + } diff --git a/ccm-cms/src/main/resources/themes/freemarker/ccm-cms/pages.ftl b/ccm-cms/src/main/resources/themes/freemarker/ccm-cms/pages.ftl new file mode 100644 index 000000000..7269754ac --- /dev/null +++ b/ccm-cms/src/main/resources/themes/freemarker/ccm-cms/pages.ftl @@ -0,0 +1,150 @@ +<#--filedoc + Functions for processing the data provided by the pages application +--> + +<#--doc + Alias for getPathPath +--> +<#function getCategoryPath> + <#return getPagePath()> + + +<#-- + Gets the path of the current page. + + @return A list of names (URL stubs/slugs) of all categories in the + path of the current page. +--> +<#function getPagePath> + <#return pagePath> + + +<#--doc + Determines if the current page is the root page of a navigation. + + @return `true` if teh current page is a root page, `false` otherwise. +--> +<#function isRootPage> + <#return getPagePath()?size <= 0> + + +<#--doc + Gets the currently selected category. + + @return The currently selected category. +--> +<#function getSelectedCategory> + <#return getPathPath()?last> + + +<#--doc + Gets the ID of the currently selected category. + + @return The ID of the currently selected category. +--> +<#function getSelectedCategoryId> + <#return getSelectedCategory().categoryId> + + +<#--doc + Get the title of the provided category. + + @param The model of a category as returned by several functions in this + library. + + @return The title of the category. +--> +<#function getCategoryTitle category> + <#return category.title> + + +<#-- + Get the ID get the provided category. + + @param The model of a category as returned by several functions in this + library. + + @return The ID of the provided category. +--> +<#function getCategoryId category> + <#return category.categoryId> + + +<#--doc + Determines of the provided category is selected. + + @param The model of a category as returned by several functions in this + library. + + @return `true` if the category is selected, `false` if not. +--> +<#function isCategorySelected category> + <#return category.isSelected> + + +<#--doc + Get the URL of the root category of the navigation with the provided id. + + @param navigationId The ID of the navigation system to use. + + @return The URL of the root category of the navigation system with the + provided ID. +--> +<#function getNavigationRootUrl navigationId="categoryMenu"> + <#return [navigationId].url> + + +<#--doc + Get title of the navigation with the provided id. + + @param navigationId The ID of the navigation system to use. + + @return The title of the navigation. +--> +<#function getNavigationTitle navigationId="categoryMenu"> + <#return [navigationId].categoryTitle> + + +<#--doc + Retrieves the first level of categories from the category hierachy with the + provided ID. If no id is provided 'categoryNav' is used. + + @param hierarchyId The ID of the category hierachy to use. + + @return The first level of categories in the hierarchy. +--> +<#function getCategoryHierarchy hierarchyId="categoryNav"> + <#return [hierarchyId].subCategories> + + +<#--doc + Gets the subcategories of the provided category. + + @param ofCategory The model of the category. + + @return The sub categories of the provided category. +--> +<#function getSubCategories ofCategory> + <#return ofCategory.subcategories> + + +<#--doc + Gets the subcategories of the category with the provided id. + + @param categoryId The ID of the category to use. + + @return The sub categories of the category with the provided ID. +--> +<#function getSubCategoriesOfCategoryWithId categoryId> + <#return model["/bebop:page/nav:categoryMenu//nav:category[@id=${categoryId}]/nav:category"]> + + +<#--doc + Gets the greeting/index item of the current navigation page. The returned + model can be processed with usual functions for processing content items. + + @return The model of the index item. +--> +<#function getGreetingItem path="greetingItem"> + <#return eval(path)> + \ No newline at end of file diff --git a/ccm-cms/src/main/resources/themes/freemarker/ccm-navigation/navigation.ftl b/ccm-cms/src/main/resources/themes/freemarker/ccm-navigation/navigation.ftl new file mode 100644 index 000000000..8502571d9 --- /dev/null +++ b/ccm-cms/src/main/resources/themes/freemarker/ccm-navigation/navigation.ftl @@ -0,0 +1,171 @@ +<#-- + @depcrecated Use ccm-cms/pages.ftl + The functions in this libary call the functions with the same + names from ccm-cms/pages.ftl. This library will removed in a future + release. +--> + +<#import "/ccm-cms/pages.ftl" as Pages> + +<#--doc + Get all categories from the category path. + + @return All categories in the current category path. +--> +<#function getCategoryPath> + <#return Pages.getCategoryPath()> + + +<#--doc + Determines if the current page is the root page of a navigation. + + @return `true` if teh current page is a root page, `false` otherwise. +--> +<#function isRootPage> + <#return Pages.isRootPage()> + + +<#--doc + Gets the currently selected category. + + @return The currently selected category. +--> +<#function getSelectedCategory> + <#return Pages.getSelectedCategory()> + + +<#--doc + Gets the ID of the currently selected category. + + @return The ID of the currently selected category. +--> +<#function getSelectedCategoryId> + <#return Pages.getSelectedCategoryId()> + + +<#--doc + Get the title of the provided category. + + @param The model of a category as returned by several functions in this + library. + + @return The title of the category. +--> +<#function getCategoryTitle category> + <#return Pages.getCategoryTitle(category)> + + +<#-- + Get the URL of the provided category. + + @param The model of a category as returned by several functions in this + library. + + @return The URL of the category. +--> +<#function getCategoryUrl category> + <#return Pages.getCategoryUrl(category)> + + +<#-- + Get the ID get the provided category. + + @param The model of a category as returned by several functions in this + library. + + @return The ID of the provided category. +--> +<#function getCategoryId category> + <#return Pages.getCategoryId(category)> + + +<#--doc + Determines of the provided category is selected. + + @param The model of a category as returned by several functions in this + library. + + @return `true` if the category is selected, `false` if not. +--> +<#function isCategorySelected category> + <#return Pages.isCategorySelected(category)> + + +<#--doc + Get the URL of the root category of the navigation with the provided id. + + @param navigationId The ID of the navigation system to use. + + @return The URL of the root category of the navigation system with the + provided ID. +--> +<#function getNavigationRootUrl navigationId="categoryMenu"> + <#return Pages.getNavigationRootUrl(navigationId)> + + +<#--doc + Get title of the navigation with the provided id. + + @param navigationId The ID of the navigation system to use. + + @return The title of the navigation. +--> +<#function getNavigationTitle navigationId="categoryMenu"> + <#return Pages.getNavigationTitle(navigationId)> + + +<#--doc + Retrieves the first level of categories from the category menu with the provided ID. + If no id is provided "categoryMenu" is used. + + @param menuId The ID of the category menu to use. + + @return The first level of categories in the menu. +--> +<#function getCategoryMenu menuId="categoryMenu"> + <#return Pages.getCategoryMenu(menuId)> + + +<#--doc + Retrieves the first level of categories from the category hierachy with the + provided ID. If no id is provided 'categoryNav' is used. + + @param hierarchyId The ID of the category hierachy to use. + + @return The first level of categories in the hierarchy. +--> +<#function getCategoryHierarchy hierarchyId="categoryNav"> + <#return Pages.getCategoryHierarchy(hierarchyId)> + + +<#--doc + Gets the subcategories of the provided category. + + @param ofCategory The model of the category. + + @return The sub categories of the provided category. +--> +<#function getSubCategories ofCategory> + <#return Pages.getSubCategories(ofCategory)> + + +<#--doc + Gets the subcategories of the category with the provided id. + + @param categoryId The ID of the category to use. + + @return The sub categories of the category with the provided ID. +--> +<#function getSubCategoriesOfCategoryWithId categoryId> + <#return Pages.getSubCategoriesOfCategoryWithId(categoryId)> + + +<#--doc + Gets the greeting/index item of the current navigation page. The returned + model can be processed with usual functions for processing content items. + + @return The model of the index item. +--> +<#function getGreetingItem> + <#return Pages.getGreetingItem()> + \ No newline at end of file diff --git a/ccm-core/src/main/java/org/libreccm/categorization/CategoryManager.java b/ccm-core/src/main/java/org/libreccm/categorization/CategoryManager.java index 64ab260ec..7a3080234 100644 --- a/ccm-core/src/main/java/org/libreccm/categorization/CategoryManager.java +++ b/ccm-core/src/main/java/org/libreccm/categorization/CategoryManager.java @@ -886,7 +886,7 @@ public class CategoryManager implements Serializable { "No category with ID %d in the database. Where did that ID come from?", category.getObjectId()))); while (current.getParentCategory() != null) { - tokens.add(current.getDisplayName()); + tokens.add(current.getName()); current = current.getParentCategory(); }