Took me about 3 or 4 hours in total. Time which otherwise would have been spent not doing anything nearly as productive. It will allow sites to far more easily control the elements that go into the site template. Previously it was all a bit messy essentially, it was a class which initialised a template, accessed datamappers directly and passed values to the template. Messy and non-=eusable code. Admittedly, in most cases not an issue but for those edge cases, especially where the template is not the same every time, it was always a bit hacky getting everything working as it should.
Aha! What is causing you difficulty understanding them? Conventions or the lack? Poor APIs? Surprises?
This is the stuff I’m after. Can you post some snippets of stuff that has caused you some head scratching?
All of the above 
Thought I’d post something quite basic. Here’s a login script: http://pastebin.com/SWnRj5Vj
-Non-descriptive variable names
-Horrible template engine requiring lots of binding logic
-developer kills me every time by renaming arbitrary variables during bindings $_SESSION[‘user_id’] = $s_rec[‘cid’]; In another script he actually does this: $t_values[‘_email’] = $s_rec[‘email’]; for about 20 fields… mostly just adding an _ but arbitrarily renaming enough fields to make it so I cant replace the whole block with a function that automatically prefixes an underscore to all the array keys.
-the if-else nesting is annoying to follow. In the shopping basket page ther are eight levels of nesting and nothing is broken up into functions.
Guess when this code was written… go on… guess. I’ll tell you: 2008. It was written by a freelance developer the company hired about 6 months before I started here.
Of course, this is just a classic example of spaghetti procedural code.
Guess what directory that’s in? /uplds/php/login.php
The login.php which is actually accessed by the browser looks like this:
<?
include 'config/config.php';
include 'config/include.php';
$page_name = basename($_SERVER['PHP_SELF']);
if(isset($_GET)){
$gtp = $_GET['gtp'];
$_SESSION['cfp'] = $_GET['cfp'];
header('Location: ' . $gtp);
} else {
header('Location: index.php');
}
?>
That’s it! The entire thing. There is a page like this, which does nothing for everything.
For every php page there is a file which looks like:
include 'config/config.php';
include 'config/include.php';
$page_name = basename($_SERVER['PHP_SELF']);
include 'inc/std_page_prep.php';
echo $page->output;
It’s identical. Exactly this, in 50+ files.
Heh, that’s just one I’ll post about a slightly better one later.
edit: i just came across this gem and had to post it:
mysql_query (sprintf ("INSERT INTO drivers
SET firstName='%s', lastName='%s', nationality='%s', dateOfBirth='%s', birthplace='%s',
residence='%s', profession='%s', maritalStatus='%s', hobbies='%s', favouriteTrack='%s',
website='%s', sponsorText1=%s, sponsorLink1=%s, sponsorText2=%s, sponsorLink2=%s,
sponsorText3=%s, sponsorLink3=%s, sponsorText4=%s, sponsorLink4=%s, sponsorText5=%s,
sponsorLink5=%s",
htmlentities (addslashes ($this->data->fields->firstName->value)),
htmlentities (addslashes ($this->data->fields->lastName->value)),
htmlentities (addslashes ($this->data->fields->nationality->value)),
$this->data->fields->dateOfBirth->value,
htmlentities (addslashes ($this->data->fields->birthplace->value)),
htmlentities (addslashes ($this->data->fields->residence->value)),
htmlentities (addslashes ($this->data->fields->profession->value)),
htmlentities (addslashes ($this->data->fields->maritalStatus->value)),
htmlentities (addslashes ($this->data->fields->hobbies->value)),
htmlentities (addslashes ($this->data->fields->favouriteTrack->value)),
htmlentities (addslashes ($this->data->fields->website->value)),
(strlen($this->data->fields->sponsorText1->value) ? sprintf("'%s'",htmlentities (addslashes ($this->data->fields->sponsorText1->value))) : 'NULL'),
(strlen($this->data->fields->sponsorLink1->value) ? sprintf("'%s'",addslashes ($this->data->fields->sponsorLink1->value)) : 'NULL'),
(strlen($this->data->fields->sponsorText2->value) ? sprintf("'%s'",htmlentities (addslashes ($this->data->fields->sponsorText2->value))) : 'NULL'),
(strlen($this->data->fields->sponsorLink2->value) ? sprintf("'%s'",addslashes ($this->data->fields->sponsorLink2->value)) : 'NULL'),
(strlen($this->data->fields->sponsorText3->value) ? sprintf("'%s'",htmlentities (addslashes ($this->data->fields->sponsorText3->value))) : 'NULL'),
(strlen($this->data->fields->sponsorLink3->value) ? sprintf("'%s'",addslashes ($this->data->fields->sponsorLink3->value)) : 'NULL'),
(strlen($this->data->fields->sponsorText4->value) ? sprintf("'%s'",htmlentities (addslashes ($this->data->fields->sponsorText4->value))) : 'NULL'),
(strlen($this->data->fields->sponsorLink4->value) ? sprintf("'%s'",addslashes ($this->data->fields->sponsorLink4->value)) : 'NULL'),
(strlen($this->data->fields->sponsorText5->value) ? sprintf("'%s'",htmlentities (addslashes ($this->data->fields->sponsorText5->value))) : 'NULL'),
(strlen($this->data->fields->sponsorLink5->value) ? sprintf("'%s'",addslashes ($this->data->fields->sponsorLink5->value)) : 'NULL')));
of course later in the page he does this:
mysql_query (sprintf ("UPDATE drivers
SET firstName='%s', lastName='%s', nationality='%s', dateOfBirth='%s', birthplace='%s',
residence='%s', profession='%s', maritalStatus='%s', hobbies='%s', favouriteTrack='%s',
website='%s', sponsorText1=%s, sponsorLink1=%s, sponsorText2=%s, sponsorLink2=%s,
sponsorText3=%s, sponsorLink3=%s, sponsorText4=%s, sponsorLink4=%s,
sponsorText5=%s, sponsorLink5=%s
WHERE id=%s",
htmlentities (addslashes ($this->data->fields->firstName->value)),
htmlentities (addslashes ($this->data->fields->lastName->value)),
htmlentities (addslashes ($this->data->fields->nationality->value)),
$this->data->fields->dateOfBirth->value,
htmlentities (addslashes ($this->data->fields->birthplace->value)),
htmlentities (addslashes ($this->data->fields->residence->value)),
htmlentities (addslashes ($this->data->fields->profession->value)),
htmlentities (addslashes ($this->data->fields->maritalStatus->value)),
htmlentities (addslashes ($this->data->fields->hobbies->value)),
htmlentities (addslashes ($this->data->fields->favouriteTrack->value)),
htmlentities (addslashes ($this->data->fields->website->value)),
(strlen($this->data->fields->sponsorText1->value) ? sprintf("'%s'",htmlentities (addslashes ($this->data->fields->sponsorText1->value))) : 'NULL'),
(strlen($this->data->fields->sponsorLink1->value) ? sprintf("'%s'",addslashes ($this->data->fields->sponsorLink1->value)) : 'NULL'),
(strlen($this->data->fields->sponsorText2->value) ? sprintf("'%s'",htmlentities (addslashes ($this->data->fields->sponsorText2->value))) : 'NULL'),
(strlen($this->data->fields->sponsorLink2->value) ? sprintf("'%s'",addslashes ($this->data->fields->sponsorLink2->value)) : 'NULL'),
(strlen($this->data->fields->sponsorText3->value) ? sprintf("'%s'",htmlentities (addslashes ($this->data->fields->sponsorText3->value))) : 'NULL'),
(strlen($this->data->fields->sponsorLink3->value) ? sprintf("'%s'",addslashes ($this->data->fields->sponsorLink3->value)) : 'NULL'),
(strlen($this->data->fields->sponsorText4->value) ? sprintf("'%s'",htmlentities (addslashes ($this->data->fields->sponsorText4->value))) : 'NULL'),
(strlen($this->data->fields->sponsorLink4->value) ? sprintf("'%s'",addslashes ($this->data->fields->sponsorLink4->value)) : 'NULL'),
(strlen($this->data->fields->sponsorText5->value) ? sprintf("'%s'",htmlentities (addslashes ($this->data->fields->sponsorText5->value))) : 'NULL'),
(strlen($this->data->fields->sponsorLink5->value) ? sprintf("'%s'",addslashes ($this->data->fields->sponsorLink5->value)) : 'NULL'),
$this->data->fields->id->value));
ahhh the code i have to work with.