Subversion Repositories eFlore/Applications.cel

Compare Revisions

Ignore whitespace Rev 582 → Rev 583

/trunk/widget/modules/photo/Photo.php
9,6 → 9,10
* @link http://www.tela-botanica.org/wikini/eflore/wakka.php?wiki=AideCELWidgetPhoto
*
* Paramètres :
* ===> extra = booléen (1 ou 0) [par défaut : 1]
* Affiche / Cache la vignette en taille plus importante au bas du widget.
* ===> vignette = [0-9]+,[0-9]+ [par défaut : 4,3]
* Indique le nombre de vignette par ligne et le nombre de ligne.
*
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
20,6 → 24,8
const DS = DIRECTORY_SEPARATOR;
const SERVICE_DEFAUT = 'photo';
private $flux_rss_url = null;
private $eflore_url_tpl = null;
/**
* Méthode appelée par défaut pour charger ce widget.
32,12 → 38,14
$mode = self::SERVICE_DEFAUT;
}
$flux_rss_url = $this->config['photo']['fluxRssUrl'];
$this->eflore_url_tpl = $this->config['photo']['efloreUrlTpl'];
$this->flux_rss_url = $this->config['photo']['fluxRssUrl'];
$cache_activation = $this->config['photo.cache']['activation'];
$cache_stockage = $this->config['photo.cache']['stockageDossier'];
$ddv = $this->config['photo.cache']['dureeDeVie'];
$cache = new Cache($cache_stockage, $ddv, $cache_activation);
$id_cache = 'photo-'.md5("$mode-$flux_rss_url");
$id_cache = 'photo-'.md5("$mode-{$this->flux_rss_url}");
if (! $contenu = $cache->charger($id_cache)) {
$methode = $this->traiterNomMethodeExecuter($mode);
if (method_exists($this, $methode)) {
59,44 → 67,58
private function executerPhoto() {
$widget = null;
extract($this->parametres);
$extra = (isset($extra) && $extra == 0) ? false : ($this->config['photo']['extraActif'] ? true : false);
$vignette = (isset($vignette) && preg_match('/^[0-9]+,[0-9]+$/', $vignette)) ? $vignette : '4,3';
list($colonne, $ligne) = explode(',', $vignette);
$xml = file_get_contents($this->config['photo']['fluxRssUrl']);
$xml = file_get_contents($this->flux_rss_url);
if ($xml) {
try {
$flux = new XmlFeedParser($xml);
$widget['donnees']['flux_rss_url'] = $this->flux_rss_url;
$widget['donnees']['url_css'] = sprintf($this->config['chemins']['baseURLAbsoluDyn'], 'modules/photo/squelettes/css/');
$widget['donnees']['colonne'] = $colonne;
$widget['donnees']['extra_actif'] = $extra;
$max_photo = $colonne * $ligne;
$num = 0;
foreach ($flux as $entree) {
if ($num == $max_photo) {
break;
}
$item = array();
// Formatage date
$item['date'] = strftime('%A %d %B %Y', $entree->pubDate);
$item['lien'] = $entree->link;
$item['url_tpl'] = preg_replace('/[SML]\.jpg$/', '%s.jpg', $entree->guid);
// Formatage titre
$item['titre'] = $entree->title;
$item['nn'] = '';
$item['eflore_url'] = '#';
if (preg_match('/\[nn([0-9]+)\]/', $entree->title, $match)) {
$item['nn'] = $match[1];
$item['eflore_url'] = sprintf($this->eflore_url_tpl, $item['nn']);
}
// Récupération du GUID
if (preg_match('/appli:cel-img:([0-9]+)[SML]\.jpg$/', $entree->guid, $match)) {
$item['guid'] = (int) $match[1];
} else {
$item['guid'] = $entree->guid;
}
// Ajout aux items et si première photo à extra
if ($num == 0) {
$widget['donnees']['extra'] = $item;
}
$widget['donnees']['items'][$num++] = $item;
}
$widget['squelette'] = 'photo';
} catch (XmlFeedParserException $e) {
trigger_error('Feed invalid: '.$e->getMessage(), E_USER_WARNING);
trigger_error('Flux invalide : '.$e->getMessage(), E_USER_WARNING);
}
$widget['donnees']['url_css'] = sprintf($this->config['chemins']['baseURLAbsoluDyn'], 'modules/photo/squelettes/css/');
$widget['donnees']['extra_actif'] = ($this->config['photo']['extraActif']) ? true : false;
$max_photo = $this->config['photo']['vignetteNbre'];
$num = 0;
foreach ($flux as $entree) {
if ($num == $max_photo) {
break;
}
 
$item = array();
// Formatage date
$item['date'] = strftime('%A %d %B %Y', $entree->pubDate);
$item['lien'] = $entree->link;
$item['url_tpl'] = preg_replace('/[SML]\.jpg$/', '%s.jpg', $entree->guid);
// Formatage titre
$item['titre'] = preg_replace('/^\d+-\d+&nbsp;:/', '', $entree->title);
// Récupération du GUID
if (preg_match('/appli:cel-img:([0-9]+)[SML]\.jpg$/', $entree->guid, $match)) {
$item['guid'] = (int) $match[1];
} else {
$item['guid'] = $entree->guid;
}
// Ajout aux items et si première photo à extra
if ($num == 0) {
$widget['donnees']['extra'] = $item;
}
$widget['donnees']['items'][$num++] = $item;
}
$widget['squelette'] = 'photo';
}
return $widget;
}