Location: PHPKode > scripts > rsscalCreator > rsscalCreator-0.8.5/samplesComplex2.0.php
<?php
/**
 * @author Kjell-Inge Gustafsson <hide@address.com>
 * @copyright copyright (c) 2006 Kjell-Inge Gustafsson kigkonsult
 * @link www.kigkonsult.se/rsscalCreator/index.php hide@address.com
 *
 * License:
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */

 /* ensure the right path to class file */
require_once './rsscalCreator.class.php';
 /* SETUP !!! directory to store feed file */
define( 'CACHE', './cache' );

 /* initiate */
$feed = new rsscalCreator();
 /* set feed directory and filename */
$feed->setFilename( CACHE, 'test.rss' );
 /* set feed version (default 1.0) */
$feed->setVersion( '2.0' );

 /* insert all required and some optional elements */
$channel = new rsscalChannel( 'RSSCAL feed sample'
                            , 'http://www.kigkonsult.se/rsscalCreator/index.php'
                            , 'A RSSCAL feed sample'
                            );
$channel->addElement( 'pubDate', date( 'Y-m-d' ));
$channel->addElement( 'copyright', 'Copyright 2006 kigkonsult' );
$channel->addElement( 'cloud', null, array( 'domain' => "radio.xmlstoragesystem.com"
                                          , 'port' => "80"
                                          , 'path' => "/RPC2"
                                          , 'registerProcedure' => "xmlStorageSystem.rssPleaseNotify"
                                          , 'protocol' => "xml-rpc"
                                          )
                    );
$channel->addElement( 'ttl', 24 * 60 );
$channel->addElement( 'url', 'http://www.kigkonsult.se/rsscalCreator/using.html' );
$feed->setChannel( $channel );

 /* use a while/for/foreach-loop to set the items */
// foreach( $databaseQueryResult as $data ) {
for( $x=1; $x<10; $x++ ) { // fake some demo data
 /* set items subelements, title, link, description  (title or desciption required) */
  $item = new rsscalItem( "Reunion $x"
                        , "http://www.org.com/lib $x?var=x$x&x2=x2$x"
                        , "Anniversary exhibition $x"
                        );
 /* add optional item subelement, one by one (element name, element content) to item */
  $item->addElement( 'enclosure', FALSE, array( 'url'    => "http://www.kigkonult.se/fake_$x/lib$x/file$x.mp3"
                                              , 'length' => "$x$x$x$x$x$x$x"
                                              , 'type'   => 'audio/mpeg' ));
  $item->addElement( 'ev:type',      "category $x" );
  $item->addElement( 'ev:organizer', "manager$hide@address.com" );
  $item->addElement( 'ev:location',  "Room no $x" );
  $item->addElement( 'ev:startdate', "201$x-11-01" );
  $item->addElement( 'ev:enddate',   "201$x-11-01" );
  $item->addElement( 'dc:subject',   "Subject $x" );
  $item->addElement( 'source',       "Tomalak's Realm $x", array( 'url' => "http://www.kigkonsult.se/fake_$x/file$x.xml" ));
 /* add item to feed */
  $feed->addItem( $item );
}

 /* insert optional image required (3) (and optional) elements */
$image = new rsscalImage( 'imagetitle'
                        , 'http://www.RSSquestionnaire.org'
                        , 'http://www.RSSquestionnaire.org/images/image.png'
                        );
$image->addElement( 'width',       '100' );
$image->addElement( 'height',      '40' );
$image->addElement( 'description', 'imagetitle' );
$feed->setImage( $image );

 /* insert required textinput (and optional) elements */
$textinput = new rsscalTextinput( "Make a question!"
                                , "Ask anything about RSS"
                                , "question"
                                , "http://www.RSSquestionnaire.org/ask.php"
                                );
$textinput->addElement( 'dc:language', 'en' );
$feed->setTextinput( $textinput );

 /* create, save feed file and redirect feed to browser */
$feed->returnRSS();

?>
Return current item: rsscalCreator