syntaxe POO (visibilite) et maj indentation
[mw_sourceml] / app / data / modules / sql / sml_data_sources.php
index 4c85c2b..ccb1a44 100644 (file)
@@ -2,18 +2,18 @@
 
   class sml_data_sources extends mw_data{
 
-    var $status;
+    public $status;
 
     # ----------------------------------------------------------------------------------------
     #                                                                        classes de source
     #
 
-    function source_status(){
+    public function source_status(){
       if(!isset($this->status)) $this->status = $this->init_sources_status();
       return $this->status;
     }
 
-    function init_sources_status(){
+    public function init_sources_status(){
       $sgbd = $this->sgbd();
       $env = $this->env();
       $status = array();
@@ -23,7 +23,9 @@
         while($v_rst = $sgbd->fetch_assoc($rst)) $status[$v_rst["id"]] = $v_rst;
         $sgbd->free_result($rst);
       }
-      catch(Exception $e) { $status = false; }
+      catch(Exception $e){
+        $status = false;
+      }
       return $status;
     }
 
     #                                                                                  sources
     #
 
-    function init_sources_table(){
+    public function init_sources_table(){
       return true;
     }
 
-    function sources($params){
+    public function sources($params){
       $start = isset($params["start"]) ? $params["start"] : null;
       $id_user = isset($params["id_user"]) ? $params["id_user"] : null;
       $id_groupe = isset($params["id_groupe"]) ? $params["id_groupe"] : null;
        ($WHERE ? " AND " : " WHERE ")
       ." #--sml_sources.id=#--sml_source_compositions.id_composition"
       ." AND #--sml_source_compositions.id_source=".$this->eq($id_source);
-      elseif(isset($id_composition))
-      { if($id_composition)
-        { $WHERE .=
+      elseif(isset($id_composition)){
+        if($id_composition){
+          $WHERE .=
            ($WHERE ? " AND " : " WHERE ")
           ." #--sml_sources.id=#--sml_source_compositions.id_source"
           ." AND #--sml_source_compositions.id_composition=".$this->eq($id_composition);
         }
-        else
-        { if(($sources_ids = $this->source_compositions(array("id_composition" => ""))) !== false)
-          { if($sources_ids)
-            { $NOT_IN = "";
+        else{
+          if(($sources_ids = $this->source_compositions(array("id_composition" => ""))) !== false){
+            if($sources_ids){
+              $NOT_IN = "";
               foreach($sources_ids as $in_source_id) $NOT_IN .= ($NOT_IN ? "," : "").$in_source_id;
               $WHERE .= ($WHERE ? " AND " : " WHERE ")." #--sml_sources.id NOT IN(".$NOT_IN.")";
             }
         $rst = $sgbd->query($sql);
         if($v_rst = $sgbd->fetch_assoc($rst)) $sources["total"] = $v_rst["n"];
         $sgbd->free_result($rst);
-        if($sources["total"])
-        { $sql = $SELECT.$FROM.$WHERE.$ORDER_BY.$LIMIT;
+        if($sources["total"]){
+          $sql = $SELECT.$FROM.$WHERE.$ORDER_BY.$LIMIT;
           $rst = $sgbd->query($sql);
           $OK = true;
           while($v_rst = $sgbd->fetch_assoc($rst)){
           if(!$OK) return false;
         }
       }
-      catch(Exception $e) { $sources = false; }
+      catch(Exception $e){
+        $sources = false;
+      }
       return $sources;
     }
 
-    function source($id, $load = false){
+    public function source($id, $load = false){
       $sgbd = $this->sgbd();
       try{
         $sql = "SELECT #--sml_sources.*, #--sml_sources.id_class as status FROM #--sml_sources WHERE id=".$this->eq($id);
         }
         $sgbd->free_result($rst);
       }
-      catch(Exception $e) { $source = false; }
+      catch(Exception $e){
+        $source = false;
+      }
       return $source;
     }
 
-    function get_source_from_v_rst($v_rst){
+    public function get_source_from_v_rst($v_rst){
       $sgbd = $this->sgbd();
       $source = $this->empty_source();
       foreach($v_rst as $rst_key => $rst_value) $source[$rst_key] = $rst_value;
           }
         }
       }
-      catch(Exception $e) { $source = false; }
+      catch(Exception $e){
+        $source = false;
+      }
       return $source;
     }
 
-    function load_source($source){
+    public function load_source($source){
       $env = $this->env();
       if(!isset($source["id"])) return false;
       $source = $this->get_source_from_v_rst($source);
-      $source["xml"] = array
-      ( "url" => $this->source_xml_url($source["id"]),
+      $source["xml"] = array(
+        "url" => $this->source_xml_url($source["id"]),
         "content" => $this->get_source_xml($source["id"])
       );
       $source["documents"] = array();
       if(($source["groupes"] = $this->source_groupes($source["id"])) === false) return false;
-      $source["image_uri"] =
-      ( isset($source["image"]) && $source["image"] ?
+      $source["image_uri"] = (
+        isset($source["image"]) && $source["image"] ?
         $env->path("content")."uploads/".$source["image"]
         : ""
       );
       if($user = $env->user()){
         if(($source["permissions"] = $this->source_permissions($source, $user["id"])) === false) return false;
       }
-      if(!$source["reference"])
-      { if(($source["documents"] = $this->source_documents($source["id"])) === false) return false;
+      if(!$source["reference"]){
+        if(($source["documents"] = $this->source_documents($source["id"])) === false) return false;
       }
       return $source;
     }
 
-    function add_source
-    ( $groupes,
+    public function add_source(
+      $groupes,
       $titre,
       $status,
       $licence,
       $reference = array(),
       $derivations = array(),
       $infos = array()
-    )
-    { $sgbd = $this->sgbd();
-      $source = array
-      ( "groupes" => $groupes,
+    ){
+      $sgbd = $this->sgbd();
+      $source = array(
+        "groupes" => $groupes,
         "titre" => $reference ? null : $titre,
         "status" => $status,
         "licence" => $reference ? null : $licence,
         .")";
         $sgbd->query($sql);
         $id = $sgbd->insert_id();
-        foreach($source["groupes"] as $id_groupe => $groupe)
-        { if($groupe["id"] && $groupe["id_groupe_status"])
-          { if(!$this->add_source_groupe($id, $groupe["id"], $groupe["id_groupe_status"])) return false;
+        foreach($source["groupes"] as $id_groupe => $groupe){
+          if($groupe["id"] && $groupe["id_groupe_status"]){
+            if(!$this->add_source_groupe($id, $groupe["id"], $groupe["id_groupe_status"])) return false;
           }
           else return false;
         }
           $sgbd->query($sql);
         }
       }
-      catch(Exception $e) { return false; }
-      foreach($derivations as $source_derivation)
-      { if
-        ( ( $id_source_derivation = $this->add_source_derivation
-            ( $id,
+      catch(Exception $e){
+        return false;
+      }
+      foreach($derivations as $source_derivation){
+        if(
+          (
+            $id_source_derivation = $this->add_source_derivation(
+              $id,
               $source_derivation["xml"]["url"],
               $source_derivation["xml"]["use_edit_content"] ? $source_derivation["xml"]["content"] : ""
             )
           ) === false
-        )
-        { return false;
+        ){
+          return false;
         }
       }
-      if($reference)
-      { if($reference["xml"]["use_edit_content"])
-        { if(!$this->set_edit_reference_content($id, $reference["xml"]["content"]))
-          { return false;
+      if($reference){
+        if($reference["xml"]["use_edit_content"]){
+          if(!$this->set_edit_reference_content($id, $reference["xml"]["content"])){
+            return false;
           }
         }
       }
-      else
-      { foreach($documents as $document)
-        { if(!$this->add_source_document($id, $document)) return false;
+      else{
+        foreach($documents as $document){
+          if(!$this->add_source_document($id, $document)) return false;
         }
       }
       if(!$this->set_source_xml($id)) return false;
       return $id;
     }
 
-    function set_source
-    ( $id,
+    public function set_source(
+      $id,
       $groupes,
       $titre,
       $status,
       $reference = array(),
       $derivations = array(),
       $infos = array()
-    )
-    { if($source = $this->source($id))
-      { $sgbd = $this->sgbd();
-        $source = array
-        ( "groupes" => $groupes,
+    ){
+      if($source = $this->source($id)){
+        $sgbd = $this->sgbd();
+        $source = array(
+          "groupes" => $groupes,
           "titre" => $reference ? null : $titre,
           "licence" => $reference ? null : $licence,
           "reference" => $reference ? $reference : null,
           ." WHERE id=".$this->eq($id);
           $sgbd->query($sql);
           if(!$this->del_source_groupes($id)) return false;
-          foreach($source["groupes"] as $id_groupe => $groupe)
-          { if($groupe["id"] && $groupe["id_groupe_status"]){
+          foreach($source["groupes"] as $id_groupe => $groupe){
+            if($groupe["id"] && $groupe["id_groupe_status"]){
               if(!$this->add_source_groupe($id, $groupe["id"], $groupe["id_groupe_status"])) return false;
             }
             else return false;
           $sgbd->query($sql);
           if(isset($infos["date_creation"])) unset($infos["date_creation"]);
           if(isset($infos["date_inscription"])) unset($infos["date_inscription"]);
-          foreach($infos as $key => $value)
-          { $sql =
+          foreach($infos as $key => $value){
+            $sql =
              "INSERT INTO #--sml_sources_infos(id_source, `key`,`value`)"
             ." VALUES"
             ."( ".$this->eq($id)
             $sgbd->query($sql);
           }
         }
-        catch(Exception $e) { return false; }
+        catch(Exception $e){
+          return false;
+        }
         if(!$this->del_source_derivations($id)) return false;
         if(!$this->del_edit_reference_content($id)) return false;
         if(!$this->del_source_documents($id)) return false;
-        foreach($derivations as $source_derivation)
-        { if
-          ( ( $id_source_derivation = $this->add_source_derivation
-              ( $id,
+        foreach($derivations as $source_derivation){
+          if(
+            (
+              $id_source_derivation = $this->add_source_derivation(
+                $id,
                 $source_derivation["xml"]["url"],
                 $source_derivation["xml"]["use_edit_content"] ? $source_derivation["xml"]["content"] : ""
               )
             ) === false
-          )
-          { return false;
+          ){
+            return false;
           }
         }
-        if($reference)
-        { if($reference["xml"]["use_edit_content"])
-          { if(!$this->set_edit_reference_content($id, $reference["xml"]["content"]))
-            { return false;
+        if($reference){
+          if($reference["xml"]["use_edit_content"]){
+            if(!$this->set_edit_reference_content($id, $reference["xml"]["content"])){
+              return false;
             }
           }
         }
       return false;
     }
 
-    function set_source_info($id_source, $key, $value){
+    public function set_source_info($id_source, $key, $value){
       $sgbd = $this->sgbd();
       try{
         $sql =
         $id = null;
         if($v_rst = $sgbd->fetch_assoc($rst)) $id = $v_rst["id"];
         $sgbd->free_result($rst);
-        if(isset($id)) $sql =
-         "UPDATE #--sml_sources_infos SET"
-        ." `value`=".$this->eq($value)
-        ." WHERE id=".$this->eq($id);
-        else $sql =
-         "INSERT INTO #--sml_sources_infos(id_source, `key`,`value`)"
-        ." VALUES"
-        ."( ".$this->eq($id_source)
-        .", ".$this->eq($key)
-        .", ".$this->eq($value)
-        .")";
+        if(isset($id)){
+          $sql =
+           "UPDATE #--sml_sources_infos SET"
+          ." `value`=".$this->eq($value)
+          ." WHERE id=".$this->eq($id);
+        }
+        else{
+          $sql =
+           "INSERT INTO #--sml_sources_infos(id_source, `key`,`value`)"
+          ." VALUES"
+          ."( ".$this->eq($id_source)
+          .", ".$this->eq($key)
+          .", ".$this->eq($value)
+          .")";
+        }
         $sgbd->query($sql);
         if(!isset($id)) $id = $sgbd->insert_id();
       }
-      catch(Exception $e) { return false; }
+      catch(Exception $e){
+        return false;
+      }
       return $id;
     }
 
-    function del_source($id){
+    public function del_source($id){
       $sgbd = $this->sgbd();
       if(!$this->del_source_compositions(array("id_source" => $id, "id_composition" => $id))) return false;
       if(!$this->del_edit_reference_content($id)) return false;
         $sql = "DELETE FROM #--sml_sources WHERE id=".$this->eq($id);
         $sgbd->query($sql);
       }
-      catch(Exception $e) { return false; }
+      catch(Exception $e){
+        return false;
+      }
       return true;
     }
 
     #                                                                   derivations de sources
     #
 
-    function init_source_derivations()
-    { $sgbd = $this->sgbd();
+    public function init_source_derivations(){
+      $sgbd = $this->sgbd();
       $rst = $sgbd->table_exists("#--sml_source_derivations");
-      if(isset($rst))
-      { if(!$rst)
-        { return
+      if(isset($rst)){
+        if(!$rst){
+          return
            "table manquante"
           ."<br />"
           ."<br />"
       return true;
     }
 
-    function source_derivations($params)
-    { $sgbd = $this->sgbd();
+    public function source_derivations($params){
+      $sgbd = $this->sgbd();
       $env = $this->env();
       $derivations = array();
       // sources dont "id_source" est une derivation
           ." FROM #--sml_source_derivations"
           ." WHERE #--sml_source_derivations.id_source=".$this->eq($params["id_source"]);
           $rst = $sgbd->query($sql);
-          while($v_rst = $sgbd->fetch_assoc($rst))
-          { $derivations[$v_rst["id"]] = array();
+          while($v_rst = $sgbd->fetch_assoc($rst)){
+            $derivations[$v_rst["id"]] = array();
             $derivation_edit_file = $this->derivation_edit_xml_path($v_rst["id_source"], $v_rst["id"]);
-            if(file_exists($derivation_edit_file))
-            { if(($derivation_edit_content = $this->get_edit_derivation_content($v_rst["id_source"], $v_rst["id"])) !== false)
-              { if(($derivations[$v_rst["id"]] = $this->source_xml_read($v_rst["derivation"], $derivation_edit_content)) !==false)
-                { $derivations[$v_rst["id"]]["xml"] = array
-                  ( "url" => $v_rst["derivation"],
+            if(file_exists($derivation_edit_file)){
+              if(
+                (
+                  $derivation_edit_content = $this->get_edit_derivation_content(
+                    $v_rst["id_source"],
+                    $v_rst["id"]
+                  )
+                ) !== false
+              ){
+                if(
+                  (
+                    $derivations[$v_rst["id"]] = $this->source_xml_read(
+                      $v_rst["derivation"],
+                      $derivation_edit_content
+                    )
+                  ) !==false
+                ){
+                  $derivations[$v_rst["id"]]["xml"] = array(
+                    "url" => $v_rst["derivation"],
                     "content" => $derivation_edit_content,
                     "use_edit_content" => true
                   );
               }
               else return false;
             }
-            else
-            { if(($derivations[$v_rst["id"]] = $this->source_xml_read($v_rst["derivation"])) !==false)
-              { $derivations[$v_rst["id"]]["id_source"] = $v_rst["id_source"];
+            else{
+              if(($derivations[$v_rst["id"]] = $this->source_xml_read($v_rst["derivation"])) !==false){
+                $derivations[$v_rst["id"]]["id_source"] = $v_rst["id_source"];
               }
               else $derivations[$v_rst["id"]] = $this->empty_source();
             }
           }
           $sgbd->free_result($rst);
         }
-        catch(Exception $e) { return false; }
+        catch(Exception $e){
+          return false;
+        }
         return $derivations;
       }
       // sources qui derivent de "derivation"
-      elseif(isset($params["derivation"]))
-      { $source_xml_url = $params["derivation"];
+      elseif(isset($params["derivation"])){
+        $source_xml_url = $params["derivation"];
         if(preg_match("/^[0-9]+$/", $source_xml_url)) $source_xml_url = $this->source_xml_url($source_xml_url);
         try{
           $sql =
           while($v_rst = $sgbd->fetch_assoc($rst)) $derivations[$v_rst["id"]] = $v_rst;
           $sgbd->free_result($rst);
         }
-        catch(Exception $e) { return false; }
+        catch(Exception $e){
+          return false;
+        }
         return $derivations;
       }
       return false;
     }
 
-    function source_derivation($id){
+    public function source_derivation($id){
       $sgbd = $this->sgbd();
       $env = $this->env();
       $derivation = array();
         if($v_rst = $sgbd->fetch_assoc($rst)) $derivation = $v_rst;
         $sgbd->free_result($rst);
       }
-      catch(Exception $e) { return false; }
+      catch(Exception $e){
+        return false;
+      }
       return $derivation;
     }
 
-    function add_source_derivation($id_source, $derivation, $edit_content = "")
-    { $sgbd = $this->sgbd();
+    public function add_source_derivation($id_source, $derivation, $edit_content = ""){
+      $sgbd = $this->sgbd();
       try{
         $sql =
          "INSERT INTO #--sml_source_derivations(id_source, derivation)"
         $sgbd->query($sql);
         $id_source_derivation = $sgbd->insert_id();
       }
-      catch(Exception $e) { return false; }
-      if($edit_content)
-      { if(!$this->set_edit_derivation_content($id_source, $id_source_derivation, $edit_content))
-        { return false;
+      catch(Exception $e){
+        return false;
+      }
+      if($edit_content){
+        if(!$this->set_edit_derivation_content($id_source, $id_source_derivation, $edit_content)){
+          return false;
         }
       }
       return $id_source_derivation;
     }
 
-    function set_source_derivation($id_source_derivation, $id_source, $derivation, $edit_content = "")
-    { $sgbd = $this->sgbd();
+    public function set_source_derivation($id_source_derivation, $id_source, $derivation, $edit_content = ""){
+      $sgbd = $this->sgbd();
       try{
         $sql =
          "UPDATE #--sml_source_derivations SET"
         ." WHERE id=".$this->eq($id_source_derivation);
         $sgbd->query($sql);
       }
-      catch(Exception $e) { return false; }
-      if($edit_content)
-      { if(!$this->set_edit_derivation_content($id_source, $id_source_derivation, $edit_content))
-        { return false;
+      catch(Exception $e){
+        return false;
+      }
+      if($edit_content){
+        if(!$this->set_edit_derivation_content($id_source, $id_source_derivation, $edit_content)){
+          return false;
         }
       }
       return true;
     }
 
-    function del_source_derivation($id_source_derivation)
-    { if(($derivation = $this->source_derivation($id_source_derivation)) !== false)
-      { if(($derivations = $this->source_derivations(array("id_source" => $derivation["id_source"]))) !== false)
-        { $sgbd = $this->sgbd();
+    public function del_source_derivation($id_source_derivation){
+      if(($derivation = $this->source_derivation($id_source_derivation)) !== false){
+        if(($derivations = $this->source_derivations(array("id_source" => $derivation["id_source"]))) !== false){
+          $sgbd = $this->sgbd();
           try{
             $sql = "DELETE FROM #--sml_source_derivations WHERE id=".$this->eq($id_source_derivation);
             $sgbd->query($sql);
           }
-          catch(Exception $e) { return false; }
-          if(count($derivations) > 1)
-          { return $this->del_edit_derivation_content($derivation["id_source"], $id_source_derivation);
+          catch(Exception $e){
+            return false;
+          }
+          if(count($derivations) > 1){
+            return $this->del_edit_derivation_content($derivation["id_source"], $id_source_derivation);
           }
           else return $this->del_edit_derivations($derivation["id_source"]);
         }
       return false;
     }
 
-    function del_source_derivations($id_source)
-    { $sgbd = $this->sgbd();
+    public function del_source_derivations($id_source){
+      $sgbd = $this->sgbd();
       try{
         $sql = "DELETE FROM #--sml_source_derivations WHERE id_source=".$this->eq($id_source);
         $sgbd->query($sql);
       }
-      catch(Exception $e) { return false; }
+      catch(Exception $e){
+        return false;
+      }
       return $this->del_edit_derivations($id_source);
     }
 
     #                                                                               references
     #
 
-    function source_reference($source)
-    { $reference = array();
-      if($source["reference"])
-      { if(!is_array($source["reference"]))
-        { $source["reference"] = array
-          ( "url" => $source["reference"],
+    public function source_reference($source){
+      $reference = array();
+      if($source["reference"]){
+        if(!is_array($source["reference"])){
+          $source["reference"] = array(
+            "url" => $source["reference"],
             "content" => "",
             "use_edit_content" => false
           );
         }
         $reference_edit_file = $this->reference_edit_xml_path($source["id"]);
-        if(file_exists($reference_edit_file))
-        { if(($reference_edit_content = $this->get_edit_reference_content($source["id"])) !== false)
-          { if(($reference = $this->source_xml_read($source["reference"], $reference_edit_content)) !==false)
-            { $reference["xml"] = array
-              ( "url" => $source["reference"]["xml"]["url"],
+        if(file_exists($reference_edit_file)){
+          if(($reference_edit_content = $this->get_edit_reference_content($source["id"])) !== false){
+            if(($reference = $this->source_xml_read($source["reference"], $reference_edit_content)) !==false){
+              $reference["xml"] = array(
+                "url" => $source["reference"]["xml"]["url"],
                 "content" => $reference_edit_content,
                 "use_edit_content" => true
               );
           }
           else return false;
         }
-        else
-        { if(($reference = $this->source_xml_read($source["reference"]["xml"]["url"])) ===false)
-          { $reference = $this->empty_source();
+        else{
+          if(($reference = $this->source_xml_read($source["reference"]["xml"]["url"])) ===false){
+            $reference = $this->empty_source();
           }
         }
       }
     #                                                                                documents
     #
 
-    function source_documents($id_source)
-    { $sgbd = $this->sgbd();
+    public function source_documents($id_source){
+      $sgbd = $this->sgbd();
       $documents = array();
       try{
         $sql = "SELECT * FROM #--sml_source_documents WHERE id_source=".$this->eq($id_source);
         while($v_rst = $sgbd->fetch_assoc($rst)) $documents[$v_rst["id"]] = $v_rst;
         $sgbd->free_result($rst);
       }
-      catch(Exception $e) { return false; }
+      catch(Exception $e){
+        return false;
+      }
       return $documents;
     }
 
-    function add_source_document($id_source, $document)
-    { $sgbd = $this->sgbd();
+    public function add_source_document($id_source, $document){
+      $sgbd = $this->sgbd();
       try{
         $sql =
          "INSERT INTO #--sml_source_documents(id_source, nom, url)"
         .")";
         $sgbd->query($sql);
       }
-      catch(Exception $e) { return false; }
+      catch(Exception $e){
+        return false;
+      }
       return $sgbd->insert_id();
     }
 
-    function del_source_documents($id_source)
-    { $sgbd = $this->sgbd();
+    public function del_source_documents($id_source){
+      $sgbd = $this->sgbd();
       try{
         $sql = "DELETE FROM #--sml_source_documents WHERE id_source=".$this->eq($id_source);
         $sgbd->query($sql);
       }
-      catch(Exception $e) { return false; }
+      catch(Exception $e){
+        return false;
+      }
       return true;
     }
 
     #                                                                  compositions de sources
     #
 
-    function source_compositions($params)
-    { $id_source = isset($params["id_source"]) ? $params["id_source"] : null;  
+    public function source_compositions($params){
+      $id_source = isset($params["id_source"]) ? $params["id_source"] : null;  
       $id_composition = isset($params["id_composition"]) ? $params["id_composition"] : null;
       $sgbd = $this->sgbd();
       $env = $this->env();
         try{
           $sql = "SELECT * FROM #--sml_source_compositions WHERE id_source=".$this->eq($id_source);
           $rst = $sgbd->query($sql);
-          while($v_rst = $sgbd->fetch_assoc($rst))
-          { if(!isset($compositions[$v_rst["id_source"]])) $compositions[$v_rst["id_source"]] = array();
+          while($v_rst = $sgbd->fetch_assoc($rst)){
+            if(!isset($compositions[$v_rst["id_source"]])) $compositions[$v_rst["id_source"]] = array();
             $compositions[$v_rst["id_source"]][] = $v_rst["id_composition"];
           }
           $sgbd->free_result($rst);
         }
-        catch(Exception $e) { return false; }
+        catch(Exception $e){
+          return false;
+        }
         return $compositions;
       }
-      elseif(isset($id_composition))
-      { if($id_composition){
+      elseif(isset($id_composition)){
+        if($id_composition){
           try{
             $sql =
              "SELECT * FROM #--sml_source_compositions WHERE id_composition=".$this->eq($id_composition);
             $rst = $sgbd->query($sql);
-            while($v_rst = $sgbd->fetch_assoc($rst))
-            { if(!isset($compositions[$v_rst["id_composition"]])) $compositions[$v_rst["id_composition"]] = array();
+            while($v_rst = $sgbd->fetch_assoc($rst)){
+              if(!isset($compositions[$v_rst["id_composition"]])) $compositions[$v_rst["id_composition"]] = array();
               $compositions[$v_rst["id_composition"]][] = $v_rst["id_source"];
             }
             $sgbd->free_result($rst);
           }
-          catch(Exception $e) { return false; }
+          catch(Exception $e){
+            return false;
+          }
           return $compositions;
         }
         else{
             while($v_rst = $sgbd->fetch_assoc($rst)) $compositions[] = $v_rst["id_source"];
             $sgbd->free_result($rst);
           }
-          catch(Exception $e) { return false; }
+          catch(Exception $e){
+            return false;
+          }
           return $compositions;
         }
       }
       return false;
     }
 
-    function set_source_composition($id_source, $id_composition){
+    public function set_source_composition($id_source, $id_composition){
       $sgbd = $this->sgbd();
       try{
         $sql =
         .")";
         $sgbd->query($sql);
       }
-      catch(Exception $e) { return false; }
+      catch(Exception $e){
+        return false;
+      }
       return $this->set_source_xml($id_composition);
     }
 
-    function del_source_compositions($params){
+    public function del_source_compositions($params){
       $res = true;
       $id_source = isset($params["id_source"]) ? $params["id_source"] : null;  
       $id_composition = isset($params["id_composition"]) ? $params["id_composition"] : null;
           while($v_rst = $sgbd->fetch_assoc($rst)) $to_update[] = $v_rst["id_composition"];
           $sgbd->free_result($rst);
         }
-        catch(Exception $e) { return false; }
+        catch(Exception $e){
+          return false;
+        }
       }
       try{
         $sql = "DELETE FROM #--sml_source_compositions";
         $sql .= $WHERE;
         $sgbd->query($sql);
       }
-      catch(Exception $e) { return false; }
+      catch(Exception $e){
+        return false;
+      }
       foreach($to_update as $id_source_xml){
         if(!$this->set_source_xml($id_source_xml)) return false;
       }
       return true;
     }
 
-    function has_sources($id_composition)
-    { $sgbd = $this->sgbd();
+    public function has_sources($id_composition){
+      $sgbd = $this->sgbd();
       $env = $this->env();
       try{
         $sql = "SELECT count(*) as n FROM #--sml_source_compositions WHERE id_composition=".$this->eq($id_composition);
         if($v_rst = $sgbd->fetch_assoc($rst)) $has_sources = $v_rst["n"];
         $sgbd->free_result($rst);
       }
-      catch(Exception $e) { return false; }
+      catch(Exception $e){
+        return false;
+      }
       return $has_sources;
     }
 
-    function source_ariane($id_source, $ariane = array())
-    { if(($compositions = $this->source_compositions(array("id_source" => $id_source))) !== false)
-      { if(isset($compositions[$id_source]) && $compositions[$id_source])
-        { foreach($compositions[$id_source] as $id_composition)
-          { if(($ariane = $this->source_ariane($id_composition, $ariane)) !== false)
-            { if(($ariane[$id_composition] = $this->source($id_composition)) !== false)
-              {
+    public function source_ariane($id_source, $ariane = array()){
+      if(($compositions = $this->source_compositions(array("id_source" => $id_source))) !== false){
+        if(isset($compositions[$id_source]) && $compositions[$id_source]){
+          foreach($compositions[$id_source] as $id_composition){
+            if(($ariane = $this->source_ariane($id_composition, $ariane)) !== false){
+              if(($ariane[$id_composition] = $this->source($id_composition)) !== false){
               }
               else $ariane = false;
             }
     }
 
   }
-
-?>
\ No newline at end of file