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
83409a08
Commit
83409a08
authored
Jun 16, 2014
by
pupi1985
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor formatting and SQL improvements to mouseover plugin.
parent
b311cb1a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
28 deletions
+27
-28
qa-mouseover-admin-form.php
qa-plugin/mouseover-layer/qa-mouseover-admin-form.php
+6
-7
qa-mouseover-layer.php
qa-plugin/mouseover-layer/qa-mouseover-layer.php
+21
-21
No files found.
qa-plugin/mouseover-layer/qa-mouseover-admin-form.php
View file @
83409a08
...
...
@@ -28,19 +28,18 @@
public
function
option_default
(
$option
)
{
if
(
$option
==
'mouseover_content_max_len'
)
if
(
$option
===
'mouseover_content_max_len'
)
return
480
;
}
public
function
admin_form
(
&
$qa_content
)
{
$saved
=
false
;
$saved
=
qa_clicked
(
'mouseover_save_button'
)
;
if
(
qa_clicked
(
'mouseover_save_button'
))
{
qa_opt
(
'mouseover_content_on'
,
(
int
)
qa_post_text
(
'mouseover_content_on_field'
));
qa_opt
(
'mouseover_content_max_len'
,
(
int
)
qa_post_text
(
'mouseover_content_max_len_field'
));
$saved
=
true
;
if
(
$saved
)
{
qa_opt
(
'mouseover_content_on'
,
(
int
)
qa_post_text
(
'mouseover_content_on_field'
));
qa_opt
(
'mouseover_content_max_len'
,
(
int
)
qa_post_text
(
'mouseover_content_max_len_field'
));
}
qa_set_display_rules
(
$qa_content
,
array
(
...
...
@@ -63,7 +62,7 @@
'label'
=>
'Maximum length of preview:'
,
'suffix'
=>
'characters'
,
'type'
=>
'number'
,
'value'
=>
(
int
)
qa_opt
(
'mouseover_content_max_len'
),
'value'
=>
(
int
)
qa_opt
(
'mouseover_content_max_len'
),
'tags'
=>
'name="mouseover_content_max_len_field"'
,
),
),
...
...
qa-plugin/mouseover-layer/qa-mouseover-layer.php
View file @
83409a08
...
...
@@ -28,38 +28,38 @@
public
function
q_list
(
$q_list
)
{
if
(
count
(
@
$q_list
[
'qs'
])
&&
qa_opt
(
'mouseover_content_on'
))
{
// first check it is not an empty list and the feature is turned on
if
(
!
empty
(
$q_list
[
'qs'
])
&&
qa_opt
(
'mouseover_content_on'
))
{
// first check it is not an empty list and the feature is turned on
//
Collect the question ids of all items in the question list (so we can do this in one DB query)
//
Collect the question ids of all items in the question list (so we can do this in one DB query)
$postids
=
array
();
$postids
=
array
();
foreach
(
$q_list
[
'qs'
]
as
$question
)
if
(
isset
(
$question
[
'raw'
][
'postid'
]))
$postids
[]
=
$question
[
'raw'
][
'postid'
];
if
(
isset
(
$question
[
'raw'
][
'postid'
]))
$postids
[]
=
$question
[
'raw'
][
'postid'
];
if
(
count
(
$postids
))
{
if
(
!
empty
(
$postids
))
{
// Retrieve the content for these questions from the database and put into an array
// Retrieve the content for these questions from the database and put into an array fetching
// the minimal amount of characters needed to determine the string should be shortened or not
$result
=
qa_db_query_sub
(
'SELECT postid, content, format FROM ^posts WHERE postid IN (#)'
,
$postids
);
$postinfo
=
qa_db_read_all_assoc
(
$result
,
'postid'
);
$maxlength
=
qa_opt
(
'mouseover_content_max_len'
);
$result
=
qa_db_query_sub
(
'SELECT postid, LEFT(content, #) content, format FROM ^posts WHERE postid IN (#)'
,
$maxlength
+
1
,
$postids
);
$postinfo
=
qa_db_read_all_assoc
(
$result
,
'postid'
);
//
Get the regular expression fragment to use for blocked words and the maximum length of content to show
//
Get the regular expression fragment to use for blocked words and the maximum length of content to show
$blockwordspreg
=
qa_get_block_words_preg
();
$maxlength
=
qa_opt
(
'mouseover_content_max_len'
);
$blockwordspreg
=
qa_get_block_words_preg
();
//
Now add the popup to the title for each question
//
Now add the popup to the title for each question
foreach
(
$q_list
[
'qs'
]
as
$index
=>
$question
)
{
$thispost
=@
$postinfo
[
$question
[
'raw'
][
'postid'
]];
if
(
isset
(
$thispost
))
{
$text
=
qa_viewer_text
(
$thispost
[
'content'
],
$thispost
[
'format'
],
array
(
'blockwordspreg'
=>
$blockwordspreg
)
);
$t
ext
=
qa_shorten_string_line
(
$text
,
$maxlength
)
;
$q_list
[
'qs'
][
$index
][
'title'
]
=
'<span title="'
.
qa_html
(
$text
)
.
'">'
.@
$question
[
'title'
]
.
'</span>'
;
foreach
(
$q_list
[
'qs'
]
as
$index
=>
$question
)
if
(
isset
(
$postinfo
[
$question
[
'raw'
][
'postid'
]]))
{
$thispost
=
$postinfo
[
$question
[
'raw'
][
'postid'
]];
$text
=
qa_viewer_text
(
$thispost
[
'content'
],
$thispost
[
'format'
],
array
(
'blockwordspreg'
=>
$blockwordspreg
));
$text
=
qa_shorten_string_line
(
$text
,
$maxlength
);
$t
itle
=
isset
(
$question
[
'title'
])
?
$question
[
'title'
]
:
''
;
$q_list
[
'qs'
][
$index
][
'title'
]
=
sprintf
(
'<span title="%s">%s</span>'
,
qa_html
(
$text
),
$title
)
;
}
}
}
}
...
...
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