/**
  * Constructs an Image object.
  *
  * @param string $url   URL of the query for the data that should be returned based on Picasa's API documentation.
  *                      See {@link http://code.google.com/apis/picasaweb/gdata.html} for instructions on how to formulate
  *                      the URL.  The URL parameter can be left blank, which will still produce a populated Image
  *                      object as long as the $albums parameter contains XML from the Picasa Atom feed for an image.
  * @param SimpleXMLElement $albums  XML describing a Picasa image.  This can be left blank as long as a URL is specified in the
  *                                  url parameter that returns valid XML for a Picasa image.  If both are null, a
  *                                  {@link Picasa_Exception} is thrown.
  * @param array $contextArray       An array that can be passed to stream_context_create() to generate
  *                                  a PHP context.  See
  *                                  {@link http://us2.php.net/manual/en/function.stream-context-create.php}
  * @param boolean $useCache  You can decide not to cache a specific request by passing false here.  You may
  *                           want to do this, for instance, if you're requesting a private feed.
  * @throws {@link Picasa_Exception} If the XML suppled through either parameter does not contain valid XML.
  */
 public function __construct($url = null, SimpleXMLElement $albums = null, $contextArray = null, $useCache = true)
 {
     if ($url != null) {
         Picasa_Logger::getLogger()->logIfEnabled('Request string: ' . $url);
         $context = null;
         $xmldata = false;
         if ($contextArray != null) {
             $context = stream_context_create($contextArray);
         }
         if ($useCache === true) {
             $xmldata = Picasa_Cache::getCache()->getIfCached($url);
         }
         if ($xmldata === false) {
             Picasa_Logger::getLogger()->logIfEnabled('Cached copy not available, requesting image freshly for URL: ' . $url);
             $xmldata = @file_get_contents($url, false, $context);
             if ($useCache === true && $xmldata !== false) {
                 Picasa_Logger::getLogger()->logIfEnabled('Saving account to cache.');
                 Picasa_Cache::getCache()->setInCache($url, $xmldata);
             }
         } else {
             Picasa_Logger::getLogger()->logIfEnabled('Image retreived from cache.');
         }
         if ($xmldata == false) {
             throw Picasa::getExceptionFromInvalidQuery($url, $contextArray);
         }
         try {
             // Load the XML file into a SimpleXMLElement
             $albums = new SimpleXMLElement($xmldata);
         } catch (Exception $e) {
             throw new Picasa_Exception($e->getMessage(), null, $url);
         }
     }
     $this->contextArray = $contextArray;
     if ($albums != null) {
         foreach ($albums->link as $plink) {
             if ($plink['rel'] == 'alternate') {
                 $this->weblink = $plink['href'];
             }
         }
         $namespaces = $albums->getNamespaces(true);
         if (array_key_exists("media", $namespaces)) {
             $media_ns = $albums->children($namespaces["media"]);
             $this->description = $media_ns->group->description;
             $this->keywords = $media_ns->group->keywords;
             $this->thumbUrlMap = array();
             $this->thumbHeightMap = array();
             $this->previous = null;
             $this->next = null;
             $i = 0;
             $this->thumbnails = array();
             $thumb = $media_ns->group->thumbnail[$i];
             while ($thumb != null) {
                 $thumbAtt = $thumb->attributes();
                 $width = "" . $thumbAtt['width'];
                 $height = $thumbAtt['height'];
                 $url = $thumbAtt['url'];
                 // These fields are deprecated but included for backwards compatibility
                 $this->thumbUrlMap[$width] = $url;
                 $this->thumbHeightMap[$width] = $height;
                 $this->thumbnails[$i] = new Picasa_Thumbnail($url, $thumbAtt['width'], $thumbAtt['height']);
                 $i++;
                 $thumb = $media_ns->group->thumbnail[$i];
             }
             /* This is to support the previous implementation.  It may seem inefficiant to loop
              * through twice, but typically there will be 1-3 iterations, so it is inconsequential. */
             $thumb = $media_ns->group->thumbnail[0];
             if ($thumb != null) {
                 $thumbAtt = $media_ns->group->thumbnail[0]->attributes();
                 $this->smallThumb = $thumbAtt['url'];
             } else {
                 $this->smallThumb = null;
             }
             $thumb = $media_ns->group->thumbnail[1];
             if ($thumb != null) {
                 $thumbAtt = $thumb->attributes();
                 $this->mediumThumb = $thumbAtt['url'];
             } else {
                 $this->mediumThumb = null;
             }
             $thumb = $media_ns->group->thumbnail[2];
             if ($thumb != null) {
                 $thumbAtt = $thumb->attributes();
                 $this->largeThumb = $thumbAtt['url'];
             } else {
                 $this->largeThumb = null;
             }
             $this->contentUrlMap = array();
             $this->contentHeightMap = array();
             $i = 0;
             $thumb = $media_ns->group->content[$i];
             while ($thumb != null) {
                 $thumbAtt = $thumb->attributes();
                 $width = "" . $thumbAtt['width'];
                 $height = $thumbAtt['height'];
                 $url = $thumbAtt['url'];
                 $this->contentUrlMap[$width] = $url;
                 $this->contentHeightMap[$width] = $height;
                 $i++;
                 $thumb = $media_ns->group->content[$i];
             }
             $this->content = $thumbAtt['url'];
             $this->imageType = $thumbAtt['type'];
             // Pull and parse the tags
             if ($media_ns->group->keywords != null || strcmp($media_ns->group->keywords, "") != 0) {
                 // Make an array for to hold all of a photo's tags
                 $this->tags = array();
                 /* Tags are stored as a comma-delimited list.
                  * Tokenize the list on comma and strip it to get just the tag.
                  */
                 $tok = strtok($media_ns->group->keywords, ",");
                 $i = 0;
                 while ($tok != false) {
                     // Set the tag in the array
                     $this->tags[$i] = trim($tok);
                     $tok = strtok(",");
                     $i++;
                 }
             } else {
                 $this->tags = null;
             }
         } else {
             $this->description = null;
             $this->keywords = null;
             $this->smallThumb = null;
             $this->mediumThumb = null;
             $this->largeThumb = null;
             $this->content = null;
         }
         if (array_key_exists("gphoto", $namespaces)) {
             $gphoto_ns = $albums->children($namespaces["gphoto"]);
             $this->idnum = $gphoto_ns->id;
             $this->width = $gphoto_ns->width;
             $this->height = $gphoto_ns->height;
             $this->albumid = $gphoto_ns->albumid;
             $this->albumTitle = $gphoto_ns->albumtitle;
             $this->albumDescription = $gphoto_ns->albumdesc;
             $this->version = $gphoto_ns->version;
             $this->timestamp = $gphoto_ns->timestamp;
             $this->commentingEnabled = $gphoto_ns->commentingEnabled;
             if (strcmp($gphoto_ns->commentCount, "") == 0 || $gphoto_ns->commentCount === null) {
                 $this->commentCount = null;
             } else {
                 $this->commentCount = intval($gphoto_ns->commentCount);
             }
         } else {
             $this->idnum = null;
             $this->width = null;
             $this->height = null;
             $this->albumid = null;
             $this->commentCount = null;
             $this->version = null;
             $this->timestamp = null;
         }
         if (array_key_exists("exif", $namespaces)) {
             $exif_ns = $albums->children($namespaces["exif"]);
             $this->flash = $exif_ns->tags->flash;
             $this->fstop = $exif_ns->tags->fstop;
             $this->cameraMake = $exif_ns->tags->make;
             $this->cameraModel = $exif_ns->tags->model;
             $this->exposure = $exif_ns->tags->exposure;
             $this->focalLength = $exif_ns->tags->focallength;
             $this->iso = $exif_ns->tags->iso;
         } else {
             $this->flash = null;
             $this->fstop = null;
             $this->cameraMake = null;
             $this->cameraModel = null;
             $this->exposure = null;
             $this->focalLength = null;
             $this->iso = null;
         }
         if (array_key_exists("georss", $namespaces)) {
             $georss_ns = $albums->children($namespaces["georss"]);
             $gml_ns = @$georss_ns->children($namespaces["gml"]);
             if ($gml_ns !== null || $gml_ns !== false) {
                 $this->gmlPosition = @$gml_ns->Point->pos;
             } else {
                 $this->gmlPosition = null;
             }
         } else {
             $this->gmlPosition = null;
         }
         // Set the basic attributes
         $this->id = $albums->id;
         $this->title = $albums->title;
         $this->updated = $albums->updated;
         if ($albums->author != null && strcmp($albums->author, "") != 0) {
             $this->author = new Picasa_Author($albums->author);
         } else {
             $this->author = new Picasa_Author();
         }
         // The user is not a field in the XML for an image like it is for an album.  Thus, we parse.
         if ($this->author->getUser() == null || strcmp($this->author->getUser(), "") == 0) {
             $startUser = strpos($this->id, '/user/') + 6;
             $endUser = strpos($this->id, '/', $startUser);
             $this->author->setUser(substr($this->id, $startUser, $endUser - $startUser));
         }
         // If there are comments, retrieve them and put them into the comments field of the object
         if ($this->commentCount === null) {
             $this->comments = null;
         } else {
             if ($this->commentCount === 0) {
                 $this->comments = array();
             } else {
                 $this->comments = array();
                 $i = 0;
                 // Grab each comment and make it into an object
                 foreach ($albums->entry as $comment) {
                     $this->comments[$i] = new Picasa_Comment($comment);
                     $i++;
                 }
             }
         }
     }
 }
