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
de40daa8
Commit
de40daa8
authored
Jun 17, 2015
by
pupi1985
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor refactoring to qa-layer-voters-flaggers.php
parent
44fb91d9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
33 deletions
+40
-33
qa-layer-voters-flaggers.php
qa-include/plugins/qa-layer-voters-flaggers.php
+40
-33
No files found.
qa-include/plugins/qa-layer-voters-flaggers.php
View file @
de40daa8
...
...
@@ -31,10 +31,11 @@ class qa_html_theme_layer extends qa_html_theme_base
public
function
main
()
{
foreach
(
$this
->
content
as
$key
=>
$part
)
{
if
(
strpos
(
$key
,
'q_list'
)
===
0
)
$this
->
queue_raw_posts_voters_flaggers
(
@
$part
[
'qs'
]);
if
(
strpos
(
$key
,
'q_list'
)
===
0
)
{
if
(
isset
(
$part
[
'qs'
]))
$this
->
queue_raw_posts_voters_flaggers
(
$part
[
'qs'
]);
elseif
(
strpos
(
$key
,
'q_view'
)
===
0
)
{
}
elseif
(
strpos
(
$key
,
'q_view'
)
===
0
)
{
$this
->
queue_post_voters_flaggers
(
$part
[
'raw'
]);
$this
->
queue_raw_posts_voters_flaggers
(
$part
[
'c_list'
][
'cs'
]);
...
...
@@ -42,8 +43,10 @@ class qa_html_theme_layer extends qa_html_theme_base
if
(
!
empty
(
$part
))
{
$this
->
queue_raw_posts_voters_flaggers
(
$part
[
'as'
]);
foreach
(
$part
[
'as'
]
as
$a_item
)
$this
->
queue_raw_posts_voters_flaggers
(
@
$a_item
[
'c_list'
][
'cs'
]);
foreach
(
$part
[
'as'
]
as
$a_item
)
{
if
(
isset
(
$a_item
[
'c_list'
][
'cs'
]))
$this
->
queue_raw_posts_voters_flaggers
(
$a_item
[
'c_list'
][
'cs'
]);
}
}
}
}
...
...
@@ -80,37 +83,42 @@ class qa_html_theme_layer extends qa_html_theme_base
public
function
vote_count
(
$post
)
{
$votersflaggers
=
$this
->
get_post_voters_flaggers
(
$post
[
'raw'
],
@
$post
[
'vote_opostid'
]
?
$post
[
'raw'
][
'opostid'
]
:
$post
[
'raw'
][
'postid'
]);
$tooltip
=
''
;
$postid
=
isset
(
$post
[
'vote_opostid'
])
&&
$post
[
'vote_opostid'
]
?
$post
[
'raw'
][
'opostid'
]
:
$post
[
'raw'
][
'postid'
];
$votersflaggers
=
$this
->
get_post_voters_flaggers
(
$post
[
'raw'
],
$postid
);
if
(
isset
(
$votersflaggers
))
{
$uphandles
=
''
;
$downhandles
=
''
;
$uphandles
=
array
()
;
$downhandles
=
array
()
;
foreach
(
$votersflaggers
as
$voterflagger
)
{
if
(
$voterflagger
[
'vote'
]
>
0
)
$uphandles
.=
(
strlen
(
$uphandles
)
?
', '
:
''
)
.
qa_html
(
$voterflagger
[
'handle'
]);
if
(
$voterflagger
[
'vote'
]
!=
0
)
{
$newflagger
=
qa_html
(
$voterflagger
[
'handle'
]);
if
(
$voterflagger
[
'vote'
]
>
0
)
$uphandles
[]
=
$newflagger
;
else
// if ($voterflagger['vote'] < 0)
$downhandles
[]
=
$newflagger
;
}
}
if
(
$voterflagger
[
'vote'
]
<
0
)
$downhandles
.=
(
strlen
(
$downhandles
)
?
', '
:
''
)
.
qa_html
(
$voterflagger
[
'handle'
]);
$tooltip
=
trim
(
(
empty
(
$uphandles
)
?
''
:
'↑ '
.
implode
(
', '
,
$uphandles
))
.
"
\n\n
"
.
(
empty
(
$downhandles
)
?
''
:
'↓ '
.
implode
(
', '
,
$downhandles
))
);
$tooltip
=
trim
((
strlen
(
$uphandles
)
?
(
'↑ '
.
$uphandles
)
:
''
)
.
"
\n\n
"
.
(
strlen
(
$downhandles
)
?
(
'↓ '
.
$downhandles
)
:
''
));
}
$post
[
'vote_count_tags'
]
=
sprintf
(
'%s title="%s"'
,
isset
(
$post
[
'vote_count_tags'
])
?
$post
[
'vote_count_tags'
]
:
''
,
$tooltip
);
}
$post
[
'vote_count_tags'
]
=
@
$post
[
'vote_count_tags'
]
.
' title="'
.
$tooltip
.
'"'
;
parent
::
vote_count
(
$post
);
}
public
function
post_meta_flags
(
$post
,
$class
)
{
$postid
=
@
$post
[
'raw'
][
'opostid'
];
if
(
!
isset
(
$postid
))
$postid
=
@
$post
[
'raw'
][
'postid'
];
if
(
isset
(
$post
[
'raw'
][
'opostid'
]))
$postid
=
$post
[
'raw'
][
'opostid'
];
elseif
(
isset
(
$post
[
'raw'
][
'postid'
]))
$postid
=
$post
[
'raw'
][
'postid'
];
$
tooltip
=
''
;
$
flaggers
=
array
()
;
if
(
isset
(
$postid
))
{
$votersflaggers
=
$this
->
get_post_voters_flaggers
(
$post
,
$postid
);
...
...
@@ -118,17 +126,17 @@ class qa_html_theme_layer extends qa_html_theme_base
if
(
isset
(
$votersflaggers
))
{
foreach
(
$votersflaggers
as
$voterflagger
)
{
if
(
$voterflagger
[
'flag'
]
>
0
)
$
tooltip
.=
(
strlen
(
$tooltip
)
?
', '
:
''
)
.
qa_html
(
$voterflagger
[
'handle'
]);
$
flaggers
[]
=
qa_html
(
$voterflagger
[
'handle'
]);
}
}
}
if
(
strlen
(
$tooltip
))
$this
->
output
(
'<span title="⚑ '
.
$tooltip
.
'">'
);
if
(
!
empty
(
$flaggers
))
$this
->
output
(
'<span title="⚑ '
.
implode
(
', '
,
$flaggers
)
.
'">'
);
parent
::
post_meta_flags
(
$post
,
$class
);
if
(
strlen
(
$tooltip
))
if
(
!
empty
(
$flaggers
))
$this
->
output
(
'</span>'
);
}
...
...
@@ -142,11 +150,10 @@ class qa_html_theme_layer extends qa_html_theme_base
public
function
queue_post_voters_flaggers
(
$post
)
{
if
(
!
qa_user_post_permit_error
(
'permit_view_voters_flaggers'
,
$post
))
{
$postids
=
array
(
@
$post
[
'postid'
],
@
$post
[
'opostid'
]);
// opostid can be relevant for flags
foreach
(
$postids
as
$postid
)
{
if
(
isset
(
$postid
)
&&
!
isset
(
$this
->
qa_voters_flaggers_cache
[
$postid
]))
$this
->
qa_voters_flaggers_queue
[
$postid
]
=
true
;
$postkeys
=
array
(
'postid'
,
'opostid'
);
foreach
(
$postkeys
as
$key
)
{
if
(
isset
(
$post
[
$key
])
&&
!
isset
(
$this
->
qa_voters_flaggers_cache
[
$post
[
$key
]]))
$this
->
qa_voters_flaggers_queue
[
$post
[
$key
]]
=
true
;
}
}
}
...
...
@@ -188,7 +195,7 @@ class qa_html_theme_layer extends qa_html_theme_base
$useridhandles
=
qa_get_public_from_userids
(
array_keys
(
$keyuserids
));
foreach
(
$newvotersflaggers
as
$index
=>
$voterflagger
)
$newvotersflaggers
[
$index
][
'handle'
]
=
@
$useridhandles
[
$voterflagger
[
'userid'
]]
;
$newvotersflaggers
[
$index
][
'handle'
]
=
isset
(
$useridhandles
[
$voterflagger
[
'userid'
]])
?
$useridhandles
[
$voterflagger
[
'userid'
]]
:
null
;
}
foreach
(
$newvotersflaggers
as
$voterflagger
)
...
...
@@ -211,7 +218,7 @@ class qa_html_theme_layer extends qa_html_theme_base
$this
->
retrieve_queued_voters_flaggers
();
}
$votersflaggers
=
@
$this
->
qa_voters_flaggers_cache
[
$postid
]
;
$votersflaggers
=
isset
(
$this
->
qa_voters_flaggers_cache
[
$postid
])
?
$this
->
qa_voters_flaggers_cache
[
$postid
]
:
null
;
if
(
isset
(
$votersflaggers
))
qa_sort_by
(
$votersflaggers
,
'handle'
);
...
...
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