[EXTENSION] EFeed Extension

Hi there,

I had to make a RSS channel on my current project and didn’t want to include any third party scripts that didn’t have the advantages of Yii. This is why I created this Extension.

Please refer to this post for bug reports and/or suggestions.

Link to the Extension for download: http://www.yiiframework.com/extension/efeed/

Hope it helps

edit: I knew it was an extension here already developed but I wanted to create something easier to use.

Thanks for sharing…

Just doing what others did (starting from creator to the rest of the network). Glad to know that my little contribution helps someone.

Thank you! Very easy to use, and doesn’t have to include parts of other frameworks to use! ;)

Oh, and this should probably be 1.1.5?

It look very promissing and usefull

Ill be using it soon and give you my feed back ;)

I don’t think that it wont be compatible with newest versions 1.1.5+

Thanks for the comments. The idea behind this extension was to easy the tasks of RSS feeds. I am glad it is working for you.

No, I meant that it says "1.5" instead of "1.1.5". There is no "Yii 1.5".

Thanks for pointing that out. All my extensions modified…

small bugfix…

If you want to generate nested(?) tags, I found a bug in the EFeedItemAtom.php code that overwrites the existing tag… uh… let me show you, I’m too tired to explain:

$item->addTag(‘georss:where’,array(‘gml:Point’=>‘test’)); <- I do this

and for the code to work I had to patch the getElement function

