/** * Returns a String which holds the selected categories for the result page of the new documents * query. * * <p> * * @param cms the CmsObject * @param request the HttpServletRequest * @param messageAll the localized message String used when all categories were selected * @return String with comma separated selected categories or localized "all" message */ public static String getCategories(CmsObject cms, HttpServletRequest request, String messageAll) { StringBuffer retValue = new StringBuffer(128); // get the current user's HHTP session // HttpSession session = // ((HttpServletRequest)cms.getRequestContext().getRequest().getOriginalRequest()).getSession(); HttpSession session = request.getSession(); // get the required parameters String paramAll = (String) session.getAttribute(C_DOCUMENT_SEARCH_PARAM_ALL); if ("true".equals(paramAll)) { return messageAll; } else { List<String> categories = getCategoryList((String) session.getAttribute(C_DOCUMENT_SEARCH_PARAM_CATEGORYLIST)); Iterator<String> i = categories.iterator(); while (i.hasNext()) { String path = i.next(); try { retValue.append( cms.readPropertyObject(path, CmsCategory.CATEGORY_TITLE, false).getValue()); } catch (CmsException e) { // noop } if (i.hasNext()) { retValue.append(", "); } } // clear objects to release memory categories = null; i = null; } return retValue.toString(); }
/** * Fills a single item. * * <p> * * @param resource the corresponding resource. * @param item the item to fill. * @param id used for the ID column. */ @SuppressWarnings("unchecked") private void fillItem(final CmsResource resource, final CmsListItem item, final int id) { CmsObject cms = this.getCms(); CmsXmlContent xmlContent; I_CmsResourceType type; String iconPath; // fill path column: String sitePath = cms.getSitePath(resource); item.set(LIST_COLUMN_PATH, sitePath); // fill language node existence column: item.set(LIST_COLUMN_PATH, sitePath); boolean languageNodeExists = false; String languageNodeHtml; List<Locale> sysLocales = OpenCms.getLocaleManager().getAvailableLocales(); try { xmlContent = CmsXmlContentFactory.unmarshal(cms, cms.readFile(resource)); for (Locale locale : sysLocales) { languageNodeExists = xmlContent.hasLocale(locale); if (languageNodeExists) { languageNodeHtml = "<input type=\"checkbox\" checked=\"checked\" disabled=\"disabled\"/>"; } else { languageNodeHtml = "<input type=\"checkbox\" disabled=\"disabled\"/>"; } item.set(locale.toString(), languageNodeHtml); } } catch (Throwable e1) { LOG.error( Messages.get().getBundle().key(Messages.LOG_ERR_LANGUAGECOPY_DETERMINE_LANGUAGE_NODE_1), e1); languageNodeHtml = "n/a"; for (Locale locale : sysLocales) { item.set(locale.toString(), languageNodeHtml); } } // type column: type = OpenCms.getResourceManager().getResourceType(resource); item.set(LIST_COLUMN_RESOURCETYPE, type.getTypeName()); // icon column with title property for tooltip: String title = ""; try { CmsProperty titleProperty = cms.readPropertyObject(resource, CmsPropertyDefinition.PROPERTY_TITLE, true); title = titleProperty.getValue(); } catch (CmsException e) { LOG.warn(Messages.get().getBundle().key(Messages.LOG_WARN_LANGUAGECOPY_READPROP_1), e); } iconPath = getSkinUri() + CmsWorkplace.RES_PATH_FILETYPES + OpenCms.getWorkplaceManager().getExplorerTypeSetting(type.getTypeName()).getIcon(); String iconImage; iconImage = "<img src=\"" + iconPath + "\" alt=\"" + type.getTypeName() + "\" title=\"" + title + "\" />"; item.set(LIST_COLUMN_ICON, iconImage); }