-
Notifications
You must be signed in to change notification settings - Fork 1
/
qa-fa-layer.php
46 lines (35 loc) · 1.34 KB
/
qa-fa-layer.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
class qa_html_theme_layer extends qa_html_theme_base {
var $featured_questions;
function doctype() {
$featured = qa_opt ( 'featured_answer_list' );
$featured_answers = array();
if (qa_opt ( 'fa_enabled' ) && array_key_exists ( 'q_view', $this->content )) {
$featured = explode ( ',', $featured );
foreach ( $this->content ['a_list'] ['as'] as $idx => $answer ) {
if (in_array ( $answer ['raw'] ['handle'], $featured )) {
$featured_answers[$idx] = $answer;
unset ($featured_answers[$idx]['vote_view']);
unset ($this->content['a_list']['as'][$idx]);
array_unshift ( $this->content ['a_list'] ['as'], $featured_answers[$idx] );
}
}
// Used in q_list() function below to add css to the first featured answers.
$this->featured_questions = count ( $featured_answers );
}
}
// theme replacement functions
function a_list($a_list) {
if (isset ( $a_list ['as'] ))
foreach ( $a_list ['as'] as $idx => $q_item )
if ($idx < $this->featured_questions)
$a_list ['as'] [$idx] ['classes'] = @$a_list ['as'] [$idx] ['classes'] . ' qa-a-list-answer-featured ';
else
break;
qa_html_theme_base::a_list ( $a_list );
}
function head_custom() {
$this->output ( '<style>', qa_opt ( 'featured_answer_css' ), '</style>' );
qa_html_theme_base::head_custom ();
}
}