1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
| <!-- VERSION ALPHABETIQUE -->
<?php if($tri == 'alpha' && $motsclefs->count() > 0): ?>
<!-- Tableau des lettres de l'alphabet, des chiffres, etc... -->
<?php $tablettre = array('0-9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'); ?>
<?php $tabchiffre = array('0','1','2','3','4','5','6','7','8','9'); ?>
<?php $tabmc = array(); ?>
<!-- Parcours des mots-clés pour mise en tableau -->
<?php foreach($motsclefs as $motsclef): ?>
<?php $intitule=$motsclef->getIntitule();
$id=$motsclef->getId();
$mc[$id] = array('Id'=>$id,'Intitule'=>$intitule,'Identifiant'=>$motsclef); ?>
<?php array_push($tabmc,$mc[$id]);?>
<?php endforeach; ?>
<ul id="tree">
<?php foreach($tablettre as $i => $valeur): ?>
<?php $nb = 0; $ok=false;?>
<?php foreach($tabmc as $j => $motsclef): ?>
<?php if($motsclef['Intitule']{0} == $valeur)
{
if($nb == 0)
{
echo "<li><strong>".$valeur."</strong><ul>";
$ok = true;
}
unset($tabmc[$j]);
echo "<li><a href='".url_for('recherche_show_motsclef',$motsclef['Identifiant'])."' title='".$motsclef['Intitule']."'>".$motsclef['Intitule']."</a></li>";
}
else
{
if(in_array($motsclef['Intitule']{0},$tabchiffre))
{
if($nb == 0)
{
echo "<li><strong>0-9</strong><ul>";
$ok = true;
}
unset($tabmc[$j]);
echo "<li><a href='".url_for('recherche_show_motsclef',$motsclef['Identifiant'])."' title='".$motsclef['Intitule']."'>".$motsclef['Intitule']."</a></li>";
}
else
{
break;
}
}
?>
<?php $nb++; ?>
<?php endforeach; ?>
<?php if($ok) echo "</ul></li>"; ?>
<?php endforeach; ?>
</ul>
<?php endif; ?>
<!-- VERSION ADMIN A OPTIMISER (optimisée car unset sur le tableau mais tri bulle à changer en tri plus performant !) -->
<?php if($tri == 'admin' && $motsclefs->count() > 0): ?>
<?php $affichage = ''; ?>
<!-- Fonction récursive -->
<?php
function getChildren($affichage, $tabmc, $parent, $type)
{
$aenfants = false;
$enfants = array();
//Récupération des enfants
foreach($tabmc as $i => $valeur)
{
if($valeur->getMotclef_id() == $parent->getId())
{
$aenfants = true;
$enfants[] = $valeur;
unset($tabmc[$i]);
}
}
//Si il a des enfants
if($aenfants)
{
if($type == 'base')
$affichage .= "<li><a href='".url_for('recherche_show_motsclef',$parent)."' title='".$parent->getIntitule()."'><strong>".ucFirst($parent->getIntitule())."</strong></a><ul>";
else
$affichage .= "<li><a href='".url_for('recherche_show_motsclef',$parent)."' title='".$parent->getIntitule()."'>".ucFirst($parent->getIntitule())."</a><ul>";
foreach($enfants as $enfant) //Pour chaque enfant
{
$affichage = getChildren($affichage, $tabmc, $enfant, 'nonbase'); //Appel récursif
}
$affichage .= "</ul></li>";
}
else
{
if($type == 'base')
$affichage .= "<li><a href='".url_for('recherche_show_motsclef',$parent)."' title='".$parent->getIntitule()."'><strong>".$parent->getIntitule()."</strong></a></li>";
else
$affichage .= "<li><a href='".url_for('recherche_show_motsclef',$parent)."' title='".$parent->getIntitule()."'>".$parent->getIntitule()."</a></li>";
}
return $affichage;
}
?>
<!-- Parcours des mots-clés pour mise en tableau -->
<?php foreach($motsclefs as $motsclef): ?>
<?php $tabmc[] = $motsclef; ?>
<?php endforeach; ?>
<!-- Création de la variable d'affichage avec appel de la fonction récursive -->
<?php
foreach($tabmc as $i => $valeur)
{
if($valeur->getMotclef_id() == null)
{
$affichage = getChildren($affichage, $tabmc, $valeur, 'base');
unset($tabmc[$i]);
}
}
?>
<ul id="tree">
<?php echo $affichage; ?>
</ul>
<?php endif; ?> |
Partager