Example #1
0
 /** Create a Track object from a SimpleXMLElement.
  *
  * @param	SimpleXMLElement	$xml	A SimpleXMLElement.
  * @return	Track						A Track object.
  *
  * @static
  * @access	public
  * @internal
  */
 public static function fromSimpleXMLElement(SimpleXMLElement $xml)
 {
     $images = array();
     $topTags = array();
     if (count($xml->image) > 1) {
         foreach ($xml->image as $image) {
             $images[Util::toImageType($image['size'])] = Util::toString($image);
         }
     } else {
         $images[Media::IMAGE_UNKNOWN] = Util::toString($xml->image);
     }
     if ($xml->toptags) {
         foreach ($xml->toptags->children() as $tag) {
             $topTags[] = Tag::fromSimpleXMLElement($tag);
         }
     }
     if ($xml->artist) {
         if ($xml->artist->name && $xml->artist->mbid && $xml->artist->url) {
             $artist = new Artist(Util::toString($xml->artist->name), Util::toString($xml->artist->mbid), Util::toString($xml->artist->url), array(), 0, 0, 0, array(), array(), '', 0.0);
         } else {
             $artist = Util::toString($xml->artist);
         }
     } else {
         if ($xml->creator) {
             $artist = Util::toString($xml->creator);
         } else {
             $artist = '';
         }
     }
     if ($xml->name) {
         $name = Util::toString($xml->name);
     } else {
         if ($xml->title) {
             $name = Util::toString($xml->title);
         } else {
             $name = '';
         }
     }
     // TODO: <extension application="http://www.last.fm">
     return new Track($artist, Util::toString($xml->album), $name, Util::toString($xml->mbid), Util::toString($xml->url), $images, Util::toInteger($xml->listeners), Util::toInteger($xml->playcount), Util::toInteger($xml->duration), $topTags, Util::toInteger($xml->id), Util::toString($xml->location), Util::toBoolean($xml->streamable), Util::toBoolean($xml->streamable['fulltrack']), $xml->wiki, Util::toTimestamp($xml->date));
 }
Example #2
0
 /** Create a Event object from a SimpleXMLElement.
  *
  * @param	SimpleXMLElement	$xml	A SimpleXMLElement.
  * @return	Event						A Event object.
  *
  * @static
  * @access	public
  * @internal
  */
 public static function fromSimpleXMLElement(SimpleXMLElement $xml)
 {
     $artists = array();
     $images = array();
     if ($xml->artists) {
         foreach ($xml->artists->artist as $artist) {
             $artists[] = Util::toString($artist);
         }
         $artists['headliner'] = Util::toString($xml->artists->headliner);
     }
     if ($xml->image) {
         foreach ($xml->image as $image) {
             $images[Util::toImageType($image['size'])] = Util::toString($image);
         }
     }
     return new Event(Util::toInteger($xml->id), Util::toString($xml->title), $artists, $xml->venue ? Venue::fromSimpleXMLElement($xml->venue) : null, Util::toTimestamp($xml->startDate), Util::toString($xml->description), $images, Util::toString($xml->url), Util::toInteger($xml->attendance), Util::toInteger($xml->reviews), Util::toString($xml->tag));
 }
Example #3
0
 /** Create an Album object from a SimpleXMLElement object.
  *
  * @param	SimpleXMLElement	$xml	A SimpleXMLElement object.
  * @return	Album						An Album object.
  *
  * @static
  * @access	public
  * @internal
  */
 public static function fromSimpleXMLElement(SimpleXMLElement $xml)
 {
     $images = array();
     $topTags = array();
     /* TODO: tagcount | library.getAlbums */
     if ($xml->mbid) {
         $mbid = Util::toString($xml->mbid);
     } else {
         if ($xml['mbid']) {
             $mbid = Util::toString($xml['mbid']);
         } else {
             $mbid = '';
         }
     }
     foreach ($xml->image as $image) {
         $images[Util::toImageType($image['size'])] = Util::toString($image);
     }
     if ($xml->toptags) {
         foreach ($xml->toptags->children() as $tag) {
             $topTags[] = Tag::fromSimpleXMLElement($tag);
         }
     }
     if ($xml->artist->name && $xml->artist->mbid && $xml->artist->url) {
         $artist = new Artist(Util::toString($xml->artist->name), Util::toString($xml->artist->mbid), Util::toString($xml->artist->url), array(), 0, 0, 0, array(), array(), '', 0.0);
     } else {
         if ($xml->artist && $xml->artist['mbid']) {
             $artist = new Artist(Util::toString($xml->artist), Util::toString($xml->artist['mbid']), '', array(), 0, 0, 0, array(), array(), '', 0.0);
         } else {
             $artist = Util::toString($xml->artist);
         }
     }
     return new Album($artist, Util::toString($xml->name), Util::toInteger($xml->id), $mbid, Util::toString($xml->url), $images, Util::toInteger($xml->listeners), Util::toInteger($xml->playcount), Util::toTimestamp($xml->releasedate), $topTags);
 }
Example #4
0
 /** Create a Playlist object from a SimpleXMLElement.
  *
  * @param SimpleXMLElement  $xml  A SimpleXMLElement object.
  * @return  Playlist          A Playlist object.
  *
  * @static
  * @access  public
  * @internal
  */
 public static function fromSimpleXMLElement(SimpleXMLElement $xml)
 {
     $tracks = array();
     if (isset($xml->trackList)) {
         foreach ($xml->trackList->children() as $track) {
             $tracks[] = Track::fromSimpleXMLElement($track);
         }
     }
     return new Playlist(Util::toInteger($xml->id), Util::toString($xml->title), Util::toString($xml->description), Util::toTimestamp($xml->date), Util::toInteger($xml->size), Util::toInteger($xml->duration), Util::toInteger($xml->streamable), Util::toString($xml->creator), Util::toString($xml->url), $tracks);
 }
Example #5
0
 /** Create a Shout object from a SimpleXMLElement.
  *
  * @param	SimpleXMLElement	$xml	A SimpleXMLElement.
  * @return	Venue						A Venue object.
  *
  * @static
  * @access	public
  * @internal
  */
 public static function fromSimpleXMLElement(SimpleXMLElement $xml)
 {
     return new Shout(Util::toString($xml->auhtor), Util::toTimestamp($xml->date), Util::toString($xml->body));
 }