use of org.olat.core.util.vfs.LocalFileImpl in project OpenOLAT by OpenOLAT.
the class ForumRTFFormatter method addImagesToVFSContainer.
/**
* Retrieves the appropriate images for the input messageNode, if any,
* and adds it to the input container.
*
* @param messageNode
* @param imageContainer
* @return
*/
private List<String> addImagesToVFSContainer(MessageNode messageNode, VFSContainer imageContainer) {
List<String> fileNameList = new ArrayList<String>();
String iconPath = null;
if (messageNode.isClosed() && messageNode.isSticky()) {
iconPath = getImagePath("fo_sticky_closed");
} else if (messageNode.isClosed()) {
iconPath = getImagePath("fo_closed");
} else if (messageNode.isSticky()) {
iconPath = getImagePath("fo_sticky");
}
if (iconPath != null) {
File file = new File(iconPath);
if (file.exists()) {
LocalFileImpl imgFile = new LocalFileImpl(file);
imageContainer.copyFrom(imgFile);
fileNameList.add(file.getName());
} else {
log.error("Could not find image for forum RTF formatter::" + iconPath);
}
}
return fileNameList;
}
use of org.olat.core.util.vfs.LocalFileImpl in project OpenOLAT by OpenOLAT.
the class FeedFileStorge method loadItemMedia.
/**
* Load the media file of the item.
*
* @param item
* @return
*/
public File loadItemMedia(Item item) {
File file = null;
Enclosure enclosure = item.getEnclosure();
VFSContainer mediaDir = getOrCreateItemMediaContainer(item);
if (mediaDir != null && enclosure != null) {
VFSLeaf mediaFile = (VFSLeaf) mediaDir.resolve(enclosure.getFileName());
if (mediaFile != null && mediaFile instanceof LocalFileImpl) {
file = ((LocalFileImpl) mediaFile).getBasefile();
}
}
return file;
}
use of org.olat.core.util.vfs.LocalFileImpl in project OpenOLAT by OpenOLAT.
the class CustomConfigManager method appendLogoPart.
private void appendLogoPart(StringBuffer sb, VFSContainer themeBase) {
VFSItem vfsItem = getLogoItem(themeBase);
if (vfsItem != null) {
sb.append("#o_right_logo {\n\tbackground-image: url(").append(vfsItem.getName()).append("); \n");
sb.append("\tbackground-position: left top; \n");
sb.append("\tbackground-repeat: no-repeat; \n");
LocalFileImpl leaf = (LocalFileImpl) vfsItem;
int[] size = getImageSize(leaf.getBasefile());
if (size != null) {
sb.append("\twidth: ").append(size[0]).append("px; \n").append("\theight: ").append(size[1]).append("px; \n");
}
sb.append("\tfloat: left; \n}\n");
sb.append("#o_logo { \n\t float: left; \n}");
}
}
use of org.olat.core.util.vfs.LocalFileImpl in project OpenOLAT by OpenOLAT.
the class CPOfflineReadableManager method writeOfflineCPStartHTMLFile.
/**
* generates a html-file (_START_.html) that presents the given cp-content
* (specified by its "_unzipped_"-dir). The resulting file is suitable for
* offline reading of the cp.
*
* @param unzippedDir
* the directory that contains the unzipped CP
*/
private void writeOfflineCPStartHTMLFile(File unzippedDir) throws IOException {
/* first, we do the menu-tree */
File mani = new File(unzippedDir, FILENAME_IMSMANIFEST);
LocalFileImpl vfsMani = new LocalFileImpl(mani);
CPManifestTreeModel ctm = new CPManifestTreeModel(vfsMani, "");
TreeNode root = ctm.getRootNode();
// let's take the rootnode title as page title
this.rootTitle = root.getTitle();
StringBuilder menuTreeSB = new StringBuilder();
renderMenuTreeNodeRecursively(root, menuTreeSB, 0);
// now put values to velocityContext
VelocityContext ctx = new VelocityContext();
ctx.put("menutree", menuTreeSB.toString());
ctx.put("rootTitle", this.rootTitle);
ctx.put("cpoff", DIRNAME_CPOFFLINEMENUMAT);
StringWriter sw = new StringWriter();
try {
String template = FileUtils.load(CPOfflineReadableManager.class.getResourceAsStream("_content/cpofflinereadable.html"), "utf-8");
boolean evalResult = velocityEngine.evaluate(ctx, sw, "cpexport", template);
if (!evalResult)
log.error("Could not evaluate velocity template for CP Export");
} catch (Exception e) {
log.error("Error while evaluating velovity template for CP Export", e);
}
File f = new File(unzippedDir, FILENAME_START);
if (f.exists()) {
FileUtils.deleteDirsAndFiles(f, false, true);
}
ExportUtil.writeContentToFile(FILENAME_START, sw.toString(), unzippedDir, "utf-8");
}
use of org.olat.core.util.vfs.LocalFileImpl in project OpenOLAT by OpenOLAT.
the class CatalogEntryEditController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
setFormStyle("o_catalog");
String name = catalogEntry == null ? "" : catalogEntry.getName();
nameEl = uifactory.addTextElement("name", "entry.category", 255, name, formLayout);
nameEl.setMandatory(true);
nameEl.setNotEmptyCheck("form.legende.mandatory");
String desc = catalogEntry == null ? "" : catalogEntry.getDescription();
descriptionEl = uifactory.addRichTextElementForStringDataMinimalistic("description", "entry.description", desc, 10, -1, formLayout, getWindowControl());
String[] styleValues = new String[] { translate("tiles"), translate("list"), translate("list.compact") };
styleEl = uifactory.addDropdownSingleselect("style", "style", formLayout, styleKeys, styleValues, null);
Style style = catalogEntry == null ? null : catalogEntry.getStyle();
if (style != null) {
for (String styleKey : styleKeys) {
if (styleKey.equals(style.name())) {
styleEl.select(styleKey, true);
}
}
}
if (!styleEl.isOneSelected()) {
styleEl.select(styleKeys[0], true);
}
VFSLeaf img = catalogEntry == null || catalogEntry.getKey() == null ? null : catalogManager.getImage(catalogEntry);
fileUpload = uifactory.addFileElement(getWindowControl(), "entry.pic", "entry.pic", formLayout);
fileUpload.setMaxUploadSizeKB(picUploadlimitKB, null, null);
fileUpload.addActionListener(FormEvent.ONCHANGE);
fileUpload.setPreview(ureq.getUserSession(), true);
fileUpload.setCropSelectionEnabled(true);
fileUpload.setDeleteEnabled(true);
if (img instanceof LocalFileImpl) {
fileUpload.setInitialFile(((LocalFileImpl) img).getBasefile());
}
fileUpload.limitToMimeType(mimeTypes, "cif.error.mimetype", new String[] { mimeTypes.toString() });
FormLayoutContainer buttonLayout = FormLayoutContainer.createButtonLayout("button_layout", getTranslator());
buttonLayout.setElementCssClass("o_sel_catalog_entry_form_buttons");
formLayout.add(buttonLayout);
uifactory.addFormSubmitButton("submit", buttonLayout);
uifactory.addFormCancelButton("cancel", buttonLayout, ureq, getWindowControl());
}
Aggregations