當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。