par
diab » 03 oct. 2005, 00:19
bonjour j'aimerais trier les images d'une galerie photo soit par ordre alphabétique soit le contraire ou encore par ordre de ajout....
c'est un dossier dans lequel je met les image et il me crée automatiquement les miniatures et fait la mise en page de la galerie mais tout les images sont classée par ordre alphabétique....
voici le code:
<?php
$col_simple = "non"; // Si $col_simple == Oui Alors presentation speciale sur une colonne
// avec gestion des pages, on affiche par page le nbr_colonne * nbre_ligne
// Si $col_simple != Oui Alors on affiche une mosaique en tenant compte de
// nbr_colonne et nbr_ligne
$nbr_colonne =5;
$nbr_ligne =3;
$image_de_fond = "#ffffff";
$thumb = "thumb/"; // Si Oui, on utilise le repertoire /thumb pour la mosaique
$pourcentage_reduce = 60;
$RepGrosseImages = "climb/images/";
$faire_miniature = "Non"; //En developpement
//Taille de l'extension = 3 // 3 : pour jpg 4 : jpeg
///////////////////////////////////////////////////////////////////////////////////////////
function GetFileList( $dirname="." ) {
$files = array();
$dir = opendir( $dirname );
while( $file = readdir( $dir ) ) {
if (ereg("jpg$",$file) || ereg("JPG$",$file) ||
ereg("jpeg$",$file) || ereg("JPEG$",$file) ||
ereg("png$",$file) || ereg("PNG$",$file) ||
ereg("gif$",$file) || ereg("GIF$",$file)
) {
$files[] = $file;
}
}
sort($files);
return $files;
}
?>
<HTML>
<HEAD>
<TITLE></TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><style type="text/css">
<!--
a:link {
color: #FFFFFF;
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #FFFFFF;
}
a:hover {
text-decoration: underline;
}
a:active {
text-decoration: none;
}
body,td,th {
color: #FFFFFF;
}
body {
background-color: #000000;
}
-->
</style><body alink="#FFFFFF" background=
<?php echo "\"$image_de_fond\""; ?>
>
</HEAD>
<SCRIPT Language="JavaScript">
<!--
var popWin = null
var winCount = 0
var winName = "popWin"
function openPopWin(winURL, winWidth, winHeight, winFeatures, winLeft, winTop){
var d_winLeft = 0
var d_winTop = 0
winName = "popWin" + winCount++
closePopWin()
if (openPopWin.arguments.length >= 4)
winFeatures = "," + winFeatures
else
winFeatures = ""
if (openPopWin.arguments.length == 6)
winFeatures += getLocation(winWidth, winHeight, winLeft, winTop)
else
winFeatures += getLocation(winWidth, winHeight, d_winLeft, d_winTop)
popWin = window.open(winURL, winName, "width=" + winWidth
+ ",height=" + winHeight + winFeatures)
}
function closePopWin(){
if (navigator.appName != "Microsoft Internet Explorer"
|| parseInt(navigator.appVersion) >=4)
if(popWin != null) if(!popWin.closed) popWin.close()
}
function getLocation(winWidth, winHeight, winLeft, winTop){
return ""
}
//-->
</SCRIPT>
<SCRIPT Language="JavaScript1.2">
<!--
function getLocation(winWidth, winHeight, winLeft, winTop){
var winLocation = ""
if (winLeft < 0)
winLeft = screen.width - winWidth + winLeft
if (winTop < 0)
winTop = screen.height - winHeight + winTop
if (winTop == "cen")
winTop = (screen.height - winHeight)/2 - 20
if (winLeft == "cen")
winLeft = (screen.width - winWidth)/2
if (winLeft>0 & winTop>0)
winLocation = ",screenX=" + winLeft + ",left=" + winLeft
+ ",screenY=" + winTop + ",top=" + winTop
else
winLocation = ""
return winLocation
}
//-->
</SCRIPT>
<p>
<center>
</p>
</center>
<?
if ($col_simple != "Oui")
{
echo "<table border=\"0\" align=\"center\" cellspacing=\"0\" cellpadding=\"6\"> \n";
}
else
{
echo "<table width=\"600\" border=\"1\" cellspacing=\"0\" cellpadding=\"2\" align=\"center\"> \n";
echo " <tr bgcolor=\"#999999\"> \n";
echo " <td> \n";
echo " <div align=\"center\"><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"2\">Apercu</font></div> \n";
echo " </td> \n";
echo " <td> \n";
echo " <div align=\"center\"><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"2\">Nom</font></div> \n";
echo " </td> \n";
echo " <td> \n";
echo " <div align=\"center\"><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"2\">Largeur</font></div> \n";
echo " </td> \n";
echo " <td> \n";
echo " <div align=\"center\"><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"2\">Hauteur</font></div> \n";
echo " </td> \n";
echo " </tr> \n";
}
$imagelist = GetFileList($RepGrosseImages);
$nbr_par_page =$nbr_colonne * $nbr_ligne;
$nbr_tot =count($imagelist);
$debut = 1;
$j = 1;
$fin = $nbr_par_page;
if (!isset($ppage))
{
$ppage=1;
}
for($i=$debut; $i < $nbr_tot +1 ; $i++) {
$image = $imagelist[$i-1];
if (file_exists("$RepGrosseImages$image"))
{
$size = getimagesize("$RepGrosseImages$image");
$width = $size[0];
$height = $size[1];
$rwidth = $size[0]+20;
$rheight = $size[1]+20;
$page = ceil($i/$nbr_par_page);
$tpage[$i] = $page ;
}
if ($page == $ppage)
{
if ($col_simple != "Oui")
{
if ($j == ( $nbr_colonne ) )
{
echo " <td> \n";
echo " <center> \n";
echo " <a href='javascript:openPopWin(\"$RepGrosseImages$image\",$rwidth,$rheight,\"\",\"cen\",\"cen\")'> \n";
if ($thumb == "Oui")
{
echo " <img src='thumb/$image' border=0 alt='$image*$width*$height' \n";
}
else
{
echo " <img src='$RepGrosseImages$image' border=0 alt='$image*$width*$height' \n";
}
echo " width='$pourcentage_reduce'><br><font face=\"Arial,Helvetica\"><font size=-2>$image</font></font></a></td> \n";
echo "</center> \n";
echo "</tr> \n";
$j = 1;
}
else
{
echo " <td> \n";
echo " <center> \n";
echo " <a href='javascript:openPopWin(\"$RepGrosseImages$image\",$rwidth,$rheight,\"\",\"cen\",\"cen\")'> \n";
if ($thumb == "Oui")
{
echo " <img src='thumb/$image' border=0 alt='$image*$width*$height' \n";
}
else
{
echo " <img src='$RepGrosseImages$image' border=0 alt='$image*$width*$height' \n";
}
echo " width='$pourcentage_reduce'><br><font face=\"Arial,Helvetica\"><font size=-2>$image</font></font></a></td></center> \n";
$j = $j + 1;
}
}
else
{
echo "<tr> \n";
echo "<td> \n";
echo "<div align=\"center\"><a href='javascript:openPopWin(\"$RepGrosseImages$image\",$rwidth,$rheight,\"\",\"cen\",\"cen\")'> \n";
if ($thumb == "Oui")
{
echo " <img src='thumb/$image' border=0 alt='$image*$width*$height' \n";
}
else
{
echo " <img src='$RepGrosseImages$image' border=0 alt='$image*$width*$height' \n";
}
echo " width='50'></a></div> \n";
echo "</td> \n";
echo "<td> \n";
echo "<div align=\"center\"><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\">$image</font></div> \n";
echo "</td> \n";
echo "<td> \n";
echo "<div align=\"center\"><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\">$rwidth</font></div> \n";
echo "</td> \n";
echo "<td> \n";
echo "<div align=\"center\"><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\">$rheight</font></div> \n";
echo "</td> \n";
echo "</tr> \n";
$j = $j + 1;
}
} //if
} //for
echo "</table> \n";
echo "<BR> \n";
echo "<CENTER> \n";
$sval = -1;
while (list ($key, $val) = each ($tpage)) {
if ($sval != $val)
{
echo "<b><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\">[\n";
echo "<a href=\"index.php?page=climb&ppage=$val\">$val</a>";
echo "]\n";
$sval = $val;
}
}
echo "</CENTER> \n";
?>
bonjour j'aimerais trier les images d'une galerie photo soit par ordre alphabétique soit le contraire ou encore par ordre de ajout....
c'est un dossier dans lequel je met les image et il me crée automatiquement les miniatures et fait la mise en page de la galerie mais tout les images sont classée par ordre alphabétique....
voici le code:
[php]<?php
$col_simple = "non"; // Si $col_simple == Oui Alors presentation speciale sur une colonne
// avec gestion des pages, on affiche par page le nbr_colonne * nbre_ligne
// Si $col_simple != Oui Alors on affiche une mosaique en tenant compte de
// nbr_colonne et nbr_ligne
$nbr_colonne =5;
$nbr_ligne =3;
$image_de_fond = "#ffffff";
$thumb = "thumb/"; // Si Oui, on utilise le repertoire /thumb pour la mosaique
$pourcentage_reduce = 60;
$RepGrosseImages = "climb/images/";
$faire_miniature = "Non"; //En developpement
//Taille de l'extension = 3 // 3 : pour jpg 4 : jpeg
///////////////////////////////////////////////////////////////////////////////////////////
function GetFileList( $dirname="." ) {
$files = array();
$dir = opendir( $dirname );
while( $file = readdir( $dir ) ) {
if (ereg("jpg$",$file) || ereg("JPG$",$file) ||
ereg("jpeg$",$file) || ereg("JPEG$",$file) ||
ereg("png$",$file) || ereg("PNG$",$file) ||
ereg("gif$",$file) || ereg("GIF$",$file)
) {
$files[] = $file;
}
}
sort($files);
return $files;
}
?>
<HTML>
<HEAD>
<TITLE></TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><style type="text/css">
<!--
a:link {
color: #FFFFFF;
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #FFFFFF;
}
a:hover {
text-decoration: underline;
}
a:active {
text-decoration: none;
}
body,td,th {
color: #FFFFFF;
}
body {
background-color: #000000;
}
-->
</style><body alink="#FFFFFF" background=
<?php echo "\"$image_de_fond\""; ?>
>
</HEAD>
<SCRIPT Language="JavaScript">
<!--
var popWin = null
var winCount = 0
var winName = "popWin"
function openPopWin(winURL, winWidth, winHeight, winFeatures, winLeft, winTop){
var d_winLeft = 0
var d_winTop = 0
winName = "popWin" + winCount++
closePopWin()
if (openPopWin.arguments.length >= 4)
winFeatures = "," + winFeatures
else
winFeatures = ""
if (openPopWin.arguments.length == 6)
winFeatures += getLocation(winWidth, winHeight, winLeft, winTop)
else
winFeatures += getLocation(winWidth, winHeight, d_winLeft, d_winTop)
popWin = window.open(winURL, winName, "width=" + winWidth
+ ",height=" + winHeight + winFeatures)
}
function closePopWin(){
if (navigator.appName != "Microsoft Internet Explorer"
|| parseInt(navigator.appVersion) >=4)
if(popWin != null) if(!popWin.closed) popWin.close()
}
function getLocation(winWidth, winHeight, winLeft, winTop){
return ""
}
//-->
</SCRIPT>
<SCRIPT Language="JavaScript1.2">
<!--
function getLocation(winWidth, winHeight, winLeft, winTop){
var winLocation = ""
if (winLeft < 0)
winLeft = screen.width - winWidth + winLeft
if (winTop < 0)
winTop = screen.height - winHeight + winTop
if (winTop == "cen")
winTop = (screen.height - winHeight)/2 - 20
if (winLeft == "cen")
winLeft = (screen.width - winWidth)/2
if (winLeft>0 & winTop>0)
winLocation = ",screenX=" + winLeft + ",left=" + winLeft
+ ",screenY=" + winTop + ",top=" + winTop
else
winLocation = ""
return winLocation
}
//-->
</SCRIPT>
<p>
<center>
</p>
</center>
<?
if ($col_simple != "Oui")
{
echo "<table border=\"0\" align=\"center\" cellspacing=\"0\" cellpadding=\"6\"> \n";
}
else
{
echo "<table width=\"600\" border=\"1\" cellspacing=\"0\" cellpadding=\"2\" align=\"center\"> \n";
echo " <tr bgcolor=\"#999999\"> \n";
echo " <td> \n";
echo " <div align=\"center\"><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"2\">Apercu</font></div> \n";
echo " </td> \n";
echo " <td> \n";
echo " <div align=\"center\"><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"2\">Nom</font></div> \n";
echo " </td> \n";
echo " <td> \n";
echo " <div align=\"center\"><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"2\">Largeur</font></div> \n";
echo " </td> \n";
echo " <td> \n";
echo " <div align=\"center\"><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"2\">Hauteur</font></div> \n";
echo " </td> \n";
echo " </tr> \n";
}
$imagelist = GetFileList($RepGrosseImages);
$nbr_par_page =$nbr_colonne * $nbr_ligne;
$nbr_tot =count($imagelist);
$debut = 1;
$j = 1;
$fin = $nbr_par_page;
if (!isset($ppage))
{
$ppage=1;
}
for($i=$debut; $i < $nbr_tot +1 ; $i++) {
$image = $imagelist[$i-1];
if (file_exists("$RepGrosseImages$image"))
{
$size = getimagesize("$RepGrosseImages$image");
$width = $size[0];
$height = $size[1];
$rwidth = $size[0]+20;
$rheight = $size[1]+20;
$page = ceil($i/$nbr_par_page);
$tpage[$i] = $page ;
}
if ($page == $ppage)
{
if ($col_simple != "Oui")
{
if ($j == ( $nbr_colonne ) )
{
echo " <td> \n";
echo " <center> \n";
echo " <a href='javascript:openPopWin(\"$RepGrosseImages$image\",$rwidth,$rheight,\"\",\"cen\",\"cen\")'> \n";
if ($thumb == "Oui")
{
echo " <img src='thumb/$image' border=0 alt='$image*$width*$height' \n";
}
else
{
echo " <img src='$RepGrosseImages$image' border=0 alt='$image*$width*$height' \n";
}
echo " width='$pourcentage_reduce'><br><font face=\"Arial,Helvetica\"><font size=-2>$image</font></font></a></td> \n";
echo "</center> \n";
echo "</tr> \n";
$j = 1;
}
else
{
echo " <td> \n";
echo " <center> \n";
echo " <a href='javascript:openPopWin(\"$RepGrosseImages$image\",$rwidth,$rheight,\"\",\"cen\",\"cen\")'> \n";
if ($thumb == "Oui")
{
echo " <img src='thumb/$image' border=0 alt='$image*$width*$height' \n";
}
else
{
echo " <img src='$RepGrosseImages$image' border=0 alt='$image*$width*$height' \n";
}
echo " width='$pourcentage_reduce'><br><font face=\"Arial,Helvetica\"><font size=-2>$image</font></font></a></td></center> \n";
$j = $j + 1;
}
}
else
{
echo "<tr> \n";
echo "<td> \n";
echo "<div align=\"center\"><a href='javascript:openPopWin(\"$RepGrosseImages$image\",$rwidth,$rheight,\"\",\"cen\",\"cen\")'> \n";
if ($thumb == "Oui")
{
echo " <img src='thumb/$image' border=0 alt='$image*$width*$height' \n";
}
else
{
echo " <img src='$RepGrosseImages$image' border=0 alt='$image*$width*$height' \n";
}
echo " width='50'></a></div> \n";
echo "</td> \n";
echo "<td> \n";
echo "<div align=\"center\"><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\">$image</font></div> \n";
echo "</td> \n";
echo "<td> \n";
echo "<div align=\"center\"><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\">$rwidth</font></div> \n";
echo "</td> \n";
echo "<td> \n";
echo "<div align=\"center\"><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\">$rheight</font></div> \n";
echo "</td> \n";
echo "</tr> \n";
$j = $j + 1;
}
} //if
} //for
echo "</table> \n";
echo "<BR> \n";
echo "<CENTER> \n";
$sval = -1;
while (list ($key, $val) = each ($tpage)) {
if ($sval != $val)
{
echo "<b><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\">[\n";
echo "<a href=\"index.php?page=climb&ppage=$val\">$val</a>";
echo "]\n";
$sval = $val;
}
}
echo "</CENTER> \n";
?>[/php]