APICHANGE: removed SWFUpload. Refactored Content Editors uploader to use standard uploader.

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@97489 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Will Rossiter 2010-01-25 21:10:43 +00:00 committed by Sam Minnee
parent 2d2253360d
commit 80c69abdb8
3 changed files with 66 additions and 63 deletions

View File

@ -198,6 +198,11 @@ class HtmlEditorField_Toolbar extends RequestHandler {
function __construct($controller, $name) {
parent::__construct();
Requirements::javascript(SAPPHIRE_DIR . "/thirdparty/behaviour/behaviour.js");
Requirements::javascript(SAPPHIRE_DIR . "/javascript/tiny_mce_improvements.js");
Requirements::javascript(SAPPHIRE_DIR ."/thirdparty/jquery-form/jquery.form.js");
Requirements::javascript(SAPPHIRE_DIR ."/javascript/HtmlEditorField.js");
$this->controller = $controller;
$this->name = $name;
@ -210,9 +215,6 @@ class HtmlEditorField_Toolbar extends RequestHandler {
* @return Form
*/
function LinkForm() {
Requirements::javascript(SAPPHIRE_DIR . "/thirdparty/behaviour/behaviour.js");
Requirements::javascript(SAPPHIRE_DIR . "/javascript/tiny_mce_improvements.js");
$form = new Form(
$this->controller,
"{$this->name}/LinkForm",
@ -256,37 +258,17 @@ class HtmlEditorField_Toolbar extends RequestHandler {
* @return Form
*/
function ImageForm() {
Requirements::javascript(SAPPHIRE_DIR . "/thirdparty/behaviour/behaviour.js");
Requirements::javascript(CMS_DIR . '/thirdparty/swfupload/swfupload.js');
Requirements::javascript(SAPPHIRE_DIR . "/javascript/tiny_mce_improvements.js");
Requirements::javascript(CMS_DIR . '/javascript/Upload.js');
Requirements::css(CMS_DIR .'/css/TinyMCEImageEnhancement.css');
Requirements::javascript(CMS_DIR . '/javascript/TinyMCEImageEnhancement.js');
/**
* @todo Adding folders via this screen is not enabled just yet as it is still
* a bit too buggy - wrossiter (09/11/09)
*/
$form = new Form(
$this->controller,
"{$this->name}/ImageForm",
new FieldSet(
new LiteralField('Heading', '<h2><img src="cms/images/closeicon.gif" alt="' . _t('HtmlEditorField.CLOSE', 'close') . '" title="' . _t('HtmlEditorField.CLOSE', 'close') . '" />' . _t('HtmlEditorField.IMAGE', 'Image') . '</h2>'),
new TreeDropdownField('FolderID', _t('HtmlEditorField.FOLDER', 'Folder'), 'Folder'),
new LiteralField('AddFolderOrUpload',
'<div id="AddFolderGroup" style="display: none;">
<a style="" href="#" id="AddFolder" class="link">' . _t('HtmlEditorField.CREATEFOLDER','Create Folder') . '</a>
<input style="display: none; margin-left: 2px; width: 94px;" id="NewFolderName" class="addFolder" type="text">
<a style="display: none;" href="#" id="FolderOk" class="link addFolder">' . _t('HtmlEditorField.OK','Ok') . '</a>
<a style="display: none;" href="#" id="FolderCancel" class="link addFolder">' . _t('HtmlEditorField.FOLDERCANCEL','Cancel') . '</a>
</div>
<div id="UploadGroup" class="group" style="margin: 0 0 0 5px; clear: both; padding-top: 3px">
<a href="#" id="SWFUploadButton" class="link">' . _t('HtmlEditorField.UPLOAD','Upload') . '</a>
</div>
<div id="UploadFiles">
</div>'
),
new CompositeField(new FieldSet(
new LiteralField('ShowUpload', '<p class="showUploadField"><a href="#">'. _t('HtmlEditorField.SHOWUPLOADFORM', 'Upload File') .'</a></p>'),
new FileField("Files[0]" , _t('AssetAdmin.CHOOSEFILE','Choose file: ')),
new LiteralField('Response', '<div id="UploadFormResponse"></div>')
)),
new TextField('getimagesSearch', _t('HtmlEditorField.SEARCHFILENAME', 'Search by file name')),
new ThumbnailStripField('FolderImages', 'FolderID', 'getimages'),
new TextField('AltText', _t('HtmlEditorField.IMAGEALTTEXT', 'Alternative text (alt) - shown if image cannot be displayed'), '', 80),
@ -319,11 +301,6 @@ class HtmlEditorField_Toolbar extends RequestHandler {
}
function FlashForm() {
Requirements::javascript(SAPPHIRE_DIR . "/thirdparty/behaviour/behaviour.js");
Requirements::javascript(CMS_DIR . '/javascript/Upload.js');
Requirements::javascript(SAPPHIRE_DIR . "/javascript/tiny_mce_improvements.js");
Requirements::javascript(CMS_DIR . '/thirdparty/swfupload/swfupload.js');
$form = new Form(
$this->controller,
"{$this->name}/FlashForm",

View File

@ -1,29 +1,61 @@
/**
* Simple TinyMCE initialisation
* Functions for HtmlEditorFields in the back end.
* Includes the JS for the ImageUpload forms.
*
* Relies on the jquery.form.js plugin to power the
* ajax / iframe submissions
*/
if((typeof tinyMCE != 'undefined')) {
tinymce.PluginManager.load('advcode', '/some/dir/someplugin/editor_plugin.js');
tinyMCE.init({
mode : "specific_textareas",
editor_selector : "htmleditor",
width: "100%",
auto_resize : false,
theme : "advanced",
(function($) {
$(document).ready(function() {
theme_advanced_layout_manager: "SimpleLayout",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_toolbar_parent : "right",
plugins : "contextmenu,table,emotions,paste,-advcode,spellchecker",
blockquote_clear_tag : "p",
table_inline_editing : true,
theme_advanced_buttons1 : "bold,italic,underline,strikethrough,separator,justifyleft,justifycenter,justifyright,justifyfull,formatselect,separator,bullist,numlist,outdent,indent,blockquote,hr,charmap",
theme_advanced_buttons2 : "undo,redo,separator,cut,copy,paste,pastetext,pasteword,spellchecker,separator,advcode,search,replace,selectall,visualaid,separator,tablecontrols",
theme_advanced_buttons3 : "",
$("#Form_EditorToolbarImageForm .showUploadField a").click(function() {
if($(this).hasClass("showing")) {
$("#Form_EditorToolbarImageForm_Files-0").parents('.file').hide();
$(this).text(ss.i18n._t('HtmlEditorField.ShowUploadForm', 'Upload File')).removeClass("showing");
}
else {
$("#Form_EditorToolbarImageForm_Files-0").parents('.file').show();
$(this).text(ss.i18n._t('HtmlEditorField.HideUploadForm', 'Hide Upload Form')).addClass("showing");
}
}).show();
safari_warning : false,
relative_urls : true,
verify_html : true
$("#Form_EditorToolbarImageForm_Files-0").change(function() {
$("#contentPanel form").ajaxForm({
url: 'admin/assets/UploadForm?action_doUpload=1',
iframe: true,
beforeSubmit: function(data) {
$("#UploadFormResponse").text("Uploading File...").addClass("loading").show();
$("#Form_EditorToolbarImageForm_Files-0").parents('.file').hide();
},
success: function(data) {
$("#UploadFormResponse").text(data).removeClass("loading");
$("#Form_EditorToolbarImageForm_Files-0").val("").parents('.file').show();
$("#FolderImages").html('<h2>'+ ss.i18n._t('HtmlEditorField.Loading', 'Loading') + '</h2>');
var ajaxURL = 'admin/EditorToolbar/ImageForm';
$.get(ajaxURL, {
action_callfieldmethod: "1",
fieldName: "FolderImages",
ajax: "1",
methodName: "getimages",
folderID: $("#Form_EditorToolbarImageForm_FolderID").val(),
searchText: $("#Form_EditorToolbarImageForm_getimagesSearch").val(),
cacheKillerDate: parseInt((new Date()).getTime()),
cacheKillerRand: parseInt(10000 * Math.random())
},
function(data) {
$("#FolderImages").html(data);
$("#FolderImages").each(function() {
Behaviour.apply(this);
})
});
}
}).submit();
});
});
})(jQuery);

View File

@ -646,12 +646,6 @@ function reselectImage(transport) {
$('Image').reapplyBehaviour();
this.addToTinyMCE = this.addToTinyMCE.bind(this);
var childNodes = $('Image').childNodes[0].childNodes;
var newImages = $A(childNodes).slice(childNodes.length - this.filesUploaded);
newImages.each(function(item) {
tinyMCEImageEnhancement.addToTinyMCE(item.childNodes[0]);
});
tinyMCEImageEnhancement.processInProgress = false;
}
function imageEditorClosed() {