Skip to content
Snippets Groups Projects
Commit 3af4750e authored by Jared Hancock's avatar Jared Hancock
Browse files

redactor: Hide image button if upload not supported

parent e632f5f6
No related branches found
No related tags found
No related merge requests found
......@@ -344,16 +344,16 @@ class DraftAjaxAPI extends AjaxController {
&& ($object = $thread->getObject())
&& ($thisstaff->canAccess($object))
) {
$union = ' UNION SELECT f.id, a.`type` FROM '.THREAD_TABLE.' t
$union = ' UNION SELECT f.id, a.`type`, a.`name` FROM '.THREAD_TABLE.' t
JOIN '.THREAD_ENTRY_TABLE.' th ON (th.thread_id = t.id)
JOIN '.ATTACHMENT_TABLE.' a ON (a.object_id = th.id AND a.`type` = \'H\')
JOIN '.FILE_TABLE.' f ON (a.file_id = f.id)
WHERE t.id='.db_input($_GET['threadId']);
WHERE a.`inline` = 1 AND t.id='.db_input($_GET['threadId']);
}
$sql = 'SELECT distinct f.id, COALESCE(a.type, f.ft) FROM '.FILE_TABLE
$sql = 'SELECT distinct f.id, COALESCE(a.type, f.ft), a.`name` FROM '.FILE_TABLE
.' f LEFT JOIN '.ATTACHMENT_TABLE.' a ON (a.file_id = f.id)
WHERE (a.`type` IN (\'C\', \'F\', \'T\', \'P\') OR f.ft = \'L\')'
WHERE ((a.`type` IN (\'C\', \'F\', \'T\', \'P\') AND a.`inline` = 1) OR f.ft = \'L\')'
.' AND f.`type` LIKE \'image/%\'';
if (!($res = db_query($sql.$union)))
Http::response(500, 'Unable to lookup files');
......@@ -367,15 +367,15 @@ class DraftAjaxAPI extends AjaxController {
'P' => __('Pages'),
'H' => __('This Thread'),
);
while (list($id, $type) = db_fetch_row($res)) {
$f = AttachmentFile::lookup($id);
while (list($id, $type, $name) = db_fetch_row($res)) {
$f = AttachmentFile::lookup((int) $id);
$url = $f->getDownloadUrl();
$files[] = array(
// Don't send special sizing for thread items 'cause they
// should be cached already by the client
'thumb'=>$url.($type != 'H' ? '&s=128' : ''),
'image'=>$url,
'title'=>$f->getName(),
'title'=>$name ?: $f->getName(),
'folder'=>$folders[$type]
);
}
......
......@@ -33,7 +33,7 @@ RedactorPlugins.draft = function() {
this.opts.imageUpload =
'ajax.php/draft/'+this.opts.draftId+'/attach';
}
else {
else if (this.$textarea.hasClass('draft')) {
// Just upload the file. A draft will be created automatically
// and will be configured locally in the afterUpateDraft()
this.opts.clipboardUploadUrl =
......@@ -43,23 +43,26 @@ RedactorPlugins.draft = function() {
if (autosave_url)
this.autosave.enable();
this.$draft_saved = $('<span>')
.addClass("pull-right draft-saved")
.hide()
.append($('<span>')
.text(__('Draft Saved')));
// Float the [Draft Saved] box with the toolbar
this.$toolbar.append(this.$draft_saved);
// Add [Delete Draft] button to the toolbar
if (this.opts.draftDelete) {
var trash = this.draft.deleteButton =
this.button.add('deleteDraft', __('Delete Draft'))
this.button.addCallback(trash, this.draft.deleteDraft);
this.button.setAwesome('deleteDraft', 'icon-trash');
trash.parent().addClass('pull-right');
trash.addClass('delete-draft');
if (!this.opts.draftId)
trash.hide();
if (this.$textarea.hasClass('draft')) {
this.$draft_saved = $('<span>')
.addClass("pull-right draft-saved")
.hide()
.append($('<span>')
.text(__('Draft Saved')));
// Float the [Draft Saved] box with the toolbar
this.$toolbar.append(this.$draft_saved);
// Add [Delete Draft] button to the toolbar
if (this.opts.draftDelete) {
var trash = this.draft.deleteButton =
this.button.add('deleteDraft', __('Delete Draft'))
this.button.addCallback(trash, this.draft.deleteDraft);
this.button.setAwesome('deleteDraft', 'icon-trash');
trash.parent().addClass('pull-right');
trash.addClass('delete-draft');
if (!this.opts.draftId)
trash.hide();
}
}
if (this.code.get())
this.$box.trigger('draft:recovered');
......@@ -247,7 +250,7 @@ $(function() {
var options = $.extend({
'air': el.hasClass('no-bar'),
'buttons': el.hasClass('no-bar')
? ['formatting', '|', 'bold', 'italic', 'underline', 'deleted', '|', 'unorderedlist', 'orderedlist', 'outdent', 'indent', '|', 'image']
? ['formatting', '|', 'bold', 'italic', 'underline', 'deleted', '|', 'unorderedlist', 'orderedlist', 'outdent', 'indent', '|', 'link', 'image']
: ['html', '|', 'formatting', '|', 'bold',
'italic', 'underline', 'deleted', '|', 'unorderedlist',
'orderedlist', 'outdent', 'indent', '|', 'image', 'video',
......@@ -261,7 +264,7 @@ $(function() {
'plugins': el.hasClass('no-bar')
? ['imagemanager','definedlinks']
: ['imagemanager','imageannotate','table','video','definedlinks','autolock'],
'imageUpload': 'tbd',
'imageUpload': el.hasClass('draft'),
'imageManagerJson': 'ajax.php/draft/images/browse',
'syncBeforeCallback': captureImageSizes,
'linebreaks': true,
......
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