function filtre_profondeur_dist($id_rubrique) { $id_rubrique = intval($id_rubrique); // sauver les calculs déjà faits static $profs = array(); if (isset($profs[$id_rubrique])) { return $profs[$id_rubrique]; } // récupérer le parent. $id_parent = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique='.$id_rubrique); // pas de parent : id_rubrique n'existe pas if (is_null($id_parent)) { return ''; } // parent zéro : on est tout en haut (racine) if ($id_parent == '0') { return $profs[$id_rubrique] = 1; } // sinon, on trouve la profondeur du parent $parent = filtre_profondeur_dist($id_parent); $profs[$id_rubrique] = ($parent + 1); return $profs[$id_rubrique]; }