Guest User

Helper_Flickr

a guest
May 30th, 2013
28
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. require_once("phpflickr/phpFlickr.php");
  3.  
  4. function flickr_photos( $apikey, $user )
  5. {
  6.     $f = new phpFlickr( "$apikey" );
  7.     $f->enableCache( "fs", "phpflickr/cache" );
  8.     $person = $f->people_findByUsername( "$user" );
  9.     $photos_url = $f->urls_getUserPhotos( $person['id'] );
  10.     $photos = $f->people_getPublicPhotos( $person['id'], NULL, NULL, 36 );
  11.  
  12.     $fphotos = array( );
  13.     foreach( (array) $photos['photos']['photo'] as $photo )
  14.     {
  15.         $photo_id = $photo['id'];
  16.         $photo_title = $photo['title'];
  17.         $aux['f_href'] = "$photos_url$photo_id";
  18.         $aux['f_href_m'] = $f->buildPhotoURL( $photo, "Medium" );
  19.         $aux['f_href_s'] = $f->buildPhotoURL( $photo, "Square" );
  20.         ;
  21.         $aux['f_title'] = "$photo_title";
  22.         $aux['f_src_s'] = $f->buildPhotoURL( $photo, "Square" );
  23.         $aux['f_src_m'] = $f->buildPhotoURL( $photo, "Medium" );
  24.         $fphotos[] = $aux;
  25.         unset( $aux );
  26.     }
  27.     return $fphotos;
  28. }
  29.  
  30. function flickr_sets( $apikey, $user )
  31. {
  32.     $f = new phpFlickr( "$apikey" );
  33.     $f->enableCache( "fs", "phpflickr/cache" );
  34.     $person = $f->people_findByUsername( "$user" );
  35.     $photos_url = $f->urls_getUserPhotos( $person['id'] );
  36.     $sets = $f->photosets_getList( $person['id'], NULL, NULL, 36 );
  37.     $fphotos = array( );
  38.     foreach( $sets['photoset'] as $set )
  39.     {
  40.         $set_title = $set['title'];
  41.         $set_id = $set['id'];
  42.         $setphotos = $f->photosets_getPhotos( $set_id );
  43.  
  44.         foreach( $setphotos['photoset']['photo'] as $photo )
  45.         {
  46.             $photo_id = $photo['id'];
  47.             $photo_title = $photo['title'];
  48.             $aux['f_set_title'] = "$set_title";
  49.             $aux['f_href'] = "$photos_url$photo_id";
  50.             $aux['f_title'] = "$photo_title";
  51.             $aux['f_src_s'] = $f->buildPhotoURL( $photo, "Square" );
  52.             $aux['f_src_m'] = $f->buildPhotoURL( $photo, "Medium" );
  53.  
  54.             $fphotos["$set_title"][] = $aux;
  55.             unset( $aux );
  56.         }
  57.     }
  58.     return $fphotos;
  59. }
  60.     function flickr_sets_html( $apikey, $user )
  61.     {
  62.         $f = new phpFlickr( "$apikey" );
  63.         $f->enableCache( "fs", "phpflickr/cache" );
  64.         $photos_url = $f->urls_getUserPhotos( "$user" );
  65.         $sets = $f->photosets_getList( "$user", NULL, NULL, 36 );
  66.         $fphotos = array( );
  67.         $html = "";
  68.         foreach( $sets['photoset'] as $set )
  69.         {
  70.             $set_title = $set['title'];
  71.             $set_id = $set['id'];
  72.             $setphotos = $f->photosets_getPhotos( $set_id );
  73.             $html .="<div class=\"fset\">\n";
  74.             $html .= "<h1>$set_title</h1>\n";
  75.      
  76.             foreach( $setphotos['photoset']['photo'] as $photo )
  77.             {
  78.                 $photo_id = $photo['id'];
  79.                 $photo_title = $photo['title'];
  80.      
  81.                 $aux['f_set_title'] = "$set_title";
  82.                 $aux['f_href'] = "$photos_url$photo_id";
  83.                 $aux['f_href_m'] = $f->buildPhotoURL( $photo, "Medium" );
  84.                 $aux['f_href_l'] = $f->buildPhotoURL( $photo, "Large" );
  85.                 $aux['f_href_s'] = $f->buildPhotoURL( $photo, "Square" );
  86.                 $aux['f_title'] = "$photo_title";
  87.                 $aux['f_src_s'] = $f->buildPhotoURL( $photo, "Square" );
  88.                 $aux['f_src_m'] = $f->buildPhotoURL( $photo, "Medium" );
  89.                 $aux['f_src_l'] = $f->buildPhotoURL( $photo, "Large" );
  90.      
  91.                 $html .= "<li>\n";
  92.                 $html .= " <a href=\"" . $aux['f_href_l'] . "\" title=\"" . $aux['f_title'] . "\" rel=\"$set_id\"> <img src=\"" . $aux['f_src_s'] . "\"  /> </a>\n";
  93.                 $html .= "</li>\n";
  94.      
  95.                 unset( $aux );
  96.             }
  97.      
  98.             $html .="</div>\n\n";
  99.         }
  100.         return $html;
  101.     }
  102.  
  103. function flickr_all_photos_html( $apikey, $user )
  104. {
  105.  
  106.     $f = new phpFlickr( "$apikey" );
  107.     $f->enableCache( "fs", "phpflickr/cache" );
  108.     $person = $f->people_findByUsername( "$user" );
  109.     $photos_url = $f->urls_getUserPhotos( $person['id'] );
  110.     $photos = $f->people_getPublicPhotos( $person['id'], NULL, NULL, 36 );
  111.  
  112.     $html = "<div class=\"fset\">\n";
  113.     $fphotos = array( );
  114.     foreach( (array) $photos['photos']['photo'] as $photo )
  115.     {
  116.         $photo_id = $photo['id'];
  117.         $photo_title = $photo['title'];
  118.         $aux['f_href'] = "$photos_url$photo_id";
  119.         $aux['f_href_m'] = $f->buildPhotoURL( $photo, "Medium" );
  120.         $aux['f_href_l'] = $f->buildPhotoURL( $photo, "Large" );
  121.         $aux['f_href_s'] = $f->buildPhotoURL( $photo, "Square" );
  122.         $aux['f_title'] = "$photo_title";
  123.         $aux['f_src_s'] = $f->buildPhotoURL( $photo, "Square" );
  124.         $aux['f_src_m'] = $f->buildPhotoURL( $photo, "Medium" );
  125.         $aux['f_src_l'] = $f->buildPhotoURL( $photo, "Large" );
  126.  
  127.         $html .= "<li>\n";
  128.         $html .= " <a href=\"" . $aux['f_href_l'] . "\" title=\"" . $aux['f_title'] . "\" rel=\"lightbox[$photo_id]\" > <img src=\"" . $aux['f_src_s'] . "\"  /> </a>\n";
  129.         $html .= "</li>\n";
  130.     }
  131.     "</div>\n";
  132.     return $html;
  133. }
  134.  
  135. function flickr_photos_slide( $apikey, $user )
  136. {
  137.     $f = new phpFlickr( "$apikey" );
  138.     $f->enableCache( "fs", "phpflickr/cache" );
  139.     $person = $f->people_findByUsername( "$user" );
  140.     $photos_url = $f->urls_getUserPhotos( $person['id'] );
  141.     $photos = $f->people_getPublicPhotos( $person['id'], NULL, NULL, 36 );
  142.  
  143.     $html = "";
  144.     foreach( (array) $photos['photos']['photo'] as $photo )
  145.     {
  146.         $photo_id = $photo['id'];
  147.         $photo_title = $photo['title'];
  148.         $photo_src_thumb = $f->buildPhotoURL( $photo, "Square" );
  149.         $photo_src = $f->buildPhotoURL( $photo, "large" );
  150.  
  151.         $description = $f->photos_getInfo( $photo_id );
  152.         $photo_desc = $description['photo']['description'];
  153.  
  154.  
  155.         $html .= "<div>\n";
  156.         $html .= "<img src=\"$photo_src\" />\n";
  157.         $html .= "<div class=\"caption elemHover fromRight\" style=\"bottom:65px; padding-bottom:5px; color:#ff0; text-transform:uppercase\">$photo_title</div>\n";
  158.         $html .= "<div class=\"caption elemHover fromLeft\" style=\"padding-top:5px;\">$photo_desc</div>\n";
  159.         $html .= "</div>\n";
  160.     }
  161.     return $html;
  162. }
  163.  
  164. function flickr_photos_slide_set( $apikey, $user, $photoset_id )
  165. {
  166.     $f = new phpFlickr( "$apikey" );
  167.     $f->enableCache( "fs", "phpflickr/cache" );
  168.     $photos = $f->photosets_getPhotos( $photoset_id );
  169.  
  170.     $html = "";
  171.     foreach( $photos['photoset']['photo'] as $photo )
  172.     {
  173.         $photo_id = $photo['id'];
  174.         $photo_title = $photo['title'];
  175.         $photo_src_thumb = $f->buildPhotoURL( $photo, "Square" );
  176.         $photo_src = $f->buildPhotoURL( $photo, "large" );
  177.  
  178.         $description = $f->photos_getInfo( $photo_id );
  179.         $photo_desc = $description['photo']['description'];
  180.  
  181.         $html .= "<a href=\"$photo_src\">\n";
  182.         $html .= "<img src=\"$photo_src\" />\n";
  183.         $html .= "<span>$photo_title</span>\n";
  184.         $html .= "</a>\n";
  185.     }
  186.     return $html;
  187. }
  188. ?>
RAW Paste Data