Accueil > > > BIBLIOTHÈQUE GÉNÉRATRICE DE FLUX RSS
BIBLIOTHÈQUE GÉNÉRATRICE DE FLUX RSS
Information sur la source
Description
Cette source n'est pas de moi je tiens a le preciser...mais je les trouver tellement puissante que je n'es pas pu m'empecher de vous la proposer ... En fait grace a cette class disposant de fonction spécifique approuvé par le feed validator vous allez pouvoir générer des flux RSS aux normes
Source
- <?php
-
- // $Id: rss10.inc,v 1.3 2001/05/20 17:58:02 edmundd Exp $
- //
- // A convenience class to make it easy to write RSS classes
- // Edd Dumbill <mailto:edd+rsswriter@usefulinc.com>
- //
- // $Log: rss10.inc,v $
- // Revision 1.3 2001/05/20 17:58:02 edmundd
- // Final distribution tweaks.
- //
- // Revision 1.2 2001/05/20 17:41:30 edmundd
- // Ready for distribution.
- //
- // Revision 1.1 2001/05/20 17:01:43 edmundd
- // First functional draft of code working.
- //
- // Revision 1.1 2001/05/17 18:17:46 edmundd
- // Start of a convenience library to help RSS1.0 creation
- //
-
- class RSSWriter {
-
- function RSSWriter($uri, $title, $description, $meta=array()) {
- $this->chaninfo=array();
- $this->website=$uri;
- $this->chaninfo["link"]=$uri;
- $this->chaninfo["description"]=$description;
- $this->chaninfo["title"]=$title;
- $this->items=array();
- $this->modules=array("dc" => "http://purl.org/dc/elements/1.1/");
- // thanks James Mills for bugfix to this line
- $this->channelURI=str_replace("&", "&", "http://" . $GLOBALS["SERVER_NAME"] . $GLOBALS["REQUEST_URI"]);
- foreach ($meta as $key => $value) {
- $this->chaninfo[$key]=$value;
- }
- }
-
- function useModule($prefix, $uri) {
- $this->modules[$prefix]=$uri;
- }
-
- function setImage($imgURI, $imgAlt, $imgWidth=88, $imgHeight=31) {
- $this->image=array(
- "uri" => $imgURI, "title" => $imgAlt, "width" => $imgWidth,
- "height" => $imgHeight);
- }
-
- function addItem($uri, $title, $meta=array()) {
- $item=array("uri" => $uri, "link" => $uri,
- "title" => $this->deTag($title));
- foreach ($meta as $key => $value) {
- if ($key == "description" || $key == "dc:description") {
- $value=$this->deTag($value);
- }
- $item[$key]=$value;
- }
- $this->items[]=$item;
- }
-
- function serialize() {
- $this->preamble();
- $this->channelinfo();
- $this->image();
- $this->items();
- $this->postamble();
- }
-
- function deTag($in) {
- while(ereg('<[^>]+>', $in)) {
- $in=ereg_replace('<[^>]+>', '', $in);
- }
- return $in;
- }
-
- function preamble() {
- header("Content-type: text/xml");
- print '<?xml version="1.0" encoding="iso-8859-1"?>
- <rdf:RDF
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns="http://purl.org/rss/1.0/"
- xmlns:mn="http://usefulinc.com/rss/manifest/"
- ';
- foreach ($this->modules as $prefix => $uri) {
- print " xmlns:${prefix}=\"${uri}\"\n";
- }
- print ">\n\n";
- }
-
- function channelinfo() {
- print ' <channel rdf:about="' . $this->channelURI . '">
- ';
- $i=$this->chaninfo;
- foreach (array("title", "link", "dc:source", "description", "dc:language", "dc:publisher",
- "dc:creator", "dc:rights") as $f) {
- if (isset($i[$f])) {
- print " <${f}>" . htmlspecialchars($i[$f]) . "</${f}>\n";
- }
- }
- if (isset($this->image)) {
- print " <image rdf:resource=\"" . htmlspecialchars($this->image["uri"]) . "\" />\n";
- }
- print " <items>\n";
- print " <rdf:Seq>\n";
- foreach ($this->items as $i) {
- print " <rdf:li rdf:resource=\"" . htmlspecialchars($i["uri"]) . "\" />\n";
- }
- print " </rdf:Seq>\n";
- print " </items>\n";
- print " </channel>\n\n";
- }
-
- function image() {
- if (isset($this->image)) {
- print " <image rdf:about=\"" . htmlspecialchars($this->image["uri"]) . "\">\n";
- print " <title>" . htmlspecialchars($this->image["title"]) . "</title>\n";
- print " <url>" . htmlspecialchars($this->image["uri"]) . "</url>\n";
- print " <link>" . htmlspecialchars($this->website) . "</link>\n";
- if ($this->chaninfo["description"])
- print " <dc:description>" . htmlspecialchars($this->chaninfo["description"]) .
- "</dc:description>\n";
- print " </image>\n\n";
- }
- }
-
- function postamble() {
- print ' <rdf:Description rdf:ID="manifest">
- <mn:channels>
- <rdf:Seq>
- <rdf:li rdf:resource="' . $this->channelURI . '" />
- </rdf:Seq>
- </mn:channels>
- </rdf:Description>
-
- </rdf:RDF>
- ';
- }
-
- function items() {
- foreach ($this->items as $item) {
- print " <item rdf:about=\"" . htmlspecialchars($item["uri"]) . "\">\n";
- foreach ($item as $key => $value) {
- if ($key!="uri") {
- if (is_array($value)) {
- foreach ($value as $v1) {
- print " <${key}>" . htmlspecialchars($v1) . "</${key}>\n";
- }
- } else {
- print " <${key}>" . htmlspecialchars($value) . "</${key}>\n";
- }
- }
- }
- print " </item>\n\n";
- }
- }
-
- }
-
- ?>
<?php
// $Id: rss10.inc,v 1.3 2001/05/20 17:58:02 edmundd Exp $
//
// A convenience class to make it easy to write RSS classes
// Edd Dumbill <mailto:edd+rsswriter@usefulinc.com>
//
// $Log: rss10.inc,v $
// Revision 1.3 2001/05/20 17:58:02 edmundd
// Final distribution tweaks.
//
// Revision 1.2 2001/05/20 17:41:30 edmundd
// Ready for distribution.
//
// Revision 1.1 2001/05/20 17:01:43 edmundd
// First functional draft of code working.
//
// Revision 1.1 2001/05/17 18:17:46 edmundd
// Start of a convenience library to help RSS1.0 creation
//
class RSSWriter {
function RSSWriter($uri, $title, $description, $meta=array()) {
$this->chaninfo=array();
$this->website=$uri;
$this->chaninfo["link"]=$uri;
$this->chaninfo["description"]=$description;
$this->chaninfo["title"]=$title;
$this->items=array();
$this->modules=array("dc" => "http://purl.org/dc/elements/1.1/");
// thanks James Mills for bugfix to this line
$this->channelURI=str_replace("&", "&", "http://" . $GLOBALS["SERVER_NAME"] . $GLOBALS["REQUEST_URI"]);
foreach ($meta as $key => $value) {
$this->chaninfo[$key]=$value;
}
}
function useModule($prefix, $uri) {
$this->modules[$prefix]=$uri;
}
function setImage($imgURI, $imgAlt, $imgWidth=88, $imgHeight=31) {
$this->image=array(
"uri" => $imgURI, "title" => $imgAlt, "width" => $imgWidth,
"height" => $imgHeight);
}
function addItem($uri, $title, $meta=array()) {
$item=array("uri" => $uri, "link" => $uri,
"title" => $this->deTag($title));
foreach ($meta as $key => $value) {
if ($key == "description" || $key == "dc:description") {
$value=$this->deTag($value);
}
$item[$key]=$value;
}
$this->items[]=$item;
}
function serialize() {
$this->preamble();
$this->channelinfo();
$this->image();
$this->items();
$this->postamble();
}
function deTag($in) {
while(ereg('<[^>]+>', $in)) {
$in=ereg_replace('<[^>]+>', '', $in);
}
return $in;
}
function preamble() {
header("Content-type: text/xml");
print '<?xml version="1.0" encoding="iso-8859-1"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://purl.org/rss/1.0/"
xmlns:mn="http://usefulinc.com/rss/manifest/"
';
foreach ($this->modules as $prefix => $uri) {
print " xmlns:${prefix}=\"${uri}\"\n";
}
print ">\n\n";
}
function channelinfo() {
print ' <channel rdf:about="' . $this->channelURI . '">
';
$i=$this->chaninfo;
foreach (array("title", "link", "dc:source", "description", "dc:language", "dc:publisher",
"dc:creator", "dc:rights") as $f) {
if (isset($i[$f])) {
print " <${f}>" . htmlspecialchars($i[$f]) . "</${f}>\n";
}
}
if (isset($this->image)) {
print " <image rdf:resource=\"" . htmlspecialchars($this->image["uri"]) . "\" />\n";
}
print " <items>\n";
print " <rdf:Seq>\n";
foreach ($this->items as $i) {
print " <rdf:li rdf:resource=\"" . htmlspecialchars($i["uri"]) . "\" />\n";
}
print " </rdf:Seq>\n";
print " </items>\n";
print " </channel>\n\n";
}
function image() {
if (isset($this->image)) {
print " <image rdf:about=\"" . htmlspecialchars($this->image["uri"]) . "\">\n";
print " <title>" . htmlspecialchars($this->image["title"]) . "</title>\n";
print " <url>" . htmlspecialchars($this->image["uri"]) . "</url>\n";
print " <link>" . htmlspecialchars($this->website) . "</link>\n";
if ($this->chaninfo["description"])
print " <dc:description>" . htmlspecialchars($this->chaninfo["description"]) .
"</dc:description>\n";
print " </image>\n\n";
}
}
function postamble() {
print ' <rdf:Description rdf:ID="manifest">
<mn:channels>
<rdf:Seq>
<rdf:li rdf:resource="' . $this->channelURI . '" />
</rdf:Seq>
</mn:channels>
</rdf:Description>
</rdf:RDF>
';
}
function items() {
foreach ($this->items as $item) {
print " <item rdf:about=\"" . htmlspecialchars($item["uri"]) . "\">\n";
foreach ($item as $key => $value) {
if ($key!="uri") {
if (is_array($value)) {
foreach ($value as $v1) {
print " <${key}>" . htmlspecialchars($v1) . "</${key}>\n";
}
} else {
print " <${key}>" . htmlspecialchars($value) . "</${key}>\n";
}
}
}
print " </item>\n\n";
}
}
}
?>
Conclusion
Comment ca marche??
<?php include("rss10.inc"); .... $rss=ne w RSSWriter("http://www.example.org/"; "Example Site", "The best examples out there.", array("dc:publisher" => "Example Publishing Inc.", "dc:creator" => "E X Ample <me@example.org>")); ... //pour une image $rss->setImage("http://www.example.org/image s/rss.gif","Example Site: All the Examples Fit to Print"); ... //pour un item $rss->addItem("http://www.example.org/page1.h tml","First Example Page"); .... //pour le module (special attention!!) $rss->useModule("ex", "http://www.example.org/ns/myModule/"); ... //pôur generer le fichier rss $rss->serialize(); ?>
plus d'explication en anglais ici http://usefulinc.com/rss/rsswriter/
Sources du même auteur
Sources de la même categorie
Commentaires et avis
Discussions en rapport avec ce code source dans le forum
Recherche de flux xml ou/et rss de prog tv sportif [ par bobganjx ]
Pauvre de moi en stage, exploité par un employeur sans scrupule qui me paye pas (c'est beaux les études) ;<font color="#800080"
flux rss [ par atchoumen ]
Bonjour,je suis en train de mettre un flux rss en place sur mon site et je me retrouve face à un problème bizarre. Lorsque je fais une requete sans co
widget+rss+php [ par lsamsoumal ]
Bonjour tt le monde: j'ai un code php qui génére un fichier xml contenant des flux rss.Maintenant je veut developper un widget qui récupére les flux r
widget avec flux rss [ par pandouta08 ]
j'ai un code php d'un générateur d'un fichier xml contenant un ensemble de lien et j'ai un widget yahoo que j'ai créé ,je veux que mon widget yahoo af
flux rss [ par mahamourta ]
bonsoir tout le monde je veux installer un flux rss sur mon site web . J'ai reussi a avoir un code dans mon fichier xml ,mais je n'arrive pas a l'exp
GESTION FLUX RSS [ par Larffas69 ]
Bonjour à tous, Quelqu'un saurait-il qu'elle expression html il faut pour afficher une image provenant de la balise d’un flux RSS ? [code=htm
insertion des flux RSS dans des pages php [ par hadjiphp ]
Bonjour, merci pour ce site et souhaite de trouver tous ce que je veux. je vous remercie.je suis entrain de créer un site web en php, et je souhai
Flux RSS [ par hadjiphp ]
Bonjour, merci pour ce site et souhaite de trouver tous ce que je veux. je vous remercie. Bonjour, j'ai une question : comment je peut insérer u
Un flux rss avec une image? (magpierss) [ par rnrr ]
Bonjour, j'utilise magpierss pour afficher mes flux rss mais la je doit afficher des images dans mes flux rss. Comment faire? Est-ce fesable avec magp
mise en page du flux rss avec du css [ par New_World ]
bonjour tous le monde, SVP j'ai un petit soucis avec mon flux rss j'essaye de le mettre en forme avec du css mais aparement il reconait pas mon CSS sa
|
Derniers Blogs
IMAGINE CUP 2012, MAKE A SIGN EN FINALEIMAGINE CUP 2012, MAKE A SIGN EN FINALE par junarnoalg
Voilà qui est fait, la nouvelle est officielle ! L'équipe belge "Make a Sign" va au pays des kangourous défendre son projet dans la catégorie Software Design. http://www.imaginecup.com/CompetitionsContent/Competition/WorldwideFinalists.aspx V...
Cliquez pour lire la suite de l'article par junarnoalg KINECT 1.5 IS OUT !KINECT 1.5 IS OUT ! par Vko
La version 1.5 du Kinect For Microsoft vient tout juste de sortir ! Plein de nouveautés: Tracking de squelette en Near Mode Détection en position assise Détection faciale avec un SDK dédié Documentation et des guideline (enfin) Un out...
Cliquez pour lire la suite de l'article par Vko LES ACTUALITéS DE LA SEMAINE SUR C2I.FR (14 MAI - 20 MAI) LES ACTUALITéS DE LA SEMAINE SUR C2I.FR (14 MAI - 20 MAI) par richardc
Mise à jour des Web API du 14 Mai
Réservez dès maintenant votre journée du 20 juin pour le Windows Azure Dev Camp 2012 à Paris
Mise à jour de Team Foundation Service
MechCommander 2 sur Windows 8
Entity Framework 5 Release Candidate e...
Cliquez pour lire la suite de l'article par richardc REACTIVE EXTENSIONS : CONSOMMER DES SERVICES AVEC RX PARTIE 3, LES PIèGES à éVITERREACTIVE EXTENSIONS : CONSOMMER DES SERVICES AVEC RX PARTIE 3, LES PIèGES à éVITER par Groc
Une mauvaise utilisation de rx lors de l'écriture d'une couche d'accès à des services peut conduire à des cas embarassants avec des erreurs mal gérées, des appels qui ne partent lorsqu'ils le devraient, et même des résultats incorrects . le tout nuis...
Cliquez pour lire la suite de l'article par Groc SHAREPOINT BLOG SITE, PROBLèME D'ARCHIVESSHAREPOINT BLOG SITE, PROBLèME D'ARCHIVES par junarnoalg
Dernièrement, nous avons migré le site
myTIC
vers un nouveau serveur SharePoint 2010. Dans les contenus que nous vouloins récupérer, nous avions un certain nombre de blogs.
Nous avons utilisé les commandes Power...
Cliquez pour lire la suite de l'article par junarnoalg
Logiciels
sDEVIS-FACTURES vlPRO (8.1.0.3)SDEVIS-FACTURES VLPRO (8.1.0.3)sDEVIS-FACTURES vlPRO a été mis au point pour les particuliers, créateurs, entrepreneurs, artisa... Cliquez pour télécharger sDEVIS-FACTURES vlPRO 974 Application Server (12.2.4.6)974 APPLICATION SERVER (12.2.4.6)Développez de puissantes applications dans un environnement de 'cloud computing', clusterisé, séc... Cliquez pour télécharger 974 Application Server vPicture (1.4.2.1)VPICTURE (1.4.2.1)Avec vPicture, hébergez vos images facilement et rapidement.
vPicture est un utilitaire simple, ... Cliquez pour télécharger vPicture Easy-Planning (2.2.1.6)EASY-PLANNING (2.2.1.6)Easy-Planning permet de créer des plannings sous la représentation de diagrammes et est adapté au... Cliquez pour télécharger Easy-Planning COM-BACKUP (2.0)COM-BACKUP (2.0)
COM-BACKUP est un logiciel de sauvegarde qui permet de planifier les sauvegardes de vos dossiers ...
Cliquez pour télécharger COM-BACKUP
|