/**
* Make the channels.
*
* @access private
* @return string The feed header as XML containing all the feed metadata.
*/
private function makeChannels()
{
$out = '';
//Start channel tag
switch ($this->version) {
case Feed::RSS2:
$out .= '<channel>' . PHP_EOL;
break;
case Feed::RSS1:
$out .= isset($this->data['ChannelAbout']) ? "<channel rdf:about=\"{$this->data['ChannelAbout']}\">" : "<channel rdf:about=\"{$this->channels['link']}\">";
break;
}
//Print Items of channel
foreach ($this->channels as $key => $value) {
// In ATOM feeds, strip all ATOM namespace prefixes from the tag name. They are not needed here,
// because the ATOM namespace name is set as default namespace.
if ($this->version == Feed::ATOM && strncmp($key, 'atom', 4) == 0) {
$key = substr($key, 5);
}
// The channel element can occur multiple times, when the key 'content' is not in the array.
if (!isset($value['content'])) {
// If this is the case, iterate through the array with the multiple elements.
foreach ($value as $singleElement) {
$out .= $this->makeNode($key, $singleElement['content'], $singleElement['attributes']);
}
} else {
$out .= $this->makeNode($key, $value['content'], $value['attributes']);
}
}
if ($this->version == Feed::RSS1) {
//RSS 1.0 have special tag <rdf:Seq> with channel
$out .= "<items>" . PHP_EOL . "<rdf:Seq>" . PHP_EOL;
foreach ($this->items as $item) {
$thisItems = $item->getElements();
$out .= "<rdf:li resource=\"{$thisItems['link']['content']}\"/>" . PHP_EOL;
}
$out .= "</rdf:Seq>" . PHP_EOL . "</items>" . PHP_EOL . "</channel>" . PHP_EOL;
} else {
if ($this->version == Feed::ATOM) {
// ATOM feeds have a unique feed ID. This is generated from the 'link' channel element.
$out .= $this->makeNode('id', Feed::uuid($this->channels['link']['attributes']['href'], 'urn:uuid:'));
}
}
return $out;
}