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']['content']}\">";
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 (!array_key_exists('content', $value)) {
// 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;
// An image has its own element after the channel elements.
if (array_key_exists('image', $this->data)) {
$out .= $this->makeNode('image', $this->data['Image'], array('rdf:about' => $this->data['Image']['url']));
}
} else {
if ($this->version == Feed::ATOM) {
// ATOM feeds have a unique feed ID. Use the title channel element as key.
$out .= $this->makeNode('id', Feed::uuid($this->channels['title']['content'], 'urn:uuid:'));
}
}
return $out;
}