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 ...@@ -25,7 +25,7 @@ class qa_wysiwyg_upload
{ {
public function match_request($request) public function match_request($request)
{ {
return ($request == 'wysiwyg-editor-upload'); return $request === 'wysiwyg-editor-upload';
} }
public function process_request($request) public function process_request($request)
...@@ -34,24 +34,33 @@ class qa_wysiwyg_upload ...@@ -34,24 +34,33 @@ class qa_wysiwyg_upload
$url = ''; $url = '';
if (is_array($_FILES) && count($_FILES)) { if (is_array($_FILES) && count($_FILES)) {
if (!qa_opt('wysiwyg_editor_upload_images')) if (qa_opt('wysiwyg_editor_upload_images')) {
$message = qa_lang('users/no_permission'); require_once QA_INCLUDE_DIR . 'app/upload.php';
require_once QA_INCLUDE_DIR.'app/upload.php';
$upload = qa_upload_file_one( $onlyImage = qa_get('qa_only_image');
qa_opt('wysiwyg_editor_upload_max_size'), $upload = qa_upload_file_one(
qa_get('qa_only_image') || !qa_opt('wysiwyg_editor_upload_all'), qa_opt('wysiwyg_editor_upload_max_size'),
qa_get('qa_only_image') ? 600 : null, // max width if it's an image upload $onlyImage || !qa_opt('wysiwyg_editor_upload_all'),
null // no max height $onlyImage ? 600 : null, // max width if it's an image upload
); null // no max height
);
$message = @$upload['error']; if (isset($upload['error'])) {
$url = @$upload['bloburl']; $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')). echo sprintf(
", ".qa_js($url).", ".qa_js($message).");</script>"; '<script>window.parent.CKEDITOR.tools.callFunction(%s, %s, %s);</script>',
qa_js(qa_get('CKEditorFuncNum')),
qa_js($url),
qa_js($message)
);
return null; 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