Index: trunk/spip/esqueleto-redcta/plugins/magusine/base/arty_init.php
===================================================================
--- trunk/spip/esqueleto-redcta/plugins/magusine/base/arty_init.php	(revision 80)
+++ trunk/spip/esqueleto-redcta/plugins/magusine/base/arty_init.php	(revision 80)
@@ -0,0 +1,60 @@
+<?php
+
+function arty_install($action){
+ switch ($action)
+ {  // La base est deja cree ?
+    case 'test':
+       // Verifier que le champ id_mon_plugin est present...
+       include_spip('base/abstract_sql');
+       $desc = spip_abstract_showtable("spip_arty_themeassoc", '', true);
+       return (isset($desc['field']['id']));
+       break;
+     // Installer la base
+     case 'install':
+       include_spip('base/create');  // definir la fonction
+       include_spip('base/tables_magusine'); // definir sa structure
+       creer_base();
+       // entre les gabarits dans la db
+       demarre_magusine();
+       break;
+     // Supprimer la base
+     case 'uninstall':
+     // liste des tables Ã  supprimer
+       spip_query("DROP TABLE spip_arty_themeassoc");
+       break;
+  }
+}
+
+function demarre_magusine() {
+include_spip('inc/xml-parser');
+
+  $resultat=spip_query("SELECT * FROM spip_arty_themeassoc WHERE type='rubrique' AND id = 0");
+  if(!spip_num_rows($resultat)) {
+  	spip_query("INSERT INTO spip_arty_themeassoc (theme, id, type) VALUES ('emilio', 0, 'rubrique')");
+  }
+  
+	$gabarits=array();
+	$ignore_liste=array(".","..",".DS_Store");
+	$rep = _DIR_PLUGIN_ARTY."definitions-gabarits";
+	$handle = opendir($rep);
+	while($fichier = readdir($handle)) {
+      if (!in_array($fichier, $ignore_liste) && eregi('^[a-zA-Z0-9_-]*\.xml$',$fichier)) {
+      
+        $p =& new xmlParser();
+		$p->parse(_DIR_PLUGIN_ARTY.'definitions-gabarits/'.$fichier);
+ 
+		 foreach($p->output[0]['child'] as $ordre => $bloc) {
+		 	
+		 $resultat = spip_query("SELECT * FROM spip_arty_gabarit_ordre WHERE nom='".$bloc['content']."' AND gabarit='".addslashes(ereg_replace("\.xml$", "", $fichier))."'");
+		 	
+		 	if (!spip_num_rows($resultat)) {
+		 		spip_query("INSERT INTO spip_arty_gabarit_ordre (nom, ordre, conteneur ,gabarit, param) VALUES ('".$bloc['content']."', $ordre, ".addslashes($bloc['attrs']['STATUT'])." , '".addslashes(ereg_replace("\.xml$", "", $fichier))."', '".addslashes($bloc['attrs']['PARAMDEFAUT'])."')");
+		 	}
+		 }
+ 		}
+} 
+}
+
+
+?>
+
Index: trunk/spip/esqueleto-redcta/plugins/magusine/base/tables_magusine.php
===================================================================
--- trunk/spip/esqueleto-redcta/plugins/magusine/base/tables_magusine.php	(revision 80)
+++ trunk/spip/esqueleto-redcta/plugins/magusine/base/tables_magusine.php	(revision 80)
@@ -0,0 +1,157 @@
+<?php
+//include_spip('base/serial'); // pour eviter une reinit posterieure des tables modifiees
+
+global $tables_principales;
+global $tables_auxiliaires;
+
+// dÃ©claration de toutes les tables
+
+// bloclibre
+$spip_arty_bloclibre = array(
+  "id_bloc_libre"  => "bigint(21) NOT NULL AUTO_INCREMENT",
+  "titre" => "VARCHAR(255) NOT NULL",
+  "contenu" => "TEXT",
+  "lien" => "VARCHAR(255) NOT NULL",
+);
+					
+$spip_arty_bloclibre_key = array(
+  "PRIMARY KEY" => "id_bloc_libre"
+);
+
+$tables_principales['spip_arty_bloclibre'] = array('field' => &$spip_arty_bloclibre, 'key' => &$spip_arty_bloclibre_key);
+
+// bloclibreassoc
+$spip_arty_bloclibreassoc = array(
+  "id_assoc"  => "bigint(21) NOT NULL AUTO_INCREMENT",
+  "type" => "VARCHAR(255) NOT NULL",
+  "id_bloc_libre" => "bigint(21)",
+  "id" => "bigint(21)",
+  "lang" => "VARCHAR(32)",
+);
+					
+$spip_arty_bloclibreassoc_key = array(
+  "PRIMARY KEY" => "id_assoc"
+);
+
+$tables_principales['spip_arty_bloclibreassoc'] = array('field' => &$spip_arty_bloclibreassoc, 'key' => &$spip_arty_bloclibreassoc_key);
+
+// gabarit_ordre
+$spip_arty_gabarit_ordre = array(
+  "id_bloc"  => "bigint(21) NOT NULL AUTO_INCREMENT",
+  "nom" => "VARCHAR(255) NOT NULL",
+  "ordre" => "bigint(21)",
+  "conteneur" => "bigint(21)",  
+  "gabarit" => "VARCHAR(255) NOT NULL",
+  "param" => "TEXT NOT NULL",
+);
+					
+$spip_arty_gabarit_ordre_key = array(
+  "PRIMARY KEY" => "id_bloc"
+);
+
+$tables_principales['spip_arty_gabarit_ordre'] = array('field' => &$spip_arty_gabarit_ordre, 'key' => &$spip_arty_gabarit_ordre_key);
+
+// gabarit perso
+$spip_arty_gabarit_perso = array(
+  "id"      => "bigint(21) NOT NULL AUTO_INCREMENT",
+  "nom"     => "VARCHAR(255)",
+  "type"    => "VARCHAR(255)",
+  "donnees" => "TEXT",
+);
+					
+$spip_arty_gabarit_perso_key = array(
+  "PRIMARY KEY" => "id"
+);
+
+$tables_principales['spip_arty_gabarit_perso'] = array('field' => &$spip_arty_gabarit_perso, 'key' => &$spip_arty_gabarit_perso_key);
+
+// gabarit assoc
+$spip_arty_gabaritassoc = array(
+  "id_assoc"  => "bigint(21) NOT NULL AUTO_INCREMENT",
+  "gabarit" => "VARCHAR(255) NOT NULL",
+  "id" => "bigint(21)",
+  "type" => "VARCHAR(255)",
+);
+					
+$spip_arty_gabaritassoc_key = array(
+  "PRIMARY KEY" => "id_assoc"
+);
+
+$tables_principales['spip_arty_gabaritassoc'] = array('field' => &$spip_arty_gabaritassoc, 'key' => &$spip_arty_gabaritassoc_key);
+
+// menu
+$spip_arty_menu = array(
+  "id_menu"  => "bigint(21) NOT NULL AUTO_INCREMENT",
+  "ordre" => "bigint(21)",
+  "type" => "VARCHAR(255) NOT NULL",
+  "id" => "bigint(21)",
+  "langue" => "VARCHAR(255)",
+  "id_parent" => "bigint(21)",
+  "type_parent" => "VARCHAR(255)",
+  "nom" => "VARCHAR(255)",
+  "url" => "TEXT",
+);
+					
+$spip_arty_menu_key = array(
+  "PRIMARY KEY" => "id_menu"
+);
+
+$tables_principales['spip_arty_menu'] = array('field' => &$spip_arty_menu, 'key' => &$spip_arty_menu_key);
+
+// paramassoc
+$spip_arty_paramassoc = array(
+  "id_assoc"  => "bigint(21) NOT NULL AUTO_INCREMENT",
+  "param" => "VARCHAR(255) NOT NULL",
+  "id_article" => "bigint(21)",
+  "id_rubrique" => "bigint(21)",
+);
+					
+$spip_arty_paramassoc_key = array(
+  "PRIMARY KEY" => "id_assoc"
+);
+
+$tables_principales['spip_arty_paramassoc'] = array('field' => &$spip_arty_paramassoc, 'key' => &$spip_arty_paramassoc_key);
+
+// parametres
+$spip_arty_parametres = array(
+  "id_parametre"  => "bigint(21) NOT NULL AUTO_INCREMENT",
+  "parametre" => "VARCHAR(255) UNIQUE NOT NULL",
+  "valeur" => "TEXT",
+  "valeur2" => "TEXT",
+  "valeur3" => "TEXT"
+);
+					
+$spip_arty_parametres_key = array(
+  "PRIMARY KEY" => "id_parametre"
+);
+
+$tables_principales['spip_arty_parametres'] = array('field' => &$spip_arty_parametres, 'key' => &$spip_arty_parametres_key);
+
+// themeassoc
+$spip_arty_themeassoc = array(
+  "id_assoc"  => "bigint(21) NOT NULL AUTO_INCREMENT",
+  "theme" => "VARCHAR(255) NOT NULL",
+  "id" => "bigint(21)",
+  "type" => "VARCHAR(255) NOT NULL"
+);
+					
+$spip_arty_themeassoc_key = array(
+  "PRIMARY KEY" => "id_assoc"
+);
+
+$tables_principales['spip_arty_themeassoc'] = array('field' => &$spip_arty_themeassoc, 'key' => &$spip_arty_themeassoc_key);
+
+        
+    // association aux tables spip    
+    global $table_des_tables;
+    $table_des_tables['arty_bloclibre'] = 'arty_bloclibre';
+    $table_des_tables['arty_bloclibreassoc'] = 'arty_bloclibreassoc';
+    $table_des_tables['arty_gabarit_ordre'] = 'arty_gabarit_ordre';
+    $table_des_tables['arty_gabarit_perso'] = 'arty_gabarit_perso';
+    $table_des_tables['arty_gabaritassoc'] = 'arty_gabaritassoc';
+    $table_des_tables['arty_menu'] = 'arty_menu';
+    $table_des_tables['arty_paramassoc'] = 'arty_paramassoc';
+    $table_des_tables['arty_parametres'] = 'arty_parametres';
+    $table_des_tables['arty_themeassoc'] = 'arty_themeassoc';
+
+?>
