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