当前位置: 首页>>代码示例>>PHP>>正文


PHP Tag::fromSimpleXMLElement方法代码示例

本文整理汇总了PHP中Tag::fromSimpleXMLElement方法的典型用法代码示例。如果您正苦于以下问题:PHP Tag::fromSimpleXMLElement方法的具体用法?PHP Tag::fromSimpleXMLElement怎么用?PHP Tag::fromSimpleXMLElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tag的用法示例。


在下文中一共展示了Tag::fromSimpleXMLElement方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getTopTags

 /** Get the top tags used by this user.
  *
  * @param	string	$user	The user name to fetch top tags for. (Required)
  * @param	integer	$limit	Limit the number of tags returned. (Optional)
  * @return	array			An array of Tag objects.
  *
  * @static
  * @access	public
  * @throws	Error
  */
 public static function getTopTags($user, $limit = null)
 {
     $xml = CallerFactory::getDefaultCaller()->call('user.getTopTags', array('user' => $user, 'limit' => $limit));
     $tags = array();
     foreach ($xml->children() as $tag) {
         $tags[] = Tag::fromSimpleXMLElement($tag);
     }
     return $tags;
 }
开发者ID:niczak,项目名称:php-last.fm-api,代码行数:19,代码来源:User.php

示例2: fromSimpleXMLElement

 /** 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));
 }
开发者ID:niczak,项目名称:php-last.fm-api,代码行数:50,代码来源:Track.php

示例3: fromSimpleXMLElement

 /** Create an Artist object from a SimpleXMLElement object.
  *
  * @param	SimpleXMLElement	$xml	A SimpleXMLElement object.
  * @return	Artist						An Artist object.
  *
  * @static
  * @access	public
  * @internal
  */
 public static function fromSimpleXMLElement(SimpleXMLElement $xml)
 {
     $images = array();
     $tags = array();
     $similar = array();
     /* NOTE: image, image_small... this sucks! */
     if ($xml->image) {
         if (count($xml->image) > 1) {
             foreach ($xml->image as $image) {
                 $images[Util::toImageType($image['size'])] = Util::toString($image);
             }
         } else {
             $images[Media::IMAGE_LARGE] = Util::toString($image);
         }
     }
     if ($xml->image_small) {
         $images[Media::IMAGE_SMALL] = Util::toString($xml->image_small);
     }
     if ($xml->tags) {
         foreach ($xml->tags->children() as $tag) {
             $tags[] = Tag::fromSimpleXMLElement($tag);
         }
     }
     if ($xml->similar) {
         foreach ($xml->similar->children() as $artist) {
             $similar[] = Artist::fromSimpleXMLElement($artist);
         }
     }
     return new Artist(Util::toString($xml->name), Util::toString($xml->mbid), Util::toString($xml->url), $images, Util::toBoolean($xml->streamable), Util::toInteger($xml->listeners), Util::toInteger($xml->playcount), $tags, $similar, $xml->bio ? Util::toString($xml->bio->summary) : "", Util::toFloat($xml->match));
 }
开发者ID:niczak,项目名称:php-last.fm-api,代码行数:39,代码来源:Artist.php

示例4: search

 /** Search for a tag by name. Returns matches sorted by relevance.
  *
  * @param	string	$tag	The tag name in question. (Required)
  * @param	integer	$limit	Limit the number of tags returned at one time. Default (maximum) is 30. (Optional)
  * @param	integer	$page	Scan into the results by specifying a page number. Defaults to first page. (Optional)
  * @return	array			An array of Tag objects.
  *
  * @static
  * @access	public
  * @throws	Error
  */
 public static function search($tag, $limit = null, $page = null)
 {
     $xml = CallerFactory::getDefaultCaller()->call('tag.search', array('tag' => $tag, 'limit' => $limit, 'page' => $page));
     $tags = array();
     foreach ($xml->tagmatches->children() as $tag) {
         $tags[] = Tag::fromSimpleXMLElement($tag);
     }
     return $tags;
 }
开发者ID:niczak,项目名称:php-last.fm-api,代码行数:20,代码来源:Tag.php

示例5: fromSimpleXMLElement

 /** 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);
 }
开发者ID:niczak,项目名称:php-last.fm-api,代码行数:42,代码来源:Album.php


注:本文中的Tag::fromSimpleXMLElement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。