Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Q
question2answer
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
outils
question2answer
Commits
79943c03
Commit
79943c03
authored
Apr 09, 2015
by
Scott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix missing smiley links in WYSIWYG plugin options
parent
4d8804c5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
63 additions
and
5 deletions
+63
-5
qa-plugin.php
qa-plugin/wysiwyg-editor/qa-plugin.php
+2
-0
qa-wysiwyg-ajax.php
qa-plugin/wysiwyg-editor/qa-wysiwyg-ajax.php
+22
-5
qa-wysiwyg-editor.php
qa-plugin/wysiwyg-editor/qa-wysiwyg-editor.php
+39
-0
No files found.
qa-plugin/wysiwyg-editor/qa-plugin.php
View file @
79943c03
...
...
@@ -42,3 +42,5 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
qa_register_plugin_module
(
'editor'
,
'qa-wysiwyg-editor.php'
,
'qa_wysiwyg_editor'
,
'WYSIWYG Editor'
);
qa_register_plugin_module
(
'page'
,
'qa-wysiwyg-upload.php'
,
'qa_wysiwyg_upload'
,
'WYSIWYG Upload'
);
qa_register_plugin_module
(
'page'
,
'qa-wysiwyg-ajax.php'
,
'qa_wysiwyg_ajax'
,
'WYSIWYG Editor AJAX handler'
);
qa-plugin/wysiwyg-editor/qa-wysiwyg-ajax.php
View file @
79943c03
...
...
@@ -31,16 +31,33 @@ class qa_wysiwyg_ajax
// Fix path to WYSIWYG editor smilies
public
function
process_request
(
$request
)
{
// todo: lock tables?
// echo '<pre>', print_r(qa_db_list_tables(), true), '</pre>';
require_once
QA_INCLUDE_DIR
.
'qa-app-posts.php'
;
// smiley replacement regexes
$rxSearch
=
'#<(img|a)([^>]+)(src|href)="([^"]+)/wysiwyg-editor/plugins/smiley/images/([^"]+)"#'
;
$rxReplace
=
'<$1$2$3="$4/wysiwyg-editor/ckeditor/plugins/smiley/images/$5"'
;
qa_suspend_event_reports
(
true
);
// avoid infinite loop
$sql
=
'SELECT postid, title, content FROM ^posts WHERE format="html" AND content LIKE "%/wysiwyg-editor/plugins/smiley/images/%" LIMIT 5'
;
$result
=
qa_db_query_sub
(
$sql
);
while
((
$post
=
qa_db_read_one_assoc
(
$result
,
true
))
!==
null
)
{
$search
=
'#<(img|a)([^>]+)(src|href)="([^"]+)/wysiwyg-editor/plugins/smiley/images/([^"]+)"#'
;
$replace
=
'<$1$2$3="$4/wysiwyg-editor/ckeditor/plugins/smiley/images/$5"'
;
$newcontent
=
preg_replace
(
$search
,
$replace
,
$post
[
'content'
]);
// prevent race conditions
$locks
=
array
(
'posts'
,
'categories'
,
'users'
,
'users AS lastusers'
,
'userpoints'
,
'words'
,
'titlewords'
,
'contentwords'
,
'tagwords'
,
'words AS x'
,
'posttags'
,
'options'
);
foreach
(
$locks
as
&
$tbl
)
$tbl
=
'^'
.
$tbl
.
' WRITE'
;
qa_db_query_sub
(
'LOCK TABLES '
.
implode
(
','
,
$locks
));
$numPosts
=
0
;
while
((
$post
=
qa_db_read_one_assoc
(
$result
,
true
))
!==
null
)
{
$newcontent
=
preg_replace
(
$rxSearch
,
$rxReplace
,
$post
[
'content'
]);
qa_post_set_content
(
$post
[
'postid'
],
$post
[
'title'
],
$newcontent
);
$numPosts
++
;
}
qa_db_query_raw
(
'UNLOCK TABLES'
);
qa_suspend_event_reports
(
false
);
echo
$numPosts
;
}
}
qa-plugin/wysiwyg-editor/qa-wysiwyg-editor.php
View file @
79943c03
...
...
@@ -57,6 +57,40 @@ class qa_wysiwyg_editor
'wysiwyg_editor_upload_max_size_display'
=>
'wysiwyg_editor_upload_images_field'
,
));
// handle AJAX requests to 'wysiwyg-editor-ajax'
$js
=
array
(
'function wysiwyg_editor_ajax(totalEdited) {'
,
' $.ajax({'
,
' url: '
.
qa_js
(
qa_path
(
'wysiwyg-editor-ajax'
))
.
','
,
' success: function(response) {'
,
' var postsEdited = parseInt(response, 10);'
,
' var $btn = $("#wysiwyg_editor_ajax");'
,
' if (isNaN(postsEdited)) {'
,
' $btn.text("ERROR");'
,
' }'
,
' else if (postsEdited < 5) {'
,
' $btn.text("All posts converted.");'
,
' }'
,
' else {'
,
' totalEdited += postsEdited;'
,
' $btn.text("Updating posts... " + totalEdited)'
,
' window.setTimeout(function() {'
,
' wysiwyg_editor_ajax(totalEdited);'
,
' }, 1000);'
,
' }'
,
' }'
,
' });'
,
'}'
,
'$("#wysiwyg_editor_ajax").click(function() {'
,
' wysiwyg_editor_ajax(0);'
,
' return false;'
,
'});'
,
);
$ajaxHtml
=
'Update broken images from old CKeditor Smilie plugin: '
.
'<button id="wysiwyg_editor_ajax">click here</button> '
.
'<script>'
.
implode
(
"
\n
"
,
$js
)
.
'</script>'
;
return
array
(
'ok'
=>
$saved
?
'WYSIWYG editor settings saved'
:
null
,
...
...
@@ -84,6 +118,11 @@ class qa_wysiwyg_editor
'value'
=>
$this
->
bytes_to_mega_html
(
qa_opt
(
'wysiwyg_editor_upload_max_size'
)),
'tags'
=>
'name="wysiwyg_editor_upload_max_size_field"'
,
),
array
(
'type'
=>
'custom'
,
'html'
=>
$ajaxHtml
,
),
),
'buttons'
=>
array
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment