use of org.olat.core.gui.components.form.flexible.impl.NameValuePair in project OpenOLAT by OpenOLAT.
the class ListRenderer method render.
/**
* Render contents of directory to a html table.
*
* @param dir
* @param secCallback
* @param ubu
* @param translator
* @param iframePostEnabled
* @return Render results.
*/
public void render(FolderComponent fc, StringOutput sb, URLBuilder ubu, Translator translator, boolean iframePostEnabled) {
if (lockManager == null) {
lockManager = CoreSpringFactory.getImpl(VFSLockManager.class);
}
if (userManager == null) {
userManager = CoreSpringFactory.getImpl(UserManager.class);
}
LicenseModule licenseModule = CoreSpringFactory.getImpl(LicenseModule.class);
LicenseHandler licenseHandler = CoreSpringFactory.getImpl(FolderLicenseHandler.class);
licensesEnabled = licenseModule.isEnabled(licenseHandler);
List<VFSItem> children = fc.getCurrentContainerChildren();
// folder empty?
if (children.size() == 0) {
sb.append("<div class=\"o_bc_empty\"><i class='o_icon o_icon_warn'></i> ").append(translator.translate("NoFiles")).append("</div>");
return;
}
boolean canVersion = FolderConfig.versionsEnabled(fc.getCurrentContainer());
String sortOrder = fc.getCurrentSortOrder();
boolean sortAsc = fc.isCurrentSortAsc();
String sortCss = (sortAsc ? "o_orderby_asc" : "o_orderby_desc");
sb.append("<table class=\"table table-condensed table-striped table-hover o_bc_table\">").append("<thead><tr><th><a class='o_orderby ").append(sortCss, FolderComponent.SORT_NAME.equals(sortOrder)).append("' ");
ubu.buildHrefAndOnclick(sb, null, iframePostEnabled, false, false, new NameValuePair(PARAM_SORTID, FolderComponent.SORT_NAME)).append(">").append(translator.translate("header.Name")).append("</a>").append("</th>");
sb.append("<th><a class='o_orderby ").append(sortCss, FolderComponent.SORT_SIZE.equals(sortOrder)).append("' ");
ubu.buildHrefAndOnclick(sb, null, iframePostEnabled, false, false, new NameValuePair(PARAM_SORTID, FolderComponent.SORT_SIZE)).append(">").append(translator.translate("header.Size")).append("</a>").append("</th><th><a class='o_orderby ").append(sortCss, FolderComponent.SORT_DATE.equals(sortOrder)).append("' ");
ubu.buildHrefAndOnclick(sb, null, iframePostEnabled, false, false, new NameValuePair(PARAM_SORTID, FolderComponent.SORT_DATE)).append(">").append(translator.translate("header.Modified")).append("</a>");
if (licensesEnabled) {
sb.append("<th>").append(translator.translate("header.license")).append("</th>");
}
if (canVersion) {
sb.append("</th><th><a class='o_orderby ").append(sortCss, FolderComponent.SORT_REV.equals(sortOrder)).append("' ");
// file size column
ubu.buildHrefAndOnclick(sb, null, iframePostEnabled, false, false, new NameValuePair(PARAM_SORTID, FolderComponent.SORT_REV)).append("><i class=\"o_icon o_icon_version o_icon-lg\" title=\"").append(translator.translate("versions")).append("\"></i></a>");
}
sb.append("</th><th><a class='o_orderby ").append(sortCss, FolderComponent.SORT_LOCK.equals(sortOrder)).append("' ");
ubu.buildHrefAndOnclick(sb, null, iframePostEnabled, false, false, new NameValuePair(PARAM_SORTID, FolderComponent.SORT_LOCK)).append("><i class=\"o_icon o_icon_locked o_icon-lg\" title=\"").append(translator.translate("lock.title")).append("\"></i></a>").append("</th><th><i class=\"o_icon o_icon_edit_metadata o_icon-lg\" title=\"").append(translator.translate("mf.edit")).append("\"></i></th></tr></thead>");
// render directory contents
String currentContainerPath = fc.getCurrentContainerPath();
if (currentContainerPath.length() > 0 && currentContainerPath.charAt(0) == '/') {
currentContainerPath = currentContainerPath.substring(1);
}
sb.append("<tbody>");
for (int i = 0; i < children.size(); i++) {
VFSItem child = children.get(i);
appendRenderedFile(fc, child, currentContainerPath, sb, ubu, translator, iframePostEnabled, canVersion, i);
}
sb.append("</tbody></table>");
}
use of org.olat.core.gui.components.form.flexible.impl.NameValuePair in project OpenOLAT by OpenOLAT.
the class ListRenderer method appendRenderedFile.
// getRenderedDirectoryContent
/**
* Render a single file or folder.
*
* @param f The file or folder to render
* @param sb StringOutput to append generated html code
*/
private void appendRenderedFile(FolderComponent fc, VFSItem child, String currentContainerPath, StringOutput sb, URLBuilder ubu, Translator translator, boolean iframePostEnabled, boolean canContainerVersion, int pos) {
// assume full access unless security callback tells us something different.
boolean canWrite = child.getParentContainer().canWrite() == VFSConstants.YES;
// special case: virtual folders are always read only. parent of child =! the current container
canWrite = canWrite && !(fc.getCurrentContainer() instanceof VirtualContainer);
boolean isAbstract = (child instanceof AbstractVirtualContainer);
Versions versions = null;
if (canContainerVersion && child instanceof Versionable) {
Versionable versionable = (Versionable) child;
if (versionable.getVersions().isVersioned()) {
versions = versionable.getVersions();
}
}
boolean canVersion = versions != null && !versions.getRevisions().isEmpty();
boolean canAddToEPortfolio = FolderConfig.isEPortfolioAddEnabled();
VFSLeaf leaf = null;
if (child instanceof VFSLeaf) {
leaf = (VFSLeaf) child;
}
// if not a leaf, it must be a container...
boolean isContainer = (leaf == null);
MetaInfo metaInfo = null;
if (child instanceof MetaTagged) {
metaInfo = ((MetaTagged) child).getMetaInfo();
}
boolean lockedForUser = lockManager.isLockedForMe(child, fc.getIdentityEnvironnement().getIdentity(), fc.getIdentityEnvironnement().getRoles());
String name = child.getName();
boolean xssErrors = StringHelper.xssScanForErrors(name);
String pathAndName;
if (xssErrors) {
pathAndName = null;
} else {
pathAndName = currentContainerPath;
if (pathAndName.length() > 0 && !pathAndName.endsWith("/")) {
pathAndName += "/";
}
pathAndName += name;
}
// tr begin
sb.append("<tr><td>").append("<input type=\"checkbox\" name=\"").append(FileSelection.FORM_ID).append("\" value=\"");
if (xssErrors) {
sb.append(StringHelper.escapeHtml(name)).append("\" disabled=\"disabled\"");
} else {
sb.append(name).append("\" ");
}
sb.append("/> ");
// browse link pre
if (xssErrors) {
sb.append("<i class='o_icon o_icon-fw o_icon_banned'> </i> ");
sb.append(StringHelper.escapeHtml(name));
log.error("XSS Scan found something suspicious in: " + child);
} else {
sb.append("<a id='o_sel_doc_").append(pos).append("'");
if (isContainer) {
// for directories... normal module URIs
// needs encoding, not done in buildHrefAndOnclick!
// FIXME: SR: refactor encode: move to ubu.buildHrefAndOnclick
String pathAndNameEncoded = ubu.encodeUrl(pathAndName);
ubu.buildHrefAndOnclick(sb, pathAndNameEncoded, iframePostEnabled, false, true);
} else {
// for files, add PARAM_SERV command
sb.append(" href=\"");
ubu.buildURI(sb, new String[] { PARAM_SERV }, new String[] { "x" }, pathAndName, AJAXFlags.MODE_NORMAL);
sb.append("\"");
boolean download = FolderManager.isDownloadForcedFileType(name);
if (download) {
sb.append(" download=\"").append(StringHelper.escapeHtml(name)).append("\"");
} else {
sb.append(" target=\"_blank\"");
}
}
sb.append(">");
// icon css
sb.append("<i class=\"o_icon o_icon-fw ");
if (isContainer)
sb.append(CSSHelper.CSS_CLASS_FILETYPE_FOLDER);
else
sb.append(CSSHelper.createFiletypeIconCssClassFor(name));
sb.append("\"></i> ");
// name
if (isAbstract)
sb.append("<i>");
sb.append(StringHelper.escapeHtml(name));
if (isAbstract)
sb.append("</i>");
sb.append("</a>");
}
// file metadata as tooltip
if (metaInfo != null) {
boolean hasMeta = false;
sb.append("<div id='o_sel_doc_tooltip_").append(pos).append("' class='o_bc_meta' style='display:none;'>");
if (StringHelper.containsNonWhitespace(metaInfo.getTitle())) {
String title = StringHelper.escapeHtml(metaInfo.getTitle());
sb.append("<h5>").append(Formatter.escapeDoubleQuotes(title)).append("</h5>");
hasMeta = true;
}
if (StringHelper.containsNonWhitespace(metaInfo.getComment())) {
sb.append("<div class=\"o_comment\">");
String comment = StringHelper.escapeHtml(metaInfo.getComment());
sb.append(Formatter.escapeDoubleQuotes(comment));
sb.append("</div>");
hasMeta = true;
}
// boolean hasThumbnail = false;
if (metaInfo.isThumbnailAvailable() && !xssErrors) {
sb.append("<div class='o_thumbnail' style='background-image:url(");
ubu.buildURI(sb, new String[] { PARAM_SERV_THUMBNAIL }, new String[] { "x" }, pathAndName, AJAXFlags.MODE_NORMAL);
sb.append("); background-repeat:no-repeat; background-position:50% 50%;'></div>");
hasMeta = true;
// hasThumbnail = true;
}
// first try author info from metadata (creator)
// boolean hasMetaAuthor = false;
String author = metaInfo.getCreator();
// fallback use file author (uploader)
if (StringHelper.containsNonWhitespace(author)) {
// hasMetaAuthor = true;
} else {
author = metaInfo.getAuthor();
if (!"-".equals(author)) {
author = UserManager.getInstance().getUserDisplayName(author);
} else {
author = null;
}
}
author = StringHelper.escapeHtml(author);
if (StringHelper.containsNonWhitespace(author)) {
sb.append("<p class=\"o_author\">").append(Formatter.escapeDoubleQuotes(translator.translate("mf.author")));
sb.append(": ").append(Formatter.escapeDoubleQuotes(author)).append("</p>");
hasMeta = true;
}
sb.append("</div>");
if (hasMeta) {
// render tooltip only when it contains something
sb.append("<script type='text/javascript'>").append("/* <![CDATA[ */").append("jQuery(function() {\n").append(" jQuery('#o_sel_doc_").append(pos).append("').tooltip({\n").append(" html: true,\n").append(" container: 'body',\n").append(" title: function(){ return jQuery('#o_sel_doc_tooltip_").append(pos).append("').html(); }\n").append(" });\n").append(" jQuery('#o_sel_doc_").append(pos).append("').on('click', function(){\n").append(" jQuery('#o_sel_doc_").append(pos).append("').tooltip('hide');\n").append(" });\n").append("});").append("/* ]]> */").append("</script>");
}
}
sb.append("</td><td>");
// filesize
if (!isContainer) {
// append filesize
sb.append("<span class='text-muted small'>");
sb.append(Formatter.formatBytes(leaf.getSize()));
sb.append("</span>");
}
sb.append("</td><td>");
// last modified
long lastModified = child.getLastModified();
sb.append("<span class='text-muted small'>");
if (lastModified != VFSConstants.UNDEFINED)
sb.append(DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, translator.getLocale()).format(new Date(lastModified)));
else
sb.append("-");
sb.append("</span></td><td>");
// license
if (licensesEnabled) {
MetaInfoFactory metaInfoFactory = CoreSpringFactory.getImpl(MetaInfoFactory.class);
License license = metaInfoFactory.getLicense(metaInfo);
LicenseRenderer licenseRenderer = new LicenseRenderer(translator.getLocale());
licenseRenderer.render(sb, license, true);
sb.append("</td><td>");
}
if (canContainerVersion) {
if (canVersion)
if (versions != null) {
sb.append("<span class='text-muted small'>");
sb.append(versions.getRevisionNr());
sb.append("</span>");
}
sb.append("</td><td>");
}
// locked
boolean locked = lockManager.isLocked(child);
if (locked) {
LockInfo lock = lockManager.getLock(child);
sb.append("<i class=\"o_icon o_icon_locked\" title=\"");
if (lock != null && lock.getLockedBy() != null) {
String fullname = userManager.getUserDisplayName(lock.getLockedBy());
String date = "";
if (lock.getCreationDate() != null) {
date = fc.getDateTimeFormat().format(lock.getCreationDate());
}
String msg = translator.translate("Locked", new String[] { fullname, date });
if (lock.isWebDAVLock()) {
msg += " (WebDAV)";
}
sb.append(msg);
}
sb.append("\"> </i>");
}
sb.append("</td><td>");
// Info link
if (canWrite) {
int actionCount = 0;
if (canVersion) {
actionCount++;
}
String nameLowerCase = name.toLowerCase();
// OO-57 only display edit link if it's not a folder
boolean isLeaf = (child instanceof VFSLeaf);
boolean isEditable = (isLeaf && !lockedForUser && !xssErrors && (nameLowerCase.endsWith(".html") || nameLowerCase.endsWith(".htm") || nameLowerCase.endsWith(".txt") || nameLowerCase.endsWith(".css") || nameLowerCase.endsWith(".csv ")));
if (isEditable)
actionCount++;
boolean canEP = canAddToEPortfolio && !isContainer;
if (canEP)
actionCount++;
boolean canMetaData = canMetaInfo(child);
if (canMetaData)
actionCount++;
if (actionCount == 1 && canMetaData) {
// when only one action is available, don't render menu
sb.append("<a ");
ubu.buildHrefAndOnclick(sb, null, iframePostEnabled, false, false, new NameValuePair(PARAM_EDTID, pos)).append(" title=\"").append(StringHelper.escapeHtml(translator.translate("mf.edit"))).append("\"><i class=\"o_icon o_icon-fw o_icon_edit_metadata\"></i></a>");
} else if (actionCount > 1) {
// add actions to menu if multiple actions available
sb.append("<a id='o_sel_actions_").append(pos).append("' href='javascript:;'><i class='o_icon o_icon-lg o_icon_actions'></i></a>").append("<div id='o_sel_actions_pop_").append(pos).append("' style='display:none;'><ul class='list-unstyled'>");
// meta edit action (rename etc)
if (canMetaData) {
// Metadata edit link... also handles rename for non-OlatRelPathImpls
sb.append("<li><a ");
ubu.buildHrefAndOnclick(sb, null, iframePostEnabled, false, false, new NameValuePair(PARAM_EDTID, pos)).append("><i class=\"o_icon o_icon-fw o_icon_edit_metadata\"></i> ").append(StringHelper.escapeHtml(translator.translate("mf.edit"))).append("</a></li>");
}
// content edit action
if (isEditable) {
sb.append("<li><a ");
ubu.buildHrefAndOnclick(sb, null, iframePostEnabled, false, false, new NameValuePair(PARAM_CONTENTEDITID, pos)).append("><i class=\"o_icon o_icon-fw o_icon_edit_file\"></i> ").append(StringHelper.escapeHtml(translator.translate("editor"))).append("</a></li>");
}
// versions action
if (canVersion) {
// Versions link
sb.append("<li><a ");
ubu.buildHrefAndOnclick(sb, null, iframePostEnabled, false, false, new NameValuePair(PARAM_VERID, pos)).append("><i class=\"o_icon o_icon-fw o_icon_version\"></i> ").append(StringHelper.escapeHtml(translator.translate("versions"))).append("</a></li>");
}
// get a link for adding a file to ePortfolio, if file-owner is the current user
if (canEP) {
if (metaInfo != null) {
Identity author = metaInfo.getAuthorIdentity();
if (author != null && fc.getIdentityEnvironnement().getIdentity().getKey().equals(author.getKey())) {
sb.append("<li><a ");
ubu.buildHrefAndOnclick(sb, null, iframePostEnabled, false, false, new NameValuePair(PARAM_EPORT, pos)).append("><i class=\"o_icon o_icon-fw o_icon_eportfolio_add\"></i> ").append(StringHelper.escapeHtml(translator.translate("eportfolio"))).append("</a></li>");
}
}
}
sb.append("</ul></div>").append("<script type='text/javascript'>").append("/* <![CDATA[ */").append("jQuery(function() {\n").append(" o_popover('o_sel_actions_").append(pos).append("','o_sel_actions_pop_").append(pos).append("','left');\n").append("});").append("/* ]]> */").append("</script>");
}
}
sb.append("</td></tr>");
}
use of org.olat.core.gui.components.form.flexible.impl.NameValuePair in project OpenOLAT by OpenOLAT.
the class FolderComponentRenderer method renderList.
private void renderList(StringOutput target, FolderComponent fc, URLBuilder ubu, Translator translator, boolean iframePostEnabled) {
VFSContainer currentContainer = fc.getCurrentContainer();
boolean canWrite = currentContainer.canWrite() == VFSConstants.YES;
boolean canCreateFolder = true;
if (currentContainer.getLocalSecurityCallback() != null && !currentContainer.getLocalSecurityCallback().canCreateFolder()) {
canCreateFolder = false;
}
boolean canDelete = false;
boolean canVersion = FolderConfig.versionsEnabled(fc.getCurrentContainer());
boolean canMail = fc.isCanMail();
for (Iterator<VFSItem> iter = fc.getCurrentContainerChildren().iterator(); iter.hasNext(); ) {
VFSItem child = iter.next();
if (child.canDelete() == VFSConstants.YES) {
canDelete = true;
break;
}
}
String formName = "folder" + CodeHelper.getRAMUniqueID();
target.append("<form method=\"post\" id=\"").append(formName).append("\" action=\"");
ubu.buildURI(target, new String[] { VelocityContainer.COMMAND_ID }, new String[] { FolderRunController.FORM_ACTION }, iframePostEnabled ? AJAXFlags.MODE_TOBGIFRAME : AJAXFlags.MODE_NORMAL);
target.append("\" ");
if (iframePostEnabled) {
// add ajax iframe target
target.append("\" onsubmit=\"o_XHRSubmit('").append(formName).append("');\">");
target.append("<input id=\"o_mai_").append(formName).append("\" type=\"hidden\" name=\"multi_action_identifier\" value=\"\"").append(" />");
} else {
target.append("\" onsubmit=\"if ( b_briefcase_isChecked('").append(formName).append("', '").append(Formatter.escapeSingleAndDoubleQuotes(StringHelper.escapeHtml(translator.translate("alert")).toString())).append("')) { if(o_info.linkbusy) return false; else o_beforeserver(); return true; } else {return false; }\">");
}
target.append("<div class=\"o_bc_createactions clearfix\"><ul class='nav navbar-nav navbar-right'>");
if (canWrite) {
if (canVersion) {
// deleted files
target.append("<li><a class=\"o_bc_deletedfiles\"");
ubu.buildHrefAndOnclick(target, null, iframePostEnabled, false, false, new NameValuePair(VelocityContainer.COMMAND_ID, "dfiles")).append("><i class='o_icon o_icon_recycle o_icon-fw'></i> ").append(translator.translate("dfiles")).append("</a></li>");
}
if (canWrite) {
if (fc.getExternContainerForCopy() != null && (fc.getExternContainerForCopy().getLocalSecurityCallback() == null || fc.getExternContainerForCopy().getLocalSecurityCallback().canCopy())) {
// option copy file
target.append("<li><a class=\"o_bc_copy\" ");
ubu.buildHrefAndOnclick(target, null, iframePostEnabled, false, false, new NameValuePair(VelocityContainer.COMMAND_ID, "copyfile")).append("><i class='o_icon o_icon_copy o_icon-fw'></i> ").append(translator.translate("copyfile")).append("</a></li>");
}
// option upload
target.append("<li><a class='o_bc_upload' ");
ubu.buildHrefAndOnclick(target, null, iframePostEnabled, false, false, new NameValuePair(VelocityContainer.COMMAND_ID, "ul")).append("><i class='o_icon o_icon_upload o_icon-fw'></i> ").append(translator.translate("ul")).append("</a></li>");
if (canCreateFolder) {
// option new folder
target.append("<li><a class=\"b_bc_newfolder\" ");
ubu.buildHrefAndOnclick(target, null, iframePostEnabled, false, false, new NameValuePair(VelocityContainer.COMMAND_ID, "cf")).append("><i class='o_icon o_icon_new_folder o_icon-fw'></i> ").append(translator.translate("cf")).append("</a></li>");
}
// option new file
target.append("<li><a class=\"b_bc_newfile\" ");
ubu.buildHrefAndOnclick(target, null, iframePostEnabled, false, false, new NameValuePair(VelocityContainer.COMMAND_ID, "cfile")).append("><i class='o_icon o_icon_new_document o_icon-fw'></i> ").append(translator.translate("cfile")).append("</a></li>");
}
}
// placeholder for the search
target.append("</ul></div>");
// add current file bread crumb path
crumbRenderer.render(fc, target, ubu, iframePostEnabled);
// add file listing for current folder
target.append("<div class='o_table_wrapper'>");
listRenderer.render(fc, target, ubu, translator, iframePostEnabled);
if (fc.getCurrentContainerChildren().size() > 0) {
target.append("<div class='o_table_footer'>").append("<div class=\"o_table_checkall input-sm\">").append("<label class='checkbox-inline'><a href=\"#\" onclick=\"javascript:b_briefcase_toggleCheck('").append(formName).append("', true)\">").append("<input type=\"checkbox\" checked=\"checked\" disabled=\"disabled\" />").append(translator.translate("checkall")).append("</a></label> <label class='checkbox-inline'><a href=\"#\" onclick=\"javascript:b_briefcase_toggleCheck('").append(formName).append("', false)\">").append("<input type=\"checkbox\" disabled=\"disabled\" />").append(translator.translate("uncheckall")).append("</a></label></div>").append("<div class='o_table_buttons'>");
if (canMail) {
target.append("<button type=\"button\" class='btn btn-default' onclick=\"o_TableMultiActionEvent('").append(formName).append("','").append(FolderRunController.ACTION_PRE).append(FolderCommandFactory.COMMAND_MAIL).append("');\"><span>").append(StringHelper.escapeHtml(translator.translate("send"))).append("</span></button>");
}
target.append(" <button type=\"button\" class='btn btn-default' onclick=\"o_TableMultiActionEvent('").append(formName).append("','").append(FolderRunController.ACTION_PRE).append(FolderCommandFactory.COMMAND_DOWNLOAD_ZIP).append("');\"><span>").append(StringHelper.escapeHtml(translator.translate("download"))).append("</span></button>");
if (canDelete) {
// delete
target.append(" <button type=\"button\" class='btn btn-default' onclick=\"o_TableMultiActionEvent('").append(formName).append("','").append(FolderRunController.ACTION_PRE).append(FolderCommandFactory.COMMAND_DEL).append("');\"><span>").append(StringHelper.escapeHtml(translator.translate("del"))).append("</span></button>");
}
if (canWrite) {
// move
target.append(" <button type=\"button\" class='btn btn-default' onclick=\"o_TableMultiActionEvent('").append(formName).append("','").append(FolderRunController.ACTION_PRE).append(FolderCommandFactory.COMMAND_MOVE).append("');\"><span>").append(StringHelper.escapeHtml(translator.translate("move"))).append("</span></button>");
// copy
target.append(" <button type=\"button\" class='btn btn-default' onclick=\"o_TableMultiActionEvent('").append(formName).append("','").append(FolderRunController.ACTION_PRE).append(FolderCommandFactory.COMMAND_COPY).append("');\"><span>").append(StringHelper.escapeHtml(translator.translate("copy"))).append("</span></button>");
// zip
target.append(" <button type=\"button\" class='btn btn-default' onclick=\"o_TableMultiActionEvent('").append(formName).append("','").append(FolderRunController.ACTION_PRE).append(FolderCommandFactory.COMMAND_ZIP).append("');\"><span>").append(StringHelper.escapeHtml(translator.translate("zip"))).append("</span></button>");
// unzip
target.append(" <button type=\"button\" class='btn btn-default' onclick=\"o_TableMultiActionEvent('").append(formName).append("','").append(FolderRunController.ACTION_PRE).append(FolderCommandFactory.COMMAND_UNZIP).append("');\"><span>").append(StringHelper.escapeHtml(translator.translate("unzip"))).append("</span></button>");
}
target.append("</div></div>");
}
target.append("</div></form>");
}
use of org.olat.core.gui.components.form.flexible.impl.NameValuePair in project OpenOLAT by OpenOLAT.
the class AbstractFlexiTableRenderer method renderPageSize.
private void renderPageSize(StringOutput sb, FlexiTableComponent ftC, Translator translator) {
FlexiTableElementImpl ftE = ftC.getFlexiTableElement();
FlexiTableDataModel<?> dataModel = ftE.getTableDataModel();
Form theForm = ftE.getRootForm();
String dispatchId = ftE.getFormDispatchId();
int pageSize = ftE.getPageSize();
int firstRow = ftE.getFirstRow();
int maxRows = ftE.getMaxRows();
int rows = dataModel.getRowCount();
int lastRow = Math.min(rows, firstRow + maxRows);
sb.append("<div class='o_table_rows_infos o_noprint'>");
sb.append(translator.translate("page.size.a", new String[] { // for humans
Integer.toString(firstRow + 1), Integer.toString(lastRow), Integer.toString(rows) })).append(" ");
sb.append("<div class='btn-group dropup'><button type='button' class='btn btn-default dropdown-toggle' data-toggle='dropdown' aria-expanded='false'>").append(" <span>");
if (pageSize < 0) {
sb.append(translator.translate("show.all"));
} else {
sb.append(Integer.toString(pageSize));
}
sb.append("</span> <span class='caret'></span></button>").append("<ul class='dropdown-menu' role='menu'>");
int[] sizes = new int[] { 20, 50, 100, 250 };
int defaultPageSize = ftE.getDefaultPageSize();
if (Arrays.binarySearch(sizes, defaultPageSize) < 0) {
sizes = new int[] { 20, 50, 100, 250, defaultPageSize };
Arrays.sort(sizes);
}
for (int size : sizes) {
sb.append("<li><a href=\"javascript:").append(FormJSHelper.getXHRFnCallFor(theForm, dispatchId, 1, true, true, true, new NameValuePair("pagesize", Integer.toString(size)))).append("\">").append(Integer.toString(size)).append("</a></li>");
}
if (ftE.isShowAllRowsEnabled()) {
sb.append("<li><a href=\"javascript:").append(FormJSHelper.getXHRFnCallFor(theForm, dispatchId, 1, true, true, true, new NameValuePair("pagesize", "all"))).append("\">").append(translator.translate("show.all")).append("</a></li>");
}
sb.append("</ul></div>").append(" ").append(translator.translate("page.size.b")).append("</div> ");
}
use of org.olat.core.gui.components.form.flexible.impl.NameValuePair in project OpenOLAT by OpenOLAT.
the class AbstractFlexiTableRenderer method renderPageNextLink.
private void renderPageNextLink(StringOutput sb, FlexiTableComponent ftC, int page, int maxPage) {
boolean disabled = (page >= maxPage);
FlexiTableElementImpl ftE = ftC.getFlexiTableElement();
Form theForm = ftE.getRootForm();
sb.append("<li ").append(" class='disabled'", disabled).append("><a href=\"");
if (disabled) {
sb.append("#");
} else {
sb.append("javascript:").append(FormJSHelper.getXHRFnCallFor(theForm, ftC.getFormDispatchId(), 1, true, true, true, new NameValuePair("page", Integer.toString(page + 1))));
}
sb.append("\">").append("»").append("</a></li>");
}
Aggregations