<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.1.3" -->
<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/"
	>

<channel>
	<title>Flipflops.org</title>
	<link>http://www.flipflops.org</link>
	<description>Stuff</description>
	<pubDate>Mon, 11 Aug 2008 21:20:43 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.1.3</generator>
	<language>en</language>
			<item>
		<title>Traffic Light Therapy</title>
		<link>http://www.flipflops.org/2008/08/11/traffic-light-therapy/</link>
		<comments>http://www.flipflops.org/2008/08/11/traffic-light-therapy/#comments</comments>
		<pubDate>Mon, 11 Aug 2008 21:20:43 +0000</pubDate>
		<dc:creator>Flipflops</dc:creator>
		
		<category><![CDATA[Stuff]]></category>

		<guid isPermaLink="false">http://www.flipflops.org/2008/08/11/traffic-light-therapy/</guid>
		<description><![CDATA[Just started a new job (so far I&#8217;m enjoying it a lot (although it will be even better perfect when I can get a Cake based system (not that what is in place at the moment is bad - on the contrary it is very good - it is just that I am philosophically opposed [...]]]></description>
			<content:encoded><![CDATA[<p>Just started a new job (so far I&#8217;m enjoying it a lot (although it will be <strike>even better</strike> perfect when I can get a Cake based system (not that what is in place at the moment is bad - on the contrary it is very good - it is just that I am philosophically opposed to it&#8230;) in place&#8230; (although I <em>really</em> want to use a bit of Django sometime))). What comes with this is much longer walk to the office from where I park the car. My walk involves crossing some very busy and very inconveniently placed roads.</p>
<p>These roads have crossing points and if you are a pedestrian you get to press a button to let you cross, but the buttons do nothing - they have no effect on the traffic flow at all. All I can surmise is that the buttons are put in place purely to give pedestrians a something to do purely so they don&#8217;t scream in impotent fury at the traffic.</p>
<p>I know (in my heart) this to be the case, but I push the buttons anyway&#8230; out of some faint hope&#8230;</p>
<p>I am right aren&#8217;t I? The buttons really don&#8217;t do a thing?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flipflops.org/2008/08/11/traffic-light-therapy/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Brutalism, Architecture, Cars and Batman</title>
		<link>http://www.flipflops.org/2008/08/06/brutalism-architecture-cars-and-batman/</link>
		<comments>http://www.flipflops.org/2008/08/06/brutalism-architecture-cars-and-batman/#comments</comments>
		<pubDate>Wed, 06 Aug 2008 22:07:16 +0000</pubDate>
		<dc:creator>Flipflops</dc:creator>
		
		<category><![CDATA[Stuff]]></category>

		<category><![CDATA[Art]]></category>

		<category><![CDATA[Architechture]]></category>

		<category><![CDATA[Film]]></category>

		<guid isPermaLink="false">http://www.flipflops.org/2008/08/06/brutalism-architecture-cars-and-batman/</guid>
		<description><![CDATA[Yesterday I saw the new Batman film the Dark Knight. All in all I was pretty impressed and I enjoyed it a lot (like my opinion matters&#8230;). I was wonderfully old fashioned in many ways epic and operatic, dark and intelligent. I thought that it was very interesting film in a lot of ways, of [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday I saw the new Batman film the <a href="http://thedarkknight.warnerbros.com/">Dark Knight</a>. All in all I was pretty impressed and I enjoyed it a lot (like my opinion matters&#8230;). I was wonderfully old fashioned in many ways epic and operatic, dark and intelligent. I thought that it was very interesting film in a lot of ways, of course there was the whole morality theme, but if you want to find out about that, pick up a paper and read a review; However I am a visual person, so it was the visual aspects that interested me most.</p>
<p>I thought that it was a particularly &#8216;tight&#8217; film in terms of the design and feel, clearly a lot of thought had gone into this and it hadn&#8217;t been wasted. Gotham city is brutal. It is the dark side of the Modernist Project, Post Modernism and wherever we are now haven&#8217;t got a look in. Can you imagine a curvey building by <a href="http://en.wikipedia.org/wiki/Frank_Gehry">Frank Gehry</a> or <a href="http://www.richardrogers.co.uk/work">Richard Rogers </a> (actually not very curvey but full of light and weightlessness)? I can&#8217;t. Gotham is a city where the concrete and the grid rule, this is not to say that some of the buildings are not beautiful, because many are.</p>
<p>I&#8217;ve noticed a few years ago that as the new model cars appeared they were all more hard edged, straight lined and less curvey than their predecessors, particularly the more expensive vehicles - think  Landrovers or BMWs - in short more militaristic, more hard edged designs. I think what makes it more interesting is that for a very long time prior to this, on the whole cars had been gaining curves. Clearly though people right now are in the mood to buy brutal looking cars. Some of the designs are wonderful (at least from a purely aesthetic point of view) - I think some of the smaller BMWs are sublime. </p>
<p>I think these hard edged designs are a direct response to fear and unease in society at large. People want to buy harder looking vehicles because they are fearful and therefore feel the need to project strength, of course good designers produce what thier customers and clients want, and the best the designers do this before their customers know what they want. Of course the biggest, hardest most brutal vehicle of all is the Batmobile.</p>
<p>Back to the film. I remember going to see <a href="http://www.imdb.com/title/tt0120201/">Starship Troopers</a> at the cinema when it came out, I went along with all my house mates and we illicitly necked a load of beers (or possibly a bottle of vodka (shudder)) and whooped and screamed as we watched the film. I remember the film because it was the first film I consciously saw where you couldn&#8217;t tell where the cgi began, of course ten years latter it almost tame. Special effects have just got bigger and better and they have got so big that they don&#8217;t really make any impact at all anymore because there is too much to take in.</p>
<p>So does he deserve an Oscar or not?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flipflops.org/2008/08/06/brutalism-architecture-cars-and-batman/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Set CakePHP layouts in app_controller</title>
		<link>http://www.flipflops.org/2008/08/04/set-cakephp-layouts-in-app_controller/</link>
		<comments>http://www.flipflops.org/2008/08/04/set-cakephp-layouts-in-app_controller/#comments</comments>
		<pubDate>Mon, 04 Aug 2008 21:37:22 +0000</pubDate>
		<dc:creator>Flipflops</dc:creator>
		
		<category><![CDATA[CakePHP]]></category>

		<guid isPermaLink="false">http://www.flipflops.org/2008/08/04/set-cakephp-layouts-in-app_controller/</guid>
		<description><![CDATA[Fed up of writing $this->layout = &#8216;admin&#8217; in all the admin methods of your controllers? Me too.
I realised that instead you could automatically set them in the beforeFilter() of your app_controller instead.

1
2
3
4
5
6
7
8
9
10
11
12
13
function beforeFilter&#40;&#41;&#123;
&#160;
  if&#40;isset&#40;$this-&#62;params&#91;'prefix'&#93;&#41;&#41; &#123;
    //read the admin prefix set in core.php
    $admin = Configure::read&#40;'Routing.admin'&#41;; 
&#160;
   [...]]]></description>
			<content:encoded><![CDATA[<p>Fed up of writing $this->layout = &#8216;admin&#8217; in all the admin methods of your controllers? Me too.</p>
<p>I realised that instead you could automatically set them in the <strong>beforeFilter()</strong> of your app_controller instead.</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
</pre></td><td class="code"><pre class="php"><span style="color: #000000; font-weight: bold;">function</span> beforeFilter<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
&nbsp;
  <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #000066;">isset</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$this</span>-&gt;<span style="color: #006600;">params</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'prefix'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #808080; font-style: italic;">//read the admin prefix set in core.php</span>
    <span style="color: #0000ff;">$admin</span> = Configure::<span style="color: #006600;">read</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'Routing.admin'</span><span style="color: #66cc66;">&#41;</span>; 
&nbsp;
    <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$this</span>-&gt;<span style="color: #006600;">params</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'prefix'</span><span style="color: #66cc66;">&#93;</span> == <span style="color: #0000ff;">$admin</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
&nbsp;
      <span style="color: #0000ff;">$this</span>-&gt;<span style="color: #006600;">layout</span> = <span style="color: #0000ff;">$admin</span>;
&nbsp;
    <span style="color: #66cc66;">&#125;</span>
  <span style="color: #66cc66;">&#125;</span>    
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>If you need to over-ride this, you can just do so as normal in individual methods.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flipflops.org/2008/08/04/set-cakephp-layouts-in-app_controller/feed/</wfw:commentRss>
		</item>
		<item>
		<title>At last the CakePHP books have arrived</title>
		<link>http://www.flipflops.org/2008/08/04/at-last-the-cakephp-books-have-arrived/</link>
		<comments>http://www.flipflops.org/2008/08/04/at-last-the-cakephp-books-have-arrived/#comments</comments>
		<pubDate>Mon, 04 Aug 2008 21:07:26 +0000</pubDate>
		<dc:creator>Flipflops</dc:creator>
		
		<category><![CDATA[CakePHP]]></category>

		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.flipflops.org/2008/08/04/at-last-the-cakephp-books-have-arrived/</guid>
		<description><![CDATA[I&#8217;d like to say it never rains but it pours, but that would be entirely the wrong sentiment, I need something more like good things come to those who wait&#8230;
Anyway after an epic wait a flurry of CakePHP books have arrived.

details on Amazon


details on Amazon


details on Amazon




view at Manning

I haven&#8217;t read any of these books [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;d like to say <em>it never rains but it pours</em>, but that would be entirely the wrong sentiment, I need something more like <em>good things come to those who wait</em>&#8230;</p>
<p>Anyway after an epic wait a flurry of CakePHP books have arrived.</p>
<div style="float: left;">
<a target="_blank" href="http://www.amazon.co.uk/gp/product/1430209771?ie=UTF8&#038;tag=flipflopsorg-21&#038;linkCode=as2&#038;camp=1634&#038;creative=6738&#038;creativeASIN=1430209771"><img src='http://www.flipflops.org/wp-content/uploads/2008/08/beginning-cakephp.jpg' alt='Beginning CakePHP Book' /><br />details on Amazon</a><img src="http://www.assoc-amazon.co.uk/e/ir?t=flipflopsorg-21&#038;l=as2&#038;o=2&#038;a=1430209771" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />
</div>
<div style="float: left;">
<a target="_blank" href="http://www.amazon.co.uk/gp/offer-listing/1847193897?ie=UTF8&#038;tag=cakephp-books-21&#038;linkCode=am2&#038;camp=1634&#038;creative=6738&#038;creativeASIN=1847193897"><img src='http://www.flipflops.org/wp-content/uploads/2008/08/cakephp-application-development.jpg' alt='CakePHP application development book' /><br />details on Amazon</a><img src="http://www.assoc-amazon.co.uk/e/ir?t=cakephp-books-21&#038;l=as2&#038;o=2&#038;a=1847193897" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />
</div>
<div style="float: left;">
<a target="_blank" href="http://www.amazon.co.uk/gp/offer-listing/143021578X?ie=UTF8&#038;tag=cakephp-books-21&#038;linkCode=am2&#038;camp=1634&#038;creative=6738&#038;creativeASIN=143021578X"><img src='http://www.flipflops.org/wp-content/uploads/2008/08/practical-cakephp-projects.jpg' alt='Practical CakePHP Projects' /><br />details on Amazon</a><img src="http://www.assoc-amazon.co.uk/e/ir?t=cakephp-books-21&#038;l=as2&#038;o=2&#038;a=143021578X" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />
</div>
<div style="float: left; clear: left;">
<a href="http://www.manning.com/obrien/" target="_blank"></p>
<p><img src='http://www.flipflops.org/wp-content/uploads/2008/08/obrien_cover150.jpg' alt='Manning CakepHP in Action' /><br />
<br />view at Manning</a></p>
</div>
<p>I haven&#8217;t read any of these books yet, but I from personal experience I would say the <a href="http://www.apress.com/">Apress</a> books are bound to be good. I have no idea what the books from <a href="http://www.packtpub.com/">Packt</a> are like. I have one <a href="http://www.manning.com/">Manning</a> book which is good but is unfortunately a PDF (and I hate reading PDFs).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flipflops.org/2008/08/04/at-last-the-cakephp-books-have-arrived/feed/</wfw:commentRss>
		</item>
		<item>
		<title>XAMPP and the PHP CLI</title>
		<link>http://www.flipflops.org/2008/07/27/xampp-and-the-php-cli/</link>
		<comments>http://www.flipflops.org/2008/07/27/xampp-and-the-php-cli/#comments</comments>
		<pubDate>Sun, 27 Jul 2008 21:00:47 +0000</pubDate>
		<dc:creator>Flipflops</dc:creator>
		
		<category><![CDATA[Web Things]]></category>

		<category><![CDATA[CakePHP]]></category>

		<category><![CDATA[bake]]></category>

		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.flipflops.org/2008/07/27/xampp-and-the-php-cli/</guid>
		<description><![CDATA[Like a lot of people I do most of my development work on windows PC and locally run a web a server and database. Like a a lot of people I just downloaded and installed a server bundle. For the last few years I have used Apache2triad and it has generally been pretty painless, but [...]]]></description>
			<content:encoded><![CDATA[<p>Like a lot of people I do most of my development work on windows PC and locally run a web a server and database. Like a a lot of people I just downloaded and installed a server bundle. For the last few years I have used <a href="http://www.apache2traid.net">Apache2triad</a> and it has generally been pretty painless, but I&#8217;ve recently been forced to abandon it. Unfortunately the development seems to have been abandoned about 2 years ago.</p>
<p>The reason I abandoned Apache2triad was PHP versions - I wanted to do some work with <a href="http://code.google.com/apis/base/">Google Base</a> using the <a href="http://framework.zend.com/download/gdata">Zend Google Data Library</a> which required PHP 5.1.4+. </p>
<p>Looking around at the various bundles I decided to go with <a href="http://www.apachefriends.org/en/xampp.html">XAMPP</a> - a lot of people seem to use it and it seems to get pretty good feedback. I won&#8217;t say the process was entirely painless (it took a couple of goes to get everything up and running) but eventually it all seemed OK.</p>
<p>The fun started when I decided to do a bit of <a href="http://book.cakephp.org/view/113/code-generation-with-bake">baking</a> (generating scaffolding code for my <a href="http://www.cakephp.org">CakePHP</a> app from a command line interface). Nothing worked.</p>
<p>Looking into it I discovered more than I wanted to know about the PHP Command Line Interface (CLI) which I had happily used for years with no idea it actually existed, having assumed it was just there as part of PHP.</p>
<p>After a lot googleing and a lot of trial and error I got it all working again and this is how I did it.</p>
<p>My environment is Windows XP Pro Service Pack 2 with XAMPP installed on E:/</p>
<ol>
<li>Downloaded the latest version of PHP and replaced the entire contents of  E:\xampp\php\.</li>
<li>Added to the E:\xampp\php to my environment PATH.</li>
</ol>
<p>At this stage PHP CLI wwas now working but there were nasty errors e.g. I was uanble to connect to MySQL from scripts. I discovered that this is because PHP CLI uses a different php.ini file to regular PHP.</p>
<p>To fix this I <strong>copied</strong> my php.ini from E:\xampp\apache\bin\php.ini (the default XAMPP ini file) to E:\xampp\php.</p>
<p>I then checked the PHP CLI again using php -v at a command prompt. There were now about 6 errors displayed, concerned with modules that could not be loaded or found. I believe that these concern modules just that aren&#8217;t meaningful in CLI mode. So I went through my new php.ini in E:\xampp\php and commented out the directives that were causing the errors until PHP CLI ran without errors.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flipflops.org/2008/07/27/xampp-and-the-php-cli/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Displaying Auth Error Messages</title>
		<link>http://www.flipflops.org/2008/07/02/displaying-auth-error-messages/</link>
		<comments>http://www.flipflops.org/2008/07/02/displaying-auth-error-messages/#comments</comments>
		<pubDate>Wed, 02 Jul 2008 22:00:01 +0000</pubDate>
		<dc:creator>Flipflops</dc:creator>
		
		<category><![CDATA[CakePHP]]></category>

		<guid isPermaLink="false">http://www.flipflops.org/2008/07/02/displaying-auth-error-messages/</guid>
		<description><![CDATA[I feel a bit daft posting this because in the end the answer was so easy to find - but maybe it will help somebody else.
I&#8217;ve been re-writing my users / groups permission system for CakePHP 1.2 and decided to incorporate as much built in functionality as possible so I&#8217;m using the Auth Component - [...]]]></description>
			<content:encoded><![CDATA[<p>I feel a bit daft posting this because in the end the answer was so easy to find - but maybe it will help somebody else.</p>
<p>I&#8217;ve been re-writing my users / groups permission system for CakePHP 1.2 and decided to incorporate as much built in functionality as possible so I&#8217;m using the Auth Component - which is great - but one thing kept bugging me, I couldn&#8217;t for the life of me figure out how to get the messages from Auth to display in my views - but by debugging I could see they were sitting there right in the Session.</p>
<p>I spent a long time Googling and looking at the API for clues, eventually in desperation I looked at the <a href="http://book.cakephp.org/view/172/authentication">cookbook</a>  (I have no idea why I hadn&#8217;t already looked there - as I use it a lot&#8230;) and the answer was both very easy and staring me right in the face.</p>
<p>Just pop the following in a view or layout:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="php">&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$session</span>-&gt;<span style="color: #006600;">check</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'Message.auth'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		<span style="color: #0000ff;">$session</span>-&gt;<span style="color: #006600;">flash</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'auth'</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.flipflops.org/2008/07/02/displaying-auth-error-messages/feed/</wfw:commentRss>
		</item>
		<item>
		<title>jQuery plugin to print HTML forms</title>
		<link>http://www.flipflops.org/2008/06/03/jquery-plugin-to-print-html-forms/</link>
		<comments>http://www.flipflops.org/2008/06/03/jquery-plugin-to-print-html-forms/#comments</comments>
		<pubDate>Tue, 03 Jun 2008 20:09:19 +0000</pubDate>
		<dc:creator>Flipflops</dc:creator>
		
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.flipflops.org/2008/06/03/jquery-plugin-to-print-html-forms/</guid>
		<description><![CDATA[Recently for a project, a client wanted to be able to print pages from a web application that were just forms. This was never intended when the application was originally built, so there were no separate view screens of data. Naively I thought this would be easy - knock up a print style sheet and [...]]]></description>
			<content:encoded><![CDATA[<p>Recently for a project, a client wanted to be able to print pages from a web application that were just forms. This was never intended when the application was originally built, so there were no separate view screens of data. Naively I thought this would be easy - knock up a print style sheet and bob&#8217;s your uncle&#8230; if only.</p>
<p>There are a couple of problems that just aren&#8217;t really fixable using a pure CSS solution, firstly &lt;select&gt; menus look pretty horrible no matter what you to them and &lt;textarea&gt; fields look fairly bad, but even worse than their aesthetic merits (or lack of rather) is the fact that the overflowing content i.e. the content that you need to scroll to see, will not be printed.</p>
<p>In the end for the application I ended up adding views, but it got me thinking and so I&#8217;ve written a quick jQuery plugin to print forms. It works by looking for any &lt;select&gt; menus or  &lt;textarea&gt; fields and replacing them with &lt;div&gt; tags styled to look like form elements. When you click on one of the &lt;div&gt;s to edit it, it reverts to the original form element and when it looses the focus (using the jQuery blur() method) the field is swapped back and replaced by the &lt;div&gt;.</p>
<p>When you come to print the form because all of the &lt;select&gt; menus and  &lt;textarea&gt; fields have been replaced by &lt;div&gt;s you can style them as you want using a print style sheet and get a nice looking form with no missing content.</p>
<p><strong>Have a look at the <a href="http://www.flipflops.org/example/print-form.html">working example</a> and view source to see how to use it.</strong></p>
<p><strong><a href='http://www.flipflops.org/wp-content/uploads/2008/06/print-form.zip' title='printform plugin'>download printform plugin example</a></strong></p>
<p>You will want to edit / write CSS for both screen and print appropriate to your situation.<br />
Tested on IE6, IE7, Firefox 2.0.</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
</pre></td><td class="code"><pre class="javascript">&nbsp;
<span style="color: #009900; font-style: italic;">/*
 * printform 1.0
 * By John Elliott (http://www.flipflops.org)
 * Copyright (c) 2008 John Elliott
 * Licensed under the MIT License: http://www.opensource.org/licenses/mit-license.php
*/</span>
&nbsp;
<span style="color: #009900; font-style: italic;">/**
 * convert textareas and select tags to divs so that you HTML forms can be printed.
 *
 *
 *
 * @name printform
 * @type jQuery
 * @author John Elliott (http://www.flipflops.org)
 * @desc 
 * 
 * @example $('#tester').printform();
 * @desc call the plugin on #tester - any select or textareas will be replaced
 *
 * @param settings - not used, but included for future proofing! (I'm sure there will be options sometime...)
 *
*/</span>
&nbsp;
jQuery.<span style="color: #006600;">fn</span>.<span style="color: #006600;">printform</span> = <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>settings<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
	<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">each</span><span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">new</span> jQuery.<span style="color: #006600;">printform</span><span style="color: #66cc66;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>, settings<span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
jQuery.<span style="color: #006600;">printform</span> = <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>obj, settings<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
  	<span style="color: #009900; font-style: italic;">/*
  	* within a parent object - replace the textareas and select menus
  	*/</span>
&nbsp;
&nbsp;
 	init<span style="color: #66cc66;">&#40;</span>obj, <span style="color: #3366CC;">'textarea'</span><span style="color: #66cc66;">&#41;</span>;
	init<span style="color: #66cc66;">&#40;</span>obj, <span style="color: #3366CC;">'select'</span><span style="color: #66cc66;">&#41;</span>;	
&nbsp;
&nbsp;
	<span style="color: #003366; font-weight: bold;">function</span> init<span style="color: #66cc66;">&#40;</span>obj, fieldType<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
	<span style="color: #009900; font-style: italic;">/*
	* loop through each instance of an element within the parent 
	*/</span>
&nbsp;
		obj = jQuery<span style="color: #66cc66;">&#40;</span>obj<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">attr</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'id'</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
		jQuery<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'#'</span> + obj + <span style="color: #3366CC;">' '</span> + fieldType<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">each</span><span style="color: #66cc66;">&#40;</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
			<span style="color: #003366; font-weight: bold;">var</span> id = jQuery<span style="color: #66cc66;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">attr</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'id'</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
			field_replacer<span style="color: #66cc66;">&#40;</span>id, fieldType<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>		
&nbsp;
&nbsp;
	<span style="color: #003366; font-weight: bold;">function</span> field_replacer<span style="color: #66cc66;">&#40;</span>id, fieldType<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
	<span style="color: #009900; font-style: italic;">/*
	* function to replace the elements with divs
	*/</span>
&nbsp;
			str = jQuery<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'#'</span> + id<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">val</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			str = str.<span style="color: #006600;">replace</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066FF;">/\n/g</span>, <span style="color: #3366CC;">'&lt;br /&gt;'</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
			<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span> jQuery<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'#replace-'</span> + id<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">length</span> &gt; <span style="color: #CC0000;">0</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
				<span style="color: #009900; font-style: italic;">// if a replacement div already exists for this element, then just show it.</span>
				<span style="color: #009900; font-style: italic;">// update the content of the replacer with the edited content</span>
				jQuery<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'#replace-'</span> + id<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">html</span><span style="color: #66cc66;">&#40;</span>str<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">show</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;			
			<span style="color: #66cc66;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #66cc66;">&#123;</span>
				<span style="color: #009900; font-style: italic;">// otherwise create a new replacement div for the element</span>
				jQuery<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'#'</span> + id<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">after</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'&lt;div class=&quot;'</span> + fieldType + <span style="color: #3366CC;">'-replace&quot; id=&quot;replace-'</span> + id + <span style="color: #3366CC;">'&quot;&gt;'</span> + str + <span style="color: #3366CC;">'&lt;/div&gt;'</span><span style="color: #66cc66;">&#41;</span>;			
			<span style="color: #66cc66;">&#125;</span>
&nbsp;
			jQuery<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'#'</span> + id<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">hide</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #009900; font-style: italic;">// hide the element that has just been replaced</span>
			field_watcher<span style="color: #66cc66;">&#40;</span>id, fieldType<span style="color: #66cc66;">&#41;</span>; <span style="color: #009900; font-style: italic;">// add event listeners</span>
	<span style="color: #66cc66;">&#125;</span>											
&nbsp;
	<span style="color: #003366; font-weight: bold;">function</span> field_watcher<span style="color: #66cc66;">&#40;</span>id,  fieldType<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
	<span style="color: #009900; font-style: italic;">/*
	* add listeners to the elements
	* onclick - show the original element and hide the replacer
	* onblur - call the field_replacer to update the page
	*/</span>
&nbsp;
		jQuery<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'#replace-'</span> + id<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">click</span><span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
		jQuery<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'#'</span> + id<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">show</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #000066;">focus</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		jQuery<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'#replace-'</span> + id<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">hide</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
		jQuery<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'#'</span> + id<span style="color: #66cc66;">&#41;</span>.<span style="color: #000066;">blur</span><span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
			field_replacer<span style="color: #66cc66;">&#40;</span>id,  fieldType<span style="color: #66cc66;">&#41;</span>;								
&nbsp;
		<span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>;</pre></td></tr></table></div>

<p>Thanks to to Mike Alsup for his great (if rather daunting) guide to writing plugins on <a href="http://www.learningjquery.com/2007/10/a-plugin-development-pattern/trackback">Learning jQuery</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flipflops.org/2008/06/03/jquery-plugin-to-print-html-forms/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Flowers</title>
		<link>http://www.flipflops.org/2008/05/13/flowers/</link>
		<comments>http://www.flipflops.org/2008/05/13/flowers/#comments</comments>
		<pubDate>Tue, 13 May 2008 14:33:46 +0000</pubDate>
		<dc:creator>Flipflops</dc:creator>
		
		<category><![CDATA[Stuff]]></category>

		<guid isPermaLink="false">http://www.flipflops.org/2008/05/13/flowers/</guid>
		<description><![CDATA[


]]></description>
			<content:encoded><![CDATA[<ul class="flip_gallery_main">
<li><a href="/gallery/flowers/"><img src="/wp-content/flip_gallery/flower.jpg" height="364" width="402" alt="Flowers" /></a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.flipflops.org/2008/05/13/flowers/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Finding overlapping dates and times in MySQL</title>
		<link>http://www.flipflops.org/2008/05/01/finding-overlapping-dates-and-times-in-mysql/</link>
		<comments>http://www.flipflops.org/2008/05/01/finding-overlapping-dates-and-times-in-mysql/#comments</comments>
		<pubDate>Thu, 01 May 2008 21:04:40 +0000</pubDate>
		<dc:creator>Flipflops</dc:creator>
		
		<category><![CDATA[Web Things]]></category>

		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.flipflops.org/2008/05/01/finding-overlapping-dates-and-times-in-mysql/</guid>
		<description><![CDATA[Quite often you end up in situations where you are required to check and see if one time period overlaps another time period. Probably the most common situation this occurs in is when you are building a booking system - be it for tables or cars or rooms.
You have a series of entries in a [...]]]></description>
			<content:encoded><![CDATA[<p>Quite often you end up in situations where you are required to check and see if one time period overlaps another time period. Probably the most common situation this occurs in is when you are building a booking system - be it for tables or cars or rooms.</p>
<p>You have a series of entries in a database with a start (date)time and an end (date)time and before adding a new record you need to check that it doesn&#8217;t overlap with another booking.</p>
<p>The solution is fairly simple but I always end up making a quick diagram on a piece of paper to check.</p>
<p><img src='http://www.flipflops.org/wp-content/uploads/2008/05/mysql_times.gif' width="300px" alt='Time overlapping diagram' /></p>
<p>As you can see two time periods can either be sequential (i.e. there is no overlap at all) or they can overlap in one of four ways. Put this into a diagram and the solution becomes pretty obvious.</p>
<p>There is an overlap if <strong>end_time_1 > start_time_2 AND start_time_1 < end_time_2</strong></p>
<table class="exam_table mtable">
<tr>
<th scope="col">Time</th>
<th scope="col">start_1 </th>
<th scope="col">start_2 </th>
<th scope="col">end_1 </th>
<th scope="col">end_2 </th>
<th scope="col">end_1 &gt; start_2 </th>
<th scope="col">start_1 &lt; end_2 </th>
</tr>
<tr>
<th scope="row">1</th>
<td>09:00</td>
<td>08:00</td>
<td>11:00</td>
<td>10:00</td>
<td>true</td>
<td>true</td>
</tr>
<tr>
<th scope="row">2</th>
<td>09:00</td>
<td>10:00</td>
<td>11:00</td>
<td>12:00</td>
<td>true</td>
<td>true</td>
</tr>
<tr>
<th scope="row">3</th>
<td>09:00</td>
<td>08:00</td>
<td>11:00</td>
<td>12:00</td>
<td>true</td>
<td>true</td>
</tr>
<tr>
<th scope="row">4</th>
<td>09:00</td>
<td>09:30</td>
<td>11:00</td>
<td>10:30</td>
<td>true</td>
<td>true</td>
</tr>
<tr>
<th scope="row">5</th>
<td>09:00</td>
<td>07:00</td>
<td>11:00</td>
<td>08:00</td>
<td>false</td>
<td>true</td>
</tr>
<tr>
<th scope="row">6</th>
<td>09:00</td>
<td>12:00</td>
<td>11:00</td>
<td>13:00</td>
<td>true</td>
<td>false</td>
</tr>
</table>
<p>An example SQL query would be something like the one below but make sure your <a href="http://dev.mysql.com/doc/refman/5.0/en/datetime.html">datetime formats are correct</a> - in MySQL the default format is YYYY-MM-DD hh:mm:ss</p>

<div class="wp_syntax"><div class="code"><pre class="mysql">&nbsp;
<span style="color: #993333; font-weight: bold;">SELECT</span> * <span style="color: #993333; font-weight: bold;">FROM</span> bookings <span style="color: #993333; font-weight: bold;">WHERE</span> room_id = <span style="color: #ff0000;">'&quot; . $room_id . &quot;'</span> <span style="color: #993333; font-weight: bold;">AND</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>date_end &gt; <span style="color: #ff0000;">'&quot; . $start_date . &quot;'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">AND</span> <span style="color: #66cc66;">&#40;</span>date_start &lt; <span style="color: #ff0000;">'&quot; . $end_date . &quot;'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #ff0000;">&quot;;</span></pre></div></div>

<p>The above query will pull back the records where the times overlap.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flipflops.org/2008/05/01/finding-overlapping-dates-and-times-in-mysql/feed/</wfw:commentRss>
		</item>
		<item>
		<title>blinks.org.uk</title>
		<link>http://www.flipflops.org/2008/04/17/blinksorguk/</link>
		<comments>http://www.flipflops.org/2008/04/17/blinksorguk/#comments</comments>
		<pubDate>Thu, 17 Apr 2008 20:54:20 +0000</pubDate>
		<dc:creator>Flipflops</dc:creator>
		
		<category><![CDATA[Web Things]]></category>

		<guid isPermaLink="false">http://www.flipflops.org/2008/04/17/blinksorguk/</guid>
		<description><![CDATA[Lately I&#8217;ve have taken a little bit of time out from Art-Thing and have been working on a smaller side project called www.blinks.org.uk
I&#8217;ve been using this as a bit of a test bed for various aspects of Art-Thing but it is also a fun little project in its own right. AND even better it should [...]]]></description>
			<content:encoded><![CDATA[<p>Lately I&#8217;ve have taken a little bit of time out from Art-Thing and have been working on a smaller side project called <a title="Finding a business in the UK - made simple" href="http://www.blinks.org.uk">www.blinks.org.uk</a></p>
<p>I&#8217;ve been using this as a bit of a test bed for various aspects of <a title="Galleries, Exhibitions and Reviews" href="http://www.art-thing.co.uk">Art-Thing</a> but it is also a fun little project in its own right. AND even better it should be ready <strong><em>very</em></strong> soon, it is a directory of UK businesses and services with a pretty flat structure based on tagging and regions. Fast, easy to use and fun (if a business directory can be fun).</p>
<p>The site is almost ready to launch and the whole process from the first ideas until now has been very quick - it is built in CakePHP 1.2 and jQuery which make coding a pleasure again. It&#8217;s also fun to do a bit of design for a change instead of just the stuff under the hood.</p>
<p>Here is a sneak preview:</p>
<p><img src='http://www.flipflops.org/wp-content/uploads/2008/04/blinks2.gif' alt='blinks.org.uk'  width="450" /></p>
<p>If you own or manage a business in the UK why not sign up for FREE with blinks.org.uk and see how it can help your business.</p>
<p>blinks.org.uk is a brand new directory of businesses and services based in the UK.</p>
<p>Every entry in the directory is approved by a real person and businesses have to provide their actual address so the directory is completely spam free and only contains quality listings.</p>
<ul>
<li> Link back to your website (great for SEO)</li>
<li>
          Add a description of your business or service</li>
<li>Add an image or company logo</li>
<li>Update your entry whenever you want</li>
<li>Add you business or service to multiple categories</li>
<li>Add tags (keywords) - that are right just for you</li>
<li>Automatically show your location on our map</li>
</ul>
<p><img  src="http://artthing.wordpress.com/files/2008/04/blinks.gif" alt="Finding a business in the UK - made simple" width="450" height="276" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.flipflops.org/2008/04/17/blinksorguk/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
