From 3ff54bb8e86262655c3ad1017ffd111b6844691b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 2 Aug 2004 21:26:10 +0000 Subject: [PATCH] =?UTF-8?q?Possibilit=E9=20de=20saisir=20plusieurs=20flux?= =?UTF-8?q?=20RSS=20et=20gestion=20partiel=20du=20register=5Fglobals=3Doff?= =?UTF-8?q?.=20Il=20y=20a=20encore=20de=20nombreux=20bugs=20sur=20cette=20?= =?UTF-8?q?page,=20je=20corrige=20le=20reste=20demain.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/admin/external_rss.php | 145 ++++++++++++++++++++++------------ 1 file changed, 95 insertions(+), 50 deletions(-) diff --git a/htdocs/admin/external_rss.php b/htdocs/admin/external_rss.php index 518f245331c..4db2f5b0321 100644 --- a/htdocs/admin/external_rss.php +++ b/htdocs/admin/external_rss.php @@ -1,6 +1,7 @@ +/* Copyright (C) 2003 Éric Seigne * Copyright (C) 2003 Rodolphe Quiedeville + * Copyright (C) 2004 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,18 +25,47 @@ require("./pre.inc.php"); llxHeader(); if (!$user->admin) -{ - print "Forbidden"; - llxfooter(); - exit; -} + accessforbidden(); + $def = array(); // positionne la variable pour le nombre de rss externes -$nbexternalrss = 1; +$db->query("select count(*) nb from ".MAIN_DB_PREFIX."const where name like 'EXTERNAL_RSS_URLRSS_%'"); +$obj = $db->fetch_object(0); +$nbexternalrss = $obj->nb; -if ($action == 'save') +if ($_POST["action"] == 'add') +{ + $external_rss_url = "external_rss_url_" . $_POST["norss"]; + if(isset($_POST[$external_rss_url])) { + $external_rss_title = "external_rss_title_" . $_POST["norss"]; + $external_rss_urlrss = "external_rss_urlrss_" . $_POST["norss"]; + + $sql = "REPLACE INTO ".MAIN_DB_PREFIX."const SET name = 'EXTERNAL_RSS_URL_" . $_POST["norss"] . "', value='".$_POST[$external_rss_url]."', visible=0"; + $sql1 = "REPLACE INTO ".MAIN_DB_PREFIX."const SET name = 'EXTERNAL_RSS_TITLE_" . $_POST["norss"] . "', value='".$_POST[$external_rss_title]."', visible=0"; + $sql2 = "REPLACE INTO ".MAIN_DB_PREFIX."const SET name = 'EXTERNAL_RSS_URLRSS_" . $_POST["norss"] . "', value='".$_POST[$external_rss_urlrss]."', visible=0"; + + if ($db->query($sql) && $db->query($sql1) && $db->query($sql2)) + { + // la constante qui a été lue en avant du nouveau set + // on passe donc par une variable pour avoir un affichage cohérent + print "Nouveau flux RSS ajouté\n"; + $nbexternalrss++; + } + else + print "Erreur d'enregistement\n"; + } +} + +if ($_POST["delete"]) +{ + // TODO Code pour supprimer + + +} + +if ($_POST["modify"]) { for ($i = 0; $i < $nbexternalrss; $i++) { $external_rss_url = "external_rss_url_" . $i; @@ -50,10 +80,10 @@ if ($action == 'save') { // la constante qui a été lue en avant du nouveau set // on passe donc par une variable pour avoir un affichage cohérent - print "

Enregistrement confirmé pour le site " . $$external_rss_title . "

\n"; + print "Enregistrement confirmé pour le site " . $$external_rss_title . "\n"; } else - print "

Erreur d'enregistement pour le site " . $$external_rss_title . "

\n"; + print "Erreur d'enregistement pour le site " . $$external_rss_title . "\n"; } } } @@ -63,9 +93,11 @@ if ($action == 'save') * Affichage du formulaire de saisie */ -print_fiche_titre("Configuration du lien vers un site syndiqué", $mesg); - -print "\n

Attention, pour la récupération des données au format RSS, les urls en https ne marchent pas pour l'instant.

+print_fiche_titre("Configuration des imports de flux RSS", $mesg); + +?> + +Attention, pour la récupération des données au format RSS, les urls en https ne marchent pas pour l'instant. Exemples:
  • WikiApril / http://wiki.april.org / http://wiki.april.org/RecentChanges?format=rss (et tous les sites phpwiki)
  • LinuxFR / http://linuxfr.org / http://www.linuxfr.org/backend.rss
  • @@ -75,15 +107,43 @@ Exemples:
    • Docs d'AbulÉdu / http://docs.abuledu.org / http://docs.abuledu.org/backend.php3 (et tous les sites spip)
    -
    -\n"; + + +
    + + + + + + + + + + + + + + + + +
    Syndication d'un nouveau flux RSS
    Titre" size="45">
    URL du site
    URL du RSS" size="45">
    +"> + + +
    + +
    + +
    + + + + - + + @@ -96,41 +156,26 @@ for($i = 0; $i < $nbexternalrss; $i++) { -\n"; -} - -clearstatcache(); - -print " - -
    Syndication du site numéro " . ($i+1) . "
    Syndication du site numéro " . ($i+1) . "
    Titre
    URL du RSS
    -\n"; - -/* - * - * - */ - -print_titre("Résultat du fetch"); - -// à modifier si on a plus d'un module RSS externe ! -if (defined("MAIN_MODULE_EXTERNAL_RSS") && MAIN_MODULE_EXTERNAL_RSS) -{ - print ''.EXTERNAL_RSS_TITLE_0.'

    '; - require_once("../includes/magpierss/rss_fetch.inc"); - - $rss = fetch_rss( EXTERNAL_RSS_URLRSS_0 ); - - foreach ($rss->items as $item) - { - $href = $item['link']; - $title = $item['title']; - print '
    '; - } + + +trans("Modify")."\"> +trans("Delete")."\"> + + + + +"; } +?> + + + +close(); llxFooter(); + ?>