Ver Mensaje Individual
  #5 (permalink)  
Antiguo 21/05/2015, 02:04
Jenn90
 
Fecha de Ingreso: junio-2014
Mensajes: 14
Antigüedad: 9 años, 11 meses
Puntos: 0
Respuesta: Paginación para mostrar Thumbnails

Cita:
Iniciado por enlinea777 Ver Mensaje
Listo

Código PHP:
<?php
if (!(isset($_GET['temp']))) {
                        echo
"no existe";
                    } else{ 
                        foreach (
$_GET['temp'] as $temp) {
                          
                        }
                        
                        if(
$temp=="A") {

                        } elseif (
$temp=="C") {

                            
$path 'images'# Directorio donde están las imágenes
                            
echo '<table>';
                            echo
'<tr>';

                            
temp($path$temp);
                        }
                    }

    function 
make_thumb($folder,$src,$dest,$thumb_width) {

        if (
preg_match("#([a-zA-Z0-9_\-\s]+)\.(jpg|JPG)#is",$src)){

            
$source_image imagecreatefromjpeg($folder.'/'.$src);
        } elseif (
preg_match("#([a-zA-Z0-9_\-\s]+)\.(png|PNG)#is",$src)){

                
$source_image imagecreatefrompng($folder.'/'.$src);
        }

        
$width imagesx($source_image);
        
$height imagesy($source_image);

        
$thumb_height floor($height*($thumb_width/$width));

        
$virtual_image imagecreatetruecolor($thumb_width,$thumb_height);

        
imagecopyresampled($virtual_image,$source_image,0,0,0,0,$thumb_width,$thumb_height,$width,$height);

        
imagejpeg($virtual_image,$dest,100);

    }

    
// display pagination
    
function print_pagination($numPages,$currentPage,$temp) {

       echo 
'Page '$currentPage .' of '$numPages;
       
       if (!isset(
$temp)) {
           echo 
"no existe";
       } else {
            if (
$numPages 1) {
                echo 
'&nbsp;&nbsp;';

                if (
$currentPage 1) {
                    
$prevPage $currentPage 1;
                    
                    echo 
'<a href="'$_SERVER['PHP_SELF'] .'?p='$prevPage.'">&laquo;&laquo;</a>';
                }       

                for( 
$e=0$e $numPages$e++ ) {
                    
$p $e 1;

                    if (
$p == $currentPage) {        
                        
$class 'current-paginate';
                    } else {
                        
$class 'paginate';
                    } 
                    echo 
$_SERVER['PHP_SELF'];
                    
//echo '<a href="http://www.forosdelweb.com/f18/paginacion-para-mostrar-thumbnails-1128115/campanas.php?temp%5B%5D=C&calendar=Introduce+una+fecha...">1</a>';
                    
echo '<a class="'$class .'" href="'$_SERVER['PHP_SELF'] .'?p='$p .'">'$p .'</a>';
                }

                if (
$currentPage != $numPages) {
                    
$nextPage $currentPage 1;    
                    echo 
'<a href="'$_SERVER['PHP_SELF'] .'p='$nextPage.'">&raquo;&raquo;</a>';
                }
                
            }
       }
    }

    function 
temp($path$temp) {

        
$itemsPerPage '16';         // number of images per page    
        
$thumb_width  '120';        // width of thumbnails
        
$thumb_height '85';         // height of thumbnails
        
$src_files    scandir($path); // files in current folder
        
$extensions   = array(".jpg",".png",".gif",".JPG",".PNG",".GIF"); // allowed extensions in photo gallery

        
echo '<div class="gallery">';
        
        
$files = array();

        foreach(
$src_files as $file) {

            
$ext strrchr($file'.');

            if(
in_array($ext$extensions)) {

                
array_push$files$file );          

                if (!
is_dir($path.'/thumbs')) {
                    
mkdir($path.'/thumbs');
                    
chmod($path.'/thumbs'0777);
                    
//chown($path.'/thumbs', 'apache'); 
                
}

                
$thumb $path.'/thumbs/'.$file;

                if (!
file_exists($thumb)) {
                    
make_thumb($path,$file,$thumb,$thumb_width); 
                }                                
            }
        }

        if ( 
count($files) == ) {
            echo 
$path;
            echo 
'There are no photos in this album!';
        } else {
            
$numPages ceilcount($files) / $itemsPerPage );

            if(isset(
$_GET['p'])) {

                
$currentPage $_GET['p'];

                if(
$currentPage $numPages) {
                    
$currentPage $numPages;
                }
            } else {
                
$currentPage=1;
            } 

            
$start = ( $currentPage $itemsPerPage ) - $itemsPerPage;

            for( 
$i=$start$i<$start $itemsPerPage$i++ ) {

                if( isset(
$files[$i]) && is_file$path .'/'$files[$i] ) ) { 

                    echo 
'<div class="thumb">
                    <a href="'
$path .'/'$files[$i] .'?temp='.$_GET['temp'].'" class="albumpix" rel="albumpix">
                    <img src="'
$path .'/thumbs/'$files[$i] .'" width="'.$thumb_width.'" height="'.$thumb_height.'" alt="" />
                    </a>  
                    </div>'

                } else {

                    if( isset(
$files[$i]) ) {
                        echo 
$files[$i];
                    }
                }
            }


            echo 
'<div class="clear"></div>';

            echo 
'<div class="p5-sides">
            <div class="float-left">'
.count($files).' images</div>
            <div class="float-right" class="paginate-wrapper">'
;

            if (
$temp="C") {
                
print_pagination($numPages,$currentPage,$temp);
            }

            echo 
'</div>
            <div class="clearb10">
            </div>'
;
        }
    }
?>
Muchas gracias!

Entiendo que la línea que modificaste es ésta:

Código PHP:
echo '<div class="thumb"> 
                    <a href="'
$path .'/'$files[$i] .'?temp='.$_GET['temp'].'" class="albumpix" rel="albumpix"> 
                    <img src="'
$path .'/thumbs/'$files[$i] .'" width="'.$thumb_width.'" height="'.$thumb_height.'" alt="" /> 
                    </a>   
                    </div>'

Me sale un error en la primera línea:

Notice: Array to string conversion

¿Cómo podría resolverlo?