if (child instanceof VFSLeaf) {
leaf = (VFSLeaf)child;
}
boolean isContainer = (leaf == null); // if not a leaf, it must be a container...
MetaInfo metaInfo = null;
if(child instanceof OlatRelPathImpl) {
metaInfo = MetaInfoFactory.createMetaInfoFor((OlatRelPathImpl)child);
}
boolean lockedForUser = MetaInfoHelper.isLocked(metaInfo, fc.getIdentityEnvironnement());
String name = child.getName();
String pathAndName = currentContainerPath;
if (pathAndName.length() > 0 && !pathAndName.endsWith("/"))
pathAndName = pathAndName + "/";
pathAndName = pathAndName + name;
String type = FolderHelper.extractFileType(child.getName(), translator.getLocale());
// tr begin, set alternating bgcolor
sb.append("<tr");
bgFlag = !bgFlag;
if (bgFlag) { sb.append(" class=\"b_table_odd\""); }
sb.append("><td class=\"b_first_child\">");
// add checkbox for actions if user can write or delete to this directory
if (canWrite || canDelete) {
sb.append("<input type=\"checkbox\" class=\"b_checkbox\" name=\"");
sb.append(FileSelection.FORM_ID);
sb.append("\" value=\"");
sb.append(StringEscapeUtils.escapeHtml(name));
sb.append("\" />");
}
// browse link pre
sb.append("<a href=\"");
if (isContainer) { // for directories... normal module URIs
ubu.buildURI(sb, null, null, pathAndName, iframePostEnabled ? AJAXFlags.MODE_TOBGIFRAME : AJAXFlags.MODE_NORMAL);
sb.append("\"");
if (iframePostEnabled) { // add ajax iframe target
StringOutput so = new StringOutput();
ubu.appendTarget(so);
sb.append(so.toString());
}
} else { // for files, add PARAM_SERV command
ubu.buildURI(sb, new String[] { PARAM_SERV }, new String[] { "x" }, pathAndName, AJAXFlags.MODE_NORMAL);
sb.append("\" target=\"_blank\"");
}
// icon css
sb.append(" class=\"b_with_small_icon_left ");
if (isContainer) sb.append(CSSHelper.CSS_CLASS_FILETYPE_FOLDER);
else sb.append(CSSHelper.createFiletypeIconCssClassFor(name));
sb.append("\"");
// file metadata
if (metaInfo != null) {
sb.append(" ext:qtip=\"<div class='b_ext_tooltip_wrapper b_briefcase_meta'>");
if (StringHelper.containsNonWhitespace(metaInfo.getTitle())) {
sb.append("<h5>").append(Formatter.escapeDoubleQuotes(metaInfo.getTitle())).append("</h5>");
}
if (StringHelper.containsNonWhitespace(metaInfo.getComment())) {
sb.append(Formatter.escapeDoubleQuotes(metaInfo.getComment()));
}
String author = metaInfo.getAuthor();
if (StringHelper.containsNonWhitespace(author)) {
sb.append("<p>").append(Formatter.escapeDoubleQuotes(translator.translate("mf.author")));
sb.append(": ").append(Formatter.escapeDoubleQuotes(author)).append("</p>");
}
sb.append("</div>\"");
}
sb.append(">");
// name
if (isAbstract) sb.append("<i>");
sb.append(name);
if (isAbstract) sb.append("</i>");
sb.append("</a></td><td>");
// filesize
if (!isContainer) {
// append filesize
sb.append(StringHelper.formatMemory(leaf.getSize()));
}
sb.append("</td><td>");
// type
if (isContainer) {
sb.append(translator.translate("Directory"));
}
else {
if (type.equals(TYPE_FILE)) {
sb.append(translator.translate("UnknownFile"));
}
else {
sb.append(type.toUpperCase());
sb.append(" ").append(translator.translate(TYPE_FILE));
}
}
sb.append("</td><td>");
if(canContainerVersion) {
if (canVersion)
sb.append(versions.getRevisionNr());
sb.append("</td><td>");
}
// last modified
long lastModified = child.getLastModified();
if (lastModified != VFSConstants.UNDEFINED)
sb.append(DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, translator.getLocale()).format(new Date(lastModified)));
else
sb.append("-");
sb.append("</td><td>");
//locked
if(metaInfo != null) {
if(metaInfo.isLocked()) {
Identity lockedBy = identityMap.get(metaInfo.getLockedBy());
if(lockedBy == null) {
lockedBy = metaInfo.getLockedByIdentity();
if(lockedBy != null) {
identityMap.put(lockedBy.getKey(), lockedBy);
}
}
sb.append("<span class=\"b_small_icon b_briefcase_locked_file_icon\" ext:qtip=\"");
if(lockedBy != null) {
String firstName = lockedBy.getUser().getProperty(UserConstants.FIRSTNAME, translator.getLocale());
String lastName = lockedBy.getUser().getProperty(UserConstants.LASTNAME, translator.getLocale());
String date = "";
if(metaInfo.getLockedDate() != null) {
date = fc.getDateTimeFormat().format(metaInfo.getLockedDate());
}
sb.append(translator.translate("Locked", new String[]{firstName, lastName, date}));
}
sb.append("\"> </span>");
}