1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace VideoGamesRecords\DwhBundle\Traits\Top; |
4
|
|
|
|
5
|
|
|
trait GetHtmlTopGameTrait |
6
|
|
|
{ |
7
|
|
|
/** |
8
|
|
|
* @param $data |
9
|
|
|
* @param string $locale |
10
|
|
|
* @return string |
11
|
|
|
*/ |
12
|
|
|
private function getHtmlTopGame($data, string $locale = 'en'): string |
13
|
|
|
{ |
14
|
|
|
$html = ''; |
15
|
|
|
|
16
|
|
|
if (count($data['list']) > 0) { |
17
|
|
|
$html .= '<div class="article-top article-top__games">'; |
18
|
|
|
|
19
|
|
|
for ($i = 0; $i <= 2; $i++) { |
20
|
|
|
if (array_key_exists($i, $data['list'])) { |
21
|
|
|
$html .= sprintf( |
22
|
|
|
'<a href="%s"><img src="https://backoffice.video-games-records.com/game/%d/picture" alt="%s" class="article-top__game" /></a>', |
23
|
|
|
'/' . $locale . '/' . $data['list'][$i]['game']->getUrl(), |
24
|
|
|
$data['list'][$i]['game']->getId(), |
25
|
|
|
$data['list'][$i]['game']->getName() |
26
|
|
|
); |
27
|
|
|
} |
28
|
|
|
if ($i == 0) { |
29
|
|
|
$html .= '<br />'; |
30
|
|
|
} |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
$html .= '<table class="article-top__table">'; |
34
|
|
|
$html .= '<thead>'; |
35
|
|
|
$html .= '<tr>'; |
36
|
|
|
$html .= '<th scope="col"><abbr title="Rank">#</abbr></th>'; |
37
|
|
|
$html .= '<th scope="col">Game</th>'; |
38
|
|
|
$html .= '<th scope="col">Posts submitted</th>'; |
39
|
|
|
$html .= '<th scope="col">Position change</th>'; |
40
|
|
|
$html .= '</tr>'; |
41
|
|
|
$html .= '</tr>'; |
42
|
|
|
$html .= '<tbody>'; |
43
|
|
|
|
44
|
|
|
foreach ($data['list'] as $row) { |
45
|
|
|
$html .= sprintf( |
46
|
|
|
$this->getHtmLine(), |
|
|
|
|
47
|
|
|
$row['rank'], |
48
|
|
|
'/' . $locale . '/' . $row['game']->getUrl(), |
49
|
|
|
$row['game']->getName(), |
50
|
|
|
$row['nb'], |
51
|
|
|
$this->diff($row, count($data['list'])) |
|
|
|
|
52
|
|
|
); |
53
|
|
|
} |
54
|
|
|
if ($data['nbTotalPost'] > $data['nbPostFromList']) { |
55
|
|
|
$html .= sprintf( |
56
|
|
|
$this->getHtmlBottom1(), |
|
|
|
|
57
|
|
|
count($data['list']) + 1, |
58
|
|
|
$data['nbItem'], |
59
|
|
|
$data['nbTotalPost'] - $data['nbPostFromList'] |
60
|
|
|
); |
61
|
|
|
} |
62
|
|
|
$html .= sprintf($this->getHtmlBottom2(), $data['nbTotalPost']); |
|
|
|
|
63
|
|
|
$html .= '</tbody>'; |
64
|
|
|
$html .= '</table>'; |
65
|
|
|
$html .= '</div>'; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
return $html; |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|