diff --git a/ecrire/base/upgrade.php b/ecrire/base/upgrade.php index d25e8cb663c023eda0e77d2847fec533b156ab51..351a3555e472ac028132a05e5d0f20e67b7253e5 100644 --- a/ecrire/base/upgrade.php +++ b/ecrire/base/upgrade.php @@ -48,16 +48,17 @@ function maj_base($version_cible = 0) { // Si pas de version mentionnee dans spip_meta, c'est qu'il s'agit // d'une nouvelle installation // => ne pas passer par le processus de mise a jour + // De meme en cas de version superieure: ca devait etre un test, + // il y a eu le message d'avertissement il doit savoir ce qu'il fa // // $version_installee = 1.702; quand on a besoin de forcer une MAJ - if (!$version_installee) { + if (!$version_installee OR ($spip_version < $version_installee)) { spip_query_db("REPLACE spip_meta (nom, valeur,impt) VALUES ('version_installee', '$spip_version','non')"); return true; } - // // Verification des droits de modification sur la base // @@ -1330,6 +1331,14 @@ function maj_base($version_cible = 0) { maj_version('1.933'); } + // Retrait de _DIR_IMG dans le champ fichier de la table des doc + if (upgrade_vers(1.934, $version_installee, $version_cible)) { + $dir_img = substr(_DIR_IMG,strlen(_DIR_RACINE)); + $n = strlen($dir_img) + 1; + spip_query("UPDATE spip_documents SET fichier=substr(fichier,$n) WHERE fichier LIKE " . _q($dir_img . '%')); + maj_version('1.934'); + } + } ?> diff --git a/ecrire/inc/import_1_3.php b/ecrire/inc/import_1_3.php index e6fcff7b9f3604f0f129de7fbf96e56202925b79..92a167e36b84897e51718aa7da38c6e8def05638 100644 --- a/ecrire/inc/import_1_3.php +++ b/ecrire/inc/import_1_3.php @@ -64,7 +64,8 @@ function inc_import_1_3_dist($lecteur, $request, $gz='fread', $atts=array()) { $desc['field'], $gz, $phpmyadmin, - '/' . $table); + '/' . $table, + $atts); if ($values === false) return ($import_ok = false); @@ -152,10 +153,18 @@ function import_replace($values, $table, $desc, $request, $atts='') { } // http://doc.spip.org/@import_lire_champs -function import_lire_champs($f, $fields, $gz, $phpmyadmin, $table) +function import_lire_champs($f, $fields, $gz, $phpmyadmin, $table, $atts) { $values = array(); - + $dir_img = 0; + + + if (($atts['version_base'] < '1.934') + AND $table == '/spip_documents') { + + $dir_img = '@^'. preg_quote (isset($atts['dir_img']) ? $atts['dir_img']:'IMG/') . '@'; + } + if (!isset($GLOBALS['meta']['charset_insertion'])) $charset = ''; else { @@ -163,7 +172,6 @@ function import_lire_champs($f, $fields, $gz, $phpmyadmin, $table) if ($charset == $GLOBALS['meta']['charset']) $charset = ''; } - for (;;) { $b = false; if (!($col = xml_fetch_tag($f, $b, $gz))) return false; @@ -179,6 +187,9 @@ function import_lire_champs($f, $fields, $gz, $phpmyadmin, $table) if ($b) { if ($phpmyadmin) $value = str_replace($phpmyadmin[0],$phpmyadmin[1],$value); + elseif ($dir_img) { + $value = preg_replace($dir_img, '', $value); + } if ($charset) $value = importer_charset($value, $charset); $values[$col]= $value; diff --git a/ecrire/inc/utils.php b/ecrire/inc/utils.php index 3dd3faa79667341bbb1a93896c9de96c171459fb..758eb6ed34b06486228ead17fab1e2992138858b 100644 --- a/ecrire/inc/utils.php +++ b/ecrire/inc/utils.php @@ -236,12 +236,12 @@ function _q($a) { } // http://doc.spip.org/@set_spip_doc -function set_spip_doc($fichier) {return $fichier;} +//function set_spip_doc($fichier) {return $fichier;} // http://doc.spip.org/@get_spip_doc -function get_spip_doc($fichier) {return _DIR_RACINE . $fichier;} +//function get_spip_doc($fichier) {return _DIR_RACINE . $fichier;} // pour bientot: -//function set_spip_doc($fichier) {return substr($fichier, strlen(_DIR_IMG));} -//function get_spip_doc($fichier) {return _DIR_IMG . $fichier;} +function set_spip_doc($fichier) {return substr($fichier, strlen(_DIR_IMG));} +function get_spip_doc($fichier) {return _DIR_IMG . $fichier;} // Renvoie le _GET ou le _POST emis par l'utilisateur // ou pioche dans $c si c'est un array() diff --git a/ecrire/inc_version.php b/ecrire/inc_version.php index 4e14005c66a7d33fd1bad24fb212d685918d01a4..56dddc7091d17aef562a210bc4da2cf7da76e578 100644 --- a/ecrire/inc_version.php +++ b/ecrire/inc_version.php @@ -285,7 +285,7 @@ $tables_des_serveurs_sql['localhost'] = &$tables_principales; // (utilise pour les modifs de la base de donnees) // version de la base -$spip_version = 1.933; +$spip_version = 1.934; // version de spip en chaine // et en numerique a incrementer sur les evolutions qui cassent la compatibilite descendante