Commit a31b8060 by Scott

Split up form elements to handle comment voting

parent fbec91bf
......@@ -654,6 +654,10 @@ function qa_page_q_comment_view($question, $parent, $comment, $usershtml, $formr
if ($comment['queued'])
$c_view['error'] = $comment['isbyuser'] ? qa_lang_html('question/c_your_waiting_approval') : qa_lang_html('question/c_waiting_your_approval');
$c_view['main_form_tags'] = 'method="post" action="' . qa_self_html() . '"';
$c_view['voting_form_hidden'] = array('code' => qa_get_form_security_code('vote'));
$c_view['buttons_form_hidden'] = array('code' => qa_get_form_security_code('buttons-' . $parent['postid']), 'qa_click' => '');
// Buttons for operating on this comment
......
......@@ -2134,8 +2134,9 @@ class qa_html_theme_base
if (!empty($q_view)) {
$this->output('<div class="qa-q-view' . (@$q_view['hidden'] ? ' qa-q-view-hidden' : '') . rtrim(' ' . @$q_view['classes']) . '"' . rtrim(' ' . @$q_view['tags']) . '>');
if (isset($q_view['main_form_tags']))
$this->output('<form ' . $q_view['main_form_tags'] . '>'); // form for voting buttons
if (isset($q_view['main_form_tags'])) {
$this->output('<form ' . $q_view['main_form_tags'] . '>'); // form for question voting buttons
}
$this->q_view_stats($q_view);
......@@ -2165,8 +2166,9 @@ class qa_html_theme_base
{
$this->output('<div class="qa-q-view-main">');
if (isset($q_view['main_form_tags']))
if (isset($q_view['main_form_tags'])) {
$this->output('<form ' . $q_view['main_form_tags'] . '>'); // form for buttons on question
}
$this->view_count($q_view);
$this->q_view_content($q_view);
......@@ -2176,13 +2178,13 @@ class qa_html_theme_base
$this->post_tags($q_view, 'qa-q-view');
$this->post_avatar_meta($q_view, 'qa-q-view');
$this->q_view_buttons($q_view);
$this->c_list(@$q_view['c_list'], 'qa-q-view');
if (isset($q_view['main_form_tags'])) {
$this->form_hidden_elements(@$q_view['buttons_form_hidden']);
$this->output('</form>');
}
$this->c_list(@$q_view['c_list'], 'qa-q-view');
$this->c_form(@$q_view['c_form']);
$this->output('</div> <!-- END qa-q-view-main -->');
......@@ -2290,8 +2292,9 @@ class qa_html_theme_base
$this->output('<div class="qa-a-list-item ' . $extraclass . '" ' . @$a_item['tags'] . '>');
if (isset($a_item['main_form_tags']))
$this->output('<form ' . $a_item['main_form_tags'] . '>'); // form for voting buttons
if (isset($a_item['main_form_tags'])) {
$this->output('<form ' . $a_item['main_form_tags'] . '>'); // form for answer voting buttons
}
$this->voting($a_item);
......@@ -2310,8 +2313,9 @@ class qa_html_theme_base
{
$this->output('<div class="qa-a-item-main">');
if (isset($a_item['main_form_tags']))
if (isset($a_item['main_form_tags'])) {
$this->output('<form ' . $a_item['main_form_tags'] . '>'); // form for buttons on answer
}
if ($a_item['hidden'])
$this->output('<div class="qa-a-item-hidden">');
......@@ -2328,13 +2332,12 @@ class qa_html_theme_base
$this->a_item_buttons($a_item);
$this->c_list(@$a_item['c_list'], 'qa-a-item');
if (isset($a_item['main_form_tags'])) {
$this->form_hidden_elements(@$a_item['buttons_form_hidden']);
$this->output('</form>');
}
$this->c_list(@$a_item['c_list'], 'qa-a-item');
$this->c_form(@$a_item['c_form']);
$this->output('</div> <!-- END qa-a-item-main -->');
......@@ -2400,7 +2403,17 @@ class qa_html_theme_base
$this->output('<div class="qa-c-list-item ' . $extraclass . '" ' . @$c_item['tags'] . '>');
if (isset($c_item['main_form_tags'])) {
$this->output('<form ' . $c_item['main_form_tags'] . '>'); // form for comment voting buttons
}
$this->voting($c_item);
if (isset($c_item['main_form_tags'])) {
$this->form_hidden_elements(@$c_item['voting_form_hidden']);
$this->output('</form>');
}
$this->c_item_main($c_item);
$this->c_item_clear();
......@@ -2409,6 +2422,10 @@ class qa_html_theme_base
public function c_item_main($c_item)
{
if (isset($c_item['main_form_tags'])) {
$this->output('<form ' . $c_item['main_form_tags'] . '>'); // form for buttons on comment
}
$this->error(@$c_item['error']);
if (isset($c_item['expand_tags']))
......@@ -2422,6 +2439,11 @@ class qa_html_theme_base
$this->post_avatar_meta($c_item, 'qa-c-item');
$this->c_item_buttons($c_item);
$this->output('</div>');
if (isset($c_item['main_form_tags'])) {
$this->form_hidden_elements(@$c_item['buttons_form_hidden']);
$this->output('</form>');
}
}
public function c_item_link($c_item)
......
......@@ -465,8 +465,9 @@ class qa_html_theme extends qa_html_theme_base
{
$this->output('<div class="qa-q-view-main">');
if (isset($q_view['main_form_tags']))
if (isset($q_view['main_form_tags'])) {
$this->output('<form ' . $q_view['main_form_tags'] . '>'); // form for buttons on question
}
$this->post_avatar_meta($q_view, 'qa-q-view');
$this->q_view_content($q_view);
......@@ -476,7 +477,6 @@ class qa_html_theme extends qa_html_theme_base
$this->post_tags($q_view, 'qa-q-view');
$this->q_view_buttons($q_view);
$this->c_list(isset($q_view['c_list']) ? $q_view['c_list'] : null, 'qa-q-view');
if (isset($q_view['main_form_tags'])) {
if (isset($q_view['buttons_form_hidden']))
......@@ -484,6 +484,7 @@ class qa_html_theme extends qa_html_theme_base
$this->output('</form>');
}
$this->c_list(isset($q_view['c_list']) ? $q_view['c_list'] : null, 'qa-q-view');
$this->c_form(isset($q_view['c_form']) ? $q_view['c_form'] : null);
$this->output('</div> <!-- END qa-q-view-main -->');
......@@ -512,47 +513,41 @@ class qa_html_theme extends qa_html_theme_base
{
$this->output('<div class="qa-a-item-main">');
$this->post_avatar_meta($a_item, 'qa-a-item');
if (isset($a_item['main_form_tags']))
if (isset($a_item['main_form_tags'])) {
$this->output('<form ' . $a_item['main_form_tags'] . '>'); // form for buttons on answer
}
$this->post_avatar_meta($a_item, 'qa-a-item');
if ($a_item['hidden'])
$answerState = 'hidden';
$this->output('<div class="qa-a-item-hidden">');
elseif ($a_item['selected'])
$answerState = 'selected';
else
$answerState = null;
if (isset($answerState))
$this->output('<div class="qa-a-item-' . $answerState . '">');
$this->output('<div class="qa-a-item-selected">');
$this->a_selection($a_item);
if (isset($a_item['error']))
$this->error($a_item['error']);
$this->a_item_content($a_item);
if (isset($answerState))
if ($a_item['hidden'] || $a_item['selected'])
$this->output('</div>');
$this->a_item_buttons($a_item);
if (isset($a_item['c_list']))
$this->c_list($a_item['c_list'], 'qa-a-item');
if (isset($a_item['main_form_tags'])) {
if (isset($a_item['buttons_form_hidden']))
$this->form_hidden_elements($a_item['buttons_form_hidden']);
$this->output('</form>');
}
$this->c_list(isset($a_item['c_list']) ? $a_item['c_list'] : null, 'qa-a-item');
$this->c_form(isset($a_item['c_form']) ? $a_item['c_form'] : null);
$this->output('</div> <!-- END qa-a-item-main -->');
}
/**
* Remove voting here
* Remove comment voting here
* @param array $c_item
*/
public function c_list_item($c_item)
......@@ -568,7 +563,7 @@ class qa_html_theme extends qa_html_theme_base
}
/**
* Move user whometa to top in comment
* Move user whometa to top in comment, add comment voting back in
*
* @since Snow 1.4
* @param array $c_item
......@@ -580,8 +575,21 @@ class qa_html_theme extends qa_html_theme_base
if (isset($c_item['error']))
$this->error($c_item['error']);
if (isset($c_item['main_form_tags'])) {
$this->output('<form ' . $c_item['main_form_tags'] . '>'); // form for comment voting buttons
}
$this->voting($c_item);
if (isset($c_item['main_form_tags'])) {
$this->form_hidden_elements(@$c_item['voting_form_hidden']);
$this->output('</form>');
}
if (isset($c_item['main_form_tags'])) {
$this->output('<form ' . $c_item['main_form_tags'] . '>'); // form for buttons on comment
}
if (isset($c_item['expand_tags']))
$this->c_item_expand($c_item);
elseif (isset($c_item['url']))
......@@ -592,6 +600,11 @@ class qa_html_theme extends qa_html_theme_base
$this->output('<div class="qa-c-item-footer">');
$this->c_item_buttons($c_item);
$this->output('</div>');
if (isset($c_item['main_form_tags'])) {
$this->form_hidden_elements(@$c_item['buttons_form_hidden']);
$this->output('</form>');
}
}
/**
......
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