1.
<?php
2.
3.
/*
4.
5.
Contenu table : source.
6.
7.
07/03/2021 10:45
8.
9.
lvardon@laposte.net - 2021
10.
11.
Licence libre
12.
13.
*/
14.
15.
include_once "dbconnect.php";
16.
include_once "phpdb/class_source.php";
17.
include_once "phpdb/class_source_ext.php";
18.
19.
// Class instance
20.
$mysource = new source( $db );
21.
22.
// Select all reccords
23.
$results = $mysource->selectAll();
24.
if ($results === false) {
25.
echo "Erreur : ".$mysource->lasterror."<br>";
26.
}
27.
28.
29.
echo '<div style="margin-left:15%; margin-right:15%"" >';
30.
31.
echo '<span class="titleedit">Source</span>';
32.
33.
echo '<span style="margin-left:1em;" class="">Liste des sources</span>';
34.
35.
echo '<span style="margin-left:1em;" class="linkbutton"><a href="index.php?page=phpui/edit_source&table=source&id=-1">Nouveau</a></span>';
36.
37.
?>
38.
39.
<table id="datatable" class="display" cellspacing="0" >
40.
41.
<thead>
42.
43.
<tr>
44.
<?php echo $mysource->getTableHeaderList(); ?>
45.
</tr>
46.
47.
</thead>
48.
49.
<tbody>
50.
51.
<?php
52.
53.
54.
foreach($results as $row) {
55.
56.
$rowkeyvalue=$row['a.id'];
57.
58.
echo "\n";
59.
echo '<tr>';
60.
61.
foreach($row as $key => $value) {
62.
63.
$fieldLen = $mysource->getTableFieldLenList( $key );
64.
if ( $fieldLen == 0 )
65.
continue;
66.
67.
echo '<td>';
68.
69.
$datafollow="";
70.
$dataDisplay=$value;
71.
if ( strlen($value) > $fieldLen ) {
72.
$datafollow="...";
73.
$dataDisplay=mb_substr($value, 0, $fieldLen);
74.
}
75.
76.
77.
if ( $mysource->getTableFieldLinkList( $key ) == 'on' ) {
78.
79.
echo '<a title="'.$value.'" href="index.php?page=phpui/edit_source&table=source&id='.$rowkeyvalue.'">'.$dataDisplay.$datafollow.'</a>';
80.
}
81.
else
82.
83.
switch ($mysource->getMeta($key , 'listdisplay')) {
84.
case 'color':
85.
echo '<span style="display:none" >'.$value.'</span>';
86.
$iconwidth = $mysource->getMeta($key , 'listdisplaywidth');
87.
$iconheight = $mysource->getMeta($key , 'listdisplayheight');
88.
echo '<div title="'.$value.'" style="height:0;width:'.$iconwidth.'%;padding-bottom:'.$iconheight.'%;background-color:'.$value.'">';
89.
break;
90.
91.
case 'urlpic':
92.
echo '<span style="display:none" >'.$value.'</span>';
93.
$iconwidth = $mysource->getMeta($key , 'listdisplaywidth');
94.
$iconheight = $mysource->getMeta($key , 'listdisplayheight');
95.
if ( file_exists($value) )
96.
echo '<img alt="'.$value.'" title="'.$value.'" src="'.$value.'" width='.$iconwidth.' height='.$iconheight.'>';
97.
else
98.
echo '<img alt="image inexistante" title="image inexistante" src="img/missing.png" width='.$iconwidth.' height='.$iconheight.'>';
99.
break;
100.
101.
case 'url':
102.
echo '<span style="display:none" >'.$value.'</span>';
103.
echo '<a title="'.$value.'" href="'.$value.'" target="_blank" >'.$dataDisplay.$datafollow.'</a>';
104.
break;
105.
106.
case 'icondoc':
107.
if (file_exists($value)) {
108.
$ext = pathinfo($value, PATHINFO_EXTENSION);
109.
echo '<a href="'.$value.'">';
110.
echo '<div class="fi fi-'.$ext.'">
111.
<div title="'.$value.'" class="fi-content">'.$ext.'</div>
112.
</div>';
113.
echo '</a>';
114.
}
115.
break;
116.
117.
default:
118.
if ($mysource->getMeta($key , 'sortformat') == 'date') {
119.
$sortData = substr($value, 6,4) . substr($value, 3,2) . substr($value, 0,2) ; // database : dd/mm/yyyy
120.
echo '<span style="display:none" >'.$sortData.'</span>'.'<div title="'.$value.'">'.$dataDisplay.$datafollow.'</div>';
121.
}
122.
else
123.
echo '<div title="'.$value.'">'.$dataDisplay.$datafollow.'</div>';
124.
}
125.
126.
echo '</td>';
127.
echo "\n";
128.
}
129.
echo '</tr>';
130.
}
131.
132.
?>
133.
134.
</tbody>
135.
136.
</table>
137.
138.
</div>
139.
140.