Beispiel #2
0
 /**
  * Constructs an Album object.  
  * When called, this method will fill out each private member	
  * of the Album object based on XML returned from Picasa's Atom feed.  It will also create
  * a Picasa_Image object for each image in the Album by passing XML for each image into 
  * the Picasa_Image constructor.	
  *
  * @param string $url   The URL of the Picasa query to retrieve the XML from.  See
  *                      http://code.google.com/apis/picasaweb/gdata.html for information on
  *                      how to format the URL.  If null, it is assumed that $albums param
  *                      has been supplied.
  * @param SimpleXMLElement $albums  XML for constructing the object.  If null, it is assumed that the 
  *                                  URL to the Atom feed has been supplied.  If both are null, a
  *                                  {@link Picasa_Exception} is thrown.
  * @param array $contextArray       An array that can be passed to stream_context_create() to generate
  *                                  a PHP context.  See 
  *                                  {@link http://us2.php.net/manual/en/function.stream-context-create.php}
  * @param boolean $useCache  You can decide not to cache a specific request by passing false here.  You may
  *                           want to do this, for instance, if you're requesting a private feed.
  * @throws {@link Picasa_Exception} If the XML suppled through either parameter does not contain valid XML.
  */
 public function __construct($url = null, SimpleXMLElement $albums = null, $contextArray = null, $useCache = true)
 {
     if ($url != null) {
         $xmldata = false;
         $context = null;
         Picasa_Logger::getLogger()->logIfEnabled('Request string: ' . $url);
         if ($contextArray !== null) {
             $context = stream_context_create($contextArray);
         }
         if ($useCache === true) {
             $xmldata = Picasa_Cache::getCache()->getIfCached($url);
         }
         if ($xmldata === false) {
             Picasa_Logger::getLogger()->logIfEnabled("Not using cached entry for " . $url);
             $xmldata = @file_get_contents($url, false, $context);
             if ($useCache === true && $xmldata !== false) {
                 Picasa_Logger::getLogger()->logIfEnabled("Refreshing cache entry for key " . $url);
                 Picasa_Cache::getCache()->setInCache($url, $xmldata);
             }
         }
         if ($xmldata === false) {
             throw Picasa::getExceptionFromInvalidQuery($url, $contextArray);
         }
         try {
             // Load the XML file into a SimpleXMLElement
             $albums = new SimpleXMLElement($xmldata);
         } catch (Exception $e) {
             throw new Picasa_Exception($e->getMessage(), null, $url);
         }
         // I'm not sure why there's a difference, but the icon is given in different ways
         // depending on if the document is just for an Album or if it's part of a larger document
         $this->icon = $albums->icon;
     }
     // Whether or not the contextArray is null, it should be set.
     $this->contextArray = $contextArray;
     if ($albums != null) {
         $namespaces = $albums->getNamespaces(true);
         $this->picasaAuthor = new Picasa_Author($albums->author);
         $this->editLink = null;
         $link = $albums->link[0];
         $i = 0;
         while ($link != null) {
             $attributes = $albums->link[$i]->attributes();
             if (strcmp($attributes["rel"], "edit") == 0) {
                 $this->editLink = $attributes["href"];
                 break;
             } else {
                 if (strcmp($attributes["rel"], "alternate") == 0) {
                     $this->weblink = $attributes["href"];
                 }
             }
             $i++;
             $link = $albums->link[$i];
         }
         if (array_key_exists("gphoto", $namespaces)) {
             $gphoto_ns = $albums->children($namespaces["gphoto"]);
             $this->location = $gphoto_ns->location;
             $this->idnum = $gphoto_ns->id;
             $this->numphotos = $gphoto_ns->numphotos;
             $this->photosRemaining = $gphoto_ns->numphotosremaining;
             $this->bytesUsed = $gphoto_ns->bytesUsed;
             $this->commentingEnabled = $gphoto_ns->commentingEnabled;
             $this->numComments = $gphoto_ns->commentCount;
             $this->timestamp = $gphoto_ns->timestamp;
             // The picasaAuthor field must be set before this line is executed
             if ($this->picasaAuthor->getUser() == null || strcmp($this->picasaAuthor->getUser(), "") == 0) {
                 $this->picasaAuthor->setUser($gphoto_ns->user);
             }
         }
         if (array_key_exists("media", $namespaces)) {
             $media_ns = $albums->children($namespaces["media"]);
             // As stated above, this is to account for the different placement of icon
             if ($url === null) {
                 $thumbAtt = $media_ns->group->thumbnail->attributes();
                 $this->icon = $thumbAtt["url"];
             }
         }
         if (array_key_exists("georss", $namespaces)) {
             $georss_ns = $albums->children($namespaces["georss"]);
             $gml_ns = $georss_ns->children($namespaces["gml"]);
             $this->gmlPosition = @$gml_ns->Point->pos;
         }
         $this->id = $albums->id;
         $this->title = $albums->title;
         $this->updated = $albums->updated;
         $this->published = $albums->published;
         $this->summary = $albums->summary;
         $this->rights = $albums->rights;
         $this->author = $albums->author->name;
         $this->subtitle = $albums->subtitle;
         $this->comments = null;
         $this->images = array();
         $i = 0;
         //Create a new Image object for each Image element
         foreach ($albums->entry as $images) {
             $this->images[$i] = new Picasa_Image(null, $images);
             $i++;
         }
     }
 }
