From: root Date: Sun, 20 Oct 2013 17:22:21 +0000 (+0200) Subject: fonctionne avec SQLite + ajustements template X-Git-Tag: sourceml.0.16.4 X-Git-Url: http://git.dj3c1t.com/?p=mw_sourceml;a=commitdiff_plain;h=ce50b139cfeb948f0a773ccd7bd7d6a800b06692 fonctionne avec SQLite + ajustements template --- diff --git a/app/observers/mw_observer_sourceml.php b/app/observers/mw_observer_sourceml.php index 23cbef8..f8d8fe3 100644 --- a/app/observers/mw_observer_sourceml.php +++ b/app/observers/mw_observer_sourceml.php @@ -7,7 +7,7 @@ $out_config = $env->get_out_config(); $out_config["groupe_view_albums"] = array( "type" => "checkbox", - "default" => 0, + "default" => 1, "text" => "Lister les albums sur la page d'un groupe" ); $out_config["colonne_logo_groupe"] = array( @@ -17,12 +17,12 @@ ); $out_config["albums_menu"] = array( "type" => "checkbox", - "default" => 1, + "default" => 0, "text" => "Afficher les albums du groupe courant dans la colonne" ); $out_config["nom_groupe"] = array( "type" => "checkbox", - "default" => 1, + "default" => 0, "text" => "Afficher le nom du groupe courant dans la colonne" ); $env->set_out_config($out_config); diff --git a/app/out/default/css/actions/sources.css b/app/out/default/css/actions/sources.css index f88d294..aea7e08 100644 --- a/app/out/default/css/actions/sources.css +++ b/app/out/default/css/actions/sources.css @@ -130,8 +130,8 @@ p#play_all a #colonne .logo_groupe{ text-align: center; height: auto; - width: 220px; - padding: 0 10px 10px 10px; + width: auto; + padding: 0 0 10px 0; } #colonne .logo_groupe a{ diff --git a/app/out/default/views/users/morceaux/edit.php b/app/out/default/views/users/morceaux/edit.php index 153f694..5b71aba 100644 --- a/app/out/default/views/users/morceaux/edit.php +++ b/app/out/default/views/users/morceaux/edit.php @@ -21,6 +21,7 @@ var is_reference = out["morceau"]["reference"] ? "true" : "fal out["groupes"]["total"] > 0) : ?> diff --git a/app/out/default/views/users/pistes/edit.php b/app/out/default/views/users/pistes/edit.php index 52c2249..756c1fe 100644 --- a/app/out/default/views/users/pistes/edit.php +++ b/app/out/default/views/users/pistes/edit.php @@ -21,6 +21,7 @@ var is_reference = out["piste"]["reference"] ? "true" : "false out["groupes"]["total"] > 0) : ?> diff --git a/mw_sourceml.php b/mw_sourceml.php index 731639f..47c3d4e 100644 --- a/mw_sourceml.php +++ b/mw_sourceml.php @@ -21,7 +21,10 @@ $env->set_link("users/albums", $env->url("users/albums"), "Albums", 31); $env->set_link("users/morceaux", $env->url("users/morceaux"), "Morceaux", 32); $env->set_link("users/pistes", $env->url("users/pistes"), "Sources", 33); - $env->set_link("users/sources_invitations", $env->url("users/sources_invitations"), "Invitations", 34); + + $invitations_title = "Invitations"; + if($nb_invitations = $this->nb_invitations($env)) $invitations_title .= " (".$nb_invitations.")"; + $env->set_link("users/sources_invitations", $env->url("users/sources_invitations"), $invitations_title, 34); $env->set_link("menu_top/groupes", $env->url("sources/groupe"), "Groupes", 10); $env->set_link("menu_top/albums", $env->url("sources/album"), "Albums", 11); @@ -48,7 +51,10 @@ $env->bdd("sgbd") == "mysql" || $env->bdd("sgbd") == "pdo_mysql" ) return $this->install_mysql($env); - return false; + elseif( + $env->bdd("sgbd") == "pdo_sqlite" + ) return $this->install_sqlite($env); + return "Mode de stockage pour Mtweb (".$env->bdd("sgbd").") non supporté par SourceML"; } function install_mysql($env){ @@ -255,6 +261,234 @@ return true; } + function install_sqlite($env){ + $data = $env->data(); + $sgbd = $data->sgbd(); + try{ + $EXISTS = + $sgbd->table_exists("#--sml_authors") + || $sgbd->table_exists("#--sml_classes") + || $sgbd->table_exists("#--sml_licences") + || $sgbd->table_exists("#--sml_sources") + || $sgbd->table_exists("#--sml_sources_access") + || $sgbd->table_exists("#--sml_sources_authors") + || $sgbd->table_exists("#--sml_sources_infos") + || $sgbd->table_exists("#--sml_source_cache") + || $sgbd->table_exists("#--sml_source_compositions") + || $sgbd->table_exists("#--sml_source_derivations") + || $sgbd->table_exists("#--sml_source_documents") + || $sgbd->table_exists("#--sml_sources_invitations"); + } + catch(Exception $e){ + return "impossible de savoir si les tables existent deja"; + } + if($EXISTS){ + return "des tables existent deja en base. installation annulee"; + } + try{ + + $sql = + "CREATE TABLE #--sml_authors(" + ." `id` INTEGER PRIMARY KEY AUTOINCREMENT," + ." `id_user` INTEGER NOT NULL," + ." `nom` TEXT NOT NULL," + ." `image` TEXT DEFAULT NULL," + ." `description` TEXT," + ." `email` TEXT NOT NULL," + ." `contact_form` INTEGER NOT NULL," + ." `captcha` INTEGER NOT NULL" + .")"; + $sgbd->query($sql); + + $sql = + "CREATE TABLE #--sml_classes(" + ." `id` INTEGER PRIMARY KEY AUTOINCREMENT," + ." `nom` TEXT NOT NULL" + .")"; + $sgbd->query($sql); + + $sql = + "CREATE TABLE #--sml_licences(" + ." `id` INTEGER PRIMARY KEY AUTOINCREMENT," + ." `nom` TEXT NOT NULL," + ." `url` TEXT NOT NULL" + .")"; + $sgbd->query($sql); + + $sql = + "CREATE TABLE #--sml_sources(" + ." `id` INTEGER PRIMARY KEY AUTOINCREMENT," + ." `id_class` INTEGER NOT NULL," + ." `reference` TEXT DEFAULT NULL," + ." `titre` TEXT DEFAULT NULL," + ." `licence` INTEGER DEFAULT NULL," + ." `date_creation` TEXT DEFAULT NULL," + ." `date_inscription` TEXT NOT NULL" + .")"; + $sgbd->query($sql); + + $sql = + "CREATE TABLE #--sml_sources_access(" + ." `id` INTEGER PRIMARY KEY AUTOINCREMENT," + ." `nom` TEXT NOT NULL," + ." `intitule` TEXT NOT NULL" + .")"; + $sgbd->query($sql); + + $sql = + "CREATE TABLE #--sml_sources_authors(" + ." `id` INTEGER PRIMARY KEY AUTOINCREMENT," + ." `id_source` INTEGER NOT NULL," + ." `id_author` INTEGER NOT NULL," + ." `id_sources_access` INTEGER NOT NULL" + .")"; + $sgbd->query($sql); + + $sql = + "CREATE TABLE #--sml_sources_infos(" + ." `id` INTEGER PRIMARY KEY AUTOINCREMENT," + ." `id_source` INTEGER NOT NULL," + ." `key` TEXT NOT NULL," + ." `value` TEXT NOT NULL" + .")"; + $sgbd->query($sql); + + $sql = + "CREATE TABLE #--sml_source_cache(" + ." `id` INTEGER PRIMARY KEY AUTOINCREMENT," + ." `url` TEXT NOT NULL," + ." `id_source` INTEGER NOT NULL," + ." `last_update` TEXT NOT NULL" + .")"; + $sgbd->query($sql); + + $sql = + "CREATE TABLE #--sml_source_compositions(" + ." `id` INTEGER PRIMARY KEY AUTOINCREMENT," + ." `id_source` INTEGER NOT NULL," + ." `id_composition` INTEGER NOT NULL" + .")"; + $sgbd->query($sql); + + $sql = + "CREATE TABLE #--sml_source_derivations(" + ." `id` INTEGER PRIMARY KEY AUTOINCREMENT," + ." `id_source` INTEGER NOT NULL," + ." `derivation` TEXT NOT NULL" + .")"; + $sgbd->query($sql); + + $sql = + "CREATE TABLE #--sml_source_documents(" + ." `id` INTEGER PRIMARY KEY AUTOINCREMENT," + ." `id_source` INTEGER NOT NULL," + ." `nom` TEXT NOT NULL," + ." `url` TEXT NOT NULL" + .")"; + $sgbd->query($sql); + + $sql = + "CREATE TABLE #--sml_sources_invitations(" + ." `id` INTEGER PRIMARY KEY AUTOINCREMENT," + ." `id_user` INTEGER NOT NULL," + ." `id_source` INTEGER NOT NULL," + ." `id_author` INTEGER NOT NULL," + ." `id_sources_access` INTEGER NOT NULL," + ." `date_invitation` TEXT NOT NULL" + .")"; + $sgbd->query($sql); + + } + catch(Exception $e){ + return "imposible de creer les tables en base"; + } + try{ + $sql = + "INSERT INTO #--sml_licences(`id`, `nom`, `url`)" + ." VALUES(1, 'Creative commons by-sa 2.0', 'http://creativecommons.org/licenses/by-sa/2.0/deed.fr')"; + $sgbd->query($sql); + + $sql = + "INSERT INTO #--sml_licences(`id`, `nom`, `url`)" + ." VALUES (2, 'Creative Commons by-nc-nd 2.5', 'http://creativecommons.org/licenses/by-nc-nd/2.5/')"; + $sgbd->query($sql); + + $sql = + "INSERT INTO #--sml_licences(`id`, `nom`, `url`)" + ." VALUES (3, 'Creative Commons by-nc-sa 2.5', 'http://creativecommons.org/licenses/by-nc-sa/2.5/')"; + $sgbd->query($sql); + + $sql = + "INSERT INTO #--sml_licences(`id`, `nom`, `url`)" + ." VALUES (4, 'Creative Commons by-nc 2.5', 'http://creativecommons.org/licenses/by-nc/2.5/')"; + $sgbd->query($sql); + + $sql = + "INSERT INTO #--sml_licences(`id`, `nom`, `url`)" + ." VALUES (5, 'Creative Commons by-nd 2.5', 'http://creativecommons.org/licenses/by-nd/2.5/')"; + $sgbd->query($sql); + + $sql = + "INSERT INTO #--sml_licences(`id`, `nom`, `url`)" + ." VALUES (6, 'Creative Commons by-sa 2.5', 'http://creativecommons.org/licenses/by-sa/2.5/')"; + $sgbd->query($sql); + + $sql = + "INSERT INTO #--sml_licences(`id`, `nom`, `url`)" + ." VALUES (7, 'Creative Commons by 2.5', 'http://creativecommons.org/licenses/by/2.5/')"; + $sgbd->query($sql); + + $sql = + "INSERT INTO #--sml_licences(`id`, `nom`, `url`)" + ." VALUES (8, 'Licence Art Libre', 'http://artlibre.org/licence/lal/')"; + $sgbd->query($sql); + + $sql = + "INSERT INTO #--sml_licences(`id`, `nom`, `url`)" + ." VALUES (9, 'Licence C Reaction', 'http://morne.free.fr/Necktar7/creactionfr.htm')"; + $sgbd->query($sql); + + $sql = + "INSERT INTO #--sml_licences(`id`, `nom`, `url`)" + ." VALUES (10, 'Yellow OpenMusic License', 'http://openmusic.linuxtag.org/yellow.html')"; + $sgbd->query($sql); + + $sql = + "INSERT INTO #--sml_licences(`id`, `nom`, `url`)" + ." VALUES (11, 'Green OpenMusic License', 'http://openmusic.linuxtag.org/green.html')"; + $sgbd->query($sql); + + $sql = + "INSERT INTO `#--sml_classes` (`id`, `nom`) VALUES (1, 'album')"; + $sgbd->query($sql); + + $sql = + "INSERT INTO `#--sml_classes` (`id`, `nom`) VALUES (2, 'morceau')"; + $sgbd->query($sql); + + $sql = + "INSERT INTO `#--sml_classes` (`id`, `nom`) VALUES (3, 'piste')"; + $sgbd->query($sql); + + $sql = + "INSERT INTO `mw_sml_sources_access` (`id`, `nom`, `intitule`) VALUES (1, 'admin', 'administrateur')"; + $sgbd->query($sql); + + $sql = + "INSERT INTO `mw_sml_sources_access` (`id`, `nom`, `intitule`) VALUES (2, 'editeur', 'éditeur')"; + $sgbd->query($sql); + + $sql = + "INSERT INTO `mw_sml_sources_access` (`id`, `nom`, `intitule`) VALUES (3, 'contributeur', 'contributeur')"; + $sgbd->query($sql); + + } + catch(Exception $e){ + return "les tables ont ete ajoutees en base mais impossible d'y enregistrer les valeurs par defaut."; + } + return true; + } + // --------------------------------------------------------------------------------- // uninstall // @@ -263,11 +497,12 @@ if( $env->bdd("sgbd") == "mysql" || $env->bdd("sgbd") == "pdo_mysql" - ) return $this->uninstall_mysql($env); - return false; + || $env->bdd("sgbd") == "pdo_sqlite" + ) return $this->uninstall_sql($env); + return "Mode de stockage pour Mtweb (".$env->bdd("sgbd").") non supporté par SourceML"; } - function uninstall_mysql($env){ + function uninstall_sql($env){ $data = $env->data(); $sgbd = $data->sgbd(); if(!$this->disable($env)) return "impossible de desactiver le plugin"; @@ -346,6 +581,37 @@ return true; } + // --------------------------------------------------------------------------------- + // fonctions internes + // + + function nb_invitations($env){ + if($user = $env->user()){ + $data = $env->data(); + if($groupes = $data->groupes($user["id"])){ + $groupes_in = ""; + foreach($groupes["list"] as $id_groupe => $groupe) $groupes_in .= ($groupes_in ? "," : "").$id_groupe; + if($groupes_in){ + if( + ( + $invitations = $data->list_sml_sources_invitations( + array( + "index_name" => "id", + "where"=> "id_author IN(".$groupes_in.") OR id_user=".$user["id"], + "order_by" => "date_invitation", + "order" => "DESC" + ) + ) + ) !== false + ){ + return $invitations["total"]; + } + } + } + } + return 0; + } + } ?> \ No newline at end of file