/branches/v1.2-lithium/services/modules/0.1/Syndication.php |
---|
14,7 → 14,6 |
*/ |
class Syndication extends RestService { |
private $parametres = array(); |
private $ressources = array(); |
private $methode = null; |
25,13 → 24,13 |
private $formats_autorises = null; |
private $conteneur; |
/** Indique si oui (true) ou non (false), on veut utiliser les paramètres bruts. */ |
protected $utilisationParametresBruts = true; |
public function __construct() { |
$this->cheminCourant = dirname(__FILE__).DS; |
$this->squelette_dossier = dirname(__FILE__).DIRECTORY_SEPARATOR.'syndication'.DIRECTORY_SEPARATOR.'squelettes'.DIRECTORY_SEPARATOR; |
$this->squelette_dossier = dirname(__FILE__).DS.'syndication'.DS.'squelettes'.DS; |
} |
public function consulter($ressources, $parametres) { |
52,14 → 51,13 |
$corps = $reponseHttp->getCorps(); |
return $corps; |
} |
private function initialiserRessourcesEtParametres($ressources, $parametres) { |
$this->ressources = $ressources; |
$this->parametres = $parametres; |
} |
private function verifierRessourcesEtParametres() { |
$servicesDispos = Config::get('servicesDispo'); |
if (!isset($this->ressources[0]) || !in_array($this->ressources[0], explode(',',$servicesDispos))) { |
$message = "Vous devez indiquer un nom de service valide, les services disponibles sont ".$servicesDispos; |
66,7 → 64,7 |
$code = RestServeur::HTTP_CODE_ERREUR; |
throw new Exception($message, $code); |
} |
$chaineFormatsAutorises = Config::get('formatsRss'); |
$this->formats_autorises = explode(',', $chaineFormatsAutorises); |
if (!isset($this->ressources[1]) || !in_array($this->ressources[1], $this->formats_autorises)) { |
81,15 → 79,13 |
private function traiterRessources() { |
$retour = ''; |
$retour = $this->initialiserService(); |
return $retour; |
} |
private function creerResultatService($donnees) { |
$resultat = new ResultatService(); |
$resultat->mime = $this->getTypeMime(); |
$resultat->corps = SquelettePhp::analyser($this->squelette_dossier.$this->format.'.tpl.xml', $donnees); |
return $resultat; |
} |
112,7 → 108,7 |
------------------------------------------------------------------------------------------------------------------*/ |
private function initialiserService() { |
$this->chargerNomService(); |
$classe = $this->obtenirNomClasseService($this->serviceNom); |
$chemins = array(); |
$chemins[] = $this->cheminCourant.$this->projetNom.DS.$classe.'.php'; |
121,7 → 117,7 |
$service = null; |
foreach ($chemins as $chemin) { |
if (file_exists($chemin)) { |
$this->conteneur->chargerConfiguration('config_'.$this->projetNom.'.ini'); |
$this->conteneur->chargerConfiguration('config_'.$this->projetNom.'.ini'); |
require_once $chemin; |
$service = new $classe($this->conteneur); |
if ($this->methode == 'consulter') { |
129,7 → 125,7 |
} |
} |
} |
if (is_null($service)) { |
$message = "Le service demandé '{$this->serviceNom}' n'existe pas dans le projet {$this->projetNom} !"; |
$code = RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE; |
137,7 → 133,7 |
} |
return $retour; |
} |
private function chargerNomService() { |
if (!isset($this->ressources[0])) { |
$message = "Vous devez indiquer un nom de service"; |
152,7 → 148,7 |
$classeNom = 'Syndication'.ucwords($mot); |
return $classeNom; |
} |
private function getTypeMime() { |
$mime = ''; |
switch ($this->format) { |
/branches/v1.2-lithium/services/modules/0.1/syndication/SyndicationTagsParProtocole.php |
---|
169,13 → 169,13 |
} |
private function creerGuidItem($element) { |
$guid = sprintf($this->conteneur->getParametre('tagParProtocole'), $element['id_tag']); |
$guid = sprintf($this->conteneur->getParametre('tagGuidTpl'), $element['id_tag']); |
return $guid; |
} |
private function creerLienItem($element) { |
// TODO : ajouter un lien vers la plateforme validation de picto lorsqu'elle sera dispo |
$lien = $this->conteneur->getParametre('pictofloraFicheObsTpl'); |
$lien = sprintf($this->conteneur->getParametre('imgFicheTpl'), $element['id_image']); |
return $lien; |
} |
/branches/v1.2-lithium/services/modules/0.1/syndication/SyndicationVotesParProtocole.php |
---|
168,12 → 168,12 |
} |
private function creerGuidItem($element) { |
$guid = sprintf($this->conteneur->getParametre('voteParProtocole'), $element['id_vote']); |
$guid = sprintf($this->conteneur->getParametre('voteGuidTpl'), $element['id_vote']); |
return $guid; |
} |
private function creerLienItem($element) { |
$lien = sprintf($this->conteneur->getParametre('pictofloraFicheObsTpl'), $element['id_observation']); |
$lien = sprintf($this->conteneur->getParametre('imgFicheTpl'), $element['id_image']); |
return $lien; |
} |
/branches/v1.2-lithium/services/modules/0.1/syndication/squelettes/opml.tpl.xml |
---|
5,14 → 5,14 |
</head> |
<body> |
<outline text="DEL"> |
<?php foreach ($liste_flux as $flux) : ?> |
<outline title="<?=$flux['titre']?>" |
description="<?=$flux['description']?>" |
htmlUrl="<?=$flux['url_html']?>" |
xmlUrl="<?=$flux['url_xml']?>" |
type="<?=$flux['type']?>" |
text="<?=$flux['texte']?>"/> |
<?php endforeach; ?> |
<?php foreach ($liste_flux as $flux) : ?> |
<outline title="<?=$flux['titre']?>" |
description="<?=$flux['description']?>" |
htmlUrl="<?=$flux['url_html']?>" |
xmlUrl="<?=$flux['url_xml']?>" |
type="<?=$flux['type']?>" |
text="<?=$flux['texte']?>"/> |
<?php endforeach; ?> |
</outline> |
</body> |
</opml> |
/branches/v1.2-lithium/services/modules/0.1/syndication/squelettes/rss2.tpl.xml |
---|
5,22 → 5,21 |
<link><?=$lien_service?></link> |
<atom:link href="<?=$lien_service?>" rel="self" type="application/rss+xml" /> |
<description><?=$description?></description> |
<?php if (isset($items)) : ?> |
<?php foreach ($items as $item) : ?> |
<item> |
<guid><?=$item['guid']?></guid> |
<title><?=$item['titre']?></title> |
<? if (isset($item['lien'])) : ?> |
<link><?=$item['lien']?></link> |
<? endif; ?> |
<description><?=$item['description_encodee']?></description> |
<category><?= $item['categorie'] ?></category> |
<author><?=$item['modifier_par']?></author> |
<pubDate><?=$item['date_maj_RSS']?></pubDate> |
</item> |
<?php endforeach; ?> |
<?php foreach ($items as $item) : ?> |
<item> |
<guid><?=$item['guid']?></guid> |
<title><?=$item['titre']?></title> |
<? if (isset($item['lien'])) : ?> |
<link><?=$item['lien']?></link> |
<? endif; ?> |
<description><?=$item['description_encodee']?></description> |
<category><?= $item['categorie'] ?></category> |
<author><?=$item['modifier_par']?></author> |
<pubDate><?=$item['date_maj_RSS']?></pubDate> |
</item> |
<?php endforeach; ?> |
<?php endif; ?> |
</channel> |
</rss> |
/branches/v1.2-lithium/services/modules/0.1/syndication/squelettes/atom.tpl.xml |
---|
1,6 → 1,5 |
<?php echo '<?xml version="1.0" encoding="UTF-8"?>'."\n";?> |
<feed xmlns="http://www.w3.org/2005/Atom"> |
<title><?=$titre?></title> |
<link href="<?=$lien_service?>" rel="alternate" type="text/html" hreflang="fr" /> |
<link href="<?=$lien_service?>" rel="self" type="application/atom+xml"/> |
11,26 → 10,24 |
<id><?=$guid?></id> |
<rights>Copyright (c) <?=$annee_courante?>, <?=$editeur?></rights> |
<generator uri="<?=$lien_service?>" version="<?=$generateur_version?>"><?=$generateur?></generator> |
<?php if (isset($items)) : ?> |
<?php foreach ($items as $item) : ?> |
<entry> |
<id><?=$item['guid']?></id> |
<title><?=$item['titre']?></title> |
<? if (isset($item['lien'])) : ?> |
<link href="<?=$item['lien']?>"/> |
<? endif; ?> |
<updated><?=$item['date_maj_ATOM']?></updated> |
<published><?=$item['date_maj_ATOM']?></published> |
<author><name><?=$item['modifier_par']?></name></author> |
<content type="xhtml" xml:lang="fr"> |
<div xmlns="http://www.w3.org/1999/xhtml"> |
<?=$item['description'];?> |
</div> |
</content> |
</entry> |
<?php endforeach; ?> |
<?php foreach ($items as $item) : ?> |
<entry> |
<id><?=$item['guid']?></id> |
<title><?=$item['titre']?></title> |
<? if (isset($item['lien'])) : ?> |
<link href="<?=$item['lien']?>"/> |
<? endif; ?> |
<updated><?=$item['date_maj_ATOM']?></updated> |
<published><?=$item['date_maj_ATOM']?></published> |
<author><name><?=$item['modifier_par']?></name></author> |
<content type="xhtml" xml:lang="fr"> |
<div xmlns="http://www.w3.org/1999/xhtml"> |
<?=$item['description'];?> |
</div> |
</content> |
</entry> |
<?php endforeach; ?> |
<?php endif; ?> |
</feed> |
/branches/v1.2-lithium/services/modules/0.1/syndication/SyndicationCommentaires.php |
---|
91,7 → 91,7 |
$donnees['titre'] = 'identiPlante : commentaires et propositions'; |
$donnees['description'] = 'Ce flux regroupe les dernières déterminations et commentaires rédigés dans l\'application identiPlante'; |
$donnees['lien_service'] = htmlspecialchars($this->creerUrlService()); |
$donnees['lien_del'] = $this->conteneur->getParametre('delAppliLien'); |
$donnees['lien_del'] = $this->conteneur->getParametre('obsAppliLien'); |
$donnees['editeur'] = $this->conteneur->getParametre('editeur'); |
$derniere_info_en_date = reset($infos); |
$date_modification_timestamp = $this->convertirDateHeureMysqlEnTimestamp($derniere_info_en_date['date']); |
160,12 → 160,12 |
} |
private function creerGuidItem($element) { |
$guid = sprintf($this->conteneur->getParametre('guidObsTpl'), $element['id_commentaire']); |
$guid = sprintf($this->conteneur->getParametre('commentaireGuidTpl'), $element['id_commentaire']); |
return $guid; |
} |
private function creerLienItem($element) { |
$lien = sprintf($this->conteneur->getParametre('delFicheObsTpl'), $element['dob_id_observation']); |
$lien = sprintf($this->conteneur->getParametre('obsFicheTpl'), $element['dob_id_observation']); |
return $lien; |
} |