web2rent
Threadersteller
Dabei seit: 16.03.2015
Ort: Leipzig
Alter: -
Geschlecht:
|
Verfasst Mo 16.03.2015 15:51
Titel PHP Ordner Sortieren |
|
|
Hallo liebe Forumgemeinde, leider konnte ich mit meiner Suche nichts sinnvolles herausfinden, darum frage ich hier nach.
es geht um ein Script welches Bilder aus einen Ordner sortiert und diese als Thubnail korrekt sortiert. Leider funktioniert diese Sortierung nicht mehr korrekt nach einen Serverumzug.
Das Skript soll die Bilder aus den Ordnern entsprechend sortieren. Die Ordner haben z.B. folgende Bennenung:
01_test123
02_test321
03_test213
04_test312
leider sortiert das Skript die Bilder nicht mehr Nummerisch sondern durcheinander.
z.B.
02_test321
03_test213
01_test123
04_test312
Das Script sieht wie folgt aus:
Zitat: | <?php
//------------------- Funktionen ---------------- //
function getPluginPath()
{
$pfad = WP_PLUGIN_URL.'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__));
return $pfad;
}
$dir_dummy_array = array();
function scan($folder, $include_subdirs){
$dir_dummy_array = array();
if($content = opendir($folder)){
while(false !== ($file = readdir($content))){
if(is_dir("$folder/$file") && $file != "." && $file != "..")
{
array_push($dir_dummy_array, $file);
if ($include_subdirs)
scan("$folder/$file", true);
}
}
closedir($content);
}
return $dir_dummy_array;
$dir_dummy_array = array();
}
function buildLeuchten($pfad)
{
$formular_nr = 1;
// Anzahl der Einzelleuchten
$leuchtenfamilie_pfad = ABSPATH . 'wp-content/plugins/leuchten/' . $pfad;
$leuchtenfamilie_pfad_url = getPluginPath();
$leuchten_dirs = scan($leuchtenfamilie_pfad, true);
$anzahl_leuchten = count($leuchten_dirs);
echo '<style>';
echo '
#editionsub {
position: relative;
float: left;
width: 155px;
min-height: 150px;
padding: 5px;
padding-right: 0px;
padding-bottom: 0px;
background-color: #484b43;
}
#editionsub ul li {
position: relative;
width: 150px;
height: 150px;
margin-bottom: 5px;
}';
for ($ll = 1; $ll <= $anzahl_leuchten; $ll++)
{
echo '
#editionsub a.editionsubnavi'.$ll.' {
position: absolute;
width: 150px;
height: 150px;
background: url('.$leuchtenfamilie_pfad_url.$pfad.'/'.$leuchten_dirs[$ll-1].'/subnavi.jpg) no-repeat 0 0;
text-indent: -9999px;
}
#editionsub a.editionsubnavi'.$ll.'.selected,
#editionsub a.editionsubnavi'.$ll.':hover {
background: url('.$leuchtenfamilie_pfad_url.$pfad.'/'.$leuchten_dirs[$ll-1].'/subnavi_o.jpg) no-repeat 0 0;
}';
}
echo '</style>';
echo '
<div id="editionsub">
<ul>';
$selected_language = null;
if (isset($_GET['lang'])) {
$selected_language = trim(strip_tags($_GET['lang']));
}
switch ($selected_language) {
case 'en': include_once ($leuchtenfamilie_pfad . '/description_en.php'); $produktblatt_linktext = 'Product Sheet (PDF)'; $technische_angaben_linktext = 'Specifications »'; $ask_for_product = 'Product Inquiry'; $formular_nr = 2; break;
case 'fr': include_once ($leuchtenfamilie_pfad . '/description_fr.php'); $produktblatt_linktext = 'Fiche produit (PDF)'; $technische_angaben_linktext = 'Specification »'; $ask_for_product = 'Demande de produit'; $formular_nr = 3; break;
default: include_once ($leuchtenfamilie_pfad . '/description_de.php'); $produktblatt_linktext = 'Produktblatt (PDF)'; $technische_angaben_linktext = 'Technische Daten »'; $ask_for_product = 'Produkt anfragen'; $formular_nr = 1; break;
}
for ($ll = 1; $ll <= $anzahl_leuchten; $ll++) {
echo ' <li><a href="#" class="editionsubnavi'.$ll.'">'.$title[$ll].'</a></li>';
}
echo '
</ul>
</div>
<script>
var clickone = 1;
function change_clickone(neue_nr)
{
$(".editionsubnavi"+clickone).removeClass(\'selected\');
$(".editionsubnavi"+neue_nr).addClass(\'selected\');
clickone = neue_nr;
}
$(document).ready(function(){
change_clickone(1);';
$scrollschritte = 605;
for ($ll = 1; $ll <= $anzahl_leuchten; $ll++)
{
echo '
$(".editionsubnavi'.$ll.'").click(function(){
$("#editionitems").animate({"left": "'.($scrollschritte - ($ll*$scrollschritte)).'px"}, 1200);
change_clickone('.$ll.');
});';
}
echo '
});
</script>
<div id="editioncontainer">
<div id="editionitems">';
// Feldnummer für das Produktanfrageformular festlegen
switch ($name_leuchtenfamilien)
{
case 'Pop': $leuchtenfamilien_nr = 0; break;
case 'Grea': $leuchtenfamilien_nr = 4; break; // hat vier Leuchten
case 'Secret': $leuchtenfamilien_nr = 7; break; // hat
case 'Seves': $leuchtenfamilien_nr = 11; break;
case 'Masters': $leuchtenfamilien_nr = 13; break;
}
for ($ll = 1; $ll <= $anzahl_leuchten; $ll++)
{
echo '<div id="item'.$ll.'">
<div class="edition">
<div class="inhalt_edition">'.$description[$ll].'</div>
<div id="zusatzhead'.$ll.'"><a href="#">'.$technische_angaben_linktext.'</a></div>
<div class="zusatz" id="tectabelle'.$ll.'" style="display:none;">'.$specification[$ll].'</div>
<div class="zusatzlink"><a href="/produktanfrage/?'.$formular_nr.'ex_field14_'.($leuchtenfamilien_nr + $ll).'=1&lang='.$selected_language.'"><span class="beige" style="margin-right: 0.5em;">></span>'.$ask_for_product.'</a></div>
<div class="zusatzlink"><a href="'.$leuchtenfamilie_pfad_url.$pfad.'/'.$productsheet[$ll].'" target="_blank"><span class="beige" style="margin-right: 0.5em;">></span>'.$produktblatt_linktext.'</a></div>
<script>
$(\'#zusatzhead'.$ll.'\').click(function() { $(\'#tectabelle'.$ll.'\').slideToggle(\'slow\', function() { }); });
</script>
</div>
<div class="editiongaleriecontainer">
<ul class="produktbildcontainer'.$ll.'">
<li href="'.$leuchtenfamilie_pfad_url.$pfad.'/'.$leuchten_dirs[$ll-1].'/01_zoom.jpg" class="lightbox'.$ll.' active'.$ll.'" id="produktbild'.$ll.'1" style="z-index: 4;"><img src="'.$leuchtenfamilie_pfad_url.$pfad.'/'.$leuchten_dirs[$ll-1].'/01.jpg" border="0" alt="" /></li>';
if (file_exists($leuchtenfamilie_pfad . '/' . $leuchten_dirs[$ll-1] . '/02_zoom.jpg')) {
echo '
<li href="'.$leuchtenfamilie_pfad_url.$pfad.'/'.$leuchten_dirs[$ll-1].'/02_zoom.jpg" class="lightbox'.$ll.'" id="produktbild'.$ll.'2" style="z-index: 3;"><img src="'.$leuchtenfamilie_pfad_url.$pfad.'/'.$leuchten_dirs[$ll-1].'/02.jpg" border="0" alt="" /></li>
<li href="'.$leuchtenfamilie_pfad_url.$pfad.'/'.$leuchten_dirs[$ll-1].'/03_zoom.jpg" class="lightbox'.$ll.'" id="produktbild'.$ll.'3" style="z-index: 2;"><img src="'.$leuchtenfamilie_pfad_url.$pfad.'/'.$leuchten_dirs[$ll-1].'/03.jpg" border="0" alt="" /></li>
<li href="'.$leuchtenfamilie_pfad_url.$pfad.'/'.$leuchten_dirs[$ll-1].'/04_zoom.jpg" class="lightbox'.$ll.'" id="produktbild'.$ll.'4" style="z-index: 1;"><img src="'.$leuchtenfamilie_pfad_url.$pfad.'/'.$leuchten_dirs[$ll-1].'/04.jpg" border="0" alt="" /></li>';
}
echo '</ul>';
if (file_exists($leuchtenfamilie_pfad . '/' . $leuchten_dirs[$ll-1] . '/02_thumb.jpg')) {
echo '
<ul class="thumbs">
<li id="thumb'.$ll.'1" class="linkcursor" onclick="change_zindex(1, \'#produktbild'.$ll.'1\');"><img src="'.$leuchtenfamilie_pfad_url.$pfad.'/'.$leuchten_dirs[$ll-1].'/01_thumb.jpg" border="0" alt="" width="77" /></li>
<li id="thumb'.$ll.'2" class="linkcursor" onclick="change_zindex(1, \'#produktbild'.$ll.'2\');"><img src="'.$leuchtenfamilie_pfad_url.$pfad.'/'.$leuchten_dirs[$ll-1].'/02_thumb.jpg" border="0" alt="" width="77" /></li>
<li id="thumb'.$ll.'3" class="linkcursor" onclick="change_zindex(1, \'#produktbild'.$ll.'3\');"><img src="'.$leuchtenfamilie_pfad_url.$pfad.'/'.$leuchten_dirs[$ll-1].'/03_thumb.jpg" border="0" alt="" width="77" /></li>
<li id="thumb'.$ll.'4" class="linkcursor" onclick="change_zindex(1, \'#produktbild'.$ll.'4\');"><img src="'.$leuchtenfamilie_pfad_url.$pfad.'/'.$leuchten_dirs[$ll-1].'/04_thumb.jpg" border="0" alt="" width="77" style="width: 78px; margin-right: 0px;" /></li>
</ul>';
}
echo '
</div>
</div>';
}
echo '
</div>
</div>
<script type="text/javascript" src="'.getPluginPath().'js/activate_lightbox.js"></script>';
}
//------------------- BACKEND ------------------- //
function pluginOptions()
{
echo '<div class="wrapper">Hat kein Backend.</div>';
}
function pluginOptionsSeite() {
add_menu_page('Leuchten-Tool', 'Leuchten-Tool', 2, __FILE__, 'pluginOptions');
}
//------------------- FRONTEND ------------------- //
function leuchtenFrontend($theContent)
{
global $page_id;
if ( ! strpos($theContent, '[leuchten ') )
return $theContent;
else
{
$startPos = strpos ( $theContent , '=' );
if ( $startPos != FALSE)
{
$dummyContent = trim($theContent);
$endPos = -5;
$get_parameter = substr($dummyContent, ($startPos+1), $endPos);
buildLeuchten($get_parameter);
}
else
echo $theContent;
}
}
// ------------------ AKTIVIERUNG --------------- //
// CSS-Datei einbetten
function addStylesheet()
{
// $x = WP_PLUGIN_URL.'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__));
echo '<link rel="stylesheet" type="text/css" href="'.getPluginPath().'leuchten_styles.css">';
}
// add_action('admin_menu','pluginOptionsSeite');
add_action('wp_head','addStylesheet');
add_filter('the_content', 'leuchtenFrontend')
?> |
Über eure Hilfe würde ich mich sehr freuen!
Zuletzt bearbeitet von web2rent am Mo 16.03.2015 16:00, insgesamt 1-mal bearbeitet
|
|