return strlen($str) == strspn($str, '0123456789');␊ |
}␊ |
␊ |
public static function photoUrl($user, $photo, $album = null) {␊ |
// At least user and photo are required to access a photo entry␊ |
if (! isset($user, $photo))␊ |
return null;␊ |
␊ |
$user = "user/$user";␊ |
$photo = self::isId($photo) ? "photoid/$photo" : "photo/$photo";␊ |
$url = 'http://picasaweb.google.com/data/entry/api';␊ |
␊ |
// The album is optional␊ |
if (isset($album)) {␊ |
$album = self::isId($album) ? "albumid/$album" : "album/$album";␊ |
$url = "$url/$user/$album/$photo";␊ |
} else {␊ |
$url = "$url/$user/$photo";␊ |
/**␊ |
* Build a Picasaweb URL.␊ |
*␊ |
* Entry point for building the canonical Picasaweb URL from its␊ |
* components.␊ |
*␊ |
* @param String $user The Picasaweb user␊ |
* @param String $album The album id (or its canonical title),␊ |
* optional for photo URLs.␊ |
* @param String $photo The photo id: leave it null for albums.␊ |
* @return String The URL or null on errors.␊ |
*/␊ |
private static function url($user, $album, $photo = null) {␊ |
$url = null;␊ |
␊ |
// The user is always required by the Picasaweb API␊ |
if (isset($user)) {␊ |
$domain = 'http://picasaweb.google.com';␊ |
$user = "/user/$user";␊ |
isset($album) and $album = self::isId($album) ? "/albumid/$album" : "/album/$album";␊ |
isset($photo) and $photo = self::isId($photo) ? "/photoid/$photo" : "/photo/$photo";␊ |
␊ |
if (isset($photo)) {␊ |
// Photo URL␊ |
$url = "$domain/data/entry/api$user$album$photo";␊ |
} elseif (isset($album)) {␊ |
// Album URL␊ |
$url = "$domain/data/feed/api$user$album";␊ |
}␊ |
}␊ |
␊ |
return $url;␊ |
}␊ |
␊ |
public static function albumUrl($user, $album) {␊ |
// Both user and album are required to access an album␊ |
if (! isset($user, $album))␊ |
return null;␊ |
␊ |
$user = "user/$user";␊ |
$album = self::isId($album) ? "albumid/$album" : "album/$album";␊ |
␊ |
return "http://picasaweb.google.com/data/feed/api/$user/$album";␊ |
}␊ |
␊ |
public static function photo($url) {␊ |
$tree = self::xmlFetch($url);␊ |
if (empty($tree))␊ |
|
return null;␊ |
} elseif (empty($photo)) {␊ |
$viewer = new SSViewer('Picasaweb_album');␊ |
$data = self::album(self::albumUrl($user, $album));␊ |
$data = self::album(self::url($user, $album));␊ |
} else {␊ |
$viewer = new SSViewer('Picasaweb_photo');␊ |
$data = self::photo(self::photoUrl($user, $photo, $album));␊ |
$data = self::photo(self::url($user, $album, $photo));␊ |
}␊ |
␊ |
if (is_null($data))␊ |