Advertisement
Guest User

Paginacao Update Dream Gallery

a guest
Feb 11th, 2013
502
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.23 KB | None | 0 0
  1. <script src="js/jquery.min.js"></script>
  2. <link rel="stylesheet" href="css/gallery.css" type="text/css"/>
  3. <link rel="stylesheet" href="js/fancy/jquery.fancybox.css?v=2.1.0"  media="screen" type="text/css"/>
  4. <script src="js/fancy/jquery.fancybox.js?v=2.1.0" type="text/javascript"></script> 
  5. <script src="js/fancy/jquery.mousewheel-3.0.6.pack.js" type="text/javascript"></script>
  6. <style>
  7. .paginacao li{display:inline-block;padding:4px;}
  8. .paginacao li a {display:inline-block;padding:4px;text-decoration:none;color:#333;}
  9. .paginacao .current{color:red;}
  10. </style>
  11. <?php
  12. @header( 'Content-Type: text/html; charset=iso-8859-1' );
  13. require_once 'database/mysql.php';
  14. $db = new Mysql;
  15. $page = 0;
  16. $perpage = 10; //quantidade de fotos por página
  17. $current = 1;
  18. $link = '';
  19. if ( isset( $_GET['page'] ) )
  20. {
  21.     $current = $_GET['page'];
  22.     $page = $perpage * $_GET['page'] - $perpage;
  23.     if ( $_GET['page'] == 1 )
  24.     {
  25.         $page = 0;
  26.     }
  27. }
  28.  
  29. if ( isset( $_GET['id'] ) )
  30. {
  31.     $album_id = $_GET['id'];
  32.     $db->query( "select * from albuns join fotos on(album_id = foto_album) where foto_album = $album_id order by foto_pos asc" )->fetchAll();
  33.         $total = $db->rows;
  34.         if ( $total > $perpage )
  35.         {              
  36.             $link = "<ul class=\"paginacao\" style=\"float:left; width:99%;\">\n";
  37.             $prox = "javascript:;";
  38.             $ant = "javascript:;";
  39.             if ( $current >= 2 )
  40.             {
  41.                 $ant = "album.php?id=$album_id&page=" . ($current - 1);
  42.             }
  43.             if ( $current >= 1 && $current < ($total / $perpage))
  44.             {
  45.                 $prox = "album.php?id=$album_id&page=" . ($current + 1);
  46.             }
  47.             $link .= '<li><a href="' . $ant . '" title="Anterior">Ant</a></li>';
  48.             $from = round( $total / $perpage ) + 1;
  49.  
  50.             for ( $i = 1; $i <= $from - 1; $i++ )
  51.             {
  52.                 if ( $current == $i )
  53.                 {
  54.                     $link .= "<li><a class=\"current\" href=\"album.php?id=$album_id&page=$i\"><b>$i</b></a></li>\n";
  55.                 }
  56.                 else
  57.                 {
  58.                     $link .= "<li><a href=\"album.php?id=$album_id&page=$i\"><b>$i</b></a></li>\n";
  59.                 }
  60.             }
  61.             $link .= '<li><a href="' . $prox . '" title="Próxima">Prox</a></li>';
  62.             $link .= "</ul>\n";
  63.         }
  64.    
  65.    
  66.     $db->query( "select * from albuns join fotos on(album_id = foto_album) where foto_album = $album_id order by foto_pos asc LIMIT $page,$perpage" )->fetchAll();
  67.     if ( $db->rows >= 1 )
  68.     {
  69.         $album_name = $db->data[0]['album_name'];
  70.  
  71.         echo "<h1>" . utf8_decode( $album_name ) . "</h1>\n";
  72.         echo "<a href=\"album.php\" class=\"back\"><img src=\"images/left.png\"/> Voltar</a>";
  73.  
  74.         foreach ( $db->data as $fotos )
  75.         {
  76.             $f = ( object ) $fotos;
  77.             $d1 = strtotime( date( 'Y-m-d' ) ) ;
  78.             $d2 = strtotime( "$f->foto_data" );
  79.             $d3 = round( ($d1 - $d2) / 86400 );
  80.             $data = $d3;
  81.             ?>
  82.             <div class="box-detail" id="<?= $f->foto_id ?>">
  83.                 <div class="box-inner box-color">  
  84.                     <a class="rel" data-fancybox-group="gallery" href="fotos/<?= $f->foto_url ?>" caption="<?= utf8_decode( $f->foto_caption ) ?>">                    
  85.                         <img src="thumb.php?img=fotos/<?= $f->foto_url ?>" alt="" />
  86.                         <div class="box-inner-fx">
  87.                             <h2><?= utf8_decode( $f->foto_caption ) ?></h2>
  88.                             <span>Ampliar</span>
  89.                         </div>
  90.                     </a>
  91.                 </div>
  92.                 <div class="box-bottom">
  93.                     <?php
  94.                     if ( $f->foto_info != "" )
  95.                     {
  96.                         ?>
  97.                         <div class="box-bottom-left"><?= utf8_decode( $f->foto_info ) ?></div> 
  98.                         <div class="box-bottom-right"><?= $data ?> dia(s) atrás</div>
  99.                         <?php
  100.                     }
  101.                     else
  102.                     {
  103.                         ?>
  104.                         <div class="box-bottom-right"><?= $data ?> dia(s) atrás</div>
  105.                         <?php
  106.                     }
  107.                     ?>
  108.                 </div>     
  109.             </div>
  110.             <?php
  111.         }
  112.         echo $link;
  113.     }
  114. }
  115. else
  116. {
  117.     echo "<h1> Selecione um Álbum</h1> <br />\n";
  118.     $db->query( "select * from albuns order by album_name asc" )->fetchAll();
  119.     if ( $db->rows >= 1 )
  120.     {
  121.         $albuns = $db->data;
  122.         foreach ( $albuns as $album )
  123.         {
  124.             $a = ( object ) $album;
  125.             $db->query( "select * from fotos where foto_album = $a->album_id order by foto_pos asc" )->fetchAll();
  126.             if ( $db->rows >= 1 )
  127.             {
  128.                 $f = ( object ) $db->data[0];
  129.                 ?>
  130.                 <div class="box-detail box-alb" id="<?= $a->album_id ?>">
  131.                     <div class="box-inner-alb">
  132.                         <a href="album.php?id=<?= $a->album_id ?>" caption="<?= utf8_decode( $a->album_name ) ?>">                 
  133.                             <img src="thumb.php?img=fotos/<?= $f->foto_url ?>" alt=""/>
  134.                             <div class="box-inner-fx">
  135.                                 <h2><?= utf8_decode( $a->album_name ) ?></h2>
  136.                             </div>
  137.                         </a>
  138.                     </div>
  139.                     <div class="box-bottom">
  140.                         <div class="box-bottom-right-photo"><?= $db->rows ?> foto(s)</div> 
  141.                     </div>     
  142.                 </div>
  143.                 <?php
  144.             }
  145.         }
  146.     }
  147. }
  148. ?>
  149. <script type="text/javascript">
  150.     $(document).ready(function(){
  151.         $('.box-alb').find('.box-inner-fx').css('background','url()').fadeIn(1000);
  152.                
  153.         $('.box-inner').hover(
  154.         function(){
  155.             $(this).find('.box-inner-fx').slideDown();
  156.         },
  157.         function(){
  158.             $(this).find('.box-inner-fx').slideUp();
  159.         }) 
  160.         window.onload = function()
  161.         {
  162.            
  163.             $(".rel").fancybox({
  164.                 openEffect : 'elastic',
  165.                 openSpeed  : 150,
  166.                 closeEffect : 'elastic',
  167.                 closeSpeed  : 350,
  168.                 arrows: true,
  169.                 helpers : {
  170.                     title : {
  171.                         type : 'float'//float, over, outside,inside
  172.                     }}                
  173.                 });
  174.             }
  175.         })
  176. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement