parent
3f0d821a59
commit
b492da18bc
|
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.librecms.pages;
|
package org.librecms.pages;
|
||||||
|
|
||||||
|
import org.libreccm.categorization.CategoryManager;
|
||||||
import org.libreccm.pagemodel.AbstractPageRenderer;
|
import org.libreccm.pagemodel.AbstractPageRenderer;
|
||||||
import org.libreccm.pagemodel.PageRenderer;
|
import org.libreccm.pagemodel.PageRenderer;
|
||||||
|
|
||||||
|
|
@ -25,10 +26,11 @@ import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.enterprise.context.RequestScoped;
|
import javax.enterprise.context.RequestScoped;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of {@link PageRenderer} for CMS pages.
|
* Implementation of {@link PageRenderer} for CMS pages.
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
*/
|
*/
|
||||||
@RequestScoped
|
@RequestScoped
|
||||||
|
|
@ -36,7 +38,7 @@ public class CmsPageRenderer extends AbstractPageRenderer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> renderPage(final Map<String, Object> parameters) {
|
public Map<String, Object> renderPage(final Map<String, Object> parameters) {
|
||||||
|
|
||||||
final Map<String, Object> result = new HashMap<>();
|
final Map<String, Object> result = new HashMap<>();
|
||||||
result.put("application", Pages.class.getName());
|
result.put("application", Pages.class.getName());
|
||||||
if (parameters.containsKey(PagesRouter.SITE_INFO)) {
|
if (parameters.containsKey(PagesRouter.SITE_INFO)) {
|
||||||
|
|
@ -44,10 +46,8 @@ public class CmsPageRenderer extends AbstractPageRenderer {
|
||||||
PagesRouter.SITE_INFO, parameters.get(PagesRouter.SITE_INFO)
|
PagesRouter.SITE_INFO, parameters.get(PagesRouter.SITE_INFO)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,150 @@
|
||||||
|
<#--filedoc
|
||||||
|
Functions for processing the data provided by the pages application
|
||||||
|
-->
|
||||||
|
|
||||||
|
<#--doc
|
||||||
|
Alias for getPathPath
|
||||||
|
-->
|
||||||
|
<#function getCategoryPath>
|
||||||
|
<#return getPagePath()>
|
||||||
|
</#function>
|
||||||
|
|
||||||
|
<#--
|
||||||
|
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>
|
||||||
|
</#function>
|
||||||
|
|
||||||
|
<#--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>
|
||||||
|
</#function>
|
||||||
|
|
||||||
|
<#--doc
|
||||||
|
Gets the currently selected category.
|
||||||
|
|
||||||
|
@return The currently selected category.
|
||||||
|
-->
|
||||||
|
<#function getSelectedCategory>
|
||||||
|
<#return getPathPath()?last>
|
||||||
|
</#function>
|
||||||
|
|
||||||
|
<#--doc
|
||||||
|
Gets the ID of the currently selected category.
|
||||||
|
|
||||||
|
@return The ID of the currently selected category.
|
||||||
|
-->
|
||||||
|
<#function getSelectedCategoryId>
|
||||||
|
<#return getSelectedCategory().categoryId>
|
||||||
|
</#function>
|
||||||
|
|
||||||
|
<#--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>
|
||||||
|
</#function>
|
||||||
|
|
||||||
|
<#--
|
||||||
|
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>
|
||||||
|
</#function>
|
||||||
|
|
||||||
|
<#--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>
|
||||||
|
</#function>
|
||||||
|
|
||||||
|
<#--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>
|
||||||
|
</#function>
|
||||||
|
|
||||||
|
<#--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>
|
||||||
|
</#function>
|
||||||
|
|
||||||
|
<#--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>
|
||||||
|
</#function>
|
||||||
|
|
||||||
|
<#--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>
|
||||||
|
</#function>
|
||||||
|
|
||||||
|
<#--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"]>
|
||||||
|
</#function>
|
||||||
|
|
||||||
|
<#--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)>
|
||||||
|
</#function>
|
||||||
|
|
@ -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()>
|
||||||
|
</#function>
|
||||||
|
|
||||||
|
<#--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()>
|
||||||
|
</#function>
|
||||||
|
|
||||||
|
<#--doc
|
||||||
|
Gets the currently selected category.
|
||||||
|
|
||||||
|
@return The currently selected category.
|
||||||
|
-->
|
||||||
|
<#function getSelectedCategory>
|
||||||
|
<#return Pages.getSelectedCategory()>
|
||||||
|
</#function>
|
||||||
|
|
||||||
|
<#--doc
|
||||||
|
Gets the ID of the currently selected category.
|
||||||
|
|
||||||
|
@return The ID of the currently selected category.
|
||||||
|
-->
|
||||||
|
<#function getSelectedCategoryId>
|
||||||
|
<#return Pages.getSelectedCategoryId()>
|
||||||
|
</#function>
|
||||||
|
|
||||||
|
<#--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)>
|
||||||
|
</#function>
|
||||||
|
|
||||||
|
<#--
|
||||||
|
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)>
|
||||||
|
</#function>
|
||||||
|
|
||||||
|
<#--
|
||||||
|
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)>
|
||||||
|
</#function>
|
||||||
|
|
||||||
|
<#--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)>
|
||||||
|
</#function>
|
||||||
|
|
||||||
|
<#--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)>
|
||||||
|
</#function>
|
||||||
|
|
||||||
|
<#--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)>
|
||||||
|
</#function>
|
||||||
|
|
||||||
|
<#--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)>
|
||||||
|
</#function>
|
||||||
|
|
||||||
|
<#--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)>
|
||||||
|
</#function>
|
||||||
|
|
||||||
|
<#--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)>
|
||||||
|
</#function>
|
||||||
|
|
||||||
|
<#--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)>
|
||||||
|
</#function>
|
||||||
|
|
||||||
|
<#--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()>
|
||||||
|
</#function>
|
||||||
|
|
@ -886,7 +886,7 @@ public class CategoryManager implements Serializable {
|
||||||
"No category with ID %d in the database. Where did that ID come from?",
|
"No category with ID %d in the database. Where did that ID come from?",
|
||||||
category.getObjectId())));
|
category.getObjectId())));
|
||||||
while (current.getParentCategory() != null) {
|
while (current.getParentCategory() != null) {
|
||||||
tokens.add(current.getDisplayName());
|
tokens.add(current.getName());
|
||||||
current = current.getParentCategory();
|
current = current.getParentCategory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue