Unverified Commit b0ccfa00 by Scott Committed by GitHub

Merge pull request #664 from pupi1985/patch-111

Refactor WYSIWYG file upload
parents 1d36caf1 fbe6bf07
......@@ -25,7 +25,7 @@ class qa_wysiwyg_upload
{
public function match_request($request)
{
return ($request == 'wysiwyg-editor-upload');
return $request === 'wysiwyg-editor-upload';
}
public function process_request($request)
......@@ -34,24 +34,33 @@ class qa_wysiwyg_upload
$url = '';
if (is_array($_FILES) && count($_FILES)) {
if (!qa_opt('wysiwyg_editor_upload_images'))
$message = qa_lang('users/no_permission');
require_once QA_INCLUDE_DIR.'app/upload.php';
if (qa_opt('wysiwyg_editor_upload_images')) {
require_once QA_INCLUDE_DIR . 'app/upload.php';
$upload = qa_upload_file_one(
qa_opt('wysiwyg_editor_upload_max_size'),
qa_get('qa_only_image') || !qa_opt('wysiwyg_editor_upload_all'),
qa_get('qa_only_image') ? 600 : null, // max width if it's an image upload
null // no max height
);
$onlyImage = qa_get('qa_only_image');
$upload = qa_upload_file_one(
qa_opt('wysiwyg_editor_upload_max_size'),
$onlyImage || !qa_opt('wysiwyg_editor_upload_all'),
$onlyImage ? 600 : null, // max width if it's an image upload
null // no max height
);
$message = @$upload['error'];
$url = @$upload['bloburl'];
if (isset($upload['error'])) {
$message = $upload['error'];
} else {
$url = $upload['bloburl'];
}
} else {
$message = qa_lang('users/no_permission');
}
}
echo "<script>window.parent.CKEDITOR.tools.callFunction(".qa_js(qa_get('CKEditorFuncNum')).
", ".qa_js($url).", ".qa_js($message).");</script>";
echo sprintf(
'<script>window.parent.CKEDITOR.tools.callFunction(%s, %s, %s);</script>',
qa_js(qa_get('CKEditorFuncNum')),
qa_js($url),
qa_js($message)
);
return null;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment