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


PHP SimplePie::get_authors方法代码示例

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


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

示例1: get_authors

 /**
  * Get all authors for the item
  *
  * Uses `<atom:author>`, `<author>`, `<dc:creator>` or `<itunes:author>`
  *
  * @since Beta 2
  * @return array|null List of {@see SimplePie_Author} objects
  */
 public function get_authors()
 {
     $authors = array();
     foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author') as $author) {
         $name = null;
         $uri = null;
         $email = null;
         if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'])) {
             $name = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
         }
         if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'])) {
             $uri = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]));
         }
         if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'])) {
             $email = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
         }
         if ($name !== null || $email !== null || $uri !== null) {
             $authors[] = $this->registry->create('Author', array($name, $uri, $email));
         }
     }
     if ($author = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'author')) {
         $name = null;
         $url = null;
         $email = null;
         if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'])) {
             $name = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
         }
         if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'])) {
             $url = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]));
         }
         if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'])) {
             $email = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
         }
         if ($name !== null || $email !== null || $url !== null) {
             $authors[] = $this->registry->create('Author', array($name, $url, $email));
         }
     }
     if ($author = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'author')) {
         $authors[] = $this->registry->create('Author', array(null, null, $this->sanitize($author[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)));
     }
     foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'creator') as $author) {
         $authors[] = $this->registry->create('Author', array($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null));
     }
     foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'creator') as $author) {
         $authors[] = $this->registry->create('Author', array($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null));
     }
     foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'author') as $author) {
         $authors[] = $this->registry->create('Author', array($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null));
     }
     if (!empty($authors)) {
         return array_unique($authors);
     } elseif (($source = $this->get_source()) && ($authors = $source->get_authors())) {
         return $authors;
     } elseif ($authors = $this->feed->get_authors()) {
         return $authors;
     } else {
         return null;
     }
 }
开发者ID:oparoz,项目名称:core-1,代码行数:67,代码来源:Item.php

示例2: foreach

}
?>
<link href="<?php 
echo $protocol . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
?>
" rel="self"/>
<link href="<?php 
echo $feed->get_base();
?>
" />
<id><?php 
echo $feed->get_permalink();
?>
</id>
<?php 
if ($feed->get_authors()) {
    ?>
    <?php 
    foreach ($feed->get_authors() as $author) {
        ?>
        <author>
            <?php 
        if ($author->get_name()) {
            ?>
                <name><?php 
            echo $author->get_name();
            ?>
</name>
            <?php 
        }
        ?>
开发者ID:Niehztog,项目名称:rssFilter,代码行数:31,代码来源:index.php


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