/** * This function display the informations related to the addresses whom idHistoriqueAdresse is given in param * * @param array of idHistorique $idList : a list of idHistoriqueAdresse to display * @return $html : the list of addresses to display */ public function displayList($idList = array(), $nbResult = 0) { $html = ""; //Template loading $t = new Template('modules/archi/templates/'); $t->set_filenames(array('addressesList' => 'addressesList.tpl')); if (empty($idList)) { $t->assign_vars(array('messageInfo' => "Aucun résultat !", 'titre' => 'Résultats')); $this->messages->addWarning("Aucun résultat à afficher."); $this->messages->display(); } else { $starttime = microtime(true); $optionsPagination = array('nbResult' => 0, 'nbPages' => 0, 'currentPage' => 0, 'nextPage' => 0, 'previousPage' => 0, 'nbResultPerPage' => 10, 'offset' => 4); //Pagination display if (isset($this->variablesGet['debut']) && $this->variablesGet['debut'] != '') { $optionsPagination['currentPage'] = $this->variablesGet['debut'] / $optionsPagination['nbResultPerPage']; } else { $optionsPagination['debut'] = 0; $optionsPagination['currentPage'] = 0; } $addressesInfromations = $this->getAddressesInfoFromIdHA($idList, $optionsPagination); if ($nbResult > 1) { $optionsPagination['nbResult'] = $nbResult; $nbReponses = $nbResult; $optionsPagination['nbPages'] = ceil($nbReponses / $optionsPagination['nbResultPerPage']); if ($optionsPagination['currentPage'] < $optionsPagination['nbPages']) { $optionsPagination['nextPage'] = $optionsPagination['currentPage'] + 1; } else { $optionsPagination['nextPage'] = $optionsPagination['nbPages']; } if ($optionsPagination['currentPage'] > 1) { $optionsPagination['previousPage'] = $optionsPagination['currentPage'] - 1; } else { $optionsPagination['previousPage'] = 1; } $url = array(); //Call link generation $url = $this->generatePaginationLinks($optionsPagination); $nbReponses .= " réponses"; } else { $nbReponses = $nbResult . " réponse"; } $t->assign_vars(array('nbReponses' => $nbReponses, 'titre' => 'Résultats')); // Template filling $paramsUrlDesc = $this->variablesGet; $paramsUrlAsc = $this->variablesGet; $paramsUrlDesc['order'] = "desc"; $paramsUrlAsc['order'] = "asc"; $urlAsc = $this->creerUrl('', '', $paramsUrlAsc); $urlDesc = $this->creerUrl('', '', $paramsUrlDesc); $t->assign_block_vars('liens', array('urlDesc' => $urlAsc, 'urlAsc' => $urlDesc)); //Generating next/previous pagination link $siblingIndex = $this->getNextPreviousPages($optionsPagination['currentPage'], $optionsPagination['nbPages']); $indexToDisplay = $this->getPaginationIndex($optionsPagination); foreach ($indexToDisplay as $indexPage) { $t->assign_block_vars('nav', array('urlNbOnClick' => '', 'urlNb' => $url[$indexPage], 'nb' => $indexPage + 1, 'urlPrecendant' => $url[$siblingIndex['previousPage']], 'urlSuivant' => $url[$siblingIndex['nextPage']])); // Dirty hack for displaying strong tag on current page if ($indexPage == $optionsPagination['currentPage']) { $t->assign_block_vars('nav.courant', array()); } } $t->assign_block_vars('urlNextPagination', array('urlSuivant' => $url[$siblingIndex['nextPage']])); $t->assign_block_vars('urlBackPagination', array('urlPrecedent' => $url[$siblingIndex['previousPage']])); /* * Addresses display * Loop on each address infos * * * Structure of $info : * * Array ( [nom] => 22 rue du général castelnau [idHistoriqueAdresse] => 2 [idAdresse] => 2 [idEvenementGroupeAdresse] => 1289 [titresEvenements] => Array ( [0] => 22 rue du général castelnau [1] => Photos de nuit [2] => Visite des appartements [3] => Evenement sans titre [4] => Visite des parties communes [5] => détails art nouveau ) ) */ foreach ($addressesInfromations as $info) { $titreEvenements = ""; $illustration = $this->getUrlImageFromAdresse($info['idHistoriqueAdresse'], 'moyen', array('idEvenementGroupeAdresse' => $info['idEvenementGroupeAdresse'], 'placeholder' => "images/placeholder.jpg")); //Processing name of the address $nom = ucfirst($info['nom']); $fulladdress = ucfirst($this->getIntituleAdresseFrom($info['idEvenementGroupeAdresse'], $type = 'idEvenementGroupeAdresse')); $titre = $info['titre']; $input = array('idEvenementGA' => $info['idEvenementGroupeAdresse'], 'idAdresse' => $info['idAdresse']); $intituleAdresse = ""; if (isset($titre) && !empty($titre) && $titre != '') { $intituleAdresse = "<b>" . $titre . "</b> "; } $intituleAdresse .= $fulladdress . ' '; $arrayUrl = $this->generateUrlListAddresses($input, $this->variablesGet['modeAffichage'], $intituleAdresse); //Regular case //Personne case if (isset($info['idPersonne']) && $info['idPersonne'] != '') { $urlImageIllustration = archiPersonne::getImage($info['idPersonne'], 'resized', true, array('height' => 130, 'width' => 130)); $addressUrl = $this->creerUrl('', 'evenementListe', array('selection' => 'personne', "id" => $info['idPersonne'])); $titre = $info['nom']; $urlDetailOnClick = ''; } else { $urlImageIllustration = $illustration['url']; $addressUrl = $this->creerUrl('', '', array('archiAffichage' => 'adresseDetail', "archiIdAdresse" => $info['idAdresse'], "archiIdEvenementGroupeAdresse" => $info['idEvenementGroupeAdresse'])); $addressUrl = $arrayUrl['urlDetailHref']; $urlDetailOnClick = $arrayUrl['urlDetailOnClick']; } // Event title $titreEvenements = implode(" - ", $info['titresEvenements']); // Getting all the events links on one line $modeAffichage = $this->variablesGet['modeAffichage']; if ($modeAffichage == 'calqueImage' || $modeAffichage == 'calqueImageChampsMultiples' || $modeAffichage == 'calqueImageChampsMultiplesRetourSimple' || $modeAffichage == 'calqueEvenement' || $modeAffichage == 'popupRechercheAdressePrisDepuis' || $modeAffichage == 'popupRechercheAdresseVueSur' || $modeAffichage == "popupAjoutAdressesLieesSurEvenement" || $modeAffichage == "popupDeplacerEvenementVersGroupeAdresse" || $modeAffichage == 'popupRechercheAdresseAdminParcours') { $titreEvenements = ""; } else { $titreEvenements = implode(" - ", $info['titresEvenements']); // Getting all the events links on one line } $t->assign_block_vars('adresses', array('nom' => $titre, 'adresseComplete' => $fulladdress, 'urlImageIllustration' => $urlImageIllustration, 'alt' => $nom, 'urlDetailHref' => $addressUrl, 'titresEvenements' => $titreEvenements, 'urlDetailOnClick' => $urlDetailOnClick)); } //End foreach } //End else (regular display w/ errors) //Filling template, getting content, returning it ob_start(); $t->pparse('addressesList'); $html .= ob_get_contents(); ob_end_clean(); return $html; }
/** * Affiche la liste des personnes liées à une source * * @param int $idSource ID de la source * * @return void * */ public static function getPersonsFromSource($idSource) { global $config; $req = "SELECT idEvenement\n FROM `historiqueEvenement`\n WHERE `idSource` =" . $idSource; $res = $config->connexionBdd->requete($req); $e = new archiEvenement(); while ($event = mysql_fetch_object($res)) { $idEvenementGroupeAdresse = $e->getIdEvenementGroupeAdresseFromIdEvenement($event->idEvenement); if ($idPerson = archiPersonne::isPerson($idEvenementGroupeAdresse)) { $person = new archiPersonne($idPerson); $people[] = $person->getInfosPersonne($idPerson); } } if (isset($people)) { $already = array(); print "<b>Voici la liste des personnes auxquelles cette source est attachée</b>"; print '<table class="results">'; foreach ($people as $person) { if (!in_array($person['idPersonne'], $already)) { $already[] = $person['idPersonne']; print '<tr class="listAddressItem"> <td><a href="' . $config->creerUrl("", "evenementListe", array("selection" => "personne", "id" => $person['idPersonne'])) . '"><img src="' . archiPersonne::getImage($person['idPersonne'], "mini", false) . '" border=0 alt=""></a> <span><br/><a href="' . $config->creerUrl("", "evenementListe", array("selection" => "personne", "id" => $person['idPersonne'])) . '" >' . stripslashes($person['prenom'] . " " . $person['nom']) . '</a></span><br/><span style="font-size:11px;">' . $person['nomMetier'] . '</span></td> </tr>'; } } print '</table>'; } }