Beispiel #3
0
 /**
  * Constructs an array of {@link Picasa_Author} objects based on the XML taken from either the $xml parameter or from the contents of $url.
  *
  * @param string $url                  A URL pointing to a Picasa Atom feed that has zero or more "entry" nodes represeing
  *                                     a Picasa author.  Optional, the default is null.  If this parameter is null, the method will
  *                                     try to get the XML content from the $xml parameter directly.
  * @param SimpleXMLElement $xml        XML from a Picasa Atom feed that has zero or more "entry" nodes represeing a Picasa author.  
  *                                     Optional, the default is null.  If the $url parameter is null and the $xml parameter is null,
  *                                     a {@Picasa_Exception} is thrown.  
  * @param array $contextArray          An array that can be passed to stream_context_create() to generate
  *                                     a PHP context.  See 
  *                                     {@link http://us2.php.net/manual/en/function.stream-context-create.php}
  * @param boolean $useCache            You can decide not to cache a specific request by passing false here.  You may
  *                                     want to do this, for instance, if you're requesting a private feed.
  * @throws {@link Picasa_Exception}    If the XML passed (through either parameter) could not be used to construct a {@link SimpleXMLElement}.
  * @return array                       An array of {@link Picasa_Author} objects representing all authors in the requested feed.
  * @see http://php.net/simplexml
  */
 public static function getAuthorArray($url = null, SimpleXMLElement $xml = null, $contextArray = null, $useCache = true)
 {
     if ($url != null) {
         $context = null;
         $authorXml = false;
         if ($contextArray != null) {
             $context = stream_context_create($contextArray);
         }
         if ($useCache === true) {
             $authorXml = Picasa_Cache::getCache()->getIfCached($url);
         }
         if ($authorXml === false) {
             Picasa_Logger::getLogger()->logIfEnabled("Not using cached entry for " . $url);
             $authorXml = @file_get_contents($url, null, $context);
             if ($useCache === true && $authorXml !== false) {
                 Picasa_Logger::getLogger()->logIfEnabled("Refreshing cache entry for key " . $url);
                 Picasa_Cache::getCache()->setInCache($url, $authorXml);
             }
         }
         if ($authorXml == false) {
             throw Picasa::getExceptionFromInvalidQuery($url);
         }
     }
     try {
         // Load the XML file into a SimpleXMLElement
         $xml = new SimpleXMLElement($authorXml);
     } catch (Exception $e) {
         throw new Picasa_Exception($e->getMessage(), null, $url);
     }
     $authorArray = array();
     $i = 0;
     foreach ($xml->entry as $author) {
         $authorArray[$i] = new Picasa_Author($author);
         $i++;
     }
     return $authorArray;
 }
