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
 
26
	public function demanderAutorisationAdmin() {
27
		$verification = $this->conteneur->getControleAcces();
28
		$verification->demanderAuthentificationAdmin();
29
	}
30
 
31
	/**
32
	 * Générer les métadonnées du flux (titre, dates, editeur etc.)
33
	 * */
34
	public function construireDonneesCommunesAuFlux($nomFlux, $dateDernierElement) {
35
		$donnees = array();
36
		$donnees['guid'] = $this->creerUrlService();
37
		$donnees['titre'] = $this->conteneur->getParametre("syndication.{$nomFlux}_titre");
38
		$donnees['description'] = $this->conteneur->getParametre("syndication.{$nomFlux}_dsc");
39
		$donnees['lien_service'] = $this->creerUrlService();
40
		$donnees['lien_del'] = $this->conteneur->getParametre('img_appli_lien');
41
		$donnees['editeur'] = $this->conteneur->getParametre('syndication.editeur');
42
		$date_modification_timestamp = strtotime($dateDernierElement);
43
		$donnees['date_maj_RSS'] = date(DATE_RSS, $date_modification_timestamp);
44
		$donnees['date_maj_ATOM'] = date(DATE_ATOM, $date_modification_timestamp);
45
		$donnees['date_maj_W3C'] = date(DATE_W3C, $date_modification_timestamp);
46
		$donnees['annee_courante'] = date('Y');
47
		$donnees['generateur'] =  $this->conteneur->getParametre("syndication.generateur_nom");
48
		$donnees['generateur_version'] =  $this->conteneur->getParametre("syndication.generateur_version");
49
		return $donnees;
50
	}
51
 
52
	public function creerUrlService() {
53
		$url = 'http://'.
54
			$this->contexte->getServer('SERVER_NAME').
55
			$this->contexte->getServer('REQUEST_URI');
56
		return htmlspecialchars($url);
57
	}
58
 
59
	public function getUrlImage($id, $format = 'L') {
60
		$url_tpl = $this->conteneur->getParametre('cel_img_url_tpl');
1840 jpm 61
		$url = sprintf($url_tpl, $id, $format);
1822 jpm 62
		return $url;
63
	}
64
 
65
	public function convertirDateHeureMysqlEnTimestamp($date_heure_mysql){
66
		$timestamp = 0;
67
		// Le date de 1970-01-01 pose problème dans certains lecteur de Flux, on met donc la date de création de Tela
68
		$date_heure_mysql = ($date_heure_mysql == '0000-00-00 00:00:00') ? '1999-12-14 00:00:00' : $date_heure_mysql;
69
		if ($date_heure_mysql != '0000-00-00 00:00:00') {
70
			$val = explode(' ', $date_heure_mysql);
71
			$date = explode('-', $val[0]);
72
			$heure = explode(':', $val[1]);
73
			$timestamp = mktime((int) $heure[0], (int) $heure[1], (int) $heure[2], (int) $date[1], (int) $date[2], (int) $date[0]);
74
		}
75
		return $timestamp;
76
	}
77
}