Changeset 95885 in spip-zone
- Timestamp:
- Mar 9, 2016, 5:36:47 PM (5 years ago)
- Location:
- _plugins_/convertisseur/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
_plugins_/convertisseur/trunk/inc/convertisseur.php
r95854 r95885 525 525 } 526 526 527 // Champs d'un article 528 include_spip("base/abstract_sql"); 529 $show = sql_showtable("spip_articles"); 530 $champs_article = array_keys($show['field']); 531 527 532 // Si $f (chargement zip), on cherche un article du meme $f 528 // (valeur stockée dans le PS)533 // (valeur stockée dans un champ fichier_source ou à défaut dans le PS) 529 534 // dans la meme rubrique, 530 535 // avec le statut prepa, qui nous appartient, et... on l'ecrase 531 $ps = 'Conversion depuis '.basename($f); 536 537 $source = 'Conversion depuis '.basename($f) ; 538 $champ_source = (in_array("fichier_source", $champs_article)) ? "fichier_source" : "ps" ; 532 539 533 540 // spip 3 … … 537 544 spip_auteurs_liens AS aut 538 545 WHERE id_rubrique=$id_rubrique 539 AND ps=".sql_quote($ps)."546 AND $champ_source=".sql_quote($source)." 540 547 AND aut.id_objet=a.id_article 541 548 AND aut.objet = 'article' … … 548 555 spip_auteurs_articles AS aut 549 556 WHERE id_rubrique=$id_rubrique 550 AND ps=".sql_quote($ps)."557 AND $champ_source=".sql_quote($source)." 551 558 AND aut.id_article=a.id_article 552 559 AND aut.id_auteur=".$id_auteur … … 562 569 563 570 $champs = array( 564 'titre' => $ ps,571 'titre' => $source, 565 572 'statut' => 'prepa', 566 573 'id_rubrique' => $id_rubrique, 567 574 'id_secteur' => $q['id_secteur'], 568 575 'lang' => $q['lang'], 569 'ps' => $ps576 $champ_source => $source 570 577 ); 571 578 … … 628 635 $c = array('texte' => $texte); 629 636 630 // Champs d'un article 631 include_spip("base/abstract_sql"); 632 $show = sql_showtable("spip_articles"); 633 $champs = array_keys($show['field']); 634 foreach ($champs as $champ) { 637 foreach ($champs_article as $champ) { 635 638 if (preg_match(",<ins class='$champ'>(.*?)</ins>\n*,ims", $texte, $r) 636 639 AND strlen($x = trim($r[1])) 637 640 AND $champ != "texte" 638 AND $champ != "ps") { 639 $c[$champ] = $x; 641 ) { 642 if($champ != $champ_source) 643 $c[$champ] = $x; 640 644 $c['texte'] = substr_replace($c['texte'], '', strpos($c['texte'], $r[0]), strlen($r[0])); 641 645 } … … 653 657 if (preg_match_all(",<ins[^>]+class='(.*?)'>(.*?)</ins>,ims", $c['texte'], $z, PREG_SET_ORDER)){ 654 658 foreach($z as $d){ 655 if(!in_array("metadonnees", $champs )){659 if(!in_array("metadonnees", $champs_articles)){ 656 660 $c['texte'] = "@@" . strtoupper($d[1]) . "\n" . $d[2] . "\n\n" . $c['texte'] ; 657 661 $c['texte'] = substr_replace($c['texte'], '', strpos($c['texte'], $d[0]), strlen($d[0])); -
_plugins_/convertisseur/trunk/spip-cli/fichiersImporter.php
r95880 r95885 110 110 sql_query("alter table spip_articles add id_source BIGINT(21) NOT NULL DEFAULT ''"); 111 111 112 // Ajout d'un champ la premiere fois pour stocker le nom du fichier source, pour reconnaitre un article déjà importé. 113 if(!in_array('fichier_source', $champs)) 114 sql_query("alter table spip_articles add fichier_source MEDIUMTEXT NOT NULL DEFAULT ''"); 115 112 116 $fichiers = preg_files($source . "/", "(?:(?<!\.metadata\.)txt$)", 100000); 113 117 … … 199 203 200 204 if($id_article = inserer_conversion($texte, $id_rubrique, $f)){ 205 // id d'importation 206 sql_update("spip_articles", array("fichier_source" => sql_quote($fichier)), "id_article=$id_article"); 201 207 202 208 // Créer l'auteur ?
Note: See TracChangeset
for help on using the changeset viewer.