Skip to content
Extraits de code Groupes Projets
Valider 426c88ff rédigé par esj's avatar esj
Parcourir les fichiers

les auteurs, ca s'exporte beaucoup moins facilement que les articles, meme a...

les auteurs, ca s'exporte beaucoup moins facilement que les articles, meme a l'OMC ils sont au courant
parent 3e392988
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -10,86 +10,23 @@ ...@@ -10,86 +10,23 @@
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
\***************************************************************************/ \***************************************************************************/
include ("inc_version.php3"); include ("inc_version.php3");
include_ecrire ("inc_auth.php3"); // prendre $var_* comme variables pour eviter les conflits avec les http_vars
include_ecrire ("inc_export.php3");
include_ecrire ("inc_admin.php3");
include_ecrire ("inc_presentation.php3");
// Liste un sommaire d'objets de n'importe quel type
// a la condition d'etre publics et plus recents que $maj
function liste_objets($result, $type) {
global $maj;
global $articles;
if ($result) while ($row = spip_fetch_array($result)) {
$t_id = $row["id_$type"];
$t_statut = $row["statut"];
$t_maj = mysql_timestamp_to_time($row["maj"]);
if ($t_maj > $maj && (!$t_statut || $t_statut == "publie")) {
echo "$type $t_id $t_maj\n";
if ($type == "article") $articles[]=$t_id;
}
}
spip_free_result($result);
}
// Liste un sommaire recursif de rubriques
// a condition que la mise a jour soit plus recente que $maj
function liste_rubriques($result) {
global $maj;
global $rubriques;
if ($result) while ($row=spip_fetch_array($result)) {
$id_rubrique = $row['id_rubrique'];
$id_parent = $row['id_parent'];
$titre = $row['titre'];
$descriptif = $row['descriptif'];
$texte = $row['texte'];
$rubrique_maj = mysql_timestamp_to_time($row["maj"]);
if ($rubrique_maj > $maj) {
echo "rubrique $id_rubrique $rubrique_maj\n";
}
$t_rubriques[] = $id_rubrique;
}
spip_free_result($result);
if ($t_rubriques) {
$t_rubriques = join(",", $t_rubriques);
$rubriques[] = $t_rubriques;
$query = "SELECT * FROM spip_rubriques WHERE id_parent IN ($t_rubriques)";
liste_rubriques(spip_query($query));
}
}
$var_nom = "export";
$var_f = find_in_path('inc_' . $var_nom . '.php');
Header("Content-Type: text/plain"); if ($var_f)
include($var_f);
// ATTENTION PHP3 ici
elseif (file_exists($var_f = (_DIR_INCLUDE . 'inc_' . $var_nom . '.php3')))
include($var_f);
if ($id_rubrique) if (function_exists($var_nom))
$query="SELECT * FROM spip_rubriques WHERE id_rubrique='$id_rubrique'"; $var_nom($id_rubrique, $maj);
elseif (function_exists($var_f = $var_nom . "_dist"))
$var_f($id_rubrique, $maj);
else else
$query="SELECT * FROM spip_rubriques WHERE id_parent=0"; spip_log("fonction $var_nom indisponible");
liste_rubriques(spip_query($query));
if ($rubriques) {
$rubriques = join(",", $rubriques);
$query = "SELECT id_article, statut, maj FROM spip_articles WHERE id_rubrique IN ($rubriques)";
liste_objets(spip_query($query), "article");
$query = "SELECT id_breve, statut, maj FROM spip_breves WHERE id_rubrique IN ($rubriques)";
liste_objets(spip_query($query), "breve");
if ($articles) {
$articles = join(",", $articles);
$query = "SELECT DISTINCT spip_auteurs.id_auteur, maj FROM spip_auteurs, spip_auteurs_articles AS lien WHERE id_article IN ($articles) AND spip_auteurs.id_auteur=lien.id_auteur";
liste_objets(spip_query($query), "auteur");
}
}
exit;
?> ?>
\ No newline at end of file
...@@ -17,7 +17,6 @@ if (defined("_ECRIRE_INC_EXPORT")) return; ...@@ -17,7 +17,6 @@ if (defined("_ECRIRE_INC_EXPORT")) return;
define("_ECRIRE_INC_EXPORT", "1"); define("_ECRIRE_INC_EXPORT", "1");
$GLOBALS['version_archive'] = '1.2'; $GLOBALS['version_archive'] = '1.2';
...@@ -209,5 +208,83 @@ function export_objets($query, $type, $file = 0, $gz = false, $etape_en_cours="" ...@@ -209,5 +208,83 @@ function export_objets($query, $type, $file = 0, $gz = false, $etape_en_cours=""
} }
// Liste un sommaire d'objets de n'importe quel type
// a la condition d'etre publics et plus recents que $maj
function liste_objets($query, $type, $maj) {
$res = array();
if ($result = spip_query($query))
while ($row = spip_fetch_array($result)) {
$t_id = $row["id_$type"];
$t_statut = $row["statut"];
$t_maj = mysql_timestamp_to_time($row["maj"]);
if (!$maj ||
($t_maj > $maj &&
(!$t_statut || $t_statut == "publie"))) {
echo "$type $t_id ", ($maj ? $t_maj : ""), "\n";
if ($type == "article") $res[]=$t_id;
}
}
spip_free_result($result);
return $res;
}
// Liste un sommaire recursif de rubriques
// a condition que la mise a jour soit plus recente que $maj
function liste_rubriques($id_rubrique) {
global $maj;
static $rubriques = array();
if ($id_rubrique)
$query="SELECT * FROM spip_rubriques WHERE id_rubrique='$id_rubrique'";
else
$query="SELECT * FROM spip_rubriques WHERE id_parent=0";
$result = spip_query($query);
if ($result) while ($row=spip_fetch_array($result)) {
$id_rubrique = $row['id_rubrique'];
$id_parent = $row['id_parent'];
$titre = $row['titre'];
$descriptif = $row['descriptif'];
$texte = $row['texte'];
$rubrique_maj = mysql_timestamp_to_time($row["maj"]);
if ($rubrique_maj > $maj) {
echo "rubrique $id_rubrique $rubrique_maj\n";
}
$t_rubriques[] = $id_rubrique;
$rubriques[] = $id_rubrique;
}
spip_free_result($result);
if ($t_rubriques) {
$t_rubriques = join(",", $t_rubriques);
$query = "SELECT * FROM spip_rubriques WHERE id_parent IN ($t_rubriques)";
liste_rubriques(spip_query($query));
}
return $rubriques;
}
function export_dist($id_rubrique, $maj)
{
header("Content-Type: text/plain");
$rubriques = liste_rubriques($id_rubriques);
if ($rubriques) {
$rubriques = join(",", $rubriques);
$query = "SELECT id_article, statut, maj FROM spip_articles WHERE id_rubrique IN ($rubriques)";
$articles = liste_objets($query, "article", $maj);
$query = "SELECT id_breve, statut, maj FROM spip_breves WHERE id_rubrique IN ($rubriques)";
liste_objets($query, "breve", $maj);
if ($articles) {
$articles = join(",", $articles);
$query = "SELECT DISTINCT id_auteur FROM spip_auteurs_articles WHERE id_article IN ($articles)";
liste_objets($query, "auteur", 0);
}
}
}
?> ?>
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter