-
Notifications
You must be signed in to change notification settings - Fork 8
/
tableuikit.php
93 lines (81 loc) · 3 KB
/
tableuikit.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
/**
* @package Radical MultiField
*
* @author delo-design.ru <info@delo-design.ru>
* @copyright Copyright (C) 2018 "Delo Design". All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @link https://delo-design.ru
*/
defined('_JEXEC') or die;
if (!$field->value)
{
return;
}
$values = json_decode($field->value, JSON_OBJECT_AS_ARRAY);
$listtype = $this->getListTypeFromField($field);
?>
<div class="uk-overflow-auto">
<table class="uk-table uk-table-divider uk-table-striped uk-table-middle uk-table-hover">
<thead>
<tr>
<?php $firstRow = reset($values); ?>
<?php foreach ($firstRow as $name => $value) : ?>
<th><?= $listtype[$name]['title']; ?></th>
<?php endforeach; ?>
</tr>
</thead>
<tbody>
<?php foreach ($values as $row => $column) { ?>
<tr>
<?php
foreach ($column as $name => $data)
{
switch ($listtype[$name]['type'])
{
case 'list':
if (is_array($data))
{
$options = explode( "\n", $listtype[$name]['options']);
foreach ($data as $key => $value) {
foreach ( $options as $option )
{
$sef = Joomla\CMS\Filter\OutputFilter::stringURLSafe( $option );
if($sef === $data[$key]) {
$data[$key] = $option;
}
}
}
$data = '<ul><li>' . implode('</li><li>', $data) . '</li></ul>';
}
else
{
$options = explode( "\n", $listtype[$name]['options']);
foreach ( $options as $option )
{
$value = Joomla\CMS\Filter\OutputFilter::stringURLSafe( $option );
if($value === $data) {
$data = $option;
}
}
}
break;
case 'media':
$data = "<img src=\"{$data}\" alt=\"\">";
break;
case 'user':
$data = \Joomla\CMS\Factory::getUser($data)->name;
break;
case 'color':
$data = "<span style=\"display:inline-block;width:1em;height:1em;background-color:{$data}\"></span> " . $data;
break;
default:
}
?>
<td><?php echo $data; ?></td>
<?php } ?>
</tr>
<?php } ?>
</tbody>
</table>
</div>