/** * Return directory contents for the silo path * * @param string $path The path to retrieve the contents of * @return array An array of MediaAssets describing the contents of the directory */ public function silo_dir($path) { $path_elements = explode("/", $path); $type = $path_elements[0]; $size = Options::get('picasasilo__picasa_size'); $picasa = new Picasa(); $results = array(); switch ($type) { case 'albums': $xml = $picasa->get_albums(); foreach ($xml->channel->item as $album) { $media = $album->children('http://search.yahoo.com/mrss/'); $photo = $album->children('http://schemas.google.com/photos/2007'); $props['title'] = (string) $album->title; $results[] = new MediaAsset(self::SILO_NAME . '/photos/album/' . $photo->id, true, $props); } break; case 'photos': $xml = $picasa->get_photos(array($path_elements[1] => $path_elements[2])); foreach ($xml->entry as $photo) { $media = $photo->children('http://search.yahoo.com/mrss/'); $props['filetype'] = 'picasa'; $props['thumbnail_url'] = (string) $media->group->thumbnail->attributes()->url; $props['title'] = (string) $media->group->title; $props['description'] = (string) $media->group->description; //$props['filetype'] = str_replace("/", "_", $photo->content->attributes()->type); //Utils::debug($photo->content->attributes()->type); //Add the desired size to the url $src = (string) $photo->content->attributes()->src; $props['url'] = substr($src, 0, strrpos($src, '/')) . "/{$size}" . substr($src, strrpos($src, '/')); // Do the same for fullsize, Google does not return fullsize by default $props['picasa_url'] = substr($src, 0, strrpos($src, '/')) . "/s0" . substr($src, strrpos($src, '/')); $results[] = new MediaAsset(self::SILO_NAME . '/photos/' . $path_elements[2] . '/' . $media->group->title, false, $props); } break; case 'recent': $xml = $picasa->get_photos(); foreach ($xml->entry as $photo) { $media = $photo->children('http://search.yahoo.com/mrss/'); $props['filetype'] = 'picasa'; $props['thumbnail_url'] = (string) $media->group->thumbnail->attributes()->url; $props['title'] = (string) $media->group->title; //$props['filetype'] = str_replace("/", "_", $photo->content->attributes()->type); //Add the desired size to the url $src = (string) $photo->content->attributes()->src; $props['url'] = substr($src, 0, strrpos($src, '/')) . "/{$size}" . substr($src, strrpos($src, '/')); $props['picasa_url'] = $src; $results[] = new MediaAsset(self::SILO_NAME . '/photos/' . $media->group->title, false, $props); } break; case 'tags': $xml = $picasa->get_tags(); foreach ($xml->entry as $tag) { $props['title'] = (string) $tag->title; $results[] = new MediaAsset(self::SILO_NAME . '/photos/tag/' . (string) $tag->title, true, $props); } break; case '': $results[] = new MediaAsset(self::SILO_NAME . '/albums', true, array('title' => 'Albums')); $results[] = new MediaAsset(self::SILO_NAME . '/recent', true, array('title' => 'Recently Uploaded')); $results[] = new MediaAsset(self::SILO_NAME . '/tags', true, array('title' => 'Tags')); break; } return $results; }