Overview

Namespaces

  • None
  • PHP
  • Pry
    • Auth
      • Interfaces
    • Config
    • Controller
    • Date
    • Db
    • Feed
      • Abstracts
      • Writers
    • File
      • Decorator
    • Form
      • Element
    • Image
    • Log
      • Writer
    • Net
      • Exception
    • Session
    • Util
    • Validate
      • Validator
    • View

Classes

  • Entry
  • Feed
  • Overview
  • Namespace
  • Class
  • Tree
  1: <?php
  2: 
  3: /**
  4:  * Pry Framework
  5:  *
  6:  * LICENSE
  7:  *
  8:  * This source file is subject to the new BSD license that is bundled
  9:  * with this package in the file LICENSE.txt.
 10:  * 
 11:  */
 12: 
 13: namespace Pry\Feed;
 14: 
 15: use Pry\Feed\Abstracts\Feed as AbstractFeed;
 16: 
 17: /**
 18:  * Gestion de la création de flux.
 19:  * <code>
 20:  * $feed = new Feed();
 21:  * $feed->setTitle('Flux base de connaissance')
 22:  *      ->setDate('Fri, 29 Jan 2010 09:27:22 +0100')
 23:  *      ->setAuthor(array('name'=>'OR','email'=>'oroger@prynel.com'))
 24:  *      ->setDescription('Derniers éléments de la base de connaissance Prynel')
 25:  *      ->setCopyright('prynel')
 26:  *      ->setLink('http://172.16.12.227/prybug/');
 27:  *
 28:  *  $entry = $feed->createEntry();
 29:  *  //$entry->setAuthor(array('name'=>'OR-'.$i,'email'=>'oroger@prynel.com'));
 30:  *  $entry->setTitle('[Digipryn v5] Carré blanc sur les images');
 31:  *  //$entry->setDate('2010-01-28');
 32:  *  $entry->setContent('UN carré blanc apparait sur l\'interface');
 33:  *  //$entry->setId($i);
 34:  *  $entry->setLink('http://172.16.12.227/prynbug/base/8/voir.html');
 35:  *  $feed->setEntry($entry);
 36:  *  
 37:  * 
 38:  *  header('Content-Type : application/xml; charset=utf-8');
 39:  *  // $feed->build('Rss','file.xml');
 40:  *  echo $feed->build('Rss');
 41:  * </code>
 42:  * @category Pry
 43:  * @package Feed
 44:  * @version 1.1.0 
 45:  * @author Olivier ROGER <oroger.fr>
 46:  *       
 47:  */
 48: class Feed extends AbstractFeed
 49: {
 50: 
 51:     /**
 52:      * Tableau des items du flux
 53:      * @access private
 54:      * @var array
 55:      */
 56:     private $entries;
 57: 
 58:     public function __construct()
 59:     {
 60:         $this->author = array();
 61:         $this->entries = array();
 62:         $this->date = time();
 63:         $this->lang = 'fr-Fr';
 64:     }
 65: 
 66:     /**
 67:      * Créer un élément de flux
 68:      * @return Feed_Entry
 69:      */
 70:     public function createEntry()
 71:     {
 72:         return new Entry();
 73:     }
 74: 
 75:     /**
 76:      * Enregistre l'élément créé dans le flux
 77:      * @param Feed_Entry $entry
 78:      * @return void
 79:      */
 80:     public function setEntry($entry)
 81:     {
 82:         $this->entries[] = $entry;
 83:     }
 84: 
 85:     /**
 86:      * Récupère tous les éléments du flux
 87:      * @return array
 88:      */
 89:     public function getEntries()
 90:     {
 91:         return $this->entries;
 92:     }
 93: 
 94:     /**
 95:      * Construit le flux avec les infos et les éléments
 96:      * @param string $type Type de flux (Rss, Atom ...)
 97:      * @param string $file Chemin vers le fichier (optionnel)
 98:      * @return string|int
 99:      */
100:     public function build($type, $file = null)
101:     {
102:         $class = 'Pry\Feed\Writers\\' . $type;
103:         if (class_exists($class))
104:         {
105:             $build = new $class($this, $file);
106:             return $build->finalize();
107:         }
108: 
109:         throw new \InvalidArgumentException('Le type ' . $type . ' ne semble pas supporté');
110:     }
111: 
112: }
113: 
114: ?>
Pry API documentation generated by ApiGen 2.8.0