3 class sml_data_sources extends mw_data{
7 # ----------------------------------------------------------------------------------------
11 public function source_status(){
12 if(!isset($this->status)) $this->status = $this->init_sources_status();
16 public function init_sources_status(){
17 $sgbd = $this->sgbd();
21 $sql = "SELECT * FROM #--sml_classes";
22 $rst = $sgbd->query($sql);
23 while($v_rst = $sgbd->fetch_assoc($rst)) $status[$v_rst["id"]] = $v_rst;
24 $sgbd->free_result($rst);
32 # ----------------------------------------------------------------------------------------
36 public function init_sources_table(){
40 public function sources($params){
41 $start = isset($params["start"]) ? $params["start"] : null;
42 $id_user = isset($params["id_user"]) ? $params["id_user"] : null;
43 $id_groupe = isset($params["id_groupe"]) ? $params["id_groupe"] : null;
44 $status = isset($params["status"]) ? $params["status"] : null;
45 $id_source = isset($params["id_source"]) ? $params["id_source"] : null;
46 $id_composition = isset($params["id_composition"]) ? $params["id_composition"] : null;
47 $id_source_derivation = isset($params["id_source_derivation"]) ? $params["id_source_derivation"] : null;
48 $id_licence = isset($params["id_licence"]) ? $params["id_licence"] : null;
49 $is_reference = isset($params["is_reference"]) ? $params["is_reference"] : null;
50 $order_by = isset($params["order_by"]) ? $params["order_by"] : "ordre";
51 $order = isset($params["order"]) ? $params["order"] : "ASC";
52 $sgbd = $this->sgbd();
54 $ORDER_FIELD_EXISTS = false;
55 $ORDER_FROM_SOURCES_INFOS = !$ORDER_FIELD_EXISTS;
56 $sources = array("list" => array(), "total" => 0);
57 $COUNT_SELECT = "SELECT count(*) as n";
58 $SELECT = "SELECT #--sml_sources.*, #--sml_sources.id_class as `status`";
59 if($ORDER_FROM_SOURCES_INFOS){
60 if($order_by == "ordre"){
61 $SELECT .= ", (0 + #--sml_sources_infos.`value`) as ordre";
64 $SELECT .= ", #--sml_sources_infos.`value` as ".$this->eq($order_by, false);
67 $FROM = "#--sml_sources";
68 if(isset($id_user)) $FROM .= ", #--sml_authors, #--sml_sources_authors";
69 elseif(isset($id_groupe)) $FROM .= ", #--sml_sources_authors";
70 if(isset($id_source)) $FROM .= ", #--sml_source_compositions";
71 elseif(isset($id_composition) && $id_composition) $FROM .= ", #--sml_source_compositions";
72 if(isset($id_source_derivation)) $FROM .= ", #--sml_source_derivations";
73 $FROM = " FROM (".$FROM.")";
74 if($ORDER_FROM_SOURCES_INFOS){
76 " LEFT JOIN #--sml_sources_infos"
77 ." ON (#--sml_sources_infos.id_source=#--sml_sources.id AND #--sml_sources_infos.`key`=".$this->eq($order_by).")";
80 if(isset($id_user)) $WHERE .=
81 ($WHERE ? " AND " : " WHERE ")
82 ." #--sml_sources.id=#--sml_sources_authors.id_source"
83 ." AND #--sml_sources_authors.id_author=#--sml_authors.id"
84 ." AND #--sml_authors.id_user=".$this->eq($id_user)/*
85 ." AND #--sml_sources_authors.id_sources_access=".$this->id_groupe_status_admin()*/;
86 if(isset($id_groupe)) $WHERE .=
87 ($WHERE ? " AND " : " WHERE ")
88 ." #--sml_sources.id=#--sml_sources_authors.id_source"
89 ." AND #--sml_sources_authors.id_author=".$this->eq($id_groupe)/*
90 ." AND #--sml_sources_authors.id_sources_access=".$this->id_groupe_status_admin()*/;
91 if(isset($status)) $WHERE .=
92 ($WHERE ? " AND " : " WHERE ")
93 ." #--sml_sources.id_class=".$this->eq($status);
94 if(isset($id_source)) $WHERE .=
95 ($WHERE ? " AND " : " WHERE ")
96 ." #--sml_sources.id=#--sml_source_compositions.id_composition"
97 ." AND #--sml_source_compositions.id_source=".$this->eq($id_source);
98 elseif(isset($id_composition)){
101 ($WHERE ? " AND " : " WHERE ")
102 ." #--sml_sources.id=#--sml_source_compositions.id_source"
103 ." AND #--sml_source_compositions.id_composition=".$this->eq($id_composition);
106 if(($sources_ids = $this->source_compositions(array("id_composition" => ""))) !== false){
109 foreach($sources_ids as $in_source_id) $NOT_IN .= ($NOT_IN ? "," : "").$in_source_id;
110 $WHERE .= ($WHERE ? " AND " : " WHERE ")." #--sml_sources.id NOT IN(".$NOT_IN.")";
116 if(isset($id_source_derivation)) $WHERE .=
117 ($WHERE ? " AND " : " WHERE ")
118 ." #--sml_sources.id=#--sml_source_derivations.id_source"
119 ." AND #--sml_source_derivations.derivation=".$this->eq($this->source_xml_url($id_source_derivation));
120 if(isset($id_licence)) $WHERE .=
121 ($WHERE ? " AND " : " WHERE ")
122 ." #--sml_sources.licence=".$this->eq($id_licence);
123 if(isset($is_reference)){
124 $WHERE .= ($WHERE ? " AND " : " WHERE ");
127 " #--sml_sources.reference IS NOT NULL"
128 ." AND LENGTH(#--sml_sources.reference) > 0";
132 " (#--sml_sources.reference IS NULL"
133 ." OR (LENGTH(#--sml_sources.reference) = 0))";
136 $ORDER_BY = " ORDER BY ".$order_by." ".$order;
137 $LIMIT = (isset($start) && $env->config("max_list") ? " LIMIT ".$env->config("max_list")." OFFSET ".$start : "");
139 $sql = $COUNT_SELECT.$FROM.$WHERE;
140 $rst = $sgbd->query($sql);
141 if($v_rst = $sgbd->fetch_assoc($rst)) $sources["total"] = $v_rst["n"];
142 $sgbd->free_result($rst);
143 if($sources["total"]){
144 $sql = $SELECT.$FROM.$WHERE.$ORDER_BY.$LIMIT;
145 $rst = $sgbd->query($sql);
147 while($v_rst = $sgbd->fetch_assoc($rst)){
148 if(($sources["list"][$v_rst["id"]] = $this->load_source($v_rst)) === false){
153 $sgbd->free_result($rst);
154 if(!$OK) return false;
163 public function source($id, $load = false){
164 $sgbd = $this->sgbd();
166 $sql = "SELECT #--sml_sources.*, #--sml_sources.id_class as status FROM #--sml_sources WHERE id=".$this->eq($id);
167 $rst = $sgbd->query($sql);
169 if($v_rst = $sgbd->fetch_assoc($rst)){
170 $source = $load ? $this->load_source($v_rst) : $this->get_source_from_v_rst($v_rst);
172 $sgbd->free_result($rst);
180 public function get_source_from_v_rst($v_rst){
181 $sgbd = $this->sgbd();
182 $source = $this->empty_source();
183 foreach($v_rst as $rst_key => $rst_value) $source[$rst_key] = $rst_value;
185 $si_sql = "SELECT * FROM #--sml_sources_infos WHERE id_source=".$this->eq($source["id"]);
186 $si_rst = $sgbd->query($si_sql);
187 while($v_si_rst = $sgbd->fetch_assoc($si_rst)){
188 if(!isset($source[$v_si_rst["key"]])) $source[$v_si_rst["key"]] = $v_si_rst["value"];
190 $sgbd->free_result($si_rst);
191 if($source["reference"]){
192 if(!is_array($source["reference"])){
193 $reference_url = $source["reference"];
194 $source["reference"] = $this->empty_source();
195 $source["reference"]["xml"]["url"] = $reference_url;
199 if(!is_array($source["licence"])){
200 $source["licence"] = array(
201 "id" => $source["licence"]
212 public function load_source($source){
214 if(!isset($source["id"])) return false;
215 $source = $this->get_source_from_v_rst($source);
216 $source["xml"] = array(
217 "url" => $this->source_xml_url($source["id"]),
218 "content" => $this->get_source_xml($source["id"])
220 $source["documents"] = array();
221 if(($source["groupes"] = $this->source_groupes($source["id"])) === false) return false;
222 $source["image_uri"] = (
223 isset($source["image"]) && $source["image"] ?
224 $env->path("content")."uploads/".$source["image"]
227 if(($source["has_sources"] = $this->has_sources($source["id"])) === false) return false;
228 if(($source["has_derivations"] = $this->source_derivations(array("derivation" => $source["id"]))) === false) return false;
229 if(($source["derivations"] = $this->source_derivations(array("id_source" => $source["id"]))) === false) return false;
230 if(($source["reference"] = $this->source_reference($source)) === false) return false;
231 if($user = $env->user()){
232 if(($source["permissions"] = $this->source_permissions($source, $user["id"])) === false) return false;
234 if(!$source["reference"]){
235 if(($source["documents"] = $this->source_documents($source["id"])) === false) return false;
240 public function add_source(
245 $documents = array(),
246 $reference = array(),
247 $derivations = array(),
250 $sgbd = $this->sgbd();
252 "groupes" => $groupes,
253 "titre" => $reference ? null : $titre,
255 "licence" => $reference ? null : $licence,
256 "reference" => $reference ? $reference : null,
257 "date_creation" => isset($infos["date_creation"]) ? $infos["date_creation"] : null,
258 "date_inscription" => isset($infos["date_inscription"]) ? $infos["date_inscription"] : date("Y-m-d")
262 "INSERT INTO #--sml_sources(id_class, reference, titre, licence, date_creation, date_inscription)"
264 ."( ".$this->eq($source["status"])
265 .", ".$this->eq($source["reference"] ? $source["reference"]["xml"]["url"] : null)
266 .", ".$this->eq($source["titre"])
267 .", ".$this->eq($source["licence"])
268 .", ".$this->eq($source["date_creation"])
269 .", ".$this->eq($source["date_inscription"])
272 $id = $sgbd->insert_id();
273 foreach($source["groupes"] as $id_groupe => $groupe){
274 if($groupe["id"] && $groupe["id_groupe_status"]){
275 if(!$this->add_source_groupe($id, $groupe["id"], $groupe["id_groupe_status"])) return false;
279 if(isset($infos["date_creation"])) unset($infos["date_creation"]);
280 if(isset($infos["date_inscription"])) unset($infos["date_inscription"]);
281 foreach($infos as $key => $value){
283 "INSERT INTO #--sml_sources_infos(id_source, `key`,`value`)"
286 .", ".$this->eq($key)
287 .", ".$this->eq($value)
295 foreach($derivations as $source_derivation){
298 $id_source_derivation = $this->add_source_derivation(
300 $source_derivation["xml"]["url"],
301 $source_derivation["xml"]["use_edit_content"] ? $source_derivation["xml"]["content"] : ""
309 if($reference["xml"]["use_edit_content"]){
310 if(!$this->set_edit_reference_content($id, $reference["xml"]["content"])){
316 foreach($documents as $document){
317 if(!$this->add_source_document($id, $document)) return false;
320 if(!$this->set_source_xml($id)) return false;
324 public function set_source(
330 $documents = array(),
331 $reference = array(),
332 $derivations = array(),
335 if($source = $this->source($id)){
336 $sgbd = $this->sgbd();
338 "groupes" => $groupes,
339 "titre" => $reference ? null : $titre,
340 "licence" => $reference ? null : $licence,
341 "reference" => $reference ? $reference : null,
342 "date_creation" => isset($infos["date_creation"]) ? $infos["date_creation"] : null
346 "UPDATE #--sml_sources SET"
347 ." reference=".$this->eq($source["reference"] ? $source["reference"]["xml"]["url"] : null)
348 .", titre=".$this->eq($source["titre"])
349 .", licence=".$this->eq($source["licence"])
350 .", date_creation=".$this->eq($source["date_creation"])
351 ." WHERE id=".$this->eq($id);
353 if(!$this->del_source_groupes($id)) return false;
354 foreach($source["groupes"] as $id_groupe => $groupe){
355 if($groupe["id"] && $groupe["id_groupe_status"]){
356 if(!$this->add_source_groupe($id, $groupe["id"], $groupe["id_groupe_status"])) return false;
360 $sql = "DELETE FROM #--sml_sources_infos WHERE id_source=".$this->eq($id);
362 if(isset($infos["date_creation"])) unset($infos["date_creation"]);
363 if(isset($infos["date_inscription"])) unset($infos["date_inscription"]);
364 foreach($infos as $key => $value){
366 "INSERT INTO #--sml_sources_infos(id_source, `key`,`value`)"
369 .", ".$this->eq($key)
370 .", ".$this->eq($value)
378 if(!$this->del_source_derivations($id)) return false;
379 if(!$this->del_edit_reference_content($id)) return false;
380 if(!$this->del_source_documents($id)) return false;
381 foreach($derivations as $source_derivation){
384 $id_source_derivation = $this->add_source_derivation(
386 $source_derivation["xml"]["url"],
387 $source_derivation["xml"]["use_edit_content"] ? $source_derivation["xml"]["content"] : ""
395 if($reference["xml"]["use_edit_content"]){
396 if(!$this->set_edit_reference_content($id, $reference["xml"]["content"])){
402 foreach($documents as $document){
403 if(!$this->add_source_document($id, $document)) return false;
406 if(!$this->set_source_xml($id)) return false;
412 public function set_source_info($id_source, $key, $value){
413 $sgbd = $this->sgbd();
416 "SELECT id FROM #--sml_sources_infos"
417 ." WHERE id_source=".$this->eq($id_source)
418 ." AND `key`=".$this->eq($key);
419 $rst = $sgbd->query($sql);
421 if($v_rst = $sgbd->fetch_assoc($rst)) $id = $v_rst["id"];
422 $sgbd->free_result($rst);
425 "UPDATE #--sml_sources_infos SET"
426 ." `value`=".$this->eq($value)
427 ." WHERE id=".$this->eq($id);
431 "INSERT INTO #--sml_sources_infos(id_source, `key`,`value`)"
433 ."( ".$this->eq($id_source)
434 .", ".$this->eq($key)
435 .", ".$this->eq($value)
439 if(!isset($id)) $id = $sgbd->insert_id();
447 public function del_source($id){
448 $sgbd = $this->sgbd();
449 if(!$this->del_source_compositions(array("id_source" => $id, "id_composition" => $id))) return false;
450 if(!$this->del_edit_reference_content($id)) return false;
451 if(!$this->del_source_derivations($id)) return false;
452 if(!$this->del_source_xml($id)) return false;
453 if(!$this->del_source_documents($id)) return false;
454 if(!$this->del_source_groupes($id)) return false;
456 $sql = "DELETE FROM #--sml_sources_infos WHERE id_source=".$this->eq($id);
458 $sql = "DELETE FROM #--sml_sources WHERE id=".$this->eq($id);
467 # ----------------------------------------------------------------------------------------
468 # derivations de sources
471 public function init_source_derivations(){
472 $sgbd = $this->sgbd();
473 $rst = $sgbd->table_exists("#--sml_source_derivations");
481 ."(table_prefix)source_derivations :\n"
483 ." id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,\n"
484 ." id_source INT NOT NULL,\n"
485 ." derivation VARCHAR NOT NULL\n"
490 else return "impossible de chercher la table #--sml_source_derivations";
494 public function source_derivations($params){
495 $sgbd = $this->sgbd();
497 $derivations = array();
498 // sources dont "id_source" est une derivation
499 if(isset($params["id_source"])){
503 ." FROM #--sml_source_derivations"
504 ." WHERE #--sml_source_derivations.id_source=".$this->eq($params["id_source"]);
505 $rst = $sgbd->query($sql);
506 while($v_rst = $sgbd->fetch_assoc($rst)){
507 $derivations[$v_rst["id"]] = array();
508 $derivation_edit_file = $this->derivation_edit_xml_path($v_rst["id_source"], $v_rst["id"]);
509 if(file_exists($derivation_edit_file)){
512 $derivation_edit_content = $this->get_edit_derivation_content(
520 $derivations[$v_rst["id"]] = $this->source_xml_read(
521 $v_rst["derivation"],
522 $derivation_edit_content
526 $derivations[$v_rst["id"]]["xml"] = array(
527 "url" => $v_rst["derivation"],
528 "content" => $derivation_edit_content,
529 "use_edit_content" => true
537 if(($derivations[$v_rst["id"]] = $this->source_xml_read($v_rst["derivation"])) !==false){
538 $derivations[$v_rst["id"]]["id_source"] = $v_rst["id_source"];
540 else $derivations[$v_rst["id"]] = $this->empty_source();
542 $derivations[$v_rst["id"]]["id_source"] = $v_rst["id_source"];
544 $sgbd->free_result($rst);
551 // sources qui derivent de "derivation"
552 elseif(isset($params["derivation"])){
553 $source_xml_url = $params["derivation"];
554 if(preg_match("/^[0-9]+$/", $source_xml_url)) $source_xml_url = $this->source_xml_url($source_xml_url);
557 "SELECT #--sml_sources.*"
558 ." FROM #--sml_sources, #--sml_source_derivations"
559 ." WHERE #--sml_sources.id=#--sml_source_derivations.id_source"
560 ." AND #--sml_source_derivations.derivation=".$this->eq($source_xml_url);
561 $rst = $sgbd->query($sql);
562 if(!isset($rst)) return false;
563 while($v_rst = $sgbd->fetch_assoc($rst)) $derivations[$v_rst["id"]] = $v_rst;
564 $sgbd->free_result($rst);
574 public function source_derivation($id){
575 $sgbd = $this->sgbd();
577 $derivation = array();
581 ." FROM #--sml_source_derivations"
582 ." WHERE #--sml_source_derivations.id=".$this->eq($id);
583 $rst = $sgbd->query($sql);
584 if($v_rst = $sgbd->fetch_assoc($rst)) $derivation = $v_rst;
585 $sgbd->free_result($rst);
593 public function add_source_derivation($id_source, $derivation, $edit_content = ""){
594 $sgbd = $this->sgbd();
597 "INSERT INTO #--sml_source_derivations(id_source, derivation)"
599 ."( ".$this->eq($id_source)
600 .", ".$this->eq($derivation)
603 $id_source_derivation = $sgbd->insert_id();
609 if(!$this->set_edit_derivation_content($id_source, $id_source_derivation, $edit_content)){
613 return $id_source_derivation;
616 public function set_source_derivation($id_source_derivation, $id_source, $derivation, $edit_content = ""){
617 $sgbd = $this->sgbd();
620 "UPDATE #--sml_source_derivations SET"
621 ." id_source=".$this->eq($id_source)
622 .", derivation=".$this->eq($derivation)
623 ." WHERE id=".$this->eq($id_source_derivation);
630 if(!$this->set_edit_derivation_content($id_source, $id_source_derivation, $edit_content)){
637 public function del_source_derivation($id_source_derivation){
638 if(($derivation = $this->source_derivation($id_source_derivation)) !== false){
639 if(($derivations = $this->source_derivations(array("id_source" => $derivation["id_source"]))) !== false){
640 $sgbd = $this->sgbd();
642 $sql = "DELETE FROM #--sml_source_derivations WHERE id=".$this->eq($id_source_derivation);
648 if(count($derivations) > 1){
649 return $this->del_edit_derivation_content($derivation["id_source"], $id_source_derivation);
651 else return $this->del_edit_derivations($derivation["id_source"]);
657 public function del_source_derivations($id_source){
658 $sgbd = $this->sgbd();
660 $sql = "DELETE FROM #--sml_source_derivations WHERE id_source=".$this->eq($id_source);
666 return $this->del_edit_derivations($id_source);
669 # ----------------------------------------------------------------------------------------
673 public function source_reference($source){
674 $reference = array();
675 if($source["reference"]){
676 if(!is_array($source["reference"])){
677 $source["reference"] = array(
678 "url" => $source["reference"],
680 "use_edit_content" => false
683 $reference_edit_file = $this->reference_edit_xml_path($source["id"]);
684 if(file_exists($reference_edit_file)){
685 if(($reference_edit_content = $this->get_edit_reference_content($source["id"])) !== false){
686 if(($reference = $this->source_xml_read($source["reference"], $reference_edit_content)) !==false){
687 $reference["xml"] = array(
688 "url" => $source["reference"]["xml"]["url"],
689 "content" => $reference_edit_content,
690 "use_edit_content" => true
698 if(($reference = $this->source_xml_read($source["reference"]["xml"]["url"])) ===false){
699 $reference = $this->empty_source();
706 # ----------------------------------------------------------------------------------------
710 public function source_documents($id_source){
711 $sgbd = $this->sgbd();
712 $documents = array();
714 $sql = "SELECT * FROM #--sml_source_documents WHERE id_source=".$this->eq($id_source);
715 $rst = $sgbd->query($sql);
716 if(!isset($rst)) return false;
717 while($v_rst = $sgbd->fetch_assoc($rst)) $documents[$v_rst["id"]] = $v_rst;
718 $sgbd->free_result($rst);
726 public function add_source_document($id_source, $document){
727 $sgbd = $this->sgbd();
730 "INSERT INTO #--sml_source_documents(id_source, nom, url)"
732 ."( ".$this->eq($id_source)
733 .", ".$this->eq($document["nom"])
734 .", ".$this->eq($document["url"])
741 return $sgbd->insert_id();
744 public function del_source_documents($id_source){
745 $sgbd = $this->sgbd();
747 $sql = "DELETE FROM #--sml_source_documents WHERE id_source=".$this->eq($id_source);
756 # ----------------------------------------------------------------------------------------
757 # compositions de sources
760 public function source_compositions($params){
761 $id_source = isset($params["id_source"]) ? $params["id_source"] : null;
762 $id_composition = isset($params["id_composition"]) ? $params["id_composition"] : null;
763 $sgbd = $this->sgbd();
765 $compositions = array();
766 if(isset($id_source)){
768 $sql = "SELECT * FROM #--sml_source_compositions WHERE id_source=".$this->eq($id_source);
769 $rst = $sgbd->query($sql);
770 while($v_rst = $sgbd->fetch_assoc($rst)){
771 if(!isset($compositions[$v_rst["id_source"]])) $compositions[$v_rst["id_source"]] = array();
772 $compositions[$v_rst["id_source"]][] = $v_rst["id_composition"];
774 $sgbd->free_result($rst);
779 return $compositions;
781 elseif(isset($id_composition)){
785 "SELECT * FROM #--sml_source_compositions WHERE id_composition=".$this->eq($id_composition);
786 $rst = $sgbd->query($sql);
787 while($v_rst = $sgbd->fetch_assoc($rst)){
788 if(!isset($compositions[$v_rst["id_composition"]])) $compositions[$v_rst["id_composition"]] = array();
789 $compositions[$v_rst["id_composition"]][] = $v_rst["id_source"];
791 $sgbd->free_result($rst);
796 return $compositions;
801 "SELECT DISTINCT id_source FROM #--sml_source_compositions";
802 $rst = $sgbd->query($sql);
803 while($v_rst = $sgbd->fetch_assoc($rst)) $compositions[] = $v_rst["id_source"];
804 $sgbd->free_result($rst);
809 return $compositions;
815 public function set_source_composition($id_source, $id_composition){
816 $sgbd = $this->sgbd();
819 "INSERT INTO #--sml_source_compositions(id_source, id_composition) VALUES"
820 ."( ".$this->eq($id_source)
821 .", ".$this->eq($id_composition)
828 return $this->set_source_xml($id_composition);
831 public function del_source_compositions($params){
833 $id_source = isset($params["id_source"]) ? $params["id_source"] : null;
834 $id_composition = isset($params["id_composition"]) ? $params["id_composition"] : null;
835 $to_delete = array();
836 $to_update = array();
837 if(isset($id_composition)) $to_update[] = $id_composition;
838 $sgbd = $this->sgbd();
839 if(isset($id_source)){
841 $sql = "SELECT * FROM #--sml_source_compositions WHERE id_source=".$this->eq($id_source);
842 $rst = $sgbd->query($sql);
843 while($v_rst = $sgbd->fetch_assoc($rst)) $to_update[] = $v_rst["id_composition"];
844 $sgbd->free_result($rst);
851 $sql = "DELETE FROM #--sml_source_compositions";
853 $WHERE .= (isset($id_source) ? ($WHERE ? " OR " : " WHERE ")."id_source=".$this->eq($id_source) : "");
854 $WHERE .= (isset($id_composition) ? ($WHERE ? " OR " : " WHERE ")."id_composition=".$this->eq($id_composition) : "");
861 foreach($to_update as $id_source_xml){
862 if(!$this->set_source_xml($id_source_xml)) return false;
867 public function has_sources($id_composition){
868 $sgbd = $this->sgbd();
871 $sql = "SELECT count(*) as n FROM #--sml_source_compositions WHERE id_composition=".$this->eq($id_composition);
872 $rst = $sgbd->query($sql);
874 if($v_rst = $sgbd->fetch_assoc($rst)) $has_sources = $v_rst["n"];
875 $sgbd->free_result($rst);
883 public function source_ariane($id_source, $ariane = array()){
884 if(($compositions = $this->source_compositions(array("id_source" => $id_source))) !== false){
885 if(isset($compositions[$id_source]) && $compositions[$id_source]){
886 foreach($compositions[$id_source] as $id_composition){
887 if(($ariane = $this->source_ariane($id_composition, $ariane)) !== false){
888 if(($ariane[$id_composition] = $this->source($id_composition)) !== false){
890 else $ariane = false;
892 else $ariane = false;
897 else $ariane = false;