class mw_admin_cache extends mw_controller{
- function index(){
+ public function index(){
$env = $this->env();
$data = $env->data();
if(($CONFIG = $env->get_CONFIG()) !== false){
}
}
-
-?>
\ No newline at end of file
<?php
- class mw_admin_licences extends mw_controller
- {
- function index(){
+ class mw_admin_licences extends mw_controller{
+
+ public function index(){
$env = $this->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 <strong>".$_POST["nom"]."</strong> a été ajoutée"
- );
+ ){
+ $env->redirect(
+ $env->url("admin/licences"),
+ "la licence <strong>".$_POST["nom"]."</strong> 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 <strong>".$licence["nom"]."</strong> a été modifiée"
- );
+ ){
+ $env->redirect
+ ( $env->url("admin/licences"),
+ "la licence <strong>".$licence["nom"]."</strong> a été modifiée"
+ );
+ }
else $env->erreur("Impossible de mettre à jour la licence");
}
else $env->message("Merci de préciser un nom");
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 <strong>".$licence["nom"]."</strong> 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 <strong>".$licence["nom"]."</strong> a été supprimée"
+ );
+ }
}
else $env->erreur("Impossible de supprimer la licence");
}
}
}
-
-?>
\ No newline at end of file
<?php
- class mw_admin_maintenance extends mw_controller
- {
- function index(){
+ class mw_admin_maintenance extends mw_controller{
+
+ public function index(){
}
- function empty_cache(){
+ public function empty_cache(){
$env = $this->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"
);
}
}
}
-
-?>
\ No newline at end of file
<?php
- class mw_admin_sourceml extends mw_controller
- {
+ class mw_admin_sourceml extends mw_controller{
- var $groupes;
- var $albums;
- var $status;
- var $album_status_id;
+ public $groupes;
+ public $albums;
+ public $status;
+ public $album_status_id;
- function validate(){
+ public function validate(){
$env = $this->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)){
}
}
-
-?>
\ No newline at end of file
<?php
- class mw_content_sources extends mw_controller
- {
- var $status;
- var $album_status_id;
- var $morceau_status_id;
- var $piste_status_id;
- var $url_params;
- var $source_param;
- var $licences;
+ class mw_content_sources extends mw_controller{
- var $groupe;
- var $source;
- var $source_controller;
+ public $status;
+ public $album_status_id;
+ public $morceau_status_id;
+ public $piste_status_id;
+ public $url_params;
+ public $source_param;
+ public $licences;
+ public $groupe;
+ public $source;
+ public $source_controller;
+ public $validation_result;
- var $validation_result;
-
- function validate(){
+ public function validate(){
$env = $this->env();
$this->validation_result = true;
$this->validate_status($env);
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;
}
}
- 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";
}
}
}
- 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";
}
}
}
- 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;
}
}
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;
}
}
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
);
}
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"];
$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);
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 =
"<pre>"
- .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"
)
exit;
}
- function erreur($content)
- { echo $content;
+ public function erreur($content){
+ echo $content;
exit;
}
}
-
-?>
\ No newline at end of file
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();
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é"
);
}
}
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;
}
}
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");
}
}
-
-?>
\ No newline at end of file
<?php
- class mw_sources_album extends mw_controller
- {
- var $content_sources_mod;
+ class mw_sources_album extends mw_controller{
- function validate(){
+ public $content_sources_mod;
+
+ public function validate(){
$env = $this->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;
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");
}
}
}
- 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");
}
}
}
-
-?>
\ No newline at end of file
<?php
- class mw_sources_groupe extends mw_controller
- {
- var $content_sources_mod;
+ class mw_sources_groupe extends mw_controller{
- function validate(){
+ public $content_sources_mod;
+
+ public function validate(){
$env = $this->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;
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");
}
}
}
-
-?>
\ No newline at end of file
<?php
- class mw_sources_morceau extends mw_controller
- {
- var $content_sources_mod;
+ class mw_sources_morceau extends mw_controller{
- function validate(){
+ public $content_sources_mod;
+
+ public function validate(){
$env = $this->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;
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"]);
}
}
}
- 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";
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);
}
}
}
-
-?>
\ No newline at end of file
<?php
- class mw_sources_piste extends mw_controller
- {
- var $content_sources_mod;
+ class mw_sources_piste extends mw_controller{
- function validate(){
+ public $content_sources_mod;
+
+ public function validate(){
$env = $this->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;
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";
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");
}
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);
}
}
-
-?>
\ No newline at end of file
*/
- 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")];
}
}
- function make_all(){
+ public function make_all(){
$env = $this->env();
$data = $env->data();
$base_url = $_GET[$env->param("from")];
}
}
-
-?>
\ No newline at end of file
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){
return true;
}
- function index(){
+ public function index(){
$env = $this->env();
$data = $env->data();
if(($groupes = $data->groupes($this->user["id"])) === false){
$env->set_out("albums", $albums);
}
- function add(){
+ public function add(){
$env = $this->env();
$data = $env->data();
$album = $data->empty_source();
$env->set_out("groupe", $groupe);
}
- function edit(){
+ public function edit(){
$env = $this->env();
$data = $env->data();
if(($groupes = $data->groupes($this->user["id"])) === false){
$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))){
);
}
- function groupes(){
+ public function groupes(){
$env = $this->env();
if(
!($sources_invitations_controller = $env->get_controller("users/sources_invitations"))
}
}
-
-?>
\ No newline at end of file
<?php
- class mw_users_groupes extends mw_controller
- {
+ class mw_users_groupes extends mw_controller{
- var $groupe;
- var $user;
+ public $groupe;
+ public $user;
- function validate(){
+ public function validate(){
$env = $this->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";
}
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"],
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à");
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"],
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");
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");
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
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){
return true;
}
- function index(){
+ public function index(){
$env = $this->env();
$data = $env->data();
if(($groupes = $data->groupes($this->user["id"])) === false){
$env->set_out("morceaux", $morceaux);
}
- function add(){
+ public function add(){
$env = $this->env();
$data = $env->data();
$morceau = $data->empty_source();
$env->set_out("album", $album);
}
- function edit(){
+ public function edit(){
$env = $this->env();
$data = $env->data();
if(($groupes = $data->groupes($this->user["id"])) === false){
$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"],
$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))){
$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))){
);
}
- function groupes(){
+ public function groupes(){
$env = $this->env();
if(
!($sources_invitations_controller = $env->get_controller("users/sources_invitations"))
}
}
-
-?>
\ No newline at end of file
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){
return true;
}
- function index(){
+ public function index(){
$env = $this->env();
$data = $env->data();
if(($groupes = $data->groupes($this->user["id"])) === false){
$env->set_out("pistes", $pistes);
}
- function add(){
+ public function add(){
$env = $this->env();
$data = $env->data();
$piste = $data->empty_source();
$env->set_out("morceau", $morceau);
}
- function edit(){
+ public function edit(){
$env = $this->env();
$data = $env->data();
if(($groupes = $data->groupes($this->user["id"])) === false){
$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;
$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))){
$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))){
);
}
- function groupes(){
+ public function groupes(){
$env = $this->env();
if(
!($sources_invitations_controller = $env->get_controller("users/sources_invitations"))
}
}
-
-?>
\ No newline at end of file
<?php
- class mw_users_sources extends mw_controller
- {
+ class mw_users_sources extends mw_controller{
- function validate(){
+ public function validate(){
return "Controleur interne - appel interne uniquement";
}
- function get_source_from_xml(&$env, $xml_url, $xml_content, $xml_use_edit_content)
- { $data = $env->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 :"
."<br /><strong>".$source_xml["url"]."</strong>"
);
}
}
- 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 :"
."<br /><strong>".$source_xml["url"]."</strong>"
);
}
- else
- { $env->message
- ( "Le contenu du fichier XML est vide pour :"
+ else{
+ $env->message(
+ "Le contenu du fichier XML est vide pour :"
."<br /><strong>".$source_xml["url"]."</strong>"
);
}
}
}
- 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
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){
return true;
}
- function index(){
+ public function index(){
$env = $this->env();
$data = $env->data();
if(($sources_access = $data->sources_access()) === false){
$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))){
$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))){
);
}
- 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")]))){
);
}
- function accepter_invitation_groupe(){
+ public function accepter_invitation_groupe(){
$env = $this->env();
$data = $env->data();
if(($groupes = $data->groupes($this->user["id"])) === false){
);
}
- function refuser_invitation_groupe(){
+ public function refuser_invitation_groupe(){
$env = $this->env();
$data = $env->data();
if(($groupes = $data->groupes($this->user["id"])) === false){
);
}
- function del_groupe(){
+ public function del_groupe(){
$env = $this->env();
$data = $env->data();
if(!($source = $data->source($_GET[$env->param("id")], true))){
}
}
-
-?>
\ No newline at end of file
* 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){
* $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;
}
}
}
* $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){
* 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;
* 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){
* $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;
}
* 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";
* 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;
}
}
-
-?>
\ No newline at end of file
<?php
- class sml_data_sources_xml extends mw_data
- {
+ class sml_data_sources_xml extends mw_data{
- function get_source_xml_from_url($url, $IGNORE_UPDATE = false)
- { $env = $this->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);
}
# 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){
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;
}
}
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;
}
}
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;
}
}
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));
# 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);
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);
# 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);
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
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();
# 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" => "",
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);
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"){
// -------------------------------------- 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;
// -------------------------------------- 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;
}
}
-
-?>
\ No newline at end of file
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)){
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
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);
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;
// 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;
}
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;
}
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";
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)),
}
}
-
-?>
\ No newline at end of file
<?php
- class sml_data_authors extends mw_data
- {
+ class sml_data_authors extends mw_data{
# ----------------------------------------------------------------------------------------
# groupes
#
- function groupes($id_user = null, $start = null, $alpha = null){
+ public function groupes($id_user = null, $start = null, $alpha = null){
$sgbd = $this->sgbd();
$env = $this->env();
$groupes = array("list" => array(), "total" => 0);
return $groupes;
}
- function groupe($id){
+ public function groupe($id){
$sgbd = $this->sgbd();
$env = $this->env();
$groupe = array();
}
$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{
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 =
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{
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);
}
}
-
-?>
\ No newline at end of file
// install
//
- function mw_sourceml_install_mysql($plugin, $env){
+ public function mw_sourceml_install_mysql($plugin, $env){
$sgbd = $this->sgbd();
try{
$EXISTS =
return true;
}
- function mw_sourceml_install_sqlite($plugin, $env){
+ public function mw_sourceml_install_sqlite($plugin, $env){
$sgbd = $this->sgbd();
try{
$EXISTS =
// 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"))){
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);
$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{
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 =
.")";
$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{
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);
$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
<?php
- class sml_data_source_groupes extends mw_data
- {
+ 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();
try{
$sql =
." 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"]
: ""
);
}
$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;
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{
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"
.")";
$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"
." 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 =
." 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{
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(
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;
}
}
}
// --------------------------------------------------------------------
- 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(
}
}
-
-?>
\ No newline at end of file
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();
while($v_rst = $sgbd->fetch_assoc($rst)) $status[$v_rst["id"]] = $v_rst;
$sgbd->free_result($rst);
}
- catch(Exception $e) { $status = false; }
+ catch(Exception $e){
+ $status = false;
+ }
return $status;
}
# sources
#
- function init_sources_table(){
+ public function init_sources_table(){
return true;
}
- function sources($params){
+ public function sources($params){
$start = isset($params["start"]) ? $params["start"] : null;
$id_user = isset($params["id_user"]) ? $params["id_user"] : null;
$id_groupe = isset($params["id_groupe"]) ? $params["id_groupe"] : null;
($WHERE ? " AND " : " WHERE ")
." #--sml_sources.id=#--sml_source_compositions.id_composition"
." AND #--sml_source_compositions.id_source=".$this->eq($id_source);
- elseif(isset($id_composition))
- { if($id_composition)
- { $WHERE .=
+ elseif(isset($id_composition)){
+ if($id_composition){
+ $WHERE .=
($WHERE ? " AND " : " WHERE ")
." #--sml_sources.id=#--sml_source_compositions.id_source"
." AND #--sml_source_compositions.id_composition=".$this->eq($id_composition);
}
- else
- { if(($sources_ids = $this->source_compositions(array("id_composition" => ""))) !== false)
- { if($sources_ids)
- { $NOT_IN = "";
+ else{
+ if(($sources_ids = $this->source_compositions(array("id_composition" => ""))) !== false){
+ if($sources_ids){
+ $NOT_IN = "";
foreach($sources_ids as $in_source_id) $NOT_IN .= ($NOT_IN ? "," : "").$in_source_id;
$WHERE .= ($WHERE ? " AND " : " WHERE ")." #--sml_sources.id NOT IN(".$NOT_IN.")";
}
$rst = $sgbd->query($sql);
if($v_rst = $sgbd->fetch_assoc($rst)) $sources["total"] = $v_rst["n"];
$sgbd->free_result($rst);
- if($sources["total"])
- { $sql = $SELECT.$FROM.$WHERE.$ORDER_BY.$LIMIT;
+ if($sources["total"]){
+ $sql = $SELECT.$FROM.$WHERE.$ORDER_BY.$LIMIT;
$rst = $sgbd->query($sql);
$OK = true;
while($v_rst = $sgbd->fetch_assoc($rst)){
if(!$OK) return false;
}
}
- catch(Exception $e) { $sources = false; }
+ catch(Exception $e){
+ $sources = false;
+ }
return $sources;
}
- function source($id, $load = false){
+ public function source($id, $load = false){
$sgbd = $this->sgbd();
try{
$sql = "SELECT #--sml_sources.*, #--sml_sources.id_class as status FROM #--sml_sources WHERE id=".$this->eq($id);
}
$sgbd->free_result($rst);
}
- catch(Exception $e) { $source = false; }
+ catch(Exception $e){
+ $source = false;
+ }
return $source;
}
- function get_source_from_v_rst($v_rst){
+ public function get_source_from_v_rst($v_rst){
$sgbd = $this->sgbd();
$source = $this->empty_source();
foreach($v_rst as $rst_key => $rst_value) $source[$rst_key] = $rst_value;
}
}
}
- catch(Exception $e) { $source = false; }
+ catch(Exception $e){
+ $source = false;
+ }
return $source;
}
- function load_source($source){
+ public function load_source($source){
$env = $this->env();
if(!isset($source["id"])) return false;
$source = $this->get_source_from_v_rst($source);
- $source["xml"] = array
- ( "url" => $this->source_xml_url($source["id"]),
+ $source["xml"] = array(
+ "url" => $this->source_xml_url($source["id"]),
"content" => $this->get_source_xml($source["id"])
);
$source["documents"] = array();
if(($source["groupes"] = $this->source_groupes($source["id"])) === false) return false;
- $source["image_uri"] =
- ( isset($source["image"]) && $source["image"] ?
+ $source["image_uri"] = (
+ isset($source["image"]) && $source["image"] ?
$env->path("content")."uploads/".$source["image"]
: ""
);
if($user = $env->user()){
if(($source["permissions"] = $this->source_permissions($source, $user["id"])) === false) return false;
}
- if(!$source["reference"])
- { if(($source["documents"] = $this->source_documents($source["id"])) === false) return false;
+ if(!$source["reference"]){
+ if(($source["documents"] = $this->source_documents($source["id"])) === false) return false;
}
return $source;
}
- function add_source
- ( $groupes,
+ public function add_source(
+ $groupes,
$titre,
$status,
$licence,
$reference = array(),
$derivations = array(),
$infos = array()
- )
- { $sgbd = $this->sgbd();
- $source = array
- ( "groupes" => $groupes,
+ ){
+ $sgbd = $this->sgbd();
+ $source = array(
+ "groupes" => $groupes,
"titre" => $reference ? null : $titre,
"status" => $status,
"licence" => $reference ? null : $licence,
.")";
$sgbd->query($sql);
$id = $sgbd->insert_id();
- foreach($source["groupes"] as $id_groupe => $groupe)
- { if($groupe["id"] && $groupe["id_groupe_status"])
- { if(!$this->add_source_groupe($id, $groupe["id"], $groupe["id_groupe_status"])) return false;
+ foreach($source["groupes"] as $id_groupe => $groupe){
+ if($groupe["id"] && $groupe["id_groupe_status"]){
+ if(!$this->add_source_groupe($id, $groupe["id"], $groupe["id_groupe_status"])) return false;
}
else return false;
}
$sgbd->query($sql);
}
}
- catch(Exception $e) { return false; }
- foreach($derivations as $source_derivation)
- { if
- ( ( $id_source_derivation = $this->add_source_derivation
- ( $id,
+ catch(Exception $e){
+ return false;
+ }
+ foreach($derivations as $source_derivation){
+ if(
+ (
+ $id_source_derivation = $this->add_source_derivation(
+ $id,
$source_derivation["xml"]["url"],
$source_derivation["xml"]["use_edit_content"] ? $source_derivation["xml"]["content"] : ""
)
) === false
- )
- { return false;
+ ){
+ return false;
}
}
- if($reference)
- { if($reference["xml"]["use_edit_content"])
- { if(!$this->set_edit_reference_content($id, $reference["xml"]["content"]))
- { return false;
+ if($reference){
+ if($reference["xml"]["use_edit_content"]){
+ if(!$this->set_edit_reference_content($id, $reference["xml"]["content"])){
+ return false;
}
}
}
- else
- { foreach($documents as $document)
- { if(!$this->add_source_document($id, $document)) return false;
+ else{
+ foreach($documents as $document){
+ if(!$this->add_source_document($id, $document)) return false;
}
}
if(!$this->set_source_xml($id)) return false;
return $id;
}
- function set_source
- ( $id,
+ public function set_source(
+ $id,
$groupes,
$titre,
$status,
$reference = array(),
$derivations = array(),
$infos = array()
- )
- { if($source = $this->source($id))
- { $sgbd = $this->sgbd();
- $source = array
- ( "groupes" => $groupes,
+ ){
+ if($source = $this->source($id)){
+ $sgbd = $this->sgbd();
+ $source = array(
+ "groupes" => $groupes,
"titre" => $reference ? null : $titre,
"licence" => $reference ? null : $licence,
"reference" => $reference ? $reference : null,
." WHERE id=".$this->eq($id);
$sgbd->query($sql);
if(!$this->del_source_groupes($id)) return false;
- foreach($source["groupes"] as $id_groupe => $groupe)
- { if($groupe["id"] && $groupe["id_groupe_status"]){
+ foreach($source["groupes"] as $id_groupe => $groupe){
+ if($groupe["id"] && $groupe["id_groupe_status"]){
if(!$this->add_source_groupe($id, $groupe["id"], $groupe["id_groupe_status"])) return false;
}
else return false;
$sgbd->query($sql);
if(isset($infos["date_creation"])) unset($infos["date_creation"]);
if(isset($infos["date_inscription"])) unset($infos["date_inscription"]);
- foreach($infos as $key => $value)
- { $sql =
+ foreach($infos as $key => $value){
+ $sql =
"INSERT INTO #--sml_sources_infos(id_source, `key`,`value`)"
." VALUES"
."( ".$this->eq($id)
$sgbd->query($sql);
}
}
- catch(Exception $e) { return false; }
+ catch(Exception $e){
+ return false;
+ }
if(!$this->del_source_derivations($id)) return false;
if(!$this->del_edit_reference_content($id)) return false;
if(!$this->del_source_documents($id)) return false;
- foreach($derivations as $source_derivation)
- { if
- ( ( $id_source_derivation = $this->add_source_derivation
- ( $id,
+ foreach($derivations as $source_derivation){
+ if(
+ (
+ $id_source_derivation = $this->add_source_derivation(
+ $id,
$source_derivation["xml"]["url"],
$source_derivation["xml"]["use_edit_content"] ? $source_derivation["xml"]["content"] : ""
)
) === false
- )
- { return false;
+ ){
+ return false;
}
}
- if($reference)
- { if($reference["xml"]["use_edit_content"])
- { if(!$this->set_edit_reference_content($id, $reference["xml"]["content"]))
- { return false;
+ if($reference){
+ if($reference["xml"]["use_edit_content"]){
+ if(!$this->set_edit_reference_content($id, $reference["xml"]["content"])){
+ return false;
}
}
}
return false;
}
- function set_source_info($id_source, $key, $value){
+ public function set_source_info($id_source, $key, $value){
$sgbd = $this->sgbd();
try{
$sql =
$id = null;
if($v_rst = $sgbd->fetch_assoc($rst)) $id = $v_rst["id"];
$sgbd->free_result($rst);
- if(isset($id)) $sql =
- "UPDATE #--sml_sources_infos SET"
- ." `value`=".$this->eq($value)
- ." WHERE id=".$this->eq($id);
- else $sql =
- "INSERT INTO #--sml_sources_infos(id_source, `key`,`value`)"
- ." VALUES"
- ."( ".$this->eq($id_source)
- .", ".$this->eq($key)
- .", ".$this->eq($value)
- .")";
+ if(isset($id)){
+ $sql =
+ "UPDATE #--sml_sources_infos SET"
+ ." `value`=".$this->eq($value)
+ ." WHERE id=".$this->eq($id);
+ }
+ else{
+ $sql =
+ "INSERT INTO #--sml_sources_infos(id_source, `key`,`value`)"
+ ." VALUES"
+ ."( ".$this->eq($id_source)
+ .", ".$this->eq($key)
+ .", ".$this->eq($value)
+ .")";
+ }
$sgbd->query($sql);
if(!isset($id)) $id = $sgbd->insert_id();
}
- catch(Exception $e) { return false; }
+ catch(Exception $e){
+ return false;
+ }
return $id;
}
- function del_source($id){
+ public function del_source($id){
$sgbd = $this->sgbd();
if(!$this->del_source_compositions(array("id_source" => $id, "id_composition" => $id))) return false;
if(!$this->del_edit_reference_content($id)) return false;
$sql = "DELETE FROM #--sml_sources WHERE id=".$this->eq($id);
$sgbd->query($sql);
}
- catch(Exception $e) { return false; }
+ catch(Exception $e){
+ return false;
+ }
return true;
}
# derivations de sources
#
- function init_source_derivations()
- { $sgbd = $this->sgbd();
+ public function init_source_derivations(){
+ $sgbd = $this->sgbd();
$rst = $sgbd->table_exists("#--sml_source_derivations");
- if(isset($rst))
- { if(!$rst)
- { return
+ if(isset($rst)){
+ if(!$rst){
+ return
"table manquante"
."<br />"
."<br />"
return true;
}
- function source_derivations($params)
- { $sgbd = $this->sgbd();
+ public function source_derivations($params){
+ $sgbd = $this->sgbd();
$env = $this->env();
$derivations = array();
// sources dont "id_source" est une derivation
." FROM #--sml_source_derivations"
." WHERE #--sml_source_derivations.id_source=".$this->eq($params["id_source"]);
$rst = $sgbd->query($sql);
- while($v_rst = $sgbd->fetch_assoc($rst))
- { $derivations[$v_rst["id"]] = array();
+ while($v_rst = $sgbd->fetch_assoc($rst)){
+ $derivations[$v_rst["id"]] = array();
$derivation_edit_file = $this->derivation_edit_xml_path($v_rst["id_source"], $v_rst["id"]);
- if(file_exists($derivation_edit_file))
- { if(($derivation_edit_content = $this->get_edit_derivation_content($v_rst["id_source"], $v_rst["id"])) !== false)
- { if(($derivations[$v_rst["id"]] = $this->source_xml_read($v_rst["derivation"], $derivation_edit_content)) !==false)
- { $derivations[$v_rst["id"]]["xml"] = array
- ( "url" => $v_rst["derivation"],
+ if(file_exists($derivation_edit_file)){
+ if(
+ (
+ $derivation_edit_content = $this->get_edit_derivation_content(
+ $v_rst["id_source"],
+ $v_rst["id"]
+ )
+ ) !== false
+ ){
+ if(
+ (
+ $derivations[$v_rst["id"]] = $this->source_xml_read(
+ $v_rst["derivation"],
+ $derivation_edit_content
+ )
+ ) !==false
+ ){
+ $derivations[$v_rst["id"]]["xml"] = array(
+ "url" => $v_rst["derivation"],
"content" => $derivation_edit_content,
"use_edit_content" => true
);
}
else return false;
}
- else
- { if(($derivations[$v_rst["id"]] = $this->source_xml_read($v_rst["derivation"])) !==false)
- { $derivations[$v_rst["id"]]["id_source"] = $v_rst["id_source"];
+ else{
+ if(($derivations[$v_rst["id"]] = $this->source_xml_read($v_rst["derivation"])) !==false){
+ $derivations[$v_rst["id"]]["id_source"] = $v_rst["id_source"];
}
else $derivations[$v_rst["id"]] = $this->empty_source();
}
}
$sgbd->free_result($rst);
}
- catch(Exception $e) { return false; }
+ catch(Exception $e){
+ return false;
+ }
return $derivations;
}
// sources qui derivent de "derivation"
- elseif(isset($params["derivation"]))
- { $source_xml_url = $params["derivation"];
+ elseif(isset($params["derivation"])){
+ $source_xml_url = $params["derivation"];
if(preg_match("/^[0-9]+$/", $source_xml_url)) $source_xml_url = $this->source_xml_url($source_xml_url);
try{
$sql =
while($v_rst = $sgbd->fetch_assoc($rst)) $derivations[$v_rst["id"]] = $v_rst;
$sgbd->free_result($rst);
}
- catch(Exception $e) { return false; }
+ catch(Exception $e){
+ return false;
+ }
return $derivations;
}
return false;
}
- function source_derivation($id){
+ public function source_derivation($id){
$sgbd = $this->sgbd();
$env = $this->env();
$derivation = array();
if($v_rst = $sgbd->fetch_assoc($rst)) $derivation = $v_rst;
$sgbd->free_result($rst);
}
- catch(Exception $e) { return false; }
+ catch(Exception $e){
+ return false;
+ }
return $derivation;
}
- function add_source_derivation($id_source, $derivation, $edit_content = "")
- { $sgbd = $this->sgbd();
+ public function add_source_derivation($id_source, $derivation, $edit_content = ""){
+ $sgbd = $this->sgbd();
try{
$sql =
"INSERT INTO #--sml_source_derivations(id_source, derivation)"
$sgbd->query($sql);
$id_source_derivation = $sgbd->insert_id();
}
- catch(Exception $e) { return false; }
- if($edit_content)
- { if(!$this->set_edit_derivation_content($id_source, $id_source_derivation, $edit_content))
- { return false;
+ catch(Exception $e){
+ return false;
+ }
+ if($edit_content){
+ if(!$this->set_edit_derivation_content($id_source, $id_source_derivation, $edit_content)){
+ return false;
}
}
return $id_source_derivation;
}
- function set_source_derivation($id_source_derivation, $id_source, $derivation, $edit_content = "")
- { $sgbd = $this->sgbd();
+ public function set_source_derivation($id_source_derivation, $id_source, $derivation, $edit_content = ""){
+ $sgbd = $this->sgbd();
try{
$sql =
"UPDATE #--sml_source_derivations SET"
." WHERE id=".$this->eq($id_source_derivation);
$sgbd->query($sql);
}
- catch(Exception $e) { return false; }
- if($edit_content)
- { if(!$this->set_edit_derivation_content($id_source, $id_source_derivation, $edit_content))
- { return false;
+ catch(Exception $e){
+ return false;
+ }
+ if($edit_content){
+ if(!$this->set_edit_derivation_content($id_source, $id_source_derivation, $edit_content)){
+ return false;
}
}
return true;
}
- function del_source_derivation($id_source_derivation)
- { if(($derivation = $this->source_derivation($id_source_derivation)) !== false)
- { if(($derivations = $this->source_derivations(array("id_source" => $derivation["id_source"]))) !== false)
- { $sgbd = $this->sgbd();
+ public function del_source_derivation($id_source_derivation){
+ if(($derivation = $this->source_derivation($id_source_derivation)) !== false){
+ if(($derivations = $this->source_derivations(array("id_source" => $derivation["id_source"]))) !== false){
+ $sgbd = $this->sgbd();
try{
$sql = "DELETE FROM #--sml_source_derivations WHERE id=".$this->eq($id_source_derivation);
$sgbd->query($sql);
}
- catch(Exception $e) { return false; }
- if(count($derivations) > 1)
- { return $this->del_edit_derivation_content($derivation["id_source"], $id_source_derivation);
+ catch(Exception $e){
+ return false;
+ }
+ if(count($derivations) > 1){
+ return $this->del_edit_derivation_content($derivation["id_source"], $id_source_derivation);
}
else return $this->del_edit_derivations($derivation["id_source"]);
}
return false;
}
- function del_source_derivations($id_source)
- { $sgbd = $this->sgbd();
+ public function del_source_derivations($id_source){
+ $sgbd = $this->sgbd();
try{
$sql = "DELETE FROM #--sml_source_derivations WHERE id_source=".$this->eq($id_source);
$sgbd->query($sql);
}
- catch(Exception $e) { return false; }
+ catch(Exception $e){
+ return false;
+ }
return $this->del_edit_derivations($id_source);
}
# references
#
- function source_reference($source)
- { $reference = array();
- if($source["reference"])
- { if(!is_array($source["reference"]))
- { $source["reference"] = array
- ( "url" => $source["reference"],
+ public function source_reference($source){
+ $reference = array();
+ if($source["reference"]){
+ if(!is_array($source["reference"])){
+ $source["reference"] = array(
+ "url" => $source["reference"],
"content" => "",
"use_edit_content" => false
);
}
$reference_edit_file = $this->reference_edit_xml_path($source["id"]);
- if(file_exists($reference_edit_file))
- { if(($reference_edit_content = $this->get_edit_reference_content($source["id"])) !== false)
- { if(($reference = $this->source_xml_read($source["reference"], $reference_edit_content)) !==false)
- { $reference["xml"] = array
- ( "url" => $source["reference"]["xml"]["url"],
+ if(file_exists($reference_edit_file)){
+ if(($reference_edit_content = $this->get_edit_reference_content($source["id"])) !== false){
+ if(($reference = $this->source_xml_read($source["reference"], $reference_edit_content)) !==false){
+ $reference["xml"] = array(
+ "url" => $source["reference"]["xml"]["url"],
"content" => $reference_edit_content,
"use_edit_content" => true
);
}
else return false;
}
- else
- { if(($reference = $this->source_xml_read($source["reference"]["xml"]["url"])) ===false)
- { $reference = $this->empty_source();
+ else{
+ if(($reference = $this->source_xml_read($source["reference"]["xml"]["url"])) ===false){
+ $reference = $this->empty_source();
}
}
}
# documents
#
- function source_documents($id_source)
- { $sgbd = $this->sgbd();
+ public function source_documents($id_source){
+ $sgbd = $this->sgbd();
$documents = array();
try{
$sql = "SELECT * FROM #--sml_source_documents WHERE id_source=".$this->eq($id_source);
while($v_rst = $sgbd->fetch_assoc($rst)) $documents[$v_rst["id"]] = $v_rst;
$sgbd->free_result($rst);
}
- catch(Exception $e) { return false; }
+ catch(Exception $e){
+ return false;
+ }
return $documents;
}
- function add_source_document($id_source, $document)
- { $sgbd = $this->sgbd();
+ public function add_source_document($id_source, $document){
+ $sgbd = $this->sgbd();
try{
$sql =
"INSERT INTO #--sml_source_documents(id_source, nom, url)"
.")";
$sgbd->query($sql);
}
- catch(Exception $e) { return false; }
+ catch(Exception $e){
+ return false;
+ }
return $sgbd->insert_id();
}
- function del_source_documents($id_source)
- { $sgbd = $this->sgbd();
+ public function del_source_documents($id_source){
+ $sgbd = $this->sgbd();
try{
$sql = "DELETE FROM #--sml_source_documents WHERE id_source=".$this->eq($id_source);
$sgbd->query($sql);
}
- catch(Exception $e) { return false; }
+ catch(Exception $e){
+ return false;
+ }
return true;
}
# compositions de sources
#
- function source_compositions($params)
- { $id_source = isset($params["id_source"]) ? $params["id_source"] : null;
+ public function source_compositions($params){
+ $id_source = isset($params["id_source"]) ? $params["id_source"] : null;
$id_composition = isset($params["id_composition"]) ? $params["id_composition"] : null;
$sgbd = $this->sgbd();
$env = $this->env();
try{
$sql = "SELECT * FROM #--sml_source_compositions WHERE id_source=".$this->eq($id_source);
$rst = $sgbd->query($sql);
- while($v_rst = $sgbd->fetch_assoc($rst))
- { if(!isset($compositions[$v_rst["id_source"]])) $compositions[$v_rst["id_source"]] = array();
+ while($v_rst = $sgbd->fetch_assoc($rst)){
+ if(!isset($compositions[$v_rst["id_source"]])) $compositions[$v_rst["id_source"]] = array();
$compositions[$v_rst["id_source"]][] = $v_rst["id_composition"];
}
$sgbd->free_result($rst);
}
- catch(Exception $e) { return false; }
+ catch(Exception $e){
+ return false;
+ }
return $compositions;
}
- elseif(isset($id_composition))
- { if($id_composition){
+ elseif(isset($id_composition)){
+ if($id_composition){
try{
$sql =
"SELECT * FROM #--sml_source_compositions WHERE id_composition=".$this->eq($id_composition);
$rst = $sgbd->query($sql);
- while($v_rst = $sgbd->fetch_assoc($rst))
- { if(!isset($compositions[$v_rst["id_composition"]])) $compositions[$v_rst["id_composition"]] = array();
+ while($v_rst = $sgbd->fetch_assoc($rst)){
+ if(!isset($compositions[$v_rst["id_composition"]])) $compositions[$v_rst["id_composition"]] = array();
$compositions[$v_rst["id_composition"]][] = $v_rst["id_source"];
}
$sgbd->free_result($rst);
}
- catch(Exception $e) { return false; }
+ catch(Exception $e){
+ return false;
+ }
return $compositions;
}
else{
while($v_rst = $sgbd->fetch_assoc($rst)) $compositions[] = $v_rst["id_source"];
$sgbd->free_result($rst);
}
- catch(Exception $e) { return false; }
+ catch(Exception $e){
+ return false;
+ }
return $compositions;
}
}
return false;
}
- function set_source_composition($id_source, $id_composition){
+ public function set_source_composition($id_source, $id_composition){
$sgbd = $this->sgbd();
try{
$sql =
.")";
$sgbd->query($sql);
}
- catch(Exception $e) { return false; }
+ catch(Exception $e){
+ return false;
+ }
return $this->set_source_xml($id_composition);
}
- function del_source_compositions($params){
+ public function del_source_compositions($params){
$res = true;
$id_source = isset($params["id_source"]) ? $params["id_source"] : null;
$id_composition = isset($params["id_composition"]) ? $params["id_composition"] : null;
while($v_rst = $sgbd->fetch_assoc($rst)) $to_update[] = $v_rst["id_composition"];
$sgbd->free_result($rst);
}
- catch(Exception $e) { return false; }
+ catch(Exception $e){
+ return false;
+ }
}
try{
$sql = "DELETE FROM #--sml_source_compositions";
$sql .= $WHERE;
$sgbd->query($sql);
}
- catch(Exception $e) { return false; }
+ catch(Exception $e){
+ return false;
+ }
foreach($to_update as $id_source_xml){
if(!$this->set_source_xml($id_source_xml)) return false;
}
return true;
}
- function has_sources($id_composition)
- { $sgbd = $this->sgbd();
+ public function has_sources($id_composition){
+ $sgbd = $this->sgbd();
$env = $this->env();
try{
$sql = "SELECT count(*) as n FROM #--sml_source_compositions WHERE id_composition=".$this->eq($id_composition);
if($v_rst = $sgbd->fetch_assoc($rst)) $has_sources = $v_rst["n"];
$sgbd->free_result($rst);
}
- catch(Exception $e) { return false; }
+ catch(Exception $e){
+ return false;
+ }
return $has_sources;
}
- function source_ariane($id_source, $ariane = array())
- { if(($compositions = $this->source_compositions(array("id_source" => $id_source))) !== false)
- { if(isset($compositions[$id_source]) && $compositions[$id_source])
- { foreach($compositions[$id_source] as $id_composition)
- { if(($ariane = $this->source_ariane($id_composition, $ariane)) !== false)
- { if(($ariane[$id_composition] = $this->source($id_composition)) !== false)
- {
+ public function source_ariane($id_source, $ariane = array()){
+ if(($compositions = $this->source_compositions(array("id_source" => $id_source))) !== false){
+ if(isset($compositions[$id_source]) && $compositions[$id_source]){
+ foreach($compositions[$id_source] as $id_composition){
+ if(($ariane = $this->source_ariane($id_composition, $ariane)) !== false){
+ if(($ariane[$id_composition] = $this->source($id_composition)) !== false){
}
else $ariane = false;
}
}
}
-
-?>
\ No newline at end of file
class sml_data_sources_cache_db extends mw_data{
- function source_cache_db(){
+ public function source_cache_db(){
$sgbd = $this->sgbd();
$cache = array();
try{
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{
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 =
.")";
$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
<?php
- class sml_data_authors extends mw_data
- {
+ class sml_data_authors extends mw_data{
- var $groupes;
+ public $groupes;
# ----------------------------------------------------------------------------------------
# groupes
#
- function groupes($id_user = null, $start = null, $alpha = null)
- { $sgbd = $this->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"]
: ""
);
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"]
: ""
);
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;
}
}
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,
);
}
- 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,
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
// 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";
// 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";
<?php
- class sml_data_licences extends mw_data
- {
+ class sml_data_licences extends mw_data{
- function licences($start = null)
- { $sgbd = $this->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;
}
}
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,
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
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;
}
}
}
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;
}
}
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;
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")){
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")){
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")){
// --------------------------------------------------------------------
- function sources_access(){
+ public function sources_access(){
$sgbd = $this->sgbd();
$sources_access = array();
$sgbd = $this->sgbd();
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(
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;
}
}
}
// --------------------------------------------------------------------
- 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();
}
}
-
-?>
\ No newline at end of file
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;
}
}
# 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();
// -------------------------------------------------------------------------------
// -------------------------------------------------------------------------------
// 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;
}
}
$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;
}
}
$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;
}
}
}
// -------------------------------- 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;
}
}
}
// -------------------------------- 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;
}
}
}
// -------------------------------- 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")));
}
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);
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"]
: ""
);
if($user = $env->user()){
if(($source["permissions"] = $this->source_permissions($source, $user["id"])) === false) return false;
}
- if(!$source["reference"])
- { if(($source["documents"] = $this->source_documents($source["id"])) === false) return false;
+ if(!$source["reference"]){
+ if(($source["documents"] = $this->source_documents($source["id"])) === false) return false;
}
return $source;
}
- function add_source
- ( $groupes,
+ public function add_source(
+ $groupes,
$titre,
$status,
$licence,
$reference = array(),
$derivations = array(),
$infos = array()
- )
- { $sgbd = $this->sgbd();
- $source = array
- ( "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,
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,
$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;
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;
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;
# 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;
}
}
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);
}
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;
}
}
}
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;
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"]);
}
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);
# references
#
- function source_reference($source)
- { $reference = array();
- if($source["reference"])
- { if(!is_array($source["reference"]))
- { $source["reference"] = array
- ( "url" => $source["reference"],
+ public function source_reference($source){
+ $reference = array();
+ if($source["reference"]){
+ if(!is_array($source["reference"])){
+ $source["reference"] = array(
+ "url" => $source["reference"],
"content" => "",
"use_edit_content" => false
);
}
$reference_edit_file = $this->reference_edit_xml_path($source["id"]);
- if(file_exists($reference_edit_file))
- { if(($reference_edit_content = $this->get_edit_reference_content($source["id"])) !== false)
- { if(($reference = $this->source_xml_read($source["reference"], $reference_edit_content)) !==false)
- { $reference["xml"] = array
- ( "url" => $source["reference"]["xml"]["url"],
+ if(file_exists($reference_edit_file)){
+ if(($reference_edit_content = $this->get_edit_reference_content($source["id"])) !== false){
+ if(($reference = $this->source_xml_read($source["reference"], $reference_edit_content)) !==false){
+ $reference["xml"] = array(
+ "url" => $source["reference"]["xml"]["url"],
"content" => $reference_edit_content,
"use_edit_content" => true
);
}
else return false;
}
- else
- { if(($reference = $this->source_xml_read($source["reference"]["xml"]["url"])) ===false)
- { $reference = $this->empty_source();
+ else{
+ if(($reference = $this->source_xml_read($source["reference"]["xml"]["url"])) ===false){
+ $reference = $this->empty_source();
}
}
}
# documents
#
- function source_documents($id_source)
- { $sgbd = $this->sgbd();
+ public function source_documents($id_source){
+ $sgbd = $this->sgbd();
$documents = array();
- 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);
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;
}
# 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);
}
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;
}
}
return $has_sources;
}
- function source_ariane($id_source, $ariane = array())
- { if(($compositions = $this->source_compositions(array("id_source" => $id_source))) !== false)
- { if(isset($compositions[$id_source]) && $compositions[$id_source])
- { foreach($compositions[$id_source] as $id_composition)
- { if(($ariane = $this->source_ariane($id_composition, $ariane)) !== false)
- { if(($ariane[$id_composition] = $this->source($id_composition)) !== false)
- {
+ public function source_ariane($id_source, $ariane = array()){
+ if(($compositions = $this->source_compositions(array("id_source" => $id_source))) !== false){
+ if(isset($compositions[$id_source]) && $compositions[$id_source]){
+ foreach($compositions[$id_source] as $id_composition){
+ if(($ariane = $this->source_ariane($id_composition, $ariane)) !== false){
+ if(($ariane[$id_composition] = $this->source($id_composition)) !== false){
}
else $ariane = false;
}
}
}
-
-?>
\ No newline at end of file
<?php
- class sml_data_sources_cache_db extends mw_data
- {
+ class sml_data_sources_cache_db extends mw_data{
- function source_cache_db()
- { $sgbd = $this->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;
}
}
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;
}
}
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
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();
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();
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;
}
}
-
-?>
\ No newline at end of file
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(
$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");
}
}
-
-?>
\ No newline at end of file
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"]){
}
}
- 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);
return true;
}
- function nb_invitations($env){
+ public function nb_invitations($env){
if($user = $env->user()){
$data = $env->data();
if($groupes = $data->groupes($user["id"])){
return 0;
}
- function enable($env){
+ public function enable($env){
$data = $env->data();
if(
($data->config("site_name") == "mtweb")
return true;
}
- function install($env){
+ public function install($env){
$data = $env->data();
$res = true;
if(
return $res;
}
- function uninstall($env){
+ public function uninstall($env){
$data = $env->data();
$res = true;
if(