Fixato bug per cui la get path del media image renderer non funzionava Aggiunto campo estensione al costruttore dei media image renderer Fixato rss helper che non riusciva ad ottenere la dimensione delle immaginni Signed-off-by: Riccardo Di Dato <r.didato@asdynamics.it>
71 lines
2.5 KiB
PHP
71 lines
2.5 KiB
PHP
<?php
|
|
/*
|
|
* RSSHelper.php
|
|
* Author: Riccardo Di Dato
|
|
* Creation Date: 17 lug 2017
|
|
*/
|
|
|
|
class RSSHelper {
|
|
|
|
public static function generateByNotiziaList(array $notizie){
|
|
header('Content-Type: application/xml');
|
|
|
|
echo '<?xml version="1.0"?>',PHP_EOL;
|
|
echo '<rss version="2.0" encoding="UTF-8">',PHP_EOL;
|
|
echo '<channel>',PHP_EOL;
|
|
|
|
self::generateChannelInfo();
|
|
if (sizeof($notizie)>0){
|
|
foreach ($notizie as $notizia){
|
|
self::generateNotiziaInfo($notizia);
|
|
}
|
|
}
|
|
|
|
echo '</channel>',PHP_EOL;
|
|
echo '</rss>',PHP_EOL;
|
|
}
|
|
|
|
private static function generateChannelInfo(){
|
|
$conf = GlobalVariables::get("config");
|
|
|
|
echo '<title>'.$conf->info->projectName.'</title>',PHP_EOL;
|
|
echo '<link>'.GUIHandler::getBaseUrl().'</link>',PHP_EOL;
|
|
echo '<description>'.html_entity_decode($conf->info->projectDescription).'</description>',PHP_EOL; // Entity decode perchè in config contiene à e non ho intenzione di controllare tutta l'applicazione
|
|
echo '<language>it-IT</language>',PHP_EOL;
|
|
echo '<webMaster>webmaster@ifattidinapoli.it</webMaster>',PHP_EOL;
|
|
|
|
echo '<image>',PHP_EOL;
|
|
echo '<title>'.$conf->info->projectName.'</title>',PHP_EOL;
|
|
echo '<link>'.GUIHandler::getBaseUrl().'</link>',PHP_EOL;
|
|
echo '<url>'.GUIHandler::getBaseUrl().'/images/logo_uff.png</url>',PHP_EOL;
|
|
echo '<width>48</width>',PHP_EOL;
|
|
echo '<height>48</height>',PHP_EOL;
|
|
echo '</image>',PHP_EOL;
|
|
}
|
|
|
|
private static function generateNotiziaInfo(NotiziaModel $notizia){
|
|
$conf = GlobalVariables::get("config");
|
|
|
|
echo '<item>',PHP_EOL;
|
|
echo '<title>'.$notizia->titolo.'</title>',PHP_EOL;
|
|
echo '<description>'.htmlentities($notizia->testo).'</description>',PHP_EOL;
|
|
echo '<link>'.GUIHandler::getBaseUrl().'articolo_'.$notizia->id.'</link>',PHP_EOL;
|
|
|
|
$mainMedia = DaoMediaHandler::getMainMediaFromModel($notizia);
|
|
if (!is_null($mainMedia) && $mainMedia->hasProperty("mediaType") && $mainMedia->mediaType == MediaModel::TYPE_IMAGE){
|
|
$renderer = $mainMedia->getRenderer();
|
|
if ($renderer instanceof MediaImage){
|
|
$link = $renderer->getImageLink(MediaRendererInterface::SIZE_MEDIUM);
|
|
echo '<enclosure url="'.$renderer->getImageLink(MediaRendererInterface::SIZE_MEDIUM).'" length="'.filesize($renderer->getPath()).'" type="image/png" />',PHP_EOL;
|
|
}
|
|
}
|
|
|
|
echo '<pubDate>'.date(DATE_RFC2822,$notizia->about->data->sec).'</pubDate>',PHP_EOL;
|
|
echo '<guid>'.GUIHandler::getBaseUrl().'articolo_'.$notizia->id.'</guid>',PHP_EOL;
|
|
|
|
echo '</item>',PHP_EOL;
|
|
|
|
}
|
|
}
|
|
|
|
?>
|