X-Git-Url: http://git.cyclocoop.org/?p=velocampus%2Fweb%2Fwww.git;a=blobdiff_plain;f=www%2Fecrire%2Finc%2Fimport_1_2.php;fp=www%2Fecrire%2Finc%2Fimport_1_2.php;h=53752ec0e7aee21792146c38fac33fd356221a0b;hp=0000000000000000000000000000000000000000;hb=80b4d3e85f78d402ed2e73f8f5d1bf4c19962eed;hpb=aaf970bf4cdaf76689ecc10609048e18d073820c diff --git a/www/ecrire/inc/import_1_2.php b/www/ecrire/inc/import_1_2.php new file mode 100644 index 0000000..53752ec --- /dev/null +++ b/www/ecrire/inc/import_1_2.php @@ -0,0 +1,142 @@ + 'spip_articles', + 'auteur' => 'spip_auteurs', + 'breve' => 'spip_breves', + 'document' => 'spip_documents', + 'forum' => 'spip_forum', + 'groupe_mots' => 'spip_groupes_mots', + 'message' => 'spip_messages', + 'mot' => 'spip_mots', + 'petition' => 'spip_petitions', + 'rubrique' => 'spip_rubriques', + 'signature' => 'spip_signatures', + 'syndic' => 'spip_syndic', + 'syndic_article' => 'spip_syndic_articles', + 'type_document' => 'spip_types_documents' + ); + } + $import_ok = false; + $b = false; + // Lire le type d'objet + if (!($type = xml_fetch_tag($f, $b, $gz))) return false; + if ($type == '/SPIP') return !($import_ok = true); + $id = "id_$type"; + $id_objet = 0; + + $table = isset($tables[$type]) ? $tables[$type] : $type; + if (in_array($table, $a_importer) AND !isset($field_desc[$table])) { + // recuperer la description de la table pour connaitre ses champs valides + $desc = description_table($table); + + if (isset($desc['field'])) + $field_desc[$table] = $desc['field']; + else + $field_desc[$table] = NULL; + } + $fields = $field_desc[$table]; + + $char = $GLOBALS['meta']['charset_insertion']; + if ($char == $GLOBALS['meta']['charset_restauration']) $char = ''; + + $values = array(); + // Lire les champs de l'objet + for (;;) { + $b = false; + if (!($col = xml_fetch_tag($f, $b, $gz))) return false; + if ($col == '/'.$type) break; + $value = true; + if (!xml_fetch_tag($f, $value, $gz)) return false; + if (substr($col, 0, 5) == 'lien:') { + $type_lien = substr($col, 5); + $liens[$type_lien][] = '('.$id_objet.','.$value.')'; + } + else if ($col != 'maj') { + // tentative de restauration d'une base sauvegardee avec le champ 'images' ; d'experience, ca arrive... + // mieux vaut accepter que canner silencieusement... + if (($type == 'article') && ($col == 'images')) + { + if ($value) { // ne pas afficher de message si on a un champ suppl mais vide + echo "-->
"._T('avis_erreur_sauvegarde', array('type' => $type, 'id_objet' => $id_objet))."\n"._T('avis_colonne_inexistante', array('col' => $col)); + if ($col == 'images') echo _T('info_verifier_image'); + echo "\n
"._T('avis_erreur_mysql')."\n".sql_error()."\n