<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Flipflops.org - Web Development and bit of Art</title>
	<atom:link href="http://www.flipflops.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.flipflops.org</link>
	<description>Flipflops.org is about web development and fairly conceptual art</description>
	<lastBuildDate>Thu, 25 Feb 2010 14:19:47 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>MySQL DATE_FORMAT() AND PHP date() formats</title>
		<link>http://www.flipflops.org/2009/12/01/mysql-date_format-and-php-date-formats/</link>
		<comments>http://www.flipflops.org/2009/12/01/mysql-date_format-and-php-date-formats/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 20:21:11 +0000</pubDate>
		<dc:creator>Flipflops</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.flipflops.org/2009/12/01/mysql-date_format-and-php-date-formats/</guid>
		<description><![CDATA[I&#8217;m always finding myself looking up strings to format PHP and MySQL dates. A simple d/m/Y is pretty straight forward but sometimes things can get a bit fiddly. Where ever possible I try and leave my date formatting in the database, but I still find myself doing it in PHP all the time.
Here are a [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m always finding myself looking up strings to format PHP and MySQL dates. A simple d/m/Y is pretty straight forward but sometimes things can get a bit fiddly. Where ever possible I try and leave my date formatting in the database, but I still find myself doing it in PHP all the time.</p>
<p>Here are a few simple cut and paste date formats.</p>
<table class="exam_table mtable" >
<thead>
<tr>
<th scope="col">PHP Date</th>
<th scope="col">MySQL Date</th>
<th scope="col">PHP Format</th>
<th scope="col">MySQL Format</th>
<th scope="col">Notes</th>
</tr>
<thead>
<tbody>
<tr>
<td>7/9/2009</td>
<td>7/9/2009</td>
<td>j/n/Y</td>
<td>%e/%c/%Y</td>
<td></td>
</tr>
<tr>
<td>07/09/2009</td>
<td>07/09/2009</td>
<td>d/m/Y</td>
<td>%d/%m/%Y</td>
<td></td>
</tr>
<tr>
<td>7/9/2009 8:07</td>
<td>7/9/2009 8:07</td>
<td>j/n/Y G:i</td>
<td>%e/%c/%Y %k:%i</td>
<td></td>
</tr>
<tr>
<td>7/9/2009 8:07 AM</td>
<td>7/9/2009 8:07 AM</td>
<td>j/n/Y G:i A</td>
<td>%e/%c/%Y %k:%i %p</td>
<td></td>
</tr>
<tr>
<td>07/09/2009 8:07 AM</td>
<td>07/09/2009 8:07 AM</td>
<td>d/m/Y G:i A</td>
<td>%d/%m/%Y %k:%i %p</td>
<td></td>
</tr>
<tr>
<td>07/09/2009 08:07 AM</td>
<td>07/09/2009 08:07 AM</td>
<td>d/m/Y H:i A</td>
<td>%d/%m/%Y %H:%i %p</td>
<td></td>
</tr>
<tr>
<td>07/09/2009 8:07 am</td>
<td></td>
<td>d/m/Y G:i a</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Mon 7th Sep 2009</td>
<td>Mon 7th Sep 2009</td>
<td>D jS M Y</td>
<td>%a %D %b %Y</td>
<td></td>
</tr>
<tr>
<td>Monday 7th September 2009</td>
<td>Monday 7th September 2009</td>
<td>l jS F Y</td>
<td>%W %D %M %Y</td>
<td></td>
</tr>
<tr>
<td>2009-09-07T08:07:50+01:00</td>
<td>Monday 7th September 2009</td>
<td>Y-m-d\TH:i:sP</td>
<td>%W %D %M %Y</td>
<td>PHP DATE_ATOM constant</td>
</tr>
<tr>
<td>Mon, 07 Sep 2009 08:07:50 +0100</td>
<td>Mon, 07 Sep 2009 08:07:50</td>
<td>D, d M Y H:i:s O</td>
<td>%a, %d %b %Y %T</td>
<td>PHP DATE_RSS constant</td>
</tr>
</tbody>
</table>
<h2>The PHP way</h2>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #b1b100;">echo</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'d/m/Y'</span><span style="color: #339933;">,</span> <span style="color: #990000;">strtotime</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'2009-09-07 08:07:50'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//or</span>
&nbsp;
<span style="color: #000088;">$dateTime</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DateTime<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;now&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$dateTime</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">format</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Y-m-d H:i:s&quot;</span><span style="color: #009900;">&#41;</span></pre></div></div>

<h2>The MySQL way</h2>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;">&nbsp;
$sqlstring <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">&quot;SELECT DATE_FORMAT('2009-09-07 08:07:50', '%d/%m/%Y') AS formated_date FROM some_table&quot;</span> ;</pre></div></div>

<ul>
<li><a href="http://php.net/manual/en/function.date.php">http://php.net/manual/en/function.date.php</a></li>
<li><a href="http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date-format">http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date-format</a></li>
</ul>
<p>If you haven&#8217;t looked at the PHP manual closely for a while you should definitely (re)acquaint yourself with the <a href="http://www.php.net/manual/en/class.datetime.php#datetime.constants.types">DateTime Class</a>. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.flipflops.org/2009/12/01/mysql-date_format-and-php-date-formats/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>T-shirts</title>
		<link>http://www.flipflops.org/2009/12/01/t-shirts/</link>
		<comments>http://www.flipflops.org/2009/12/01/t-shirts/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 20:19:47 +0000</pubDate>
		<dc:creator>Flipflops</dc:creator>
				<category><![CDATA[Art]]></category>
		<category><![CDATA[T-shirts]]></category>

		<guid isPermaLink="false">http://www.flipflops.org/2009/12/01/t-shirts/</guid>
		<description><![CDATA[I&#8217;ve been designing a few T-shirts over the summer. Get yours now in time for Christmas before everybody gets one!

Spotty Dog T-shirt




Shiny Dog Organic T-shirt





Butterfly T-shirt



More T-Shirts
]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been designing a few T-shirts over the summer. Get yours now in time for Christmas before <em>everybody</em> gets one!</p>
<div>
<h2><a href="http://www.spreadshirt.net/en/GB/Spotty-Dog/Detail-4408/Marketplace/Products/detail/article/9804814/" target="_blank">Spotty Dog T-shirt</a></h2>
<p><a href="http://www.spreadshirt.net/en/GB/Spotty-Dog/Detail-4408/Marketplace/Products/detail/article/9804814/" target="_blank"><br />
<img src="http://image.spreadshirt.net/image-server/image/product/11030433/view/1/type/png/width/190/height/190" alt="Men's Classic T-Shirt - Men's T-Shirts Spotty Dog" title="Men's Classic T-Shirt - Men's T-Shirts Spotty Dog" style="width:190px; border:0px;"/></a><br/>
</div>
<div>
<h2><a href="http://www.spreadshirt.net/en/GB/Shiny-Dog/Detail-4408/Marketplace/Products/detail/article/9777185/" target="_blank">Shiny Dog Organic T-shirt</a></h2>
<p><a href="http://www.spreadshirt.net/en/GB/Shiny-Dog/Detail-4408/Marketplace/Products/detail/article/9777185/" target="_blank"><br />
<img src="http://image.spreadshirt.net/image-server/image/product/10997656/view/1/type/png/width/190/height/190" alt="Women's Slim Fit Earth Positive T-shirt - Organic Products Shiny Dog" title="Women's Slim Fit Earth Positive T-shirt - Organic Products Shiny Dog" style="width:190px; border:0px;"/></a><br/></p>
</div>
<div>
<h2>
<a href="http://www.spreadshirt.net/en/GB/Sand-beige-butterflies-Men-s-Tees/Detail-4408/Marketplace/Products/detail/article/9746104/" target="_blank">Butterfly T-shirt</a></h2>
<p><a href="http://www.spreadshirt.net/en/GB/Sand-beige-butterflies-Men-s-Tees/Detail-4408/Marketplace/Products/detail/article/9746104/" target="_blank"><br />
<img src="http://image.spreadshirt.net/image-server/image/product/10963184/view/1/type/png/width/190/height/190" alt="Men's Classic T-Shirt - Men's T-Shirts Sand beige butterflies Men's Tees" title="Men's Classic T-Shirt - Men's T-Shirts Sand beige butterflies Men's Tees" style="width:190px; border:0px;"/></a><br/></p>
</div>
<p><a href="http://flipflops.spreadshirt.co.uk/">More T-Shirts</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.flipflops.org/2009/12/01/t-shirts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lithium, Doctrine &amp; doing it yourself</title>
		<link>http://www.flipflops.org/2009/10/30/lithium-doctrine-doing-it-yourself/</link>
		<comments>http://www.flipflops.org/2009/10/30/lithium-doctrine-doing-it-yourself/#comments</comments>
		<pubDate>Fri, 30 Oct 2009 22:12:38 +0000</pubDate>
		<dc:creator>Flipflops</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.flipflops.org/2009/10/30/lithium-doctrine-doing-it-yourself/</guid>
		<description><![CDATA[If you use CakePHP you&#8217;ll probably be aware (or you&#8217;re dead or on holiday or something&#8230;) that Gwoo and Nate have left the project and gone elsewhere. Sort of. Well actually they have forked Cake3 into Lithium &#8211; souped up CakePHP for PHP 5.3
Unfortunately I&#8217;m not going to be using it in the immediate future [...]]]></description>
			<content:encoded><![CDATA[<p>If you use CakePHP you&#8217;ll probably be aware (or you&#8217;re dead or on holiday or something&#8230;) that Gwoo and Nate have left the project and gone elsewhere. Sort of. Well actually they have forked Cake3 into <a href="http://li3.rad-dev.org/">Lithium</a> &#8211; souped up CakePHP for PHP 5.3</p>
<p>Unfortunately I&#8217;m not going to be using it in the immediate future due to the 5.3 limitation, but I had a good look through the <a href="http://rad-dev.org/lithium_examples">blog example</a> and it looks like it would be a pleasure to work with.</p>
<p>Looking round the Lithium site I also came across <a href="http://www.doctrine-project.org/">Doctrine</a> &#8211; an object relational mapper (ORM) system. I spent an evening reading the documentation and decided it was perfect for a project I&#8217;m working on at work, unfortunately the next day I discovered we aren&#8217;t up to the required PHP version yet (almost, but not quite) so on the back burner for now.</p>
<p>I&#8217;m building a small application (about 8 tables) to be integrated into an existing CMS system. The structure of the CMS is essentially front controller based with a great template engine and well developed plugin / module system. The new module I&#8217;ve had to develop just didn&#8217;t fit well into the existing code structure and so I have ended up writing a Model / Controller system within my module that utilizes the things like the DB library, routing, security, templating etc. of the parent application.</p>
<p>The setup is pretty straight forward &#8211; a base model and base controller extended by respective models and controllers for each table. The child controllers and models are mostly pretty thin &#8211; mostly just setting class specific instance variables and the calling methods in the base classes with parent:: There isn&#8217;t any fancy ORM or anything like that in the models, just good old fashioned SQL, one query or closely related group of queries per method.</p>
<p>It took me about 1 1/2 days to write the framework and about another half day to write the templates (I&#8217;ve still got a load of reporting etc. to write) but now I&#8217;ve got the views for all the CRUD operations I will need and a lot of reusable code. Thinking about it, I would probably have done about a quarter of the work, in a far less maintainable way if I hadn&#8217;t taken this route. Goes to show that as long as your goals are well defined &#8211; this kind of approach far from being overkill has saved a huge amount of time and produced very understandable code &#8211; and you don&#8217;t need an entire framework to do it (with the added advantage that if you write stuff yourself, you hopefully have a better grasp of what is going on).</p>
<p>(I&#8217;ve still written a fair amount of Cake code this week <img src='http://www.flipflops.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> )</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flipflops.org/2009/10/30/lithium-doctrine-doing-it-yourself/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My first bit of Mootools and centering a Google Map in a hidden div</title>
		<link>http://www.flipflops.org/2009/10/26/my-first-bit-of-mootools-and-centering-a-google-map-in-a-hidden-div/</link>
		<comments>http://www.flipflops.org/2009/10/26/my-first-bit-of-mootools-and-centering-a-google-map-in-a-hidden-div/#comments</comments>
		<pubDate>Mon, 26 Oct 2009 22:56:10 +0000</pubDate>
		<dc:creator>Flipflops</dc:creator>
				<category><![CDATA[Google]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Mootools]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.flipflops.org/2009/10/26/my-first-bit-of-mootools-and-centering-a-google-map-in-a-hidden-div/</guid>
		<description><![CDATA[Started a new job last week for a really cool agency in a place I really want to work* &#8211; but they are Mootools users not jQuery folk, so I am been thrown headlong into (among other things) the world of Mootools. I&#8217;m used to just sitting down and being able to make things work [...]]]></description>
			<content:encoded><![CDATA[<p>Started a new job last week for a really cool agency in a place I really want to work* &#8211; but they are Mootools users not jQuery folk, so I am been thrown headlong into (among other things) the world of Mootools. I&#8217;m used to just sitting down and being able to make things work quickly and painlessly with jQuery and it is funny being back to basics again. Today I wrote my first useful bit of Mootools code, which in the grand scheme of things is nothing &#8211; just a nice fading toggle to show and hide a Google Map &#8211; but it still felt good.</p>
<p>Along the way I had to ran into a problem with my map &#8211; when I showed it the centre-ing was gone &#8211; I tried all sorts of things&#8230; map.checkResize() didn&#8217;t work and map.setCenter() didn&#8217;t work.</p>
<p>Eventually I deduced that first you actually need to call both functions &#8211; reset, then centre e.g.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">&nbsp;
    map.<span style="color: #660066;">checkResize</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    map.<span style="color: #660066;">setCenter</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">new</span> GLatLng<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">51.90568</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1.33214</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Along my way I have found a <a href="http://jqueryvsmootools.com/">great article comparing jQuery and Mootools</a> &#8211; which I would recommend to anyone going either way.</p>
<p>*But it is a kind of a personal philosophy not to ever say on my blog where I do work, just because. I&#8217;ve taken over a big project running on a Cloud server written by a load of other people, the sort of thing that is hard but very rewarding.<br />
** I have no idea where those coordinates are. Maybe Up North somewhere?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flipflops.org/2009/10/26/my-first-bit-of-mootools-and-centering-a-google-map-in-a-hidden-div/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>I feel stupid blogging about a vacuum cleaner but&#8230;</title>
		<link>http://www.flipflops.org/2009/10/11/i-feel-stupid-blogging-about-a-vacuum-cleaner-but/</link>
		<comments>http://www.flipflops.org/2009/10/11/i-feel-stupid-blogging-about-a-vacuum-cleaner-but/#comments</comments>
		<pubDate>Sun, 11 Oct 2009 21:57:26 +0000</pubDate>
		<dc:creator>Flipflops</dc:creator>
				<category><![CDATA[Stuff]]></category>

		<guid isPermaLink="false">http://www.flipflops.org/2009/10/11/i-feel-stupid-blogging-about-a-vacuum-cleaner-but/</guid>
		<description><![CDATA[We have just bought a new vacuum cleaner (I hate it when people (e.g. my girlfriend) call them hoovers)) to replace the beaten up old piece of junk we inherited from one of our grandparents.
Anyway other people we know did loads of research (like Which) and apparently the best vacuum cleaners you can get at [...]]]></description>
			<content:encoded><![CDATA[<p>We have just bought a new vacuum cleaner (I hate it when people (e.g. my girlfriend) call them hoovers)) to replace the beaten up old piece of junk we inherited from one of our grandparents.</p>
<p>Anyway other people we know did loads of research (like <a href="http://www.which.co.uk/">Which</a>) and apparently the best vacuum cleaners you can get at the moment are Miele vacuum cleaners. So a few people we know bought them &#8211; and we&#8217;ve just got one&#8230; </p>
<p>And it really is amazing. It is awesome. It actually sucks the carpet up of the floor creating a kind of carpet wave as you hoover the room. Our house is considerably cleaner now than it was a few days ago.</p>
<p><a href="http://www.amazon.co.uk/gp/product/B0013SSDUM?ie=UTF8&#038;tag=flipflopsorg-21&#038;linkCode=as2&#038;camp=1634&#038;creative=19450&#038;creativeASIN=B0013SSDUM"><img src='http://www.flipflops.org/wp-content/uploads/2009/10/miele-vacuum-cleaner.jpg' alt='Miele S 5211 Vacuum Cleaner' /></a></p>
<p><a href="http://www.amazon.co.uk/gp/product/B0013SSDUM?ie=UTF8&#038;tag=flipflopsorg-21&#038;linkCode=as2&#038;camp=1634&#038;creative=19450&#038;creativeASIN=B0013SSDUM">Miele S 5211 Vacuum Cleaner</a> (on Amazon)<img src="http://www.assoc-amazon.co.uk/e/ir?t=flipflopsorg-21&#038;l=as2&#038;o=2&#038;a=B0013SSDUM" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.flipflops.org/2009/10/11/i-feel-stupid-blogging-about-a-vacuum-cleaner-but/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Ernest Marples postcode lookup is disabled</title>
		<link>http://www.flipflops.org/2009/10/11/ernest-marples-postcode-lookup-is-disabled/</link>
		<comments>http://www.flipflops.org/2009/10/11/ernest-marples-postcode-lookup-is-disabled/#comments</comments>
		<pubDate>Sun, 11 Oct 2009 21:37:13 +0000</pubDate>
		<dc:creator>Flipflops</dc:creator>
				<category><![CDATA[Postcodes]]></category>

		<guid isPermaLink="false">http://www.flipflops.org/2009/10/11/ernest-marples-postcode-lookup-is-disabled/</guid>
		<description><![CDATA[A while ago I came across a great UK postcode lookup service http://www.ernestmarples.com/ and wrote a post about it here. 
Just went back to it a few days ago and unfortunately the service has been suspended. Luckily I didn&#8217;t have any applications using it (I mostly use the Google or Yahoo) &#8211; but it was [...]]]></description>
			<content:encoded><![CDATA[<p>A while ago I came across a great UK postcode lookup service <a href="http://www.ernestmarples.com/">http://www.ernestmarples.com/</a> and wrote a post about it <a href="http://www.flipflops.org/2009/08/04/free-uk-postcode-geocoding/">here</a>. </p>
<p>Just went back to it a few days ago and unfortunately the service has been suspended. Luckily I didn&#8217;t have any applications using it (I mostly use the Google or Yahoo) &#8211; but it was a damn fast way to just get the co-ordinates of a UK postcode. </p>
<p>It&#8217;s just a shame that such a useful service has been shut down &#8211; obviously postcode data is worth a lot of money to Royal Mail &#8211; but surely more economic value could be extracted if postcodes were free.</p>
<p>If you are interested in how this pans out there is a <a href="http://ernestmarples.com/blog/">blog</a>. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.flipflops.org/2009/10/11/ernest-marples-postcode-lookup-is-disabled/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Green Man Photos</title>
		<link>http://www.flipflops.org/2009/09/30/green-man-photos/</link>
		<comments>http://www.flipflops.org/2009/09/30/green-man-photos/#comments</comments>
		<pubDate>Wed, 30 Sep 2009 14:26:24 +0000</pubDate>
		<dc:creator>Flipflops</dc:creator>
				<category><![CDATA[Photography]]></category>

		<guid isPermaLink="false">http://www.flipflops.org/2009/09/30/green-man-photos/</guid>
		<description><![CDATA[A few photos from the Green Man music festival earlier this year. I always love night photos even if some of them are a bit out of focus&#8230;
(click on the photo to view the gallery)
]]></description>
			<content:encoded><![CDATA[<p>A few photos from the Green Man music festival earlier this year. I always love night photos even if some of them are a bit out of focus&#8230;</p>
<p>(click on the photo to view the gallery)</p>

]]></content:encoded>
			<wfw:commentRss>http://www.flipflops.org/2009/09/30/green-man-photos/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Setting TinyMCE configs in Django settings.py</title>
		<link>http://www.flipflops.org/2009/09/30/setting-tinymce-configs-in-django-settingspy/</link>
		<comments>http://www.flipflops.org/2009/09/30/setting-tinymce-configs-in-django-settingspy/#comments</comments>
		<pubDate>Wed, 30 Sep 2009 13:59:57 +0000</pubDate>
		<dc:creator>Flipflops</dc:creator>
				<category><![CDATA[Django]]></category>

		<guid isPermaLink="false">http://www.flipflops.org/2009/09/30/setting-tinymce-configs-in-django-settingspy/</guid>
		<description><![CDATA[Working with the Django Filebrowser and TinyMCE I have just spent quite a while with an utterly frustrating problem.
I want to set all my my inserted image paths to absolute e.g. /media/uploads/someimge.jpg &#8211; in TinyMCE the way to do this is to set &#8220;convert_urls&#8221;: false
The relevant part of my settings.py file looked like this:

TINYMCE_DEFAULT_CONFIG = [...]]]></description>
			<content:encoded><![CDATA[<p>Working with the <a href="http://code.google.com/p/django-filebrowser/">Django Filebrowser</a> and TinyMCE I have just spent quite a while with an utterly frustrating problem.</p>
<p>I want to set all my my inserted image paths to absolute e.g. /media/uploads/someimge.jpg &#8211; in TinyMCE the way to do this is to set &#8220;convert_urls&#8221;: false</p>
<p>The relevant part of my settings.py file looked like this:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">TINYMCE_DEFAULT_CONFIG = <span style="color: black;">&#123;</span>
    <span style="color: #483d8b;">'plugins'</span>: <span style="color: #483d8b;">&quot;table,spellchecker,paste,searchreplace&quot;</span>,
    <span style="color: #483d8b;">'theme'</span>: <span style="color: #483d8b;">&quot;advanced&quot;</span>,
    <span style="color: #483d8b;">'theme_advanced_toolbar_location'</span> : <span style="color: #483d8b;">&quot;top&quot;</span>,
    <span style="color: #483d8b;">'theme_advanced_toolbar_align'</span> : <span style="color: #483d8b;">&quot;left&quot;</span>,
    <span style="color: #483d8b;">'theme_advanced_statusbar_location'</span> : <span style="color: #483d8b;">&quot;bottom&quot;</span>,
    <span style="color: #483d8b;">'theme_advanced_resizing'</span> : <span style="color: #483d8b;">&quot;true&quot;</span>,
    <span style="color: #483d8b;">'convert_urls'</span> : <span style="color: #483d8b;">&quot;false&quot;</span>
<span style="color: black;">&#125;</span></pre></div></div>

<p>But nothing worked and my images were all being inserted as ../../../media/uploads/someimge.jpg</p>
<p>Eventually looking at the generated source of my page I realised that the problem was this was rendering &#8220;convert_urls&#8221;: &#8220;false&#8221;  it should be rendering &#8220;convert_urls&#8221;: false</p>
<p>The solution is pretty obvious &#8211; but then they usually are:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">TINYMCE_DEFAULT_CONFIG = <span style="color: black;">&#123;</span>
    <span style="color: #483d8b;">'plugins'</span>: <span style="color: #483d8b;">&quot;table,spellchecker,paste,searchreplace&quot;</span>,
    <span style="color: #483d8b;">'theme'</span>: <span style="color: #483d8b;">&quot;advanced&quot;</span>,
    <span style="color: #483d8b;">'theme_advanced_toolbar_location'</span> : <span style="color: #483d8b;">&quot;top&quot;</span>,
    <span style="color: #483d8b;">'theme_advanced_toolbar_align'</span> : <span style="color: #483d8b;">&quot;left&quot;</span>,
    <span style="color: #483d8b;">'theme_advanced_statusbar_location'</span> : <span style="color: #483d8b;">&quot;bottom&quot;</span>,
    <span style="color: #483d8b;">'theme_advanced_resizing'</span> : <span style="color: #008000;">True</span>,
    <span style="color: #483d8b;">'convert_urls'</span> : <span style="color: #008000;">False</span>
<span style="color: black;">&#125;</span></pre></div></div>

<p>The reason it took me so long to figure out was that I tried to use &#8216;convert_urls&#8217; : false &#8211; which just resulted in syntax error &#8211; coming from PHP I&#8217;m used to booleans being case insensitive &#8211; in Python they aren&#8217;t. It also explains why my &#8216;theme_advanced_resizing&#8217; didn&#8217;t work either.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flipflops.org/2009/09/30/setting-tinymce-configs-in-django-settingspy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CakePHP Menu Helper for Tree data</title>
		<link>http://www.flipflops.org/2009/09/29/cakephp-menu-helper-for-tree-data/</link>
		<comments>http://www.flipflops.org/2009/09/29/cakephp-menu-helper-for-tree-data/#comments</comments>
		<pubDate>Tue, 29 Sep 2009 19:11:03 +0000</pubDate>
		<dc:creator>Flipflops</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.flipflops.org/2009/09/29/cakephp-menu-helper-for-tree-data/</guid>
		<description><![CDATA[This is the MenuHelper I use in my CMS system. It is designed to work with data from the Tree behaviour or from any $model->find(&#8216;threaded&#8217;) call. I use it to generate multi level CSS menus (that you see at the top of most websites), contextual menus (that you see in sidebars, showing the current page [...]]]></description>
			<content:encoded><![CDATA[<p>This is the MenuHelper I use in my CMS system. It is designed to work with data from the Tree behaviour or from any $model->find(&#8216;threaded&#8217;) call. I use it to generate multi level CSS menus (that you see at the top of most websites), contextual menus (that you see in sidebars, showing the current page and its &#8216;branch&#8217;) and sitemaps &#8211; which let&#8217;s face it are basically often just the same as a top level menu but without the fancy stuff to make them pop out when you hover over them.</p>
<h2>Prerequisites, history, overview</h2>
<p>There are a couple of prerequisites here which may mean that this isn&#8217;t applicable for a lot of people. The helper is designed to deal with &#8216;page&#8217; structures organised in simple /parent/child/grand-child format e.g.</p>
<p>/home<br />
/about<br />
/about/company-history<br />
/about/company-history/gallery<br />
/about/ethos<br />
/about/vacancies<br />
/news<br />
/news/2009/jan<br />
/news/2009/feb<br />
/news/2009/mar<br />
/contact<br />
(etc.)</p>
<p>In my system I have a model &#8216;Article&#8217; with Tree behaviour attached. So in the example above &#8216;ethos&#8217; is a child of &#8216;about&#8217;. Some of these pages have real content, but others just act as place holders for other controllers / models &#8211; &#8216;news&#8217; is a placeholder for the &#8216;News&#8217; model. But all of them (even the placeholders) have other data attached like content for sidebars or meta information.</p>
<p>The helper will add a &#8217;selected-item&#8217; class to the LI corresponding to the current page, and if it has any parents it will add a &#8217;selected&#8217; class to each of those parent LIs too.</p>
<p><strong>I create a full slug for each &#8216;Article&#8217; on $model->save()</strong></p>
<p>The helper operates in 2 modes &#8216;tree&#8217; (which is default) and &#8216;context&#8217;<br />
&#8216;tree&#8217; will produce a whole list of nested ULs &#8211; can be used to generate top level navigation (works well with things like suckerfish)<br />
&#8216;context&#8217; will only produce nested ULs for the current branch</p>
<p>Using the example above if you were on the /about/ethos page and you wanted the navigation fragment in the sidebar you would use &#8216;context&#8217;<br />
/about<br />
/about/company-history<br />
/about/company-history/gallery<br />
/about/ethos<br />
/about/vacancies</p>
<h2>Database Fields</h2>
<p>These are the default field names, they can be simply overridden to match your database schema.</p>
<h3>Required Fields</h3>
<ul>
<li>name </li>
<li>slug_url</li>
</ul>
<h3>Optional Fields</h3>
<ul>
<li>title_for_navigation</li>
<li>redirect_url</li>
<li>redirect_target</li>
</ul>
<h2>Example &#8216;threaded&#8217; data</h2>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009900;">&#91;</span>Article<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">Array</span>
                <span style="color: #009900;">&#40;</span>
                    <span style="color: #009900;">&#91;</span>name<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> Find out about us
                    <span style="color: #009900;">&#91;</span>slug_url<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #339933;">/</span>about<span style="color: #339933;">-</span>us
                    <span style="color: #009900;">&#91;</span>title_for_navigation<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> About Us
                    <span style="color: #009900;">&#91;</span>redirect_url<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> 
                    <span style="color: #009900;">&#91;</span>redirect_target<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> 
                    <span style="color: #009900;">&#91;</span>lft<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">15</span>
                    <span style="color: #009900;">&#91;</span>id<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">105</span>
                    <span style="color: #009900;">&#91;</span>rght<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">24</span>
                    <span style="color: #009900;">&#91;</span>parent_id<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> 
                <span style="color: #009900;">&#41;</span>
&nbsp;
            <span style="color: #009900;">&#91;</span>children<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">Array</span>
                <span style="color: #009900;">&#40;</span>
                    <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">Array</span>
                        <span style="color: #009900;">&#40;</span>
                            <span style="color: #009900;">&#91;</span>Article<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">Array</span>
                                <span style="color: #009900;">&#40;</span>
                                    <span style="color: #009900;">&#91;</span>name<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> Philosophy
                                    <span style="color: #009900;">&#91;</span>slug_url<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #339933;">/</span>about<span style="color: #339933;">-</span>us<span style="color: #339933;">/</span>philosophy
                                    <span style="color: #009900;">&#91;</span>title_for_navigation<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> 
                                    <span style="color: #009900;">&#91;</span>redirect_url<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> 
                                    <span style="color: #009900;">&#91;</span>redirect_target<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> 
                                    <span style="color: #009900;">&#91;</span>lft<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">16</span>
                                    <span style="color: #009900;">&#91;</span>id<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">111</span>
                                    <span style="color: #009900;">&#91;</span>rght<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">21</span>
                                    <span style="color: #009900;">&#91;</span>parent_id<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">105</span>
                                <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span></pre></div></div>

<h2>Usage</h2>
<p>Include the helper in your controller as usual.</p>
<p>In a view / element to generate complete menu</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$menu</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setup</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$menu_data</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'selected'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">here</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>In a view / element to generate a context menu from the same data, set the class of the parent UL</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$menu</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setup</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$menu_data</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'selected'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">here</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'type'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'context'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'menuClass'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'context-menu'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>In a view / element to generate a sitemap from different data, let the helper know to use the &#8216;Sitemap&#8217; model rather than the default &#8216;Article&#8217; model and set the parent UL class.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #000088;">$sitemap</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> MenuHelper<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$sitemap</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setup</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #339933;">,</span>  <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'modelName'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Sitemap'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'menuClass'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'sitemap'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h2>The Helper Code</h2>
<p><strong><a href="/scripts/menu.php.txt">Download the Helper</a></strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>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
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #009933; font-style: italic;">/**
 * Menu Helper
 * 
 * @author John Elliott (http://www.flipflops.org)
 * @package app
 * @subpackage app.views.helpers
 * @version 1.0
 * @lastmodified 2009-09-29
 * 
 * This helper is designed to work with the data arrays returned by the Tree behaviour or $model-&gt;find('threaded');
 * More specifically it is designed to generate menus composed of nested ULs for use in CMS systems where all the URLs are pretty:
 * 	- naviagtion menus (usually at the top of the page)
 * 	- context menus (usually found at the side) and showing the links in the current branch
 * 	- sitemaps
 * 
 * Overview (A bit of history)
 * 
 * The helper is designed to deal with navigation / page structures organised in simple /parent/child/grand-child like structures
 * for instance:
 * 
 * /home
 * /about
 * /about/company-history
 * /about/company-history/gallery
 * /about/ethos
 * /about/vacancies
 * /news
 * /news/2009/jan
 * /news/2009/feb
 * /news/2009/mar
 * /contact
 * (etc.)
 * 
 * -------------------
 * URLs are generated in the model or controller not in the view / helper
 * -------------------
 * In the system from which this is taken, I create a full slug for each page on $model-&gt;save();
 * Some of the pages are actual pages of text and others are palceholders for content in other models
 * but they allow you do things like control the content of left / right columns, set default meta tags etc.
 * The purpose being to create really easy site structures with nice urls, the 
 * In the example above /home, /about etc. are all from a single model 'Article' which is my master model 
 * /news however is a placeholder for the 'News' model and /contact for the 'Contact' model
 * 
 *
 * 
 * Required Fields
 * ------------------
 * title / name (defaults to 'title')
 * page url (defaults to 'slug_url' e.g. /about/ethos)
 * 
 * Optional Fields
 * ------------------
 * title_for_navigation
 * redirect_url
 * redirect_target
 * 
 * Example data
 * ------------------
 * [Article] =&gt; Array
                (
                    [name] =&gt; Find out about us
                    [slug_url] =&gt; /about-us
                    [title_for_navigation] =&gt; About Us
                    [redirect_url] =&gt; 
                    [redirect_target] =&gt; 
                    [lft] =&gt; 15
                    [id] =&gt; 105
                    [rght] =&gt; 24
                    [parent_id] =&gt; 
                )
&nbsp;
            [children] =&gt; Array
                (
                    [0] =&gt; Array
                        (
                            [Article] =&gt; Array
                                (
                                    [name] =&gt; Philosophy
                                    [slug_url] =&gt; /about-us/philosophy
                                    [title_for_navigation] =&gt; 
                                    [redirect_url] =&gt; 
                                    [redirect_target] =&gt; 
                                    [lft] =&gt; 16
                                    [id] =&gt; 111
                                    [rght] =&gt; 21
                                    [parent_id] =&gt; 105
                                )
 * 
 * 
 * 
 *
 * Usage:
 * 
 * Include the helper in your controller as usual.
 * 
 * The helper operates in 2 modes 'tree' (which is default) and 'context'
 * 'tree' will produce a whole list of nested Uls - can be used to generate top level navigation (works well with things like suckerfish)
 * 'context' will only produce nested ULs for the current branch
 * 
 * Using the example above if you were on the /about/ethos page and you wanted the navigation fragment in the sidebar you would use context
 * /about
 * /about/company-history
 * /about/company-history/gallery
 * /about/ethos
 * /about/vacancies
 * 
 * In a view / element to generate complete menu
 * echo $menu-&gt;setup($menu_data, array('selected' =&gt; $this-&gt;here));
 * 
 * In a view / element to generate a context menu from the same data, set the class of the parent UL
 * echo $menu-&gt;setup($menu_data, array('selected' =&gt; $this-&gt;here, 'type' =&gt; 'context', 'menuClass' =&gt; 'context-menu'));
 * 
 * 
 * In a view / element to generate a sitemap from different data, let the helper know to use the 'Sitemap' model rather than the default 'Article' model and set the parent UL class.
 * $sitemap = new MenuHelper();
 * echo $sitemap-&gt;setup($data,  array('modelName' =&gt; 'Sitemap', 'menuClass' =&gt; 'sitemap'));
 * 
 * Version Details
 * 
 * 1.0
 * + Initial release.
 */</span>
<span style="color: #000000; font-weight: bold;">class</span> MenuHelper <span style="color: #000000; font-weight: bold;">extends</span> AppHelper <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #009933; font-style: italic;">/**
	 * Current page in application
	 *
	 * @var string
	 */</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$selected</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009933; font-style: italic;">/** Internal variable for the data
	 *
	 * @var array
	 */</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$array</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009933; font-style: italic;">/**
	 * Default css class applied to the menu
	 *
	 * @var string
	 */</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$menuClass</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'menu'</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009933; font-style: italic;">/**
	 * Default DOM id applied to menu
	 *
	 * @var string
	 */</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$menuId</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'top-menu'</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009933; font-style: italic;">/**
	 * CSS class applied to the selected node and its parent nodes 
	 *
	 * @var string
	 */</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$selectedClass</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'selected'</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009933; font-style: italic;">/**
	 * CSS class applied to the exact selected node in the tree - in addition to $selectedClass
	 *
	 * @var unknown_type
	 */</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$selectedClassItem</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'item-selected'</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009933; font-style: italic;">/**
	 * Default Slug
	 *
	 * @var string
	 */</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$defaultSlug</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'home'</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009933; font-style: italic;">/**
	 * Type of menu to be generated:
	 * 'tree' - to generate a complete tree
	 * 'context' - to only render the specific barnch under the current page
	 *
	 * @var string
	 */</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$type</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'tree'</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009933; font-style: italic;">/**
	 * Model name used in $array e.g. $data[0]['Article']['name']
	 *
	 * @var string
	 */</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$modelName</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Article'</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009933; font-style: italic;">/**
	 * Database column name - (i.e. a shorter version of the name / title for use only in naviagtion)
	 * e.g. A page called 'Welcome to the giant flea circus' 
	 * might be set to show up on navigation as 'home'
	 *
	 * @var string
	 */</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$titleForNavigation</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'title_for_navigation'</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009933; font-style: italic;">/**
	 * Database column name for title / name
	 * @var string
	 */</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$title</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'name'</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009933; font-style: italic;">/**
	 * Database column name for complete page slug e.g. /about/history/early-years
	 *
	 * @var string
	 */</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$slugUrl</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'slug_url'</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009933; font-style: italic;">/**
	 * Database column name for redirect_url for instance if /about/blog redirects to http://blog.somewebsite.com
	 *
	 * @var string
	 */</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$redirectUrl</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'redirect_url'</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009933; font-style: italic;">/**
	 * Target for redirect (see redirectUrl)
	 *
	 * @var string
	 */</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$redirectTarget</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'redirect_target'</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009933; font-style: italic;">/**
	 * Minumum number of items required to render a context menu
	 *
	 * @var int
	 */</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$contextMinLength</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009933; font-style: italic;">/**
	 * Internal Counter used in type: 'context'
	 *
	 * @var int
	 */</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$li_count</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009933; font-style: italic;">/**
	 * Internal flag to see if the page has been matched to an item
	 *
	 * @var bool
	 */</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$matched</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009933; font-style: italic;">/**
	 * Internal counter
	 *
	 * @var int
	 */</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009933; font-style: italic;">/**
	 * Enter description here...
	 *
	 * @var unknown_type
	 */</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$rootNode</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> setOption<span style="color: #009900;">&#40;</span><span style="color: #000088;">$key</span><span style="color: #339933;">,</span> <span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span><span style="color: #000088;">$key</span><span style="color: #009900;">&#125;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$value</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getOption<span style="color: #009900;">&#40;</span><span style="color: #000088;">$key</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span><span style="color: #000088;">$key</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #009933; font-style: italic;">/**
	 * Setup the helper and return a string to echo
	 *
	 * @param array $array Data array containing the lists
	 * @param array $config Configuration variables to override the defaults
	 * @return string
	 */</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> setup<span style="color: #009900;">&#40;</span><span style="color: #000088;">$array</span><span style="color: #339933;">,</span> <span style="color: #000088;">$config</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// update and override the default variables </span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$config</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$config</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setOption</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$key</span><span style="color: #339933;">,</span> <span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// set the default slug selected if the current page does not match</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">selected</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'/'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">selected</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">defaultSlug</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">array</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$array</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
&nbsp;
		<span style="color: #666666; font-style: italic;">// get the root node of the selected tree if this a context menu</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">type</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'context'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">rootNode</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getRootNode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">selected</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000088;">$str</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">buildMenu</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// if the current page has matched one of the links in the tree</span>
		<span style="color: #666666; font-style: italic;">// then get rid of the 'default_slected' placeholder</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">matched</span> <span style="color: #339933;">==</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$str</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'default_selected'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$str</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$s</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">' class=&quot;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">selectedClass</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot; '</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$str</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'default_selected'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$s</span><span style="color: #339933;">,</span> <span style="color: #000088;">$str</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// if this is a context menu, it looks daft if it only has 1 item </span>
		<span style="color: #666666; font-style: italic;">// if this is the case hide it</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">type</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'context'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">li_count</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">contextMinLength</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$str</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">output</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$str</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
&nbsp;
	<span style="color: #009900;">&#125;</span>
	<span style="color: #009933; font-style: italic;">/**
	 * Call the menu iterator method and if it returns a string warp it up in a UL
	 *
	 * @return string
	 */</span>
	protected <span style="color: #000000; font-weight: bold;">function</span> buildMenu<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #000088;">$str</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">menuIterator</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">array</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$str</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$str</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'&lt;ul  id=&quot;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">menuId</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot; class=&quot;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">menuClass</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot;&gt;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$str</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;/ul&gt;'</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$str</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #009933; font-style: italic;">/**
	 * Explode a url slug and get the root page
	 *
	 * @param string $string 
	 * @return string
	 */</span>
	protected <span style="color: #000000; font-weight: bold;">function</span> getRootNode<span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$rootNode</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$node</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #666666; font-style: italic;">// $node[0] will always be empty becuase the first char of $this-&gt;selected will always be '/'</span>
				<span style="color: #000088;">$rootNode</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$node</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #000088;">$rootNode</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
	<span style="color: #009933; font-style: italic;">/**
	 * Recursive method to loop down through the data array building menus and sub menus
	 *
	 * @param array $array
	 * @param int $depth
	 * @return string
	 */</span>
	protected <span style="color: #000000; font-weight: bold;">function</span> menuIterator<span style="color: #009900;">&#40;</span><span style="color: #000088;">$array</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #000088;">$str</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$is_selected</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$array</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$var</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
			<span style="color: #000088;">$continue</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$selected</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$sub</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">type</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'context'</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getRootNode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$var</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">modelName</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">slugUrl</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">rootNode</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$continue</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
&nbsp;
			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$continue</span> <span style="color: #339933;">==</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
				<span style="color: #666666; font-style: italic;">// if this is the first list item set default_selected placeholder</span>
				<span style="color: #000088;">$default_selected</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
				<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">i</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
					<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
					<span style="color: #000088;">$default_selected</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'default_selected'</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
				<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$var</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'children'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
					<span style="color: #000088;">$sub</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&lt;ul&gt;'</span><span style="color: #339933;">;</span>
					<span style="color: #000088;">$sub</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">menuIterator</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$var</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'children'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #000088;">$sub</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&lt;/ul&gt;'</span><span style="color: #339933;">;</span>	
				<span style="color: #009900;">&#125;</span>
&nbsp;
				<span style="color: #000088;">$p</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strpos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">selected</span><span style="color: #339933;">,</span> <span style="color: #000088;">$var</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">modelName</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">slugUrl</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
				<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$p</span> <span style="color: #339933;">===</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
				<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$p</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
						<span style="color: #666666; font-style: italic;">// this is the selected item or a parent node of the selected item</span>
						<span style="color: #000088;">$selected</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">' class=&quot;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">selectedClass</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot; '</span><span style="color: #339933;">;</span>
						<span style="color: #000088;">$is_selected</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
						<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">matched</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
&nbsp;
				<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">selected</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$var</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">modelName</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">slugUrl</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
					<span style="color: #666666; font-style: italic;">// this is the exact selected item</span>
					<span style="color: #000088;">$selected</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">' class=&quot;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">selectedClass</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">' '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">selectedClassItem</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot; '</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
&nbsp;
				<span style="color: #666666; font-style: italic;">// keep track if this is a contextual menu </span>
				<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">type</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'context'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
					<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">li_count</span><span style="color: #339933;">++;</span>
				<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
				<span style="color: #666666; font-style: italic;">// Get the name / title to be used for the link text</span>
				<span style="color: #000088;">$name</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$var</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #666666; font-style: italic;">// Get the URL / target for the link</span>
				<span style="color: #000088;">$url</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getUrl</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$var</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
				<span style="color: #000088;">$str</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&lt;li '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$selected</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">' '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$default_selected</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&gt;'</span><span style="color: #339933;">;</span>
					<span style="color: #000088;">$str</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&lt;a  href=&quot;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$url</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'url'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot; '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$url</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'target'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&gt;&lt;span&gt;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$name</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;/span&gt;&lt;/a&gt;'</span><span style="color: #339933;">;</span>
					<span style="color: #000088;">$str</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$sub</span><span style="color: #339933;">;</span>
				<span style="color: #000088;">$str</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&lt;/li&gt;'</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$str</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #009933; font-style: italic;">/**
	 * Look in the data and check if this is a straight url
	 * or whether it is actually a redirect
	 *
	 * @param array $var
	 * @return array
	 */</span>
	protected <span style="color: #000000; font-weight: bold;">function</span> getUrl<span style="color: #009900;">&#40;</span><span style="color: #000088;">$var</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$url</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$var</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">modelName</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">redirectUrl</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$var</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">modelName</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">redirectUrl</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$url</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'url'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$var</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">modelName</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">redirectUrl</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
				<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$var</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">modelName</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">redirectTarget</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$var</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">modelName</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">redirectTarget</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
					<span style="color: #000088;">$url</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'target'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">' target=&quot;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$var</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">modelName</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">redirectTarget</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot; '</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$url</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'url'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$var</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">modelName</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">slugUrl</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
				<span style="color: #000088;">$url</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'target'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #000088;">$url</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #009933; font-style: italic;">/**
	 * See if there is a title_for_navigation 
	 *
	 * @param array $var
	 * @return string
	 */</span>
	protected <span style="color: #000000; font-weight: bold;">function</span> getName<span style="color: #009900;">&#40;</span><span style="color: #000088;">$var</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$var</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">modelName</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">titleForNavigation</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$var</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">modelName</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">titleForNavigation</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$name</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$var</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">modelName</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">titleForNavigation</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$name</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$var</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">modelName</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">title</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$name</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.flipflops.org/2009/09/29/cakephp-menu-helper-for-tree-data/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Symbiotica</title>
		<link>http://www.flipflops.org/2009/09/24/symbiotica-2/</link>
		<comments>http://www.flipflops.org/2009/09/24/symbiotica-2/#comments</comments>
		<pubDate>Thu, 24 Sep 2009 09:13:12 +0000</pubDate>
		<dc:creator>Flipflops</dc:creator>
				<category><![CDATA[Stuff]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Web Things]]></category>

		<guid isPermaLink="false">http://www.flipflops.org/2009/09/24/symbiotica-media-ltd/</guid>
		<description><![CDATA[
I&#8217;ve been meaning to announce the launch of my company Symbiotica Media Ltd &#8211; based in Devon near the city of Exeter. As you will be unsurprised to learn it is a web development company &#8211; so if you need beautiful, functional websites and applications that are a joy to use, look no further.
I have [...]]]></description>
			<content:encoded><![CDATA[<p><a href='http://www.symbiotica.co.uk' title='Symbiotica Media Development Ltd - web design &#038; development in Devon'><img src='http://www.flipflops.org/wp-content/uploads/2009/08/logo.jpg' alt='Symbiotica Media Ltd - web design &#038; development in Devon' /></a></p>
<p>I&#8217;ve been meaning to announce the launch of my company <a href="http://blog.symbiotica.co.uk/2009/09/we-have-arrived/">Symbiotica Media Ltd</a> &#8211; based in Devon near the city of Exeter. As you will be unsurprised to learn it is a web development company &#8211; so if you need beautiful, functional websites and applications that are a joy to use, look no further.</p>
<p>I have been so busy that our <a href="http://www.symbiotica.co.uk">main website</a> still isn&#8217;t ready, but we now have a delicious looking <a href="http://blog.symbiotica.co.uk">blog</a> up and running.</p>
<p><img src='http://www.flipflops.org/wp-content/uploads/2009/09/symblog.jpg' alt='Symbiotica Media Development Ltd - web design &#038; development in Devon' /></p>
<p>If you read flipflops.org regularly, you will rightly guess that we will be working with CakePHP quite a lot, but current projects also make extensive use of <a href="http://www.wordpress.org">Wordpress</a> and  <a href="http://tarzan-aws.com">Tarzan AWS</a>. I&#8217;m also built and am using a great a little, lightweight  XML template engine based on the Page Controller pattern, and hopefully more Django soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flipflops.org/2009/09/24/symbiotica-2/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 28.291 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2010-03-21 21:40:38 -->
<!-- Compression = gzip -->