Beispiel #4
0
 /**
  * Constructs an Account object.  
  * This method assigns Album objects to the Account,
  * but the Album objects that are constructed will not initially contain Image objects.  This is 
  * because the XML that is returned from Picasa does not contain individual Image nodes
  * for each Album, presumeably because it could potentially take a lot of time to fetch
  * every image in an Account when all you likely need are the Albums.  Starting with version
  * 3.0 of this API, the images are fetched from Picasa when {@link Picasa_Album::getImages()}
  * is called and {@link Picasa_Album::$images} is null. 
  *  
  * @param string $url    The URL for the specific query that should be returned, as defined 
  *			 in Picasa's API documentation (http://code.google.com/apis/picasaweb/gdata.html).
  *			 Optional, the default is null.  If this parameter is null, the xml must
  *			 come from the $xml parameter.
  * @param SimpleXMLElement $xml  XML from a Picasa Atom feed represeting a Picasa Account. Optional,
  *                                      the default is null.  If this parameter and the $url parameters are
  *                                      both null, a {@link Picasa_Exception} is thrown.  You cannot create
  *                                      an empty Picasa_Account instance.
  * @param array $contextArray  An array that can be passed to the PHP built in function {@link stream_context_create()}.
  *                             It contains useful information when retrieving a feed, including headers that
  *                             might include needed authorization information.
  * @param boolean $useCache  You can decide not to cache a specific request by passing false here.  You may
  *                           want to do this, for instance, if you're requesting a private feed.
  * @throws Picasa_Exception  If valid XML cannot be retrieved from the URL specified in $url or $xml. 
  */
 public function __construct($url = null, SimpleXMLElement $xml = null, $contextArray = null, $useCache = true)
 {
     if ($url != null) {
         Picasa_Logger::getLogger()->logIfEnabled('Request string: ' . $url);
         $context = null;
         $xmldata = false;
         if ($contextArray != null) {
             $context = stream_context_create($contextArray);
         }
         if ($useCache === true) {
             $xmldata = Picasa_Cache::getCache()->getIfCached($url);
         }
         if ($xmldata === false) {
             Picasa_Logger::getLogger()->logIfEnabled('Cached copy not available, requesting account freshly for URL: ' . $url);
             $xmldata = @file_get_contents($url, false, $context);
             if ($useCache === true && $xmldata !== false) {
                 Picasa_Logger::getLogger()->logIfEnabled('Saving account to cache.');
                 Picasa_Cache::getCache()->setInCache($url, $xmldata);
             }
         } else {
             Picasa_Logger::getLogger()->logIfEnabled('Account retreived from cache.');
         }
         if ($xmldata === false) {
             throw Picasa::getExceptionFromInvalidQuery($url, $contextArray);
         }
         try {
             // Load the XML file into a SimpleXMLElement
             $xml = new SimpleXMLElement($xmldata);
         } catch (Exception $e) {
             throw new Picasa_Exception($e->getMessage(), null, $url);
         }
     }
     // The basic data can easily be loaded from the XML
     $this->author = $xml->author->name;
     $this->id = $xml->id;
     $this->title = $xml->title;
     $this->subtitle = $xml->subtitle;
     $this->icon = $xml->icon;
     $this->picasaAuthor = new Picasa_Author($xml->author);
     foreach ($xml->link as $plink) {
         if ($plink['rel'] == 'alternate') {
             $this->weblink = $plink['href'];
         }
     }
     // Create an array to hold the albums in the account
     $this->albums = array();
     $i = 0;
     // Create a blank Album object for each album in the account
     foreach ($xml->entry as $albums) {
         $this->albums[$i] = new Picasa_Album(null, $albums);
         $i++;
     }
 }
 /**
  * Public method to get a Cache instance.  This is to ensure that only one instance is ever created.
  *
  * @access public
  * @return Picasa_Cache 	The Cache instance.
  */
 public static function getCache()
 {
     if (self::$instance == null) {
         self::$instance = new Picasa_Cache(true);
     }
     return self::$instance;
 }
 /**
  * Constructs an ImageCollection object from the Picasa XML feed.
  *
  * @param string $url    A query URL constructed according to the Picasa API documentation hosted by
  *                       Google at {@link http://code.google.com/apis/picasaweb/gdata.html#Add_Album_Manual_Web}.
  * @param SimpleXMLElement $albums  XML describing a Picasa image collection.  This can be left blank as long as a URL is 
  *                                  specified in the url parameter that returns valid XML for a Picasa image collection.  If both 
  *                                  are null, a {@link Picasa_Exception} is thrown.
  * @param array $contextArray       An array that can be passed to stream_context_create() to generate
  *                                  a PHP context.  See 
  *                                  {@link http://us2.php.net/manual/en/function.stream-context-create.php}
  * @param boolean $useCache  You can decide not to cache a specific request by passing false here.  You may
  *                           want to do this, for instance, if you're requesting a private feed.
  * @throws {@link Picasa_Exception} If the XML suppled through either parameter does not contain valid XML.
  */
 public function __construct($url = null, SimpleXMLElement $collectionXml = null, $contextArray = null, $useCache = true)
 {
     if ($url != null) {
         Picasa_Logger::getLogger()->logIfEnabled('Request string: ' . $url);
         $context = null;
         $xmldata = false;
         if ($contextArray != null) {
             $context = stream_context_create($contextArray);
         }
         if ($useCache === true) {
             $xmldata = Picasa_Cache::getCache()->getIfCached($url);
         }
         if ($xmldata === false) {
             Picasa_Logger::getLogger()->logIfEnabled("Not using cached entry for " . $url);
             $xmldata = @file_get_contents($url, false, $context);
             if ($xmldata != false) {
                 Picasa_Cache::getCache()->setInCache($url, $xmldata);
             }
         }
         if ($xmldata === false) {
             throw Picasa::getExceptionFromInvalidQuery($url, $contextArray);
         }
         //print $xmldata;
         try {
             // Load the XML file into a SimpleXMLElement
             $albums = new SimpleXMLElement($xmldata);
         } catch (Exception $e) {
             throw new Picasa_Exception($e->getMessage(), null, $url);
         }
     }
     $namespaces = $albums->getNamespaces(true);
     if (array_key_exists("openSearch", $namespaces)) {
         $os_ns = $albums->children($namespaces["openSearch"]);
         $this->totalResults = $os_ns->totalResults;
         $this->startIndex = $os_ns->startIndex;
         $this->itemsPerPage = $os_ns->itemsPerPage;
     } else {
         $this->totalResults = null;
         $this->startIndex = null;
         $this->itemsPerPage = null;
     }
     $this->id = $albums->id;
     $this->title = $albums->title;
     $this->updated = $albums->updated;
     $this->icon = $albums->icon;
     $this->subtitle = $albums->subtitle;
     if ($albums->author != null && $albums->author != "") {
         $this->picasaAuthor = new Picasa_Author($albums->author);
         $this->author = $albums->author->name;
     } else {
         $this->picasaAuthor = null;
         $this->author = null;
     }
     $this->images = array();
     $i = 0;
     foreach ($albums->entry as $images) {
         $this->images[$i] = new Picasa_Image(null, $images);
         $i++;
     }
 }
