|
|
|
@ -68,6 +68,9 @@ function territoire_informer_ascendance($iso_territoire, $iso_parent = null, $or
|
|
|
|
|
*/
|
|
|
|
|
function territoire_lister_pays($type = '', $categorie = '') {
|
|
|
|
|
|
|
|
|
|
// Initialisation de la sortie en erreur
|
|
|
|
|
$pays = array();
|
|
|
|
|
|
|
|
|
|
// Filtre sur la catégorie et le type si demandé
|
|
|
|
|
$where = array();
|
|
|
|
|
if ($categorie) {
|
|
|
|
@ -82,17 +85,20 @@ function territoire_lister_pays($type = '', $categorie = '') {
|
|
|
|
|
// -- ou simplement tous les pays (type = country).
|
|
|
|
|
if ($type === 'country') {
|
|
|
|
|
$select = array('t1.iso_territoire as pays', 't1.nom_usage');
|
|
|
|
|
$pays = sql_allfetsel($select, 'spip_territoires as t1', $where);
|
|
|
|
|
$liste = sql_allfetsel($select, 'spip_territoires as t1', $where);
|
|
|
|
|
} else {
|
|
|
|
|
$from = array('spip_territoires as t1', 'spip_territoires as t2');
|
|
|
|
|
$select = array('t1.iso_pays as pays', 't2.nom_usage');
|
|
|
|
|
$where[] = 't1.iso_pays = t2.iso_territoire';
|
|
|
|
|
$group_by = array('t1.iso_pays');
|
|
|
|
|
$pays = sql_allfetsel($select, $from, $where, $group_by);
|
|
|
|
|
$liste = sql_allfetsel($select, $from, $where, $group_by);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($pays) {
|
|
|
|
|
$pays = array_column($pays, 'nom_usage', 'pays');
|
|
|
|
|
if ($liste) {
|
|
|
|
|
include_spip('inc/filtres');
|
|
|
|
|
foreach ($liste as $_pays) {
|
|
|
|
|
$pays[$_pays['pays']] = extraire_multi($_pays['nom_usage']);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $pays;
|
|
|
|
@ -128,10 +134,10 @@ function territoire_lister_categorie($type = '', $pays = '') {
|
|
|
|
|
$where[] = 'iso_pays=' . sql_quote($pays);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$ids_categorie = sql_allfetsel($select, 'spip_territoires', $where, $group_by);
|
|
|
|
|
if ($ids_categorie) {
|
|
|
|
|
foreach ($ids_categorie as $_id_categorie) {
|
|
|
|
|
$categorie = $_id_categorie['categorie'];
|
|
|
|
|
$liste = sql_allfetsel($select, 'spip_territoires', $where, $group_by);
|
|
|
|
|
if ($liste) {
|
|
|
|
|
foreach ($liste as $_categorie) {
|
|
|
|
|
$categorie = $_categorie['categorie'];
|
|
|
|
|
$categories[$categorie] = _T("territoire:categorie_${categorie}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|