Permalink
Browse files

Images work again

  • Loading branch information...
1 parent e1e078e commit 77b80485d480474e204e21e4bf38a4c70d52b71f @joergviola committed Nov 22, 2011
@@ -15,6 +15,7 @@
import play.data.validation.Valid;
import play.db.jpa.Blob;
+import play.db.jpa.JPABase;
import play.libs.MimeTypes;
import play.mvc.Controller;
import play.mvc.With;
@@ -67,8 +68,11 @@ public static void savePage(@Valid CMSPage page, boolean active) throws Throwabl
public static void upload(File data, String title) {
if (!Profiler.canEnter())
forbidden();
- CMSImage image = new CMSImage();
- image.name = data.getName();
+ CMSImage image = CMSImage.findById(data.getName());
+ if (image==null) {
+ image = new CMSImage();
+ image.name = data.getName();
+ }
if (StringUtils.isEmpty(title))
image.title = data.getName();
else
@@ -81,7 +85,7 @@ public static void upload(File data, String title) {
e.printStackTrace();
}
image.save();
- redirectToStatic("/public/tiny_mce/plugins/advimage/image.htm");
+ redirect("/public/tiny_mce/plugins/advimage/image.htm?"+image.name);
}
public static void imagelist() {
@@ -1,6 +1,6 @@
var tinyMCEImageList = new Array(
// Name, URL
#{list items:images, as:'image' }
- ["${image.title}", "../image/${image.name}"]#{ifnot image_isLast},#{/ifnot}
+ ["${image.title}", "@{cms.Frontend.image(image.name)}"]#{ifnot image_isLast},#{/ifnot}
#{/list}
);
@@ -17,7 +17,7 @@ var ImageDialog = {
this.fillFileList('over_list', fl);
this.fillFileList('out_list', fl);
TinyMCE_EditableSelects.init();
-
+
if (n.nodeName == 'IMG') {
nl.src.value = dom.getAttrib(n, 'src');
nl.width.value = dom.getAttrib(n, 'width');
@@ -86,6 +86,19 @@ var ImageDialog = {
this.changeAppearance();
this.showPreviewImage(nl.src.value, 1);
+
+ var imgList = document.getElementById("src_list");
+ for(i=0;i<imgList.length;i++) {
+ if(imgList.options[i].innerHTML==window.location.search.substring(1)) {
+ imgList.selectedIndex = i;
+ var value = imgList.options[i].value;
+ this.showPreviewImage(value,1);
+ document.getElementById("src").value = value;
+ document.getElementById("alt").value = value;
+ document.getElementById("title").value = imgList.options[i].text;
+ break;
+ }
+ }
},
insert : function(file, title) {

0 comments on commit 77b8048

Please sign in to comment.