Beispiel #7
0
 /**
  * Constructs an array of {@link Picasa_Comment} objects based on the XML taken from either the $xml parameter or from the contents of $url.
  *
  * @param string $url                  A URL pointing to a Picasa Atom feed that has zero or more "entry" nodes represeing
  *                                     a Picasa comment.  Optional, the default is null.  If this parameter is null, the method will
  *                                     try to get the XML content from the $xml parameter directly.
  * @param SimpleXMLElement $xml        XML from a Picasa Atom feed that has zero or more "entry" nodes represeing a Picasa comment.  
  *                                     Optional, the default is null.  If the $url parameter is null and the $xml parameter is null,
  *                                     a {@Picasa_Exception} is thrown.  
  * @param array $contextArray          An array that can be passed to stream_context_create() to generate
  *                                     a PHP context.  See 
  *                                     {@link http://us2.php.net/manual/en/function.stream-context-create.php}
  * @param boolean $useCache            You can decide not to cache a specific request by passing false here.  You may
  *                                     want to do this, for instance, if you're requesting a private feed.
  * @throws {@link Picasa_Exception}    If the XML passed (through either parameter) could not be used to construct a {@link SimpleXMLElement}.
  * @return array                       An array of {@link Picasa_Comment} objects representing all comments in the requested feed.
  * @see http://php.net/simplexml
  */
 public static function getCommentArray($url = null, SimpleXMLElement $xml = null, $contextArray = null, $useCache = true)
 {
     if ($url != null) {
         $context = null;
         $commentXml = false;
         if ($contextArray != null) {
             $context = stream_context_create($contextArray);
         }
         if ($useCache === true) {
             $commentXml = Picasa_Cache::getCache()->getIfCached($url);
         }
         if ($commentXml === false) {
             Picasa_Logger::getLogger()->logIfEnabled("Comments not coming from the cache.");
             // Get the XML document from Picasa's server based on the query in the URL
             $commentXml = @file_get_contents($url, null, $context);
             if ($useCache === true && $commentXml !== false) {
                 Picasa_Logger::getLogger()->logIfEnabled("Refreshing cache entry for comments.");
                 Picasa_Cache::getCache()->setInCache($url, $commentXml);
             }
         } else {
             Picasa_Logger::getLogger()->logIfEnabled("Comments coming from the cache.");
         }
         if ($commentXml === false) {
             throw Picasa::getExceptionFromInvalidQuery($url);
         }
     }
     try {
         // Load the XML file into a SimpleXMLElement
         $xml = new SimpleXMLElement($commentXml);
     } catch (Exception $e) {
         throw new Picasa_Exception($e->getMessage(), null, $url);
     }
     $commentArray = array();
     $i = 0;
     // Create a blank Album object for each album in the account
     foreach ($xml->entry as $comment) {
         $commentArray[$i] = new Picasa_Comment($comment);
         $i++;
     }
     return $commentArray;
 }