stripit/rss.php
Leblanc Simon 6dcfdba0e0 Réponse en partie à la requête #1886192.
Une limitation du nombre de strip affiché dans le flux rss en appellant le RSS de cette manière: http://site/rss.php?limit=10 (on affiche alors les 10 derniers strips)
2008-03-21 17:22:20 +00:00

92 lines
1.9 KiB
PHP

<?php
/**
* Strip-It RSS manager
*
* @author Johann "nojhan" Dréo <nojhan@gmail.com>
* @license http://www.gnu.org/licenses/gpl.html GPL
* @copyright 2007 Johann Dréo
*
* @package stripit
*/
set_include_path(get_include_path() . PATH_SEPARATOR . getcwd());
require_once 'strip_manager.php';
require_once 'configuration.php';
// hack for passing objects by values instead of reference under PHP5 (but not PHP4)
// damn clone keyword !
if (version_compare(phpversion(), '5.0') < 0) {
eval('function clone($object) {return $object;}');
}
/**
* RSS manager
*/
class rss_manager
{
/**
* Items list
* @var array
*/
var $items_list = array();
/**
* Configuration
* @var array
*/
var $general;
/**
* Constructor
*
* Use the {@link strip_manager} to do the stuff, and convert date from the iso8601 to RFC822 format.
*/
function rss_manager() {
//$this->general = new configuration;
$sm = new strip_manager();
$this->general = $sm->general;
$this->lang = $sm->lang;
$sm->strips_list_get();
// limit the number of strip in RSS
$limit = 0;
if (isset($_GET['limit']) && is_numeric($_GET['limit'])) {
// check for have no infinite for
if ($_GET['limit'] > 0 && $_GET['limit'] < $sm->strips_count) {
$limit = $sm->strips_count - $_GET['limit'];
}
}
for( $i = $sm->strips_count-1; $i >= $limit; $i-- ) { // reverser order
$sm->strip_info_get( $i );
// conversion iso8601 -> RFC822
$sm->date = date('r', strtotime($sm->date));
$this->items_list[] = clone($sm); // hack for php4/5 compat
}
}
/**
* Generate the RSS output with the template engine.
*/
function generate() {
$sm = new strip_manager;
$output = new HTML_Template_Flexy($sm->options);
$output->compile('template.rss');
$output->outputObject($this,$this->items_list);
}
}
/**
* Instanciation and output.
*/
$rssm = new rss_manager();
$rssm->generate();
?>