This repository has been archived by the owner on Jan 30, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 42
/
atom_rewrittenbydom.xml
701 lines (607 loc) · 37.6 KB
/
atom_rewrittenbydom.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0" xml:lang="en" xml:base="http://www.norm2782.com/wp-atom.php">
<title type="text">Norm 2782</title>
<subtitle type="text">Why are you here?</subtitle>
<updated>2009-03-07T08:03:50Z</updated>
<generator uri="http://wordpress.org/" version="2.8">WordPress</generator>
<link rel="alternate" type="text/html" href="http://www.norm2782.com"/>
<id>http://www.norm2782.com/feed/atom/</id>
<link rel="self" type="application/atom+xml" href="http://www.norm2782.com/feed/atom/"/>
<entry>
<author>
<name>norm2782</name>
<uri>http://www.norm2782.com</uri>
</author>
<title type="html"><![CDATA[Wth… reading books?]]></title>
<link rel="alternate" type="text/html" href="http://www.norm2782.com/2009/03/wth-reading-books/"/>
<id>http://www.norm2782.com/?p=114</id>
<updated>2009-03-07T08:03:50Z</updated>
<published>2009-03-02T08:09:33Z</published>
<category scheme="http://www.norm2782.com" term="New Zealand"/><category scheme="http://www.norm2782.com" term="Personal"/><category scheme="http://www.norm2782.com" term="Programming"/><category scheme="http://www.norm2782.com" term="Study"/> <summary type="html"><![CDATA[Being in New Zealand does strange things to a person. Everybody who knows me, knows I don’t much like that crazy invention called a Book. However, being here I’ve already finished 4 books, all of which I can highly recommend.
Agile Software Development with Scrum, by Ken Schwaber and Mike Beedle
Domain-Driven Design: Tackling Complexity in the [...]]]></summary>
<content type="html" xml:base="http://www.norm2782.com/2009/03/wth-reading-books/"><![CDATA[<p>Being in New Zealand does strange things to a person. Everybody who knows me, knows I don’t much like that crazy invention called a Book. However, being here I’ve already finished 4 books, all of which I can highly recommend.</p>
<ul>
<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>
<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>
<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>
<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>
</ul>
<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>
]]></content>
<link rel="replies" type="text/html" href="http://www.norm2782.com/2009/03/wth-reading-books/#comments" thr:count="0"/>
<link rel="replies" type="application/atom+xml" href="http://www.norm2782.com/2009/03/wth-reading-books/feed/atom/" thr:count="0"/>
<thr:total>0</thr:total>
</entry>
<entry>
<author>
<name>norm2782</name>
<uri>http://www.norm2782.com</uri>
</author>
<title type="html"><![CDATA[My first few weeks in New Zealand]]></title>
<link rel="alternate" type="text/html" href="http://www.norm2782.com/2009/02/my-first-few-weeks-in-new-zealand/"/>
<id>http://www.norm2782.com/?p=105</id>
<updated>2009-02-18T03:30:07Z</updated>
<published>2009-02-15T03:29:21Z</published>
<category scheme="http://www.norm2782.com" term="New Zealand"/><category scheme="http://www.norm2782.com" term="Personal"/> <summary type="html"><![CDATA[It’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’m locked [...]]]></summary>
<content type="html" xml:base="http://www.norm2782.com/2009/02/my-first-few-weeks-in-new-zealand/"><![CDATA[<p>It’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’m locked away in an office most of my time.</p>
<p><span id="more-105"></span><br />
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’s excellent on-board service made my flight to SF a breeze.</p>
<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’t too bad. It was great to get out into the sun and to grab some decent food and coffee. Didn’t get to see much of SF though, which was too bad.</p>
<p><img src="http://farm4.static.flickr.com/3403/3232983613_637af46bc3.jpg?v=0" alt="SF Airport" /></p>
<p>The flight to Auckland wasn’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… I barely made it in time!</p>
<p><img src="http://farm4.static.flickr.com/3109/3233835892_ec0b4d26f8.jpg?v=0" alt="Flying to Dunedin" /></p>
<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’s where I’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>
<p><img src="http://farm4.static.flickr.com/3201/3280470572_fceb6c64c8.jpg?v=0" alt="My Room" /></p>
<p>Abbey is a great place to stay by the way. It’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’s got it all!</p>
<p><img src="http://farm4.static.flickr.com/3227/3279648921_d8efbd51e3.jpg?v=0" alt="View from my room" /></p>
<p>So what am I doing here in NZ? We’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’ll be working on a great and exciting cutting-edge open-source project. Unfortunately I can’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>
<p><img src="http://farm4.static.flickr.com/3432/3239911680_bd2f368457.jpg?v=0" alt="My Desk" /></p>
<p>Seeing as I don’t have internet-access at Abbey College yet, I’ve got lots of time for other activities. I’ve finished reading the better part of my <a href="http://domaindrivendesign.org/books/#DDD">Domain Driven Design book</a> and I’ve ordered Martin Fowler’s <a href="http://martinfowler.com/books.html#eaa">Patterns Of Enterprise Application Architecture</a>, which should arrive this week. I’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… 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… six months in NZ is not going to be enough time!</p>
<p><img src="http://farm4.static.flickr.com/3408/3279649371_521a113552.jpg?v=0" alt="Me!" /></p>
<p>Well, that’s my first NZ blog-post. There will definitely be more of these! Let’s hope they fix my internet soon… See <a href="http://www.flickr.com/photos/34800767@N05/">my Flickr photo-stream</a> for more pictures.</p>
]]></content>
<link rel="replies" type="text/html" href="http://www.norm2782.com/2009/02/my-first-few-weeks-in-new-zealand/#comments" thr:count="0"/>
<link rel="replies" type="application/atom+xml" href="http://www.norm2782.com/2009/02/my-first-few-weeks-in-new-zealand/feed/atom/" thr:count="0"/>
<thr:total>0</thr:total>
</entry>
<entry>
<author>
<name>norm2782</name>
<uri>http://www.norm2782.com</uri>
</author>
<title type="html"><![CDATA[Properties in PHP – revisited]]></title>
<link rel="alternate" type="text/html" href="http://www.norm2782.com/2009/01/properties-in-php-revisited/"/>
<id>http://www.norm2782.com/?p=94</id>
<updated>2009-01-14T10:47:25Z</updated>
<published>2009-01-14T10:47:25Z</published>
<category scheme="http://www.norm2782.com" term="PHP"/><category scheme="http://www.norm2782.com" term="Proof-of-concepts"/> <summary type="html"><![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.
So what’s the big deal about those properties? In short, they make a developers [...]]]></summary>
<content type="html" xml:base="http://www.norm2782.com/2009/01/properties-in-php-revisited/"><![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>
<p>So what’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… less code is better! In this post we’ll see that it’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…</p>
<p><span id="more-94"></span><br />
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’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>
<pre name="code" class="php:nogutter">
<?php
class Person
{
public $age;
public $name;
}
</pre>
<p>This look easy enough, and it is. It even works like a charm and it’s possibly the fastest implementation for the Person class.</p>
<p>But, pesky as they are, the client suddenly wants some logic added to our Person class! A Person suddenly can’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>
<pre name="code" class="php:nogutter">
<?php
class Person
{
private $_age = null;
public $name = null;
public function getAge()
{
return $this->_age;
}
public function setAge($age)
{
if ($age < 21) {
throw new Exception('You need to be at least 21 years or older!');
}
$this->_age = $age;
}
}
</pre>
<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’t have to do so afterwards. Even though this works fine, it’s in violation of our mission to write no more code than we actually need at the moment of writing.</p>
<p>The solution? Properties! But wait… PHP doesn’t support those, remember? Luckily we still have magic methods. It’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’re first writing our code:</p>
<pre name="code" class="php:nogutter">
<?php
abstract class ModelAbstract
{
public function __get($key)
{
$method = 'get' . ucfirst($key);
if (!method_exists($this, $method)) {
throw new Exception('No property found for ' . $key);
}
return $this->$method();
}
public function __set($key, $value)
{
$method = 'set' . ucfirst($key);
if (!method_exists($this, $method)) {
throw new Exception('No property found for ' . $key);
}
$this->$method($value);
}
}
</pre>
<p>We’ll take a look at what this does exactly later. The important thing to note is that we can now do the following:</p>
<pre name="code" class="php:nogutter">
<?php
class Person extends ModelAbstract
{
private $_age = null;
public $name = null;
public function getAge()
{
return $this->_age;
}
public function setAge($age)
{
if ($age < 21) {
throw new Exception('You need to be at least 21 years or older!');
}
$this->_age = $age;
}
}
$person = new Person();
try {
$person->age = 10;
} catch (Exception $e) {
// Will print "You need to be at least 21 years or older!"
echo $e->getMessage();
}
</pre>
<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 – aside from the minor speed impact – is the fact that you have to subclass ModelAbstract to make this work. Luckily it’s not a lot of code, so should there be a big need to get rid of the ModelAbstract inheritance it’s not a big disaster to do some copy/paste work.</p>
<p>This method works by assuming you have get- and set methods that have the same name as the property you’re trying to access. When there’s a public attribute, it will use that. If there’s no public attribute, it will fall back to __get or __set and the logic will take it from there.</p>
<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’m curious to see how practical this solution would be in a real-life situation.</p>
]]></content>
<link rel="replies" type="text/html" href="http://www.norm2782.com/2009/01/properties-in-php-revisited/#comments" thr:count="0"/>
<link rel="replies" type="application/atom+xml" href="http://www.norm2782.com/2009/01/properties-in-php-revisited/feed/atom/" thr:count="0"/>
<thr:total>0</thr:total>
</entry>
<entry>
<author>
<name>norm2782</name>
<uri>http://www.norm2782.com</uri>
</author>
<title type="html"><![CDATA[Filters for Zend_Paginator]]></title>
<link rel="alternate" type="text/html" href="http://www.norm2782.com/2009/01/filters-for-zend_paginator/"/>
<id>http://www.norm2782.com/?p=72</id>
<updated>2009-01-14T08:23:19Z</updated>
<published>2009-01-13T12:57:53Z</published>
<category scheme="http://www.norm2782.com" term="PHP"/><category scheme="http://www.norm2782.com" term="Zend Framework"/> <summary type="html"><![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.
So [...]]]></summary>
<content type="html" xml:base="http://www.norm2782.com/2009/01/filters-for-zend_paginator/"><![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>
<p><span id="more-72"></span><br />
So why would you want to apply filters to your result set? Usually my domain models don’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>
<p>Lets have a look at an example. In this example I want to list all my users from the database. I’ll grab the name of the user from the row and inject it into a User object.</p>
<pre name="code" class="php:nogutter">
<?php
class User
{
private $_name = '';
public function getName()
{
return $this->_name;
}
public function setName($name)
{
$this->_name = $name;
}
}
class UserFilter implements Zend_Filter_Interface
{
public function filter($rows)
{
$users = array();
foreach ($rows as $row) {
$user = new User();
$user->setName($row->name);
$users[] = $user;
}
return $rows;
}
}
class MyModel
{
public static function getUserPaginator()
{
$userTable = new UserTable();
$paginator = Zend_Paginator::factory($userTable->select());
$paginator->setFilter(new UserFilter());
return $paginator;
}
}
$paginator = MyModel::getUserPaginator();
$items = $paginator->getCurrentItems();
foreach ($items as $user) {
echo 'Current name: ' . $user->getName() . '<br />' . PHP_EOL;
}
</pre>
<p>To simplify adding a simple filter to your paginator I’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>
<pre name="code" class="php:nogutter">
<?php
class MyModel
{
public static function getUserPaginator()
{
$userTable = new UserTable();
$paginator = Zend_Paginator::factory($userTable->select());
$paginator->setFilter(new Zend_Filter_Callback(
array('MyModel', 'filter'))
);
return $paginator;
}
public static function filter($rows)
{
$users = array();
foreach ($rows as $row) {
$user = new User();
$user->setName($row->name);
$users[] = $user;
}
return $rows;
}
}
</pre>
<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>
<p>Enjoy!</p>
]]></content>
<link rel="replies" type="text/html" href="http://www.norm2782.com/2009/01/filters-for-zend_paginator/#comments" thr:count="0"/>
<link rel="replies" type="application/atom+xml" href="http://www.norm2782.com/2009/01/filters-for-zend_paginator/feed/atom/" thr:count="0"/>
<thr:total>0</thr:total>
</entry>
<entry>
<author>
<name>norm2782</name>
<uri>http://www.norm2782.com</uri>
</author>
<title type="html"><![CDATA[ZF-3239]]></title>
<link rel="alternate" type="text/html" href="http://www.norm2782.com/2009/01/zf-3239/"/>
<id>http://www.norm2782.com/?p=68</id>
<updated>2009-01-11T09:53:20Z</updated>
<published>2009-01-07T11:48:31Z</published>
<category scheme="http://www.norm2782.com" term="PHP"/><category scheme="http://www.norm2782.com" term="Zend Framework"/> <summary type="html"><![CDATA[Zend_Db_Table_Select users, rejoice! I’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 “No table has been specified for the FROM clause” exceptions.
]]></summary>
<content type="html" xml:base="http://www.norm2782.com/2009/01/zf-3239/"><![CDATA[<p>Zend_Db_Table_Select users, rejoice! I’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 “No table has been specified for the FROM clause” exceptions.</p>
]]></content>
<link rel="replies" type="text/html" href="http://www.norm2782.com/2009/01/zf-3239/#comments" thr:count="0"/>
<link rel="replies" type="application/atom+xml" href="http://www.norm2782.com/2009/01/zf-3239/feed/atom/" thr:count="0"/>
<thr:total>0</thr:total>
</entry>
<entry>
<author>
<name>norm2782</name>
<uri>http://www.norm2782.com</uri>
</author>
<title type="html"><![CDATA[New in-ear earphones]]></title>
<link rel="alternate" type="text/html" href="http://www.norm2782.com/2009/01/new-in-ear-earphones/"/>
<id>http://www.norm2782.com/?p=53</id>
<updated>2009-01-03T18:51:43Z</updated>
<published>2009-01-03T15:49:19Z</published>
<category scheme="http://www.norm2782.com" term="Personal"/> <summary type="html"><![CDATA[Just got myself the Sennheiser CX 300 II Precision in-ear earphones. Check ‘em out by clicking the read more link!
]]></summary>
<content type="html" xml:base="http://www.norm2782.com/2009/01/new-in-ear-earphones/"><![CDATA[<p>Just got myself the Sennheiser CX 300 II Precision in-ear earphones. Check ‘em out by clicking the read more link!</p>
<p><span id="more-53"></span><br />
<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>
]]></content>
<link rel="replies" type="text/html" href="http://www.norm2782.com/2009/01/new-in-ear-earphones/#comments" thr:count="0"/>
<link rel="replies" type="application/atom+xml" href="http://www.norm2782.com/2009/01/new-in-ear-earphones/feed/atom/" thr:count="0"/>
<thr:total>0</thr:total>
</entry>
<entry>
<author>
<name>norm2782</name>
<uri>http://www.norm2782.com</uri>
</author>
<title type="html"><![CDATA[Seven Things – Tagged by Pádraic]]></title>
<link rel="alternate" type="text/html" href="http://www.norm2782.com/2009/01/seven-things-tagged-by-padraic/"/>
<id>http://www.norm2782.com/?p=44</id>
<updated>2009-01-03T11:47:19Z</updated>
<published>2009-01-03T10:14:38Z</published>
<category scheme="http://www.norm2782.com" term="Personal"/> <summary type="html"><![CDATA[Well, this was bound to happen: I got tagged by Pádraic because I’m working on Zend_Feed_Reader with him. Luckily I’ve just setup this new blog, so here we go!
Did you know that…
Every bit of PHP I know is self-taught
My programming adventure started out with Visual Basic 3 back in 1993. I was just 8 years [...]]]></summary>
<content type="html" xml:base="http://www.norm2782.com/2009/01/seven-things-tagged-by-padraic/"><![CDATA[<p>Well, this was bound to happen: I got tagged by <a href="http://blog.astrumfutura.com/">Pádraic</a> because I’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’ve just setup this new blog, so here we go!</p>
<p>Did you know that…</p>
<ul>
<li>Every bit of PHP I know is self-taught</li>
<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>
<li>My left foot is actually a few millimeter bigger than my right foot.</li>
<li>I used to have long hair (almost reached my ass). I cut it off in the summer of ‘08 for various reasons, one of which was 100 euro.</li>
<li>I bought my Harley Davidson before I even had my drivers license.</li>
<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>
<li>While I use a Mac, with an Apple Cinema Display and an Apple keyboard… I have an HTC Touch with Windows Mobile and I’m stuck with it for at least a few more months.</li>
</ul>
<p>Now it’s my turn to start tagging!</p>
<ul>
<li><a href="http://www.leftontheweb.com/weblog">Stefan Koopmanschap</a> – For not being tagged yet and having said so on Twitter</li>
<li><a href="http://naneau.nl/">Maurice Fonk</a> – For being my co-worker and for not having finished <a href="http://madoqua.org/">Madoqua</a> yet</li>
<li><a href="http://mirmodynamics.com/">Geoffrey Bachelet</a> – For the great party in Paris</li>
<li><a href="http://wadearnold.com/blog/">Wade Arnold</a> – For doing a great job on Zend_AMF and having the same WordPress theme as me.</li>
<li><a href="http://www.missyeh.nl/blog/">Kana Yeh</a> – For being the coolest PHP girl in the Netherlands (that I know of)</li>
<li><a href="http://www.builtfromsource.com/">Matthew Ratzloff</a> – For his great help on Zend_Paginator</li>
<li>And one more here…</li>
</ul>
<p>As for the rules:</p>
<ul>
<li>Link your original tagger(s), and list these rules on your blog.</li>
<li>Share seven facts about yourself in the post – some random, some wierd.</li>
<li>Tag seven people at the end of your post by leaving their names and the links to their blogs.</li>
<li>Let them know they’ve been tagged by leaving a comment on their blogs and/or Twitter.</li>
</ul>
]]></content>
<link rel="replies" type="text/html" href="http://www.norm2782.com/2009/01/seven-things-tagged-by-padraic/#comments" thr:count="0"/>
<link rel="replies" type="application/atom+xml" href="http://www.norm2782.com/2009/01/seven-things-tagged-by-padraic/feed/atom/" thr:count="0"/>
<thr:total>0</thr:total>
</entry>
<entry>
<author>
<name>norm2782</name>
<uri>http://www.norm2782.com</uri>
</author>
<title type="html"><![CDATA[AMF Server class for WordPress]]></title>
<link rel="alternate" type="text/html" href="http://www.norm2782.com/2009/01/amf-server-class-for-wordpress/"/>
<id>http://www.norm2782.com/?p=27</id>
<updated>2009-01-06T15:00:54Z</updated>
<published>2009-01-02T14:49:42Z</published>
<category scheme="http://www.norm2782.com" term="Flex"/><category scheme="http://www.norm2782.com" term="PHP"/><category scheme="http://www.norm2782.com" term="Zend Framework"/> <summary type="html"><![CDATA[After browsing through WordPress’ code I quickly found that there’s no sane way to create AMF support as a WP plugin. At least not for someone who hasn’t done any old-skool procedural PHP in years. Instead of writing a plugin, I decided to write a standalone server script. It’s still very basic and currently setup [...]]]></summary>
<content type="html" xml:base="http://www.norm2782.com/2009/01/amf-server-class-for-wordpress/"><![CDATA[<p>After browsing through WordPress’ code I quickly found that there’s no sane way to create AMF support as a WP plugin. At least not for someone who hasn’t done any old-skool procedural PHP in years. Instead of writing a plugin, I decided to write a standalone server script. It’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’ve released it under the generous BSD license, so knock yourself out! Use it at your own risk… I’m not going to support it. Any updates will be posted in this post. Also, please note that I haven’t tested it yet. If you access the script directly it should output “Zend Amf Endpoint” just fine, but that’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>
<p><span id="more-27"></span></p>
<pre name="code" class="php:nogutter">
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Feed
*/
/**
* Set production mode.
* If set to false, exceptions will bubble through to the Flex frontend
*
* @var bool
*/
$production = false;
/**
* Determine the absolute path of the AMF server
*
* @var string
*/
define('ABSPATH', dirname(__FILE__) . '/');
/**
* One directory below docroot. Your config file and library dir should be here.
*
* @var string
*/
define('SUBPATH', dirname(ABSPATH));
/**
* You should make sure Zend Framework is in your include path
*/
set_include_path(
implode(PATH_SEPARATOR, array(
SUBPATH . '/library',
get_include_path()
))
);
/**
* Include the WordPress config file
*/
$configFile = SUBPATH . '/wp-config.php';
if (!file_exists($configFile)) {
throw new Exception('WordPress config file was not found!');
}
require_once $configFile;
/**
* No need to config more stuff from this point on
*/
/**
* @see Zend_Amf_Server
*/
require_once 'Zend/Amf/Server.php';
/**
* @see Zend_Db_Adapter_Pdo_Mysql
*/
require_once 'Zend/Db/Adapter/Pdo/Mysql.php';
/**
* @see Zend_Paginator
*/
require_once 'Zend/Paginator.php';
/**
* @see Zend_Paginator_Adapter_DbSelect
*/
require_once 'Zend/Paginator/Adapter/DbSelect.php';
/**
* Simple class to expose wordpress data through AMF
*
* @author norm2782
*/
class Wp_Amf_Gateway
{
/**
* Database adapter
*
* @var Zend_Db_Adapter_Pdo_Mysql
*/
private $_db = null;
/**
* WordPress table prefix
*
* @var string
*/
private $_prefix = null;
/**
* Constructor
*
* @param array $dbConfig
* @param string $prefix
*/
public function __construct(array $dbConfig, $prefix)
{
$this->_db = new Zend_Db_Adapter_Pdo_Mysql($dbConfig);
$this->_db->query('SET NAMES `utf8`');
$this->_prefix = $prefix;
}
/**
* Get paginated results for the provided query
*
* @param Zend_Db_Select $select
* @param int $page
* @param int $itemsPerPage
* @return array
*/
private function _getPaginated(Zend_Db_Select $select, $page, $itemsPerPage)
{
$paginator = new Zend_Paginator(
new Zend_Paginator_Adapter_DbSelect($select)
);
$paginator->setCurrentPageNumber($page)
->setItemCountPerPage($itemsPerPage);
return array(
'info' => $paginator->getPages(),
'items' => $paginator->getCurrentItems()
);
}
/**
* Get the comments for the specified post ID
*
* @param int $postId
* @param int $page
* @param int $itemsPerPage
* @return array
*/
public function getCommentsForPost($postId, $page = 1, $itemsPerPage = 10)
{
$select = $this->_db->select()->from($this->_prefix . 'comments')
->where('comment_post_ID = ?', $postId);
return $this->_getPaginated($select, $page, $itemsPerPage);
}
/**
* Get the meta data for the specified post ID
*
* @param $postId
* @return unknown_type
*/
public function getMetaForPost($postId)
{
$select = $this->_db->select()->from($this->_prefix . 'postmeta')
->where('post_id = ?', $postId);
return $this->_db->fetchAll($select);
}
/**
* Get a post by specifying its ID
*
* @param int $postId
* @return array
*/
public function getPost($postId)
{
$select = $this->_db->select()->from($this->_prefix . 'posts')
->where('ID = ?', $postId);
return $this->_db->fetchOne($select);
}
/**
* Get posts per page
*
* @param int $page
* @param int $itemsPerPage
* @return array
*/
public function getPosts($page = 1, $itemsPerPage = 10)
{
$select = $this->_db->select()->from($this->_prefix . 'posts');
return $this->_getPaginated($select, $page, $itemsPerPage);
}
}
/**
* Pass the values from wp-config.php to the Wp_Amf_Gateway class.
*/
$gateway = new Wp_Amf_Gateway(
array(
'host' => DB_HOST,
'username' => DB_USER,
'password' => DB_PASSWORD,
'dbname' => DB_NAME
),
$table_prefix
);
$server = new Zend_Amf_Server();
$server->setProduction($production)
->setClass($gateway)
->handle();
</pre>
]]></content>
<link rel="replies" type="text/html" href="http://www.norm2782.com/2009/01/amf-server-class-for-wordpress/#comments" thr:count="0"/>
<link rel="replies" type="application/atom+xml" href="http://www.norm2782.com/2009/01/amf-server-class-for-wordpress/feed/atom/" thr:count="0"/>
<thr:total>0</thr:total>
</entry>
<entry>
<author>
<name>norm2782</name>
<uri>http://www.norm2782.com</uri>
</author>
<title type="html"><![CDATA[Flex frontend]]></title>
<link rel="alternate" type="text/html" href="http://www.norm2782.com/2009/01/flex-frontend/"/>
<id>http://www.norm2782.com/?p=22</id>
<updated>2009-01-02T09:27:20Z</updated>
<published>2009-01-01T23:29:35Z</published>
<category scheme="http://www.norm2782.com" term="Flex"/><category scheme="http://www.norm2782.com" term="PHP"/> <summary type="html"><![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’ll have a look and see if I can create a Zend_AMF plugin for WordPress that allows me to retrieve virtually [...]]]></summary>
<content type="html" xml:base="http://www.norm2782.com/2009/01/flex-frontend/"><![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’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>
]]></content>
<link rel="replies" type="text/html" href="http://www.norm2782.com/2009/01/flex-frontend/#comments" thr:count="0"/>
<link rel="replies" type="application/atom+xml" href="http://www.norm2782.com/2009/01/flex-frontend/feed/atom/" thr:count="0"/>
<thr:total>0</thr:total>
</entry>
<entry>
<author>
<name>norm2782</name>
<uri>http://www.norm2782.com</uri>
</author>
<title type="html"><![CDATA[Properties in PHP]]></title>
<link rel="alternate" type="text/html" href="http://www.norm2782.com/2009/01/properties-in-php/"/>
<id>http://www.norm2782.com/?p=8</id>
<updated>2009-01-02T15:13:15Z</updated>
<published>2009-01-01T23:02:54Z</published>
<category scheme="http://www.norm2782.com" term="Daydreaming"/><category scheme="http://www.norm2782.com" term="PHP"/> <summary type="html"><![CDATA[A while ago Dynom from #php_bnl pointed me to an interesting entry on the PHP 5.3 wiki page. In the “Future PHP releases” sections there’s an entry called “29. “real” properties with attached getters and setters”. Personally I can’t wait for this. Hopefully it will look something like ActionScript 3’s properties:
<?php
class Bar
{
[...]]]></summary>
<content type="html" xml:base="http://www.norm2782.com/2009/01/properties-in-php/"><![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 “Future PHP releases” sections there’s an entry called “29. “real” properties with attached getters and setters”. Personally I can’t wait for this. Hopefully it will look something like ActionScript 3’s properties:</p>
<pre name="code" class="php:nogutter">
<?php
class Bar
{
private $_foo = 'foo';
public function get foo()
{
return $this->_foo;
}
public function set foo($fooString)
{
$this->_foo = $fooString;
}
}
$bar = new Bar();
$bar->foo = 'baz';
echo $bar->foo; // prints baz
</pre>
]]></content>
<link rel="replies" type="text/html" href="http://www.norm2782.com/2009/01/properties-in-php/#comments" thr:count="0"/>
<link rel="replies" type="application/atom+xml" href="http://www.norm2782.com/2009/01/properties-in-php/feed/atom/" thr:count="0"/>
<thr:total>0</thr:total>
</entry>
</feed>