[ Index ]
 

Code source de SPIP 1.9.2c

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/ecrire/inc/ -> import_0_0.php (source)

   1  <?php
   2  
   3  /***************************************************************************\
   4   *  SPIP, Systeme de publication pour l'internet                           *
   5   *                                                                         *
   6   *  Copyright (c) 2001-2007                                                *
   7   *  Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James  *
   8   *                                                                         *
   9   *  Ce programme est un logiciel libre distribue sous licence GNU/GPL.     *
  10   *  Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne.   *
  11  \***************************************************************************/
  12  
  13  if (!defined("_ECRIRE_INC_VERSION")) return;
  14  
  15  // pour le support des vieux dump
  16  // pff ou vous l'avez trouve ce dump ?
  17  // http://doc.spip.org/@inc_import_0_0_dist
  18  function inc_import_0_0_dist($f, $request, $gz='fread') {
  19      global $import_ok;
  20  
  21      // detruire les tables a restaurer
  22      $init = $request['init'];
  23      $tables = $init($request);
  24  
  25      $import_ok = false;
  26      $b = false;
  27      if (!($type = xml_fetch_tag($f, $b, $gz))) return false;
  28      if ($type == '/SPIP') return !($import_ok = true);
  29      $is_art = ($type == 'article');
  30      $is_mot = ($type == 'mot');
  31      for (;;) {
  32          $b = false;
  33          if (!($col = xml_fetch_tag($f, $b, $gz))) return false;
  34          if ($col == ("/$type")) break;
  35          $value = true;
  36          if (!xml_fetch_tag($f, $value, $gz)) return false;
  37          if ($is_art AND $col == 'id_auteur') {
  38              $auteurs[] = $value;
  39          }
  40          else if ($is_mot AND $col == 'id_article') {
  41              $articles[] = $value;
  42          }
  43          else if ($is_mot AND $col == 'id_breve') {
  44              $breves[] = $value;
  45          }
  46          else if ($is_mot AND $col == 'id_forum') {
  47              $forums[] = $value;
  48          }
  49          else if ($is_mot AND $col == 'id_rubrique') {
  50              $rubriques[] = $value;
  51          }
  52          else if ($is_mot AND $col == 'id_syndic') {
  53              $syndics[] = $value;
  54          }
  55          else if ($col != 'maj') {
  56              $cols[] = $col;
  57              $values[] = _q($value);
  58              if ($is_art && ($col == 'id_article')) $id_article = $value;
  59              if ($is_mot && ($col == 'id_mot')) $id_mot = $value;
  60          }
  61      }
  62  
  63      $table = "spip_$type";
  64      if ($type != 'forum' AND $type != 'syndic') $table .= 's';
  65      spip_query("REPLACE $table (" . join(",", $cols) . ") VALUES (" . join(",", $values) . ")");
  66  
  67      if ($is_art && $id_article) {
  68          spip_query("DELETE FROM spip_auteurs_articles WHERE id_article=$id_article");
  69          if ($auteurs) {
  70              reset ($auteurs);
  71              while (list(, $auteur) = each($auteurs)) {
  72                spip_abstract_insert("spip_auteurs_articles", "(id_auteur, id_article)", "($auteur, $id_article)");
  73              }
  74          }
  75      }
  76      if ($is_mot && $id_mot) {
  77          spip_query("DELETE FROM spip_mots_articles WHERE id_mot=$id_mot");
  78          spip_query("DELETE FROM spip_mots_breves WHERE id_mot=$id_mot");
  79          spip_query("DELETE FROM spip_mots_forum WHERE id_mot=$id_mot");
  80          spip_query("DELETE FROM spip_mots_rubriques WHERE id_mot=$id_mot");
  81          spip_query("DELETE FROM spip_mots_syndic WHERE id_mot=$id_mot");
  82          if ($articles) {
  83              reset ($articles);
  84              while (list(, $article) = each($articles)) {
  85  
  86                  spip_abstract_insert("spip_mots_articles", "(id_mot, id_article)", "($id_mot, $article)");
  87              }
  88          }
  89          if ($breves) {
  90              reset ($breves);
  91              while (list(, $breve) = each($breves)) {
  92  
  93                  spip_abstract_insert("spip_mots_breves", "(id_mot, id_breve)", "($id_mot, $breve)");
  94              }
  95          }
  96          if ($forums) {
  97              reset ($forums);
  98              while (list(, $forum) = each($forums)) {
  99  
 100                  spip_abstract_insert("spip_mots_forum", "(id_mot, id_forum)", "($id_mot, $forum)");
 101              }
 102          }
 103          if ($rubriques) {
 104              reset ($rubriques);
 105              while (list(, $rubrique) = each($rubriques)) {
 106  
 107                  spip_abstract_insert("spip_mots_rubriques", "(id_mot, id_rubrique)", "($id_mot, $id_rubrique)");
 108              }
 109          }
 110          if ($syndics) {
 111              reset ($syndics);
 112              while (list(, $syndic) = each($syndics)) {
 113  
 114                  spip_abstract_insert("spip_mots_syndic", "(id_mot, id_syndic)", "($id_mot, $syndic)");
 115              }
 116          }
 117      }
 118  
 119      return $import_ok = "      ";
 120  }
 121  ?>


Généré le : Wed Nov 21 10:20:27 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics