Contao\Feed::generateAtom PHP Метод

generateAtom() публичный Метод

Generate an Atom feed and return it as XML string
public generateAtom ( ) : string
Результат string The Atom feed markup
    public function generateAtom()
    {
        $this->adjustPublicationDate();
        $xml = '<?xml version="1.0" encoding="' . \Config::get('characterSet') . '"?>';
        $xml .= '<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="' . $this->language . '">';
        $xml .= '<title>' . \StringUtil::specialchars($this->title) . '</title>';
        $xml .= '<subtitle>' . \StringUtil::specialchars($this->description) . '</subtitle>';
        $xml .= '<link rel="alternate" href="' . \StringUtil::specialchars($this->link) . '" />';
        $xml .= '<id>' . \StringUtil::specialchars($this->link) . '</id>';
        $xml .= '<updated>' . preg_replace('/00$/', ':00', date('Y-m-d\\TH:i:sO', $this->published)) . '</updated>';
        $xml .= '<generator>Contao Open Source CMS</generator>';
        $xml .= '<link href="' . \StringUtil::specialchars(\Environment::get('base') . 'share/' . $this->strName) . '.xml" rel="self" />';
        foreach ($this->arrItems as $objItem) {
            $xml .= '<entry>';
            $xml .= '<title>' . \StringUtil::specialchars($objItem->title) . '</title>';
            $xml .= '<content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">' . preg_replace('/[\\n\\r]+/', ' ', \StringUtil::toXhtml($objItem->description)) . '</div></content>';
            $xml .= '<link rel="alternate" href="' . \StringUtil::specialchars($objItem->link) . '" />';
            $xml .= '<updated>' . preg_replace('/00$/', ':00', date('Y-m-d\\TH:i:sO', $objItem->published)) . '</updated>';
            $xml .= '<id>' . ($objItem->guid ? $objItem->guid : \StringUtil::specialchars($objItem->link)) . '</id>';
            $xml .= '<author><name>' . $objItem->author . '</name></author>';
            // Enclosures
            if (is_array($objItem->enclosure)) {
                foreach ($objItem->enclosure as $arrEnclosure) {
                    $xml .= '<link rel="enclosure" type="' . $arrEnclosure['type'] . '" href="' . $arrEnclosure['url'] . '" length="' . $arrEnclosure['length'] . '" />';
                }
            }
            $xml .= '</entry>';
        }
        return $xml . '</feed>';
    }