private function getElement( EFeedTag $tag ){

	&#036;element = '';


	


	if(in_array(&#036;tag-&gt;name,&#036;this-&gt;CDATAEncoded))


	{


		&#036;tag-&gt;attributes['type']=&quot;html&quot;;


		&#036;element .= CHtml::openTag(&#036;tag-&gt;name,&#036;tag-&gt;attributes);


		&#036;element .= '&lt;&#33;[CDATA['.PHP_EOL;


		


	}else 


	{


		&#036;element .= CHtml::openTag(&#036;tag-&gt;name,&#036;tag-&gt;attributes);


	}


		


	if(is_array(&#036;tag-&gt;content))


	{ 


		foreach (&#036;tag-&gt;content as [color=&quot;#FF0000&quot;]&#036;tag[/color] =&gt; &#036;content) [color=&quot;#00FF00&quot;]//change this to &#036;newtag, or you will overwrite your &#036;tag[/color]


		{


			&#036;tmpTag = new EFeedTag([color=&quot;#FF0000&quot;]&#036;tag[/color], &#036;content);[color=&quot;#00FF00&quot;]//same here.. change it to &#036;newtag[/color]


			


			&#036;element .= &#036;this-&gt;getElement( &#036;tmpTag );


		}


	}


	else


	{


		&#036;element .= (in_array(&#036;tag-&gt;name, &#036;this-&gt;CDATAEncoded))? &#036;tag-&gt;content : CHtml::encode(&#036;tag-&gt;content);


	}           


       


		//print_r(&#036;tag);die();


	&#036;element .= (in_array(&#036;tag-&gt;name, &#036;this-&gt;CDATAEncoded))? &quot;]]&gt;&quot;:&quot;&quot;;


	


	&#036;element .= CHtml::closeTag(&#036;tag-&gt;name).PHP_EOL;


	


	return &#036;element;


}

then I can produce Atom Code like this:

<georss:where>

<gml:Point>test</gml:Point>

</georss:where>

I just tested this with one level, but I’ve to make it deeper… we’ll see if it works out :)

cheers!

Thank you very much Flokey,

I have updated the file. If you don’t mind i will mention your help.

Thanks again

I’m currently looking for an Extenions to produce an Atom feed and noticed a glitch in the implementation of the UUID function: The functions doe /not/ create a valid random UUID according to RFC4122.

To do so, you need to set and flip some bits.




diff -u "c:/Users/Maus/AppData/Local/Temp/7zO2880.tmp/EFeed.php.orig" "c:/Users/Maus/AppData/Local/Temp/7zO2880.tmp/EFeed.php"

--- c:/Users/Maus/AppData/Local/Temp/7zO2880.tmp/EFeed.php.orig	2011-06-20 15:13:57.845000000 +0200

+++ c:/Users/Maus/AppData/Local/Temp/7zO2880.tmp/EFeed.php	2011-06-20 15:31:33.785000000 +0200

@@ -260,9 +260,10 @@

                 $key = ($key == null)? uniqid(rand()) : $key;

                 $chars = md5($key);

                 $uuid  = substr($chars,0,<img src='http://www.yiiframework.com/forum/public/style_emoticons/default/cool.gif' class='bbc_emoticon' alt='8)' /> . '-';

-                $uuid .= substr($chars,8,4) . '-';

-                $uuid .= substr($chars,12,4) . '-';

-                $uuid .= substr($chars,16,4) . '-';

+                $uuid .= substr($chars,8,4) . '-4';

+                $uuid .= substr($chars,13,3) . '-';

+                $uuid .= sprintf('%x', hexdec(substr($chars,16,2)) & 191 | 128);

+                $uuid .= substr($chars,18,2) . '-';

                 $uuid .= substr($chars,20,12);

 

                 return $prefix . $uuid;


Diff finished.  Mon Jun 20 15:31:49 2011



Best,

– David

Hi David!

Thanks for your suggestion. You are right, the uuid wasn’t RFC4122 compliant and I was about to refactor it with (https://github.com/LiosK/UUID.js/blob/master/src/uuid.js) but I wouldn’t mind to use yours but is it correct?

I would say so. The Specs:




4.4.  Algorithms for Creating a UUID from Truly Random or

      Pseudo-Random Numbers


   The version 4 UUID is meant for generating UUIDs from truly-random or

   pseudo-random numbers.


   The algorithm is as follows:


   o  Set the two most significant bits (bits 6 and 7) of the

      clock_seq_hi_and_reserved to zero and one, respectively.


   o  Set the four most significant bits (bits 12 through 15) of the

      time_hi_and_version field to the 4-bit version number from

      Section 4.1.3.


   o  Set all the other bits to randomly (or pseudo-randomly) chosen

      values.



  • ( & 191 | 128 ) => (& #b1011111 | 0b1000000) => Step 1

  • the literal "4" => Step 2

  • md5($key) => Step 3

The very same algorithm is used in Emacs/Org mode

I see, so you talking about Version 4 of UUID and that’s correct:


Version 4 UUIDs use a scheme relying only on random numbers. This algorithm sets the version number as well as two reserved bits. All other bits are set using a random or pseudorandom data source. Version 4 UUIDs have the form xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx where x is any hexadecimal digit and y is one of 8, 9, A, or B. e.g. f47ac10b-58cc-4372-a567-0e02b2c3d479.


Thanks, will change the code asap

Cheers

And another problem: I noticed that current version of EFeed passes an entry’s URL to EFeed::uuid() and EFeed::uudi() uses MD5($url) as base for the UUID. But (sorry, I am quite picky with these issues) then the UUID is not a random UUID.

You could use the URL "as is"

RFC 4287, 4.2.6

Using the URL of the feed / the entry is a valid option according to RFC4287 and in my eyes far better than pretending that the ID is something else.

Best,

– David

So you are saying that this should be in place instead:




echo $this->makeNode($key,'',array('href'=>$value));

// And add the id for ATOM

echo $this->makeNode('id',$value);



I should GIT all my extensions so you all can work on to make them better… do not have much time to look at these things now

Thanks David

Yes.

I definitely need to upload these extensions to Git

Hi, I am having this error when trying to createNewItem():

include(CTypedMap.php) [<a href=‘function.include’>function.include</a>]: failed to open stream: No such file or directory

ok, solved this issue by importing 'system.collections.*