Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
11 / 11
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
TagProposalsRenderer
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
1
 renderItem
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3App::uses('DataTableRenderer', 'Utility');
4
5class TagProposalsRenderer extends DataTableRenderer
6{
7    public function __construct($urlParams)
8    {
9        $this->count = Util::query("SELECT COUNT(DISTINCT tsumego_id) as total FROM sgf WHERE accepted = false")[0]['total'];
10        parent::__construct($urlParams, 'tag_proposals_page', 'Tag proposals');
11        $this->data = Util::query("
12SELECT
13    tag.id as tag_id,
14    tag.name as tag_name,
15    user.name as user_name,
16    user.id as user_id,
17    user.rating as user_rating
18FROM
19    tag
20    JOIN user ON user.id = tag.user_id
21WHERE approved = 0
22LIMIT " . self::$PAGE_SIZE . "
23OFFSET " . $this->offset);
24    }
25
26    public function renderItem(int $index, array $item): void
27    {
28        echo '<td class="adminpanel-table-text">' . User::renderLink($item) . ' made a proposal for <a href="/tags/view' . $item['tag_id'] . '">' . $item['tag_name'] . '</a>:</td>';
29        echo '<td>';
30        echo '<a class="new-button-default2" href="/tags/acceptTagProposal/' . $item['tag_id'] . '" id="tag-accept-' . $item['tag_id'] . '">Accept</a>';
31        echo '<a class="new-button-default2" href="/tags/rejectTagProposal/' . $item['tag_id'] . '" id="tag-reject-' . $item['tag_id'] . '">Reject</a>';
32        echo '</td>';
33    }
34}