PageRenderTime 45ms CodeModel.GetById 2ms app.highlight 16ms RepoModel.GetById 2ms app.codeStats 1ms

/tests/Zend/Feed/Reader/Entry/_files/Common/rss.xml

Design Patterns: Elements of Reusable Object-Oriented Software

Also known as 'The Gang of Four' or GoF book. The bible when it comes to design patterns. One of the books that you read early in your career and apply over and over again. Amazon Affiliate Link
https://bitbucket.org/svenax/zendframework
XML | 700 lines | 620 code | 80 blank | 0 comment | 0 complexity | c56a0fc6eb386a4a2f468caf24fba793 MD5 | raw file
  1<?xml version="1.0" encoding="UTF-8"?>
  2<rss version="2.0"
  3	xmlns:content="http://purl.org/rss/1.0/modules/content/"
  4	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
  5	xmlns:dc="http://purl.org/dc/elements/1.1/"
  6	xmlns:atom="http://www.w3.org/2005/Atom"
  7	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
  8	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
  9	>
 10
 11<channel>
 12	<title>Norm 2782</title>
 13	<atom:link href="http://www.norm2782.com/feed/" rel="self" type="application/rss+xml" />
 14	<link>http://www.norm2782.com</link>
 15	<description>Why are you here?</description>
 16	<lastBuildDate>Sat, 07 Mar 2009 08:03:50 +0000</lastBuildDate>
 17	<generator>http://wordpress.org/?v=2.8</generator>
 18	<language>en</language>
 19	<sy:updatePeriod>hourly</sy:updatePeriod>
 20	<sy:updateFrequency>1</sy:updateFrequency>
 21			<item>
 22		<title>Wth&#8230; reading books?</title>
 23		<link>http://www.norm2782.com/2009/03/wth-reading-books/</link>
 24		<comments>http://www.norm2782.com/2009/03/wth-reading-books/#comments</comments>
 25		<pubDate>Mon, 02 Mar 2009 08:09:33 +0000</pubDate>
 26		<dc:creator>norm2782</dc:creator>
 27				<category><![CDATA[New Zealand]]></category>
 28		<category><![CDATA[Personal]]></category>
 29		<category><![CDATA[Programming]]></category>
 30		<category><![CDATA[Study]]></category>
 31
 32		<guid isPermaLink="false">http://www.norm2782.com/?p=114</guid>
 33		<description><![CDATA[Being in New Zealand does strange things to a person. Everybody who knows me, knows I don&#8217;t much like that crazy invention called a Book. However, being here I&#8217;ve already finished 4 books, all of which I can highly recommend.
 34
 35Agile Software Development with Scrum, by Ken Schwaber and Mike Beedle
 36Domain-Driven Design: Tackling Complexity in the [...]]]></description>
 37			<content:encoded><![CDATA[<p>Being in New Zealand does strange things to a person. Everybody who knows me, knows I don&#8217;t much like that crazy invention called a Book. However, being here I&#8217;ve already finished 4 books, all of which I can highly recommend.</p>
 38<ul>
 39<li><a href="http://www.amazon.com/Agile-Software-Development-Scrum/dp/0130676349/">Agile Software Development with Scrum, by Ken Schwaber and Mike Beedle</a></li>
 40<li><a href="http://www.amazon.com/Domain-Driven-Design-Tackling-Complexity-Software/dp/0321125215/">Domain-Driven Design: Tackling Complexity in the Heart of Software, by Eric Evans</a></li>
 41<li><a href="http://www.amazon.com/Enterprise-Application-Architecture-Addison-Wesley-Signature/dp/0321127420/">Patterns of Enterprise Application Architecture, by Martin Fowler</a></li>
 42<li><a href="http://www.amazon.com/Refactoring-Improving-Existing-Addison-Wesley-Technology/dp/0201485672/">Refactoring: Improving the Design of Existing Code by Martin Fowler</a></li>
 43</ul>
 44<p>Next up: <a href="http://www.amazon.com/Design-Patterns-Object-Oriented-Addison-Wesley-Professional/dp/0201633612/">Design Patterns: Elements of Reusable Object-Oriented Software, by the Gang of Four</a>. Yes, talk about classics and shame on me for not having ordered it sooner! Also reading <a href="http://www.amazon.com/Implementation-Patterns-Addison-Wesley-Signature-Kent/dp/0321413091/">Implementation Patterns, by Kent Beck</a> at the moment.</p>
 45]]></content:encoded>
 46			<wfw:commentRss>http://www.norm2782.com/2009/03/wth-reading-books/feed/</wfw:commentRss>
 47		<slash:comments>0</slash:comments>
 48		</item>
 49		<item>
 50		<title>My first few weeks in New Zealand</title>
 51		<link>http://www.norm2782.com/2009/02/my-first-few-weeks-in-new-zealand/</link>
 52		<comments>http://www.norm2782.com/2009/02/my-first-few-weeks-in-new-zealand/#comments</comments>
 53		<pubDate>Sun, 15 Feb 2009 03:29:21 +0000</pubDate>
 54		<dc:creator>norm2782</dc:creator>
 55				<category><![CDATA[New Zealand]]></category>
 56		<category><![CDATA[Personal]]></category>
 57
 58		<guid isPermaLink="false">http://www.norm2782.com/?p=105</guid>
 59		<description><![CDATA[It&#8217;s been a while since my last blog post. Things have been quite hectic for me these last few weeks. There was my final week at Angry Bytes, followed by a pre-NZ party and then my trip to New Zealand. Currently New Zealand looks pretty much the same as the Netherlands, seeing as I&#8217;m locked [...]]]></description>
 60			<content:encoded><![CDATA[<p>It&#8217;s been a while since my last blog post. Things have been quite hectic for me these last few weeks. There was my final week at <a href="http://www.angrybytes.com">Angry Bytes</a>, followed by a pre-NZ party and then my trip to New Zealand. Currently New Zealand looks pretty much the same as the Netherlands, seeing as I&#8217;m locked away in an office most of my time.</p>
 61<p><span id="more-105"></span><br />
 62My adventure into Kiwi-land started with a long and interesting trip to San Francisco. The interesting part was my new book: <a href="http://domaindrivendesign.org/books/#DDD">Domain Driven Design: Tackling Complexity in the Heart of Software</a>, by Eric Evans. This book, combined with KLM&#8217;s excellent on-board service made my flight to SF a breeze.</p>
 63<p>It was only 2PM when I arrived in SF, so I had to wait another 4 hours before my flight to Auckland even boarded. The waiting wasn&#8217;t too bad. It was great to get out into the sun and to grab some decent food and coffee. Didn&#8217;t get to see much of SF though, which was too bad.</p>
 64<p><img src="http://farm4.static.flickr.com/3403/3232983613_637af46bc3.jpg?v=0" alt="SF Airport" /></p>
 65<p>The flight to Auckland wasn&#8217;t that flawless unfortunately. There were some technical problems with the airplane, which caused quite a bit of a delay. Because of this delay I had to run to catch my flight to Dunedin. The flight was all set to go and was waiting for me&#8230; I barely made it in time!</p>
 66<p><img src="http://farm4.static.flickr.com/3109/3233835892_ec0b4d26f8.jpg?v=0" alt="Flying to Dunedin" /></p>
 67<p>When I got to Dunedin I was welcomed by Jesse, Tracey and Lindsay. It was great to meet them in person. The first order of business for me was to get some coffee, because I only got roughly 3 hours of sleep on my way there. After a little tour of <a href="http://www.otago.ac.nz/abbeycollege/">Abbey College</a> (that&#8217;s where I&#8217;m staying) it was time for our first meeting. No time for sleep! Finally, after dinner at Abbey, I decided it was time to get some sleep. When I woke up the next day, the jet-lag was no more!</p>
 68<p><img src="http://farm4.static.flickr.com/3201/3280470572_fceb6c64c8.jpg?v=0" alt="My Room" /></p>
 69<p>Abbey is a great place to stay by the way. It&#8217;s not far from the office or from the city center. The people who are staying there are great as well. Just <a href="http://www.otago.ac.nz/abbeycollege/">check out the site</a>. Abbey&#8217;s got it all!</p>
 70<p><img src="http://farm4.static.flickr.com/3227/3279648921_d8efbd51e3.jpg?v=0" alt="View from my room" /></p>
 71<p>So what am I doing here in NZ? We&#8217;re currently working on writing the software for the <a href="http://www.otago.ac.nz/research/pbrf/">PBRF initiative</a>. It has already taken a lot of late hours, and it will probably take a lot more. It will be worth it though! After that, we&#8217;ll be working on a great and exciting cutting-edge open-source project. Unfortunately I can&#8217;t say a lot more at this point, but you can rest assured that it includes the latest <a href="http://framework.zend.com">Zend Framework technologies</a>.</p>
 72<p><img src="http://farm4.static.flickr.com/3432/3239911680_bd2f368457.jpg?v=0" alt="My Desk" /></p>
 73<p>Seeing as I don&#8217;t have internet-access at Abbey College yet, I&#8217;ve got lots of time for other activities. I&#8217;ve finished reading the better part of my <a href="http://domaindrivendesign.org/books/#DDD">Domain Driven Design book</a> and I&#8217;ve ordered Martin Fowler&#8217;s <a href="http://martinfowler.com/books.html#eaa">Patterns Of Enterprise Application Architecture</a>, which should arrive this week. I&#8217;ve also bought myself a brand new bicycle so I can get around. Cycling here is a bit more dangerous than in the Netherlands though&#8230; it definitely brings back memories from my bicycling trip in Scotland! There are lots more things on my todo list: winery tour, surfing, snowboarding, skydiving, bungee-jumping, renting/buying a Harley&#8230; six months in NZ is not going to be enough time!</p>
 74<p><img src="http://farm4.static.flickr.com/3408/3279649371_521a113552.jpg?v=0" alt="Me!" /></p>
 75<p>Well, that&#8217;s my first NZ blog-post. There will definitely be more of these! Let&#8217;s hope they fix my internet soon&#8230; See <a href="http://www.flickr.com/photos/34800767@N05/">my Flickr photo-stream</a> for more pictures.</p>
 76]]></content:encoded>
 77			<wfw:commentRss>http://www.norm2782.com/2009/02/my-first-few-weeks-in-new-zealand/feed/</wfw:commentRss>
 78		<slash:comments>0</slash:comments>
 79		</item>
 80		<item>
 81		<title>Properties in PHP &#8211; revisited</title>
 82		<link>http://www.norm2782.com/2009/01/properties-in-php-revisited/</link>
 83		<comments>http://www.norm2782.com/2009/01/properties-in-php-revisited/#comments</comments>
 84		<pubDate>Wed, 14 Jan 2009 10:47:25 +0000</pubDate>
 85		<dc:creator>norm2782</dc:creator>
 86				<category><![CDATA[PHP]]></category>
 87		<category><![CDATA[Proof-of-concepts]]></category>
 88
 89		<guid isPermaLink="false">http://www.norm2782.com/?p=94</guid>
 90		<description><![CDATA[A while ago I was daydreaming about native property support in PHP. Unfortunately it will be a while before PHP itself will support this natively and an even longer while before shared hosting providers will upgrade to a newer version of PHP.
 91So what&#8217;s the big deal about those properties? In short, they make a developers [...]]]></description>
 92			<content:encoded><![CDATA[<p>A while ago I was daydreaming about native <a href="http://www.norm2782.com/2009/01/properties-in-php/">property support in PHP</a>. Unfortunately it will be a while before PHP itself will support this natively and an even longer while before shared hosting providers will upgrade to a newer version of PHP.</p>
 93<p>So what&#8217;s the big deal about those properties? In short, they make a developers life easier by allowing the developer to code no more than needed at that moment. And lets face it&#8230; less code is better! In this post we&#8217;ll see that it&#8217;s not impossible to enjoy properties in PHP <em>today</em>. As with a lot of good things, it does come with a small price though&#8230;</p>
 94<p><span id="more-94"></span><br />
 95Lets have a look at a use-case to demonstrate where properties will not only save you time, but it will also save your sanity. In this example we&#8217;re modeling a Person class. In the beginning of the project, the requirements for the Person class are quite simple: a Person has an age and a name. In the simplest form we can code that as follows:</p>
 96<pre name="code" class="php:nogutter">
 97&lt;?php
 98class Person
 99{
100    public $age;
101
102    public $name;
103}
104</pre>
105<p>This look easy enough, and it is. It even works like a charm and it&#8217;s possibly the fastest implementation for the Person class.</p>
106<p>But, pesky as they are, the client suddenly wants some logic added to our Person class! A Person suddenly can&#8217;t be younger than 21 years old. This poses a problem. To add logic to our Person class, we would have to switch the public age attribute with a pair of getters and setters:</p>
107<pre name="code" class="php:nogutter">
108&lt;?php
109class Person
110{
111    private $_age = null;
112
113    public $name = null;
114
115    public function getAge()
116    {
117        return $this-&gt;_age;
118    }
119
120    public function setAge($age)
121    {
122        if ($age &lt; 21) {
123            throw new Exception('You need to be at least 21 years or older!');
124        }
125
126        $this-&gt;_age = $age;
127    }
128}
129</pre>
130<p>Technically this works like a charm, however it will force me to go through my entire application and switch all references from the public attribute to the getter and setter. Not an ideal situation. One possible solution is to do things the Java way: just create all getters and setters up-front so you don&#8217;t have to do so afterwards. Even though this works fine, it&#8217;s in violation of our mission to write no more code than we actually need at the moment of writing.</p>
131<p>The solution? Properties! But wait&#8230; PHP doesn&#8217;t support those, remember? Luckily we still have magic methods. It&#8217;s nowhere near as nice as a native solution, but at least it helps us write no more code than we need at the moment we&#8217;re first writing our code:</p>
132<pre name="code" class="php:nogutter">
133&lt;?php
134abstract class ModelAbstract
135{
136    public function __get($key)
137    {
138        $method = 'get' . ucfirst($key);
139
140        if (!method_exists($this, $method)) {
141            throw new Exception('No property found for ' . $key);
142        }
143
144        return $this-&gt;$method();
145    }
146
147    public function __set($key, $value)
148    {
149        $method = 'set' . ucfirst($key);
150
151        if (!method_exists($this, $method)) {
152            throw new Exception('No property found for ' . $key);
153        }
154
155        $this-&gt;$method($value);
156    }
157}
158</pre>
159<p>We&#8217;ll take a look at what this does exactly later. The important thing to note is that we can now do the following:</p>
160<pre name="code" class="php:nogutter">
161&lt;?php
162class Person extends ModelAbstract
163{
164    private $_age = null;
165
166    public $name = null;
167
168    public function getAge()
169    {
170        return $this-&gt;_age;
171    }
172
173    public function setAge($age)
174    {
175        if ($age &lt; 21) {
176            throw new Exception('You need to be at least 21 years or older!');
177        }
178
179        $this-&gt;_age = $age;
180    }
181}
182
183$person = new Person();
184
185try {
186    $person-&gt;age = 10;
187} catch (Exception $e) {
188    // Will print "You need to be at least 21 years or older!"
189    echo $e-&gt;getMessage();
190}
191</pre>
192<p>With this construction in place, we can safely switch from a public attribute to getters and setters, without changing the rest of the application code. The only real downside to this &#8211; aside from the minor speed impact &#8211; is the fact that you have to subclass ModelAbstract to make this work. Luckily it&#8217;s not a lot of code, so should there be a big need to get rid of the ModelAbstract inheritance it&#8217;s not a big disaster to do some copy/paste work.</p>
193<p>This method works by assuming you have get- and set methods that have the same name as the property you&#8217;re trying to access. When there&#8217;s a public attribute, it will use that. If there&#8217;s no public attribute, it will fall back to __get or __set and the logic will take it from there.</p>
194<p>All of this is just a proof-of-concept of implementing properties in PHP and of the way I want to be using properties to access data the data in my objects. Please comment your experiences with this approach or similar approaches. I&#8217;m curious to see how practical this solution would be in a real-life situation.</p>
195]]></content:encoded>
196			<wfw:commentRss>http://www.norm2782.com/2009/01/properties-in-php-revisited/feed/</wfw:commentRss>
197		<slash:comments>0</slash:comments>
198		</item>
199		<item>
200		<title>Filters for Zend_Paginator</title>
201		<link>http://www.norm2782.com/2009/01/filters-for-zend_paginator/</link>
202		<comments>http://www.norm2782.com/2009/01/filters-for-zend_paginator/#comments</comments>
203		<pubDate>Tue, 13 Jan 2009 12:57:53 +0000</pubDate>
204		<dc:creator>norm2782</dc:creator>
205				<category><![CDATA[PHP]]></category>
206		<category><![CDATA[Zend Framework]]></category>
207
208		<guid isPermaLink="false">http://www.norm2782.com/?p=72</guid>
209		<description><![CDATA[Zend_Paginator has a new feature! It is now possible to add a filter to your Paginator object which acts on the data retrieved from the adapter. This filter can be any instance of Zend_Filter_Interface, including a filter-chain. If a filter(-chain) is set, the raw data from the adapter will be passed to the filter() method.
210
211So [...]]]></description>
212			<content:encoded><![CDATA[<p>Zend_Paginator has a new feature! It is now possible to add a filter to your Paginator object which acts on the data retrieved from the adapter. This filter can be any instance of Zend_Filter_Interface, including a filter-chain. If a filter(-chain) is set, the raw data from the adapter will be passed to the filter() method.</p>
213<p><span id="more-72"></span><br />
214So why would you want to apply filters to your result set? Usually my domain models don&#8217;t inherit from Zend_Db_Table_Row but that is the data type I get from the Paginator when I use the DbTableSelect adapter (wrapped in a nice Zend_Db_Table_Rowset). Instead, I would like to load my rows into my models and preferably without using the Paginator abilities or having to apply weird hacks. Previously this was only possible (in a sane way) by subclassing an adapter so it could return a collection of model objects instead of a rowset. With the new filter support you can just inject a filter to do this for you.</p>
215<p>Lets have a look at an example. In this example I want to list all my users from the database. I&#8217;ll grab the name of the user from the row and inject it into a User object.</p>
216<pre name="code" class="php:nogutter">
217&lt;?php
218class User
219{
220    private $_name = '';
221
222    public function getName()
223    {
224        return $this-&gt;_name;
225    }
226
227    public function setName($name)
228    {
229        $this-&gt;_name = $name;
230    }
231}
232
233class UserFilter implements Zend_Filter_Interface
234{
235    public function filter($rows)
236    {
237        $users = array();
238
239        foreach ($rows as $row) {
240            $user = new User();
241            $user-&gt;setName($row-&gt;name);
242
243            $users[] = $user;
244        }
245
246        return $rows;
247    }
248}
249
250class MyModel
251{
252    public static function getUserPaginator()
253    {
254        $userTable = new UserTable();
255        $paginator = Zend_Paginator::factory($userTable-&gt;select());
256        $paginator-&gt;setFilter(new UserFilter());
257
258        return $paginator;
259    }
260}
261
262$paginator = MyModel::getUserPaginator();
263$items = $paginator-&gt;getCurrentItems();
264
265foreach ($items as $user) {
266    echo 'Current name: ' . $user-&gt;getName() . '&lt;br /&gt;' . PHP_EOL;
267}
268</pre>
269<p>To simplify adding a simple filter to your paginator I&#8217;ve also added Zend_Filter_Callback. This allows you to specify a callback method that does the same as the filter in the previous example.</p>
270<pre name="code" class="php:nogutter">
271&lt;?php
272class MyModel
273{
274    public static function getUserPaginator()
275    {
276        $userTable = new UserTable();
277        $paginator = Zend_Paginator::factory($userTable-&gt;select());
278        $paginator-&gt;setFilter(new Zend_Filter_Callback(
279            array('MyModel', 'filter'))
280        );
281
282        return $paginator;
283    }
284
285    public static function filter($rows)
286    {
287        $users = array();
288
289        foreach ($rows as $row) {
290            $user = new User();
291            $user-&gt;setName($row-&gt;name);
292
293            $users[] = $user;
294        }
295
296        return $rows;
297    }
298}
299</pre>
300<p>The callback also accepts object instead of a static reference to a class. Internally it uses call_user_func to execute the filter() method, so any notation that works there, works with the Callback filter.</p>
301<p>Enjoy!</p>
302]]></content:encoded>
303			<wfw:commentRss>http://www.norm2782.com/2009/01/filters-for-zend_paginator/feed/</wfw:commentRss>
304		<slash:comments>0</slash:comments>
305		</item>
306		<item>
307		<title>ZF-3239</title>
308		<link>http://www.norm2782.com/2009/01/zf-3239/</link>
309		<comments>http://www.norm2782.com/2009/01/zf-3239/#comments</comments>
310		<pubDate>Wed, 07 Jan 2009 11:48:31 +0000</pubDate>
311		<dc:creator>norm2782</dc:creator>
312				<category><![CDATA[PHP]]></category>
313		<category><![CDATA[Zend Framework]]></category>
314
315		<guid isPermaLink="false">http://www.norm2782.com/?p=68</guid>
316		<description><![CDATA[Zend_Db_Table_Select users, rejoice! I&#8217;ve just committed a patch for ZF-3239 in revision 13530. This should be a relief for those of you who have been implementing workarounds for those &#8220;No table has been specified for the FROM clause&#8221; exceptions.
317]]></description>
318			<content:encoded><![CDATA[<p>Zend_Db_Table_Select users, rejoice! I&#8217;ve just committed a patch for <a href="http://framework.zend.com/issues/browse/ZF-3239">ZF-3239</a> in revision 13530. This should be a relief for those of you who have been implementing workarounds for those &#8220;No table has been specified for the FROM clause&#8221; exceptions.</p>
319]]></content:encoded>
320			<wfw:commentRss>http://www.norm2782.com/2009/01/zf-3239/feed/</wfw:commentRss>
321		<slash:comments>0</slash:comments>
322		</item>
323		<item>
324		<title>New in-ear earphones</title>
325		<link>http://www.norm2782.com/2009/01/new-in-ear-earphones/</link>
326		<comments>http://www.norm2782.com/2009/01/new-in-ear-earphones/#comments</comments>
327		<pubDate>Sat, 03 Jan 2009 15:49:19 +0000</pubDate>
328		<dc:creator>norm2782</dc:creator>
329				<category><![CDATA[Personal]]></category>
330
331		<guid isPermaLink="false">http://www.norm2782.com/?p=53</guid>
332		<description><![CDATA[Just got myself the Sennheiser CX 300 II Precision in-ear earphones. Check &#8216;em out by clicking the read more link!
333
334
335]]></description>
336			<content:encoded><![CDATA[<p>Just got myself the Sennheiser CX 300 II Precision in-ear earphones. Check &#8216;em out by clicking the read more link!</p>
337<p><span id="more-53"></span><br />
338<img src="http://www.norm2782.com/wp-content/uploads/2009/01/cx300.jpeg" alt="cx300" title="cx300" width="300" height="300" class="alignnone size-full wp-image-60" /></p>
339]]></content:encoded>
340			<wfw:commentRss>http://www.norm2782.com/2009/01/new-in-ear-earphones/feed/</wfw:commentRss>
341		<slash:comments>0</slash:comments>
342		</item>
343		<item>
344		<title>Seven Things &#8211; Tagged by Pádraic</title>
345		<link>http://www.norm2782.com/2009/01/seven-things-tagged-by-padraic/</link>
346		<comments>http://www.norm2782.com/2009/01/seven-things-tagged-by-padraic/#comments</comments>
347		<pubDate>Sat, 03 Jan 2009 10:14:38 +0000</pubDate>
348		<dc:creator>norm2782</dc:creator>
349				<category><![CDATA[Personal]]></category>
350
351		<guid isPermaLink="false">http://www.norm2782.com/?p=44</guid>
352		<description><![CDATA[Well, this was bound to happen: I got tagged by Pádraic because I&#8217;m working on Zend_Feed_Reader with him. Luckily I&#8217;ve just setup this new blog, so here we go!
353Did you know that&#8230;
354
355Every bit of PHP I know is self-taught
356My programming adventure started out with Visual Basic 3 back in 1993. I was just 8 years [...]]]></description>
357			<content:encoded><![CDATA[<p>Well, this was bound to happen: I got tagged by <a href="http://blog.astrumfutura.com/">Pádraic</a> because I&#8217;m working on <a href="http://framework.zend.com/code/browse/Zend_Framework/standard/incubator/library/Zend/Feed">Zend_Feed_Reader</a> with him. Luckily I&#8217;ve just setup this new blog, so here we go!</p>
358<p>Did you know that&#8230;</p>
359<ul>
360<li>Every bit of PHP I know is self-taught</li>
361<li>My programming adventure started out with Visual Basic 3 back in 1993. I was just 8 years old back then and had no clue what I was doing.</li>
362<li>My left foot is actually a few millimeter bigger than my right foot.</li>
363<li>I used to have long hair (almost reached my ass). I cut it off in the summer of &#8216;08 for various reasons, one of which was 100 euro.</li>
364<li>I bought my Harley Davidson before I even had my drivers license.</li>
365<li>My whisky collection (only single malts <img src='http://www.norm2782.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> ) keeps growing instead of shrinking</li>
366<li>While I use a Mac, with an Apple Cinema Display and an Apple keyboard&#8230; I have an HTC Touch with Windows Mobile and I&#8217;m stuck with it for at least a few more months.</li>
367</ul>
368<p>Now it&#8217;s my turn to start tagging!</p>
369<ul>
370<li><a href="http://www.leftontheweb.com/weblog">Stefan Koopmanschap</a> &#8211; For not being tagged yet and having said so on Twitter</li>
371<li><a href="http://naneau.nl/">Maurice Fonk</a> &#8211; For being my co-worker and for not having finished <a href="http://madoqua.org/">Madoqua</a> yet</li>
372<li><a href="http://mirmodynamics.com/">Geoffrey Bachelet</a> &#8211; For the great party in Paris</li>
373<li><a href="http://wadearnold.com/blog/">Wade Arnold</a> &#8211; For doing a great job on Zend_AMF and having the same WordPress theme as me.</li>
374<li><a href="http://www.missyeh.nl/blog/">Kana Yeh</a> &#8211; For being the coolest PHP girl in the Netherlands (that I know of)</li>
375<li><a href="http://www.builtfromsource.com/">Matthew Ratzloff</a> &#8211; For his great help on Zend_Paginator</li>
376<li>And one more here&#8230;</li>
377</ul>
378<p>As for the rules:</p>
379<ul>
380<li>Link your original tagger(s), and list these rules on your blog.</li>
381<li>Share seven facts about yourself in the post &#8211; some random, some wierd.</li>
382<li>Tag seven people at the end of your post by leaving their names and the links to their blogs.</li>
383<li>Let them know they&#8217;ve been tagged by leaving a comment on their blogs and/or Twitter.</li>
384</ul>
385]]></content:encoded>
386			<wfw:commentRss>http://www.norm2782.com/2009/01/seven-things-tagged-by-padraic/feed/</wfw:commentRss>
387		<slash:comments>0</slash:comments>
388		</item>
389		<item>
390		<title>AMF Server class for WordPress</title>
391		<link>http://www.norm2782.com/2009/01/amf-server-class-for-wordpress/</link>
392		<comments>http://www.norm2782.com/2009/01/amf-server-class-for-wordpress/#comments</comments>
393		<pubDate>Fri, 02 Jan 2009 14:49:42 +0000</pubDate>
394		<dc:creator>norm2782</dc:creator>
395				<category><![CDATA[Flex]]></category>
396		<category><![CDATA[PHP]]></category>
397		<category><![CDATA[Zend Framework]]></category>
398
399		<guid isPermaLink="false">http://www.norm2782.com/?p=27</guid>
400		<description><![CDATA[After browsing through WordPress&#8217; code I quickly found that there&#8217;s no sane way to create AMF support as a WP plugin. At least not for someone who hasn&#8217;t done any old-skool procedural PHP in years. Instead of writing a plugin, I decided to write a standalone server script. It&#8217;s still very basic and currently setup [...]]]></description>
401			<content:encoded><![CDATA[<p>After browsing through WordPress&#8217; code I quickly found that there&#8217;s no sane way to create AMF support as a WP plugin. At least not for someone who hasn&#8217;t done any old-skool procedural PHP in years. Instead of writing a plugin, I decided to write a standalone server script. It&#8217;s still very basic and currently setup to work for me. To get it working for your WP setup you should probably make some minor modifications. Click the read more link to check out the code. I&#8217;ve released it under the generous BSD license, so knock yourself out! Use it at your own risk&#8230; I&#8217;m not going to support it. Any updates will be posted in this post. Also, please note that I haven&#8217;t tested it yet. If you access the script directly it should output &#8220;Zend Amf Endpoint&#8221; just fine, but that&#8217;s all I can guarantee at this point <img src='http://www.norm2782.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
402<p><span id="more-27"></span></p>
403<pre name="code" class="php:nogutter">
404&lt;?php
405/**
406 * BSD LICENSE
407 *
408 * Copyright (c) 2009, norm2782
409 * All rights reserved.
410 *
411 * Redistribution and use in source and binary forms, with or without
412 * modification, are permitted provided that the following conditions are met:
413 *     * Redistributions of source code must retain the above copyright
414 *       notice, this list of conditions and the following disclaimer.
415 *     * Redistributions in binary form must reproduce the above copyright
416 *       notice, this list of conditions and the following disclaimer in the
417 *       documentation and/or other materials provided with the distribution.
418 *     * Neither the name of norm2782 nor the
419 *       names of its contributors may be used to endorse or promote products
420 *       derived from this software without specific prior written permission.
421 *
422 * THIS SOFTWARE IS PROVIDED BY norm2782 ''AS IS'' AND ANY
423 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
424 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
425 * DISCLAIMED. IN NO EVENT SHALL norm2782 BE LIABLE FOR ANY
426 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
427 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
428 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
429 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
430 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
431 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
432 */
433
434/**
435 * Set production mode.
436 * If set to false, exceptions will bubble through to the Flex frontend
437 *
438 * @var bool
439 */
440$production = false;
441
442/**
443 * Determine the absolute path of the AMF server
444 *
445 * @var string
446 */
447define('ABSPATH', dirname(__FILE__) . '/');
448
449/**
450 * One directory below docroot. Your config file and library dir should be here.
451 *
452 * @var string
453 */
454define('SUBPATH', dirname(ABSPATH));
455
456/**
457 * You should make sure Zend Framework is in your include path
458 */
459set_include_path(
460    implode(PATH_SEPARATOR, array(
461        SUBPATH . '/library',
462        get_include_path()
463    ))
464);
465
466/**
467 * Include the WordPress config file
468 */
469$configFile = SUBPATH . '/wp-config.php';
470
471if (!file_exists($configFile)) {
472    throw new Exception('WordPress config file was not found!');
473}
474
475require_once $configFile;
476
477/**
478 * No need to config more stuff from this point on
479 */
480
481/**
482 * @see Zend_Amf_Server
483 */
484require_once 'Zend/Amf/Server.php';
485
486/**
487 * @see Zend_Db_Adapter_Pdo_Mysql
488 */
489require_once 'Zend/Db/Adapter/Pdo/Mysql.php';
490
491/**
492 * @see Zend_Paginator
493 */
494require_once 'Zend/Paginator.php';
495
496/**
497 * @see Zend_Paginator_Adapter_DbSelect
498 */
499require_once 'Zend/Paginator/Adapter/DbSelect.php';
500
501/**
502 * Simple class to expose wordpress data through AMF
503 *
504 * @author norm2782
505 */
506class Wp_Amf_Gateway
507{
508    /**
509     * Database adapter
510     *
511     * @var Zend_Db_Adapter_Pdo_Mysql
512     */
513    private $_db = null;
514
515    /**
516     * WordPress table prefix
517     *
518     * @var string
519     */
520    private $_prefix = null;
521
522    /**
523     * Constructor
524     *
525     * @param array $dbConfig
526     * @param string $prefix
527     * @return void
528     */
529    public function __construct(array $dbConfig, $prefix)
530    {
531        $this-&gt;_db = new Zend_Db_Adapter_Pdo_Mysql($dbConfig);
532        $this-&gt;_db-&gt;query('SET NAMES `utf8`');
533
534        $this-&gt;_prefix = $prefix;
535    }
536
537    /**
538     * Get paginated results for the provided query
539     *
540     * @param Zend_Db_Select $select
541     * @param int $page
542     * @param int $itemsPerPage
543     * @return array
544     */
545    private function _getPaginated(Zend_Db_Select $select, $page, $itemsPerPage)
546    {
547        $paginator = new Zend_Paginator(
548            new Zend_Paginator_Adapter_DbSelect($select)
549        );
550
551        $paginator-&gt;setCurrentPageNumber($page)
552                  -&gt;setItemCountPerPage($itemsPerPage);
553
554        return array(
555            'info'  =&gt; $paginator-&gt;getPages(),
556            'items' =&gt; $paginator-&gt;getCurrentItems()
557        );
558    }
559
560    /**
561     * Get the comments for the specified post ID
562     *
563     * @param int $postId
564     * @param int $page
565     * @param int $itemsPerPage
566     * @return array
567     */
568    public function getCommentsForPost($postId, $page = 1, $itemsPerPage = 10)
569    {
570        $select = $this-&gt;_db-&gt;select()-&gt;from($this-&gt;_prefix . 'comments')
571                                      -&gt;where('comment_post_ID = ?', $postId);
572
573        return $this-&gt;_getPaginated($select, $page, $itemsPerPage);
574    }
575
576    /**
577     * Get the meta data for the specified post ID
578     *
579     * @param $postId
580     * @return unknown_type
581     */
582    public function getMetaForPost($postId)
583    {
584        $select = $this-&gt;_db-&gt;select()-&gt;from($this-&gt;_prefix . 'postmeta')
585                                      -&gt;where('post_id = ?', $postId);
586
587        return $this-&gt;_db-&gt;fetchAll($select);
588    }
589
590    /**
591     * Get a post by specifying its ID
592     *
593     * @param int $postId
594     * @return array
595     */
596    public function getPost($postId)
597    {
598        $select = $this-&gt;_db-&gt;select()-&gt;from($this-&gt;_prefix . 'posts')
599                                      -&gt;where('ID = ?', $postId);
600
601        return $this-&gt;_db-&gt;fetchOne($select);
602    }
603
604    /**
605     * Get posts per page
606     *
607     * @param int $page
608     * @param int $itemsPerPage
609     * @return array
610     */
611    public function getPosts($page = 1, $itemsPerPage = 10)
612    {
613        $select = $this-&gt;_db-&gt;select()-&gt;from($this-&gt;_prefix . 'posts');
614
615        return $this-&gt;_getPaginated($select, $page, $itemsPerPage);
616    }
617}
618
619/**
620 * Pass the values from wp-config.php to the Wp_Amf_Gateway class.
621 */
622$gateway = new Wp_Amf_Gateway(
623    array(
624        'host'     =&gt; DB_HOST,
625        'username' =&gt; DB_USER,
626        'password' =&gt; DB_PASSWORD,
627        'dbname'   =&gt; DB_NAME
628    ),
629    $table_prefix
630);
631
632$server = new Zend_Amf_Server();
633$server-&gt;setProduction($production)
634       -&gt;setClass($gateway)
635       -&gt;handle();
636</pre>
637]]></content:encoded>
638			<wfw:commentRss>http://www.norm2782.com/2009/01/amf-server-class-for-wordpress/feed/</wfw:commentRss>
639		<slash:comments>0</slash:comments>
640		</item>
641		<item>
642		<title>Flex frontend</title>
643		<link>http://www.norm2782.com/2009/01/flex-frontend/</link>
644		<comments>http://www.norm2782.com/2009/01/flex-frontend/#comments</comments>
645		<pubDate>Thu, 01 Jan 2009 23:29:35 +0000</pubDate>
646		<dc:creator>norm2782</dc:creator>
647				<category><![CDATA[Flex]]></category>
648		<category><![CDATA[PHP]]></category>
649
650		<guid isPermaLink="false">http://www.norm2782.com/?p=22</guid>
651		<description><![CDATA[I was planning on writing a quick Flex frontend for this blog, but it appears WordPress only offers the posts themselves as RSS feed. If I get real bored (which I doubt,  unfortunately) I&#8217;ll have a look and see if I can create a Zend_AMF plugin for WordPress that allows me to retrieve virtually [...]]]></description>
652			<content:encoded><![CDATA[<p>I was planning on writing a quick Flex frontend for this blog, but it appears WordPress only offers the posts themselves as RSS feed. If I get real bored (which I doubt,  unfortunately) I&#8217;ll have a look and see if I can create a Zend_AMF plugin for WordPress that allows me to retrieve virtually all data from my WordPress install. Would be cool <img src='http://www.norm2782.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
653]]></content:encoded>
654			<wfw:commentRss>http://www.norm2782.com/2009/01/flex-frontend/feed/</wfw:commentRss>
655		<slash:comments>0</slash:comments>
656		</item>
657		<item>
658		<title>Properties in PHP</title>
659		<link>http://www.norm2782.com/2009/01/properties-in-php/</link>
660		<comments>http://www.norm2782.com/2009/01/properties-in-php/#comments</comments>
661		<pubDate>Thu, 01 Jan 2009 23:02:54 +0000</pubDate>
662		<dc:creator>norm2782</dc:creator>
663				<category><![CDATA[Daydreaming]]></category>
664		<category><![CDATA[PHP]]></category>
665
666		<guid isPermaLink="false">http://www.norm2782.com/?p=8</guid>
667		<description><![CDATA[A while ago Dynom from #php_bnl pointed me to an interesting entry on the PHP 5.3 wiki page. In the &#8220;Future PHP releases&#8221; sections there&#8217;s an entry called &#8220;29. “real” properties with attached getters and setters&#8221;. Personally I can&#8217;t wait for this. Hopefully it will look something like ActionScript 3&#8217;s properties:
668
669&#60;?php
670class Bar
671{
672    [...]]]></description>
673			<content:encoded><![CDATA[<p>A while ago Dynom from #php_bnl pointed me to an interesting entry on the <a title="PHP 5.3 wiki page" href="http://wiki.php.net/todo/php53">PHP 5.3 wiki page</a>. In the &#8220;Future PHP releases&#8221; sections there&#8217;s an entry called &#8220;29. “real” properties with attached getters and setters&#8221;. Personally I can&#8217;t wait for this. Hopefully it will look something like ActionScript 3&#8217;s properties:</p>
674<pre name="code" class="php:nogutter">
675&lt;?php
676class Bar
677{
678    private $_foo = 'foo';
679
680    public function get foo()
681    {
682        return $this->_foo;
683    }
684
685    public function set foo($fooString)
686    {
687        $this->_foo = $fooString;
688    }
689}
690
691$bar = new Bar();
692$bar->foo = 'baz';
693echo $bar->foo; // prints baz
694</pre>
695]]></content:encoded>
696			<wfw:commentRss>http://www.norm2782.com/2009/01/properties-in-php/feed/</wfw:commentRss>
697		<slash:comments>0</slash:comments>
698		</item>
699	</channel>
700</rss>