3 changed files with 554 additions and 548 deletions
@ -1,58 +1,60 @@
|
||||
<?php |
||||
/** |
||||
* Ce fichier contient l'action `rubrique_prefixe_generer` utilisée lors de la migration |
||||
* pour actualiser le préfixe des rubrique-plugin à partir de l'url sur Plugins SPIP si elle existe. |
||||
* |
||||
*/ |
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return; |
||||
|
||||
/** |
||||
* Cette action permet d'actualiser le préfixe des rubrique-plugin à partir de l'url |
||||
* sur Plugins SPIP si elle existe. |
||||
* |
||||
* Cette action est réservée aux webmestres. Elle ne nécessite aucun argument. |
||||
* |
||||
* @return void |
||||
*/ |
||||
function action_rubrique_prefixe_generer_dist(){ |
||||
|
||||
// Securisation: aucun argument attendu. |
||||
|
||||
// Verification des autorisations |
||||
if (!autoriser('webmestre')) { |
||||
include_spip('inc/minipres'); |
||||
echo minipres(); |
||||
exit(); |
||||
} |
||||
|
||||
// Actualisation des rubriques-plugin : |
||||
// Un rubrique-plugin a une profondeur de 2 et est incluse dans un secteur-plugin. |
||||
// -- on récupère les secteurs-plugin |
||||
include_spip('inc:contrib_rubrique'); |
||||
$secteurs_plugin = rubrique_lister_secteur_plugin(); |
||||
|
||||
// -- on récupère les rubriques-plugin |
||||
$from = 'spip_rubriques'; |
||||
$where = array('profondeur=2', sql_in('id_secteur', $secteurs_plugin)); |
||||
$rubriques_plugin = sql_allfetsel('id_rubrique', $from, $where); |
||||
|
||||
if ($rubriques_plugin) { |
||||
// Pour chaque rubrique-plugin on identifie si il existe un article possédant une url_site |
||||
// pointant vers plugins spip car le basename est égal au préfixe (http[s]://plugins.spip.net/prefixe[.html]). |
||||
foreach ($rubriques_plugin as $_rubrique) { |
||||
$from = 'spip_articles'; |
||||
$where = array('id_rubrique=' . intval($_rubrique['id_rubrique'])); |
||||
if ($urls = sql_allfetsel('url_site', $from, $where)) { |
||||
foreach ($urls as $_url) { |
||||
if ($_url['url_site'] |
||||
and ((stripos($_url['url_site'], 'https://plugins.spip.net/') === 0) |
||||
or (stripos($_url['url_site'], 'http://plugins.spip.net/')))) { |
||||
$maj['prefixe'] = basename($_url['url_site'], '.html'); |
||||
sql_updateq('spip_rubriques', $maj, $where); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
<?php |
||||
/** |
||||
* Ce fichier contient l'action `rubrique_prefixe_generer` utilisée lors de la migration |
||||
* pour actualiser le préfixe des rubrique-plugin à partir de l'url sur Plugins SPIP si elle existe. |
||||
* |
||||
*/ |
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return; |
||||
|
||||
/** |
||||
* Cette action permet d'actualiser le préfixe des rubrique-plugin à partir de l'url |
||||
* sur Plugins SPIP si elle existe. |
||||
* |
||||
* Cette action est réservée aux webmestres. Elle ne nécessite aucun argument. |
||||
* |
||||
* @return void |
||||
*/ |
||||
function action_rubrique_prefixe_generer_dist(){ |
||||
|
||||
// Securisation: aucun argument attendu. |
||||
|
||||
// Verification des autorisations |
||||
if (!autoriser('webmestre')) { |
||||
include_spip('inc/minipres'); |
||||
echo minipres(); |
||||
exit(); |
||||
} |
||||
|
||||
// Actualisation des rubriques-plugin : |
||||
// Un rubrique-plugin a une profondeur de 2 et est incluse dans un secteur-plugin. |
||||
// -- on récupère les secteurs-plugin |
||||
include_spip('inc:contrib_rubrique'); |
||||
$secteurs_plugin = rubrique_lister_secteur_plugin(); |
||||
|
||||
// Pour limiter le nombre de rubriques récupérées, on boucle par secteur. |
||||
foreach ($secteurs_plugin as $_id_secteur) { |
||||
// -- on récupère les rubriques-plugin |
||||
$from = 'spip_rubriques'; |
||||
$where = array('id_secteur=' . intval($_id_secteur)); |
||||
$rubriques_plugin = sql_allfetsel('id_rubrique', $from, $where); |
||||
if ($rubriques_plugin) { |
||||
// Pour chaque rubrique-plugin on identifie si il existe un article possédant une url_site |
||||
// pointant vers plugins spip car le basename est égal au préfixe (http[s]://plugins.spip.net/prefixe[.html]). |
||||
foreach ($rubriques_plugin as $_rubrique) { |
||||
$from = 'spip_articles'; |
||||
$where = array('id_rubrique=' . intval($_rubrique['id_rubrique'])); |
||||
if ($urls = sql_allfetsel('url_site, id_article', $from, $where)) { |
||||
foreach ($urls as $_url) { |
||||
if ($_url['url_site'] |
||||
and ((stripos($_url['url_site'], 'https://plugins.spip.net/') === 0) |
||||
or (stripos($_url['url_site'], 'http://plugins.spip.net/') === 0))) { |
||||
$maj['prefixe'] = basename($_url['url_site'], '.html'); |
||||
sql_updateq('spip_rubriques', $maj, $where); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
@ -1,236 +1,239 @@
|
||||
<?php |
||||
if (!defined('_ECRIRE_INC_VERSION')) { |
||||
return; |
||||
} |
||||
|
||||
function rubrique_lire_profondeur($id_rubrique) { |
||||
|
||||
static $profondeurs = array(); |
||||
|
||||
if (!isset($profondeurs[$id_rubrique])) { |
||||
$from = 'spip_rubriques'; |
||||
$where = array('id_rubrique=' . intval($id_rubrique)); |
||||
$profondeurs[$id_rubrique] = sql_getfetsel('profondeur', $from, $where); |
||||
} |
||||
|
||||
return $profondeurs[$id_rubrique]; |
||||
} |
||||
|
||||
|
||||
function rubrique_lire_parent($id_rubrique) { |
||||
|
||||
static $ids_parent = array(); |
||||
|
||||
if (!isset($ids_parent[$id_rubrique])) { |
||||
$ids_parent[$id_rubrique] = 0; |
||||
|
||||
$from = 'spip_rubriques'; |
||||
$where = array('id_rubrique=' . intval($id_rubrique)); |
||||
$id = sql_getfetsel('id_parent', $from, $where); |
||||
if ($id !== null) { |
||||
$ids_parent[$id_rubrique] = $id; |
||||
} |
||||
} |
||||
|
||||
return $ids_parent[$id_rubrique]; |
||||
} |
||||
|
||||
|
||||
function rubrique_lire_secteur($id_rubrique) { |
||||
|
||||
static $ids_secteur = array(); |
||||
|
||||
if (!isset($ids_secteur[$id_rubrique])) { |
||||
$ids_secteur[$id_rubrique] = 0; |
||||
|
||||
$from = 'spip_rubriques'; |
||||
$where = array('id_rubrique=' . intval($id_rubrique)); |
||||
$id = sql_getfetsel('id_secteur', $from, $where); |
||||
if ($id !== null) { |
||||
$ids_secteur[$id_rubrique] = $id; |
||||
} |
||||
} |
||||
|
||||
return $ids_secteur[$id_rubrique]; |
||||
} |
||||
|
||||
|
||||
function rubrique_lire_categorie($id_rubrique) { |
||||
|
||||
static $categories = array(); |
||||
|
||||
if (!isset($ids_secteur[$id_rubrique])) { |
||||
$categories[$id_rubrique] = ''; |
||||
|
||||
$from = 'spip_rubriques'; |
||||
$where = array('id_rubrique=' . intval($id_rubrique)); |
||||
$categorie = sql_getfetsel('categorie', $from, $where); |
||||
if ($categorie !== null) { |
||||
$categories[$id_rubrique] = $categorie; |
||||
} |
||||
} |
||||
|
||||
return $categories[$id_rubrique]; |
||||
} |
||||
|
||||
|
||||
function rubrique_determiner_type($id_rubrique) { |
||||
|
||||
static $types = array(); |
||||
|
||||
if (!isset($types[$id_rubrique])) { |
||||
if (rubrique_dans_secteur_plugin($id_rubrique)) { |
||||
$types[$id_rubrique] = 'plugin'; |
||||
} elseif (rubrique_dans_secteur_apropos($id_rubrique)) { |
||||
$types[$id_rubrique] = 'apropos'; |
||||
} elseif (rubrique_dans_secteur_carnet($id_rubrique)) { |
||||
$types[$id_rubrique] = 'carnet'; |
||||
} elseif (rubrique_dans_secteur_galaxie($id_rubrique)) { |
||||
$types[$id_rubrique] = 'galaxie'; |
||||
} else { |
||||
$types[$id_rubrique] = ''; |
||||
} |
||||
} |
||||
|
||||
return $types[$id_rubrique]; |
||||
} |
||||
|
||||
function rubrique_determiner_couleur($categorie) { |
||||
|
||||
static $couleurs = array( |
||||
'auteur' => '1310b2', |
||||
'communication' => 'acbd70', |
||||
'date' => '471bb2', |
||||
'interactivite' => '50699b', |
||||
'contenu' => 'b22ba4', |
||||
'administration' => '09b2a3', |
||||
'multimedia' => 'de175f', |
||||
'navigation' => 'b26714', |
||||
'developpement' => 'dfb811', |
||||
'multilinguisme' => '11b23c', |
||||
'activite' => 'bd87c0', |
||||
'interface-publique' => '40dd5d', |
||||
); |
||||
|
||||
$couleur = (!$categorie or empty($couleurs[$categorie])) ? 'b9274d' : $couleurs[$categorie]; |
||||
|
||||
return $couleur; |
||||
} |
||||
|
||||
/** |
||||
* Vérifie que la rubrique concernée fait bien partie du secteur-apropos. |
||||
* Le secteur-apropos est déterminé par la configuration du secteur exclus dans |
||||
* le plugin Exclure Secteur. |
||||
* |
||||
* @param int $id |
||||
* Id de la rubrique concernée. |
||||
* |
||||
* @return bool |
||||
* True si la rubrique fait partie du secteur-apropos, false sinon. |
||||
*/ |
||||
function rubrique_dans_secteur_apropos($id_rubrique) { |
||||
|
||||
$est_apropos = false; |
||||
|
||||
include_spip('inc/config'); |
||||
$apropos = lire_config('secteur/exclure_sect', array()); |
||||
|
||||
if ($apropos and in_array(rubrique_lire_secteur($id_rubrique), $apropos)) { |
||||
$est_apropos = true; |
||||
} |
||||
|
||||
return $est_apropos; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* Vérifie que la rubrique concernée fait bien partie du secteur-carnet. |
||||
* Le secteur-carnet est déterminé par la configuration de l'espace wiki dans le plugin |
||||
* Autorité. |
||||
* |
||||
* @param int $id |
||||
* Id de la rubrique concernée. |
||||
* |
||||
* @return bool |
||||
* True si la rubrique fait partie du secteur-carnet, false sinon. |
||||
*/ |
||||
function rubrique_dans_secteur_carnet($id_rubrique) { |
||||
|
||||
$est_carnet = false; |
||||
|
||||
include_spip('inc/config'); |
||||
$carnet = lire_config('autorite/espace_wiki', array()); |
||||
|
||||
if ($carnet and in_array(rubrique_lire_secteur($id_rubrique), $carnet)) { |
||||
$est_carnet = true; |
||||
} |
||||
|
||||
return $est_carnet; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* Vérifie que la rubrique concernée fait bien partie du secteur-carnet. |
||||
* Le secteur-carnet est déterminé par la configuration de l'espace wiki dans le plugin |
||||
* Autorité. |
||||
* |
||||
* @param int $id |
||||
* Id de la rubrique concernée. |
||||
* |
||||
* @return bool |
||||
* True si la rubrique fait partie du secteur-carnet, false sinon. |
||||
*/ |
||||
function rubrique_dans_secteur_galaxie($id_rubrique) { |
||||
|
||||
$est_galaxie = false; |
||||
|
||||
include_spip('inc/config'); |
||||
$galaxie = lire_config('contrib/secteurs', array()); |
||||
|
||||
if ($galaxie and in_array(rubrique_lire_secteur($id_rubrique), $galaxie)) { |
||||
$est_galaxie = true; |
||||
} |
||||
|
||||
return $est_galaxie; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* Vérifie que la rubrique concernée fait bien partie d'un secteur-plugin. |
||||
* Il suffit de vérifier que le secteur a bien une catégorie non vide. |
||||
* |
||||
* @param int $id |
||||
* Id de la rubrique concernée. |
||||
* |
||||
* @return bool |
||||
* True si la rubrique fait partie d'un secteur-plugin, false sinon. |
||||
*/ |
||||
function rubrique_dans_secteur_plugin($id_rubrique) { |
||||
|
||||
static $est_plugin = array(); |
||||
|
||||
if (!isset($est_plugin[$id_rubrique])) { |
||||
$est_plugin[$id_rubrique] = false; |
||||
|
||||
if (rubrique_lire_categorie(rubrique_lire_secteur($id_rubrique))) { |
||||
$est_plugin[$id_rubrique] = true; |
||||
} |
||||
} |
||||
|
||||
return $est_plugin[$id_rubrique]; |
||||
} |
||||
|
||||
/** |
||||
* Récupère les id de tous les secteurs-plugin. |
||||
* |
||||
* @return array |
||||
* Liste des id des secteurs-pllugin ou tableau vide. |
||||
*/ |
||||
function rubrique_lister_secteur_plugin() { |
||||
|
||||
$from = 'spip_rubriques'; |
||||
$where = array('profondeur=0', 'categorie!=' . sql_quote('')); |
||||
$secteurs = sql_allfetsel('id_rubrique', $from, $where); |
||||
|
||||
return $secteurs; |
||||
} |
||||
<?php |
||||
if (!defined('_ECRIRE_INC_VERSION')) { |
||||
return; |
||||
} |
||||
|
||||
function rubrique_lire_profondeur($id_rubrique) { |
||||
|
||||
static $profondeurs = array(); |
||||
|
||||
if (!isset($profondeurs[$id_rubrique])) { |
||||
$from = 'spip_rubriques'; |
||||
$where = array('id_rubrique=' . intval($id_rubrique)); |
||||
$profondeurs[$id_rubrique] = sql_getfetsel('profondeur', $from, $where); |
||||
} |
||||
|
||||
return $profondeurs[$id_rubrique]; |
||||
} |
||||
|
||||
|
||||
function rubrique_lire_parent($id_rubrique) { |
||||
|
||||
static $ids_parent = array(); |
||||
|
||||
if (!isset($ids_parent[$id_rubrique])) { |
||||
$ids_parent[$id_rubrique] = 0; |
||||
|
||||
$from = 'spip_rubriques'; |
||||
$where = array('id_rubrique=' . intval($id_rubrique)); |
||||
$id = sql_getfetsel('id_parent', $from, $where); |
||||
if ($id !== null) { |
||||
$ids_parent[$id_rubrique] = $id; |
||||
} |
||||
} |
||||
|
||||
return $ids_parent[$id_rubrique]; |
||||
} |
||||
|
||||
|
||||
function rubrique_lire_secteur($id_rubrique) { |
||||
|
||||
static $ids_secteur = array(); |
||||
|
||||
if (!isset($ids_secteur[$id_rubrique])) { |
||||
$ids_secteur[$id_rubrique] = 0; |
||||
|
||||
$from = 'spip_rubriques'; |
||||
$where = array('id_rubrique=' . intval($id_rubrique)); |
||||
$id = sql_getfetsel('id_secteur', $from, $where); |
||||
if ($id !== null) { |
||||
$ids_secteur[$id_rubrique] = $id; |
||||
} |
||||
} |
||||
|
||||
return $ids_secteur[$id_rubrique]; |
||||
} |
||||
|
||||
|
||||
function rubrique_lire_categorie($id_rubrique) { |
||||
|
||||
static $categories = array(); |
||||
|
||||
if (!isset($ids_secteur[$id_rubrique])) { |
||||
$categories[$id_rubrique] = ''; |
||||
|
||||
$from = 'spip_rubriques'; |
||||
$where = array('id_rubrique=' . intval($id_rubrique)); |
||||
$categorie = sql_getfetsel('categorie', $from, $where); |
||||
if ($categorie !== null) { |
||||
$categories[$id_rubrique] = $categorie; |
||||
} |
||||
} |
||||
|
||||
return $categories[$id_rubrique]; |
||||
} |
||||
|
||||
|
||||
function rubrique_determiner_type($id_rubrique) { |
||||
|
||||
static $types = array(); |
||||
|
||||
if (!isset($types[$id_rubrique])) { |
||||
if (rubrique_dans_secteur_plugin($id_rubrique)) { |
||||
$types[$id_rubrique] = 'plugin'; |
||||
} elseif (rubrique_dans_secteur_apropos($id_rubrique)) { |
||||
$types[$id_rubrique] = 'apropos'; |
||||
} elseif (rubrique_dans_secteur_carnet($id_rubrique)) { |
||||
$types[$id_rubrique] = 'carnet'; |
||||
} elseif (rubrique_dans_secteur_galaxie($id_rubrique)) { |
||||
$types[$id_rubrique] = 'galaxie'; |
||||
} else { |
||||
$types[$id_rubrique] = ''; |
||||
} |
||||
} |
||||
|
||||
return $types[$id_rubrique]; |
||||
} |
||||
|
||||
function rubrique_determiner_couleur($categorie) { |
||||
|
||||
static $couleurs = array( |
||||
'auteur' => '1310b2', |
||||
'communication' => 'acbd70', |
||||
'date' => '471bb2', |
||||
'interactivite' => '50699b', |
||||
'contenu' => 'b22ba4', |
||||
'administration' => '09b2a3', |
||||
'multimedia' => 'de175f', |
||||
'navigation' => 'b26714', |
||||
'developpement' => 'dfb811', |
||||
'multilinguisme' => '11b23c', |
||||
'activite' => 'bd87c0', |
||||
'interface-publique' => '40dd5d', |
||||
); |
||||
|
||||
$couleur = (!$categorie or empty($couleurs[$categorie])) ? 'b9274d' : $couleurs[$categorie]; |
||||
|
||||
return $couleur; |
||||
} |
||||
|
||||
/** |
||||
* Vérifie que la rubrique concernée fait bien partie du secteur-apropos. |
||||
* Le secteur-apropos est déterminé par la configuration du secteur exclus dans |
||||
* le plugin Exclure Secteur. |
||||
* |
||||
* @param int $id |
||||
* Id de la rubrique concernée. |
||||
* |
||||
* @return bool |
||||
* True si la rubrique fait partie du secteur-apropos, false sinon. |
||||
*/ |
||||
function rubrique_dans_secteur_apropos($id_rubrique) { |
||||
|
||||
$est_apropos = false; |
||||
|
||||
include_spip('inc/config'); |
||||
$apropos = lire_config('secteur/exclure_sect', array()); |
||||
|
||||
if ($apropos and in_array(rubrique_lire_secteur($id_rubrique), $apropos)) { |
||||
$est_apropos = true; |
||||
} |
||||
|
||||
return $est_apropos; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* Vérifie que la rubrique concernée fait bien partie du secteur-carnet. |
||||
* Le secteur-carnet est déterminé par la configuration de l'espace wiki dans le plugin |
||||
* Autorité. |
||||
* |
||||
* @param int $id |
||||
* Id de la rubrique concernée. |
||||
* |
||||
* @return bool |
||||
* True si la rubrique fait partie du secteur-carnet, false sinon. |
||||
*/ |
||||
function rubrique_dans_secteur_carnet($id_rubrique) { |
||||
|
||||
$est_carnet = false; |
||||
|
||||
include_spip('inc/config'); |
||||
$carnet = lire_config('autorite/espace_wiki', array()); |
||||
|
||||
if ($carnet and in_array(rubrique_lire_secteur($id_rubrique), $carnet)) { |
||||
$est_carnet = true; |
||||
} |
||||
|
||||
return $est_carnet; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* Vérifie que la rubrique concernée fait bien partie du secteur-carnet. |
||||
* Le secteur-carnet est déterminé par la configuration de l'espace wiki dans le plugin |
||||
* Autorité. |
||||
* |
||||
* @param int $id |
||||
* Id de la rubrique concernée. |
||||
* |
||||
* @return bool |
||||
* True si la rubrique fait partie du secteur-carnet, false sinon. |
||||
*/ |
||||
function rubrique_dans_secteur_galaxie($id_rubrique) { |
||||
|
||||
$est_galaxie = false; |
||||
|
||||
include_spip('inc/config'); |
||||
$galaxie = lire_config('contrib/secteurs', array()); |
||||
|
||||
if ($galaxie and in_array(rubrique_lire_secteur($id_rubrique), $galaxie)) { |
||||
$est_galaxie = true; |
||||
} |
||||
|
||||
return $est_galaxie; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* Vérifie que la rubrique concernée fait bien partie d'un secteur-plugin. |
||||
* Il suffit de vérifier que le secteur a bien une catégorie non vide. |
||||
* |
||||
* @param int $id |
||||
* Id de la rubrique concernée. |
||||
* |
||||
* @return bool |
||||
* True si la rubrique fait partie d'un secteur-plugin, false sinon. |
||||
*/ |
||||
function rubrique_dans_secteur_plugin($id_rubrique) { |
||||
|
||||
static $est_plugin = array(); |
||||
|
||||
if (!isset($est_plugin[$id_rubrique])) { |
||||
$est_plugin[$id_rubrique] = false; |
||||
|
||||
if (rubrique_lire_categorie(rubrique_lire_secteur($id_rubrique))) { |
||||
$est_plugin[$id_rubrique] = true; |
||||
} |
||||
} |
||||
|
||||
return $est_plugin[$id_rubrique]; |
||||
} |
||||
|
||||
/** |
||||
* Récupère les id de tous les secteurs-plugin. |
||||
* |
||||
* @return array |
||||
* Liste des id des secteurs-pllugin ou tableau vide. |
||||
*/ |
||||
function rubrique_lister_secteur_plugin() { |
||||
|
||||
$from = 'spip_rubriques'; |
||||
$where = array('profondeur=0', 'categorie!=' . sql_quote('')); |
||||
if ($secteurs = sql_allfetsel('id_rubrique', $from, $where)) { |
||||
$secteurs = array_map('reset', $secteurs); |
||||
} |
||||
|
||||
|
||||
return $secteurs; |
||||
} |
||||
|
@ -1,254 +1,255 @@
|
||||
<?php |
||||
|
||||
/***************************************************************************\ |
||||
* SPIP, Systeme de publication pour l'internet * |
||||
* * |
||||
* Copyright (c) 2001-2019 * |
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James * |
||||
* * |
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. * |
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * |
||||
\***************************************************************************/ |
||||
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) { |
||||
return; |
||||
} |
||||
|
||||
include_spip('inc/autoriser'); |
||||
include_spip('inc/presentation'); |
||||
|
||||
/** |
||||
* Crée l'affichage des listes de rubriques dans le privé |
||||
* |
||||
* @param int $collection |
||||
* L'identifiant numérique de la rubrique à lister |
||||
* @param int $debut |
||||
* Le numéro de la pagination si paginé (> 500) |
||||
* @param int $limite |
||||
* Le pas de pagination si paginé (> 500) |
||||
* @return array $res |
||||
* Un tableau des sous rubriques |
||||
*/ |
||||
function enfant_rub($collection, $debut = 0, $limite = 500) { |
||||
$voir_logo = (isset($GLOBALS['meta']['image_process']) and $GLOBALS['meta']['image_process'] != 'non'); |
||||
$logo = ''; |
||||
|
||||
if ($voir_logo) { |
||||
$chercher_logo = charger_fonction('chercher_logo', 'inc'); |
||||
include_spip('inc/filtres_images_mini'); |
||||
} |
||||
|
||||
$res = array(); |
||||
|
||||
$result = sql_select( |
||||
'id_rubrique, id_parent, titre, descriptif, lang, categorie, prefixe', |
||||
'spip_rubriques', |
||||
'id_parent='.intval($collection), |
||||
'', |
||||
'0+titre,titre', |
||||
"$debut,$limite" |
||||
); |
||||
while ($row = sql_fetch($result)) { |
||||
$id_rubrique = $row['id_rubrique']; |
||||
$id_parent = $row['id_parent']; |
||||
$categorie = $row['categorie']; |
||||
$prefixe = $row['prefixe']; |
||||
// pour etre sur de passer par tous les traitements |
||||
$titre = generer_info_entite($id_rubrique, 'rubrique', 'titre'); |
||||
if ('' !== ($rang = recuperer_numero($row['titre']))) { |
||||
$rang = "$rang. "; |
||||
} |
||||
|
||||
if (autoriser('voir', 'rubrique', $id_rubrique)) { |
||||
$les_sous_enfants = sous_enfant_rub($id_rubrique); |
||||
|
||||
changer_typo($row['lang']); |
||||
$lang_dir = lang_dir($row['lang']); |
||||
$descriptif = propre($row['descriptif']); |
||||
|
||||
if ($voir_logo) { |
||||
if ($logo = $chercher_logo($id_rubrique, 'id_rubrique', 'on')) { |
||||
list($fid, $dir, $nom, $format) = $logo; |
||||
$logo = image_reduire("<img src='$fid' alt='' />", 48, 36); |
||||
if ($logo) { |
||||
$logo = inserer_attribut($logo, 'class', 'logo'); |
||||
} |
||||
} |
||||
} |
||||
|
||||
$lib_bouton = (!acces_restreint_rubrique($id_rubrique) ? '' : |
||||
http_img_pack( |
||||
'auteur-0minirezo-16.png', |
||||
'', |
||||
" width='16' height='16'", |
||||
_T('image_administrer_rubrique') |
||||
)) . |
||||
" <a dir='$lang_dir'" . |
||||
($row['lang'] !== $GLOBALS['spip_lang'] ? " hreflang='" . $row['lang'] . "'" : '') . |
||||
" href='" . |
||||
generer_url_entite($id_rubrique, 'rubrique') . |
||||
"'>" . |
||||
$rang . $titre . |
||||
'</a>'; |
||||
|
||||
$titre = (is_string($logo) ? $logo : '') . |
||||
bouton_block_depliable($lib_bouton, $les_sous_enfants ? false : -1, "enfants$id_rubrique"); |
||||
|
||||
// déterminer l'icone de la rubrique. |
||||
include_spip('inc/contrib_rubrique'); |
||||
$type = rubrique_determiner_type($id_rubrique); |
||||
$icone = $prefixe |
||||
? 'plugin-24.png' |
||||
: ($id_parent ? 'rubrique' : 'secteur') . ($type ? '_' . $type : '') . '-24.png'; |
||||
|
||||
// déterminer le complément au titre, cad , la catégorie ou le préfixe. |
||||
$complement = ''; |
||||
if ($categorie or $prefixe) { |
||||
include_spip('inc/contrib_rubrique'); |
||||
$classe = 'couleur_' . rubrique_lire_categorie(rubrique_lire_secteur($id_rubrique)); |
||||
$complement = _T('svp:label_' . ($categorie ? 'categorie' : 'prefixe')) |
||||
. " : <span class='plugin ${classe}'>" |
||||
. ($categorie ? $categorie : $prefixe) |
||||
. "</span></p>"; |
||||
} |
||||
|
||||
$res[] = |
||||
debut_cadre_sous_rub($icone, true, '', "${titre} (${id_rubrique})") . |
||||
(!$complement ? '' : "\n<div class='descriptif'>$complement</div>") . |
||||
(!$descriptif ? '' : "\n<div class='descriptif'>$descriptif</div>") . |
||||
$les_sous_enfants . |
||||
fin_cadre_sous_rub(); |
||||
} |
||||
} |
||||
|
||||
changer_typo($GLOBALS['spip_lang']); # remettre la typo de l'interface pour la suite |
||||
return $res; |
||||
} |
||||
|
||||
/** |
||||
* Affiche les enfants d'une sous rubrique dans un bloc dépliable |
||||
* (Utilisé dans les pages du privé) |
||||
* |
||||
* @param int $collection2 |
||||
* L'identifiant numérique de la rubrique parente |
||||
* @return string |
||||
* Le contenu du bloc dépliable |
||||
*/ |
||||
function sous_enfant_rub($collection2) { |
||||
$nb = sql_countsel('spip_rubriques', 'id_parent='.intval($collection2)); |
||||
|
||||
$retour = ''; |
||||
$pagination = ''; |
||||
$debut = 0; |
||||
$limite = 500; |
||||
|
||||
/** |
||||
* On ne va afficher que 500 résultats max |
||||
* Si > 500 on affiche une pagination |
||||
*/ |
||||
if ($nb > $limite) { |
||||
$debut = _request('debut_rubrique' . $collection2) ? _request('debut_rubrique' . $collection2) : $debut; |
||||
$pagination = chercher_filtre('pagination'); |
||||
$pagination = '<p class="pagination">' . $pagination($nb, '_rubrique' . $collection2, $debut, $limite, true, |
||||
'prive') . '</p>'; |
||||
$limite = $debut + $limite; |
||||
} |
||||
|
||||
$result = sql_select( |
||||
'id_rubrique, id_parent, titre, lang, categorie, prefixe', |
||||
'spip_rubriques', |
||||
'id_parent='.intval($collection2), |
||||
'', |
||||
'0+titre,titre', |
||||
"$debut,$limite" |
||||
); |
||||
|
||||
while ($row = sql_fetch($result)) { |
||||
$id_rubrique2 = $row['id_rubrique']; |
||||
$titre2 = generer_info_entite( |
||||
$id_rubrique2, |
||||
'rubrique', |
||||
'titre' |
||||
); // pour etre sur de passer par tous les traitements |
||||
$titre2 .= $row['categorie'] ? " ({$row['categorie']})" : ''; |
||||
$titre2 .= $row['prefixe'] ? " ({$row['prefixe']})" : ''; |
||||
if ('' !== ($rang2 = recuperer_numero($row['titre']))) { |
||||
$rang2 = "$rang2. "; |
||||
} |
||||
|
||||
changer_typo($row['lang']); |
||||
$lang_dir = lang_dir($row['lang']); |
||||
if (autoriser('voir', 'rubrique', $id_rubrique2)) { |
||||
$retour .= "\n<li class='item' dir='$lang_dir'><a href='" . generer_url_entite( |
||||
$id_rubrique2, |
||||
'rubrique' |
||||
) . "'>" . $rang2 . $titre2 . "</a></li>\n"; |
||||
} |
||||
} |
||||
|
||||
$retour = $pagination . $retour . $pagination; |
||||
|
||||
if (!$retour) { |
||||
return ''; |
||||
} |
||||
|
||||
return debut_block_depliable($debut > 0 ? true : false, "enfants$collection2") |
||||
. "\n<ul class='liste-items sous-sous-rub'>\n" |
||||
. $retour |
||||
. "</ul>\n" . fin_block() . "\n\n"; |
||||
} |
||||
|
||||
/** |
||||
* Affiche la liste des rubriques enfants d'une rubrique |
||||
* (Utilisé dans les pages du privé notamment ?exec=rubriques) |
||||
* |
||||
* Si plus de 500 rubriques enfants, on pagine par 500 les résultats |
||||
* |
||||
* @param int $id_rubrique |
||||
* L'identifiant numérique de la rubrique parente (0 par défaut, la racine) |
||||
* @return string $res |
||||
* Le contenu textuel affiché, la liste des sous rubriques |
||||
*/ |
||||
function afficher_enfant_rub($id_rubrique = 0) { |
||||
$pagination = ''; |
||||
$debut = 0; |
||||
$limite = 500; |
||||
|
||||
$nb = sql_countsel('spip_rubriques', 'id_parent='.intval($id_rubrique)); |
||||
|
||||
if ($nb > $limite) { |
||||
$debut = _request('debut_rubrique' . $id_rubrique) ? _request('debut_rubrique' . $id_rubrique) : $debut; |
||||
$pagination = chercher_filtre('pagination'); |
||||
$pagination = '<br class="nettoyeur"><p class="pagination">' . |
||||
$pagination($nb, '_rubrique' . $id_rubrique, $debut, $limite, true, 'prive') . |
||||
'</p>'; |
||||
} |
||||
|
||||
$les_enfants = enfant_rub($id_rubrique, $debut, $limite); |
||||
|
||||
if (!$n = count($les_enfants)) { |
||||
return ''; |
||||
} |
||||
|
||||
if ($n == 1) { |
||||
$les_enfants = reset($les_enfants); |
||||
$les_enfants2 = ''; |
||||
} else { |
||||
$n = ceil($n / 2); |
||||
$les_enfants2 = implode('', array_slice($les_enfants, $n)); |
||||
$les_enfants = implode('', array_slice($les_enfants, 0, $n)); |
||||
} |
||||
|
||||
$res = |
||||
$pagination |
||||
. "<div class='gauche'>" |
||||
. $les_enfants |
||||
. '</div>' |
||||
. "<div class='droite'>" |
||||
. $les_enfants2 |
||||
. '</div>' |
||||
. $pagination; |
||||
|
||||
return $res; |
||||
} |
||||
<?php |
||||
|
||||
/***************************************************************************\ |
||||
* SPIP, Systeme de publication pour l'internet * |
||||
* * |
||||
* Copyright (c) 2001-2019 * |
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James * |
||||
* * |
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. * |
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * |
||||
\***************************************************************************/ |
||||
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) { |
||||
return; |
||||
} |
||||
|
||||
include_spip('inc/autoriser'); |
||||
include_spip('inc/presentation'); |
||||
|
||||
/** |
||||
* Crée l'affichage des listes de rubriques dans le privé |
||||
* |
||||
* @param int $collection |
||||
* L'identifiant numérique de la rubrique à lister |
||||
* @param int $debut |
||||
* Le numéro de la pagination si paginé (> 500) |
||||
* @param int $limite |
||||
* Le pas de pagination si paginé (> 500) |
||||
* @return array $res |
||||
* Un tableau des sous rubriques |
||||
*/ |
||||
function enfant_rub($collection, $debut = 0, $limite = 500) { |
||||
$voir_logo = (isset($GLOBALS['meta']['image_process']) and $GLOBALS['meta']['image_process'] != 'non'); |
||||
$logo = ''; |
||||
|
||||
if ($voir_logo) { |
||||
$chercher_logo = charger_fonction('chercher_logo', 'inc'); |
||||
include_spip('inc/filtres_images_mini'); |
||||
} |
||||
|
||||
$res = array(); |
||||
|
||||
$result = sql_select( |
||||
'id_rubrique, id_parent, titre, descriptif, lang, categorie, prefixe', |
||||
'spip_rubriques', |
||||
'id_parent='.intval($collection), |
||||
'', |
||||
'0+titre,titre', |
||||
"$debut,$limite" |
||||
); |
||||
while ($row = sql_fetch($result)) { |
||||
$id_rubrique = $row['id_rubrique']; |
||||
$id_parent = $row['id_parent']; |
||||
$categorie = $row['categorie']; |
||||
$prefixe = $row['prefixe']; |
||||
// pour etre sur de passer par tous les traitements |
||||
$titre = generer_info_entite($id_rubrique, 'rubrique', 'titre'); |
||||
if ('' !== ($rang = recuperer_numero($row['titre']))) { |
||||
$rang = "$rang. "; |
||||
} |
||||
|
||||
if (autoriser('voir', 'rubrique', $id_rubrique)) { |
||||
$les_sous_enfants = sous_enfant_rub($id_rubrique); |
||||
|
||||
changer_typo($row['lang']); |
||||
$lang_dir = lang_dir($row['lang']); |
||||
$descriptif = propre($row['descriptif']); |
||||
|
||||
if ($voir_logo) { |
||||
if ($logo = $chercher_logo($id_rubrique, 'id_rubrique', 'on')) { |
||||
list($fid, $dir, $nom, $format) = $logo; |
||||
$logo = image_reduire("<img src='$fid' alt='' />", 48, 36); |
||||
if ($logo) { |
||||
$logo = inserer_attribut($logo, 'class', 'logo'); |
||||
} |
||||
} |
||||
} |
||||
|
||||
$lib_bouton = (!acces_restreint_rubrique($id_rubrique) ? '' : |
||||
http_img_pack( |
||||
'auteur-0minirezo-16.png', |
||||
'', |
||||
" width='16' height='16'", |
||||
_T('image_administrer_rubrique') |
||||
)) . |
||||
" <a dir='$lang_dir'" . |
||||
($row['lang'] !== $GLOBALS['spip_lang'] ? " hreflang='" . $row['lang'] . "'" : '') . |
||||
" href='" . |
||||
generer_url_entite($id_rubrique, 'rubrique') . |
||||
"'>" . |
||||
$rang . $titre . " (${id_rubrique})" . |
||||
'</a>'; |
||||
|
||||
$titre = (is_string($logo) ? $logo : '') . |
||||
bouton_block_depliable($lib_bouton, $les_sous_enfants ? false : -1, "enfants$id_rubrique"); |
||||
|
||||
// déterminer l'icone de la rubrique. |
||||
include_spip('inc/contrib_rubrique'); |
||||
$type = rubrique_determiner_type($id_rubrique); |
||||
$icone = $prefixe |
||||
? 'plugin-24.png' |
||||
: ($id_parent ? 'rubrique' : 'secteur') . ($type ? '_' . $type : '') . '-24.png'; |
||||
|
||||
// déterminer le complément au titre, cad , la catégorie ou le préfixe. |
||||
$complement = ''; |
||||
if ($categorie or $prefixe) { |
||||
include_spip('inc/contrib_rubrique'); |
||||
$classe = 'couleur_' . rubrique_lire_categorie(rubrique_lire_secteur($id_rubrique)); |
||||
$complement = _T('svp:label_' . ($categorie ? 'categorie' : 'prefixe')) |
||||
. " : <span class='plugin ${classe}'>" |
||||
. ($categorie ? $categorie : $prefixe) |
||||
. "</span></p>"; |
||||
} |
||||
|
||||
$res[] = |
||||
debut_cadre_sous_rub($icone, true, '', $titre) . |
||||
(!$complement ? '' : "\n<div class='descriptif'>$complement</div>") . |
||||
(!$descriptif ? '' : "\n<div class='descriptif'>$descriptif</div>") . |
||||
$les_sous_enfants . |
||||
fin_cadre_sous_rub(); |
||||
} |
||||
} |
||||
|
||||
changer_typo($GLOBALS['spip_lang']); # remettre la typo de l'interface pour la suite |
||||
return $res; |
||||
} |
||||
|
||||
/** |
||||
* Affiche les enfants d'une sous rubrique dans un bloc dépliable |
||||
* (Utilisé dans les pages du privé) |
||||
* |
||||
* @param int $collection2 |
||||
* L'identifiant numérique de la rubrique parente |
||||
* @return string |
||||
* Le contenu du bloc dépliable |
||||
*/ |
||||
function sous_enfant_rub($collection2) { |
||||
$nb = sql_countsel('spip_rubriques', 'id_parent='.intval($collection2)); |
||||
|
||||
$retour = ''; |
||||
$pagination = ''; |
||||
$debut = 0; |
||||
$limite = 500; |
||||
|
||||
/** |
||||
* On ne va afficher que 500 résultats max |
||||
* Si > 500 on affiche une pagination |
||||
*/ |
||||
if ($nb > $limite) { |
||||
$debut = _request('debut_rubrique' . $collection2) ? _request('debut_rubrique' . $collection2) : $debut; |
||||
$pagination = chercher_filtre('pagination'); |
||||
$pagination = '<p class="pagination">' . $pagination($nb, '_rubrique' . $collection2, $debut, $limite, true, |
||||
'prive') . '</p>'; |
||||
$limite = $debut + $limite; |
||||
} |
||||
|
||||
$result = sql_select( |
||||
'id_rubrique, id_parent, titre, lang, categorie, prefixe', |
||||
'spip_rubriques', |
||||
'id_parent='.intval($collection2), |
||||
'', |
||||
'0+titre,titre', |
||||
"$debut,$limite" |
||||
); |
||||
|
||||
while ($row = sql_fetch($result)) { |
||||
$id_rubrique2 = $row['id_rubrique']; |
||||
$titre2 = generer_info_entite( |
||||
$id_rubrique2, |
||||
'rubrique', |
||||
'titre' |
||||
); // pour etre sur de passer par tous les traitements |
||||
$titre2 .= $row['categorie'] ? " ({$row['categorie']})" : ''; |
||||
$titre2 .= $row['prefixe'] ? " ({$row['prefixe']})" : ''; |
||||
$titre2 .= " - ${id_rubrique2}"; |
||||
if ('' !== ($rang2 = recuperer_numero($row['titre']))) { |
||||
$rang2 = "$rang2. "; |
||||
} |
||||
|
||||
changer_typo($row['lang']); |
||||
$lang_dir = lang_dir($row['lang']); |
||||
if (autoriser('voir', 'rubrique', $id_rubrique2)) { |
||||
$retour .= "\n<li class='item' dir='$lang_dir'><a href='" . generer_url_entite( |
||||
$id_rubrique2, |
||||
'rubrique' |
||||
) . "'>" . $rang2 . $titre2 . "</a></li>\n"; |
||||
} |
||||
} |
||||
|
||||
$retour = $pagination . $retour . $pagination; |
||||
|
||||
if (!$retour) { |
||||
return ''; |
||||
} |
||||
|
||||
return debut_block_depliable($debut > 0 ? true : false, "enfants$collection2") |
||||
. "\n<ul class='liste-items sous-sous-rub'>\n" |
||||
. $retour |
||||
. "</ul>\n" . fin_block() . "\n\n"; |
||||
} |
||||
|
||||
/** |
||||
* Affiche la liste des rubriques enfants d'une rubrique |
||||
* (Utilisé dans les pages du privé notamment ?exec=rubriques) |
||||
* |
||||
* Si plus de 500 rubriques enfants, on pagine par 500 les résultats |
||||
* |
||||
* @param int $id_rubrique |
||||
* L'identifiant numérique de la rubrique parente (0 par défaut, la racine) |
||||
* @return string $res |
||||
* Le contenu textuel affiché, la liste des sous rubriques |
||||
*/ |
||||
function afficher_enfant_rub($id_rubrique = 0) { |
||||
$pagination = ''; |
||||
$debut = 0; |
||||
$limite = 500; |
||||
|
||||
$nb = sql_countsel('spip_rubriques', 'id_parent='.intval($id_rubrique)); |
||||
|
||||
if ($nb > $limite) { |
||||
$debut = _request('debut_rubrique' . $id_rubrique) ? _request('debut_rubrique' . $id_rubrique) : $debut; |
||||
$pagination = chercher_filtre('pagination'); |
||||
$pagination = '<br class="nettoyeur"><p class="pagination">' . |
||||
$pagination($nb, '_rubrique' . $id_rubrique, $debut, $limite, true, 'prive') . |
||||
'</p>'; |
||||
} |
||||
|
||||
$les_enfants = enfant_rub($id_rubrique, $debut, $limite); |
||||
|
||||
if (!$n = count($les_enfants)) { |
||||
return ''; |
||||
} |
||||
|
||||
if ($n == 1) { |
||||
$les_enfants = reset($les_enfants); |
||||
$les_enfants2 = ''; |
||||
} else { |
||||
$n = ceil($n / 2); |
||||
$les_enfants2 = implode('', array_slice($les_enfants, $n)); |
||||
$les_enfants = implode('', array_slice($les_enfants, 0, $n)); |
||||
} |
||||
|
||||
$res = |
||||
$pagination |
||||
. "<div class='gauche'>" |
||||
. $les_enfants |
||||
. '</div>' |
||||
. "<div class='droite'>" |
||||
. $les_enfants2 |
||||
. '</div>' |
||||
. $pagination; |
||||
|
||||
return $res; |
||||
} |
||||
|
Loading…
Reference in new issue