Search in sources :

Example 1 with BreadcrumbDTO

use of org.broadleafcommerce.common.breadcrumbs.dto.BreadcrumbDTO in project BroadleafCommerce by BroadleafCommerce.

the class SimpleSearchBreadcrumbServiceExtensionHandler method modifyBreadcrumbList.

@Override
public ExtensionResultStatusType modifyBreadcrumbList(String url, Map<String, String[]> params, ExtensionResultHolder<List<BreadcrumbDTO>> holder) {
    String keyword = getSearchKeyword(url, params);
    url = getBreadcrumbUrl(url, holder);
    params = getBreadcrumbParams(params, holder);
    if (!StringUtils.isEmpty(keyword)) {
        BreadcrumbDTO searchDto = new BreadcrumbDTO();
        searchDto.setText(keyword);
        searchDto.setLink(buildLink(url, params));
        searchDto.setType(BreadcrumbDTOType.SEARCH);
        holder.getResult().add(0, searchDto);
        updateContextMap(params, holder);
    }
    return ExtensionResultStatusType.HANDLED_CONTINUE;
}
Also used : BreadcrumbDTO(org.broadleafcommerce.common.breadcrumbs.dto.BreadcrumbDTO)

Example 2 with BreadcrumbDTO

use of org.broadleafcommerce.common.breadcrumbs.dto.BreadcrumbDTO in project BroadleafCommerce by BroadleafCommerce.

the class HomePageBreadcrumbServiceExtensionHandler method modifyBreadcrumbList.

@Override
public ExtensionResultStatusType modifyBreadcrumbList(String url, Map<String, String[]> params, ExtensionResultHolder<List<BreadcrumbDTO>> holder) {
    BreadcrumbDTO homePageDto = new BreadcrumbDTO();
    homePageDto.setText(homePageText);
    homePageDto.setLink("/");
    homePageDto.setType(BreadcrumbDTOType.HOME);
    holder.getResult().add(0, homePageDto);
    return ExtensionResultStatusType.HANDLED_CONTINUE;
}
Also used : BreadcrumbDTO(org.broadleafcommerce.common.breadcrumbs.dto.BreadcrumbDTO)

Example 3 with BreadcrumbDTO

use of org.broadleafcommerce.common.breadcrumbs.dto.BreadcrumbDTO in project BroadleafCommerce by BroadleafCommerce.

the class ProductBreadcrumbServiceExtensionHandler method modifyBreadcrumbList.

public ExtensionResultStatusType modifyBreadcrumbList(String url, Map<String, String[]> params, ExtensionResultHolder<List<BreadcrumbDTO>> holder) {
    Product product = determineProduct(url, params, holder);
    if (product != null) {
        BreadcrumbDTO productDto = new BreadcrumbDTO();
        productDto.setText(getNameForProductLink(product));
        productDto.setLink(buildLink(url, params));
        productDto.setType(BreadcrumbDTOType.PRODUCT);
        holder.getResult().add(0, productDto);
    }
    updateContextMap(url, params, holder);
    return ExtensionResultStatusType.HANDLED_CONTINUE;
}
Also used : BreadcrumbDTO(org.broadleafcommerce.common.breadcrumbs.dto.BreadcrumbDTO) Product(org.broadleafcommerce.core.catalog.domain.Product)

Example 4 with BreadcrumbDTO

use of org.broadleafcommerce.common.breadcrumbs.dto.BreadcrumbDTO in project BroadleafCommerce by BroadleafCommerce.

the class CategoryBreadcrumbServiceExtensionHandler method addParentCrumbs.

/**
 * Add the parent crumb for the passed in category.
 * Recursively call to find all parents.
 *
 * @param parentCrumbs
 * @param category
 * @param url
 * @param params
 */
protected void addParentCrumbs(List<BreadcrumbDTO> parentCrumbs, Category category, String url, Map<String, String[]> params) {
    Category parentCategory = category.getParentCategory();
    if (parentCategory != null && !parentCrumbs.contains(parentCategory)) {
        // prevent recursion
        BreadcrumbDTO dto = buildCrumbForCategory(parentCategory, url, params);
        parentCrumbs.add(0, dto);
        addParentCrumbs(parentCrumbs, parentCategory, url, params);
    }
}
Also used : BreadcrumbDTO(org.broadleafcommerce.common.breadcrumbs.dto.BreadcrumbDTO) Category(org.broadleafcommerce.core.catalog.domain.Category)

Example 5 with BreadcrumbDTO

use of org.broadleafcommerce.common.breadcrumbs.dto.BreadcrumbDTO in project BroadleafCommerce by BroadleafCommerce.

the class CategoryBreadcrumbServiceExtensionHandler method buildCrumbForCategory.

protected BreadcrumbDTO buildCrumbForCategory(Category category, String url, Map<String, String[]> params) {
    BreadcrumbDTO categoryDto = null;
    if (category != null) {
        categoryDto = new BreadcrumbDTO();
        categoryDto.setText(getNameForCategoryLink(category));
        categoryDto.setLink(category.getUrl());
        categoryDto.setType(BreadcrumbDTOType.CATEGORY);
    }
    return categoryDto;
}
Also used : BreadcrumbDTO(org.broadleafcommerce.common.breadcrumbs.dto.BreadcrumbDTO)

Aggregations

BreadcrumbDTO (org.broadleafcommerce.common.breadcrumbs.dto.BreadcrumbDTO)7 Category (org.broadleafcommerce.core.catalog.domain.Category)2 ArrayList (java.util.ArrayList)1 Product (org.broadleafcommerce.core.catalog.domain.Product)1 JSONArray (org.codehaus.jettison.json.JSONArray)1 JSONObject (org.codehaus.jettison.json.JSONObject)1