24,11 → 24,10 |
|
const DS = DIRECTORY_SEPARATOR; |
const SERVICE_DEFAUT = 'photo'; |
|
private $ce_img_url_tpl = null; |
private $del_url_service_tpl = null; |
|
private $id_observation_suivant = null; |
private $id_observation_precedent = null; |
private $id_observation = null; |
|
/** |
72,15 → 71,16 |
} |
|
private function convertirParametresEnChaineRequeteService() { |
$requete = ''; |
$mapping = $this->config['mapping_masque']; |
$parametresWs = array(); |
$mapping = $this->transformerEnTableau($this->config['vote']['mapping_masque']); |
if(!empty($this->parametres)) { |
foreach ($this->parametres as $parametre=>$valeur) { |
if (isset($mapping[$parametre])) { |
$requete .= '&'.$mapping[$parametre].'='.urlencode($valeur); |
$parametresWs[] = $mapping[$parametre].'='.urlencode($valeur); |
} |
} |
} |
$requete = (!empty($parametresWs)) ? '?'.implode('&', $parametresWs) : ''; |
return $requete; |
} |
|
93,12 → 93,19 |
} |
|
private function obtenirIdsObservation() { |
$ids = json_decode(file_get_contents($this->del_url_service_tpl.'observations?retour.format=widget'.$this->convertirParametresEnChaineRequeteService()), true); |
$url = $this->del_url_service_tpl.'observations'.$this->convertirParametresEnChaineRequeteService(); |
//exit('<pre>'.print_r($url, true).'</pre>'); |
$infos = json_decode(file_get_contents($url), true); |
//exit('<pre>'.print_r($infos, true).'</pre>'); |
$ids = array(); |
foreach ($infos['resultats'] as $resultat) { |
if($this->id_observation == null) { |
$this->id_observation = $ids['resultats'][0]; |
$this->id_observation = $resultat['id_observation']; |
} |
return $ids['resultats']; |
$ids[] = $resultat['id_observation']; |
} |
return $ids; |
} |
|
private function obtenirUrlBaseWidget() { |
return $this->config['chemins']['baseURL'].'vote'; |
105,7 → 112,6 |
} |
|
private function construireUrlsSuivantesEtPrecedentes($tableau_id_observation) { |
|
$indices_id_obs = array_flip($tableau_id_observation); |
$indice_obs_courante = $indices_id_obs[$this->id_observation]; |
$url_base = $this->obtenirUrlBaseWidget(); |
116,13 → 122,12 |
$url_suivant = isset($tableau_id_observation[$indice_obs_courante + 1]) ? $url_base.'?id_observation='.$tableau_id_observation[$indice_obs_courante + 1].$this->convertirParametresEnChaineRequete() : null; |
$url_precedent = isset($tableau_id_observation[$indice_obs_courante - 1]) ? $url_base.'?id_observation='.$tableau_id_observation[$indice_obs_courante - 1].$this->convertirParametresEnChaineRequete() : null; |
|
return array('url_suivant' => $url_suivant, |
'url_precedent' => $url_precedent |
); |
return array('url_suivant' => $url_suivant, 'url_precedent' => $url_precedent); |
} |
|
private function obtenirDonnees($id_observation) { |
$donnees = json_decode(file_get_contents($this->del_url_service_tpl.'observations/'.$id_observation), true); |
//exit('<pre>'.print_r($donnees, true).'</pre>'); |
return $donnees; |
} |
|
137,14 → 142,11 |
private function formaterDeterminations($observation) { |
$liste_determinations = $observation['commentaires']; |
$liste_determinations_formatees = array(); |
|
$creerPropositionAPartirObservation = true; |
|
foreach ($liste_determinations as $determination) { |
$determination_formatee = $determination; |
if($determination['nom_sel'] != null && $determination['nom_sel'] != '') { |
$determination_formatee['votes'] = $this->formaterVotes($determination['votes']); |
$liste_determinations_formatees[] = $determination_formatee; |
$liste_determinations_formatees[] = $this->formaterDetermination($determination); |
} |
|
if($determination['nom_sel'] == $observation['determination.ns'] && |
160,23 → 162,47 |
return $liste_determinations_formatees; |
} |
|
private function formaterDetermination($infos) { |
//exit('<pre>'.print_r($infos, true).'</pre>'); |
$determination = array( |
"id_commentaire" => $infos['id_commentaire'], |
"observation" => $infos['observation'], |
"proposition" => $infos['proposition'], |
"id_parent" => $infos['id_parent'], |
"texte" => $infos['texte'], |
"date" => $infos['date_observation'], |
"nom_sel" => $infos['nom_sel'], |
"auteur_intitule" => $this->formaterIntituleAuteur($infos), |
"votes" => $this->formaterVotes($infos['votes']) |
); |
return $determination; |
} |
|
private function creerDeterminationAPartirObservation($observation) { |
$proposition = array("id_commentaire" => "0", |
$determination = array( |
"id_commentaire" => "0", |
"observation" => $observation['id_observation'], |
"proposition" => "0", |
"id_parent" => "0", |
"auteur.id" => $observation['auteur.id'], |
"texte" => null, |
"auteur.nom" => $observation['auteur.nom'], |
"auteur.prenom" => $observation['auteur.prenom'], |
"auteur.courriel" => $observation['observateur'], |
"date" => $observation['date_observation'], |
"nom_sel" => $observation['determination.ns'], |
"auteur_intitule" => $this->formaterIntituleAuteur($observation), |
"votes" => array('oui' => 0, 'non' => 0) |
); |
return $determination; |
} |
|
return $proposition; |
private function formaterIntituleAuteur($donnees) { |
$intitule = 'Anonyme'; |
// TODO : si auteur.id existe, appelé le WS de l'annuaire... |
if (!empty($donnees['auteur.prenom']) && !empty($donnees['auteur.nom'])) { |
$intitule = $donnees['auteur.prenom'].' '.$donnees['auteur.nom']; |
} else if (!empty($donnees['auteur.courriel'])) { |
$intitule = strstr($donnees['auteur.courriel'], '@').'@...'; |
} |
return $intitule; |
} |
|
private function formaterVotes($liste_votes) { |
$liste_votes_formates = array('oui' => 0, 'non' => 0); |
187,7 → 213,6 |
$liste_votes_formates['non']++; |
} |
} |
|
return $liste_votes_formates; |
} |
|
201,8 → 226,6 |
} |
} |
} |
|
return $tableau_js; |
} |
} |
?> |
} |