template/php2/template/phpui/list_{{table}}.tpl
1.
<?php
2.
 
3.
/*
4.
 
5.
        Contenu table : {{table}}.
6.
 
7.
        {{datetime}}
8.
 
9.
        {{author}}
10.
 
11.
        {{licence}}
12.
        
13.
*/
14.
ID:listsort
15.
include_once "dbconnect.php";
16.
include_once "phpdb/class_{{table}}.php";
17.
include_once "phpdb/class_{{table}}_ext.php";
18.
 
19.
// Class instance
20.
$my{{table}} = new {{table}}( $db );
21.
 
22.
// Select all reccords
23.
$results $my{{table}}->selectAll();
24.
if ($results === false) {
25.
    echo "Erreur : ".$my{{table}}->lasterror."<br>";
26.
}
27.
 
28.
 
29.
echo '<div style="margin-left:{{listmargin}}%; margin-right:{{listmargin}}%"" >';
30.
 
31.
echo '<span class="titleedit">{{tablelib}}</span>';
32.
 
33.
echo '<span style="margin-left:1em;" class="">{{tabledes}}</span>';
34.
 
35.
echo '<span style="margin-left:1em;" class="linkbutton"><a href="index.php?page=phpui/edit_{{table}}&table={{table}}&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 $my{{table}}->getTableHeaderList(); ?>
45.
        </tr>
46.
 
47.
    </thead>
48.
 
49.
    <tbody>
50.
 
51.
<?php
52.
 
53.
 
54.
foreach($results as $row) {
55.
 
56.
    $rowkeyvalue=$row['{{mainprefix}}.{{idkeyname}}'];
57.
 
58.
    echo "\n";   
59.
    echo '<tr>';
60.
 
61.
    foreach($row as $key => $value) {
62.
 
63.
        $fieldLen $my{{table}}->getTableFieldLenList$key );
64.
        if ( $fieldLen == )
65.
            continue;
66.
        
67.
        echo '<td>';
68.
 
69.
        $datafollow="";    
70.
        $dataDisplay=$value;
71.
        if ( strlen($value) > $fieldLen ) {
72.
            $datafollow="...";     
73.
            $dataDisplay=mb_substr($value0$fieldLen);
74.
        }
75.
                
76.
        
77.
        if ( $my{{table}}->getTableFieldLinkList$key ) == 'on' ) {
78.
            
79.
            echo '<a title="'.$value.'" href="index.php?page=phpui/edit_{{table}}&table={{table}}&id='.$rowkeyvalue.'">'.$dataDisplay.$datafollow.'</a>';        
80.
        }
81.
        else 
82.
 
83.
            switch ($my{{table}}->getMeta($key 'listdisplay')) {
84.
              case 'color':    
85.
                echo '<span style="display:none" >'.$value.'</span>';
86.
                $iconwidth $my{{table}}->getMeta($key 'listdisplaywidth');
87.
                $iconheight $my{{table}}->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 $my{{table}}->getMeta($key 'listdisplaywidth');
94.
                $iconheight $my{{table}}->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($valuePATHINFO_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 ($my{{table}}->getMeta($key 'sortformat') == 'date') {
119.
                    $sortData substr($value6,4) . substr($value3,2) . substr($value0,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.