<% /** * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ %> <% ShoppingCategory category = (ShoppingCategory)request.getAttribute(WebKeys.SHOPPING_CATEGORY); long categoryId = BeanParamUtil.getLong(category, request, "categoryId", ShoppingCategoryImpl.DEFAULT_PARENT_CATEGORY_ID); PortletURL portletURL = renderResponse.createRenderURL(); portletURL.setWindowState(WindowState.MAXIMIZED); portletURL.setParameter("struts_action", "/shopping/view"); portletURL.setParameter("tabs1", tabs1); portletURL.setParameter("categoryId", String.valueOf(categoryId)); %>
<% List headerNames = new ArrayList(); headerNames.add("category"); headerNames.add("num-of-categories"); headerNames.add("num-of-items"); headerNames.add(StringPool.BLANK); SearchContainer searchContainer = new SearchContainer(renderRequest, null, null, "cur1", SearchContainer.DEFAULT_DELTA, portletURL, headerNames, null); int total = ShoppingCategoryLocalServiceUtil.getCategoriesCount(scopeGroupId, categoryId); searchContainer.setTotal(total); List results = ShoppingCategoryLocalServiceUtil.getCategories(scopeGroupId, categoryId, searchContainer.getStart(), searchContainer.getEnd()); searchContainer.setResults(results); List resultRows = searchContainer.getResultRows(); for (int i = 0; i < results.size(); i++) { ShoppingCategory curCategory = (ShoppingCategory)results.get(i); curCategory = curCategory.toEscapedModel(); ResultRow row = new ResultRow(curCategory, curCategory.getCategoryId(), i); PortletURL rowURL = renderResponse.createRenderURL(); rowURL.setWindowState(WindowState.MAXIMIZED); rowURL.setParameter("struts_action", "/shopping/view"); rowURL.setParameter("categoryId", String.valueOf(curCategory.getCategoryId())); // Name and description StringBuilder sb = new StringBuilder(); sb.append(curCategory.getName()); if (Validator.isNotNull(curCategory.getDescription())) { sb.append("
"); sb.append(curCategory.getDescription()); } row.addText(sb.toString(), rowURL); // Statistics List subcategoryIds = new ArrayList(); subcategoryIds.add(new Long(curCategory.getCategoryId())); ShoppingCategoryLocalServiceUtil.getSubcategoryIds(subcategoryIds, scopeGroupId, curCategory.getCategoryId()); int categoriesCount = subcategoryIds.size() - 1; int itemsCount = ShoppingItemLocalServiceUtil.getCategoriesItemsCount(subcategoryIds); row.addText(String.valueOf(categoriesCount), rowURL); row.addText(String.valueOf(itemsCount), rowURL); // Action row.addJSP("right", SearchEntry.DEFAULT_VALIGN, "/html/portlet/shopping/category_action.jsp"); // Add result row resultRows.add(row); } boolean showAddCategoryButton = ShoppingCategoryPermission.contains(permissionChecker, scopeGroupId, categoryId, ActionKeys.ADD_CATEGORY); boolean showPermissionsButton = GroupPermissionUtil.contains(permissionChecker, scopeGroupId, ActionKeys.PERMISSIONS); boolean showSearch = (results.size() > 0); %>
" /> ' />" onClick="location.href = '';" /> <% String modelResource = "com.liferay.portlet.shopping"; String modelResourceDescription = themeDisplay.getScopeGroupName(); String resourcePrimKey = String.valueOf(scopeGroupId); if (category != null) { modelResource = ShoppingCategory.class.getName(); modelResourceDescription = category.getName(); resourcePrimKey = String.valueOf(category.getCategoryId()); } %> " onClick="location.href = '<%= permissionsURL %>';" />


<% String orderByCol = ParamUtil.getString(request, "orderByCol"); String orderByType = ParamUtil.getString(request, "orderByType"); if (Validator.isNotNull(orderByCol) && Validator.isNotNull(orderByType)) { portalPrefs.setValue(PortletKeys.SHOPPING, "items-order-by-col", orderByCol); portalPrefs.setValue(PortletKeys.SHOPPING, "items-order-by-type", orderByType); } else { orderByCol = portalPrefs.getValue(PortletKeys.SHOPPING, "items-order-by-col", "sku"); orderByType = portalPrefs.getValue(PortletKeys.SHOPPING, "items-order-by-type", "asc"); } OrderByComparator orderByComparator = ShoppingUtil.getItemOrderByComparator(orderByCol, orderByType); headerNames.clear(); headerNames.add("sku"); headerNames.add("description"); headerNames.add("min-qty"); headerNames.add("price"); headerNames.add(StringPool.BLANK); Map orderableHeaders = new HashMap(); orderableHeaders.put("sku", "sku"); orderableHeaders.put("description", "name"); orderableHeaders.put("min-qty", "min-qty"); orderableHeaders.put("price", "price"); searchContainer = new SearchContainer(renderRequest, null, null, "cur2", SearchContainer.DEFAULT_DELTA, portletURL, headerNames, null); searchContainer.setOrderableHeaders(orderableHeaders); searchContainer.setOrderByCol(orderByCol); searchContainer.setOrderByType(orderByType); total = ShoppingItemLocalServiceUtil.getItemsCount(categoryId); searchContainer.setTotal(total); results = ShoppingItemLocalServiceUtil.getItems(categoryId, searchContainer.getStart(), searchContainer.getEnd(), orderByComparator); searchContainer.setResults(results); resultRows = searchContainer.getResultRows(); for (int i = 0; i < results.size(); i++) { ShoppingItem item = (ShoppingItem)results.get(i); item = item.toEscapedModel(); ResultRow row = new ResultRow(item, item.getItemId(), i); PortletURL rowURL = renderResponse.createRenderURL(); rowURL.setWindowState(WindowState.MAXIMIZED); rowURL.setParameter("struts_action", "/shopping/view_item"); rowURL.setParameter("redirect", currentURL); rowURL.setParameter("itemId", String.valueOf(item.getItemId())); // SKU and small image StringBuilder sb = new StringBuilder(); if (item.isSmallImage()) { sb.append("
"); sb.append("\"");"); } else { sb.append(item.getSku()); } row.addText(sb.toString(), rowURL); // Description sb = new StringBuilder(); sb.append(item.getName()); if (Validator.isNotNull(item.getDescription())) { sb.append("
"); sb.append(item.getDescription()); } Properties props = new OrderedProperties(); PropertiesUtil.load(props, item.getProperties()); Enumeration enu = props.propertyNames(); while (enu.hasMoreElements()) { String propsKey = (String)enu.nextElement(); String propsValue = props.getProperty(propsKey, StringPool.BLANK); sb.append("
"); sb.append(propsKey); sb.append(": "); sb.append(propsValue); } row.addText(sb.toString(), rowURL); // Minimum quantity row.addText(String.valueOf(item.getMinQuantity()), rowURL); // Price if (item.getDiscount() <= 0) { row.addText(currencyFormat.format(item.getPrice()), rowURL); } else { row.addText( "" + currencyFormat.format(ShoppingUtil.calculateActualPrice(item)) + "", rowURL); } // Action row.addJSP("right", SearchEntry.DEFAULT_VALIGN, "/html/portlet/shopping/item_action.jsp"); // Add result row resultRows.add(row); } boolean showAddItemButton = ShoppingCategoryPermission.contains(permissionChecker, category, ActionKeys.ADD_ITEM); showSearch = results.size() > 0; %>
" /> " onClick="location.href = '';" /> " onClick="location.href = '';" />