⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rss.php

📁 Piwik#Opensourcewebanalytics一款可以和GOOGLE媲美的开源统计系统,运用AJAX.功能强大.无色提示:按照需要PHP5.1以上和MySQL数据库支持。
💻 PHP
📖 第 1 页 / 共 2 页
字号:
        if (isset($array->itunes->author)) {            $author = $array->itunes->author;        } elseif (isset($array->author)) {            $author = $array->author;        }        if (!empty($author)) {            $node = $this->_element->createElementNS('http://www.itunes.com/DTDs/Podcast-1.0.dtd', 'itunes:author', $author);            $root->appendChild($node);        }        /* owner node */        $author = '';        $email = '';        if (isset($array->itunes->owner)) {            if (isset($array->itunes->owner['name'])) {                $author = $array->itunes->owner['name'];            }            if (isset($array->itunes->owner['email'])) {                $email = $array->itunes->owner['email'];            }        }        if (empty($author) && isset($array->author)) {            $author = $array->author;        }        if (empty($email) && isset($array->email)) {            $email = $array->email;        }        if (!empty($author) || !empty($email)) {            $owner = $this->_element->createElementNS('http://www.itunes.com/DTDs/Podcast-1.0.dtd', 'itunes:owner');            if (!empty($author)) {                $node = $this->_element->createElementNS('http://www.itunes.com/DTDs/Podcast-1.0.dtd', 'itunes:name', $author);                $owner->appendChild($node);            }            if (!empty($email)) {                $node = $this->_element->createElementNS('http://www.itunes.com/DTDs/Podcast-1.0.dtd', 'itunes:email', $email);                $owner->appendChild($node);            }            $root->appendChild($owner);        }        $image = '';        if (isset($array->itunes->image)) {            $image = $array->itunes->image;        } elseif (isset($array->image)) {            $image = $array->image;        }        if (!empty($image)) {            $node = $this->_element->createElementNS('http://www.itunes.com/DTDs/Podcast-1.0.dtd', 'itunes:image');            $node->setAttribute('href', $image);            $root->appendChild($node);        }        $subtitle = '';        if (isset($array->itunes->subtitle)) {            $subtitle = $array->itunes->subtitle;        } elseif (isset($array->description)) {            $subtitle = $array->description;        }        if (!empty($subtitle)) {            $node = $this->_element->createElementNS('http://www.itunes.com/DTDs/Podcast-1.0.dtd', 'itunes:subtitle', $subtitle);            $root->appendChild($node);        }        $summary = '';        if (isset($array->itunes->summary)) {            $summary = $array->itunes->summary;        } elseif (isset($array->description)) {            $summary = $array->description;        }        if (!empty($summary)) {            $node = $this->_element->createElementNS('http://www.itunes.com/DTDs/Podcast-1.0.dtd', 'itunes:summary', $summary);            $root->appendChild($node);        }        if (isset($array->itunes->block)) {            $node = $this->_element->createElementNS('http://www.itunes.com/DTDs/Podcast-1.0.dtd', 'itunes:block', $array->itunes->block);            $root->appendChild($node);        }        if (isset($array->itunes->explicit)) {            $node = $this->_element->createElementNS('http://www.itunes.com/DTDs/Podcast-1.0.dtd', 'itunes:explicit', $array->itunes->explicit);            $root->appendChild($node);        }        if (isset($array->itunes->keywords)) {            $node = $this->_element->createElementNS('http://www.itunes.com/DTDs/Podcast-1.0.dtd', 'itunes:keywords', $array->itunes->keywords);            $root->appendChild($node);        }        if (isset($array->itunes->new_feed_url)) {            $node = $this->_element->createElementNS('http://www.itunes.com/DTDs/Podcast-1.0.dtd', 'itunes:new-feed-url', $array->itunes->new_feed_url);            $root->appendChild($node);        }        if (isset($array->itunes->category)) {            foreach ($array->itunes->category as $i => $category) {                $node = $this->_element->createElementNS('http://www.itunes.com/DTDs/Podcast-1.0.dtd', 'itunes:category');                $node->setAttribute('text', $category['main']);                $root->appendChild($node);                $add_end_category = false;                if (!empty($category['sub'])) {                    $add_end_category = true;                    $node = $this->_element->createElementNS('http://www.itunes.com/DTDs/Podcast-1.0.dtd', 'itunes:category');                    $node->setAttribute('text', $category['sub']);                    $root->appendChild($node);                }                if ($i > 0 || $add_end_category) {                    $node = $this->_element->createElementNS('http://www.itunes.com/DTDs/Podcast-1.0.dtd', 'itunes:category');                    $root->appendChild($node);                }            }        }    }    /**     * Generate the entries of the feed when working in write mode     *     * The following nodes are constructed for each feed entry     * <item>     *    <title>entry title</title>     *    <link>url to feed entry</link>     *    <guid>url to feed entry</guid>     *    <description>short text</description>     *    <content:encoded>long version, can contain html</content:encoded>     * </item>     *     * @param  DOMElement $root the root node to use     * @param  array $array the data to use     * @return void     */    protected function _mapFeedEntries(DOMElement $root, $array)    {        Zend_Feed::registerNamespace('content', 'http://purl.org/rss/1.0/modules/content/');        foreach ($array as $dataentry) {            $item = $this->_element->createElement('item');            $title = $this->_element->createElement('title');            $title->appendChild($this->_element->createCDATASection($dataentry->title));            $item->appendChild($title);            $link = $this->_element->createElement('link', $dataentry->link);            $item->appendChild($link);            if (isset($dataentry->guid)) {                $guid = $this->_element->createElement('guid', $dataentry->guid);                $item->appendChild($guid);            }            $description = $this->_element->createElement('description');            $description->appendChild($this->_element->createCDATASection($dataentry->description));            $item->appendChild($description);            if (isset($dataentry->content)) {                $content = $this->_element->createElement('content:encoded');                $content->appendChild($this->_element->createCDATASection($dataentry->content));                $item->appendChild($content);            }            $pubdate = isset($dataentry->lastUpdate) ? $dataentry->lastUpdate : time();            $pubdate = $this->_element->createElement('pubDate', gmdate('r', $pubdate));            $item->appendChild($pubdate);            if (isset($dataentry->category)) {                foreach ($dataentry->category as $category) {                    $node = $this->_element->createElement('category', $category['term']);                    if (isset($category['scheme'])) {                        $node->setAttribute('domain', $category['scheme']);                    }                    $item->appendChild($node);                }            }            if (isset($dataentry->source)) {                $source = $this->_element->createElement('source', $dataentry->source['title']);                $source->setAttribute('url', $dataentry->source['url']);                $item->appendChild($source);            }            if (isset($dataentry->comments)) {                $comments = $this->_element->createElement('comments', $dataentry->comments);                $item->appendChild($comments);            }            if (isset($dataentry->commentRss)) {                $comments = $this->_element->createElementNS('http://wellformedweb.org/CommentAPI/',                                                             'wfw:commentRss',                                                             $dataentry->commentRss);                $item->appendChild($comments);            }            if (isset($dataentry->enclosure)) {                foreach ($dataentry->enclosure as $enclosure) {                    $node = $this->_element->createElement('enclosure');                    $node->setAttribute('url', $enclosure['url']);                    if (isset($enclosure['type'])) {                        $node->setAttribute('type', $enclosure['type']);                    }                    if (isset($enclosure['length'])) {                        $node->setAttribute('length', $enclosure['length']);                    }                    $item->appendChild($node);                }            }            $root->appendChild($item);        }    }    /**     * Override Zend_Feed_Element to include <rss> root node     *     * @return string     */    public function saveXml()    {        // Return a complete document including XML prologue.        $doc = new DOMDocument($this->_element->ownerDocument->version,                               $this->_element->ownerDocument->actualEncoding);        $root = $doc->createElement('rss');        // Use rss version 2.0        $root->setAttribute('version', '2.0');        // Content namespace        $root->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:content', 'http://purl.org/rss/1.0/modules/content/');        $root->appendChild($doc->importNode($this->_element, true));        // Append root node        $doc->appendChild($root);        // Format output        $doc->formatOutput = true;        return $doc->saveXML();    }    /**     * Send feed to a http client with the correct header     *     * @return void     * @throws Zend_Feed_Exception if headers have already been sent     */    public function send()    {        if (headers_sent()) {            /**              * @see Zend_Feed_Exception             */            require_once 'Zend/Feed/Exception.php';            throw new Zend_Feed_Exception('Cannot send RSS because headers have already been sent.');        }        header('Content-type: application/rss+xml; charset: ' . $this->_element->ownerDocument->actualEncoding);        echo $this->saveXml();    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -