Bilder Modul sortierung

Gesperrt
Defender
Beiträge: 7
Registriert: Mo 7. Jun 2004, 18:13
Kontaktdaten:

Bilder Modul sortierung

Beitrag von Defender » Mi 14. Jul 2004, 09:11

Moin,

ich hab mir das Bilder modul runter geladen und zwar das hier (Output):

Code: Alles auswählen

<?php 

$imagedir="CMS_VALUE[2]"; 
$thumbnails="CMS_VALUE[3]";  
$imagetypes=explode(";","CMS_VALUE[4]"); 
$rows="CMS_VALUE[6]";  
$cols="CMS_VALUE[5]"; 

$thb_x_size="CMS_VALUE[7]"; 
$thb_y_size="CMS_VALUE[8]"; 

$image_idcat="CMS_VALUE[0]";  
$image_idside="CMS_VALUE[1]"; 

$im_path="CMS_VALUE[9]"; 

//-- config ende ------------------------------------- 

function is_image($filename,$typearray) { 
  reset($typearray); 
  while($val=each($typearray)) { 
     if (strstr($filename,$val[value])!==false) { 
       return true; 
     } 
  } 
} 

//-- functions ende ---------------------------------- 

if (!isset($mmstart)) { 
  $mmstart=0; 
} 

// Anzeige eines Bildes oder Übersicht? 

if ($subfile!="") { 
// Bild anzeigen 
echo "<img src=\"$subfile\">"; 

} else { 
// Gallery anzeigen 

$handle=opendir($imagedir); 

echo "<table width=\"100%\" height=\"100%\"  border=\"0\" cellpadding=\"5\">"; 
$n=0; 
$filearray=Array(); 
while (false !== ($file = readdir($handle))) { 
        if ($file != "." && $file != ".." && is_image($file,$imagetypes)) { 
             $filearray[]=$file; 
        } 
} 

reset($filearray); 

// skip images... 
for ($n=0;$n<$mmstart;$n++) 
  $ffile=each($filearray); 
$n=0; 
while ($ffile=each($filearray)) { 
             $file=$ffile[value]; 
             // generate thumbnail, if nessesairy. Now THIS is fun :) 
             // natuerlich nur, wenn imagemagick vorhanden ist... 
            if (!file_exists($thumbnails."/thb_".$file) ) { 
               if ($im_path!="") { 
                 $cmd=$im_path."/convert -scale ".$thb_x_size."x".$thb_y_size." ".$imagedir."/".$file." ".$thumbnails."/thb_".$file; 

                 exec($cmd); 
                 // nochmal prüfen! 
                 $thumbnail=file_exists($thumbnails."/thb_".$file); 
                } else 
                  $thumbnail=false; 
            } else 
              $thumbnail=true; 
            if ($n%$cols==0) 
              echo "<tr>\n"; 
            if ($image_idcat!=0) 
              $url=$sess->url("front_content.php?client=$client&lang=$lang&subid=$subid&idcatside=$image_idcat&subfile=".rawurlencode($imagedir."/".$file));  
            else 
              $url=$sess->url("front_content.php?client=$client&lang=$lang&subid=$subid&idcat=$idcat&idside=$idside&subfile=".rawurlencode($imagedir."/".$file));
  
            echo "<td valign=\"middle\" align=\"center\" width=\"$thb_x_size\" height=\"$thb_y_size\"><a href=\"/cms/dw.php?file=$file&imagedir=CMS_VALUE[2]\" target=\"dw\" onbeforeunload=\"MM_openBrWindow(\'/cms/dw.php?file=$file&imagedir=CMS_VALUE[2]\',\'dw\',\'menubar=yes,scrollbars=yes,resizable=yes,width=700,height=400\')\">".($thumbnail ? "<img src=\"$thumbnails/thb_$file\" border=\"0\">":"$file")."</a></td> 
            \n"; 
            $n++; 
            if ($n%$cols==0) 
              echo "</tr>\n"; 
          

        // nur solange wie's not tut... 
        if ($n>=$rows*$cols) 
          break; 
    } 
echo "<tr> <td colspan=\"$cols\" align=\"center\" height=\"35\" valign=\"middle\">"; 

if ($mmstart>0) { 
  $url=$sess->url("front_content.php?client=$client&lang=$lang&idcat=$idcat&idart=$idart&subid=$subid&idside=$idside&mmstart=".($mmstart-$rows*$cols)); 
  echo "<a href=\"$url\">vorherige Bilder...</a>"; 
} 

echo " | zeige Bilder ".($mmstart+1)." - ".($mmstart+$n)." | "; 

if ($n+$mmstart<count($filearray)) { 
  $url=$sess->url("front_content.php?client=$client&lang=$lang&idcat=$idcat&idart=$idart&subid=$subid&idside=$idside&mmstart=".($mmstart+$rows*$cols)); 
  echo "<a href=\"$url\">weitere Bilder...</a>"; 
} 
echo "</td>\n"; 
echo "</tr>\n"; 
echo "</table>"; 
} // Ende Gallery anzeigen 
?>


da ich ein totaler PHP versager bin ist mal meine frage, kann mir das modul vieleicht jemand umstricken damit es die bilder sortiert? den derzeit stellt es die bilder total durcheinander da!

emergence
Beiträge: 10641
Registriert: Mo 28. Jul 2003, 12:49
Wohnort: Austria
Kontaktdaten:

Beitrag von emergence » Mi 14. Jul 2004, 13:28

da nicht weiss wonach du sortieren möchtest kannst du mal das versuchen

vor

Code: Alles auswählen

reset($filearray);
ergänzt du

Code: Alles auswählen

sort($filearray);
du kannst auch rsort nehmen...

doku dazu findest du unter
http://de.php.net/manual/en/function.sort.php
oder
http://de.php.net/manual/en/function.rsort.php
*** make your own tools (wishlist :: thx)

Defender
Beiträge: 7
Registriert: Mo 7. Jun 2004, 18:13
Kontaktdaten:

Daaaaaaaaaaaaaanke

Beitrag von Defender » Mi 14. Jul 2004, 15:11

rsort

passt, super gut :D

cu

Michael

Gesperrt