PageRenderTime 56ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

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

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. <channel>
  11. <title>Norm 2782</title>
  12. <atom:link href="http://www.norm2782.com/feed/" rel="self" type="application/rss+xml" />
  13. <link>http://www.norm2782.com</link>
  14. <description>Why are you here?</description>
  15. <lastBuildDate>Sat, 07 Mar 2009 08:03:50 +0000</lastBuildDate>
  16. <generator>http://wordpress.org/?v=2.8</generator>
  17. <language>en</language>
  18. <sy:updatePeriod>hourly</sy:updatePeriod>
  19. <sy:updateFrequency>1</sy:updateFrequency>
  20. <item>
  21. <title>Wth&#8230; reading books?</title>
  22. <link>http://www.norm2782.com/2009/03/wth-reading-books/</link>
  23. <comments>http://www.norm2782.com/2009/03/wth-reading-books/#comments</comments>
  24. <pubDate>Mon, 02 Mar 2009 08:09:33 +0000</pubDate>
  25. <dc:creator>norm2782</dc:creator>
  26. <category><![CDATA[New Zealand]]></category>
  27. <category><![CDATA[Personal]]></category>
  28. <category><![CDATA[Programming]]></category>
  29. <category><![CDATA[Study]]></category>
  30. <guid isPermaLink="false">http://www.norm2782.com/?p=114</guid>
  31. <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.
  32. Agile Software Development with Scrum, by Ken Schwaber and Mike Beedle
  33. Domain-Driven Design: Tackling Complexity in the [...]]]></description>
  34. <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>
  35. <ul>
  36. <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>
  37. <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>
  38. <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>
  39. <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>
  40. </ul>
  41. <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>
  42. ]]></content:encoded>
  43. <wfw:commentRss>http://www.norm2782.com/2009/03/wth-reading-books/feed/</wfw:commentRss>
  44. <slash:comments>0</slash:comments>
  45. </item>
  46. <item>
  47. <title>My first few weeks in New Zealand</title>
  48. <link>http://www.norm2782.com/2009/02/my-first-few-weeks-in-new-zealand/</link>
  49. <comments>http://www.norm2782.com/2009/02/my-first-few-weeks-in-new-zealand/#comments</comments>
  50. <pubDate>Sun, 15 Feb 2009 03:29:21 +0000</pubDate>
  51. <dc:creator>norm2782</dc:creator>
  52. <category><![CDATA[New Zealand]]></category>
  53. <category><![CDATA[Personal]]></category>
  54. <guid isPermaLink="false">http://www.norm2782.com/?p=105</guid>
  55. <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>
  56. <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>
  57. <p><span id="more-105"></span><br />
  58. My 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>
  59. <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>
  60. <p><img src="http://farm4.static.flickr.com/3403/3232983613_637af46bc3.jpg?v=0" alt="SF Airport" /></p>
  61. <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>
  62. <p><img src="http://farm4.static.flickr.com/3109/3233835892_ec0b4d26f8.jpg?v=0" alt="Flying to Dunedin" /></p>
  63. <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>
  64. <p><img src="http://farm4.static.flickr.com/3201/3280470572_fceb6c64c8.jpg?v=0" alt="My Room" /></p>
  65. <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>
  66. <p><img src="http://farm4.static.flickr.com/3227/3279648921_d8efbd51e3.jpg?v=0" alt="View from my room" /></p>
  67. <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>
  68. <p><img src="http://farm4.static.flickr.com/3432/3239911680_bd2f368457.jpg?v=0" alt="My Desk" /></p>
  69. <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>
  70. <p><img src="http://farm4.static.flickr.com/3408/3279649371_521a113552.jpg?v=0" alt="Me!" /></p>
  71. <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>
  72. ]]></content:encoded>
  73. <wfw:commentRss>http://www.norm2782.com/2009/02/my-first-few-weeks-in-new-zealand/feed/</wfw:commentRss>
  74. <slash:comments>0</slash:comments>
  75. </item>
  76. <item>
  77. <title>Properties in PHP &#8211; revisited</title>
  78. <link>http://www.norm2782.com/2009/01/properties-in-php-revisited/</link>
  79. <comments>http://www.norm2782.com/2009/01/properties-in-php-revisited/#comments</comments>
  80. <pubDate>Wed, 14 Jan 2009 10:47:25 +0000</pubDate>
  81. <dc:creator>norm2782</dc:creator>
  82. <category><![CDATA[PHP]]></category>
  83. <category><![CDATA[Proof-of-concepts]]></category>
  84. <guid isPermaLink="false">http://www.norm2782.com/?p=94</guid>
  85. <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.
  86. So what&#8217;s the big deal about those properties? In short, they make a developers [...]]]></description>
  87. <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>
  88. <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>
  89. <p><span id="more-94"></span><br />
  90. Lets 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>
  91. <pre name="code" class="php:nogutter">
  92. &lt;?php
  93. class Person
  94. {
  95. public $age;
  96. public $name;
  97. }
  98. </pre>
  99. <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>
  100. <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>
  101. <pre name="code" class="php:nogutter">
  102. &lt;?php
  103. class Person
  104. {
  105. private $_age = null;
  106. public $name = null;
  107. public function getAge()
  108. {
  109. return $this-&gt;_age;
  110. }
  111. public function setAge($age)
  112. {
  113. if ($age &lt; 21) {
  114. throw new Exception('You need to be at least 21 years or older!');
  115. }
  116. $this-&gt;_age = $age;
  117. }
  118. }
  119. </pre>
  120. <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>
  121. <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>
  122. <pre name="code" class="php:nogutter">
  123. &lt;?php
  124. abstract class ModelAbstract
  125. {
  126. public function __get($key)
  127. {
  128. $method = 'get' . ucfirst($key);
  129. if (!method_exists($this, $method)) {
  130. throw new Exception('No property found for ' . $key);
  131. }
  132. return $this-&gt;$method();
  133. }
  134. public function __set($key, $value)
  135. {
  136. $method = 'set' . ucfirst($key);
  137. if (!method_exists($this, $method)) {
  138. throw new Exception('No property found for ' . $key);
  139. }
  140. $this-&gt;$method($value);
  141. }
  142. }
  143. </pre>
  144. <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>
  145. <pre name="code" class="php:nogutter">
  146. &lt;?php
  147. class Person extends ModelAbstract
  148. {
  149. private $_age = null;
  150. public $name = null;
  151. public function getAge()
  152. {
  153. return $this-&gt;_age;
  154. }
  155. public function setAge($age)
  156. {
  157. if ($age &lt; 21) {
  158. throw new Exception('You need to be at least 21 years or older!');
  159. }
  160. $this-&gt;_age = $age;
  161. }
  162. }
  163. $person = new Person();
  164. try {
  165. $person-&gt;age = 10;
  166. } catch (Exception $e) {
  167. // Will print "You need to be at least 21 years or older!"
  168. echo $e-&gt;getMessage();
  169. }
  170. </pre>
  171. <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>
  172. <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>
  173. <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>
  174. ]]></content:encoded>
  175. <wfw:commentRss>http://www.norm2782.com/2009/01/properties-in-php-revisited/feed/</wfw:commentRss>
  176. <slash:comments>0</slash:comments>
  177. </item>
  178. <item>
  179. <title>Filters for Zend_Paginator</title>
  180. <link>http://www.norm2782.com/2009/01/filters-for-zend_paginator/</link>
  181. <comments>http://www.norm2782.com/2009/01/filters-for-zend_paginator/#comments</comments>
  182. <pubDate>Tue, 13 Jan 2009 12:57:53 +0000</pubDate>
  183. <dc:creator>norm2782</dc:creator>
  184. <category><![CDATA[PHP]]></category>
  185. <category><![CDATA[Zend Framework]]></category>
  186. <guid isPermaLink="false">http://www.norm2782.com/?p=72</guid>
  187. <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.
  188. So [...]]]></description>
  189. <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>
  190. <p><span id="more-72"></span><br />
  191. So 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>
  192. <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>
  193. <pre name="code" class="php:nogutter">
  194. &lt;?php
  195. class User
  196. {
  197. private $_name = '';
  198. public function getName()
  199. {
  200. return $this-&gt;_name;
  201. }
  202. public function setName($name)
  203. {
  204. $this-&gt;_name = $name;
  205. }
  206. }
  207. class UserFilter implements Zend_Filter_Interface
  208. {
  209. public function filter($rows)
  210. {
  211. $users = array();
  212. foreach ($rows as $row) {
  213. $user = new User();
  214. $user-&gt;setName($row-&gt;name);
  215. $users[] = $user;
  216. }
  217. return $rows;
  218. }
  219. }
  220. class MyModel
  221. {
  222. public static function getUserPaginator()
  223. {
  224. $userTable = new UserTable();
  225. $paginator = Zend_Paginator::factory($userTable-&gt;select());
  226. $paginator-&gt;setFilter(new UserFilter());
  227. return $paginator;
  228. }
  229. }
  230. $paginator = MyModel::getUserPaginator();
  231. $items = $paginator-&gt;getCurrentItems();
  232. foreach ($items as $user) {
  233. echo 'Current name: ' . $user-&gt;getName() . '&lt;br /&gt;' . PHP_EOL;
  234. }
  235. </pre>
  236. <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>
  237. <pre name="code" class="php:nogutter">
  238. &lt;?php
  239. class MyModel
  240. {
  241. public static function getUserPaginator()
  242. {
  243. $userTable = new UserTable();
  244. $paginator = Zend_Paginator::factory($userTable-&gt;select());
  245. $paginator-&gt;setFilter(new Zend_Filter_Callback(
  246. array('MyModel', 'filter'))
  247. );
  248. return $paginator;
  249. }
  250. public static function filter($rows)
  251. {
  252. $users = array();
  253. foreach ($rows as $row) {
  254. $user = new User();
  255. $user-&gt;setName($row-&gt;name);
  256. $users[] = $user;
  257. }
  258. return $rows;
  259. }
  260. }
  261. </pre>
  262. <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>
  263. <p>Enjoy!</p>
  264. ]]></content:encoded>
  265. <wfw:commentRss>http://www.norm2782.com/2009/01/filters-for-zend_paginator/feed/</wfw:commentRss>
  266. <slash:comments>0</slash:comments>
  267. </item>
  268. <item>
  269. <title>ZF-3239</title>
  270. <link>http://www.norm2782.com/2009/01/zf-3239/</link>
  271. <comments>http://www.norm2782.com/2009/01/zf-3239/#comments</comments>
  272. <pubDate>Wed, 07 Jan 2009 11:48:31 +0000</pubDate>
  273. <dc:creator>norm2782</dc:creator>
  274. <category><![CDATA[PHP]]></category>
  275. <category><![CDATA[Zend Framework]]></category>
  276. <guid isPermaLink="false">http://www.norm2782.com/?p=68</guid>
  277. <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.
  278. ]]></description>
  279. <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>
  280. ]]></content:encoded>
  281. <wfw:commentRss>http://www.norm2782.com/2009/01/zf-3239/feed/</wfw:commentRss>
  282. <slash:comments>0</slash:comments>
  283. </item>
  284. <item>
  285. <title>New in-ear earphones</title>
  286. <link>http://www.norm2782.com/2009/01/new-in-ear-earphones/</link>
  287. <comments>http://www.norm2782.com/2009/01/new-in-ear-earphones/#comments</comments>
  288. <pubDate>Sat, 03 Jan 2009 15:49:19 +0000</pubDate>
  289. <dc:creator>norm2782</dc:creator>
  290. <category><![CDATA[Personal]]></category>
  291. <guid isPermaLink="false">http://www.norm2782.com/?p=53</guid>
  292. <description><![CDATA[Just got myself the Sennheiser CX 300 II Precision in-ear earphones. Check &#8216;em out by clicking the read more link!
  293. ]]></description>
  294. <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>
  295. <p><span id="more-53"></span><br />
  296. <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>
  297. ]]></content:encoded>
  298. <wfw:commentRss>http://www.norm2782.com/2009/01/new-in-ear-earphones/feed/</wfw:commentRss>
  299. <slash:comments>0</slash:comments>
  300. </item>
  301. <item>
  302. <title>Seven Things &#8211; Tagged by Pádraic</title>
  303. <link>http://www.norm2782.com/2009/01/seven-things-tagged-by-padraic/</link>
  304. <comments>http://www.norm2782.com/2009/01/seven-things-tagged-by-padraic/#comments</comments>
  305. <pubDate>Sat, 03 Jan 2009 10:14:38 +0000</pubDate>
  306. <dc:creator>norm2782</dc:creator>
  307. <category><![CDATA[Personal]]></category>
  308. <guid isPermaLink="false">http://www.norm2782.com/?p=44</guid>
  309. <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!
  310. Did you know that&#8230;
  311. Every bit of PHP I know is self-taught
  312. My programming adventure started out with Visual Basic 3 back in 1993. I was just 8 years [...]]]></description>
  313. <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>
  314. <p>Did you know that&#8230;</p>
  315. <ul>
  316. <li>Every bit of PHP I know is self-taught</li>
  317. <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>
  318. <li>My left foot is actually a few millimeter bigger than my right foot.</li>
  319. <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>
  320. <li>I bought my Harley Davidson before I even had my drivers license.</li>
  321. <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>
  322. <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>
  323. </ul>
  324. <p>Now it&#8217;s my turn to start tagging!</p>
  325. <ul>
  326. <li><a href="http://www.leftontheweb.com/weblog">Stefan Koopmanschap</a> &#8211; For not being tagged yet and having said so on Twitter</li>
  327. <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>
  328. <li><a href="http://mirmodynamics.com/">Geoffrey Bachelet</a> &#8211; For the great party in Paris</li>
  329. <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>
  330. <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>
  331. <li><a href="http://www.builtfromsource.com/">Matthew Ratzloff</a> &#8211; For his great help on Zend_Paginator</li>
  332. <li>And one more here&#8230;</li>
  333. </ul>
  334. <p>As for the rules:</p>
  335. <ul>
  336. <li>Link your original tagger(s), and list these rules on your blog.</li>
  337. <li>Share seven facts about yourself in the post &#8211; some random, some wierd.</li>
  338. <li>Tag seven people at the end of your post by leaving their names and the links to their blogs.</li>
  339. <li>Let them know they&#8217;ve been tagged by leaving a comment on their blogs and/or Twitter.</li>
  340. </ul>
  341. ]]></content:encoded>
  342. <wfw:commentRss>http://www.norm2782.com/2009/01/seven-things-tagged-by-padraic/feed/</wfw:commentRss>
  343. <slash:comments>0</slash:comments>
  344. </item>
  345. <item>
  346. <title>AMF Server class for WordPress</title>
  347. <link>http://www.norm2782.com/2009/01/amf-server-class-for-wordpress/</link>
  348. <comments>http://www.norm2782.com/2009/01/amf-server-class-for-wordpress/#comments</comments>
  349. <pubDate>Fri, 02 Jan 2009 14:49:42 +0000</pubDate>
  350. <dc:creator>norm2782</dc:creator>
  351. <category><![CDATA[Flex]]></category>
  352. <category><![CDATA[PHP]]></category>
  353. <category><![CDATA[Zend Framework]]></category>
  354. <guid isPermaLink="false">http://www.norm2782.com/?p=27</guid>
  355. <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>
  356. <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>
  357. <p><span id="more-27"></span></p>
  358. <pre name="code" class="php:nogutter">
  359. &lt;?php
  360. /**
  361. * BSD LICENSE
  362. *
  363. * Copyright (c) 2009, norm2782
  364. * All rights reserved.
  365. *
  366. * Redistribution and use in source and binary forms, with or without
  367. * modification, are permitted provided that the following conditions are met:
  368. * * Redistributions of source code must retain the above copyright
  369. * notice, this list of conditions and the following disclaimer.
  370. * * Redistributions in binary form must reproduce the above copyright
  371. * notice, this list of conditions and the following disclaimer in the
  372. * documentation and/or other materials provided with the distribution.
  373. * * Neither the name of norm2782 nor the
  374. * names of its contributors may be used to endorse or promote products
  375. * derived from this software without specific prior written permission.
  376. *
  377. * THIS SOFTWARE IS PROVIDED BY norm2782 ''AS IS'' AND ANY
  378. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  379. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  380. * DISCLAIMED. IN NO EVENT SHALL norm2782 BE LIABLE FOR ANY
  381. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  382. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  383. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  384. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  385. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  386. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  387. */
  388. /**
  389. * Set production mode.
  390. * If set to false, exceptions will bubble through to the Flex frontend
  391. *
  392. * @var bool
  393. */
  394. $production = false;
  395. /**
  396. * Determine the absolute path of the AMF server
  397. *
  398. * @var string
  399. */
  400. define('ABSPATH', dirname(__FILE__) . '/');
  401. /**
  402. * One directory below docroot. Your config file and library dir should be here.
  403. *
  404. * @var string
  405. */
  406. define('SUBPATH', dirname(ABSPATH));
  407. /**
  408. * You should make sure Zend Framework is in your include path
  409. */
  410. set_include_path(
  411. implode(PATH_SEPARATOR, array(
  412. SUBPATH . '/library',
  413. get_include_path()
  414. ))
  415. );
  416. /**
  417. * Include the WordPress config file
  418. */
  419. $configFile = SUBPATH . '/wp-config.php';
  420. if (!file_exists($configFile)) {
  421. throw new Exception('WordPress config file was not found!');
  422. }
  423. require_once $configFile;
  424. /**
  425. * No need to config more stuff from this point on
  426. */
  427. /**
  428. * @see Zend_Amf_Server
  429. */
  430. require_once 'Zend/Amf/Server.php';
  431. /**
  432. * @see Zend_Db_Adapter_Pdo_Mysql
  433. */
  434. require_once 'Zend/Db/Adapter/Pdo/Mysql.php';
  435. /**
  436. * @see Zend_Paginator
  437. */
  438. require_once 'Zend/Paginator.php';
  439. /**
  440. * @see Zend_Paginator_Adapter_DbSelect
  441. */
  442. require_once 'Zend/Paginator/Adapter/DbSelect.php';
  443. /**
  444. * Simple class to expose wordpress data through AMF
  445. *
  446. * @author norm2782
  447. */
  448. class Wp_Amf_Gateway
  449. {
  450. /**
  451. * Database adapter
  452. *
  453. * @var Zend_Db_Adapter_Pdo_Mysql
  454. */
  455. private $_db = null;
  456. /**
  457. * WordPress table prefix
  458. *
  459. * @var string
  460. */
  461. private $_prefix = null;
  462. /**
  463. * Constructor
  464. *
  465. * @param array $dbConfig
  466. * @param string $prefix
  467. * @return void
  468. */
  469. public function __construct(array $dbConfig, $prefix)
  470. {
  471. $this-&gt;_db = new Zend_Db_Adapter_Pdo_Mysql($dbConfig);
  472. $this-&gt;_db-&gt;query('SET NAMES `utf8`');
  473. $this-&gt;_prefix = $prefix;
  474. }
  475. /**
  476. * Get paginated results for the provided query
  477. *
  478. * @param Zend_Db_Select $select
  479. * @param int $page
  480. * @param int $itemsPerPage
  481. * @return array
  482. */
  483. private function _getPaginated(Zend_Db_Select $select, $page, $itemsPerPage)
  484. {
  485. $paginator = new Zend_Paginator(
  486. new Zend_Paginator_Adapter_DbSelect($select)
  487. );
  488. $paginator-&gt;setCurrentPageNumber($page)
  489. -&gt;setItemCountPerPage($itemsPerPage);
  490. return array(
  491. 'info' =&gt; $paginator-&gt;getPages(),
  492. 'items' =&gt; $paginator-&gt;getCurrentItems()
  493. );
  494. }
  495. /**
  496. * Get the comments for the specified post ID
  497. *
  498. * @param int $postId
  499. * @param int $page
  500. * @param int $itemsPerPage
  501. * @return array
  502. */
  503. public function getCommentsForPost($postId, $page = 1, $itemsPerPage = 10)
  504. {
  505. $select = $this-&gt;_db-&gt;select()-&gt;from($this-&gt;_prefix . 'comments')
  506. -&gt;where('comment_post_ID = ?', $postId);
  507. return $this-&gt;_getPaginated($select, $page, $itemsPerPage);
  508. }
  509. /**
  510. * Get the meta data for the specified post ID
  511. *
  512. * @param $postId
  513. * @return unknown_type
  514. */
  515. public function getMetaForPost($postId)
  516. {
  517. $select = $this-&gt;_db-&gt;select()-&gt;from($this-&gt;_prefix . 'postmeta')
  518. -&gt;where('post_id = ?', $postId);
  519. return $this-&gt;_db-&gt;fetchAll($select);
  520. }
  521. /**
  522. * Get a post by specifying its ID
  523. *
  524. * @param int $postId
  525. * @return array
  526. */
  527. public function getPost($postId)
  528. {
  529. $select = $this-&gt;_db-&gt;select()-&gt;from($this-&gt;_prefix . 'posts')
  530. -&gt;where('ID = ?', $postId);
  531. return $this-&gt;_db-&gt;fetchOne($select);
  532. }
  533. /**
  534. * Get posts per page
  535. *
  536. * @param int $page
  537. * @param int $itemsPerPage
  538. * @return array
  539. */
  540. public function getPosts($page = 1, $itemsPerPage = 10)
  541. {
  542. $select = $this-&gt;_db-&gt;select()-&gt;from($this-&gt;_prefix . 'posts');
  543. return $this-&gt;_getPaginated($select, $page, $itemsPerPage);
  544. }
  545. }
  546. /**
  547. * Pass the values from wp-config.php to the Wp_Amf_Gateway class.
  548. */
  549. $gateway = new Wp_Amf_Gateway(
  550. array(
  551. 'host' =&gt; DB_HOST,
  552. 'username' =&gt; DB_USER,
  553. 'password' =&gt; DB_PASSWORD,
  554. 'dbname' =&gt; DB_NAME
  555. ),
  556. $table_prefix
  557. );
  558. $server = new Zend_Amf_Server();
  559. $server-&gt;setProduction($production)
  560. -&gt;setClass($gateway)
  561. -&gt;handle();
  562. </pre>
  563. ]]></content:encoded>
  564. <wfw:commentRss>http://www.norm2782.com/2009/01/amf-server-class-for-wordpress/feed/</wfw:commentRss>
  565. <slash:comments>0</slash:comments>
  566. </item>
  567. <item>
  568. <title>Flex frontend</title>
  569. <link>http://www.norm2782.com/2009/01/flex-frontend/</link>
  570. <comments>http://www.norm2782.com/2009/01/flex-frontend/#comments</comments>
  571. <pubDate>Thu, 01 Jan 2009 23:29:35 +0000</pubDate>
  572. <dc:creator>norm2782</dc:creator>
  573. <category><![CDATA[Flex]]></category>
  574. <category><![CDATA[PHP]]></category>
  575. <guid isPermaLink="false">http://www.norm2782.com/?p=22</guid>
  576. <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>
  577. <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>
  578. ]]></content:encoded>
  579. <wfw:commentRss>http://www.norm2782.com/2009/01/flex-frontend/feed/</wfw:commentRss>
  580. <slash:comments>0</slash:comments>
  581. </item>
  582. <item>
  583. <title>Properties in PHP</title>
  584. <link>http://www.norm2782.com/2009/01/properties-in-php/</link>
  585. <comments>http://www.norm2782.com/2009/01/properties-in-php/#comments</comments>
  586. <pubDate>Thu, 01 Jan 2009 23:02:54 +0000</pubDate>
  587. <dc:creator>norm2782</dc:creator>
  588. <category><![CDATA[Daydreaming]]></category>
  589. <category><![CDATA[PHP]]></category>
  590. <guid isPermaLink="false">http://www.norm2782.com/?p=8</guid>
  591. <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:
  592. &#60;?php
  593. class Bar
  594. {
  595. [...]]]></description>
  596. <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>
  597. <pre name="code" class="php:nogutter">
  598. &lt;?php
  599. class Bar
  600. {
  601. private $_foo = 'foo';
  602. public function get foo()
  603. {
  604. return $this->_foo;
  605. }
  606. public function set foo($fooString)
  607. {
  608. $this->_foo = $fooString;
  609. }
  610. }
  611. $bar = new Bar();
  612. $bar->foo = 'baz';
  613. echo $bar->foo; // prints baz
  614. </pre>
  615. ]]></content:encoded>
  616. <wfw:commentRss>http://www.norm2782.com/2009/01/properties-in-php/feed/</wfw:commentRss>
  617. <slash:comments>0</slash:comments>
  618. </item>
  619. </channel>
  620. </rss>