maj du lien vers le séminaire Création et Territoires, et favicon.ico sur accueils
<?php
/* liste des dossiers */
function list_dir($base, $cur, $level=0) {
global $PHP_SELF, $BASE;
if ($dir = opendir($base)) {
$tab = array();
while($entry = readdir($dir)) {
if(is_dir($base."/".$entry) && !in_array($entry, array(".",".."))) {
$tab[] = $entry;
}
}
if(ereg("([0-9]{1,2})[_]([0-9]{1,2})[_]([0-9]{4})",$tab[0])){
$timestamp=array();
foreach($tab as $val):
list($day, $month, $year) = explode('_',$val);
$timestamp[] = mktime(0,0,0,$month, $day, $year);
endforeach;
sort($timestamp,SORT_NUMERIC);
$tab=array();
foreach($timestamp as $ts):
$tab[] = date('d_m_Y', $ts);
endforeach;
}else{
natcasesort($tab);
}
//natsort($tab);
foreach($tab as $entry) {
/* chemin relatif � la racine */
$file = $base."/".$entry;
/* marge gauche
for($i=1; $i<=(4*$level); $i++) {
echo " ";
}
*/
/* l'entr�e est-elle le dossier courant */
if($file == $cur) {
echo "<img src=\"http://www.iri.centrepompidou.fr/privatedoc/img/folder.png\" /> ".strtoupper($entry)."<br />\n";
} else {
$display = deInterCaps($entry);
$display = UtoWS($display);
echo "<img src=\"http://www.iri.centrepompidou.fr/privatedoc/img/folder.png\" /> <a href=\"$PHP_SELF?dir=".rawurlencode($file)."\">".trim(strtoupper($display))."</a><br/>\n";
}
/* l'entr�e est-elle dans la branche dont le dossier courant est la feuille */
if(ereg($file."/",$cur."/")) {
list_dir($file, $cur, $level+1);
}
}
closedir($dir);
}
}
/* liste des fichiers */
function list_file($cur) {
global $PHP_SELF, $BASE;
if ($dir = opendir($cur)) {
/* tableaux */
$tab_dir = array();
$tab_file = array();
/* extraction */
while($file = readdir($dir)) {
if(is_dir($cur."/".$file)) {
$tab_dir[] = $file;
} else {
$tab_file[] = $file;
}
}
/* tri */
sort($tab_dir);
sort($tab_file);
/* affichage */
if(!empty($tab_file)):
foreach($tab_dir as $elem) {
if($elem == ".." && isset($_GET['dir'])):
echo "<img src=\"http://www.iri.centrepompidou.fr/privatedoc/img/folder.png\" /> <a href='javascript:history.back()' title='retour'>".$elem."</a><br />\n";
else:
//echo "<img src=\"dir-close.gif\" /> ".$elem."<br />\n";
endif;
}
endif;
$i=0;
$tab=array();
$path='';
$tab = explode("/",$BASE);
echo '<table width="100%" cellspacing="0" cellpadding="0">';
foreach($tab_file as $elem) {
$path='';
for($j=5;$j<count($tab);$j++){
$path .= $tab[$j]."/";
}
$path .= $elem;
$temppath = substr($BASE,26);
$temppath .= "/";
$displayElem = UtoWS($elem);
$iconeInfo = (strstr(strtolower($BASE),"regards"))?'<a href="javascript:void(0)" onclick="document.getElementById(\'moreinfo\').style.display=\'block\'"><img src="http://www.iri.centrepompidou.fr/privatedoc/img/information.png" alt="information" title="plus d\'information" class="image"/></a> ':'';
//gestion du type de fichier
//si mp3 : affichage lien download et ecoute
//si pdf : uniquement download
//si zip : uniquement download
list($filename, $ext) = explode('.',$elem);
if($ext == 'mp3'){
echo "<tr>";
echo "<td width='80%'><img src=\"http://www.iri.centrepompidou.fr/privatedoc/img/page_white_cd.png\" border='0'/> <a href=\"javascript:void(0)\" onclick=\"switchMedia('".trim($temppath.$elem)."')\" >".$displayElem."</a></td>";
echo "<td>".$iconeInfo."<a href=\"javascript:void(0)\" onclick=\"switchMedia('".trim($temppath.$elem)."')\"> <img src='http://www.iri.centrepompidou.fr/privatedoc/img/sound.png' border='0' title='ecouter' alt='ecouter' class='image'/></a> ";
echo "<a href=\"http://www.iri.centrepompidou.fr/documents/audio/".$path."\"> <img src='http://www.iri.centrepompidou.fr/privatedoc/img/disk.png' border='0' title='t�l�charger' alt='t�l�charger' class='image'></a><br/></td>";
echo '</tr>';
}
elseif($ext == 'pdf' || $ext == 'zip'){
echo "<tr>";
echo "<td width='80%'>";
echo "<img src=\"http://www.iri.centrepompidou.fr/privatedoc/img/$ext.png\" border='0'/> <a href=\"http://www.iri.centrepompidou.fr/documents/audio/$path\" >".$displayElem."</a></td>";
echo "<td>".$iconeInfo."<a href=\"http://www.iri.centrepompidou.fr/documents/audio/".$path."\"> <img src='http://www.iri.centrepompidou.fr/privatedoc/img/disk.png' border='0' title='t�l�charger' alt='t�l�charger' class='image'></a><br/></td>";
echo '</tr>';
}
$i++;
}
echo '</table>';
closedir($dir);
}
}
/*remplace une majuscule par un espace*/
function deInterCaps($var){
return ucfirst(strtolower(ereg_replace("[A-Z]"," \\0",$var)));
}
/*remplace un underscore par un espace*/
function UtoWS($text){
return ucfirst(strtolower(ereg_replace("[_]"," ",$text)));
}
?>