projects/genea/out/phpdb/class_place.php
1.
<?php
2.
 
3.
/*
4.
        Généalogik
5.
        
6.
        Class for table : place.
7.
 
8.
        07/03/2021 10:45
9.
 
10.
        lvardon@laposte.net - 2021
11.
        
12.
        Licence libre
13.
 
14.
        Usage examples :
15.
 
16.
        <?php
17.
 
18.
            include_once("classdir/dbconnect.php);
19.
            include_once("classdir/class_place.php);
20.
 
21.
            // Class instance
22.
            $myplace = place( $db );
23.
 
24.
            // Select all reccords :
25.
            $results = $myplace->selectAll();
26.
            foreach($results as $row) {
27.
                print_r($row);
28.
            } 
29.
 
30.
            // Select reccord #12 :
31.
            $id = 12;
32.
            $row = $myplace->select($id);
33.
            print_r($row);
34.
 
35.
        ?>
36.
 
37.
*/
38.
class _place {
39.
      
40.
    public $db;
41.
    public $lasterror="";
42.
    public $lastInsertId=-1;
43.
    public $count = 0;
44.
  
45.
    /*
46.
        Initialise object with dbHanler.
47.
                
48.
    */    
49.
    function __construct( $db ) {
50.
        $this->db = $db;
51.
    }
52.
 
53.
    /*
54.
        Select one reccord from place.
55.
        
56.
        parameters : $id (reccord id).
57.
        return : associative array of reccord.
58.
    */
59.
    function select($id) {
60.
 
61.
        $this->lasterror="";
62.
 
63.
        $sqlSt="
64.
        select       
65.
            a.id as 'a.id',  
66.
            a.name as 'a.name',
67.
            a.description as 'a.description',
68.
            a.private as 'a.private',
69.
            a.icon as 'a.icon',
70.
            a.adress1 as 'a.adress1',
71.
            a.adress2 as 'a.adress2',
72.
            a.zipcode as 'a.zipcode',
73.
            a.city as 'a.city',
74.
            a.cityinsee as 'a.cityinsee',
75.
            a.country as 'a.country',
76.
            a.url as 'a.url',
77.
            a.gpslat as 'a.gpslat',
78.
            a.gpslon as 'a.gpslon',
79.
            a.datecreated as 'a.datecreated'
80.
 
81.
 
82.
        from place a 
83.
 
84.
        where a.id = :id; 
85.
            ";
86.
 
87.
        try {                
88.
 
89.
            $stmt = $this->db->prepare($sqlSt);        
90.
            $stmt->bindParam(':id', $id, PDO::PARAM_INT);
91.
            $stmt->execute(); 
92.
            $results = $stmt->fetchAll(PDO::FETCH_ASSOC);
93.
            return $results;
94.
 
95.
        } catch (Exception $e) {
96.
            $this->lasterror = $e->getMessage().' (<b>Id</b> = '.$idkeyname.')';
97.
            return false;
98.
        }
99.
    }
100.
 
101.
    function selectPrev($id) {
102.
 
103.
        $this->lasterror="";
104.
 
105.
        $sqlSt="
106.
        select       
107.
            a.id as 'a.id',  
108.
            a.name as 'a.name',
109.
            a.description as 'a.description',
110.
            a.private as 'a.private',
111.
            a.icon as 'a.icon',
112.
            a.adress1 as 'a.adress1',
113.
            a.adress2 as 'a.adress2',
114.
            a.zipcode as 'a.zipcode',
115.
            a.city as 'a.city',
116.
            a.cityinsee as 'a.cityinsee',
117.
            a.country as 'a.country',
118.
            a.url as 'a.url',
119.
            a.gpslat as 'a.gpslat',
120.
            a.gpslon as 'a.gpslon',
121.
            a.datecreated as 'a.datecreated'
122.
 
123.
 
124.
        from place a 
125.
 
126.
        where a.id =  (SELECT id FROM place WHERE id < :id ORDER BY id DESC LIMIT 1) ; 
127.
            ";
128.
 
129.
        try {                
130.
 
131.
            $stmt = $this->db->prepare($sqlSt);        
132.
            $stmt->bindParam(':id', $id, PDO::PARAM_INT);
133.
            $stmt->execute(); 
134.
            $results = $stmt->fetchAll(PDO::FETCH_ASSOC);
135.
            return $results;
136.
 
137.
        } catch (Exception $e) {
138.
            $this->lasterror = $e->getMessage().' (<b>Id</b> = '.$idkeyname.')';
139.
            return false;
140.
        }
141.
    }
142.
 
143.
 
144.
    function selectNext($id) {
145.
 
146.
        $this->lasterror="";
147.
 
148.
        $sqlSt="
149.
        select       
150.
            a.id as 'a.id',  
151.
            a.name as 'a.name',
152.
            a.description as 'a.description',
153.
            a.private as 'a.private',
154.
            a.icon as 'a.icon',
155.
            a.adress1 as 'a.adress1',
156.
            a.adress2 as 'a.adress2',
157.
            a.zipcode as 'a.zipcode',
158.
            a.city as 'a.city',
159.
            a.cityinsee as 'a.cityinsee',
160.
            a.country as 'a.country',
161.
            a.url as 'a.url',
162.
            a.gpslat as 'a.gpslat',
163.
            a.gpslon as 'a.gpslon',
164.
            a.datecreated as 'a.datecreated'
165.
 
166.
 
167.
        from place a 
168.
 
169.
        where a.id =  (SELECT id FROM place WHERE id > :id ORDER BY id ASC LIMIT 1) ; 
170.
            ";
171.
 
172.
        try {                
173.
 
174.
            $stmt = $this->db->prepare($sqlSt);        
175.
            $stmt->bindParam(':id', $id, PDO::PARAM_INT);
176.
            $stmt->execute(); 
177.
            $results = $stmt->fetchAll(PDO::FETCH_ASSOC);
178.
            return $results;
179.
 
180.
        } catch (Exception $e) {
181.
            $this->lasterror = $e->getMessage().' (<b>Id</b> = '.$idkeyname.')';
182.
            return false;
183.
        }
184.
    }
185.
 
186.
    /*
187.
        Select all reccords from place  (with default order).
188.
        
189.
        parameters : None
190.
        return : associative array of reccords.
191.
    */
192.
    function selectAll() {
193.
 
194.
        $this->lasterror="";
195.
 
196.
        $sqlSt="
197.
        select       
198.
            a.id as 'a.id',  
199.
            a.name as 'a.name',
200.
            a.description as 'a.description',
201.
            a.private as 'a.private',
202.
            a.icon as 'a.icon',
203.
            a.adress1 as 'a.adress1',
204.
            a.adress2 as 'a.adress2',
205.
            a.zipcode as 'a.zipcode',
206.
            a.city as 'a.city',
207.
            a.cityinsee as 'a.cityinsee',
208.
            a.country as 'a.country',
209.
            a.url as 'a.url',
210.
            a.gpslat as 'a.gpslat',
211.
            a.gpslon as 'a.gpslon',
212.
            a.datecreated as 'a.datecreated'
213.
 
214.
 
215.
        from place a 
216.
 
217.
        ;    
218.
                ";
219.
 
220.
        try {        
221.
 
222.
            $stmt = $this->db->prepare($sqlSt);        
223.
            $stmt->execute(); 
224.
            $results = $stmt->fetchAll(PDO::FETCH_ASSOC);           
225.
            return $results;
226.
 
227.
        } catch (Exception $e) {
228.
            $this->lasterror = $e->getMessage();
229.
            $this->count = 0;
230.
            return false;
231.
        }
232.
    }
233.
 
234.
    /*
235.
        Update place 
236.
        
237.
        parameters : $id (reccord id) and fields list values.
238.
        return : True if no error.
239.
    */
240.
    function update( $id, $name,$description,$private,$icon,$adress1,$adress2,$zipcode,$city,$cityinsee,$country,$url,$gpslat,$gpslon,$datecreated ) {
241.
 
242.
        $this->lasterror="";        
243.
 
244.
        if ($name == '') $name = null;
245.
        if ($description == '') $description = null;
246.
        if ($private == '') $private = null;
247.
        if ($icon == '') $icon = null;
248.
        if ($adress1 == '') $adress1 = null;
249.
        if ($adress2 == '') $adress2 = null;
250.
        if ($zipcode == '') $zipcode = null;
251.
        if ($city == '') $city = null;
252.
        if ($cityinsee == '') $cityinsee = null;
253.
        if ($country == '') $country = null;
254.
        if ($url == '') $url = null;
255.
        if ($gpslat == '') $gpslat = null;
256.
        if ($gpslon == '') $gpslon = null;
257.
        if ($datecreated == '') $datecreated = null;
258.
        
259.
 
260.
        if ($this->checkValue( array( 
261.
        $name => '',
262.
        $description => '',
263.
        $private => '',
264.
        $icon => '',
265.
        $adress1 => '',
266.
        $adress2 => '',
267.
        $zipcode => '',
268.
        $city => '',
269.
        $cityinsee => '',
270.
        $country => '',
271.
        $url => '',
272.
        $gpslat => '',
273.
        $gpslon => '',
274.
        $datecreated => ''
275.
 
276.
) ) == false )
277.
        {
278.
            $this->lasterror="Check fields false";        
279.
            return false;
280.
        }
281.
 
282.
        $sqlSt="
283.
        update place set
284.
            name = :name,
285.
            description = :description,
286.
            private = :private,
287.
            icon = :icon,
288.
            adress1 = :adress1,
289.
            adress2 = :adress2,
290.
            zipcode = :zipcode,
291.
            city = :city,
292.
            cityinsee = :cityinsee,
293.
            country = :country,
294.
            url = :url,
295.
            gpslat = :gpslat,
296.
            gpslon = :gpslon,
297.
            datecreated = :datecreated
298.
 
299.
        where id = :id; 
300.
            ";
301.
 
302.
        try {        
303.
            
304.
            $stmt = $this->db->prepare($sqlSt);
305.
            
306.
            $stmt->bindParam(':id', $id, PDO::PARAM_INT);
307.
 
308.
            $stmt->bindParam(':name', $name, PDO::PARAM_STR); 
309.
            $stmt->bindParam(':description', $description, PDO::PARAM_STR); 
310.
            $stmt->bindParam(':private', $private, PDO::PARAM_INT); 
311.
            $stmt->bindParam(':icon', $icon, PDO::PARAM_STR); 
312.
            $stmt->bindParam(':adress1', $adress1, PDO::PARAM_STR); 
313.
            $stmt->bindParam(':adress2', $adress2, PDO::PARAM_STR); 
314.
            $stmt->bindParam(':zipcode', $zipcode, PDO::PARAM_STR); 
315.
            $stmt->bindParam(':city', $city, PDO::PARAM_STR); 
316.
            $stmt->bindParam(':cityinsee', $cityinsee, PDO::PARAM_INT); 
317.
            $stmt->bindParam(':country', $country, PDO::PARAM_STR); 
318.
            $stmt->bindParam(':url', $url, PDO::PARAM_STR); 
319.
            $stmt->bindParam(':gpslat', $gpslat, PDO::PARAM_STR); 
320.
            $stmt->bindParam(':gpslon', $gpslon, PDO::PARAM_STR); 
321.
            $stmt->bindParam(':datecreated', $datecreated, PDO::PARAM_STR); 
322.
 
323.
            $stmt->execute();             
324.
            
325.
            if ($stmt->rowCount() == 0) {
326.
                $this->lasterror = 'Erreur Sql update '.'  (<b>Id</b> = '.$id.'). <b>Sqlst</b> = ['.$sqlSt.'] values : '."<b>name</b> = [$name],<b>description</b> = [$description],<b>private</b> = [$private],<b>icon</b> = [$icon],<b>adress1</b> = [$adress1],<b>adress2</b> = [$adress2],<b>zipcode</b> = [$zipcode],<b>city</b> = [$city],<b>cityinsee</b> = [$cityinsee],<b>country</b> = [$country],<b>url</b> = [$url],<b>gpslat</b> = [$gpslat],<b>gpslon</b> = [$gpslon],<b>datecreated</b> = [$datecreated]";
327.
                
328.
                return false;
329.
            }   
330.
                     
331.
            return true;
332.
 
333.
        } catch (Exception $e) {            
334.
            $this->lasterror = $e->getMessage().' (<b>Id</b> = '.$id.'). <b>Sqlst</b> = ['.$sqlSt.'] values : '."<b>name</b> = [$name],<b>description</b> = [$description],<b>private</b> = [$private],<b>icon</b> = [$icon],<b>adress1</b> = [$adress1],<b>adress2</b> = [$adress2],<b>zipcode</b> = [$zipcode],<b>city</b> = [$city],<b>cityinsee</b> = [$cityinsee],<b>country</b> = [$country],<b>url</b> = [$url],<b>gpslat</b> = [$gpslat],<b>gpslon</b> = [$gpslon],<b>datecreated</b> = [$datecreated]";  
335.
            return false;
336.
        }
337.
 
338.
    }
339.
 
340.
    /*
341.
        Insert new reccord into place.
342.
        
343.
        Parameters : fields values list.
344.
        return : True if no error.
345.
    */
346.
    function insert( $name,$description,$private,$icon,$adress1,$adress2,$zipcode,$city,$cityinsee,$country,$url,$gpslat,$gpslon,$datecreated ) {
347.
 
348.
        $this->lasterror="";
349.
        $this->lastInsertId = -1;
350.
 
351.
        if ($name == '') $name = null;
352.
        if ($description == '') $description = null;
353.
        if ($private == '') $private = null;
354.
        if ($icon == '') $icon = null;
355.
        if ($adress1 == '') $adress1 = null;
356.
        if ($adress2 == '') $adress2 = null;
357.
        if ($zipcode == '') $zipcode = null;
358.
        if ($city == '') $city = null;
359.
        if ($cityinsee == '') $cityinsee = null;
360.
        if ($country == '') $country = null;
361.
        if ($url == '') $url = null;
362.
        if ($gpslat == '') $gpslat = null;
363.
        if ($gpslon == '') $gpslon = null;
364.
        if ($datecreated == '') $datecreated = null;
365.
        
366.
        
367.
        if ($this->checkValue( array( 
368.
        $name => '',
369.
        $description => '',
370.
        $private => '',
371.
        $icon => '',
372.
        $adress1 => '',
373.
        $adress2 => '',
374.
        $zipcode => '',
375.
        $city => '',
376.
        $cityinsee => '',
377.
        $country => '',
378.
        $url => '',
379.
        $gpslat => '',
380.
        $gpslon => '',
381.
        $datecreated => ''
382.
 
383.
) ) == false )
384.
        {
385.
            $this->lasterror="Check fields error";        
386.
            return false;
387.
        }
388.
 
389.
        $sqlSt="
390.
        insert into place (
391.
        name,
392.
        description,
393.
        private,
394.
        icon,
395.
        adress1,
396.
        adress2,
397.
        zipcode,
398.
        city,
399.
        cityinsee,
400.
        country,
401.
        url,
402.
        gpslat,
403.
        gpslon,
404.
        datecreated
405.
 
406.
            )
407.
        values (
408.
        :name, 
409.
        :description, 
410.
        :private, 
411.
        :icon, 
412.
        :adress1, 
413.
        :adress2, 
414.
        :zipcode, 
415.
        :city, 
416.
        :cityinsee, 
417.
        :country, 
418.
        :url, 
419.
        :gpslat, 
420.
        :gpslon, 
421.
        :datecreated 
422.
 
423.
            );    
424.
            ";
425.
 
426.
        try {        
427.
 
428.
            $stmt = $this->db->prepare($sqlSt);               
429.
            
430.
            $stmt->bindParam(':name', $name, PDO::PARAM_STR); 
431.
            $stmt->bindParam(':description', $description, PDO::PARAM_STR); 
432.
            $stmt->bindParam(':private', $private, PDO::PARAM_INT); 
433.
            $stmt->bindParam(':icon', $icon, PDO::PARAM_STR); 
434.
            $stmt->bindParam(':adress1', $adress1, PDO::PARAM_STR); 
435.
            $stmt->bindParam(':adress2', $adress2, PDO::PARAM_STR); 
436.
            $stmt->bindParam(':zipcode', $zipcode, PDO::PARAM_STR); 
437.
            $stmt->bindParam(':city', $city, PDO::PARAM_STR); 
438.
            $stmt->bindParam(':cityinsee', $cityinsee, PDO::PARAM_INT); 
439.
            $stmt->bindParam(':country', $country, PDO::PARAM_STR); 
440.
            $stmt->bindParam(':url', $url, PDO::PARAM_STR); 
441.
            $stmt->bindParam(':gpslat', $gpslat, PDO::PARAM_STR); 
442.
            $stmt->bindParam(':gpslon', $gpslon, PDO::PARAM_STR); 
443.
            $stmt->bindParam(':datecreated', $datecreated, PDO::PARAM_STR); 
444.
 
445.
 
446.
            $stmt->execute();     
447.
            $this->lastInsertId = $this->db->lastInsertId(); 
448.
            
449.
            if ($stmt->rowCount() == 0) {
450.
                $this->lasterror = 'Erreur Sql insert'.'  (<b>Id</b> = '.$id.'). <b>Sqlst</b> = ['.$sqlSt.'] values : '."<b>name</b> = [$name],<b>description</b> = [$description],<b>private</b> = [$private],<b>icon</b> = [$icon],<b>adress1</b> = [$adress1],<b>adress2</b> = [$adress2],<b>zipcode</b> = [$zipcode],<b>city</b> = [$city],<b>cityinsee</b> = [$cityinsee],<b>country</b> = [$country],<b>url</b> = [$url],<b>gpslat</b> = [$gpslat],<b>gpslon</b> = [$gpslon],<b>datecreated</b> = [$datecreated]";
451.
                return false;
452.
            }              
453.
                   
454.
            return true;
455.
 
456.
        } catch (Exception $e) {
457.
             $this->lasterror = $e->getMessage().'  (<b>Id</b> = '.$id.'). <b>Sqlst</b> = ['.$sqlSt.'] values : '."<b>name</b> = [$name],<b>description</b> = [$description],<b>private</b> = [$private],<b>icon</b> = [$icon],<b>adress1</b> = [$adress1],<b>adress2</b> = [$adress2],<b>zipcode</b> = [$zipcode],<b>city</b> = [$city],<b>cityinsee</b> = [$cityinsee],<b>country</b> = [$country],<b>url</b> = [$url],<b>gpslat</b> = [$gpslat],<b>gpslon</b> = [$gpslon],<b>datecreated</b> = [$datecreated]";
458.
            return false;
459.
        }
460.
    }
461.
 
462.
    /*
463.
        Delete one reccord from place.
464.
        
465.
        parameters : $id (reccord id).
466.
        return : True if no error.
467.
    */
468.
    function delete($id) {
469.
 
470.
        $this->lasterror="";
471.
 
472.
        $sqlSt="
473.
        delete from place             
474.
        where id = :id; 
475.
            ";   
476.
     
477.
        try {        
478.
 
479.
            $stmt = $this->db->prepare($sqlSt);  
480.
            $stmt->bindParam(':id', $id, PDO::PARAM_INT);
481.
            $stmt->execute();        
482.
            
483.
            if ($stmt->rowCount() == 0) {
484.
                $this->lasterror = "Erreur Sql delete ".' (<b>Id</b> ='.$id.')';       
485.
                return false;
486.
            }              
487.
 
488.
        } catch (Exception $e) {
489.
            $this->lasterror = $e->getMessage().' (<b>Id</b>='.$id.')';
490.
            return false;
491.
        }
492.
        return true;
493.
    }
494.
 
495.
    /*
496.
        Get id min, id max, record count from place  
497.
        
498.
        parameters : None
499.
        return : count value or False in case of error
500.
    */
501.
    function getCount() {
502.
        
503.
        $this->lasterror="";
504.
 
505.
        $sqlSt="
506.
        select min(id) as minid, max(id) as maxid, count(*) as count 
507.
        from place 
508.
                ";
509.
 
510.
        try {        
511.
 
512.
            $stmt = $this->db->prepare($sqlSt);        
513.
            $stmt->execute(); 
514.
            $results = $stmt->fetchAll(PDO::FETCH_ASSOC); 
515.
            return $results[0];          
516.
 
517.
        } catch (Exception $e) {
518.
            $this->lasterror = $e->getMessage();
519.
            return array( 'minid' => -1, 'maxid' => -1, 'count' => -1);
520.
        }
521.
                
522.
        //return $this->count;
523.
        return $results[0];
524.
    }
525.
 
526.
 
527.
 
528.
 
529.
    public $colmeta = [
530.
    'a.id' => array (
531.
        'metades' => "id",
532.
        'sortformat' => "{{sortformat}}",
533.
        'listlen' => 4,
534.
        'listlib' => 'id',
535.
        'listlink' => 'on',
536.
        'selectlen' => 4,
537.
        'selectlib' => 'id',
538.
        'selectlink' => 'on',
539.
        'selectdisplay' => '',
540.
        'selectdisplaywidth' => '0', 
541.
        'selectdisplayheight' => '0', 
542.
        'listdisplay' => '', 
543.
        'listdisplaywidth' => '0', 
544.
        'listdisplayheight' => '0' 
545.
 
546.
        ),
547.
    'a.name' => array ( 
548.
        'metades' => "name",
549.
        'sortformat' => "", 
550.
        'listlen' => 25,
551.
        'listlib' => 'name' , 
552.
        'listlink' => '',
553.
        'selectlen' => 25,
554.
        'selectlib' => 'name' , 
555.
        'selectlink' => 'on',
556.
        'selectdisplay' => 'text',
557.
        'selectdisplaywidth' => '0', 
558.
        'selectdisplayheight' => '0', 
559.
        'listdisplay' => 'text',
560.
        'listdisplaywidth' => '0', 
561.
        'listdisplayheight' => '0' 
562.
),
563.
    'a.description' => array ( 
564.
        'metades' => "description",
565.
        'sortformat' => "", 
566.
        'listlen' => 0,
567.
        'listlib' => 'description' , 
568.
        'listlink' => '',
569.
        'selectlen' => 0,
570.
        'selectlib' => 'description' , 
571.
        'selectlink' => '',
572.
        'selectdisplay' => 'text',
573.
        'selectdisplaywidth' => '0', 
574.
        'selectdisplayheight' => '0', 
575.
        'listdisplay' => 'text',
576.
        'listdisplaywidth' => '0', 
577.
        'listdisplayheight' => '0' 
578.
),
579.
    'a.private' => array ( 
580.
        'metades' => "private",
581.
        'sortformat' => "", 
582.
        'listlen' => 0,
583.
        'listlib' => 'private' , 
584.
        'listlink' => '',
585.
        'selectlen' => 0,
586.
        'selectlib' => 'private' , 
587.
        'selectlink' => '',
588.
        'selectdisplay' => 'text',
589.
        'selectdisplaywidth' => '0', 
590.
        'selectdisplayheight' => '0', 
591.
        'listdisplay' => 'text',
592.
        'listdisplaywidth' => '0', 
593.
        'listdisplayheight' => '0' 
594.
),
595.
    'a.icon' => array ( 
596.
        'metades' => "icon",
597.
        'sortformat' => "", 
598.
        'listlen' => 4,
599.
        'listlib' => 'icon' , 
600.
        'listlink' => '',
601.
        'selectlen' => 4,
602.
        'selectlib' => 'icon' , 
603.
        'selectlink' => '',
604.
        'selectdisplay' => 'urlpic',
605.
        'selectdisplaywidth' => '50', 
606.
        'selectdisplayheight' => '50', 
607.
        'listdisplay' => 'urlpic',
608.
        'listdisplaywidth' => '50', 
609.
        'listdisplayheight' => '50' 
610.
),
611.
    'a.adress1' => array ( 
612.
        'metades' => "adress1",
613.
        'sortformat' => "", 
614.
        'listlen' => 12,
615.
        'listlib' => 'adress1' , 
616.
        'listlink' => '',
617.
        'selectlen' => 0,
618.
        'selectlib' => 'adress1' , 
619.
        'selectlink' => '',
620.
        'selectdisplay' => 'text',
621.
        'selectdisplaywidth' => '0', 
622.
        'selectdisplayheight' => '0', 
623.
        'listdisplay' => 'text',
624.
        'listdisplaywidth' => '0', 
625.
        'listdisplayheight' => '0' 
626.
),
627.
    'a.adress2' => array ( 
628.
        'metades' => "adress2",
629.
        'sortformat' => "", 
630.
        'listlen' => 0,
631.
        'listlib' => 'adress2' , 
632.
        'listlink' => '',
633.
        'selectlen' => 0,
634.
        'selectlib' => 'adress2' , 
635.
        'selectlink' => '',
636.
        'selectdisplay' => 'text',
637.
        'selectdisplaywidth' => '0', 
638.
        'selectdisplayheight' => '0', 
639.
        'listdisplay' => 'text',
640.
        'listdisplaywidth' => '0', 
641.
        'listdisplayheight' => '0' 
642.
),
643.
    'a.zipcode' => array ( 
644.
        'metades' => "zipcode",
645.
        'sortformat' => "", 
646.
        'listlen' => 5,
647.
        'listlib' => 'zipcode' , 
648.
        'listlink' => '',
649.
        'selectlen' => 0,
650.
        'selectlib' => 'zipcode' , 
651.
        'selectlink' => '',
652.
        'selectdisplay' => 'text',
653.
        'selectdisplaywidth' => '0', 
654.
        'selectdisplayheight' => '0', 
655.
        'listdisplay' => 'text',
656.
        'listdisplaywidth' => '0', 
657.
        'listdisplayheight' => '0' 
658.
),
659.
    'a.city' => array ( 
660.
        'metades' => "city",
661.
        'sortformat' => "", 
662.
        'listlen' => 0,
663.
        'listlib' => 'city' , 
664.
        'listlink' => '',
665.
        'selectlen' => 0,
666.
        'selectlib' => 'city' , 
667.
        'selectlink' => '',
668.
        'selectdisplay' => 'text',
669.
        'selectdisplaywidth' => '0', 
670.
        'selectdisplayheight' => '0', 
671.
        'listdisplay' => 'text',
672.
        'listdisplaywidth' => '0', 
673.
        'listdisplayheight' => '0' 
674.
),
675.
    'a.cityinsee' => array ( 
676.
        'metades' => "cityinsee",
677.
        'sortformat' => "", 
678.
        'listlen' => 0,
679.
        'listlib' => 'cityinsee' , 
680.
        'listlink' => '',
681.
        'selectlen' => 0,
682.
        'selectlib' => 'cityinsee' , 
683.
        'selectlink' => '',
684.
        'selectdisplay' => 'text',
685.
        'selectdisplaywidth' => '0', 
686.
        'selectdisplayheight' => '0', 
687.
        'listdisplay' => 'text',
688.
        'listdisplaywidth' => '0', 
689.
        'listdisplayheight' => '0' 
690.
),
691.
    'a.country' => array ( 
692.
        'metades' => "country",
693.
        'sortformat' => "", 
694.
        'listlen' => 0,
695.
        'listlib' => 'country' , 
696.
        'listlink' => '',
697.
        'selectlen' => 0,
698.
        'selectlib' => 'country' , 
699.
        'selectlink' => '',
700.
        'selectdisplay' => 'text',
701.
        'selectdisplaywidth' => '0', 
702.
        'selectdisplayheight' => '0', 
703.
        'listdisplay' => 'text',
704.
        'listdisplaywidth' => '0', 
705.
        'listdisplayheight' => '0' 
706.
),
707.
    'a.url' => array ( 
708.
        'metades' => "",
709.
        'sortformat' => "", 
710.
        'listlen' => 12,
711.
        'listlib' => 'url' , 
712.
        'listlink' => '',
713.
        'selectlen' => 12,
714.
        'selectlib' => 'url' , 
715.
        'selectlink' => '',
716.
        'selectdisplay' => 'text',
717.
        'selectdisplaywidth' => '0', 
718.
        'selectdisplayheight' => '0', 
719.
        'listdisplay' => 'text',
720.
        'listdisplaywidth' => '0', 
721.
        'listdisplayheight' => '0' 
722.
),
723.
    'a.gpslat' => array ( 
724.
        'metades' => "gpslat",
725.
        'sortformat' => "", 
726.
        'listlen' => 0,
727.
        'listlib' => 'Lat' , 
728.
        'listlink' => '',
729.
        'selectlen' => 0,
730.
        'selectlib' => 'gpslat' , 
731.
        'selectlink' => '',
732.
        'selectdisplay' => 'text',
733.
        'selectdisplaywidth' => '0', 
734.
        'selectdisplayheight' => '0', 
735.
        'listdisplay' => 'text',
736.
        'listdisplaywidth' => '0', 
737.
        'listdisplayheight' => '0' 
738.
),
739.
    'a.gpslon' => array ( 
740.
        'metades' => "gpslon",
741.
        'sortformat' => "", 
742.
        'listlen' => 0,
743.
        'listlib' => 'Lon' , 
744.
        'listlink' => '',
745.
        'selectlen' => 0,
746.
        'selectlib' => 'gpslon' , 
747.
        'selectlink' => '',
748.
        'selectdisplay' => 'text',
749.
        'selectdisplaywidth' => '0', 
750.
        'selectdisplayheight' => '0', 
751.
        'listdisplay' => 'text',
752.
        'listdisplaywidth' => '0', 
753.
        'listdisplayheight' => '0' 
754.
),
755.
    'a.datecreated' => array ( 
756.
        'metades' => "datecreated",
757.
        'sortformat' => "date", 
758.
        'listlen' => 0,
759.
        'listlib' => 'datecreated' , 
760.
        'listlink' => '',
761.
        'selectlen' => 0,
762.
        'selectlib' => 'datecreated' , 
763.
        'selectlink' => '',
764.
        'selectdisplay' => 'text',
765.
        'selectdisplaywidth' => '0', 
766.
        'selectdisplayheight' => '0', 
767.
        'listdisplay' => 'text',
768.
        'listdisplaywidth' => '0', 
769.
        'listdisplayheight' => '0' 
770.
)
771.
 
772.
            
773.
    ];
774.
 
775.
    /*
776.
        Get field property value
777.
        
778.
        Parameters : field name and property name.
779.
        return : value of property.
780.
    */
781.
 
782.
    function getMeta( $fieldkey , $metakey ) {
783.
        return $this->colmeta [$fieldkey][$metakey];
784.
    }
785.
 
786.
    /*
787.
        Get labels for list table header.
788.
        
789.
        Parameters : None.
790.
        return : String.
791.
    */
792.
 
793.
    function getTableHeaderList() {        
794.
        
795.
        $labelsStr ='';
796.
        
797.
        foreach (  $this->colmeta as $k => $v) {
798.
            if ( $v['listlen'] > 0 ) 
799.
                $labelsStr = $labelsStr.'<th title="'.$v['metades'].'" >'.$v['listlib'] .'</th>'."\n";
800.
        }                
801.
        return $labelsStr;
802.
    }
803.
    
804.
    function getTableFieldLenList( $field ) {        
805.
        
806.
        return $this->colmeta[$field]['listlen'];
807.
    }
808.
 
809.
    function getTableFieldLinkList( $field ) {        
810.
        
811.
        return $this->colmeta[$field]['listlink'];
812.
    }
813.
 
814.
    /*
815.
        Get labels for select table header.
816.
        
817.
        Parameters : None.
818.
        return : String.
819.
    */
820.
 
821.
    function getTableHeaderSelect() {        
822.
        
823.
        $labelsStr ='';
824.
        
825.
        foreach (  $this->colmeta as $k => $v) {
826.
            if ( $v['selectlen'] > 0 ) 
827.
                $labelsStr = $labelsStr.'<th title="'.$v['metades'].'" >'.$v['selectlib'] .'</th>'."\n";
828.
        }                
829.
        return $labelsStr;
830.
    }
831.
    
832.
    function getTableFieldLenSelect( $field ) {        
833.
        
834.
        return $this->colmeta[$field]['selectlen'];
835.
    }
836.
 
837.
    function getTableFieldLinkSelect( $field ) {        
838.
        
839.
        return $this->colmeta[$field]['selectlink'];
840.
    }
841.
 
842.
    
843.
    /*
844.
        Check user input values for place.
845.
        
846.
        Parameters : array of fields with regexp  paterns. ex: array( $nom =>'^(?!\s*$).+' , $icone => '')
847.
        return : False if at last one regexp does not match.
848.
    */
849.
    function checkValue( $arrayCheck ) {
850.
 
851.
        $indexfield=1;
852.
        foreach ( $arrayCheck as $value => $pattern) {
853.
 
854.
            if ($pattern=='') continue;
855.
 
856.
            $pattern='/'.$pattern.'/';
857.
 
858.
            if (!preg_match($pattern, $value)) {
859.
                $this->lasterror = "Erreur champ #".$indexfield. '. Valeur:['.$value.']';
860.
                return false;                
861.
            }
862.
 
863.
            $indexfield+=1;
864.
 
865.
        }
866.
 
867.
        return true;
868.
    }
869.
 
870.
} // end class
871.
 
872.
?>
873.