mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
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:
parent
2d2253360d
commit
80c69abdb8
@ -198,6 +198,11 @@ class HtmlEditorField_Toolbar extends RequestHandler {
|
|||||||
|
|
||||||
function __construct($controller, $name) {
|
function __construct($controller, $name) {
|
||||||
parent::__construct();
|
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->controller = $controller;
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
@ -210,9 +215,6 @@ class HtmlEditorField_Toolbar extends RequestHandler {
|
|||||||
* @return Form
|
* @return Form
|
||||||
*/
|
*/
|
||||||
function LinkForm() {
|
function LinkForm() {
|
||||||
Requirements::javascript(SAPPHIRE_DIR . "/thirdparty/behaviour/behaviour.js");
|
|
||||||
Requirements::javascript(SAPPHIRE_DIR . "/javascript/tiny_mce_improvements.js");
|
|
||||||
|
|
||||||
$form = new Form(
|
$form = new Form(
|
||||||
$this->controller,
|
$this->controller,
|
||||||
"{$this->name}/LinkForm",
|
"{$this->name}/LinkForm",
|
||||||
@ -256,37 +258,17 @@ class HtmlEditorField_Toolbar extends RequestHandler {
|
|||||||
* @return Form
|
* @return Form
|
||||||
*/
|
*/
|
||||||
function ImageForm() {
|
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(
|
$form = new Form(
|
||||||
$this->controller,
|
$this->controller,
|
||||||
"{$this->name}/ImageForm",
|
"{$this->name}/ImageForm",
|
||||||
new FieldSet(
|
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 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 TreeDropdownField('FolderID', _t('HtmlEditorField.FOLDER', 'Folder'), 'Folder'),
|
||||||
new LiteralField('AddFolderOrUpload',
|
new CompositeField(new FieldSet(
|
||||||
'<div id="AddFolderGroup" style="display: none;">
|
new LiteralField('ShowUpload', '<p class="showUploadField"><a href="#">'. _t('HtmlEditorField.SHOWUPLOADFORM', 'Upload File') .'</a></p>'),
|
||||||
<a style="" href="#" id="AddFolder" class="link">' . _t('HtmlEditorField.CREATEFOLDER','Create Folder') . '</a>
|
new FileField("Files[0]" , _t('AssetAdmin.CHOOSEFILE','Choose file: ')),
|
||||||
<input style="display: none; margin-left: 2px; width: 94px;" id="NewFolderName" class="addFolder" type="text">
|
new LiteralField('Response', '<div id="UploadFormResponse"></div>')
|
||||||
<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 TextField('getimagesSearch', _t('HtmlEditorField.SEARCHFILENAME', 'Search by file name')),
|
new TextField('getimagesSearch', _t('HtmlEditorField.SEARCHFILENAME', 'Search by file name')),
|
||||||
new ThumbnailStripField('FolderImages', 'FolderID', 'getimages'),
|
new ThumbnailStripField('FolderImages', 'FolderID', 'getimages'),
|
||||||
new TextField('AltText', _t('HtmlEditorField.IMAGEALTTEXT', 'Alternative text (alt) - shown if image cannot be displayed'), '', 80),
|
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() {
|
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(
|
$form = new Form(
|
||||||
$this->controller,
|
$this->controller,
|
||||||
"{$this->name}/FlashForm",
|
"{$this->name}/FlashForm",
|
||||||
|
@ -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",
|
|
||||||
|
|
||||||
theme_advanced_layout_manager: "SimpleLayout",
|
(function($) {
|
||||||
theme_advanced_toolbar_location : "top",
|
$(document).ready(function() {
|
||||||
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 : "",
|
|
||||||
|
|
||||||
safari_warning : false,
|
$("#Form_EditorToolbarImageForm .showUploadField a").click(function() {
|
||||||
relative_urls : true,
|
if($(this).hasClass("showing")) {
|
||||||
verify_html : true
|
$("#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();
|
||||||
|
|
||||||
|
$("#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);
|
6
javascript/tiny_mce_improvements.js
vendored
6
javascript/tiny_mce_improvements.js
vendored
@ -646,12 +646,6 @@ function reselectImage(transport) {
|
|||||||
|
|
||||||
$('Image').reapplyBehaviour();
|
$('Image').reapplyBehaviour();
|
||||||
this.addToTinyMCE = this.addToTinyMCE.bind(this);
|
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() {
|
function imageEditorClosed() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user