Ejemplo n.º 1
0
     $struct->simplify();
 }
 //if we're simplifying, do so
 if (is_a($struct->getField('channel'), 'Outline')) {
     //feed2json hack -- if there is a field named 'channel', and it is an Outline object (ie, has sub-fields, this happens for RSS 1.0 channel data)
     $channel = $struct->getField('channel');
     //extract the channel field
     foreach ($channel->getFields() as $name => $val) {
         //and copy all of it's fields into the main object (a la RSS 2.0)
         $struct->addField($name, $val);
     }
     $struct->unsetField('channel');
     //kill the channel field
 }
 //end if channel
 $tmp = $struct->getNode(0);
 //temporary variable for first node
 if (is_a($tmp, 'Outline') && (!$tmp->getField('link') || is_a($tmp->getField('link'), 'Outline'))) {
     //feed2json hack, if the first node has no link field or link fiels is an Outline
     foreach ($struct->getNodes() as $id => $nodes) {
         //assuming ATOM-style links, go through all subnodes and set the link field equal to the href field of the link field (because ATOM link fields have multiple fields, instead of being just the URL)
         if (!$tmp->getField('link')) {
             $nds = $nodes->getNodes();
         } else {
             $nds = $nodes->getField('link')->getNodes();
         }
         foreach ($nds as $node) {
             if ($node->getField('rel') == 'alternate') {
                 $struct->_subnodes[$id]->setField('link', $node->getField('href'));
                 break;
             }