1.
<?php
2.
3.
/*
4.
Généalogik
5.
6.
Class for table : source.
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_source.php);
20.
21.
// Class instance
22.
$mysource = source( $db );
23.
24.
// Select all reccords :
25.
$results = $mysource->selectAll();
26.
foreach($results as $row) {
27.
print_r($row);
28.
}
29.
30.
// Select reccord #12 :
31.
$id = 12;
32.
$row = $mysource->select($id);
33.
print_r($row);
34.
35.
?>
36.
37.
*/
38.
class _source {
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 source.
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.category as 'a.category',
70.
a.icon as 'a.icon',
71.
a.sourcetext as 'a.sourcetext',
72.
a.sourceurl as 'a.sourceurl',
73.
a.quality as 'a.quality',
74.
a.page as 'a.page',
75.
a.citation as 'a.citation',
76.
a.textdraduction as 'a.textdraduction',
77.
a.notesearch as 'a.notesearch',
78.
a.datecreated as 'a.datecreated'
79.
80.
81.
from source 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.name as 'a.name',
108.
a.description as 'a.description',
109.
a.private as 'a.private',
110.
a.category as 'a.category',
111.
a.icon as 'a.icon',
112.
a.sourcetext as 'a.sourcetext',
113.
a.sourceurl as 'a.sourceurl',
114.
a.quality as 'a.quality',
115.
a.page as 'a.page',
116.
a.citation as 'a.citation',
117.
a.textdraduction as 'a.textdraduction',
118.
a.notesearch as 'a.notesearch',
119.
a.datecreated as 'a.datecreated'
120.
121.
122.
from source a
123.
124.
where a.id = (SELECT id FROM source 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.name as 'a.name',
150.
a.description as 'a.description',
151.
a.private as 'a.private',
152.
a.category as 'a.category',
153.
a.icon as 'a.icon',
154.
a.sourcetext as 'a.sourcetext',
155.
a.sourceurl as 'a.sourceurl',
156.
a.quality as 'a.quality',
157.
a.page as 'a.page',
158.
a.citation as 'a.citation',
159.
a.textdraduction as 'a.textdraduction',
160.
a.notesearch as 'a.notesearch',
161.
a.datecreated as 'a.datecreated'
162.
163.
164.
from source a
165.
166.
where a.id = (SELECT id FROM source 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 source (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.name as 'a.name',
197.
a.description as 'a.description',
198.
a.private as 'a.private',
199.
a.category as 'a.category',
200.
a.icon as 'a.icon',
201.
a.sourcetext as 'a.sourcetext',
202.
a.sourceurl as 'a.sourceurl',
203.
a.quality as 'a.quality',
204.
a.page as 'a.page',
205.
a.citation as 'a.citation',
206.
a.textdraduction as 'a.textdraduction',
207.
a.notesearch as 'a.notesearch',
208.
a.datecreated as 'a.datecreated'
209.
210.
211.
from source 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 source
232.
233.
parameters : $id (reccord id) and fields list values.
234.
return : True if no error.
235.
*/
236.
function update( $id, $name,$description,$private,$category,$icon,$sourcetext,$sourceurl,$quality,$page,$citation,$textdraduction,$notesearch,$datecreated ) {
237.
238.
$this->lasterror="";
239.
240.
if ($name == '') $name = null;
241.
if ($description == '') $description = null;
242.
if ($private == '') $private = null;
243.
if ($category == '') $category = null;
244.
if ($icon == '') $icon = null;
245.
if ($sourcetext == '') $sourcetext = null;
246.
if ($sourceurl == '') $sourceurl = null;
247.
if ($quality == '') $quality = null;
248.
if ($page == '') $page = null;
249.
if ($citation == '') $citation = null;
250.
if ($textdraduction == '') $textdraduction = null;
251.
if ($notesearch == '') $notesearch = null;
252.
if ($datecreated == '') $datecreated = null;
253.
254.
255.
if ($this->checkValue( array(
256.
$name => '',
257.
$description => '',
258.
$private => '',
259.
$category => '',
260.
$icon => '',
261.
$sourcetext => '',
262.
$sourceurl => '',
263.
$quality => '',
264.
$page => '',
265.
$citation => '',
266.
$textdraduction => '',
267.
$notesearch => '',
268.
$datecreated => ''
269.
270.
) ) == false )
271.
{
272.
$this->lasterror="Check fields false";
273.
return false;
274.
}
275.
276.
$sqlSt="
277.
update source set
278.
name = :name,
279.
description = :description,
280.
private = :private,
281.
category = :category,
282.
icon = :icon,
283.
sourcetext = :sourcetext,
284.
sourceurl = :sourceurl,
285.
quality = :quality,
286.
page = :page,
287.
citation = :citation,
288.
textdraduction = :textdraduction,
289.
notesearch = :notesearch,
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(':name', $name, PDO::PARAM_STR);
302.
$stmt->bindParam(':description', $description, PDO::PARAM_STR);
303.
$stmt->bindParam(':private', $private, PDO::PARAM_INT);
304.
$stmt->bindParam(':category', $category, PDO::PARAM_STR);
305.
$stmt->bindParam(':icon', $icon, PDO::PARAM_STR);
306.
$stmt->bindParam(':sourcetext', $sourcetext, PDO::PARAM_STR);
307.
$stmt->bindParam(':sourceurl', $sourceurl, PDO::PARAM_STR);
308.
$stmt->bindParam(':quality', $quality, PDO::PARAM_INT);
309.
$stmt->bindParam(':page', $page, PDO::PARAM_STR);
310.
$stmt->bindParam(':citation', $citation, PDO::PARAM_STR);
311.
$stmt->bindParam(':textdraduction', $textdraduction, PDO::PARAM_STR);
312.
$stmt->bindParam(':notesearch', $notesearch, 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>name</b> = [$name],<b>description</b> = [$description],<b>private</b> = [$private],<b>category</b> = [$category],<b>icon</b> = [$icon],<b>sourcetext</b> = [$sourcetext],<b>sourceurl</b> = [$sourceurl],<b>quality</b> = [$quality],<b>page</b> = [$page],<b>citation</b> = [$citation],<b>textdraduction</b> = [$textdraduction],<b>notesearch</b> = [$notesearch],<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>name</b> = [$name],<b>description</b> = [$description],<b>private</b> = [$private],<b>category</b> = [$category],<b>icon</b> = [$icon],<b>sourcetext</b> = [$sourcetext],<b>sourceurl</b> = [$sourceurl],<b>quality</b> = [$quality],<b>page</b> = [$page],<b>citation</b> = [$citation],<b>textdraduction</b> = [$textdraduction],<b>notesearch</b> = [$notesearch],<b>datecreated</b> = [$datecreated]";
327.
return false;
328.
}
329.
330.
}
331.
332.
/*
333.
Insert new reccord into source.
334.
335.
Parameters : fields values list.
336.
return : True if no error.
337.
*/
338.
function insert( $name,$description,$private,$category,$icon,$sourcetext,$sourceurl,$quality,$page,$citation,$textdraduction,$notesearch,$datecreated ) {
339.
340.
$this->lasterror="";
341.
$this->lastInsertId = -1;
342.
343.
if ($name == '') $name = null;
344.
if ($description == '') $description = null;
345.
if ($private == '') $private = null;
346.
if ($category == '') $category = null;
347.
if ($icon == '') $icon = null;
348.
if ($sourcetext == '') $sourcetext = null;
349.
if ($sourceurl == '') $sourceurl = null;
350.
if ($quality == '') $quality = null;
351.
if ($page == '') $page = null;
352.
if ($citation == '') $citation = null;
353.
if ($textdraduction == '') $textdraduction = null;
354.
if ($notesearch == '') $notesearch = null;
355.
if ($datecreated == '') $datecreated = null;
356.
357.
358.
if ($this->checkValue( array(
359.
$name => '',
360.
$description => '',
361.
$private => '',
362.
$category => '',
363.
$icon => '',
364.
$sourcetext => '',
365.
$sourceurl => '',
366.
$quality => '',
367.
$page => '',
368.
$citation => '',
369.
$textdraduction => '',
370.
$notesearch => '',
371.
$datecreated => ''
372.
373.
) ) == false )
374.
{
375.
$this->lasterror="Check fields error";
376.
return false;
377.
}
378.
379.
$sqlSt="
380.
insert into source (
381.
name,
382.
description,
383.
private,
384.
category,
385.
icon,
386.
sourcetext,
387.
sourceurl,
388.
quality,
389.
page,
390.
citation,
391.
textdraduction,
392.
notesearch,
393.
datecreated
394.
395.
)
396.
values (
397.
:name,
398.
:description,
399.
:private,
400.
:category,
401.
:icon,
402.
:sourcetext,
403.
:sourceurl,
404.
:quality,
405.
:page,
406.
:citation,
407.
:textdraduction,
408.
:notesearch,
409.
:datecreated
410.
411.
);
412.
";
413.
414.
try {
415.
416.
$stmt = $this->db->prepare($sqlSt);
417.
418.
$stmt->bindParam(':name', $name, PDO::PARAM_STR);
419.
$stmt->bindParam(':description', $description, PDO::PARAM_STR);
420.
$stmt->bindParam(':private', $private, PDO::PARAM_INT);
421.
$stmt->bindParam(':category', $category, PDO::PARAM_STR);
422.
$stmt->bindParam(':icon', $icon, PDO::PARAM_STR);
423.
$stmt->bindParam(':sourcetext', $sourcetext, PDO::PARAM_STR);
424.
$stmt->bindParam(':sourceurl', $sourceurl, PDO::PARAM_STR);
425.
$stmt->bindParam(':quality', $quality, PDO::PARAM_INT);
426.
$stmt->bindParam(':page', $page, PDO::PARAM_STR);
427.
$stmt->bindParam(':citation', $citation, PDO::PARAM_STR);
428.
$stmt->bindParam(':textdraduction', $textdraduction, PDO::PARAM_STR);
429.
$stmt->bindParam(':notesearch', $notesearch, 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>name</b> = [$name],<b>description</b> = [$description],<b>private</b> = [$private],<b>category</b> = [$category],<b>icon</b> = [$icon],<b>sourcetext</b> = [$sourcetext],<b>sourceurl</b> = [$sourceurl],<b>quality</b> = [$quality],<b>page</b> = [$page],<b>citation</b> = [$citation],<b>textdraduction</b> = [$textdraduction],<b>notesearch</b> = [$notesearch],<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>name</b> = [$name],<b>description</b> = [$description],<b>private</b> = [$private],<b>category</b> = [$category],<b>icon</b> = [$icon],<b>sourcetext</b> = [$sourcetext],<b>sourceurl</b> = [$sourceurl],<b>quality</b> = [$quality],<b>page</b> = [$page],<b>citation</b> = [$citation],<b>textdraduction</b> = [$textdraduction],<b>notesearch</b> = [$notesearch],<b>datecreated</b> = [$datecreated]";
445.
return false;
446.
}
447.
}
448.
449.
/*
450.
Delete one reccord from source.
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 source
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 source
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 source
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' => 'a_id',
522.
'listlink' => 'on',
523.
'selectlen' => 4,
524.
'selectlib' => 'a_id',
525.
'selectlink' => 'on',
526.
'selectdisplay' => '',
527.
'selectdisplaywidth' => '0',
528.
'selectdisplayheight' => '0',
529.
'listdisplay' => '',
530.
'listdisplaywidth' => '0',
531.
'listdisplayheight' => '0'
532.
533.
),
534.
'a.name' => array (
535.
'metades' => "Nom de la source",
536.
'sortformat' => "",
537.
'listlen' => 30,
538.
'listlib' => 'Nom' ,
539.
'listlink' => '',
540.
'selectlen' => 12,
541.
'selectlib' => 'Nom' ,
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' => 'a_description' ,
555.
'listlink' => '',
556.
'selectlen' => 0,
557.
'selectlib' => 'a_description' ,
558.
'selectlink' => '',
559.
'selectdisplay' => 'text',
560.
'selectdisplaywidth' => '0',
561.
'selectdisplayheight' => '0',
562.
'listdisplay' => 'text',
563.
'listdisplaywidth' => '0',
564.
'listdisplayheight' => '0'
565.
),
566.
'a.private' => array (
567.
'metades' => "private",
568.
'sortformat' => "",
569.
'listlen' => 0,
570.
'listlib' => 'a_private' ,
571.
'listlink' => '',
572.
'selectlen' => 0,
573.
'selectlib' => 'a_private' ,
574.
'selectlink' => '',
575.
'selectdisplay' => 'text',
576.
'selectdisplaywidth' => '0',
577.
'selectdisplayheight' => '0',
578.
'listdisplay' => 'text',
579.
'listdisplaywidth' => '0',
580.
'listdisplayheight' => '0'
581.
),
582.
'a.category' => array (
583.
'metades' => "",
584.
'sortformat' => "",
585.
'listlen' => 12,
586.
'listlib' => 'category' ,
587.
'listlink' => '',
588.
'selectlen' => 12,
589.
'selectlib' => 'category' ,
590.
'selectlink' => '',
591.
'selectdisplay' => 'text',
592.
'selectdisplaywidth' => '0',
593.
'selectdisplayheight' => '0',
594.
'listdisplay' => 'text',
595.
'listdisplaywidth' => '0',
596.
'listdisplayheight' => '0'
597.
),
598.
'a.icon' => array (
599.
'metades' => "icon",
600.
'sortformat' => "",
601.
'listlen' => 4,
602.
'listlib' => 'icon' ,
603.
'listlink' => '',
604.
'selectlen' => 4,
605.
'selectlib' => 'icon' ,
606.
'selectlink' => '',
607.
'selectdisplay' => 'urlpic',
608.
'selectdisplaywidth' => '50',
609.
'selectdisplayheight' => '50',
610.
'listdisplay' => 'urlpic',
611.
'listdisplaywidth' => '50',
612.
'listdisplayheight' => '50'
613.
),
614.
'a.sourcetext' => array (
615.
'metades' => "",
616.
'sortformat' => "",
617.
'listlen' => 12,
618.
'listlib' => 'sourcetext' ,
619.
'listlink' => '',
620.
'selectlen' => 12,
621.
'selectlib' => 'sourcetext' ,
622.
'selectlink' => '',
623.
'selectdisplay' => 'text',
624.
'selectdisplaywidth' => '0',
625.
'selectdisplayheight' => '0',
626.
'listdisplay' => 'text',
627.
'listdisplaywidth' => '0',
628.
'listdisplayheight' => '0'
629.
),
630.
'a.sourceurl' => array (
631.
'metades' => "",
632.
'sortformat' => "",
633.
'listlen' => 12,
634.
'listlib' => 'sourceurl' ,
635.
'listlink' => '',
636.
'selectlen' => 12,
637.
'selectlib' => 'sourceurl' ,
638.
'selectlink' => '',
639.
'selectdisplay' => 'text',
640.
'selectdisplaywidth' => '0',
641.
'selectdisplayheight' => '0',
642.
'listdisplay' => 'text',
643.
'listdisplaywidth' => '0',
644.
'listdisplayheight' => '0'
645.
),
646.
'a.quality' => array (
647.
'metades' => "",
648.
'sortformat' => "",
649.
'listlen' => 8,
650.
'listlib' => 'quality' ,
651.
'listlink' => '',
652.
'selectlen' => 8,
653.
'selectlib' => 'quality' ,
654.
'selectlink' => '',
655.
'selectdisplay' => 'text',
656.
'selectdisplaywidth' => '0',
657.
'selectdisplayheight' => '0',
658.
'listdisplay' => 'text',
659.
'listdisplaywidth' => '0',
660.
'listdisplayheight' => '0'
661.
),
662.
'a.page' => array (
663.
'metades' => "Page dans le document",
664.
'sortformat' => "",
665.
'listlen' => 12,
666.
'listlib' => 'Page' ,
667.
'listlink' => '',
668.
'selectlen' => 12,
669.
'selectlib' => 'Page' ,
670.
'selectlink' => '',
671.
'selectdisplay' => 'text',
672.
'selectdisplaywidth' => '0',
673.
'selectdisplayheight' => '0',
674.
'listdisplay' => 'text',
675.
'listdisplaywidth' => '0',
676.
'listdisplayheight' => '0'
677.
),
678.
'a.citation' => array (
679.
'metades' => "",
680.
'sortformat' => "",
681.
'listlen' => 12,
682.
'listlib' => 'citation' ,
683.
'listlink' => '',
684.
'selectlen' => 12,
685.
'selectlib' => 'citation' ,
686.
'selectlink' => '',
687.
'selectdisplay' => 'text',
688.
'selectdisplaywidth' => '0',
689.
'selectdisplayheight' => '0',
690.
'listdisplay' => 'text',
691.
'listdisplaywidth' => '0',
692.
'listdisplayheight' => '0'
693.
),
694.
'a.textdraduction' => array (
695.
'metades' => "",
696.
'sortformat' => "",
697.
'listlen' => 12,
698.
'listlib' => 'textdraduction' ,
699.
'listlink' => '',
700.
'selectlen' => 12,
701.
'selectlib' => 'textdraduction' ,
702.
'selectlink' => '',
703.
'selectdisplay' => 'text',
704.
'selectdisplaywidth' => '0',
705.
'selectdisplayheight' => '0',
706.
'listdisplay' => 'text',
707.
'listdisplaywidth' => '0',
708.
'listdisplayheight' => '0'
709.
),
710.
'a.notesearch' => array (
711.
'metades' => "Notes de recherche",
712.
'sortformat' => "",
713.
'listlen' => 0,
714.
'listlib' => 'Notes de recherche' ,
715.
'listlink' => '',
716.
'selectlen' => 0,
717.
'selectlib' => 'Notes de recherche' ,
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' => 0,
730.
'listlib' => 'a_datecreated' ,
731.
'listlink' => '',
732.
'selectlen' => 0,
733.
'selectlib' => 'a_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 source.
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.