From 0b1ecd8b7536944d54d74ffc836982de3654d98b Mon Sep 17 00:00:00 2001 From: dj3c1t Date: Sat, 14 Jun 2014 20:48:03 +0200 Subject: [PATCH] syntaxe POO (visibilite) et maj indentation --- app/controllers/admin/cache.php | 4 +- app/controllers/admin/licences.php | 95 +-- app/controllers/admin/maintenance.php | 24 +- app/controllers/admin/sourceml.php | 33 +- app/controllers/content/sources.php | 226 +++---- app/controllers/forms/sourceml.php | 64 +- app/controllers/sources/album.php | 54 +- app/controllers/sources/groupe.php | 43 +- app/controllers/sources/morceau.php | 74 ++- app/controllers/sources/piste.php | 86 ++- app/controllers/sources/waveforms.php | 8 +- app/controllers/users/albums.php | 21 +- app/controllers/users/groupes.php | 163 ++--- app/controllers/users/morceaux.php | 30 +- app/controllers/users/pistes.php | 32 +- app/controllers/users/sources.php | 52 +- app/controllers/users/sources_invitations.php | 29 +- app/data/modules/share/sml_data_sources_cache.php | 70 ++- app/data/modules/share/sml_data_sources_xml.php | 147 +++-- .../modules/share/sml_data_sources_xml_format.php | 30 +- .../modules/share/sml_data_sources_xml_pathes.php | 16 +- app/data/modules/share/sml_data_waveforms.php | 20 +- app/data/modules/sql/sml_data_authors.php | 21 +- app/data/modules/sql/sml_data_install.php | 6 +- app/data/modules/sql/sml_data_licences.php | 32 +- app/data/modules/sql/sml_data_source_groupes.php | 121 ++-- app/data/modules/sql/sml_data_sources.php | 433 +++++++------ app/data/modules/sql/sml_data_sources_cache_db.php | 26 +- app/data/modules/xml/sml_data_authors.php | 123 ++-- app/data/modules/xml/sml_data_install.php | 64 +- app/data/modules/xml/sml_data_licences.php | 77 ++- app/data/modules/xml/sml_data_source_groupes.php | 128 ++-- app/data/modules/xml/sml_data_sources.php | 668 +++++++++++---------- app/data/modules/xml/sml_data_sources_cache_db.php | 57 +- .../upgrades/sql/mw_sourceml_sql_version_1_1_2.php | 4 +- .../upgrades/xml/mw_sourceml_xml_version_1_1_2.php | 4 +- app/helpers/mw_helper_sourceml_out.php | 6 +- app/observers/mw_observer_sourceml.php | 6 +- mw_sourceml.php | 16 +- 39 files changed, 1628 insertions(+), 1485 deletions(-) diff --git a/app/controllers/admin/cache.php b/app/controllers/admin/cache.php index b45330a..e3aec5a 100644 --- a/app/controllers/admin/cache.php +++ b/app/controllers/admin/cache.php @@ -2,7 +2,7 @@ class mw_admin_cache extends mw_controller{ - function index(){ + public function index(){ $env = $this->env(); $data = $env->data(); if(($CONFIG = $env->get_CONFIG()) !== false){ @@ -33,5 +33,3 @@ } } - -?> \ No newline at end of file diff --git a/app/controllers/admin/licences.php b/app/controllers/admin/licences.php index 0ea28df..4fc03c7 100644 --- a/app/controllers/admin/licences.php +++ b/app/controllers/admin/licences.php @@ -1,57 +1,58 @@ env(); $data = $env->data(); - if($env->set_out("licences", $data->licences()) !== false) - { + if($env->set_out("licences", $data->licences()) === false){ + $env->erreur("impossible de lire la liste des licences"); } - else $env->erreur("impossible de lire la liste des licences"); } - function add(){ + public function add(){ $env = $this->env(); $data = $env->data(); - if($_POST) - { $env->set_out("licence", $_POST); - if($_POST["nom"]) - { if - ( $data->add_licence - ( $_POST["nom"], + if($_POST){ + $env->set_out("licence", $_POST); + if($_POST["nom"]){ + if( + $data->add_licence( + $_POST["nom"], $_POST["url"] ) - ) - $env->redirect - ( $env->url("admin/licences"), - "la licence ".$_POST["nom"]." a été ajoutée" - ); + ){ + $env->redirect( + $env->url("admin/licences"), + "la licence ".$_POST["nom"]." a été ajoutée" + ); + } else $env->erreur("Impossible d'ajouter la licence"); } else $env->message("merci de préciser un nom"); } } - function edit(){ + public function edit(){ $env = $this->env(); $data = $env->data(); - if($env->set_out("licence", $data->licence($_GET[$env->param("id")]))) - { if($_POST) - { if($_POST["nom"]) - { $licence = $env->out("licence"); + if($env->set_out("licence", $data->licence($_GET[$env->param("id")]))){ + if($_POST){ + if($_POST["nom"]){ + $licence = $env->out("licence"); $env->set_out("licence", $_POST); - if - ( $data->set_licence - ( $_GET[$env->param("id")], + if( + $data->set_licence( + $_GET[$env->param("id")], $_POST["nom"], $_POST["url"] ) - ) - $env->redirect - ( $env->url("admin/licences"), - "la licence ".$licence["nom"]." a été modifiée" - ); + ){ + $env->redirect + ( $env->url("admin/licences"), + "la licence ".$licence["nom"]." a été modifiée" + ); + } else $env->erreur("Impossible de mettre à jour la licence"); } else $env->message("Merci de préciser un nom"); @@ -60,21 +61,25 @@ else $env->erreur("impossible de lire la licence"); } - function del(){ + public function del(){ $env = $this->env(); $data = $env->data(); - if($env->set_out("licence", $data->licence($_GET[$env->param("id")]))) - { $licence = $env->out("licence"); - if(($res = $data->del_licence($_GET[$env->param("id")])) !== false) - { if($res === 1) $env->redirect - ( $env->url("admin/licences"), - "Des sources sur ce site utilisent cette licence, elle n'a pas été supprimée.", - 5 - ); - else $env->redirect - ( $env->url("admin/licences"), - "la licence ".$licence["nom"]." a été supprimée" - ); + if($env->set_out("licence", $data->licence($_GET[$env->param("id")]))){ + $licence = $env->out("licence"); + if(($res = $data->del_licence($_GET[$env->param("id")])) !== false){ + if($res === 1){ + $env->redirect( + $env->url("admin/licences"), + "Des sources sur ce site utilisent cette licence, elle n'a pas été supprimée.", + 5 + ); + } + else{ + $env->redirect( + $env->url("admin/licences"), + "la licence ".$licence["nom"]." a été supprimée" + ); + } } else $env->erreur("Impossible de supprimer la licence"); } @@ -82,5 +87,3 @@ } } - -?> \ No newline at end of file diff --git a/app/controllers/admin/maintenance.php b/app/controllers/admin/maintenance.php index 7791b50..c2cbf8d 100644 --- a/app/controllers/admin/maintenance.php +++ b/app/controllers/admin/maintenance.php @@ -1,28 +1,28 @@ env(); $data = $env->data(); - if($data->empty_source_cache()) - { $env->redirect - ( $env->url("admin/maintenance"), + if($data->empty_source_cache()){ + $env->redirect( + $env->url("admin/maintenance"), "le cache a été vidé" ); } else $env->erreur("Impossible de vider le cache"); } - function maj_all_xml(){ + public function maj_all_xml(){ $env = $this->env(); $data = $env->data(); - if($data->maj_source_xml_all()) - { $env->redirect - ( $env->url("admin/maintenance"), + if($data->maj_source_xml_all()){ + $env->redirect( + $env->url("admin/maintenance"), "les fichiers XML des sources ont été mis à jour" ); } @@ -30,5 +30,3 @@ } } - -?> \ No newline at end of file diff --git a/app/controllers/admin/sourceml.php b/app/controllers/admin/sourceml.php index cc674c1..7764cc0 100644 --- a/app/controllers/admin/sourceml.php +++ b/app/controllers/admin/sourceml.php @@ -1,33 +1,34 @@ env(); $data = $env->data(); - if(($this->status = $data->source_status()) === false) - { return "Impossible de lire la liste des status de source"; + if(($this->status = $data->source_status()) === false){ + return "Impossible de lire la liste des status de source"; } - foreach($this->status as $id_source_status => $source_status) - { if($source_status["nom"] == "album") $this->album_status_id = $id_source_status; + foreach($this->status as $id_source_status => $source_status){ + if($source_status["nom"] == "album") $this->album_status_id = $id_source_status; if(isset($this->album_status_id) && isset($this->morceau_status_id)) break; } if(!isset($this->album_status_id)) return "Type de source inconnu: album"; - if(($this->groupes = $data->groupes()) === false) - { return "Impossible de lire la liste des groupes"; + if(($this->groupes = $data->groupes()) === false){ + return "Impossible de lire la liste des groupes"; } $select = array("status" => $this->album_status_id); - if(($this->albums = $data->sources($select)) === false) return "impossible de lire la liste des albums"; + if(($this->albums = $data->sources($select)) === false){ + return "impossible de lire la liste des albums"; + } return true; } - function index(){ + public function index(){ $env = $this->env(); $data = $env->data(); if(!($groupes = $this->groupes)){ @@ -93,5 +94,3 @@ } } - -?> \ No newline at end of file diff --git a/app/controllers/content/sources.php b/app/controllers/content/sources.php index 82d9b6d..9bc0d20 100644 --- a/app/controllers/content/sources.php +++ b/app/controllers/content/sources.php @@ -1,22 +1,20 @@ env(); $this->validation_result = true; $this->validate_status($env); @@ -24,13 +22,13 @@ return true; } - function validate_status(){ + public function validate_status(){ $env = $this->env(); - if($this->validation_result === true) - { $data = $env->data(); - if(($this->status = $data->source_status()) !== false) - { foreach($this->status as $id_source_status => $source_status) - { if($source_status["nom"] == "album") $this->album_status_id = $id_source_status; + if($this->validation_result === true){ + $data = $env->data(); + if(($this->status = $data->source_status()) !== false){ + foreach($this->status as $id_source_status => $source_status){ + if($source_status["nom"] == "album") $this->album_status_id = $id_source_status; if($source_status["nom"] == "morceau") $this->morceau_status_id = $id_source_status; if($source_status["nom"] == "piste") $this->piste_status_id = $id_source_status; if(isset($this->album_status_id) && isset($this->morceau_status_id) && isset($this->piste_status_id)) break; @@ -43,24 +41,23 @@ } } - function validate_licences(){ + public function validate_licences(){ $env = $this->env(); - if($this->validation_result === true) - { $data = $env->data(); - if(($this->licences = $data->licences()) !== false) - { $env->set_out("licences", $this->licences); + if($this->validation_result === true){ + $data = $env->data(); + if(($this->licences = $data->licences()) !== false){ + $env->set_out("licences", $this->licences); } else $this->validation_result = "Impossible de lire la liste des licences"; } } - function validate_source(){ + public function validate_source(){ $env = $this->env(); - if($this->validation_result === true) - { $data = $env->data(); - if(isset($_GET[$env->param("id")]) && $_GET[$env->param("id")]) - { if($this->source = $data->source($_GET[$env->param("id")])) - { + if($this->validation_result === true){ + $data = $env->data(); + if(isset($_GET[$env->param("id")]) && $_GET[$env->param("id")]){ + if($this->source = $data->source($_GET[$env->param("id")])){ } else $this->validation_result = "Impossible de lire les informations de la source"; } @@ -68,15 +65,15 @@ } } - function validate_groupes(){ + public function validate_groupes(){ $env = $this->env(); - if($this->validation_result === true) - { $data = $env->data(); - if(($groupes = $data->groupes()) !== false) - { $env->set_out("groupes", $groupes); - if(isset($_GET[$env->param("groupe")]) && $_GET[$env->param("groupe")]) - { if(($this->groupe = $data->groupe($_GET[$env->param("groupe")])) !== false) - { $env->set_out("groupe", $groupe); + if($this->validation_result === true){ + $data = $env->data(); + if(($groupes = $data->groupes()) !== false){ + $env->set_out("groupes", $groupes); + if(isset($_GET[$env->param("groupe")]) && $_GET[$env->param("groupe")]){ + if(($this->groupe = $data->groupe($_GET[$env->param("groupe")])) !== false){ + $env->set_out("groupe", $groupe); } else $this->validation_result = "Impossible de lire les informations du groupe"; } @@ -85,41 +82,41 @@ } } - function sources(){ + public function sources(){ $env = $this->env(); $this->validate_source($env); - if($this->validation_result === true) - { $data = $env->data(); + if($this->validation_result === true){ + $data = $env->data(); $sources = array("list" => array(), "total" => 0); - if($this->source) - { if(($source_ariane = $data->source_ariane($this->source["id"])) !== false) - { $this->url_params = array(); - foreach($source_ariane as $id_composition => $composition) - { if($composition["status"] == $this->morceau_status_id) $this->url_params["morceau"] = $id_composition; + if($this->source){ + if(($source_ariane = $data->source_ariane($this->source["id"])) !== false){ + $this->url_params = array(); + foreach($source_ariane as $id_composition => $composition){ + if($composition["status"] == $this->morceau_status_id) $this->url_params["morceau"] = $id_composition; elseif($composition["status"] == $this->album_status_id) $this->url_params["album"] = $id_composition; } - if($this->source["status"] == $this->morceau_status_id) - { $this->source_param = $env->set_out("source_param", "piste"); + if($this->source["status"] == $this->morceau_status_id){ + $this->source_param = $env->set_out("source_param", "piste"); $this->source_controller = $env->set_out("source_controller", "piste"); $this->url_params["morceau"] = $this->source["id"]; } - elseif($this->source["status"] == $this->album_status_id) - { $this->source_param = $env->set_out("source_param", "morceau"); + elseif($this->source["status"] == $this->album_status_id){ + $this->source_param = $env->set_out("source_param", "morceau"); $this->source_controller = $env->set_out("source_controller", "morceau"); $this->url_params["album"] = $this->source["id"]; } $env->set_out("url_params", $this->url_params); - if(($_sources = $data->source_compositions(array("id_composition" => $this->source["id"]))) !== false) - { if(isset($_sources[$this->source["id"]]) && $_sources[$this->source["id"]]) - { foreach($_sources[$this->source["id"]] as $id_source) - { if(($sources["list"][$id_source] = $data->source($id_source, true)) !== false) - { if(!isset($sources["list"][$id_source]["ordre"])){ + if(($_sources = $data->source_compositions(array("id_composition" => $this->source["id"]))) !== false){ + if(isset($_sources[$this->source["id"]]) && $_sources[$this->source["id"]]){ + foreach($_sources[$this->source["id"]] as $id_source){ + if(($sources["list"][$id_source] = $data->source($id_source, true)) !== false){ + if(!isset($sources["list"][$id_source]["ordre"])){ $sources["list"][$id_source]["ordre"] = 0; } $sources["total"]++; } - else - { $this->erreur("Impossible de lire les informations de l'une des sources"); + else{ + $this->erreur("Impossible de lire les informations de l'une des sources"); break; } } @@ -136,37 +133,37 @@ else $this->erreur($this->validation_result); } - function derivations(){ + public function derivations(){ $env = $this->env(); $this->validate_source($env); - if($this->validation_result === true) - { $data = $env->data(); + if($this->validation_result === true){ + $data = $env->data(); $derivations = array("list" => array(), "total" => 0); - if($this->source) - { if(($source_ariane = $data->source_ariane($this->source["id"])) !== false) - { $this->url_params = array(); - foreach($source_ariane as $id_composition => $composition) - { if($composition["status"] == $this->morceau_status_id) $this->url_params["morceau"] = $id_composition; + if($this->source){ + if(($source_ariane = $data->source_ariane($this->source["id"])) !== false){ + $this->url_params = array(); + foreach($source_ariane as $id_composition => $composition){ + if($composition["status"] == $this->morceau_status_id) $this->url_params["morceau"] = $id_composition; elseif($composition["status"] == $this->album_status_id) $this->url_params["album"] = $id_composition; } - if($this->source["status"] == $this->piste_status_id) - { $this->source_param = $env->set_out("source_param", "piste"); + if($this->source["status"] == $this->piste_status_id){ + $this->source_param = $env->set_out("source_param", "piste"); $this->source_controller = $env->set_out("source_controller", "piste"); $this->url_params["piste"] = $this->source["id"]; } - elseif($this->source["status"] == $this->morceau_status_id) - { $this->source_param = $env->set_out("source_param", "morceau"); + elseif($this->source["status"] == $this->morceau_status_id){ + $this->source_param = $env->set_out("source_param", "morceau"); $this->source_controller = $env->set_out("source_controller", "morceau"); $this->url_params["morceau"] = $this->source["id"]; } $env->set_out("url_params", $this->url_params); - if(($_derivations = $data->source_derivations(array("derivation" => $this->source["id"]))) !== false) - { foreach($_derivations as $id_derivation => $derivation) - { if(($derivations["list"][$id_derivation] = $data->source($id_derivation, true)) !== false) - { $derivations["total"]++; + if(($_derivations = $data->source_derivations(array("derivation" => $this->source["id"]))) !== false){ + foreach($_derivations as $id_derivation => $derivation){ + if(($derivations["list"][$id_derivation] = $data->source($id_derivation, true)) !== false){ + $derivations["total"]++; } - else - { $this->erreur("Impossible de lire les informations de l'une des derivations"); + else{ + $this->erreur("Impossible de lire les informations de l'une des derivations"); break; } } @@ -182,28 +179,42 @@ else $this->erreur($this->validation_result); } - function xml_form(){ + public function xml_form(){ $env = $this->env(); - if(isset($_GET[$env->param("form")])) - { $data = $env->data(); + if(isset($_GET[$env->param("form")])){ + $data = $env->data(); $form_params = array(); - if(isset($_GET[$env->param("derivation")])) - { if($_GET[$env->param("form")] == "edit") - { if(($source_derivation = $data->source_derivation($_GET[$env->param("derivation")])) !== false) - { $source = array - ( "id" => $source_derivation["id"], - "xml" => array - ( "url" => $source_derivation["derivation"], + if(isset($_GET[$env->param("derivation")])){ + if($_GET[$env->param("form")] == "edit"){ + if(($source_derivation = $data->source_derivation($_GET[$env->param("derivation")])) !== false){ + $source = array( + "id" => $source_derivation["id"], + "xml" => array( + "url" => $source_derivation["derivation"], "content" => "", "use_edit_content" => false ) ); $derivation_edit_file = $data->derivation_edit_xml_path($source_derivation["id_source"], $source_derivation["id"]); - if(file_exists($derivation_edit_file)) - { if(($derivation_edit_content = $data->get_edit_derivation_content($source_derivation["id_source"], $source_derivation["id"])) !== false) - { if(($source = $data->source_xml_read($source_derivation["derivation"], $derivation_edit_content)) !==false) - { $source["xml"] = array - ( "url" => $source_derivation["derivation"], + if(file_exists($derivation_edit_file)){ + if( + ( + $derivation_edit_content = $data->get_edit_derivation_content( + $source_derivation["id_source"], + $source_derivation["id"] + ) + ) !== false + ){ + if( + ( + $source = $data->source_xml_read( + $source_derivation["derivation"], + $derivation_edit_content + ) + ) !==false + ){ + $source["xml"] = array( + "url" => $source_derivation["derivation"], "content" => $derivation_edit_content, "use_edit_content" => true ); @@ -212,9 +223,9 @@ } else $this->erreur("Impossible de lire le XML de la source"); } - else - { if(($source = $data->source_xml_read($source_derivation["derivation"])) === false) - { $source = $data->empty_source(); + else{ + if(($source = $data->source_xml_read($source_derivation["derivation"])) === false){ + $source = $data->empty_source(); } } $source["id_source"] = $source_derivation["id_source"]; @@ -235,8 +246,7 @@ $form_params["can_delete"] = true; $form_params["id"] = $_GET[$env->param("derivation")]; } - elseif(isset($_GET[$env->param("reference")])) - { + elseif(isset($_GET[$env->param("reference")])){ } $env->set_out("form_params", $form_params); $env->set_out("xml_form_source", $source); @@ -244,18 +254,18 @@ else $this->erreur("Parametres invalides pour le formulaire"); } - function xml(){ + public function xml(){ $env = $this->env(); $this->validate_source($env); - if($this->validation_result === true) - { $data = $env->data(); + if($this->validation_result === true){ + $data = $env->data(); $xml = ""; - if($this->source) - { if($this->source = $data->load_source($this->source)) - { $xml = + if($this->source){ + if($this->source = $data->load_source($this->source)){ + $xml = "
"
-            .htmlentities
-            ( $this->source["reference"] ? $this->source["reference"]["xml"]["content"] : $this->source["xml"]["content"],
+            .htmlentities(
+              $this->source["reference"] ? $this->source["reference"]["xml"]["content"] : $this->source["xml"]["content"],
               ENT_COMPAT,
               "UTF-8"
             )
@@ -270,11 +280,9 @@
       exit;
     }
 
-    function erreur($content)
-    { echo $content;
+    public function erreur($content){
+      echo $content;
       exit;
     }
 
   }
-
-?>
\ No newline at end of file
diff --git a/app/controllers/forms/sourceml.php b/app/controllers/forms/sourceml.php
index 46fc014..5f6f608 100644
--- a/app/controllers/forms/sourceml.php
+++ b/app/controllers/forms/sourceml.php
@@ -2,9 +2,9 @@
 
   class mw_forms_sourceml extends mw_controller{
 
-    var $forms_contact_mod;
+    public $forms_contact_mod;
 
-    function validate(){
+    public function validate(){
       $env = $this->env();
       if($this->forms_contact_mod = $env->get_controller("forms/contact")){
         return $this->forms_contact_mod->validate();
@@ -12,36 +12,36 @@
       return "impossible de trouver le controlleur forms/contact";
     }
 
-    function contact_author(){
+    public function contact_author(){
       $env = $this->env();
       if(file_exists($env->path("mw_dir")."libs/ptitcaptcha.php")) require_once $env->path("mw_dir")."libs/ptitcaptcha.php";
       $data = $env->data();
-      if(($status = $data->source_status()) !== false)
-      { foreach($status as $id_source_status => $source_status)
-        { if($source_status["nom"] == "album") $album_status_id = $id_source_status;
+      if(($status = $data->source_status()) !== false){
+        foreach($status as $id_source_status => $source_status){
+          if($source_status["nom"] == "album") $album_status_id = $id_source_status;
           if(isset($album_status_id)) break;
         }
-        if(isset($album_status_id))
-        { if($groupe = $data->groupe($_GET[$env->param("id")]))
-          { if($groupe["contact_form"] && $groupe["email"])
-            { $env->set_out("groupe", $groupe);
+        if(isset($album_status_id)){
+          if($groupe = $data->groupe($_GET[$env->param("id")])){
+            if($groupe["contact_form"] && $groupe["email"]){
+              $env->set_out("groupe", $groupe);
               $select = array("status" => $album_status_id);
               $select["id_groupe"] = $groupe["id"];
-              if(($albums = $data->sources($select)) !== false)
-              { $env->set_out("albums", $albums);
-                if($_POST)
-                { if
-                  ( $this->send
-                    ( $env,
+              if(($albums = $data->sources($select)) !== false){
+                $env->set_out("albums", $albums);
+                if($_POST){
+                  if(
+                    $this->send(
+                      $env,
                       $_POST["email"],
                       "[".$env->config("site_name")." - ".$groupe["nom"]."] nouveau message",
                       $_POST["message"],
                       $groupe["email"],
                       $groupe["captcha"]
                     )
-                  )
-                  { $env->redirect
-                    ( $env->url("sources/groupe/view", array("id" => $_GET[$env->param("id")])),
+                  ){
+                    $env->redirect(
+                      $env->url("sources/groupe/view", array("id" => $_GET[$env->param("id")])),
                       "Le message a été envoyé"
                     );
                   }
@@ -49,8 +49,8 @@
               }
               else $env->erreur("impossible de lire la liste des albums");
             }
-            else
-            { $env->run("sources/groupe/view", array("get" => array("id" => $groupe["id"])));
+            else{
+              $env->run("sources/groupe/view", array("get" => array("id" => $groupe["id"])));
               return;
             }
           }
@@ -61,25 +61,25 @@
       else $env->erreur("Impossible de lire la liste des status de source");
     }
 
-    function send(&$env, $from, $titre, $message, $dest, $captcha)
-    { $env->set_out("ENVOYE", false);
+    public function send(&$env, $from, $titre, $message, $dest, $captcha){
+      $env->set_out("ENVOYE", false);
       if($captcha && !class_exists("PtitCaptchaHelper")){
         $env->erreur("fichier du captcha introuvable");
         return false;
       }
-      if(!$captcha || PtitCaptchaHelper::checkCaptcha())
-      { if($from)
-        { if($dest)
-          { if
-            ( mail
-              ( $dest,
+      if(!$captcha || PtitCaptchaHelper::checkCaptcha()){
+        if($from){
+          if($dest){
+            if(
+              mail(
+                $dest,
                 $titre,
                 $message,
                  "From: ".$from."\r\n"
                 ."Reply-To: ".$from."\r\n"
               )
-            )
-            { $env->set_out("ENVOYE", true);
+            ){
+              $env->set_out("ENVOYE", true);
               return true;
             }
             else $env->erreur("Erreur à l'envoi du mail");
@@ -93,5 +93,3 @@
     }
 
   }
-
-?>
\ No newline at end of file
diff --git a/app/controllers/sources/album.php b/app/controllers/sources/album.php
index 9364a64..8ede977 100644
--- a/app/controllers/sources/album.php
+++ b/app/controllers/sources/album.php
@@ -1,13 +1,13 @@
 env();
-      if($this->content_sources_mod = $env->get_controller("content/sources"))
-      { $this->content_sources_mod->validation_result = true;
+      if($this->content_sources_mod = $env->get_controller("content/sources")){
+        $this->content_sources_mod->validation_result = true;
         $this->content_sources_mod->validate_status($env);
         $this->content_sources_mod->validate_licences($env);
         return $this->content_sources_mod->validation_result;
@@ -15,23 +15,23 @@
       return "impossible de valider le module";
     }
 
-    function index(){
+    public function index(){
       $env = $this->env();
       $data = $env->data();
-      if(isset($this->content_sources_mod->licences) && $this->content_sources_mod->licences !== false)
-      { $env->set_out("licences", $this->content_sources_mod->licences);
-        if(($groupes = $data->groupes()) !== false)
-        { $env->set_out("groupes", $groupes);
+      if(isset($this->content_sources_mod->licences) && $this->content_sources_mod->licences !== false){
+        $env->set_out("licences", $this->content_sources_mod->licences);
+        if(($groupes = $data->groupes()) !== false){
+          $env->set_out("groupes", $groupes);
           $select = array();
           $select["status"] = $this->content_sources_mod->album_status_id;
           $select["order_by"] = "ordre";
           if(isset($_GET[$env->param("groupe")]) && $_GET[$env->param("groupe")]) $select["id_groupe"] = $_GET[$env->param("groupe")];
           $select["start"] = isset($_GET[$env->param("start")]) && $_GET[$env->param("start")] ? $_GET[$env->param("start")] : 0;
-          if(($albums = $data->sources($select)) !== false)
-          { $env->set_out("albums", $albums);
-            if(isset($_GET[$env->param("groupe")]) && $_GET[$env->param("groupe")])
-            { if(($groupe = $data->groupe($_GET[$env->param("groupe")])) !== false)
-              { $env->set_out("groupe", $groupe);
+          if(($albums = $data->sources($select)) !== false){
+            $env->set_out("albums", $albums);
+            if(isset($_GET[$env->param("groupe")]) && $_GET[$env->param("groupe")]){
+              if(($groupe = $data->groupe($_GET[$env->param("groupe")])) !== false){
+                $env->set_out("groupe", $groupe);
               }
               else $env->erreur("Impossible de lire les informations du groupe");
             }
@@ -42,26 +42,26 @@
       }
     }
 
-    function view(){
+    public function view(){
       $env = $this->env();
       $data = $env->data();
-      if(isset($this->content_sources_mod->licences) && $this->content_sources_mod->licences !== false)
-      { $env->set_out("licences", $this->content_sources_mod->licences);
-        if(isset($_GET[$env->param("album")]) && $_GET[$env->param("album")])
-        { if($album = $data->source($_GET[$env->param("album")], true))
-          { $env->set_out("album", $album);
+      if(isset($this->content_sources_mod->licences) && $this->content_sources_mod->licences !== false){
+        $env->set_out("licences", $this->content_sources_mod->licences);
+        if(isset($_GET[$env->param("album")]) && $_GET[$env->param("album")]){
+          if($album = $data->source($_GET[$env->param("album")], true)){
+            $env->set_out("album", $album);
             if($groupe = $data->get_admin_groupe($album["groupes"])){
 //              $env->set_out("groupe", $groupe);
               $env->set_out("groupes", $album["groupes"]);
               $select = array("status" => $this->content_sources_mod->album_status_id);
               $select["id_groupe"] = $groupe["id"];
-              if(($albums = $data->sources($select)) !== false)
-              { $env->set_out("albums", $albums);
+              if(($albums = $data->sources($select)) !== false){
+                $env->set_out("albums", $albums);
                 $select = array("status" => $this->content_sources_mod->morceau_status_id);
                 $select["id_composition"] = $album["id"];
                 $select["start"] = isset($_GET[$env->param("start")]) && $_GET[$env->param("start")] ? $_GET[$env->param("start")] : 0;
-                if(($morceaux = $data->sources($select)) !== false)
-                { $env->set_out("morceaux", $morceaux);
+                if(($morceaux = $data->sources($select)) !== false){
+                  $env->set_out("morceaux", $morceaux);
                 }
                 else $env->erreur("impossible de lire la liste des morceaux");
               }
@@ -76,5 +76,3 @@
     }
 
   }
-
-?>
\ No newline at end of file
diff --git a/app/controllers/sources/groupe.php b/app/controllers/sources/groupe.php
index 3400d7e..7f68416 100644
--- a/app/controllers/sources/groupe.php
+++ b/app/controllers/sources/groupe.php
@@ -1,13 +1,13 @@
 env();
-      if($this->content_sources_mod = $env->get_controller("content/sources"))
-      { $this->content_sources_mod->validation_result = true;
+      if($this->content_sources_mod = $env->get_controller("content/sources")){
+        $this->content_sources_mod->validation_result = true;
         $this->content_sources_mod->validate_status($env);
         $this->content_sources_mod->validate_licences($env);
         return $this->content_sources_mod->validation_result;
@@ -15,31 +15,34 @@
       return "impossible de valider le module";
     }
 
-    function index(){
+    public function index(){
       $env = $this->env();
       $data = $env->data();
-      if
-      ( ( $groupes = $data->groupes
-          ( null,
+      if(
+        (
+          $groupes = $data->groupes(
+            null,
             isset($_GET[$env->param("start")]) ? $_GET[$env->param("start")] : 0
           )
         ) !== false
-      ) $env->set_out("groupes", $groupes);
+      ){
+        $env->set_out("groupes", $groupes);
+      }
       else $env->erreur("Impossible de lire la liste des groupes");
     }
 
-    function view(){
+    public function view(){
       $env = $this->env();
       $data = $env->data();
-      if(isset($this->content_sources_mod->licences) && $this->content_sources_mod->licences !== false)
-      { $env->set_out("licences", $this->content_sources_mod->licences);
-        if(isset($_GET[$env->param("id")]) && $_GET[$env->param("id")])
-        { if(($groupe = $data->groupe($_GET[$env->param("id")])) !== false)
-          { $env->set_out("groupe", $groupe);
+      if(isset($this->content_sources_mod->licences) && $this->content_sources_mod->licences !== false){
+        $env->set_out("licences", $this->content_sources_mod->licences);
+        if(isset($_GET[$env->param("id")]) && $_GET[$env->param("id")]){
+          if(($groupe = $data->groupe($_GET[$env->param("id")])) !== false){
+            $env->set_out("groupe", $groupe);
             $select = array("status" => $this->content_sources_mod->album_status_id);
             $select["id_groupe"] = $groupe["id"];
-            if(($albums = $data->sources($select)) !== false)
-            { $env->set_out("albums", $albums);
+            if(($albums = $data->sources($select)) !== false){
+              $env->set_out("albums", $albums);
             }
             else $env->erreur("impossible de lire la liste des albums");
           }
@@ -51,5 +54,3 @@
     }
 
   }
-
-?>
\ No newline at end of file
diff --git a/app/controllers/sources/morceau.php b/app/controllers/sources/morceau.php
index 3d68bed..ffd1018 100644
--- a/app/controllers/sources/morceau.php
+++ b/app/controllers/sources/morceau.php
@@ -1,13 +1,13 @@
 env();
-      if($this->content_sources_mod = $env->get_controller("content/sources"))
-      { $this->content_sources_mod->validation_result = true;
+      if($this->content_sources_mod = $env->get_controller("content/sources")){
+        $this->content_sources_mod->validation_result = true;
         $this->content_sources_mod->validate_status($env);
         $this->content_sources_mod->validate_licences($env);
         return $this->content_sources_mod->validation_result;
@@ -15,26 +15,26 @@
       return "impossible de valider le module";
     }
 
-    function index(){
+    public function index(){
       $env = $this->env();
       $data = $env->data();
-      if($this->content_sources_mod->licences !== false)
-      { $env->set_out("licences", $this->content_sources_mod->licences);
-        if(($groupes = $data->groupes()) !== false)
-        { $env->set_out("groupes", $groupes);
+      if($this->content_sources_mod->licences !== false){
+        $env->set_out("licences", $this->content_sources_mod->licences);
+        if(($groupes = $data->groupes()) !== false){
+          $env->set_out("groupes", $groupes);
           $groupe = null;
           $album = null;
-          if(isset($_GET[$env->param("groupe")]) && $_GET[$env->param("groupe")])
-          { if(isset($groupes["list"][$_GET[$env->param("groupe")]]))
-            { $groupe = $groupes["list"][$_GET[$env->param("groupe")]];
+          if(isset($_GET[$env->param("groupe")]) && $_GET[$env->param("groupe")]){
+            if(isset($groupes["list"][$_GET[$env->param("groupe")]])){
+              $groupe = $groupes["list"][$_GET[$env->param("groupe")]];
               $env->set_out("groupe", $groupe);
             }
             else $groupe = false;
           }
-          if($groupe !== false)
-          { if(isset($_GET[$env->param("album")]) && $_GET[$env->param("album")])
-            { if(($album = $data->source($_GET[$env->param("album")], true)) !== false)
-              { $env->set_out("album", $album);
+          if($groupe !== false){
+            if(isset($_GET[$env->param("album")]) && $_GET[$env->param("album")]){
+              if(($album = $data->source($_GET[$env->param("album")], true)) !== false){
+                $env->set_out("album", $album);
 /*
                 if(!isset($groupe)){
                   $groupe = $data->get_admin_groupe($album["groupes"]);
@@ -44,13 +44,13 @@
               }
             }
           }
-          if($groupe !== false)
-          { $env->set_out("groupe", $groupe);
-            if($album !== false)
-            { $select = array("status" => $this->content_sources_mod->album_status_id);
+          if($groupe !== false){
+            $env->set_out("groupe", $groupe);
+            if($album !== false){
+              $select = array("status" => $this->content_sources_mod->album_status_id);
               if(isset($groupe)) $select["id_groupe"] = $groupe["id"];
-              if(($albums = $data->sources($select)) !== false)
-              { $env->set_out("albums", $albums);
+              if(($albums = $data->sources($select)) !== false){
+                $env->set_out("albums", $albums);
                 $select = array();
                 $select["status"] = $this->content_sources_mod->morceau_status_id;
                 $select["order_by"] = "ordre";
@@ -71,26 +71,26 @@
       else $env->erreur("Impossible de lire la liste des licences");
     }
 
-    function view(){
+    public function view(){
       $env = $this->env();
       $data = $env->data();
-      if($this->content_sources_mod->licences !== false)
-      { $env->set_out("licences", $this->content_sources_mod->licences);
-        if(isset($_GET[$env->param("morceau")]) && $_GET[$env->param("morceau")])
-        { if($morceau = $data->source($_GET[$env->param("morceau")], true))
-          { $env->set_out("morceau", $morceau);
+      if($this->content_sources_mod->licences !== false){
+        $env->set_out("licences", $this->content_sources_mod->licences);
+        if(isset($_GET[$env->param("morceau")]) && $_GET[$env->param("morceau")]){
+          if($morceau = $data->source($_GET[$env->param("morceau")], true)){
+            $env->set_out("morceau", $morceau);
             if($groupe = $data->get_admin_groupe($morceau["groupes"])){
 //              $env->set_out("groupe", $groupe);
               $env->set_out("groupes", $morceau["groupes"]);
               $select = array("status" => $this->content_sources_mod->album_status_id);
               $select["id_groupe"] = $groupe["id"];
-              if(($albums = $data->sources($select)) !== false)
-              { $env->set_out("albums", $albums);
-                if(($ariane = $data->source_ariane($morceau["id"])) !== false)
-                { $ariane = array_reverse($ariane);
+              if(($albums = $data->sources($select)) !== false){
+                $env->set_out("albums", $albums);
+                if(($ariane = $data->source_ariane($morceau["id"])) !== false){
+                  $ariane = array_reverse($ariane);
                   $album = null;
-                  foreach($ariane as $id_ariane => $source_ariane)
-                  { if(!isset($album)) $album = $source_ariane;
+                  foreach($ariane as $id_ariane => $source_ariane){
+                    if(!isset($album)) $album = $source_ariane;
                   }
                   if($album) $env->set_out("album", $album);
                 }
@@ -108,5 +108,3 @@
     }
 
   }
-
-?>
\ No newline at end of file
diff --git a/app/controllers/sources/piste.php b/app/controllers/sources/piste.php
index c6a26e4..fa853c3 100644
--- a/app/controllers/sources/piste.php
+++ b/app/controllers/sources/piste.php
@@ -1,13 +1,13 @@
 env();
-      if($this->content_sources_mod = $env->get_controller("content/sources"))
-      { $this->content_sources_mod->validation_result = true;
+      if($this->content_sources_mod = $env->get_controller("content/sources")){
+        $this->content_sources_mod->validation_result = true;
         $this->content_sources_mod->validate_status($env);
         $this->content_sources_mod->validate_licences($env);
         return $this->content_sources_mod->validation_result;
@@ -15,42 +15,42 @@
       return "impossible de valider le module";
     }
 
-    function index(){
+    public function index(){
       $env = $this->env();
       $data = $env->data();
-      if(isset($this->content_sources_mod->licences) && $this->content_sources_mod->licences !== false)
-      { $env->set_out("licences", $this->content_sources_mod->licences);
-        if(($groupes = $data->groupes()) !== false)
-        { $env->set_out("groupes", $groupes);
+      if(isset($this->content_sources_mod->licences) && $this->content_sources_mod->licences !== false){
+        $env->set_out("licences", $this->content_sources_mod->licences);
+        if(($groupes = $data->groupes()) !== false){
+          $env->set_out("groupes", $groupes);
           $groupe = null;
           $morceau = null;
-          if(isset($_GET[$env->param("groupe")]) && $_GET[$env->param("groupe")])
-          { if(isset($groupes["list"][$_GET[$env->param("groupe")]]))
-            { $groupe = $groupes["list"][$_GET[$env->param("groupe")]];
+          if(isset($_GET[$env->param("groupe")]) && $_GET[$env->param("groupe")]){
+            if(isset($groupes["list"][$_GET[$env->param("groupe")]])){
+              $groupe = $groupes["list"][$_GET[$env->param("groupe")]];
               $env->set_out("groupe", $groupe);
             }
             else $groupe = false;
           }
-          if($groupe !== false)
-          { if(isset($_GET[$env->param("morceau")]) && $_GET[$env->param("morceau")])
-            { if(($morceau = $data->source($_GET[$env->param("morceau")], true)) !== false)
-              { $env->set_out("morceau", $morceau);
+          if($groupe !== false){
+            if(isset($_GET[$env->param("morceau")]) && $_GET[$env->param("morceau")]){
+              if(($morceau = $data->source($_GET[$env->param("morceau")], true)) !== false){
+                $env->set_out("morceau", $morceau);
 /*
-                if(!isset($groupe))
-                { $groupe = $data->get_admin_groupe($morceau["groupes"]);
+                if(!isset($groupe)){
+                  $groupe = $data->get_admin_groupe($morceau["groupes"]);
                   if(!$groupe) $groupe = false;
                 }
 */
               }
             }
           }
-          if($groupe !== false)
-          { $env->set_out("groupe", $groupe);
-            if($morceau !== false)
-            { $select = array("status" => $this->content_sources_mod->morceau_status_id);
+          if($groupe !== false){
+            $env->set_out("groupe", $groupe);
+            if($morceau !== false){
+              $select = array("status" => $this->content_sources_mod->morceau_status_id);
               if(isset($groupe)) $select["id_groupe"] = $groupe["id"];
-              if(($morceaux = $data->sources($select)) !== false)
-              { $env->set_out("morceaux", $morceaux);
+              if(($morceaux = $data->sources($select)) !== false){
+                $env->set_out("morceaux", $morceaux);
                 $select = array();
                 $select["status"] = $this->content_sources_mod->piste_status_id;
                 $select["order_by"] = "ordre";
@@ -63,8 +63,8 @@
               else $env->erreur("impossible de lire la liste des morceaux");
               $select = array("status" => $this->content_sources_mod->album_status_id);
               if(isset($groupe)) $select["id_groupe"] = $groupe["id"];
-              if(($albums = $data->sources($select)) !== false)
-              { $env->set_out("albums", $albums);
+              if(($albums = $data->sources($select)) !== false){
+                $env->set_out("albums", $albums);
               }
               else $env->erreur("impossible de lire la liste des albums");
             }
@@ -77,29 +77,29 @@
       else $env->erreur("impossible de lire la liste des licences");
     }
 
-    function view(){
+    public function view(){
       $env = $this->env();
       $data = $env->data();
-      if(isset($this->content_sources_mod->licences) && $this->content_sources_mod->licences !== false)
-      { $env->set_out("licences", $this->content_sources_mod->licences);
-        if(isset($_GET[$env->param("piste")]) && $_GET[$env->param("piste")])
-        { if($piste = $data->source($_GET[$env->param("piste")], true))
-          { $env->set_out("piste", $piste);
+      if(isset($this->content_sources_mod->licences) && $this->content_sources_mod->licences !== false){
+        $env->set_out("licences", $this->content_sources_mod->licences);
+        if(isset($_GET[$env->param("piste")]) && $_GET[$env->param("piste")]){
+          if($piste = $data->source($_GET[$env->param("piste")], true)){
+            $env->set_out("piste", $piste);
             if($groupe = $data->get_admin_groupe($piste["groupes"])){
 //              $env->set_out("groupe", $groupe);
               $env->set_out("groupes", $piste["groupes"]);
               $select = array("status" => $this->content_sources_mod->album_status_id);
               $select["id_groupe"] = $groupe["id"];
-              if(($albums = $data->sources($select)) !== false)
-              { $env->set_out("albums", $albums);
-                if(($ariane = $data->source_ariane($piste["id"])) !== false)
-                { $ariane = array_reverse($ariane);
+              if(($albums = $data->sources($select)) !== false){
+                $env->set_out("albums", $albums);
+                if(($ariane = $data->source_ariane($piste["id"])) !== false){
+                  $ariane = array_reverse($ariane);
                   $morceau = null;
                   $album = null;
-                  foreach($ariane as $id_ariane => $source_ariane)
-                  { if(!isset($morceau)) $morceau = $source_ariane;
-                    else
-                    { if(!isset($album)) $album = $source_ariane;
+                  foreach($ariane as $id_ariane => $source_ariane){
+                    if(!isset($morceau)) $morceau = $source_ariane;
+                    else{
+                      if(!isset($album)) $album = $source_ariane;
                     }
                   }
                   if($morceau) $env->set_out("morceau", $morceau);
@@ -119,5 +119,3 @@
     }
 
   }
-
-?>
\ No newline at end of file
diff --git a/app/controllers/sources/waveforms.php b/app/controllers/sources/waveforms.php
index 556f22d..884d9c1 100644
--- a/app/controllers/sources/waveforms.php
+++ b/app/controllers/sources/waveforms.php
@@ -40,14 +40,14 @@
   
   */
 
-    function validate(){
+    public function validate(){
       if(PHP_SAPI != "cli"){
         return "utilisation en ligne de commande uniquement";
       }
       return true;
     }
 
-    function make(){
+    public function make(){
       $env = $this->env();
       $data = $env->data();
       $id_source = $_GET[$env->param("id")];
@@ -123,7 +123,7 @@
       }
     }
 
-    function make_all(){
+    public function make_all(){
       $env = $this->env();
       $data = $env->data();
       $base_url = $_GET[$env->param("from")];
@@ -201,5 +201,3 @@
     }
 
   }
-
-?>
\ No newline at end of file
diff --git a/app/controllers/users/albums.php b/app/controllers/users/albums.php
index 64f7789..97db03f 100644
--- a/app/controllers/users/albums.php
+++ b/app/controllers/users/albums.php
@@ -2,12 +2,11 @@
 
   class mw_users_albums extends mw_controller{
 
-    var $user;
+    public $user;
+    public $status;
+    public $album_status_id;
 
-    var $status;
-    var $album_status_id;
-
-    function validate(){
+    public function validate(){
       $env = $this->env();
       $data = $env->data();
       if(($this->status = $data->source_status()) === false){
@@ -28,7 +27,7 @@
       return true;
     }
 
-    function index(){
+    public function index(){
       $env = $this->env();
       $data = $env->data();
       if(($groupes = $data->groupes($this->user["id"])) === false){
@@ -77,7 +76,7 @@
       $env->set_out("albums", $albums);
     }
 
-    function add(){
+    public function add(){
       $env = $this->env();
       $data = $env->data();
       $album = $data->empty_source();
@@ -162,7 +161,7 @@
       $env->set_out("groupe", $groupe);
     }
 
-    function edit(){
+    public function edit(){
       $env = $this->env();
       $data = $env->data();
       if(($groupes = $data->groupes($this->user["id"])) === false){
@@ -272,7 +271,7 @@
       $env->set_out("album", $album);
     }
 
-    function del(){
+    public function del(){
       $env = $this->env();
       $data = $env->data();
       if(!($album = $data->source($_GET[$env->param("id")], true))){
@@ -294,7 +293,7 @@
       );
     }
 
-    function groupes(){
+    public function groupes(){
       $env = $this->env();
       if(
             !($sources_invitations_controller = $env->get_controller("users/sources_invitations"))
@@ -307,5 +306,3 @@
     }
 
   }
-
-?>
\ No newline at end of file
diff --git a/app/controllers/users/groupes.php b/app/controllers/users/groupes.php
index 8730e2c..27f063f 100644
--- a/app/controllers/users/groupes.php
+++ b/app/controllers/users/groupes.php
@@ -1,25 +1,25 @@
 env();
       $data = $env->data();
-      if($this->user = $env->user())
-      { if($env->etat("action") == "edit" || $env->etat("action") == "del")
-        { if
-          ( ( $this->groupe = $data->groupe
-              ( $_GET[$env->param("id")]
+      if($this->user = $env->user()){
+        if($env->etat("action") == "edit" || $env->etat("action") == "del"){
+          if(
+            (
+              $this->groupe = $data->groupe(
+                $_GET[$env->param("id")]
               )
             ) !== false
             && $this->groupe
-          )
-          { if($this->groupe["id_user"] == $this->user["id"])
-            { return true;
+          ){
+            if($this->groupe["id_user"] == $this->user["id"]){
+              return true;
             }
             else return "Vous n'est pas autorisé à modifier ce groupe";
           }
@@ -30,40 +30,39 @@
       return "Vous devez être identifier pour accéder à cette page";
     }
 
-    function index(){
+    public function index(){
       $env = $this->env();
       $data = $env->data();
-      if
-      ( $env->set_out
-        ( "groupes",
-          $data->groupes
-          ( $this->user["id"],
+      if(
+        $env->set_out(
+          "groupes",
+          $data->groupes(
+            $this->user["id"],
             isset($_GET[$env->param("start")]) ? $_GET[$env->param("start")] : 0
           )
         ) !== false
-      )
-      {
+      ){
       }
       else $env->erreur("Impossible de lire la liste des groupes");
     }
 
-    function add(){
+    public function add(){
       $env = $this->env();
       $data = $env->data();
-      if($data->check_user_uploads_dir())
-      { $web_path = $env->path("web");
+      if($data->check_user_uploads_dir()){
+        $web_path = $env->path("web");
         $upload_dir = $env->path("content")."uploads/".$this->user["id"];
         $_SESSION["upload_dir"] = $web_path.($web_path ? "" : "/").$upload_dir;
-        if($_POST)
-        { $env->set_out("groupe", $_POST);
+        if($_POST){
+          $env->set_out("groupe", $_POST);
           if(($image = $data->upload("image", $upload_dir)) !== false){
-            if(trim($_POST["nom"]))
-            { if(($exists = $data->groupe_exists($_POST["nom"])) !== false)
-              { if(!isset($_POST["contact_form"]) || trim($_POST["email"]))
-                { if($exists == 0)
-                  { if
-                    ( $data->add_groupe
-                      ( $this->user["id"],
+            if(trim($_POST["nom"])){
+              if(($exists = $data->groupe_exists($_POST["nom"])) !== false){
+                if(!isset($_POST["contact_form"]) || trim($_POST["email"])){
+                  if($exists == 0){
+                    if(
+                      $data->add_groupe(
+                        $this->user["id"],
                         $_POST["nom"],
                         $image ? $this->user["id"]."/".$image : null,
                         $_POST["description"],
@@ -71,10 +70,12 @@
                         isset($_POST["contact_form"]) ? 1 : 0,
                         isset($_POST["captcha"]) ? 1 : 0
                       )
-                    ) $env->redirect
-                    ( $env->url("users/groupes"),
-                      "le groupe a été ajouté"
-                    );
+                    ){
+                      $env->redirect(
+                        $env->url("users/groupes"),
+                        "le groupe a été ajouté"
+                      );
+                    }
                     else $env->erreur("Impossible d'ajouter le groupe");
                   }
                   else $env->message("Un groupe avec ce nom existe déjà");
@@ -91,45 +92,45 @@
       else $env->erreur("Impossible de creer le repertoire utilisateur");
     }
 
-    function edit(){
+    public function edit(){
       $env = $this->env();
       $data = $env->data();
-      if($data->check_user_uploads_dir())
-      { $web_path = $env->path("web");
+      if($data->check_user_uploads_dir()){
+        $web_path = $env->path("web");
         $upload_dir = $env->path("content")."uploads/".$this->user["id"];
         $_SESSION["upload_dir"] = $web_path.($web_path ? "" : "/").$upload_dir;
-        if($env->set_out("groupe", $this->groupe))
-        { $groupe = $env->out("groupe");
-          if($_POST)
-          { $id = $groupe["id"];
+        if($env->set_out("groupe", $this->groupe)){
+          $groupe = $env->out("groupe");
+          if($_POST){
+            $id = $groupe["id"];
             $nom = $groupe["nom"];
             $image = $groupe["image"];
             $_POST["image"] = $image ? $_SESSION["upload_dir"]."/".$image : "";
             $env->set_out("groupe", $_POST);
-            if(isset($_POST["del_image"]))
-            { if($image)
-              { if(@unlink($env->path("content")."uploads/".$image)) $image = "";
-                else
-                { $image = false;
+            if(isset($_POST["del_image"])){
+              if($image){
+                if(@unlink($env->path("content")."uploads/".$image)) $image = "";
+                else{
+                  $image = false;
                   $env->erreur("Impossible d'effacer l'image");
                 }
               }
               else $image = "";
             }
-            else
-            { if(($new_image = $data->upload("image", $upload_dir)) !== false)
-              { if($new_image) $image = $this->user["id"]."/".$new_image;
+            else{
+              if(($new_image = $data->upload("image", $upload_dir)) !== false){
+                if($new_image) $image = $this->user["id"]."/".$new_image;
               }
               else $env->erreur("Impossible d'uploader l'image");
             }
-            if($image !== false)
-            { if(trim($_POST["nom"]))
-              { if(($exists = $data->groupe_exists($_POST["nom"], $this->groupe["id"])) !== false)
-                { if(!$exists)
-                  { if(!isset($_POST["contact_form"]) || trim($_POST["email"]))
-                    { if
-                      ( $data->set_groupe
-                        ( $id,
+            if($image !== false){
+              if(trim($_POST["nom"])){
+                if(($exists = $data->groupe_exists($_POST["nom"], $this->groupe["id"])) !== false){
+                  if(!$exists){
+                    if(!isset($_POST["contact_form"]) || trim($_POST["email"])){
+                      if(
+                        $data->set_groupe(
+                          $id,
                           $_POST["nom"],
                           $image,
                           $_POST["description"],
@@ -137,10 +138,12 @@
                           isset($_POST["contact_form"]) ? 1 : 0,
                           isset($_POST["captcha"]) ? 1 : 0
                         )
-                      ) $env->redirect
-                      ( $env->url("users/groupes/edit", array("id" => $_GET[$env->param("id")])),
-                        "le groupe a été modifié"
-                      );
+                      ){
+                        $env->redirect(
+                          $env->url("users/groupes/edit", array("id" => $_GET[$env->param("id")])),
+                          "le groupe a été modifié"
+                        );
+                      }
                       else $env->erreur("Impossible de modifier le groupe");
                     }
                     else $env->message("merci de préciser un email pour le formulaire de contact");
@@ -152,8 +155,8 @@
               else $env->message("merci de préciser un nom pour le groupe");
             }
           }
-          else
-          { $env->set_out("groupe", $groupe);
+          else{
+            $env->set_out("groupe", $groupe);
           }
         }
         else $env->erreur("Impossible de lire les informations du groupe");
@@ -161,23 +164,25 @@
       else $env->erreur("Impossible de creer le repertoire utilisateur");
     }
 
-    function del(){
+    public function del(){
       $env = $this->env();
       $data = $env->data();
-      if(($res = $data->del_groupe($this->groupe["id"])) !== false)
-      { if($res === 1) $env->redirect
-        ( $env->url("users/groupes"),
-          "Ce groupe a des sources sur ce site, il n'a pas été supprimé.",
-          5
-        );
-        else $env->redirect
-        ( $env->url("users/groupes"),
-          "le groupe a été supprimé"
-        );
+      if(($res = $data->del_groupe($this->groupe["id"])) !== false){
+        if($res === 1){
+          $env->redirect(
+            $env->url("users/groupes"),
+            "Ce groupe a des sources sur ce site, il n'a pas été supprimé.",
+            5
+          );
+        }
+        else{
+          $env->redirect(
+            $env->url("users/groupes"),
+            "le groupe a été supprimé"
+          );
+        }
       }
       else $env->erreur("Impossible de supprimer le groupe");
     }
 
   }
-
-?>
\ No newline at end of file
diff --git a/app/controllers/users/morceaux.php b/app/controllers/users/morceaux.php
index 11004d0..9bf2fdf 100644
--- a/app/controllers/users/morceaux.php
+++ b/app/controllers/users/morceaux.php
@@ -2,13 +2,12 @@
 
   class mw_users_morceaux extends mw_controller{
 
-    var $user;
+    public $user;
+    public $status;
+    public $album_status_id;
+    public $morceau_status_id;
 
-    var $status;
-    var $album_status_id;
-    var $morceau_status_id;
-
-    function validate(){
+    public function validate(){
       $env = $this->env();
       $data = $env->data();
       if(($this->status = $data->source_status()) === false){
@@ -29,7 +28,7 @@
       return true;
     }
 
-    function index(){
+    public function index(){
       $env = $this->env();
       $data = $env->data();
       if(($groupes = $data->groupes($this->user["id"])) === false){
@@ -105,7 +104,7 @@
       $env->set_out("morceaux", $morceaux);
     }
 
-    function add(){
+    public function add(){
       $env = $this->env();
       $data = $env->data();
       $morceau = $data->empty_source();
@@ -275,7 +274,7 @@
       $env->set_out("album", $album);
     }
 
-    function edit(){
+    public function edit(){
       $env = $this->env();
       $data = $env->data();
       if(($groupes = $data->groupes($this->user["id"])) === false){
@@ -324,7 +323,10 @@
         $env->erreur("Impossible de lire la liste des compositions");
         return;
       }
-      if($compositions) foreach($compositions[$morceau["id"]] as $id_album) { $morceau["album"] = $id_album; break; }
+      if($compositions) foreach($compositions[$morceau["id"]] as $id_album){
+        $morceau["album"] = $id_album;
+        break;
+      }
       if($_POST){
         $source_infos = array(
           "date_inscription" => $_POST["date_inscription"],
@@ -472,7 +474,7 @@
       $env->set_out("morceau", $morceau);
     }
 
-    function maj_xml(){
+    public function maj_xml(){
       $env = $this->env();
       $data = $env->data();
       if(!($morceau = $data->source($_GET[$env->param("id")], true))){
@@ -535,7 +537,7 @@
       $env->run("users/morceaux/edit", array("get" => array("id" => $morceau["id"])));
     }
 
-    function del(){
+    public function del(){
       $env = $this->env();
       $data = $env->data();
       if(!($morceau = $data->source($_GET[$env->param("id")], true))){
@@ -557,7 +559,7 @@
       );
     }
 
-    function groupes(){
+    public function groupes(){
       $env = $this->env();
       if(
             !($sources_invitations_controller = $env->get_controller("users/sources_invitations"))
@@ -570,5 +572,3 @@
     }
 
   }
-
-?>
\ No newline at end of file
diff --git a/app/controllers/users/pistes.php b/app/controllers/users/pistes.php
index 7269cbb..fa2dbae 100644
--- a/app/controllers/users/pistes.php
+++ b/app/controllers/users/pistes.php
@@ -2,14 +2,13 @@
 
   class mw_users_pistes extends mw_controller{
 
-    var $user;
+    public $user;
+    public $status;
+    public $album_status_id;
+    public $morceau_status_id;
+    public $piste_status_id;
 
-    var $status;
-    var $album_status_id;
-    var $morceau_status_id;
-    var $piste_status_id;
-
-    function validate(){
+    public function validate(){
       $env = $this->env();
       $data = $env->data();
       if(($this->status = $data->source_status()) === false){
@@ -34,7 +33,7 @@
       return true;
     }
 
-    function index(){
+    public function index(){
       $env = $this->env();
       $data = $env->data();
       if(($groupes = $data->groupes($this->user["id"])) === false){
@@ -110,7 +109,7 @@
       $env->set_out("pistes", $pistes);
     }
 
-    function add(){
+    public function add(){
       $env = $this->env();
       $data = $env->data();
       $piste = $data->empty_source();
@@ -281,7 +280,7 @@
       $env->set_out("morceau", $morceau);
     }
 
-    function edit(){
+    public function edit(){
       $env = $this->env();
       $data = $env->data();
       if(($groupes = $data->groupes($this->user["id"])) === false){
@@ -330,7 +329,10 @@
         $env->erreur("Impossible de lire la liste des compositions");
         return;
       }
-      if($compositions) foreach($compositions[$piste["id"]] as $id_morceau) { $piste["morceau"] = $id_morceau; break; }
+      if($compositions) foreach($compositions[$piste["id"]] as $id_morceau){
+        $piste["morceau"] = $id_morceau;
+        break;
+      }
       if($_POST){
         $permissions = $piste["permissions"];
         $image = isset($piste["image"]) ? $piste["image"] : null;
@@ -476,7 +478,7 @@
       $env->set_out("piste", $piste);
     }
 
-    function maj_xml(){
+    public function maj_xml(){
       $env = $this->env();
       $data = $env->data();
       if(!($piste = $data->source($_GET[$env->param("id")], true))){
@@ -540,7 +542,7 @@
       $env->run("users/pistes/edit", array("get" => array("id" => $piste["id"])));
     }
 
-    function del(){
+    public function del(){
       $env = $this->env();
       $data = $env->data();
       if(!($piste = $data->source($_GET[$env->param("id")], true))){
@@ -562,7 +564,7 @@
       );
     }
 
-    function groupes(){
+    public function groupes(){
       $env = $this->env();
       if(
             !($sources_invitations_controller = $env->get_controller("users/sources_invitations"))
@@ -575,5 +577,3 @@
     }
 
   }
-
-?>
\ No newline at end of file
diff --git a/app/controllers/users/sources.php b/app/controllers/users/sources.php
index f962924..b125eda 100644
--- a/app/controllers/users/sources.php
+++ b/app/controllers/users/sources.php
@@ -1,58 +1,56 @@
 data();
+    public function get_source_from_xml(&$env, $xml_url, $xml_content, $xml_use_edit_content){
+      $data = $env->data();
       $source = $data->empty_source();
-      $source_xml = array
-      ( "url" => $xml_url,
+      $source_xml = array(
+        "url" => $xml_url,
         "content" => $xml_content,
         "use_edit_content" => $xml_use_edit_content
       );
-      if($source_xml["url"])
-      { if($source_xml["content"])
-        { if
-          ( ( $source = $data->source_xml_read
-              ( $source_xml["url"],
+      if($source_xml["url"]){
+        if($source_xml["content"]){
+          if(
+            (
+              $source = $data->source_xml_read(
+                $source_xml["url"],
                 $source_xml["content"]
               )
             ) === false
-          )
-          { $source = $data->empty_source();
-            $env->message
-            ( "Code XML invalide pour :"
+          ){
+            $source = $data->empty_source();
+            $env->message(
+              "Code XML invalide pour :"
              ."
".$source_xml["url"]."" ); } } - else - { if($source_xml["content"] === false) - { $env->message - ( "Impossible de lire le contenu du fichier XML pour :" + else{ + if($source_xml["content"] === false){ + $env->message( + "Impossible de lire le contenu du fichier XML pour :" ."
".$source_xml["url"]."" ); } - else - { $env->message - ( "Le contenu du fichier XML est vide pour :" + else{ + $env->message( + "Le contenu du fichier XML est vide pour :" ."
".$source_xml["url"]."" ); } } } - else - { $env->message("Merci de préciser l'ULR du fichier XML"); + else{ + $env->message("Merci de préciser l'ULR du fichier XML"); } $source["xml"] = $source_xml; return $source; } } - -?> \ No newline at end of file diff --git a/app/controllers/users/sources_invitations.php b/app/controllers/users/sources_invitations.php index 6691283..a56dd49 100644 --- a/app/controllers/users/sources_invitations.php +++ b/app/controllers/users/sources_invitations.php @@ -2,14 +2,13 @@ class mw_users_sources_invitations extends mw_controller{ - var $user; + public $user; + public $status; + public $album_status_id; + public $morceau_status_id; + public $piste_status_id; - var $status; - var $album_status_id; - var $morceau_status_id; - var $piste_status_id; - - function validate(){ + public function validate(){ $env = $this->env(); $data = $env->data(); if(($this->status = $data->source_status()) === false){ @@ -34,7 +33,7 @@ return true; } - function index(){ + public function index(){ $env = $this->env(); $data = $env->data(); if(($sources_access = $data->sources_access()) === false){ @@ -72,7 +71,7 @@ $env->set_out("status", $this->status); } - function source_groupes(){ + public function source_groupes(){ $env = $this->env(); $data = $env->data(); if(!($source = $data->source($_GET[$env->param("id")], true))){ @@ -126,7 +125,7 @@ $env->set_out("invitations", $invitations); } - function invite_groupe(){ + public function invite_groupe(){ $env = $this->env(); $data = $env->data(); if(!($source = $data->source($_GET[$env->param("id")], true))){ @@ -168,7 +167,7 @@ ); } - function annule_invitation_groupe(){ + public function annule_invitation_groupe(){ $env = $this->env(); $data = $env->data(); if(!($invitation = $data->get_sml_sources_invitations("id", $_GET[$env->param("id")]))){ @@ -194,7 +193,7 @@ ); } - function accepter_invitation_groupe(){ + public function accepter_invitation_groupe(){ $env = $this->env(); $data = $env->data(); if(($groupes = $data->groupes($this->user["id"])) === false){ @@ -235,7 +234,7 @@ ); } - function refuser_invitation_groupe(){ + public function refuser_invitation_groupe(){ $env = $this->env(); $data = $env->data(); if(($groupes = $data->groupes($this->user["id"])) === false){ @@ -264,7 +263,7 @@ ); } - function del_groupe(){ + public function del_groupe(){ $env = $this->env(); $data = $env->data(); if(!($source = $data->source($_GET[$env->param("id")], true))){ @@ -325,5 +324,3 @@ } } - -?> \ No newline at end of file diff --git a/app/data/modules/share/sml_data_sources_cache.php b/app/data/modules/share/sml_data_sources_cache.php index aa65109..fcdd88a 100644 --- a/app/data/modules/share/sml_data_sources_cache.php +++ b/app/data/modules/share/sml_data_sources_cache.php @@ -18,7 +18,7 @@ * sa date de validite est depassee * */ - function get_source_xml_from_cache($url, $IGNORE_UPDATE = false){ + public function get_source_xml_from_cache($url, $IGNORE_UPDATE = false){ $env = $this->env(); $sgbd = $this->sgbd(); if(($cache_infos = $this->source_cache_infos_db($url)) !== false){ @@ -71,23 +71,23 @@ * $cache_time : duree, en secondes * */ - function cache_need_update($last_update, $cache_time) - { $v_last_update = explode(" ", $last_update); - if(count($v_last_update) == 2) - { $v_date = explode("-", $v_last_update[0]); - if(count($v_date) == 3) - { $v_time = explode(":", $v_last_update[1]); - if(count($v_time) == 3) - { if - ( preg_match("/^[0-9]+$/", $v_date[0]) + public function cache_need_update($last_update, $cache_time){ + $v_last_update = explode(" ", $last_update); + if(count($v_last_update) == 2){ + $v_date = explode("-", $v_last_update[0]); + if(count($v_date) == 3){ + $v_time = explode(":", $v_last_update[1]); + if(count($v_time) == 3){ + if( + preg_match("/^[0-9]+$/", $v_date[0]) && preg_match("/^[0-9]+$/", $v_date[1]) && preg_match("/^[0-9]+$/", $v_date[2]) && preg_match("/^[0-9]+$/", $v_time[0]) && preg_match("/^[0-9]+$/", $v_time[1]) && preg_match("/^[0-9]+$/", $v_time[2]) && preg_match("/^[0-9]+$/", $cache_time) - ) - { return (time() - mktime($v_time[0], $v_time[1], $v_time[2], $v_date[1], $v_date[2], $v_date[0])) < $cache_time ? 0 : 1; + ){ + return (time() - mktime($v_time[0], $v_time[1], $v_time[2], $v_date[1], $v_date[2], $v_date[0])) < $cache_time ? 0 : 1; } } } @@ -103,7 +103,7 @@ * $xml_content : le contenu du fichier XML * */ - function add_source_cache($url, $xml_content){ + public function add_source_cache($url, $xml_content){ $env = $this->env(); $sgbd = $this->sgbd(); if(($cache_index = $this->inc_sources_cache_index()) !== false){ @@ -131,17 +131,17 @@ * FAUX si le cache n'a pas pu etre mis a jour avec les nouvelles infos * */ - function maj_source_cache($url) - { if($this->buffer = @file_get_contents($url)) - { if($this->parse_source_xml($this->buffer)) - { if(($cache_infos = $this->source_cache_infos_db($url)) !== false) - { if($cache_infos) - { if($this->del_source_cache($cache_infos["id"], $cache_infos["id_source"])) - { if($this->add_source_cache($url, $this->buffer)) return true; + public function maj_source_cache($url){ + if($this->buffer = @file_get_contents($url)){ + if($this->parse_source_xml($this->buffer)){ + if(($cache_infos = $this->source_cache_infos_db($url)) !== false){ + if($cache_infos){ + if($this->del_source_cache($cache_infos["id"], $cache_infos["id_source"])){ + if($this->add_source_cache($url, $this->buffer)) return true; } } - else - { if($this->add_source_cache($url, $this->buffer)) return true; + else{ + if($this->add_source_cache($url, $this->buffer)) return true; } } return false; @@ -155,7 +155,7 @@ * vide le cache * */ - function empty_source_cache(){ + public function empty_source_cache(){ $OK = true; if(($cache = $this->source_cache_db()) !== false){ foreach($cache as $id_cache => $cache_infos){ @@ -178,10 +178,10 @@ * $id_xml_cache : l'index du contenu XML dans le cache * */ - function del_source_cache($id_cache_data, $id_xml_cache) - { $env = $this->env(); - if($this->del_source_cache_db($id_cache_data)) - { if(@unlink($env->path("content")."cache/sources/".$id_xml_cache.".xml")) return true; + public function del_source_cache($id_cache_data, $id_xml_cache){ + $env = $this->env(); + if($this->del_source_cache_db($id_cache_data)){ + if(@unlink($env->path("content")."cache/sources/".$id_xml_cache.".xml")) return true; } return false; } @@ -192,13 +192,13 @@ * et les cree sinon * */ - function init_sources_cache() - { $env = $this->env(); + public function init_sources_cache(){ + $env = $this->env(); if(!is_dir($env->path("content")."cache")) @mkdir($env->path("content")."cache"); - if(is_dir($env->path("content")."cache")) - { if(!is_dir($env->path("content")."cache/sources")) @mkdir($env->path("content")."cache/sources"); - if(is_dir($env->path("content")."cache/sources")) - { return true; + if(is_dir($env->path("content")."cache")){ + if(!is_dir($env->path("content")."cache/sources")) @mkdir($env->path("content")."cache/sources"); + if(is_dir($env->path("content")."cache/sources")){ + return true; } } return "impossible d'initialiser le cache"; @@ -208,7 +208,7 @@ * incremente l'index du cache et retourne le nouvel index * */ - function inc_sources_cache_index(){ + public function inc_sources_cache_index(){ clearstatcache(); $env = $this->env(); $cache_index = false; @@ -246,5 +246,3 @@ } } - -?> \ No newline at end of file diff --git a/app/data/modules/share/sml_data_sources_xml.php b/app/data/modules/share/sml_data_sources_xml.php index 1cf0cc4..47b94fd 100644 --- a/app/data/modules/share/sml_data_sources_xml.php +++ b/app/data/modules/share/sml_data_sources_xml.php @@ -1,10 +1,9 @@ env(); + public function get_source_xml_from_url($url, $IGNORE_UPDATE = false){ + $env = $this->env(); if($env->config("cache_actif")) return $this->get_source_xml_from_cache($url, $IGNORE_UPDATE); else return @file_get_contents($url); } @@ -13,8 +12,8 @@ # XML source # - function set_source_xml($id, $params = array()) - { $env = $this->env(); + public function set_source_xml($id, $params = array()){ + $env = $this->env(); $OK = false; if(strlen($id) > 0 && ($fh = @fopen($this->source_xml_path($id), "wb")) !== false){ if(($content = $this->source_xml_content($id, $params)) !== false){ @@ -25,15 +24,15 @@ return $OK; } - function maj_source_xml_groupe($groupe) - { $OK = true; - if($groupe !== false) - { $sgbd = $this->sgbd(); + public function maj_source_xml_groupe($groupe){ + $OK = true; + if($groupe !== false){ + $sgbd = $this->sgbd(); $env = $this->env(); - if(($sources = $this->sources(array("id_groupe" => $groupe["id"]))) !== false) - { foreach($sources["list"] as $id_source => $source) - { if(!$this->set_source_xml($source["id"], array("source" => $source))) - { $OK = false; + if(($sources = $this->sources(array("id_groupe" => $groupe["id"]))) !== false){ + foreach($sources["list"] as $id_source => $source){ + if(!$this->set_source_xml($source["id"], array("source" => $source))){ + $OK = false; break; } } @@ -44,15 +43,15 @@ return $OK; } - function maj_source_xml_licence($licence) - { $OK = true; - if($licence !== false) - { $sgbd = $this->sgbd(); + public function maj_source_xml_licence($licence){ + $OK = true; + if($licence !== false){ + $sgbd = $this->sgbd(); $env = $this->env(); - if(($sources = $this->sources(array("id_licence" => $licence["id"]))) !== false) - { foreach($sources["list"] as $id_source => $source) - { if(!$this->set_source_xml($source["id"], array("source" => $source))) - { $OK = false; + if(($sources = $this->sources(array("id_licence" => $licence["id"]))) !== false){ + foreach($sources["list"] as $id_source => $source){ + if(!$this->set_source_xml($source["id"], array("source" => $source))){ + $OK = false; break; } } @@ -63,14 +62,14 @@ return $OK; } - function maj_source_xml_all() - { $OK = true; + public function maj_source_xml_all(){ + $OK = true; $sgbd = $this->sgbd(); $env = $this->env(); - if(($sources = $this->sources(array())) !== false) - { foreach($sources["list"] as $id_source => $source) - { if(!$this->set_source_xml($source["id"], array("source" => $source))) - { $OK = false; + if(($sources = $this->sources(array())) !== false){ + foreach($sources["list"] as $id_source => $source){ + if(!$this->set_source_xml($source["id"], array("source" => $source))){ + $OK = false; break; } } @@ -79,18 +78,18 @@ return $OK; } - function get_source_xml($id_source) - { $source_file = $this->source_xml_path($id_source); - if(file_exists($source_file)) - { return @file_get_contents($source_file); + public function get_source_xml($id_source){ + $source_file = $this->source_xml_path($id_source); + if(file_exists($source_file)){ + return @file_get_contents($source_file); } return ""; } - function del_source_xml($id_source) - { $env = $this->env(); - if(file_exists($this->source_xml_path($id_source))) - { return + public function del_source_xml($id_source){ + $env = $this->env(); + if(file_exists($this->source_xml_path($id_source))){ + return $this->del_edit_derivations(array("id_source" => $id_source)) && $this->del_edit_reference_content($id_source) && @unlink($this->source_xml_path($id_source)); @@ -102,17 +101,17 @@ # edition XML derivation # - function set_edit_derivation_content($id_source, $id_source_derivation, $content) - { $env = $this->env(); + public function set_edit_derivation_content($id_source, $id_source_derivation, $content){ + $env = $this->env(); $derivations_dir = $this->derivations_edit_xml_dir_path(); if(!file_exists($derivations_dir) || !is_dir($derivations_dir)) @mkdir($derivations_dir); - if(file_exists($derivations_dir) && is_dir($derivations_dir)) - { $derivations_dir = $this->derivations_edit_xml_dir_path($id_source); + if(file_exists($derivations_dir) && is_dir($derivations_dir)){ + $derivations_dir = $this->derivations_edit_xml_dir_path($id_source); if(!file_exists($derivations_dir) || !is_dir($derivations_dir)) @mkdir($derivations_dir); - if(file_exists($derivations_dir) && is_dir($derivations_dir)) - { if($fh = @fopen($this->derivation_edit_xml_path($id_source, $id_source_derivation), "w+")) - { if(@fwrite($fh, $content)) - { @fclose($fh); + if(file_exists($derivations_dir) && is_dir($derivations_dir)){ + if($fh = @fopen($this->derivation_edit_xml_path($id_source, $id_source_derivation), "w+")){ + if(@fwrite($fh, $content)){ + @fclose($fh); return true; } @fclose($fh); @@ -122,35 +121,35 @@ return false; } - function get_edit_derivation_content($id_source, $id_source_derivation) - { $env = $this->env(); + public function get_edit_derivation_content($id_source, $id_source_derivation){ + $env = $this->env(); $derivation_file = $this->derivation_edit_xml_path($id_source, $id_source_derivation); $derivation_content = ""; - if(file_exists($derivation_file)) - { $derivation_content = @file_get_contents($derivation_file); + if(file_exists($derivation_file)){ + $derivation_content = @file_get_contents($derivation_file); } return $derivation_content; } - function del_edit_derivation_content($id_source, $id_source_derivation) - { $env = $this->env(); + public function del_edit_derivation_content($id_source, $id_source_derivation){ + $env = $this->env(); $derivation_file = $this->derivation_edit_xml_path($id_source, $id_source_derivation); $OK = true; - if(file_exists($derivation_file)) - { $OK = @unlink($derivation_file); + if(file_exists($derivation_file)){ + $OK = @unlink($derivation_file); } return $OK; } - function del_edit_derivations($id_source) - { $env = $this->env(); + public function del_edit_derivations($id_source){ + $env = $this->env(); $derivations_dir = $this->derivations_edit_xml_dir_path($id_source); $OK = true; - if(is_dir($derivations_dir)) - { if($dh = opendir($derivations_dir)) - { while($OK && (($file = readdir($dh)) !== false)) - { if(preg_match("/^.+\.xml$/", $file)) - { $OK = @unlink($derivations_dir.$file) && $OK; + if(is_dir($derivations_dir)){ + if($dh = opendir($derivations_dir)){ + while($OK && (($file = readdir($dh)) !== false)){ + if(preg_match("/^.+\.xml$/", $file)){ + $OK = @unlink($derivations_dir.$file) && $OK; } } closedir($dh); @@ -166,14 +165,14 @@ # edition XML reference # - function set_edit_reference_content($id_source, $content) - { $env = $this->env(); + public function set_edit_reference_content($id_source, $content){ + $env = $this->env(); $references_dir = $this->reference_edit_xml_dir_path(); if(!file_exists($references_dir) || !is_dir($references_dir)) @mkdir($references_dir); - if(file_exists($references_dir) && is_dir($references_dir)) - { if($fh = @fopen($this->reference_edit_xml_path($id_source), "w+")) - { if(@fwrite($fh, $content)) - { @fclose($fh); + if(file_exists($references_dir) && is_dir($references_dir)){ + if($fh = @fopen($this->reference_edit_xml_path($id_source), "w+")){ + if(@fwrite($fh, $content)){ + @fclose($fh); return true; } @fclose($fh); @@ -182,26 +181,24 @@ return false; } - function get_edit_reference_content($id_source) - { $env = $this->env(); + public function get_edit_reference_content($id_source){ + $env = $this->env(); $reference_file = $this->reference_edit_xml_path($id_source); $reference_content = ""; - if(file_exists($reference_file)) - { $reference_content = @file_get_contents($reference_file); + if(file_exists($reference_file)){ + $reference_content = @file_get_contents($reference_file); } return $reference_content; } - function del_edit_reference_content($id_source) - { $env = $this->env(); + public function del_edit_reference_content($id_source){ + $env = $this->env(); $reference_file = $this->reference_edit_xml_path($id_source); $OK = true; - if(file_exists($reference_file)) - { $OK = @unlink($reference_file); + if(file_exists($reference_file)){ + $OK = @unlink($reference_file); } return $OK; } } - -?> \ No newline at end of file diff --git a/app/data/modules/share/sml_data_sources_xml_format.php b/app/data/modules/share/sml_data_sources_xml_format.php index 676262a..e9d2804 100644 --- a/app/data/modules/share/sml_data_sources_xml_format.php +++ b/app/data/modules/share/sml_data_sources_xml_format.php @@ -2,18 +2,18 @@ class sml_data_sources_xml_format extends mw_data{ - var $status; // classes de sources - table sml_classes - var $source; - var $groupes; - var $licence; - var $sources; - var $xml_content; + public $status; // classes de sources - table sml_classes + public $source; + public $groupes; + public $licence; + public $sources; + public $xml_content; # ---------------------------------------------------------------------------------------- # data vers XML # - function source_xml_content($id, $params = array()){ + public function source_xml_content($id, $params = array()){ $env = $this->env(); $content = false; $this->status = isset($this->status) ? $this->status : $this->source_status(); @@ -96,13 +96,13 @@ # XML vers data # - function parse_source_xml($xml_content){ + public function parse_source_xml($xml_content){ if(!isset($this->sxml)) $this->sxml = new sxml(); $this->sxml->parse($xml_content); return isset($this->sxml->data["source"][0]); } - function empty_source($params = array()){ + public function empty_source($params = array()){ $source = array( "groupes" => array(), "titre" => "", @@ -125,7 +125,7 @@ return $source; } - function source_xml_read($url, $xml_content = null){ + public function source_xml_read($url, $xml_content = null){ $source = $this->empty_source(); if($this->xml_content = (isset($xml_content) ? $xml_content : $this->get_source_xml_from_url($url))){ if($this->xml_content === -1) $this->xml_content = $this->get_source_xml_from_url($url, true); @@ -147,14 +147,14 @@ return $source; } - function parse_source_buffer($source_xml_version, $default_source = null){ + public function parse_source_buffer($source_xml_version, $default_source = null){ if(method_exists($this, $method_name = "parse_source_buffer_".$source_xml_version)){ return $this->$method_name($default_source); } return false; } - function get_source_buffer_xml_version(){ + public function get_source_buffer_xml_version(){ if(!isset($this->buffer["subs"])) return false; foreach($this->buffer["subs"] as $key => $value){ if($key == "titre" || $key == "auteur"){ @@ -168,7 +168,7 @@ // -------------------------------------- source XML v2 - function parse_source_buffer_v2($default_source = null){ + public function parse_source_buffer_v2($default_source = null){ if(isset($default_source)) $source = $default_source; else $source = $this->empty_source(); if(!isset($this->buffer["subs"])) return $source; @@ -237,7 +237,7 @@ // -------------------------------------- source XML v1 - function parse_source_buffer_v1($default_source = null){ + public function parse_source_buffer_v1($default_source = null){ if(isset($default_source)) $source = $default_source; else $source = $this->empty_source(); if(!isset($this->buffer["subs"])) return $source; @@ -289,5 +289,3 @@ } } - -?> \ No newline at end of file diff --git a/app/data/modules/share/sml_data_sources_xml_pathes.php b/app/data/modules/share/sml_data_sources_xml_pathes.php index f49d891..605d60e 100644 --- a/app/data/modules/share/sml_data_sources_xml_pathes.php +++ b/app/data/modules/share/sml_data_sources_xml_pathes.php @@ -2,7 +2,7 @@ class sml_data_sources_xml_pathes extends mw_data{ - function init_source_xml_pathes(){ + public function init_source_xml_pathes(){ $env = $this->env(); $sources_dir = $env->path("content")."sources/"; if(!is_dir($sources_dir)){ @@ -25,42 +25,40 @@ return true; } - function source_xml_path($id_source){ + public function source_xml_path($id_source){ if(!$this->init_source_xml_pathes()) return false; $env = $this->env(); return $env->path("content")."sources/".$id_source.".xml"; } - function reference_edit_xml_dir_path(){ + public function reference_edit_xml_dir_path(){ if(!$this->init_source_xml_pathes()) return false; $env = $this->env(); return $env->path("content")."sources/references/"; } - function reference_edit_xml_path($id_source){ + public function reference_edit_xml_path($id_source){ if(!$this->init_source_xml_pathes()) return false; $env = $this->env(); return $this->reference_edit_xml_dir_path().$id_source.".xml"; } - function derivations_edit_xml_dir_path($id_source = null){ + public function derivations_edit_xml_dir_path($id_source = null){ if(!$this->init_source_xml_pathes()) return false; $env = $this->env(); return $env->path("content")."sources/derivations/".(isset($id_source) ? $id_source."/" : ""); } - function derivation_edit_xml_path($id_source, $id_source_derivation){ + public function derivation_edit_xml_path($id_source, $id_source_derivation){ if(!$this->init_source_xml_pathes()) return false; $env = $this->env(); return $this->derivations_edit_xml_dir_path($id_source).$id_source_derivation.".xml"; } - function source_xml_url($id_source){ + public function source_xml_url($id_source){ if(!$this->init_source_xml_pathes()) return false; $env = $this->env(); return "http://".$_SERVER["SERVER_NAME"].$env->path("web").$this->source_xml_path($id_source); } } - -?> \ No newline at end of file diff --git a/app/data/modules/share/sml_data_waveforms.php b/app/data/modules/share/sml_data_waveforms.php index 91a3011..306cb8b 100644 --- a/app/data/modules/share/sml_data_waveforms.php +++ b/app/data/modules/share/sml_data_waveforms.php @@ -2,9 +2,9 @@ class sml_data_waveforms extends mw_data{ - var $SOX_EXISTS; + public $SOX_EXISTS; - function init_waveform_dirs(){ + public function init_waveform_dirs(){ $env = $this->env(); $dir = $env->path("content")."tmp"; if(!is_dir($dir)) @mkdir($dir); @@ -15,7 +15,7 @@ return true; } - function audio_to_png($params = array()){ + public function audio_to_png($params = array()){ $env = $this->env(); $audio_file = $params["audio_file"]; if(!$audio_file) return false; @@ -91,11 +91,11 @@ // utilitaires // - function sox_command($audio_file, $wav_file){ + public function sox_command($audio_file, $wav_file){ return "sox -V \"".$audio_file."\" -b 16 -r 8000 -c 1 \"".$wav_file."\""; } - function sox_exists(){ + public function sox_exists(){ if(isset($this->SOX_EXISTS)){ return $this->SOX_EXISTS; } @@ -127,7 +127,7 @@ return $this->SOX_EXISTS; } - function audio_to_wav($audio_file, $wav_file){ + public function audio_to_wav($audio_file, $wav_file){ if(!$this->sox_exists()){ return false; } @@ -135,7 +135,7 @@ return file_exists($wav_file); } - function wav_to_img($wav_file, $params = array()){ + public function wav_to_img($wav_file, $params = array()){ $width = isset($params["width"]) ? $params["width"] : "650"; $height = isset($params["height"]) ? $params["height"] : "100"; @@ -244,11 +244,11 @@ return $img; } - function findValues($byte1, $byte2){ + public function findValues($byte1, $byte2){ return hexdec(bin2hex($byte1)) + (hexdec(bin2hex($byte2)) * 256); } - function html2rgb($input){ + public function html2rgb($input){ $input = $input[0] == "#" ? substr($input, 1, 6) : substr($input, 0, 6); return array( hexdec(substr($input, 0, 2)), @@ -258,5 +258,3 @@ } } - -?> \ No newline at end of file diff --git a/app/data/modules/sql/sml_data_authors.php b/app/data/modules/sql/sml_data_authors.php index 81d308d..5d1288f 100644 --- a/app/data/modules/sql/sml_data_authors.php +++ b/app/data/modules/sql/sml_data_authors.php @@ -1,13 +1,12 @@ sgbd(); $env = $this->env(); $groupes = array("list" => array(), "total" => 0); @@ -43,7 +42,7 @@ return $groupes; } - function groupe($id){ + public function groupe($id){ $sgbd = $this->sgbd(); $env = $this->env(); $groupe = array(); @@ -61,11 +60,13 @@ } $sgbd->free_result($rst); } - catch(Exception $e) { return false; } + catch(Exception $e){ + return false; + } return $groupe; } - function groupe_exists($nom, $other_than_id = null){ + public function groupe_exists($nom, $other_than_id = null){ $sgbd = $this->sgbd(); $EXISTS = 0; try{ @@ -81,7 +82,7 @@ return $EXISTS; } - function add_groupe($id_user, $nom, $image, $description, $email, $contact_form, $captcha){ + public function add_groupe($id_user, $nom, $image, $description, $email, $contact_form, $captcha){ $sgbd = $this->sgbd(); try{ $sql = @@ -102,7 +103,7 @@ return true; } - function set_groupe($id, $nom, $image, $description, $email, $contact_form, $captcha){ + public function set_groupe($id, $nom, $image, $description, $email, $contact_form, $captcha){ if(($groupe = $this->groupe($id)) === false) return false; $sgbd = $this->sgbd(); try{ @@ -127,7 +128,7 @@ return true; } - function del_groupe($id){ + public function del_groupe($id){ $sgbd = $this->sgbd(); try{ $sql = "SELECT count(*) as n FROM #--sml_sources_authors WHERE id_author=".$this->eq($id); @@ -145,5 +146,3 @@ } } - -?> \ No newline at end of file diff --git a/app/data/modules/sql/sml_data_install.php b/app/data/modules/sql/sml_data_install.php index e5be178..41b1e44 100644 --- a/app/data/modules/sql/sml_data_install.php +++ b/app/data/modules/sql/sml_data_install.php @@ -6,7 +6,7 @@ // install // - function mw_sourceml_install_mysql($plugin, $env){ + public function mw_sourceml_install_mysql($plugin, $env){ $sgbd = $this->sgbd(); try{ $EXISTS = @@ -217,7 +217,7 @@ return true; } - function mw_sourceml_install_sqlite($plugin, $env){ + public function mw_sourceml_install_sqlite($plugin, $env){ $sgbd = $this->sgbd(); try{ $EXISTS = @@ -455,7 +455,7 @@ // uninstall // - function mw_sourceml_uninstall_sql($plugin, $env){ + public function mw_sourceml_uninstall_sql($plugin, $env){ $sgbd = $this->sgbd(); if(!$plugin->disable($env)) return "impossible de desactiver le plugin"; if(!($version = $env->version("mw_sourceml"))){ diff --git a/app/data/modules/sql/sml_data_licences.php b/app/data/modules/sql/sml_data_licences.php index 90445bb..53f96a3 100644 --- a/app/data/modules/sql/sml_data_licences.php +++ b/app/data/modules/sql/sml_data_licences.php @@ -2,7 +2,7 @@ class sml_data_licences extends mw_data{ - function licences($start = null){ + public function licences($start = null){ $sgbd = $this->sgbd(); $env = $this->env(); $licences = array("list" => array(), "total" => 0); @@ -22,11 +22,13 @@ $sgbd->free_result($rst); } } - catch(Exception $e) { $licences = false; } + catch(Exception $e){ + $licences = false; + } return $licences; } - function licence($id){ + public function licence($id){ $sgbd = $this->sgbd(); $licence = array(); try{ @@ -35,11 +37,13 @@ if($v_rst = $sgbd->fetch_assoc($rst)) $licence = $v_rst; $sgbd->free_result($rst); } - catch(Exception $e) { $licence = false; } + catch(Exception $e){ + $licence = false; + } return $licence; } - function add_licence($nom, $url){ + public function add_licence($nom, $url){ $sgbd = $this->sgbd(); try{ $sql = @@ -49,11 +53,13 @@ .")"; $sgbd->query($sql); } - catch(Exception $e) { return false; } + catch(Exception $e){ + return false; + } return true; } - function set_licence($id, $nom, $url){ + public function set_licence($id, $nom, $url){ if(($licence = $this->licence($id)) !== false){ $sgbd = $this->sgbd(); try{ @@ -69,13 +75,15 @@ if(!$this->maj_source_xml_licence($licence)) return false; } } - catch(Exception $e) { return false; } + catch(Exception $e){ + return false; + } return true; } return false; } - function del_licence($id){ + public function del_licence($id){ $sgbd = $this->sgbd(); try{ $sql = "SELECT count(*) as n FROM #--sml_sources WHERE licence=".$this->eq($id); @@ -86,10 +94,10 @@ $sql = "DELETE FROM #--sml_licences WHERE id=".$this->eq($id); $sgbd->query($sql); } - catch(Exception $e) { return false; } + catch(Exception $e){ + return false; + } return true; } } - -?> \ No newline at end of file diff --git a/app/data/modules/sql/sml_data_source_groupes.php b/app/data/modules/sql/sml_data_source_groupes.php index 0ada4f0..0854508 100644 --- a/app/data/modules/sql/sml_data_source_groupes.php +++ b/app/data/modules/sql/sml_data_source_groupes.php @@ -1,14 +1,13 @@ env(); + public function source_groupes($id_source){ + $env = $this->env(); $sgbd = $this->sgbd(); try{ $sql = @@ -20,9 +19,9 @@ ." ORDER BY nom"; $rst = $sgbd->query($sql); $groupes = array(); - while($v_rst = $sgbd->fetch_assoc($rst)) - { $v_rst["image_uri"] = - ( $v_rst["image"] ? + while($v_rst = $sgbd->fetch_assoc($rst)){ + $v_rst["image_uri"] = ( + $v_rst["image"] ? $env->path("content")."uploads/".$v_rst["image"] : "" ); @@ -30,11 +29,13 @@ } $sgbd->free_result($rst); } - catch(Exception $e) { return false; } + catch(Exception $e){ + return false; + } return $groupes; } - function groupes_sources($params){ + public function groupes_sources($params){ if(!isset($params["groupes"])) return false; if(!isset($params["id_source_access"])) return false; $satisfy_all_groupes_access = true; @@ -92,11 +93,13 @@ if(!($sources[$id_source] = $this->load_source($source))) return false; } } - catch(Exception $e) { $sources = false; } + catch(Exception $e){ + $sources = false; + } return $sources; } - function source_has_groupe($id_source, $id_groupe){ + public function source_has_groupe($id_source, $id_groupe){ $sgbd = $this->sgbd(); $HAS_THIS_GROUP = 0; try{ @@ -108,12 +111,14 @@ if($v_rst = $sgbd->fetch_assoc($rst)) $HAS_THIS_GROUP = $v_rst["n"]; $sgbd->free_result($rst); } - catch(Exception $e) { $HAS_THIS_GROUP = false; } + catch(Exception $e){ + $HAS_THIS_GROUP = false; + } return $HAS_THIS_GROUP; } - function add_source_groupe($id_source, $id_groupe, $id_groupe_status) - { $sgbd = $this->sgbd(); + public function add_source_groupe($id_source, $id_groupe, $id_groupe_status){ + $sgbd = $this->sgbd(); try{ $sql = "INSERT INTO #--sml_sources_authors(id_source, id_author, id_sources_access) VALUES" @@ -123,13 +128,15 @@ .")"; $sgbd->query($sql); } - catch(Exception $e) { return false; } + catch(Exception $e){ + return false; + } return true; } - function set_source_groupe($id, $id_groupe_status) - { if(($groupe = $this->groupe($id)) !== false) - { $sgbd = $this->sgbd(); + public function set_source_groupe($id, $id_groupe_status){ + if(($groupe = $this->groupe($id)) !== false){ + $sgbd = $this->sgbd(); try{ $sql = "UPDATE #--sml_sources_authors SET" @@ -137,23 +144,27 @@ ." WHERE id=".$id; $sgbd->query($sql); } - catch(Exception $e) { return false; } + catch(Exception $e){ + return false; + } return true; } return false; } - function del_source_groupes($id_source) - { $sgbd = $this->sgbd(); + public function del_source_groupes($id_source){ + $sgbd = $this->sgbd(); try{ $sql = "DELETE FROM #--sml_sources_authors WHERE id_source=".$this->eq($id_source); $sgbd->query($sql); } - catch(Exception $e) { return false; } + catch(Exception $e){ + return false; + } return true; } - function del_source_groupe($id_source, $id_author){ + public function del_source_groupe($id_source, $id_author){ $sgbd = $this->sgbd(); try{ $sql = @@ -162,13 +173,15 @@ ." AND id_author=".$this->eq($id_author); $sgbd->query($sql); } - catch(Exception $e) { return false; } + catch(Exception $e){ + return false; + } return true; } // -------------------------------------------------------------------- - function sources_access(){ + public function sources_access(){ $sgbd = $this->sgbd(); $sources_access = array(); try{ @@ -177,26 +190,36 @@ while($v_rst = $sgbd->fetch_assoc($rst)) $sources_access[$v_rst["id"]] = $v_rst; $sgbd->free_result($rst); } - catch(Exception $e) { $sources_access = false; } + catch(Exception $e){ + $sources_access = false; + } return $sources_access; } - function id_groupe_status_admin() { return 1; } - function id_groupe_status_editeur() { return 2; } - function id_groupe_status_contributeur() { return 3; } + public function id_groupe_status_admin(){ + return 1; + } + + public function id_groupe_status_editeur(){ + return 2; + } + + public function id_groupe_status_contributeur(){ + return 3; + } - function get_admin_groupe($groupes) - { $groupe = array(); - if(is_array($groupes)) foreach($groupes as $source_groupe) - { if($source_groupe["id_groupe_status"] == $this->id_groupe_status_admin()) - { $groupe = $source_groupe; + public function get_admin_groupe($groupes){ + $groupe = array(); + if(is_array($groupes)) foreach($groupes as $source_groupe){ + if($source_groupe["id_groupe_status"] == $this->id_groupe_status_admin()){ + $groupe = $source_groupe; break; } } return $groupe; } - function get_editor_groupes($groupes){ + public function get_editor_groupes($groupes){ $editor_groupes = array(); if(is_array($groupes)) foreach($groupes as $source_groupe){ if( @@ -209,25 +232,25 @@ return $editor_groupes; } - function source_permissions($source, $id_user) - { $permissions = array - ( "admin" => false, + public function source_permissions($source, $id_user){ + $permissions = array( + "admin" => false, "editeur" => false, "contributeur" => false ); - foreach($source["groupes"] as $id_groupe => $source_groupe) - { if($source_groupe["id_user"] == $id_user) - { if($source_groupe["id_groupe_status"] == $this->id_groupe_status_admin()) - { $permissions["admin"] = true; + foreach($source["groupes"] as $id_groupe => $source_groupe){ + if($source_groupe["id_user"] == $id_user){ + if($source_groupe["id_groupe_status"] == $this->id_groupe_status_admin()){ + $permissions["admin"] = true; $permissions["editeur"] = true; $permissions["contributeur"] = true; } - elseif($source_groupe["id_groupe_status"] == $this->id_groupe_status_editeur()) - { $permissions["editeur"] = true; + elseif($source_groupe["id_groupe_status"] == $this->id_groupe_status_editeur()){ + $permissions["editeur"] = true; $permissions["contributeur"] = true; } - elseif($source_groupe["id_groupe_status"] == $this->id_groupe_status_contributeur()) - { $permissions["contributeur"] = true; + elseif($source_groupe["id_groupe_status"] == $this->id_groupe_status_contributeur()){ + $permissions["contributeur"] = true; } } } @@ -236,7 +259,7 @@ // -------------------------------------------------------------------- - function sources_invitations($groupes, $id_user){ + public function sources_invitations($groupes, $id_user){ $groupes_in = ""; foreach($groupes as $id_groupe => $groupe) $groupes_in .= ($groupes_in ? "," : "").$id_groupe; return $this->list_sml_sources_invitations( @@ -250,5 +273,3 @@ } } - -?> \ No newline at end of file diff --git a/app/data/modules/sql/sml_data_sources.php b/app/data/modules/sql/sml_data_sources.php index 4c85c2b..ccb1a44 100644 --- a/app/data/modules/sql/sml_data_sources.php +++ b/app/data/modules/sql/sml_data_sources.php @@ -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; } @@ -31,11 +33,11 @@ # 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; @@ -93,17 +95,17 @@ ($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.")"; } @@ -138,8 +140,8 @@ $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)){ @@ -152,11 +154,13 @@ 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); @@ -167,11 +171,13 @@ } $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; @@ -197,22 +203,24 @@ } } } - 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"] : "" ); @@ -223,14 +231,14 @@ 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, @@ -238,10 +246,10 @@ $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, @@ -262,9 +270,9 @@ .")"; $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; } @@ -281,37 +289,40 @@ $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, @@ -320,11 +331,11 @@ $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, @@ -340,8 +351,8 @@ ." 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; @@ -350,8 +361,8 @@ $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) @@ -361,26 +372,29 @@ $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; } } } @@ -395,7 +409,7 @@ return false; } - function set_source_info($id_source, $key, $value){ + public function set_source_info($id_source, $key, $value){ $sgbd = $this->sgbd(); try{ $sql = @@ -406,25 +420,31 @@ $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; @@ -438,7 +458,9 @@ $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; } @@ -446,12 +468,12 @@ # 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" ."
" ."
" @@ -469,8 +491,8 @@ 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 @@ -481,14 +503,28 @@ ." 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 ); @@ -497,9 +533,9 @@ } 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(); } @@ -507,12 +543,14 @@ } $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 = @@ -525,13 +563,15 @@ 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(); @@ -544,12 +584,14 @@ 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)" @@ -560,17 +602,19 @@ $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" @@ -579,26 +623,30 @@ ." 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"]); } @@ -606,13 +654,15 @@ 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); } @@ -620,22 +670,22 @@ # 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 ); @@ -644,9 +694,9 @@ } 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(); } } } @@ -657,8 +707,8 @@ # 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); @@ -667,12 +717,14 @@ 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)" @@ -683,17 +735,21 @@ .")"; $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; } @@ -701,8 +757,8 @@ # 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(); @@ -711,28 +767,32 @@ 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{ @@ -743,14 +803,16 @@ 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 = @@ -760,11 +822,13 @@ .")"; $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; @@ -779,7 +843,9 @@ 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"; @@ -789,15 +855,17 @@ $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); @@ -806,17 +874,18 @@ 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; } @@ -830,5 +899,3 @@ } } - -?> \ No newline at end of file diff --git a/app/data/modules/sql/sml_data_sources_cache_db.php b/app/data/modules/sql/sml_data_sources_cache_db.php index 2497e58..9b972a7 100644 --- a/app/data/modules/sql/sml_data_sources_cache_db.php +++ b/app/data/modules/sql/sml_data_sources_cache_db.php @@ -2,7 +2,7 @@ class sml_data_sources_cache_db extends mw_data{ - function source_cache_db(){ + public function source_cache_db(){ $sgbd = $this->sgbd(); $cache = array(); try{ @@ -11,11 +11,13 @@ while($v_rst = $sgbd->fetch_assoc($rst)) $cache[$v_rst["id"]] = $v_rst; $sgbd->free_result($rst); } - catch(Exception $e) { $cache = false; } + catch(Exception $e){ + $cache = false; + } return $cache; } - function source_cache_infos_db($url){ + public function source_cache_infos_db($url){ $sgbd = $this->sgbd(); $cache_infos = array(); try{ @@ -24,11 +26,13 @@ if($v_rst = $sgbd->fetch_assoc($rst)) $cache_infos = $v_rst; $sgbd->free_result($rst); } - catch(Exception $e) { $cache_infos = false; } + catch(Exception $e){ + $cache_infos = false; + } return $cache_infos; } - function add_source_cache_db($url, $cache_index){ + public function add_source_cache_db($url, $cache_index){ $sgbd = $this->sgbd(); try{ $sql = @@ -39,21 +43,23 @@ .")"; $sgbd->query($sql); } - catch(Exception $e) { return false; } + catch(Exception $e){ + return false; + } return true; } - function del_source_cache_db($id_cache_data){ + public function del_source_cache_db($id_cache_data){ $env = $this->env(); $sgbd = $this->sgbd(); try{ $sql = "DELETE FROM #--sml_source_cache WHERE id=".$this->eq($id_cache_data); $sgbd->query($sql); } - catch(Exception $e) { return false; } + catch(Exception $e){ + return false; + } return true; } } - -?> \ No newline at end of file diff --git a/app/data/modules/xml/sml_data_authors.php b/app/data/modules/xml/sml_data_authors.php index 953ccfe..410227d 100644 --- a/app/data/modules/xml/sml_data_authors.php +++ b/app/data/modules/xml/sml_data_authors.php @@ -1,46 +1,45 @@ sgbd(); + public function groupes($id_user = null, $start = null, $alpha = null){ + $sgbd = $this->sgbd(); $env = $this->env(); $groupes = array("list" => array(), "total" => 0); - if(true || isset($id_user)) - { if($rst = $sgbd->open_data("sml_authors")) - { while($v_rst = $sgbd->fetch_data($rst)) - { if(isset($v_rst)) - { if(!isset($alpha) || (isset($v_rst["nom"]) && substr($v_rst["nom"], 0, 1) == $alpha)) - { if(!isset($id_user) || (isset($v_rst["id_user"]) && $v_rst["id_user"] == $id_user)) - { $groupes["total"]++; + if(true || isset($id_user)){ + if($rst = $sgbd->open_data("sml_authors")){ + while($v_rst = $sgbd->fetch_data($rst)){ + if(isset($v_rst)){ + if(!isset($alpha) || (isset($v_rst["nom"]) && substr($v_rst["nom"], 0, 1) == $alpha)){ + if(!isset($id_user) || (isset($v_rst["id_user"]) && $v_rst["id_user"] == $id_user)){ + $groupes["total"]++; $groupes["list"][$v_rst["id"]] = $v_rst; } } } - else - { $groupes = false; + else{ + $groupes = false; break; } } $sgbd->close_data($rst); - if($groupes !== false) - { $n = -1; - foreach($groupes["list"] as $id_groupe => $groupe) - { $n++; - if(isset($start) && $env->config("max_list") && ($n < $start || $n >= ($start + $env->config("max_list")))) - { unset($groupes["list"][$id_groupe]); + if($groupes !== false){ + $n = -1; + foreach($groupes["list"] as $id_groupe => $groupe){ + $n++; + if(isset($start) && $env->config("max_list") && ($n < $start || $n >= ($start + $env->config("max_list")))){ + unset($groupes["list"][$id_groupe]); } else{ if(!isset($groupes["list"][$id_groupe]["image"])) $groupes["list"][$id_groupe]["image"] = ""; - $groupes["list"][$id_groupe]["image_uri"] = - ( $groupes["list"][$id_groupe]["image"] ? + $groupes["list"][$id_groupe]["image_uri"] = ( + $groupes["list"][$id_groupe]["image"] ? $env->path("content")."uploads/".$groupes["list"][$id_groupe]["image"] : "" ); @@ -53,15 +52,15 @@ return $groupes; } - function groupe($id){ + public function groupe($id){ if(!isset($this->groupes)) $this->groupes = array(); if(isset($this->groupes[$id])) return $this->groupes[$id]; $sgbd = $this->sgbd(); $env = $this->env(); if(($groupe = $sgbd->get_data("sml_authors", $id)) !== null){ if(!isset($groupe["image"])) $groupe["image"] = ""; - $groupe["image_uri"] = - ( $groupe["image"] ? + $groupe["image_uri"] = ( + $groupe["image"] ? $env->path("content")."uploads/".$groupe["image"] : "" ); @@ -71,21 +70,21 @@ return $groupe; } - function groupe_exists($nom, $other_than_id = null) - { $sgbd = $this->sgbd(); + public function groupe_exists($nom, $other_than_id = null){ + $sgbd = $this->sgbd(); $EXISTS = 0; - if($rst = $sgbd->open_data("sml_authors")) - { while($v_rst = $sgbd->fetch_data($rst)) - { if(isset($v_rst)) - { if(isset($v_rst["nom"]) && $v_rst["nom"] == $nom) - { if(isset($other_than_id)) - { if($v_rst["id"] != $other_than_id) $EXISTS++; + if($rst = $sgbd->open_data("sml_authors")){ + while($v_rst = $sgbd->fetch_data($rst)){ + if(isset($v_rst)){ + if(isset($v_rst["nom"]) && $v_rst["nom"] == $nom){ + if(isset($other_than_id)){ + if($v_rst["id"] != $other_than_id) $EXISTS++; } else $EXISTS++; } } - else - { $EXISTS = false; + else{ + $EXISTS = false; break; } } @@ -94,12 +93,12 @@ return $EXISTS; } - function add_groupe($id_user, $nom, $image, $description, $email, $contact_form, $captcha) - { $sgbd = $this->sgbd(); - return $sgbd->add_data - ( "sml_authors", - array - ( "id_user" => $id_user, + public function add_groupe($id_user, $nom, $image, $description, $email, $contact_form, $captcha){ + $sgbd = $this->sgbd(); + return $sgbd->add_data( + "sml_authors", + array( + "id_user" => $id_user, "nom" => $nom, "image" => $image, "description" => $description, @@ -110,18 +109,18 @@ ); } - function set_groupe($id, $nom, $image, $description, $email, $contact_form, $captcha) - { if(($groupe = $this->groupe($id)) !== false) - { $sgbd = $this->sgbd(); - if($nom != $groupe["nom"]) - { $groupe["nom"] = $nom; + public function set_groupe($id, $nom, $image, $description, $email, $contact_form, $captcha){ + if(($groupe = $this->groupe($id)) !== false){ + $sgbd = $this->sgbd(); + if($nom != $groupe["nom"]){ + $groupe["nom"] = $nom; if(!$this->maj_source_xml_groupe($groupe)) return false; } - return $sgbd->set_data - ( "sml_authors", + return $sgbd->set_data( + "sml_authors", $id, - array - ( "id_user" => $groupe["id_user"], + array( + "id_user" => $groupe["id_user"], "nom" => $nom, "image" => $image, "description" => $description, @@ -134,34 +133,32 @@ return false; } - function del_groupe($id) - { $OK = true; + public function del_groupe($id){ + $OK = true; $USED = false; $sgbd = $this->sgbd(); $env = $this->env(); - if($rst = $sgbd->open_data("sml_sources_authors")) - { while($source_author = $sgbd->fetch_data($rst)) - { if(isset($source_author)) - { if($source_author["id_author"] == $id) - { $USED = true; + if($rst = $sgbd->open_data("sml_sources_authors")){ + while($source_author = $sgbd->fetch_data($rst)){ + if(isset($source_author)){ + if($source_author["id_author"] == $id){ + $USED = true; break; } } - else - { $OK = false; + else{ + $OK = false; break; } } $sgbd->close_data($rst); } else $OK = false; - if($OK) - { if($USED) return 1; + if($OK){ + if($USED) return 1; return $sgbd->del_data("sml_authors", $id) ? true : false; } return false; } } - -?> \ No newline at end of file diff --git a/app/data/modules/xml/sml_data_install.php b/app/data/modules/xml/sml_data_install.php index 0b9ea55..849c441 100644 --- a/app/data/modules/xml/sml_data_install.php +++ b/app/data/modules/xml/sml_data_install.php @@ -6,20 +6,60 @@ // install // - function mw_sourceml_install_xml($plugin, $env){ + public function mw_sourceml_install_xml($plugin, $env){ $sgbd = $this->sgbd(); $RES = true; - $res = $sgbd->data_exists("sml_authors"); if(isset($res)){ if($res) $RES = 1; } else $RES = -1; - $res = $sgbd->data_exists("sml_classes"); if(isset($res)){ if($res) $RES = 1; } else $RES = -1; - $res = $sgbd->data_exists("sml_licences"); if(isset($res)){ if($res) $RES = 1; } else $RES = -1; - $res = $sgbd->data_exists("sml_sources"); if(isset($res)){ if($res) $RES = 1; } else $RES = -1; - $res = $sgbd->data_exists("sml_sources_access"); if(isset($res)){ if($res) $RES = 1; } else $RES = -1; - $res = $sgbd->data_exists("sml_sources_authors"); if(isset($res)){ if($res) $RES = 1; } else $RES = -1; - $res = $sgbd->data_exists("sml_source_cache"); if(isset($res)){ if($res) $RES = 1; } else $RES = -1; - $res = $sgbd->data_exists("sml_source_compositions"); if(isset($res)){ if($res) $RES = 1; } else $RES = -1; - $res = $sgbd->data_exists("sml_source_derivations"); if(isset($res)){ if($res) $RES = 1; } else $RES = -1; - $res = $sgbd->data_exists("sml_sources_invitations"); if(isset($res)){ if($res) $RES = 1; } else $RES = -1; + $res = $sgbd->data_exists("sml_authors"); + if(isset($res)){ + if($res) $RES = 1; + } + else $RES = -1; + $res = $sgbd->data_exists("sml_classes"); + if(isset($res)){ + if($res) $RES = 1; + } + else $RES = -1; + $res = $sgbd->data_exists("sml_licences"); + if(isset($res)){ + if($res) $RES = 1; + } + else $RES = -1; + $res = $sgbd->data_exists("sml_sources"); + if(isset($res)){ + if($res) $RES = 1; + } + else $RES = -1; + $res = $sgbd->data_exists("sml_sources_access"); + if(isset($res)){ + if($res) $RES = 1; + } + else $RES = -1; + $res = $sgbd->data_exists("sml_sources_authors"); + if(isset($res)){ + if($res) $RES = 1; + } + else $RES = -1; + $res = $sgbd->data_exists("sml_source_cache"); + if(isset($res)){ + if($res) $RES = 1; + } + else $RES = -1; + $res = $sgbd->data_exists("sml_source_compositions"); + if(isset($res)){ + if($res) $RES = 1; + } + else $RES = -1; + $res = $sgbd->data_exists("sml_source_derivations"); + if(isset($res)){ + if($res) $RES = 1; + } + else $RES = -1; + $res = $sgbd->data_exists("sml_sources_invitations"); + if(isset($res)){ + if($res) $RES = 1; + } + else $RES = -1; if($RES === -1) return "impossible de savoir si les tables existent deja. installation annulee"; if($RES === 1) return "des tables existent deja en base. installation annulee"; @@ -223,7 +263,7 @@ // uninstall // - function mw_sourceml_uninstall_xml($plugin, $env){ + public function mw_sourceml_uninstall_xml($plugin, $env){ $sgbd = $this->sgbd(); if(!$plugin->disable($env)) return "impossible de desactiver le plugin"; diff --git a/app/data/modules/xml/sml_data_licences.php b/app/data/modules/xml/sml_data_licences.php index 0953652..af85667 100644 --- a/app/data/modules/xml/sml_data_licences.php +++ b/app/data/modules/xml/sml_data_licences.php @@ -1,22 +1,21 @@ sgbd(); + public function licences($start = null){ + $sgbd = $this->sgbd(); $env = $this->env(); $licences = array("list" => array(), "total" => 0); - if($rst = $sgbd->open_data("sml_licences")) - { while($v_rst = $sgbd->fetch_data($rst)) - { if(isset($v_rst)) - { $licences["total"]++; - if(!isset($start) || !$env->config("max_list") || ($licences["total"] > $start && $licences["total"] < ($start + $env->config("max_list")))) - { $licences["list"][$v_rst["id"]] = $v_rst; + if($rst = $sgbd->open_data("sml_licences")){ + while($v_rst = $sgbd->fetch_data($rst)){ + if(isset($v_rst)){ + $licences["total"]++; + if(!isset($start) || !$env->config("max_list") || ($licences["total"] > $start && $licences["total"] < ($start + $env->config("max_list")))){ + $licences["list"][$v_rst["id"]] = $v_rst; } } - else - { $licences = false; + else{ + $licences = false; break; } } @@ -26,33 +25,33 @@ return $licences; } - function licence($id) - { if($id == 0) return $id; + public function licence($id){ + if($id == 0) return $id; $sgbd = $this->sgbd(); return $sgbd->get_data("sml_licences", $id); } - function add_licence($nom, $url) - { $sgbd = $this->sgbd(); - return $sgbd->add_data - ( "sml_licences", - array - ( "nom" => $nom, + public function add_licence($nom, $url){ + $sgbd = $this->sgbd(); + return $sgbd->add_data( + "sml_licences", + array( + "nom" => $nom, "url" => $url ) ); } - function set_licence($id, $nom, $url) - { if(($licence = $this->licence($id)) !== false) - { $sgbd = $this->sgbd(); - if($nom != $licence["nom"] || $url != $licence["url"]) - { $licence["nom"] = $nom; + public function set_licence($id, $nom, $url){ + if(($licence = $this->licence($id)) !== false){ + $sgbd = $this->sgbd(); + if($nom != $licence["nom"] || $url != $licence["url"]){ + $licence["nom"] = $nom; $licence["url"] = $url; if(!$this->maj_source_xml_licence($licence)) return false; } - return $sgbd->set_data - ( "sml_licences", + return $sgbd->set_data( + "sml_licences", $id, array ( "nom" => $nom, @@ -63,34 +62,32 @@ return false; } - function del_licence($id) - { $OK = true; + public function del_licence($id){ + $OK = true; $USED = false; $sgbd = $this->sgbd(); $env = $this->env(); - if($rst = $sgbd->open_data("sml_sources")) - { while($source = $sgbd->fetch_data($rst)) - { if(isset($source)) - { if($source["licence"] == $id) - { $USED = true; + if($rst = $sgbd->open_data("sml_sources")){ + while($source = $sgbd->fetch_data($rst)){ + if(isset($source)){ + if($source["licence"] == $id){ + $USED = true; break; } } - else - { $OK = false; + else{ + $OK = false; break; } } $sgbd->close_data($rst); } else $OK = false; - if($OK) - { if($USED) return 1; + if($OK){ + if($USED) return 1; return $sgbd->del_data("sml_licences", $id) ? true : false; } return false; } } - -?> \ No newline at end of file diff --git a/app/data/modules/xml/sml_data_source_groupes.php b/app/data/modules/xml/sml_data_source_groupes.php index fead1be..d055d08 100644 --- a/app/data/modules/xml/sml_data_source_groupes.php +++ b/app/data/modules/xml/sml_data_source_groupes.php @@ -2,22 +2,22 @@ class sml_data_source_groupes extends mw_data{ - function init_groupe_status(){ + public function init_groupe_status(){ return true; } - function source_groupes($id_source) - { $env = $this->env(); + public function source_groupes($id_source){ + $env = $this->env(); $sgbd = $this->sgbd(); $groupes = array(); $groupes_status = array(); - if($rst = $sgbd->open_data("sml_sources_authors")) - { while($v_rst = $sgbd->fetch_data($rst)) - { if(isset($v_rst) && isset($v_rst["id_author"]) && isset($v_rst["id_source"]) && isset($v_rst["id_sources_access"])) - { if($v_rst["id_source"] == $id_source) $groupes_status[$v_rst["id_author"]] = $v_rst["id_sources_access"]; + if($rst = $sgbd->open_data("sml_sources_authors")){ + while($v_rst = $sgbd->fetch_data($rst)){ + if(isset($v_rst) && isset($v_rst["id_author"]) && isset($v_rst["id_source"]) && isset($v_rst["id_sources_access"])){ + if($v_rst["id_source"] == $id_source) $groupes_status[$v_rst["id_author"]] = $v_rst["id_sources_access"]; } - else - { $groupes_status = false; + else{ + $groupes_status = false; break; } } @@ -25,21 +25,21 @@ } else $groupes_status = false; if($groupes_status === false) return false; - if($rst = $sgbd->open_data("sml_authors")) - { while($v_rst = $sgbd->fetch_data($rst)) - { if(isset($v_rst) && isset($v_rst["id"])) - { if(isset($groupes_status[$v_rst["id"]])) - { $groupes[$v_rst["id"]] = $v_rst; + if($rst = $sgbd->open_data("sml_authors")){ + while($v_rst = $sgbd->fetch_data($rst)){ + if(isset($v_rst) && isset($v_rst["id"])){ + if(isset($groupes_status[$v_rst["id"]])){ + $groupes[$v_rst["id"]] = $v_rst; $groupes[$v_rst["id"]]["id_groupe_status"] = $groupes_status[$v_rst["id"]]; - $groupes[$v_rst["id"]]["image_uri"] = - ( isset($v_rst["image"]) && $v_rst["image"] ? + $groupes[$v_rst["id"]]["image_uri"] = ( + isset($v_rst["image"]) && $v_rst["image"] ? $env->path("content")."uploads/".$v_rst["image"] : "" ); } } - else - { $groupes = false; + else{ + $groupes = false; break; } } @@ -49,7 +49,7 @@ return $groupes; } - function groupes_sources($params){ + public function groupes_sources($params){ if(!isset($params["groupes"])) return false; if(!isset($params["id_source_access"])) return false; $satisfy_all_groupes_access = true; @@ -130,7 +130,7 @@ return $sources; } - function source_has_groupe($id_source, $id_groupe){ + public function source_has_groupe($id_source, $id_groupe){ $sgbd = $this->sgbd(); $HAS_THIS_GROUP = 0; if($rst = $sgbd->open_data("sml_sources_authors")){ @@ -151,41 +151,41 @@ return $HAS_THIS_GROUP; } - function add_source_groupe($id_source, $id_groupe, $id_groupe_status) - { $sgbd = $this->sgbd(); - if - ( $sgbd->add_data - ( "sml_sources_authors", - array - ( "id_source" => $id_source, + public function add_source_groupe($id_source, $id_groupe, $id_groupe_status){ + $sgbd = $this->sgbd(); + if( + $sgbd->add_data( + "sml_sources_authors", + array( + "id_source" => $id_source, "id_author" => $id_groupe, "id_sources_access" => $id_groupe_status ) ) - ) - { return true; + ){ + return true; } return false; } - function set_source_groupe($id, $id_groupe_status) - { if(($groupe = $this->groupe($id)) !== false) - { if - ( $sgbd->set_data - ( "sml_sources_authors", + public function set_source_groupe($id, $id_groupe_status){ + if(($groupe = $this->groupe($id)) !== false){ + if( + $sgbd->set_data( + "sml_sources_authors", $id, array( "id_sources_access" => $id_groupe_status ) ) - ) - { return true; + ){ + return true; } } return false; } - function del_source_groupes($id_source){ + public function del_source_groupes($id_source){ $sgbd = $this->sgbd(); $OK = true; if($rst = $sgbd->open_data("sml_sources_authors")){ @@ -201,7 +201,7 @@ return $OK; } - function del_source_groupe($id_source, $id_author){ + public function del_source_groupe($id_source, $id_author){ $sgbd = $this->sgbd(); $OK = true; if($rst = $sgbd->open_data("sml_sources_authors")){ @@ -223,7 +223,7 @@ // -------------------------------------------------------------------- - function sources_access(){ + public function sources_access(){ $sgbd = $this->sgbd(); $sources_access = array(); $sgbd = $this->sgbd(); @@ -241,22 +241,28 @@ return $sources_access; } - function id_groupe_status_admin() { return 1; } - function id_groupe_status_editeur() { return 2; } - function id_groupe_status_contributeur() { return 3; } + public function id_groupe_status_admin(){ + return 1; + } + public function id_groupe_status_editeur(){ + return 2; + } + public function id_groupe_status_contributeur(){ + return 3; + } - function get_admin_groupe($groupes) - { $groupe = array(); - if(is_array($groupes)) foreach($groupes as $source_groupe) - { if($source_groupe["id_groupe_status"] == $this->id_groupe_status_admin()) - { $groupe = $source_groupe; + public function get_admin_groupe($groupes){ + $groupe = array(); + if(is_array($groupes)) foreach($groupes as $source_groupe){ + if($source_groupe["id_groupe_status"] == $this->id_groupe_status_admin()){ + $groupe = $source_groupe; break; } } return $groupe; } - function get_editor_groupes($groupes){ + public function get_editor_groupes($groupes){ $editor_groupes = array(); if(is_array($groupes)) foreach($groupes as $source_groupe){ if( @@ -269,25 +275,25 @@ return $editor_groupes; } - function source_permissions($source, $id_user) - { $permissions = array - ( "admin" => false, + public function source_permissions($source, $id_user){ + $permissions = array( + "admin" => false, "editeur" => false, "contributeur" => false ); - foreach($source["groupes"] as $id_groupe => $source_groupe) - { if($source_groupe["id_user"] == $id_user) - { if($source_groupe["id_groupe_status"] == $this->id_groupe_status_admin()) - { $permissions["admin"] = true; + foreach($source["groupes"] as $id_groupe => $source_groupe){ + if($source_groupe["id_user"] == $id_user){ + if($source_groupe["id_groupe_status"] == $this->id_groupe_status_admin()){ + $permissions["admin"] = true; $permissions["editeur"] = true; $permissions["contributeur"] = true; } - elseif($source_groupe["id_groupe_status"] == $this->id_groupe_status_editeur()) - { $permissions["editeur"] = true; + elseif($source_groupe["id_groupe_status"] == $this->id_groupe_status_editeur()){ + $permissions["editeur"] = true; $permissions["contributeur"] = true; } - elseif($source_groupe["id_groupe_status"] == $this->id_groupe_status_contributeur()) - { $permissions["contributeur"] = true; + elseif($source_groupe["id_groupe_status"] == $this->id_groupe_status_contributeur()){ + $permissions["contributeur"] = true; } } } @@ -296,7 +302,7 @@ // -------------------------------------------------------------------- - function sources_invitations($groupes, $id_user){ + public function sources_invitations($groupes, $id_user){ $sgbd = $this->sgbd(); $invitations = array("list" => array(), "total" => 0); $groupes_in = array(); @@ -338,5 +344,3 @@ } } - -?> \ No newline at end of file diff --git a/app/data/modules/xml/sml_data_sources.php b/app/data/modules/xml/sml_data_sources.php index fb8dc2b..68e3a52 100644 --- a/app/data/modules/xml/sml_data_sources.php +++ b/app/data/modules/xml/sml_data_sources.php @@ -2,28 +2,28 @@ class sml_data_sources extends mw_data{ - var $status; + public $status; # ---------------------------------------------------------------------------------------- # status de source # - function source_status() - { if(!isset($this->status)) $this->status = $this->init_sources_status(); + public function source_status(){ + if(!isset($this->status)) $this->status = $this->init_sources_status(); return $this->status; } - function init_sources_status() - { $sgbd = $this->sgbd(); + public function init_sources_status(){ + $sgbd = $this->sgbd(); $env = $this->env(); $status = array(); - if($rst = $sgbd->open_data("sml_classes")) - { while($v_rst = $sgbd->fetch_data($rst)) - { if(isset($v_rst)) - { $status[$v_rst["id"]] = $v_rst; + if($rst = $sgbd->open_data("sml_classes")){ + while($v_rst = $sgbd->fetch_data($rst)){ + if(isset($v_rst)){ + $status[$v_rst["id"]] = $v_rst; } - else - { $status = false; + else{ + $status = false; break; } } @@ -37,12 +37,12 @@ # sources # - function init_sources_table(){ + public function init_sources_table(){ return true; } - function sources($params) - { $sgbd = $this->sgbd(); + public function sources($params){ + $sgbd = $this->sgbd(); $env = $this->env(); // ------------------------------------------------------------------------------- @@ -63,21 +63,21 @@ // ------------------------------------------------------------------------------- // infos pour verifier les filtres - if(isset($id_user) || isset($id_groupe)) - { $in_source_ids = array(); + if(isset($id_user) || isset($id_groupe)){ + $in_source_ids = array(); $in_groupe_ids = array(); if(isset($id_groupe)) $in_groupe_ids[$id_groupe] = true; - else - { if(($groupes = $this->groupes($id_user)) !== false) - { foreach($groupes["list"] as $id_groupe => $groupe) $in_groupe_ids[$id_groupe] = true; + else{ + if(($groupes = $this->groupes($id_user)) !== false){ + foreach($groupes["list"] as $id_groupe => $groupe) $in_groupe_ids[$id_groupe] = true; } else return false; } $OK = true; - if($rst = $sgbd->open_data("sml_sources_authors")) - { while($OK && $v_rst = $sgbd->fetch_data($rst)) - { if(isset($v_rst) && isset($v_rst["id_source"]) && isset($v_rst["id_author"])) - { if(isset($in_groupe_ids[$v_rst["id_author"]])) $in_source_ids[$v_rst["id_source"]] = true; + if($rst = $sgbd->open_data("sml_sources_authors")){ + while($OK && $v_rst = $sgbd->fetch_data($rst)){ + if(isset($v_rst) && isset($v_rst["id_source"]) && isset($v_rst["id_author"])){ + if(isset($in_groupe_ids[$v_rst["id_author"]])) $in_source_ids[$v_rst["id_source"]] = true; } else $OK = false; } @@ -88,21 +88,21 @@ } $compositions = array(); - if(isset($id_source)) - { if(($compositions = $this->source_compositions(array("id_source" => $id_source))) === false) - { return false; + if(isset($id_source)){ + if(($compositions = $this->source_compositions(array("id_source" => $id_source))) === false){ + return false; } } - elseif(isset($id_composition)) - { if(($compositions = $this->source_compositions(array("id_composition" => $id_composition))) === false) - { return false; + elseif(isset($id_composition)){ + if(($compositions = $this->source_compositions(array("id_composition" => $id_composition))) === false){ + return false; } } $derivations = array(); - if(isset($id_source_derivation)) - { if(($derivations = $this->source_derivations($id_source_derivation)) === false) - { return false; + if(isset($id_source_derivation)){ + if(($derivations = $this->source_derivations($id_source_derivation)) === false){ + return false; } } @@ -111,44 +111,44 @@ $sources = array("list" => array(), "total" => 0); $res = array(); - if($rst = $sgbd->open_data("sml_sources")) - { while($v_rst = $sgbd->fetch_data($rst)) - { if(isset($v_rst)){ + if($rst = $sgbd->open_data("sml_sources")){ + while($v_rst = $sgbd->fetch_data($rst)){ + if(isset($v_rst)){ $res[$v_rst["id"]] = $v_rst; if(!isset($res[$v_rst["id"]]["ordre"])) $res[$v_rst["id"]]["ordre"] = 0; } - else - { $res = false; + else{ + $res = false; break; } } $sgbd->close_data($rst); - if($res !== false) - { $res = $this->ordonne($res, $order_by, $order); + if($res !== false){ + $res = $this->ordonne($res, $order_by, $order); - foreach($res as $id_res => $v_rst) - { // ------------------------------- par defaut + foreach($res as $id_res => $v_rst){ + // ------------------------------- par defaut $MATCH = true; // ------------------------------- filtre sur id_user et id_groupe - if(isset($in_source_ids)) - { $MATCH = isset($in_source_ids[$v_rst["id"]]) && $in_source_ids[$v_rst["id"]]; + if(isset($in_source_ids)){ + $MATCH = isset($in_source_ids[$v_rst["id"]]) && $in_source_ids[$v_rst["id"]]; } // ------------------------------- filtre sur status - if($MATCH) - { $MATCH = !isset($status) || (isset($v_rst["id_class"]) && $v_rst["id_class"] == $status); + if($MATCH){ + $MATCH = !isset($status) || (isset($v_rst["id_class"]) && $v_rst["id_class"] == $status); } // -------------------------------- filtre sur id_source - if($MATCH) - { if(isset($id_source)) - { $MATCH = false; - if($compositions && is_array($compositions[$id_source])) - { foreach($compositions[$id_source] as $id_composition) - { if(isset($v_rst["id"]) && $v_rst["id"] == $id_composition) - { $MATCH = true; + if($MATCH){ + if(isset($id_source)){ + $MATCH = false; + if($compositions && is_array($compositions[$id_source])){ + foreach($compositions[$id_source] as $id_composition){ + if(isset($v_rst["id"]) && $v_rst["id"] == $id_composition){ + $MATCH = true; break; } } @@ -157,35 +157,35 @@ } // -------------------------------- filtre sur id_composition - if($MATCH) - { if(isset($id_composition)) - { if($id_composition) - { $MATCH = false; - if($compositions && is_array($compositions[$id_composition])) - { foreach($compositions[$id_composition] as $_id_source) - { if(isset($v_rst["id"]) && $v_rst["id"] == $_id_source) - { $MATCH = true; + if($MATCH){ + if(isset($id_composition)){ + if($id_composition){ + $MATCH = false; + if($compositions && is_array($compositions[$id_composition])){ + foreach($compositions[$id_composition] as $_id_source){ + if(isset($v_rst["id"]) && $v_rst["id"] == $_id_source){ + $MATCH = true; break; } } } } - else - { if($compositions) - { if(isset($compositions[$v_rst["id"]])) $MATCH = false; + else{ + if($compositions){ + if(isset($compositions[$v_rst["id"]])) $MATCH = false; } } } } // -------------------------------- filtre sur id_source_derivation - if($MATCH) - { if(isset($id_source_derivation)) - { $MATCH = false; - if($derivations && is_array($derivations[$id_source_derivation])) - { foreach($derivations[$id_source_derivation] as $_id_derivation) - { if(isset($v_rst["id"]) && $v_rst["id"] == $_id_derivation) - { $MATCH = true; + if($MATCH){ + if(isset($id_source_derivation)){ + $MATCH = false; + if($derivations && is_array($derivations[$id_source_derivation])){ + foreach($derivations[$id_source_derivation] as $_id_derivation){ + if(isset($v_rst["id"]) && $v_rst["id"] == $_id_derivation){ + $MATCH = true; break; } } @@ -194,9 +194,9 @@ } // -------------------------------- filtre sur la licence - if($MATCH) - { if(isset($id_licence)) - { $MATCH = false; + if($MATCH){ + if(isset($id_licence)){ + $MATCH = false; if(isset($v_rst["licence"]) && $v_rst["licence"] == $id_licence) $MATCH = true; } } @@ -214,8 +214,8 @@ } // -------------------------------- filtre sur quantite de resultats - if($MATCH) - { $sources["total"]++; + if($MATCH){ + $sources["total"]++; $MATCH = !isset($start) || !$env->config("max_list") || ($sources["total"] > $start && $sources["total"] <= ($start + $env->config("max_list"))); } @@ -232,8 +232,8 @@ return $sources; } - function source($id, $load = false) - { $sgbd = $this->sgbd(); + public function source($id, $load = false){ + $sgbd = $this->sgbd(); if(($source = $sgbd->get_data("sml_sources", $id)) !== false){ $source["status"] = $source["id_class"]; $source = $load ? $this->load_source($source) : $this->get_source_from_v_rst($source); @@ -242,40 +242,40 @@ return false; } - function get_source_from_v_rst($v_rst) - { $sgbd = $this->sgbd(); + 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; $source["status"] = $source["id_class"]; - if($source["reference"]) - { if(!is_array($source["reference"])) - { $reference_url = $source["reference"]; + if($source["reference"]){ + if(!is_array($source["reference"])){ + $reference_url = $source["reference"]; $source["reference"] = $this->empty_source(); $source["reference"]["xml"]["url"] = $reference_url; } } - else - { if(!is_array($source["licence"])) - { $source["licence"] = array - ( "id" => $source["licence"] + else{ + if(!is_array($source["licence"])){ + $source["licence"] = array( + "id" => $source["licence"] ); } } 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"] : "" ); @@ -286,14 +286,14 @@ 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, @@ -301,10 +301,10 @@ $reference = array(), $derivations = array(), $infos = array() - ) - { $sgbd = $this->sgbd(); - $source = array - ( "id_class" => $status, + ){ + $sgbd = $this->sgbd(); + $source = array( + "id_class" => $status, "reference" => $reference ? $reference["xml"]["url"] : null, "titre" => $reference ? null : $titre, "licence" => $reference ? null : $licence, @@ -314,42 +314,43 @@ foreach($infos as $key => $value) if(!isset($source[$key])) $source[$key] = $value; $id = $sgbd->add_data("sml_sources", $source); if(!isset($id)) return false; - foreach($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($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; } - 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; } } } - 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, @@ -358,9 +359,9 @@ $reference = array(), $derivations = array(), $infos = array() - ) - { if($source = $this->source($id)) - { $sgbd = $this->sgbd(); + ){ + if($source = $this->source($id)){ + $sgbd = $this->sgbd(); $source["reference"] = $reference ? $reference["xml"]["url"] : null; $source["titre"] = $reference ? null : $titre; $source["licence"] = $reference ? null : $licence; @@ -368,37 +369,38 @@ foreach($infos as $key => $value) $source[$key] = $value; if(!$sgbd->set_data("sml_sources", $id, $source)) return false; if(!$this->del_source_groupes($id)) return false; - foreach($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($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; } 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; } } } - 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; @@ -407,17 +409,17 @@ return false; } - function set_source_info($id_source, $key, $value) - { $sgbd = $this->sgbd(); - if($source = $sgbd->get_data("sml_sources", $id_source)) - { $source[$key] = $value; + public function set_source_info($id_source, $key, $value){ + $sgbd = $this->sgbd(); + if($source = $sgbd->get_data("sml_sources", $id_source)){ + $source[$key] = $value; if($sgbd->set_data("sml_sources", $id_source, $source)) return true; } return false; } - function del_source($id) - { $sgbd = $this->sgbd(); + 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; if(!$this->del_source_derivations($id)) return false; @@ -432,52 +434,52 @@ # derivations de sources # - function init_source_derivations(){ + public function init_source_derivations(){ 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 - if(isset($params["id_source"])) - { if($rst = $sgbd->open_data("sml_source_derivations")) - { while($v_rst = $sgbd->fetch_data($rst)) - { if(isset($v_rst)) - { if(isset($v_rst["id"]) && isset($v_rst["id_source"]) && $v_rst["id_source"] == $params["id_source"]) - { $derivations[$v_rst["id"]] = array(); + if(isset($params["id_source"])){ + if($rst = $sgbd->open_data("sml_source_derivations")){ + while($v_rst = $sgbd->fetch_data($rst)){ + if(isset($v_rst)){ + if(isset($v_rst["id"]) && isset($v_rst["id_source"]) && $v_rst["id_source"] == $params["id_source"]){ + $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 - { $derivations = null; + else{ + $derivations = null; break; } } - else - { $derivations = null; + else{ + $derivations = null; break; } } - 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(); } $derivations[$v_rst["id"]]["id_source"] = $v_rst["id_source"]; } } - else - { $derivations = null; + else{ + $derivations = null; break; } } @@ -487,32 +489,38 @@ 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); $id_sources = array(); - if($rst = $sgbd->open_data("sml_source_derivations")) - { while($v_rst = $sgbd->fetch_data($rst)) - { if(isset($v_rst)) - { if(isset($v_rst["id_source"]) && isset($v_rst["derivation"]) && $v_rst["derivation"] == $source_xml_url) - { $id_sources[$v_rst["id_source"]] = true; + if($rst = $sgbd->open_data("sml_source_derivations")){ + while($v_rst = $sgbd->fetch_data($rst)){ + if(isset($v_rst)){ + if(isset($v_rst["id_source"]) && isset($v_rst["derivation"]) && $v_rst["derivation"] == $source_xml_url){ + $id_sources[$v_rst["id_source"]] = true; } } - else { $id_sources = false; break; } + else{ + $id_sources = false; + break; + } } $sgbd->close_data($rst); } else $id_sources = false; if($id_sources === false) return false; - if($id_sources) - { if($rst = $sgbd->open_data("sml_sources")) - { while($v_rst = $sgbd->fetch_data($rst)) - { if(isset($v_rst)) - { if(isset($v_rst["id"]) && isset($id_sources[$v_rst["id"]])) - { $derivations[$v_rst["id"]] = $v_rst; + if($id_sources){ + if($rst = $sgbd->open_data("sml_sources")){ + while($v_rst = $sgbd->fetch_data($rst)){ + if(isset($v_rst)){ + if(isset($v_rst["id"]) && isset($id_sources[$v_rst["id"]])){ + $derivations[$v_rst["id"]] = $v_rst; } } - else { $derivations = false; break; } + else{ + $derivations = false; + break; + } } $sgbd->close_data($rst); } @@ -523,24 +531,24 @@ return false; } - function source_derivation($id) - { $sgbd = $this->sgbd(); + public function source_derivation($id){ + $sgbd = $this->sgbd(); return $sgbd->get_data("sml_source_derivations", $id); } - function add_source_derivation($id_source, $derivation, $edit_content = "") - { $sgbd = $this->sgbd(); - $id_source_derivation = $sgbd->add_data - ( "sml_source_derivations", - array - ( "id_source" => $id_source, + public function add_source_derivation($id_source, $derivation, $edit_content = ""){ + $sgbd = $this->sgbd(); + $id_source_derivation = $sgbd->add_data( + "sml_source_derivations", + array( + "id_source" => $id_source, "derivation" => $derivation ) ); - if(isset($id_source_derivation)) - { if($edit_content) - { if(!$this->set_edit_derivation_content($id_source, $id_source_derivation, $edit_content)) - { $id_source_derivation = false; + if(isset($id_source_derivation)){ + if($edit_content){ + if(!$this->set_edit_derivation_content($id_source, $id_source_derivation, $edit_content)){ + $id_source_derivation = false; } } } @@ -548,22 +556,23 @@ return $id_source_derivation; } - function set_source_derivation($id_source_derivation, $id_source, $derivation, $edit_content = "") - { $sgbd = $this->sgbd(); - if - ( ( $sgbd->set_data - ( "sml_source_derivations", + public function set_source_derivation($id_source_derivation, $id_source, $derivation, $edit_content = ""){ + $sgbd = $this->sgbd(); + if( + ( + $sgbd->set_data( + "sml_source_derivations", $id_source_derivation, - array - ( "id_source" => $id_source, + array( + "id_source" => $id_source, "derivation" => $derivation ) ) ) - ) - { if($edit_content) - { if(!$this->set_edit_derivation_content($id_source, $id_source_derivation, $edit_content)) - { return false; + ){ + if($edit_content){ + if(!$this->set_edit_derivation_content($id_source, $id_source_derivation, $edit_content)){ + return false; } } return true; @@ -571,13 +580,13 @@ return false; } - 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(); if(!$sgbd->del_data("sml_source_derivations", $id_source_derivation)) return false; - if(count($derivations) > 1) - { return $this->del_edit_derivation_content($derivation["id_source"], $id_source_derivation); + 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"]); } @@ -585,25 +594,28 @@ return false; } - function del_source_derivations($id_source) - { $sgbd = $this->sgbd(); + public function del_source_derivations($id_source){ + $sgbd = $this->sgbd(); $id_source_derivations = array(); - if($rst = $sgbd->open_data("sml_source_derivations")) - { while($v_rst = $sgbd->fetch_data($rst)) - { if(isset($v_rst)) - { if(isset($v_rst["id"]) && isset($v_rst["id_source"]) && $v_rst["id_source"] == $id_source) - { $id_source_derivations[] = $v_rst["id"]; + if($rst = $sgbd->open_data("sml_source_derivations")){ + while($v_rst = $sgbd->fetch_data($rst)){ + if(isset($v_rst)){ + if(isset($v_rst["id"]) && isset($v_rst["id_source"]) && $v_rst["id_source"] == $id_source){ + $id_source_derivations[] = $v_rst["id"]; } } - else { $id_source_derivations = false; break; } + else{ + $id_source_derivations = false; + break; + } } $sgbd->close_data($rst); } else $id_source_derivations = false; if($id_source_derivations === false) return false; - if($id_source_derivations) - { foreach($id_source_derivations as $id_source_derivation) - { if(!$sgbd->del_data("sml_source_derivations", $id_source_derivation)) return false; + if($id_source_derivations){ + foreach($id_source_derivations as $id_source_derivation){ + if(!$sgbd->del_data("sml_source_derivations", $id_source_derivation)) return false; } } return $this->del_edit_derivations($id_source); @@ -613,22 +625,22 @@ # 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 ); @@ -637,9 +649,9 @@ } 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(); } } } @@ -650,14 +662,14 @@ # documents # - function source_documents($id_source) - { $sgbd = $this->sgbd(); + public function source_documents($id_source){ + $sgbd = $this->sgbd(); $documents = array(); - if($sgbd->data_exists("sml_sources/".$id_source)) - { if($rst = $sgbd->open_data("sml_sources/".$id_source)) - { $OK = true; - while($OK && ($document = $sgbd->fetch_data($rst))) - { if(isset($document)) $documents[$document["id"]] = $document; + if($sgbd->data_exists("sml_sources/".$id_source)){ + if($rst = $sgbd->open_data("sml_sources/".$id_source)){ + $OK = true; + while($OK && ($document = $sgbd->fetch_data($rst))){ + if(isset($document)) $documents[$document["id"]] = $document; else $OK = false; } $sgbd->close_data($rst); @@ -668,28 +680,31 @@ return $documents; } - function add_source_document($id_source, $document) - { $sgbd = $this->sgbd(); - if(!$sgbd->data_exists("sml_sources/".$id_source)) - { if(!$sgbd->create_data("sml_sources/".$id_source)) return false; - } - if - ( !( $id_document = $sgbd->add_data - ( "sml_sources/".$id_source, - array - ( "nom" => $document["nom"], + public function add_source_document($id_source, $document){ + $sgbd = $this->sgbd(); + if(!$sgbd->data_exists("sml_sources/".$id_source)){ + if(!$sgbd->create_data("sml_sources/".$id_source)) return false; + } + if( + !( + $id_document = $sgbd->add_data( + "sml_sources/".$id_source, + array( + "nom" => $document["nom"], "url" => $document["url"] ) ) ) - ) return false; + ){ + return false; + } return $id_document; } - function del_source_documents($id_source) - { $sgbd = $this->sgbd(); - if($sgbd->data_exists("sml_sources/".$id_source)) - { if(!$sgbd->remove_data("sml_sources/".$id_source)) return false; + public function del_source_documents($id_source){ + $sgbd = $this->sgbd(); + if($sgbd->data_exists("sml_sources/".$id_source)){ + if(!$sgbd->remove_data("sml_sources/".$id_source)) return false; } return true; } @@ -698,50 +713,59 @@ # 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(); $compositions = array(); - if(isset($id_source)) - { if($rst = $sgbd->open_data("sml_source_compositions")) - { while($v_rst = $sgbd->fetch_data($rst)) - { if(isset($v_rst)) - { if(isset($v_rst["id_source"]) && isset($v_rst["id_composition"]) && $v_rst["id_source"] == $id_source) - { if(!isset($compositions[$v_rst["id_source"]])) $compositions[$v_rst["id_source"]] = array(); + if(isset($id_source)){ + if($rst = $sgbd->open_data("sml_source_compositions")){ + while($v_rst = $sgbd->fetch_data($rst)){ + if(isset($v_rst)){ + if(isset($v_rst["id_source"]) && isset($v_rst["id_composition"]) && $v_rst["id_source"] == $id_source){ + if(!isset($compositions[$v_rst["id_source"]])) $compositions[$v_rst["id_source"]] = array(); $compositions[$v_rst["id_source"]][] = $v_rst["id_composition"]; } } - else { $compositions = false; break; } + else{ + $compositions = false; + break; + } } $sgbd->close_data($rst); } else $compositions = false; } - elseif(isset($id_composition)) - { if($id_composition) - { if($rst = $sgbd->open_data("sml_source_compositions")) - { while($v_rst = $sgbd->fetch_data($rst)) - { if(isset($v_rst)) - { if(isset($v_rst["id_source"]) && isset($v_rst["id_composition"]) && $v_rst["id_composition"] == $id_composition) - { if(!isset($compositions[$v_rst["id_composition"]])) $compositions[$v_rst["id_composition"]] = array(); + elseif(isset($id_composition)){ + if($id_composition){ + if($rst = $sgbd->open_data("sml_source_compositions")){ + while($v_rst = $sgbd->fetch_data($rst)){ + if(isset($v_rst)){ + if(isset($v_rst["id_source"]) && isset($v_rst["id_composition"]) && $v_rst["id_composition"] == $id_composition){ + if(!isset($compositions[$v_rst["id_composition"]])) $compositions[$v_rst["id_composition"]] = array(); $compositions[$v_rst["id_composition"]][] = $v_rst["id_source"]; } } - else { $compositions = false; break; } + else{ + $compositions = false; + break; + } } $sgbd->close_data($rst); } else $compositions = false; } - else - { if($rst = $sgbd->open_data("sml_source_compositions")) - { while($v_rst = $sgbd->fetch_data($rst)) - { if(isset($v_rst)) - { if(isset($v_rst["id_source"])) $compositions[$v_rst["id_source"]] = true; + else{ + if($rst = $sgbd->open_data("sml_source_compositions")){ + while($v_rst = $sgbd->fetch_data($rst)){ + if(isset($v_rst)){ + if(isset($v_rst["id_source"])) $compositions[$v_rst["id_source"]] = true; + } + else{ + $compositions = false; + break; } - else { $compositions = false; break; } } $sgbd->close_data($rst); } @@ -751,70 +775,77 @@ return $compositions; } - function set_source_composition($id_source, $id_composition) - { $sgbd = $this->sgbd(); - if - ( $sgbd->add_data - ( "sml_source_compositions", - array - ( "id_source" => $id_source, + public function set_source_composition($id_source, $id_composition){ + $sgbd = $this->sgbd(); + if( + $sgbd->add_data( + "sml_source_compositions", + array( + "id_source" => $id_source, "id_composition" => $id_composition ) ) - ) return $this->set_source_xml($id_composition); + ){ + return $this->set_source_xml($id_composition); + } return false; } - function del_source_compositions($params) - { $OK = true; + public function del_source_compositions($params){ + $OK = true; $id_source = isset($params["id_source"]) ? $params["id_source"] : null; $id_composition = isset($params["id_composition"]) ? $params["id_composition"] : null; $to_delete = array(); $to_update = array(); if(isset($id_composition)) $to_update[$id_composition] = true; $sgbd = $this->sgbd(); - if($rst = $sgbd->open_data("sml_source_compositions")) - { while($v_rst = $sgbd->fetch_data($rst)) - { if(isset($v_rst)) - { if(isset($v_rst["id"]) && isset($v_rst["id_source"]) && isset($v_rst["id_composition"])) - { if - ( (isset($id_source) && $v_rst["id_source"] == $id_source) + if($rst = $sgbd->open_data("sml_source_compositions")){ + while($v_rst = $sgbd->fetch_data($rst)){ + if(isset($v_rst)){ + if(isset($v_rst["id"]) && isset($v_rst["id_source"]) && isset($v_rst["id_composition"])){ + if( + (isset($id_source) && $v_rst["id_source"] == $id_source) || (isset($id_composition) && $v_rst["id_composition"] == $id_composition) - ) $to_delete[] = $v_rst["id"]; + ){ + $to_delete[] = $v_rst["id"]; + } if(isset($id_source) && $v_rst["id_source"] == $id_source) $to_update[$v_rst["id_composition"]] = true; } } - else { $OK = false; break; } + else{ + $OK = false; + break; + } } $sgbd->close_data($rst); } else $OK = false; if(!$OK) return false; - foreach($to_delete as $id_source_composition) - { if(!$sgbd->del_data("sml_source_compositions", $id_source_composition)) return false; + foreach($to_delete as $id_source_composition){ + if(!$sgbd->del_data("sml_source_compositions", $id_source_composition)) return false; } - foreach($to_update as $id_source_xml => $delete) - { if(!$this->set_source_xml($id_source_xml)) return false; + foreach($to_update as $id_source_xml => $delete){ + 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(); $has_sources = 0; - if($rst = $sgbd->open_data("sml_source_compositions")) - { while($v_rst = $sgbd->fetch_data($rst)) - { if(isset($v_rst)) - { if(isset($v_rst["id_source"]) && isset($v_rst["id_composition"])) - { if($v_rst["id_composition"] == $id_composition) - { $has_sources = 1; + if($rst = $sgbd->open_data("sml_source_compositions")){ + while($v_rst = $sgbd->fetch_data($rst)){ + if(isset($v_rst)){ + if(isset($v_rst["id_source"]) && isset($v_rst["id_composition"])){ + if($v_rst["id_composition"] == $id_composition){ + $has_sources = 1; break; } } } - else - { $has_sources = false; + else{ + $has_sources = false; break; } } @@ -824,13 +855,12 @@ 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; } @@ -844,5 +874,3 @@ } } - -?> \ No newline at end of file diff --git a/app/data/modules/xml/sml_data_sources_cache_db.php b/app/data/modules/xml/sml_data_sources_cache_db.php index 9700fdd..7496d6b 100644 --- a/app/data/modules/xml/sml_data_sources_cache_db.php +++ b/app/data/modules/xml/sml_data_sources_cache_db.php @@ -1,18 +1,17 @@ sgbd(); + public function source_cache_db(){ + $sgbd = $this->sgbd(); $source_cache = array(); - if($rst = $sgbd->open_data("sml_source_cache")) - { while($v_rst = $sgbd->fetch_data($rst)) - { if(isset($v_rst)) - { if(isset($v_rst["id"])) $source_cache[$v_rst["id"]] = $v_rst; + if($rst = $sgbd->open_data("sml_source_cache")){ + while($v_rst = $sgbd->fetch_data($rst)){ + if(isset($v_rst)){ + if(isset($v_rst["id"])) $source_cache[$v_rst["id"]] = $v_rst; } - else - { $source_cache = false; + else{ + $source_cache = false; $break; } } @@ -22,21 +21,21 @@ return $source_cache; } - function source_cache_infos_db($url) - { $sgbd = $this->sgbd(); + public function source_cache_infos_db($url){ + $sgbd = $this->sgbd(); $cache_infos = array(); - if($rst = $sgbd->open_data("sml_source_cache")) - { while($v_rst = $sgbd->fetch_data($rst)) - { if(isset($v_rst)) - { if(isset($v_rst["id"]) && isset($v_rst["url"])) - { if($v_rst["url"] == $url) - { $cache_infos = $v_rst; + if($rst = $sgbd->open_data("sml_source_cache")){ + while($v_rst = $sgbd->fetch_data($rst)){ + if(isset($v_rst)){ + if(isset($v_rst["id"]) && isset($v_rst["url"])){ + if($v_rst["url"] == $url){ + $cache_infos = $v_rst; $break; } } } - else - { $cache_infos = false; + else{ + $cache_infos = false; $break; } } @@ -46,23 +45,21 @@ return $cache_infos; } - function add_source_cache_db($url, $cache_index) - { $sgbd = $this->sgbd(); - return $sgbd->add_data - ( "sml_source_cache", - array - ( "url" => $url, + public function add_source_cache_db($url, $cache_index){ + $sgbd = $this->sgbd(); + return $sgbd->add_data( + "sml_source_cache", + array( + "url" => $url, "id_source" => $cache_index, "last_update" => date("Y-m-d H:i:s") ) ) ? true : false; } - function del_source_cache_db($id_cache_data) - { $sgbd = $this->sgbd(); + public function del_source_cache_db($id_cache_data){ + $sgbd = $this->sgbd(); return $sgbd->del_data("sml_source_cache", $id_cache_data) ? true : false; } } - -?> \ No newline at end of file diff --git a/app/data/upgrades/sql/mw_sourceml_sql_version_1_1_2.php b/app/data/upgrades/sql/mw_sourceml_sql_version_1_1_2.php index 50769d3..bbae392 100644 --- a/app/data/upgrades/sql/mw_sourceml_sql_version_1_1_2.php +++ b/app/data/upgrades/sql/mw_sourceml_sql_version_1_1_2.php @@ -2,11 +2,11 @@ class mw_sourceml_sql_version_1_1_2 extends mw_data_version{ - function version(){ + public function version(){ return "1.1.2"; } - function do_upgrade(){ + public function do_upgrade(){ $env = $this->env(); $data = $env->data(); diff --git a/app/data/upgrades/xml/mw_sourceml_xml_version_1_1_2.php b/app/data/upgrades/xml/mw_sourceml_xml_version_1_1_2.php index 196adde..b8dfd4e 100644 --- a/app/data/upgrades/xml/mw_sourceml_xml_version_1_1_2.php +++ b/app/data/upgrades/xml/mw_sourceml_xml_version_1_1_2.php @@ -2,11 +2,11 @@ class mw_sourceml_xml_version_1_1_2 extends mw_data_version{ - function version(){ + public function version(){ return "1.1.2"; } - function do_upgrade(){ + public function do_upgrade(){ $env = $this->env(); $data = $env->data(); diff --git a/app/helpers/mw_helper_sourceml_out.php b/app/helpers/mw_helper_sourceml_out.php index a1f962b..8bb4636 100644 --- a/app/helpers/mw_helper_sourceml_out.php +++ b/app/helpers/mw_helper_sourceml_out.php @@ -2,14 +2,14 @@ class mw_helper_sourceml_out extends mw_helper{ - function aff_date($date){ + public function aff_date($date){ if(preg_match("/([0-9]{2,4})-([0-9]{1,2})-([0-9]{1,2})/", $date, $regs)){ $date = $regs[3]." ".$this->mois($regs[2])." ".$regs[1]; } return $date; } - function mois($n){ + public function mois($n){ switch($n){ case 1: $mois = "jan"; break; case 2: $mois = "fev"; break; @@ -29,5 +29,3 @@ } } - -?> \ No newline at end of file diff --git a/app/observers/mw_observer_sourceml.php b/app/observers/mw_observer_sourceml.php index 38c3622..fb7c3ee 100644 --- a/app/observers/mw_observer_sourceml.php +++ b/app/observers/mw_observer_sourceml.php @@ -2,7 +2,7 @@ class mw_observer_sourceml extends mw_observer{ - function before_action(){ + public function before_action(){ $env = $this->env(); $out_config = $env->get_out_config(); $out_config["groupe_view_albums"] = array( @@ -28,7 +28,7 @@ $env->set_out_config($out_config); } - function after_action(){ + public function after_action(){ $env = $this->env(); if($env->etat("mod") == "users"){ $env->add_js_file($env->path("web").$env->path("mw_path")."libs/tiny_mce/tiny_mce.js"); @@ -47,5 +47,3 @@ } } - -?> \ No newline at end of file diff --git a/mw_sourceml.php b/mw_sourceml.php index 4563009..66db9de 100644 --- a/mw_sourceml.php +++ b/mw_sourceml.php @@ -2,15 +2,15 @@ class mw_sourceml extends mw_plugin{ - function title(){ + public function title(){ return "SourceML"; } - function description(){ + public function description(){ return "Publication de sources musicales"; } - function loaded($env){ + public function loaded($env){ $AUTO_ACTIVATE = false; if(!$env->bdd("sgbd") || ($plugin_data = $env->plugin_data("mw_sourceml")) === false) return; if(!isset($plugin_data["installed"]) || !$plugin_data["installed"]){ @@ -39,7 +39,7 @@ } } - function init($env){ + public function init($env){ $env->set_link("admin/sourceml", $env->url("admin/sourceml"), "SourceML", 50); $env->set_link("admin/sourceml/licences", $env->url("admin/licences"), "Licences", 10); @@ -63,7 +63,7 @@ return true; } - function nb_invitations($env){ + public function nb_invitations($env){ if($user = $env->user()){ $data = $env->data(); if($groupes = $data->groupes($user["id"])){ @@ -75,7 +75,7 @@ return 0; } - function enable($env){ + public function enable($env){ $data = $env->data(); if( ($data->config("site_name") == "mtweb") @@ -99,7 +99,7 @@ return true; } - function install($env){ + public function install($env){ $data = $env->data(); $res = true; if( @@ -127,7 +127,7 @@ return $res; } - function uninstall($env){ + public function uninstall($env){ $data = $env->data(); $res = true; if( -- 2.1.4