Rev 587 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
<?php// declare(encoding='UTF-8');/*** Service affichant les dernières photo publiques du CEL ouvrable sous forme de diaporama.* Encodage en entrée : utf8* Encodage en sortie : utf8** Cas d'utilisation et documentation :* @link http://www.tela-botanica.org/wikini/eflore/wakka.php?wiki=AideCELWidgetPhoto** Paramètres :** @author Jean-Pascal MILCENT <jpm@tela-botanica.org>* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>* @version $Id$* @copyright Copyright (c) 2010, Tela Botanica (accueil@tela-botanica.org)*/class Photo extends WidgetCommun {const DS = DIRECTORY_SEPARATOR;const SERVICE_DEFAUT = 'photo';/*** Méthode appelée par défaut pour charger ce widget.*/public function executer() {$retour = null;extract($this->parametres);if (!isset($mode)) {$mode = self::SERVICE_DEFAUT;}$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");if (! $contenu = $cache->charger($id_cache)) {$methode = $this->traiterNomMethodeExecuter($mode);if (method_exists($this, $methode)) {$retour = $this->$methode();} else {$this->messages[] = "Ce type de service '$methode' n'est pas disponible.";}if (is_null($retour)) {$contenu = 'Un problème est survenu : '.print_r($this->messages, true);} else {$squelette = dirname(__FILE__).self::DS.'squelettes'.self::DS.$retour['squelette'].'.tpl.html';$contenu = $this->traiterSquelettePhp($squelette, $retour['donnees']);$cache->sauver($id_cache, $contenu);}}$this->envoyer($contenu);}private function executerPhoto() {$widget = null;$xml = file_get_contents($this->config['photo']['fluxRssUrl']);if ($xml) {try {$flux = new XmlFeedParser($xml);} catch (XmlFeedParserException $e) {trigger_error('Feed invalid: '.$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+ :/', '', $entree->title);// Récupération du GUIDif (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 à extraif ($num == 0) {$widget['donnees']['extra'] = $item;}$widget['donnees']['items'][$num++] = $item;}$widget['squelette'] = 'photo';}return $widget;}}?>