Skip to content
Snippets Groups Projects
Commit 98fa15d7 authored by srosse's avatar srosse
Browse files

Merge OpenOLAT 10.5 to OpenOLAT default branch with 38674fa7548d127cb41ef220c61c394c7015bc03

parents f6e8bb1c 243c917e
No related branches found
No related tags found
No related merge requests found
...@@ -119,7 +119,10 @@ public class CmdEditMeta extends BasicController implements FolderCommand { ...@@ -119,7 +119,10 @@ public class CmdEditMeta extends BasicController implements FolderCommand {
private String getResourceURL(WindowControl wControl) { private String getResourceURL(WindowControl wControl) {
String path = "path=" + folderComponent.getCurrentContainerPath(); String path = "path=" + folderComponent.getCurrentContainerPath();
if(currentItem != null) { if(currentItem != null) {
path += "/" + currentItem.getName(); if(path.charAt(path.length() - 1) != '/') {
path += currentItem.getName();
}
path += currentItem.getName();
} }
OLATResourceable ores = OresHelper.createOLATResourceableTypeWithoutCheck(path); OLATResourceable ores = OresHelper.createOLATResourceableTypeWithoutCheck(path);
WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(ores, null, wControl); WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(ores, null, wControl);
......
...@@ -57,6 +57,7 @@ public class VFSMediaResource implements MediaResource { ...@@ -57,6 +57,7 @@ public class VFSMediaResource implements MediaResource {
return true; return true;
} }
@Override
public String getContentType() { public String getContentType() {
String mimeType; String mimeType;
if(downloadable) { if(downloadable) {
...@@ -87,24 +88,28 @@ public class VFSMediaResource implements MediaResource { ...@@ -87,24 +88,28 @@ public class VFSMediaResource implements MediaResource {
return mimeType; return mimeType;
} }
@Override
public Long getSize() { public Long getSize() {
long size = vfsLeaf.getSize(); long size = vfsLeaf.getSize();
return (size == VFSConstants.UNDEFINED) ? null : new Long(size); return (size == VFSConstants.UNDEFINED) ? null : new Long(size);
} }
@Override
public InputStream getInputStream() { public InputStream getInputStream() {
filesInfoMBean.logDownload(getSize()); filesInfoMBean.logDownload(getSize());
return vfsLeaf.getInputStream(); return vfsLeaf.getInputStream();
} }
@Override
public Long getLastModified() { public Long getLastModified() {
long size = vfsLeaf.getLastModified(); long lastModified = vfsLeaf.getLastModified();
return (size == VFSConstants.UNDEFINED) ? null : new Long(size); return (lastModified == VFSConstants.UNDEFINED) ? null : new Long(lastModified);
} }
/** /**
* @see org.olat.core.gui.media.MediaResource#prepare(javax.servlet.http.HttpServletResponse) * @see org.olat.core.gui.media.MediaResource#prepare(javax.servlet.http.HttpServletResponse)
*/ */
@Override
public void prepare(HttpServletResponse hres) { public void prepare(HttpServletResponse hres) {
String filename = StringHelper.urlEncodeUTF8(vfsLeaf.getName()); String filename = StringHelper.urlEncodeUTF8(vfsLeaf.getName());
if (unknownMimeType) { if (unknownMimeType) {
...@@ -114,6 +119,7 @@ public class VFSMediaResource implements MediaResource { ...@@ -114,6 +119,7 @@ public class VFSMediaResource implements MediaResource {
} }
} }
@Override
public void release() { public void release() {
// nothing to do here // nothing to do here
} }
......
...@@ -717,9 +717,17 @@ public class WikiMainController extends BasicController implements CloneableCont ...@@ -717,9 +717,17 @@ public class WikiMainController extends BasicController implements CloneableCont
private void deliverMediaFile(UserRequest ureq, String command) { private void deliverMediaFile(UserRequest ureq, String command) {
VFSLeaf leaf = (VFSLeaf)WikiManager.getInstance().getMediaFolder(ores).resolve(command); VFSItem item = WikiManager.getInstance().getMediaFolder(ores).resolve(command);
if(leaf == null) showError("wiki.error.file.not.found"); if(item == null) {
else ureq.getDispatchResult().setResultingMediaResource(new VFSMediaResource(leaf)); //try to replace blanck with _
item = WikiManager.getInstance().getMediaFolder(ores).resolve(command.replace(" ", "_"));
}
if(item instanceof VFSLeaf) {
ureq.getDispatchResult()
.setResultingMediaResource(new VFSMediaResource((VFSLeaf)item));
} else {
showError("wiki.error.file.not.found");
}
} }
......
...@@ -40,6 +40,7 @@ import org.olat.core.gui.render.Renderer; ...@@ -40,6 +40,7 @@ import org.olat.core.gui.render.Renderer;
import org.olat.core.gui.render.StringOutput; import org.olat.core.gui.render.StringOutput;
import org.olat.core.gui.render.URLBuilder; import org.olat.core.gui.render.URLBuilder;
import org.olat.core.gui.translator.Translator; import org.olat.core.gui.translator.Translator;
import org.olat.core.helpers.Settings;
import org.olat.core.logging.OLATRuntimeException; import org.olat.core.logging.OLATRuntimeException;
import org.olat.core.util.Formatter; import org.olat.core.util.Formatter;
...@@ -112,7 +113,8 @@ public class WikiMarkupRenderer extends DefaultComponentRenderer { ...@@ -112,7 +113,8 @@ public class WikiMarkupRenderer extends DefaultComponentRenderer {
sb.append("</div>"); sb.append("</div>");
//set targets of media, image and external links to target "_blank" //set targets of media, image and external links to target "_blank"
sb.append("<script type=\"text/javascript\">/* <![CDATA[ */ "); sb.append("<script type=\"text/javascript\">/* <![CDATA[ */ ");
sb.append("changeAnchorTargets('").append(uniqueId).append("');"); String instanceUrl = Settings.getServerContextPathURI();
sb.append("changeAnchorTargets('").append(uniqueId).append("','").append(instanceUrl).append("');");
sb.append("/* ]]> */</script>"); sb.append("/* ]]> */</script>");
} }
} }
...@@ -9,7 +9,7 @@ if (clientPC.indexOf('opera') != -1) { ...@@ -9,7 +9,7 @@ if (clientPC.indexOf('opera') != -1) {
var is_opera_seven = (window.opera && document.childNodes); var is_opera_seven = (window.opera && document.childNodes);
} }
function changeAnchorTargets(id) { function changeAnchorTargets(id, hostUrl) {
jQuery('a', jQuery('#' + id)).each(function(index, el) { jQuery('a', jQuery('#' + id)).each(function(index, el) {
var anchor = jQuery(el); var anchor = jQuery(el);
var openInNewWindow = false; var openInNewWindow = false;
...@@ -28,7 +28,9 @@ function changeAnchorTargets(id) { ...@@ -28,7 +28,9 @@ function changeAnchorTargets(id) {
//open media links in new window, but only if file exists //open media links in new window, but only if file exists
if (anchor.attr("title")) { if (anchor.attr("title")) {
var href = anchor.attr("href"); var href = anchor.attr("href");
if (!anchor.attr("class") && anchor.attr("title").indexOf("Media:") != -1) { //normal media link file found if(href.indexOf(hostUrl) == 0) {
openInNewWindow = false;
} else if (!anchor.attr("class") && anchor.attr("title").indexOf("Media:") != -1) { //normal media link file found
openInNewWindow = true; openInNewWindow = true;
//modify link to non ajax mode as opening in new window with ajax mode on fails //modify link to non ajax mode as opening in new window with ajax mode on fails
if (href.indexOf(":1/") != -1) { if (href.indexOf(":1/") != -1) {
...@@ -38,9 +40,9 @@ function changeAnchorTargets(id) { ...@@ -38,9 +40,9 @@ function changeAnchorTargets(id) {
anchor.prop('onclick', null).off('click'); anchor.prop('onclick', null).off('click');
} }
} else if (anchor.attr("class") == "edit" && anchor.attr("title").indexOf("Media:") != -1) { //media file not found } else if (anchor.attr("class") == "edit" && anchor.attr("title").indexOf("Media:") != -1) { //media file not found
href = href.substr(0, href.indexOf("Edit:topic")); var startHref = href.substr(0, href.indexOf("Special:Edit:topic="));
href = href+"Upload"; var endHref = href.substr(href.indexOf("Special:Edit:topic=") + "Special:Edit:topic=".length);
anchor.attr("href", href); anchor.attr("href", startHref + "Media:" + endHref);
} }
} }
if (openInNewWindow) { if (openInNewWindow) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment