enableCache('db', $GLOBALS['flickr_cache_db'], $GLOBALS['flickr_cache_exp'], $GLOBALS['flickr_cache_table']); } // whoami $GLOBALS['nsid'] = $f->people_findByUsername($GLOBALS['flickr_username']); } // "Hello World" function function photos_flickr_hello() { // Bring in our flickr object and NSID $f = $GLOBALS['f']; $nsid = $GLOBALS['nsid']; // Get the friendly URL of the user's photos $photos_url = $f->urls_getUserPhotos($nsid); // Get the user's first 36 public photos $photos = $f->people_getPublicPhotos($nsid, NULL, 36); // Loop through the photos and output the html foreach ($photos['photo'] as $photo) { print ""; print "$photo[title]"; print ""; $i++; // If it reaches the sixth photo, insert a line break if ($i % 6 == 0) { echo "
\n"; } } } // Print a reasonable index page. function photos_index( $num_per_page = 25, $num_per_row = 5, $page = NULL, $thumb_type='square', $thumb_before = '', $thumb_after = '', $row_sep = '
' ) { // Bring in our flickr object and NSID $f = $GLOBALS['f']; $nsid = $GLOBALS['nsid']; // IF no page is passed, check $_REQUEST, else set to 1 if( $page == NULL ) { if( $_REQUEST['page'] ) { $page = $_REQUEST['page']; } else { $page = 1; } } if( $_REQUEST['tag'] ) { $photos = $f->photos_search(array("user_id"=>$nsid, "tags"=>$_REQUEST['tag'], "per_page"=>$num_per_page, "page"=>$page)); } else { $photos = $f->people_getPublicPhotos($nsid, NULL, $num_per_page, $page); } foreach ($photos['photo'] as $photo) { $i++; print $thumb_before . "" . "\"$photo[title]\"buildPhotoURL($photo, $thumb_type)."\" />" . "" . $thumb_after."\n"; if( $i%$num_per_row == 0 ) { print $row_sep."\n"; } } } // Print "paginate" link bar thingy function photos_pageindex( $context = 2, $num_per_page = 25, $item_sep = ', ', $dotdotdot = " . . . ",$page = NULL ) { // Bring in our flickr object and NSID $f = $GLOBALS['f']; $nsid = $GLOBALS['nsid']; // IF no page is passed, check $_REQUEST, else set to 1 if( $page == NULL ) { if( $_REQUEST['page'] ) { $page = $_REQUEST['page']; } else { $page = 1; } } // Count the number of pages ... if( $_REQUEST['tag'] ) { $photos = $f->photos_search(array("user_id"=>$nsid, "tags"=>$_REQUEST['tag'], "per_page"=>$num_per_page, "page"=>$page)); } else { $photos = $f->people_getPublicPhotos($nsid, NULL, $num_per_page, $page); } $pagecount = $photos['pages']; $n = 1; $emit = 0; $printme = ''; while( $n <= $pagecount ) { if( // 1, 2, 3 ... (1 <= $n && $n <= (1+$context)) || // ... 7, 8, [9], 10, 11 ... (($page-$context) <= $n && $n <= ($page+$context)) || // ... 98, 99, 100 (($pagecount-$context) <= $n && $n <= $pagecount) ) { if( $emit != 0 ) { print $item_sep; $emit = 0; } if( $n == $page ) { print "$n"; } else { if( $_REQUEST['tag'] ) { print "$n"; } else { print "$n"; } } $emit++; } else if( $emit != 0 ) { print $dotdotdot; $emit = 0; } $n++; } } // Print linked tags for a photo function photos_photo_tags( $tag_before = '', $tag_after = ' ', $photo_id = NULL ) { if( $photo_id == NULL ) { $photo_id = $_REQUEST['photo']; } // Bring in our flickr object $f = $GLOBALS['f']; $photo = $f->photos_getInfo($photo_id); if( $photo['tags'] ) { foreach( $photo['tags']['tag'] as $tag ) { print "$tag_before$tag[raw]$tag_after"; } } } // Print photo information - photopage URL function photos_photo_page_url( $photo_id = NULL ) { if( $photo_id == NULL ) { $photo_id = $_REQUEST['photo']; } print "http://www.flickr.com/photos/". $GLOBALS['flickr_username']."/".$photo_id."/"; } // Print photo information - URL function photos_photo_url( $size='medium', $photo_id = NULL ) { if( $photo_id == NULL ) { $photo_id = $_REQUEST['photo']; } // Bring in our flickr object $f = $GLOBALS['f']; $photo = $f->photos_getInfo($photo_id); print $f->buildPhotoURL($photo, $size); } // Print photo information - description function photos_photo_description( $photo_id = NULL ) { if( $photo_id == NULL ) { $photo_id = $_REQUEST['photo']; } // Bring in our flickr object $f = $GLOBALS['f']; $photo = $f->photos_getInfo($photo_id); $description = str_replace("\n", '
', $photo[description]); print $description; } // Print photo information - title function photos_photo_title( $photo_id = NULL ) { if( $photo_id == NULL ) { $photo_id = $_REQUEST['photo']; } // Bring in our flickr object $f = $GLOBALS['f']; $photo = $f->photos_getInfo($photo_id); print $photo[title]; } // Print next photo thumbnail function photos_photo_next_url( $thumb_type = 'square', $photo_id = NULL ) { if( $photo_id == NULL ) { $photo_id = $_REQUEST['photo']; } // Bring in our flickr object $f = $GLOBALS['f']; $nl = $f->photos_getContext($photo_id); if( $nl[nextphoto][id] != 0 ) { $photo = $f->photos_getInfo($nl[nextphoto][id]); print "buildPhotoURL($photo, $thumb_type). "\" title=\"".$nl[nextphoto][title]."\" />"; } } // Print prev photo thumbnail function photos_photo_prev_url( $thumb_type = 'square', $photo_id = NULL ) { if( $photo_id == NULL ) { $photo_id = $_REQUEST['photo']; } // Bring in our flickr object $f = $GLOBALS['f']; $nl = $f->photos_getContext($photo_id); if( $nl[prevphoto][id] != 0 ) { $photo = $f->photos_getInfo($nl[prevphoto][id]); print "buildPhotoURL($photo, $thumb_type). "\" title=\"".$nl[prevphoto][title]."\" />"; } } // Print next photo href function photos_photo_next_href( $photo_id = NULL ) { if( $photo_id == NULL ) { $photo_id = $_REQUEST['photo']; } // Bring in our flickr object $f = $GLOBALS['f']; $nl = $f->photos_getContext($photo_id); if( $nl[nextphoto][id] != 0 ) { print get_settings('home')."/photos/?photo=".$nl[nextphoto][id]; } } // Print prev photo href function photos_photo_prev_href( $photo_id = NULL ) { if( $photo_id == NULL ) { $photo_id = $_REQUEST['photo']; } // Bring in our flickr object $f = $GLOBALS['f']; $nl = $f->photos_getContext($photo_id); if( $nl[prevphoto][id] != 0 ) { print get_settings('home')."/photos/?photo=".$nl[prevphoto][id]; } } // Print next photo title function photos_photo_next_title( $photo_id = NULL ) { if( $photo_id == NULL ) { $photo_id = $_REQUEST['photo']; } // Bring in our flickr object $f = $GLOBALS['f']; $nl = $f->photos_getContext($photo_id); if( $nl[prevphoto][id] != 0 ) { print $nl[nextphoto][title]; } } // Print prev photo title function photos_photo_prev_title( $photo_id = NULL ) { if( $photo_id == NULL ) { $photo_id = $_REQUEST['photo']; } // Bring in our flickr object $f = $GLOBALS['f']; $nl = $f->photos_getContext($photo_id); if( $nl[prevphoto][id] != 0 ) { print $nl[prevphoto][title]; } } // Are we a page for one photo, or some nav index? function is_photo() { if( $_REQUEST['photo'] ) { return $_REQUEST['photo']; } else { return false; } } ?>