tonydspaniard / Yii-extensions

My small contribution to the Yii framework community
124 stars 50 forks source link

Fixed errors I had when validating with validator.w3.org/feed #1

Closed hofrob closed 12 years ago

hofrob commented 12 years ago

Hi,

I fixed two errors that came up after I tried to validate my RSS2 XML with the w3 feed validator. It's explained here.

FYI: I couldn't use the existing makeNode method because this tag has no content.

Thank you! hofrob

hofrob commented 12 years ago
$feed->addChannelTag('atom:link','http://www.ramirezcobos.com/rss/');

With the current code this will generate the following tag:

<atom:link>http://www.ramirezcobos.com/rss/</atom:link>

But it should be:

<atom:link href="http://example.com/rss.xml" rel="self" type="application/rss+xml" />
tonydspaniard commented 12 years ago

Oh man!

I just realized I submitted the wrong version of EFeed! renderChannels function should have:

// Printing channel items
        foreach ($this->feedElements->itemAt('channels') as $key => $value) 
        {
            if($this->type == self::ATOM && $key == 'link') 
            {
                // ATOM prints link element as href attribute
                echo $this->makeNode($key,'',array('href'=>$value));
                // And add the id for ATOM
                echo $this->makeNode('id',$this->uuid($value,'urn:uuid:'));
            }
            elseif ($this->type == self::RSS2 && $key == 'atom:link')
            {

                echo $this->makeNode($key,'',array('rel'=>'self', 'href'=>$value, 'type'=>'application/rss+xml'));

            }
            else
            {
                echo $this->makeNode($key, $value);
            }    

        }

Thank you so much!

By the way, why are the namespaces removed from your commit?

tonydspaniard commented 12 years ago

I am going to close the pull request as I believe it is better to use the makeNode but I thank you so much for pointing me to the bug as I did not update the GitHub version with the atom:link fix.

hofrob commented 12 years ago

Alrighty, that's fine with me! Thanks for sharing your extensions by the way.

tonydspaniard commented 12 years ago

You are welcome... -got more coming :)