Permalink
Browse files

Merge pull request #181 from bitstorm/core-1.5.x

Core 1.5.x
  • Loading branch information...
2 parents 994ac77 + 5bc39c6 commit a9f7a81c14c0eda73fc47ad95e447c8fee6d34b5 @martin-g martin-g committed Dec 21, 2012
@@ -74,17 +74,7 @@ public void renderHead(Component c, IHeaderResponse response)
{
super.renderHead(c, response);
if (component == null)
- throw new IllegalStateException("TinyMceBehavior is not bound to a component");
-
- ResourceReferenceRequestHandler handler = new ResourceReferenceRequestHandler(
- TinyMCESettings.javaScriptReference(), null);
-
- Url url = new Url();
- List<String> segments = url.getSegments();
- segments.add(Application.get().getMapperContext().getNamespace());
- segments.add(Application.get().getMapperContext().getResourceIdentifier());
- segments.add(handler.getResourceReference().getScope().getName());
- settings.setDocumentBaseUrl(url.toString());
+ throw new IllegalStateException("TinyMceBehavior is not bound to a component");
// TinyMce javascript:
if (mayRenderJavascriptDirect())
@@ -32,11 +32,18 @@
private static final long serialVersionUID = -1794953981259227822L;
private static final Logger log = LoggerFactory.getLogger(ImageUploadContentPanel.class);
private static final FileExtensionValidator FILE_EXTENSION_VALIDATOR = new FileExtensionValidator();
+ private final String uploadFolderPath;
public ImageUploadContentPanel(String pId)
{
+ this(pId, ImageUploadHelper.getTemporaryDirPath());
+ }
+
+ public ImageUploadContentPanel(String pId, String customUploadFolderPath)
+ {
super(pId);
setOutputMarkupId(true);
+ this.uploadFolderPath = customUploadFolderPath;
Form<?> form = new Form<Void>("form");
final FeedbackPanel feedback = new FeedbackPanel("feedback");
feedback.setOutputMarkupId(true);
@@ -57,7 +64,7 @@ protected void onSubmit(AjaxRequestTarget pTarget, Form<?> pForm)
String fileName = fileUpload.getClientFileName();
try
{
- File currentEngineerDir = new File(ImageUploadHelper.getTemporaryDirPath());
+ File currentEngineerDir = new File(uploadFolderPath);
if (!currentEngineerDir.exists())
{
currentEngineerDir.mkdir();
@@ -65,7 +65,7 @@ public static XmlTag createImageTag(ImageFileDescription pImageFileDescription,
"src",
RequestCycle.get()
.getOriginalResponse()
- .encodeURL(Strings.replaceAll(sb.toString(), "&", "&amp;")));
+ .encodeURL(sb.toString()));
return tag;
}
}
@@ -17,6 +17,7 @@
import org.apache.wicket.model.ResourceModel;
import org.apache.wicket.request.cycle.RequestCycle;
import org.apache.wicket.request.handler.resource.ResourceStreamRequestHandler;
+import org.apache.wicket.request.resource.CssResourceReference;
import org.apache.wicket.request.resource.JavaScriptResourceReference;
import org.apache.wicket.request.resource.ResourceReference;
import org.apache.wicket.util.string.Strings;
@@ -36,12 +37,16 @@
private static final Logger log = LoggerFactory.getLogger(ImageUploadPanel.class);
private static final ResourceReference IMAGE_UPLOAD_JS_RESOURCE = new JavaScriptResourceReference(
ImageUploadPanel.class, "imageUpload.js");
+ private static final ResourceReference IMAGE_UPLOAD_CSS_RESOURCE = new CssResourceReference(
+ ImageUploadPanel.class, "imageUpload.css");
private ModalWindow modalWindow;
private ImageUploadBehavior imageUploadBehavior;
-
- public ImageUploadPanel(String pId)
+ private final String uploadFolderPath;
+
+ public ImageUploadPanel(String pId, String uploadFolderPath)
{
+
super(pId);
setOutputMarkupId(true);
add(modalWindow = new ModalWindow("imageUploadDialog"));
@@ -58,6 +63,13 @@ public void onClose(AjaxRequestTarget pTarget)
}
});
add(imageUploadBehavior = new ImageUploadBehavior());
+
+ this.uploadFolderPath = uploadFolderPath;
+ }
+
+ public ImageUploadPanel(String pId)
+ {
+ this(pId, ImageUploadHelper.getTemporaryDirPath());
}
public void resetModalContent()
@@ -76,7 +88,7 @@ public void resetModalContent()
protected void respond(AjaxRequestTarget pTarget)
{
ImageUploadContentPanel content = new ImageUploadContentPanel(
- modalWindow.getContentId())
+ modalWindow.getContentId(), uploadFolderPath)
{
private static final long serialVersionUID = 1L;
@@ -109,6 +121,7 @@ public void renderHead(Component c, IHeaderResponse pResponse)
String script = getCallbackName() + " = function () { " + getCallbackScript() + " }";
pResponse.renderOnDomReadyJavaScript(script);
pResponse.renderJavaScriptReference(IMAGE_UPLOAD_JS_RESOURCE);
+ pResponse.renderCSSReference(IMAGE_UPLOAD_CSS_RESOURCE);
}
}
@@ -137,7 +150,7 @@ public void onResourceRequested()
FileInputStream inputStream = null;
try
{
- inputStream = new FileInputStream(ImageUploadHelper.getTemporaryDirPath() +
+ inputStream = new FileInputStream(uploadFolderPath +
File.separatorChar + fileName);
}
catch (FileNotFoundException ex)
@@ -0,0 +1 @@
+.defaultSkin span.mce_upload {background-position:-380px 0}
Oops, something went wrong.
@@ -11,7 +11,7 @@
// Register commands
ed.addCommand('mceImageUpload', t._save, t);
// Register buttons
- ed.addButton('upload', {title : 'imageupload.title', cmd : 'mceImageUpload'});
+ ed.addButton('upload', {title : 'Upload image', cmd : 'mceImageUpload'});
},

0 comments on commit a9f7a81

Please sign in to comment.