Subversion Repositories eFlore/Applications.del

Rev

Rev 1840 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1822 jpm 1
<?php
2
 
3
/*
4
 * To change this license header, choose License Headers in Project Properties.
5
 * To change this template file, choose Tools | Templates
6
 * and open the template in the editor.
7
 */
8
 
9
class SyndicationOutils {
10
 
11
	private $conteneur;
12
	private $contexte;
13
 
14
	public function __construct($conteneur) {
15
		$this->conteneur = $conteneur;
16
		$this->contexte = $this->conteneur->getContexte();
17
	}
18
 
19
	/**
20
	 * Verifier si le flux admin est demande
21
	 */
22
	public function fluxAdminDemande() {
23
		return $this->contexte->getQS('admin') != null && $this->contexte->getQS('admin') == 1;
24
	}
25
 
2155 mathias 26
	// @TODO ne devrait plus être utilisé
27
	// @TODO réécrire si nécessaire
1822 jpm 28
	public function demanderAutorisationAdmin() {
2155 mathias 29
		throw new Exception("méthode obsolète - utiliser le SSO à la place"); // fuk lé jandarme
30
		//$verification = $this->conteneur->getControleAcces();
31
		//$verification->demanderAuthentificationAdmin();
1822 jpm 32
	}
33
 
34
	/**
35
	 * Générer les métadonnées du flux (titre, dates, editeur etc.)
36
	 * */
37
	public function construireDonneesCommunesAuFlux($nomFlux, $dateDernierElement) {
38
		$donnees = array();
39
		$donnees['guid'] = $this->creerUrlService();
40
		$donnees['titre'] = $this->conteneur->getParametre("syndication.{$nomFlux}_titre");
41
		$donnees['description'] = $this->conteneur->getParametre("syndication.{$nomFlux}_dsc");
42
		$donnees['lien_service'] = $this->creerUrlService();
43
		$donnees['lien_del'] = $this->conteneur->getParametre('img_appli_lien');
44
		$donnees['editeur'] = $this->conteneur->getParametre('syndication.editeur');
45
		$date_modification_timestamp = strtotime($dateDernierElement);
46
		$donnees['date_maj_RSS'] = date(DATE_RSS, $date_modification_timestamp);
47
		$donnees['date_maj_ATOM'] = date(DATE_ATOM, $date_modification_timestamp);
48
		$donnees['date_maj_W3C'] = date(DATE_W3C, $date_modification_timestamp);
49
		$donnees['annee_courante'] = date('Y');
50
		$donnees['generateur'] =  $this->conteneur->getParametre("syndication.generateur_nom");
51
		$donnees['generateur_version'] =  $this->conteneur->getParametre("syndication.generateur_version");
52
		return $donnees;
53
	}
54
 
55
	public function creerUrlService() {
56
		$url = 'http://'.
57
			$this->contexte->getServer('SERVER_NAME').
58
			$this->contexte->getServer('REQUEST_URI');
59
		return htmlspecialchars($url);
60
	}
61
 
62
	public function getUrlImage($id, $format = 'L') {
63
		$url_tpl = $this->conteneur->getParametre('cel_img_url_tpl');
1840 jpm 64
		$url = sprintf($url_tpl, $id, $format);
1822 jpm 65
		return $url;
66
	}
67
 
68
	public function convertirDateHeureMysqlEnTimestamp($date_heure_mysql){
69
		$timestamp = 0;
70
		// Le date de 1970-01-01 pose problème dans certains lecteur de Flux, on met donc la date de création de Tela
71
		$date_heure_mysql = ($date_heure_mysql == '0000-00-00 00:00:00') ? '1999-12-14 00:00:00' : $date_heure_mysql;
72
		if ($date_heure_mysql != '0000-00-00 00:00:00') {
73
			$val = explode(' ', $date_heure_mysql);
74
			$date = explode('-', $val[0]);
75
			$heure = explode(':', $val[1]);
76
			$timestamp = mktime((int) $heure[0], (int) $heure[1], (int) $heure[2], (int) $date[1], (int) $date[2], (int) $date[0]);
77
		}
78
		return $timestamp;
79
	}
80
}