<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>What A Wonderful Web - The online portfolio of Craig Morris</title>
	
	<link>http://waww.com.au</link>
	<description>Welcome to &lt;strong&gt;What A Wonderful Web&lt;/strong&gt; (aka Craig Morris). See my &lt;strong&gt;work below&lt;/strong&gt; and my &lt;strong&gt;skills above&lt;/strong&gt;. Impressed? Phone me on 0422 174 194 or email me &lt;a href="mailto:craig@waww.com.au"&gt;craig@waww.com.au&lt;/a&gt;.&lt;br /&gt;&lt;span style="font-size: 13px;"&gt;(you could also check out my &lt;a href="/category/ramblings"&gt;blog posts&lt;/a&gt; or &lt;a href="/projects"&gt;open source projects&lt;/a&gt;)&lt;/span&gt;</description>
	<lastBuildDate>Tue, 03 Nov 2009 12:52:37 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/what-a-wonderful-web" /><feedburner:info uri="what-a-wonderful-web" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:browserFriendly></feedburner:browserFriendly><item>
		<title>POCS Widget</title>
		<link>http://waww.com.au/portfolio/flash-actionscript/pocs-widget</link>
		<comments>http://waww.com.au/portfolio/flash-actionscript/pocs-widget#comments</comments>
		<pubDate>Tue, 03 Nov 2009 12:46:42 +0000</pubDate>
		<dc:creator>Craig</dc:creator>
				<category><![CDATA[Flash & Actionscript]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[cakephp]]></category>
		<category><![CDATA[remoting]]></category>
		<category><![CDATA[widget]]></category>

		<guid isPermaLink="false">http://waww.com.au/?p=649</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<div><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="300" height="250"><param name="allowScriptAccess" value="always"><param name="movie" value="http://www.protectourcoralsea.org.au/swf/widget.swf"><param name="quality" value="high"><embed allowScriptAccess="always" src="http://www.protectourcoralsea.org.au/swf/widget.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="300" height="250"></embed></object></div>
]]></content:encoded>
			<wfw:commentRss>http://waww.com.au/portfolio/flash-actionscript/pocs-widget/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Determine state from postcode in Australia</title>
		<link>http://waww.com.au/ramblings/determine-state-from-postcode-in-australia</link>
		<comments>http://waww.com.au/ramblings/determine-state-from-postcode-in-australia#comments</comments>
		<pubDate>Thu, 01 Oct 2009 06:58:09 +0000</pubDate>
		<dc:creator>Craig</dc:creator>
				<category><![CDATA[Ramblings]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[postcodes]]></category>

		<guid isPermaLink="false">http://waww.com.au/?p=644</guid>
		<description><![CDATA[I had a little dilemma where I was importing a list of stores, but a required field was state. I had the postcodes for all these stores so I figured I could determine the state. I&#8217;ve dealt with postcode data before but I really couldn&#8217;t be bothered downloading that database from Australia Post (it&#8217;s pretty [...]]]></description>
			<content:encoded><![CDATA[<p>I had a little dilemma where I was importing a list of stores, but a required field was state. I had the postcodes for all these stores so I figured I could determine the state. I&#8217;ve dealt with postcode data before but I really couldn&#8217;t be bothered downloading that database from Australia Post (it&#8217;s pretty big). I&#8217;ve always known that postcodes starting with 2 are in NSW, 3 are in VIC, 4 are in QLD etc. so I set out to find what exactly determines the state from postcode.</p>
<p>The result was this article <a href="http://en.wikipedia.org/wiki/Postcodes_in_Australia#States_and_territories">http://en.wikipedia.org/wiki/Postcodes_in_Australia#States_and_territories</a></p>
<p>And the PHP function is:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">	<span style="color: #009933; font-style: italic;">/**
	/**
	* Returns the state for a postcode.
	* eg. NSW
	* 
	* @link http://en.wikipedia.org/wiki/Postcodes_in_Australia#States_and_territories
	*/</span>
	<span style="color: #000000; font-weight: bold;">function</span> findState<span style="color: #009900;">&#40;</span><span style="color: #000088;">$postcode</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$ranges</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
			<span style="color: #0000ff;">'NSW'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
				<span style="color: #cc66cc;">1000</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1999</span><span style="color: #339933;">,</span>
				<span style="color: #cc66cc;">2000</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2599</span><span style="color: #339933;">,</span>
				<span style="color: #cc66cc;">2619</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2898</span><span style="color: #339933;">,</span>
				<span style="color: #cc66cc;">2921</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2999</span>
			<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'ACT'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
				<span style="color: #cc66cc;">200</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">299</span><span style="color: #339933;">,</span>
				<span style="color: #cc66cc;">2600</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2618</span><span style="color: #339933;">,</span>
				<span style="color: #cc66cc;">2900</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2920</span>
			<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'VIC'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
				<span style="color: #cc66cc;">3000</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">3999</span><span style="color: #339933;">,</span>
				<span style="color: #cc66cc;">8000</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">8999</span>
			<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'QLD'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
				<span style="color: #cc66cc;">4000</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">4999</span><span style="color: #339933;">,</span>
				<span style="color: #cc66cc;">9000</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">9999</span>
			<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'SA'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
				<span style="color: #cc66cc;">5000</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">5999</span>
			<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'WA'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
				<span style="color: #cc66cc;">6000</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">6797</span><span style="color: #339933;">,</span>
				<span style="color: #cc66cc;">6800</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">6999</span>
			<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'TAS'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
				<span style="color: #cc66cc;">7000</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">7999</span>
			<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'NT'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
				<span style="color: #cc66cc;">800</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">999</span>
			<span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$exceptions</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
			<span style="color: #cc66cc;">872</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'NT'</span><span style="color: #339933;">,</span>
			<span style="color: #cc66cc;">2540</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'NSW'</span><span style="color: #339933;">,</span>
			<span style="color: #cc66cc;">2611</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'ACT'</span><span style="color: #339933;">,</span>
			<span style="color: #cc66cc;">2620</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'NSW'</span><span style="color: #339933;">,</span>
			<span style="color: #cc66cc;">3500</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'VIC'</span><span style="color: #339933;">,</span>
			<span style="color: #cc66cc;">3585</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'VIC'</span><span style="color: #339933;">,</span>
			<span style="color: #cc66cc;">3586</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'VIC'</span><span style="color: #339933;">,</span>
			<span style="color: #cc66cc;">3644</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'VIC'</span><span style="color: #339933;">,</span>
			<span style="color: #cc66cc;">3707</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'VIC'</span><span style="color: #339933;">,</span>
			<span style="color: #cc66cc;">2899</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'NSW'</span><span style="color: #339933;">,</span>
			<span style="color: #cc66cc;">6798</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'WA'</span><span style="color: #339933;">,</span>
			<span style="color: #cc66cc;">6799</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'WA'</span><span style="color: #339933;">,</span>
			<span style="color: #cc66cc;">7151</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'TAS'</span>
		<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$postcode</span> <span style="color: #339933;">=</span> <span style="color: #990000;">intval</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$postcode</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">array_key_exists</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$postcode</span><span style="color: #339933;">,</span> <span style="color: #000088;">$exceptions</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #000088;">$exceptions</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$postcode</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$ranges</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$state</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$range</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$c</span> <span style="color: #339933;">=</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$range</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$c</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">+=</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$min</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$range</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
				<span style="color: #000088;">$max</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$range</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">1</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: #000088;">$postcode</span> <span style="color: #339933;">&gt;=</span> <span style="color: #000088;">$min</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$postcode</span> <span style="color: #339933;">&lt;=</span> <span style="color: #000088;">$max</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #b1b100;">return</span> <span style="color: #000088;">$state</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://waww.com.au/ramblings/determine-state-from-postcode-in-australia/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Zaditen</title>
		<link>http://waww.com.au/portfolio/content-management/zaditen</link>
		<comments>http://waww.com.au/portfolio/content-management/zaditen#comments</comments>
		<pubDate>Thu, 01 Oct 2009 06:50:43 +0000</pubDate>
		<dc:creator>Craig</dc:creator>
				<category><![CDATA[Content Management]]></category>
		<category><![CDATA[Website Development]]></category>
		<category><![CDATA[baked simple]]></category>
		<category><![CDATA[geotagging]]></category>
		<category><![CDATA[store finder]]></category>

		<guid isPermaLink="false">http://waww.com.au/?p=640</guid>
		<description><![CDATA[Freckle designed and scoped a good looking, straight to the point information website that allowed users to get information about the product and learn where to buy it. The site uses 3 templates of varying complexity, which are loaded up into the content management system, Baked Simple. Baked Simple isn&#8217;t sizeist, it can handle any [...]]]></description>
			<content:encoded><![CDATA[<p>Freckle designed and scoped a good looking, straight to the point information website that allowed users to get information about the product and learn where to buy it. The site uses 3 templates of varying complexity, which are loaded up into the content management system, Baked Simple. Baked Simple isn&#8217;t sizeist, it can handle any amount of fields in any template. The product page on this one had fields for description, image, also available products and instructions.</p>
<p>The pharmacy locator takes the postcode of the user and plots the 5 nearest pharmacies on a map for the user to see. The technology behind this maps each pharmacy address to latitude and longitudes, maps the postcodes main latitude and longitude and then uses some advanced mathematical calculations to calculate the distance (it&#8217;s not as simple as trigonometry, although it would of been before <a href="http://en.wikipedia.org/wiki/Flat_Earth">this</a> was proven wrong). This means that even if you hard pharmacies in a different locale (a lot of store locators match a postcode to a locale and then simply return all stores in that locale), state or country the closest 5 will always be returned.</p>
]]></content:encoded>
			<wfw:commentRss>http://waww.com.au/portfolio/content-management/zaditen/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Paperartzi</title>
		<link>http://waww.com.au/portfolio/ecommerce/paperartzi</link>
		<comments>http://waww.com.au/portfolio/ecommerce/paperartzi#comments</comments>
		<pubDate>Mon, 28 Sep 2009 02:10:29 +0000</pubDate>
		<dc:creator>Craig</dc:creator>
				<category><![CDATA[eCommerce]]></category>
		<category><![CDATA[integration]]></category>
		<category><![CDATA[magento]]></category>
		<category><![CDATA[themes]]></category>

		<guid isPermaLink="false">http://waww.com.au/?p=636</guid>
		<description><![CDATA[Almost every kid on the block wants to run their own online store and why wouldn&#8217;t you? Your tapping into an international market and thanks to open source software out there, you can get it done on the cheap. Paperartzi contacted me about setting up an online store with a limited budget but with also [...]]]></description>
			<content:encoded><![CDATA[<p>Almost every kid on the block wants to run their own online store and why wouldn&#8217;t you? Your tapping into an international market and thanks to open source software out there, you can get it done on the cheap. Paperartzi contacted me about setting up an online store with a limited budget but with also complicated requirements.</p>
<p>The job involved a front website which could be used as informational purposes and then also a shop which could accept payments online. Magento was used as the platform for the online store and a custom Magento theme was developed which would match the look &amp; feel of the front website. The online store also integrates with Australia Post for delivery costs and PayPal for processing order payments.</p>
<p>The front website also integrates inside the Magento category structure and allows the front website to display categories from the shop, this provides multiple gateways into the shop to promote more purchases.</p>
]]></content:encoded>
			<wfw:commentRss>http://waww.com.au/portfolio/ecommerce/paperartzi/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Protect Our Coral Sea</title>
		<link>http://waww.com.au/portfolio/content-management/protect-our-coral-sea</link>
		<comments>http://waww.com.au/portfolio/content-management/protect-our-coral-sea#comments</comments>
		<pubDate>Fri, 25 Sep 2009 07:57:54 +0000</pubDate>
		<dc:creator>Craig</dc:creator>
				<category><![CDATA[Content Management]]></category>
		<category><![CDATA[Email Marketing]]></category>
		<category><![CDATA[Specifications]]></category>
		<category><![CDATA[Website Development]]></category>
		<category><![CDATA[baked simple]]></category>
		<category><![CDATA[cakephp]]></category>
		<category><![CDATA[campaign]]></category>
		<category><![CDATA[google maps]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://waww.com.au/?p=630</guid>
		<description><![CDATA[Designed to raise awareness about the dangers that Australia&#8217;s coral sea is facing. The site&#8217;s design is visually stunning and I faced real problems getting the transparent PNG&#8217;s to work correctly in IE6. After discussing it with the client, they agreed to degrade gracefully for IE6 and have a less visually stunning design and urged [...]]]></description>
			<content:encoded><![CDATA[<p>Designed to raise awareness about the dangers that Australia&#8217;s coral sea is facing. The site&#8217;s design is visually stunning and I faced real problems getting the transparent PNG&#8217;s to work correctly in IE6. After discussing it with the client, they agreed to degrade gracefully for IE6 and have a less visually stunning design and urged the visitor to upgrade their browser.</p>
<p>The site runs off the same Content Management System as Without Surgery, Skills Connect. The CMS allows the updating of videos, images, menus and more. They can even update the location of the coral see on the Google map (even though I don&#8217;t think it&#8217;s going anywhere sometime soon). The site also utilises caching to provide maximum performance when under heavy load, especially when the television commercial comes in late September.</p>
<p>In addition, the site is also integrated with Campaign Monitor.</p>
]]></content:encoded>
			<wfw:commentRss>http://waww.com.au/portfolio/content-management/protect-our-coral-sea/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>View Harvest invoices with your iPhone</title>
		<link>http://waww.com.au/ramblings/view-harvest-invoices-with-your-iphone</link>
		<comments>http://waww.com.au/ramblings/view-harvest-invoices-with-your-iphone#comments</comments>
		<pubDate>Fri, 25 Sep 2009 02:30:22 +0000</pubDate>
		<dc:creator>Craig</dc:creator>
				<category><![CDATA[Ramblings]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[harvest]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[jqtouch]]></category>

		<guid isPermaLink="false">http://waww.com.au/?p=626</guid>
		<description><![CDATA[Invoices are at the core of every business, it&#8217;s what drives the money into any freelance / business gig. Harvest is awesome for tracking time, invoices and estimates. Unfortunately their iPhone support is limited to time tracking, but really I care about money and so I needed an iPhone interface for invoices ASAP.
So last night [...]]]></description>
			<content:encoded><![CDATA[<p>Invoices are at the core of every business, it&#8217;s what drives the money into any freelance / business gig. Harvest is awesome for tracking time, invoices and estimates. Unfortunately their iPhone support is limited to time tracking, but really I care about money and so I needed an iPhone interface for invoices ASAP.</p>
<p>So last night I mashed up a quick web app which used <a href="http://www.jqtouch.com/">jqTouch</a> and the <a href="http://www.getharvest.com/api/">Harvest API</a>. Now I can check my invoices from anywhere, and I abstracted it enough so anybody out there can use it.</p>
<p>Check it out (on your iPhone) at <a href="http://scripts.waww.com.au/harvest_invoices">http://scripts.waww.com.au/harvest_invoices</a></p>
]]></content:encoded>
			<wfw:commentRss>http://waww.com.au/ramblings/view-harvest-invoices-with-your-iphone/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>No domain? No problems! Fallback translations in CakePHP</title>
		<link>http://waww.com.au/ramblings/no-domain-no-problems-fallback-translations-in-cakephp</link>
		<comments>http://waww.com.au/ramblings/no-domain-no-problems-fallback-translations-in-cakephp#comments</comments>
		<pubDate>Sun, 13 Sep 2009 07:37:32 +0000</pubDate>
		<dc:creator>Craig</dc:creator>
				<category><![CDATA[Ramblings]]></category>
		<category><![CDATA[cakephp]]></category>
		<category><![CDATA[i18n]]></category>

		<guid isPermaLink="false">http://waww.com.au/?p=621</guid>
		<description><![CDATA[A common methodology in CakePHP is that if something doesn&#8217;t exist somewhere, it will look in the next logical spot until it finds it. This is evident with themed views, controllers, models, basically everything in the framework. That&#8217;s why I was a little bit suprised dismorning when I was looking into translations within a domain. [...]]]></description>
			<content:encoded><![CDATA[<p>A common methodology in CakePHP is that if something doesn&#8217;t exist somewhere, it will look in the next logical spot until it finds it. This is evident with themed views, controllers, models, basically everything in the framework. That&#8217;s why I was a little bit suprised dismorning when I was looking into translations within a domain. If the phrase didn&#8217;t exist in the domain then it would simply return the original string, without looking inside the default domain.</p>
<p>So I came up with a function that would first look inside the custom domain and if nothing was found then it would naturally work inside the default domain. The function is named __dd(), which is short for default domain.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
 * Allows you to override the current domain for a single message lookup.
 * If the msg doesn't exist in the current domain, it will use the default
 * domain.
 *
 * @param string $domain Domain
 * @param string $msg String to translate
 * @param string $return true to return, false to echo
 * @return translated string if $return is false string will be echoed
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> __dd<span style="color: #009900;">&#40;</span><span style="color: #000088;">$domain</span><span style="color: #339933;">,</span> <span style="color: #000088;">$msg</span><span style="color: #339933;">,</span> <span style="color: #000088;">$return</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>
	<span style="color: #000088;">$d</span> <span style="color: #339933;">=</span> __d<span style="color: #009900;">&#40;</span><span style="color: #000088;">$domain</span><span style="color: #339933;">,</span> <span style="color: #000088;">$msg</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$d</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$msg</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> __<span style="color: #009900;">&#40;</span><span style="color: #000088;">$msg</span><span style="color: #339933;">,</span> <span style="color: #000088;">$return</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$return</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$d</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: #b1b100;">echo</span> <span style="color: #000088;">$d</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>I&#8217;m not sure why the CakePHP gods haven&#8217;t done it this way, I&#8217;m pretty sure there would be a reason though. The idea came to me with the recent feature addition of domains to my <a href="http://github.com/morrislaptop/settings">settings plugin</a> (<a href="http://wiki.github.com/morrislaptop/settings">documentation</a>).</p>
]]></content:encoded>
			<wfw:commentRss>http://waww.com.au/ramblings/no-domain-no-problems-fallback-translations-in-cakephp/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CakePHP custom error class doesn’t work when providing translations</title>
		<link>http://waww.com.au/ramblings/cakephp-custom-error-class-doesnt-work-when-providing-translations</link>
		<comments>http://waww.com.au/ramblings/cakephp-custom-error-class-doesnt-work-when-providing-translations#comments</comments>
		<pubDate>Wed, 09 Sep 2009 11:43:26 +0000</pubDate>
		<dc:creator>Craig</dc:creator>
				<category><![CDATA[Ramblings]]></category>
		<category><![CDATA[cakephp]]></category>
		<category><![CDATA[fixes]]></category>
		<category><![CDATA[uniform]]></category>

		<guid isPermaLink="false">http://waww.com.au/?p=612</guid>
		<description><![CDATA[So today I was trying to make a form that was friendly between CakePHP and UniForm. Things were going really well, I created a standard options array which converted the markup into UniForm friendly markup, it all looked good until I went to submit. Cake was somehow forgetting the error class I specified. Let&#8217;s get [...]]]></description>
			<content:encoded><![CDATA[<p>So today I was trying to make a form that was friendly between CakePHP and UniForm. Things were going really well, I created a standard options array which converted the markup into UniForm friendly markup, it all looked good until I went to submit. Cake was somehow forgetting the error class I specified. Let&#8217;s get to some examples&#8230;</p>
<p><strong>The Model Validation Rules</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">class</span> Product <span style="color: #000000; font-weight: bold;">extends</span> AppModel <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$name</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Product'</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$validate</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
	    <span style="color: #0000ff;">'title'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
    		<span style="color: #0000ff;">'notEmpty'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
    			<span style="color: #0000ff;">'rule'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'notEmpty'</span>
    		<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	    <span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p><strong>The View Template</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;div class=&quot;products form&quot;&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$form</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">create</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Product'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'type'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'file'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
	&lt;fieldset&gt;
 		&lt;legend&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Add Product'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/legend&gt;
	<span style="color: #000000; font-weight: bold;">&lt;?php</span>
		<span style="color: #000088;">$options</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
			<span style="color: #0000ff;">'error'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
				<span style="color: #0000ff;">'class'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'errorField'</span><span style="color: #339933;">,</span>
				<span style="color: #0000ff;">'email'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Please enter a product title'</span>
			<span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$form</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">input</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'title'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$options</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">element</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'attachments'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'plugin'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'media'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #000000; font-weight: bold;">?&gt;</span>
	&lt;/fieldset&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$form</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">end</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Submit'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;/div&gt;
&lt;div class=&quot;actions&quot;&gt;
	&lt;ul&gt;
		&lt;li&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$html</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">link</span><span style="color: #009900;">&#40;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'List Products'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'action'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'index'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/li&gt;
	&lt;/ul&gt;
&lt;/div&gt;</pre></div></div>

<p>Which, when submitting the form with an empty product title would you give the error message of &#8220;Please enter a product title&#8221; inside a div with the class &#8220;errorField&#8221;, however Cake forgets the custom error class and gives the &#8220;error-message&#8221; class.</p>
<p><strong>What Happened?</strong></p>
<p>I got this code&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;div class=&quot;input text error&quot;&gt;
    &lt;label for=&quot;ProductTitle&quot;&gt;Title&lt;/label&gt;
    &lt;input type=&quot;text&quot; class=&quot;form-error&quot; id=&quot;ProductTitle&quot; value=&quot;&quot; maxlength=&quot;255&quot; name=&quot;data[Product][title]&quot;/&gt;
    &lt;div class=&quot;error-message&quot;&gt;Please enter a product title&lt;/div&gt;
&lt;/div&gt;</pre></div></div>

<p><strong>What was expected?</strong></p>
<p>This&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;div class=&quot;input text error&quot;&gt;
    &lt;label for=&quot;ProductTitle&quot;&gt;Title&lt;/label&gt;
    &lt;input type=&quot;text&quot; class=&quot;form-error&quot; id=&quot;ProductTitle&quot; value=&quot;&quot; maxlength=&quot;255&quot; name=&quot;data[Product][title]&quot;/&gt;
    &lt;div class=&quot;errorField&quot;&gt;Please enter a product title&lt;/div&gt;
&lt;/div&gt;</pre></div></div>

<p><strong>The Fix</strong></p>
<p>After looking through the core code, I traced the problem down into the error function of the FormHelper. The input() function only passes the $field name and the $text variable as the options submitted in the original &#8220;error&#8221; key to the options passed to the input() function.</p>
<p>In the error function, if the $text array contains the key of the error type, then it disregards the rest of the $text array, forgetting the custom error class. What we need to do is set the $options variable to $text if it is in array, as well as pull the custom message for the error type, kapeech? OK, I&#8217;ll just give you the code&#8230;</p>
<p><em>Before</em></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>411
412
413
414
415
416
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">is_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$error</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;">$text</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$text</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$error</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">is_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$options</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array_merge</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$options</span><span style="color: #339933;">,</span> <span style="color: #000088;">$text</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$text</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p><em>After</em></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>411
412
413
414
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">is_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$options</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array_merge</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$options</span><span style="color: #339933;">,</span> <span style="color: #000088;">$text</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$text</span> <span style="color: #339933;">=</span> <span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$error</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #000088;">$text</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$error</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">:</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>I never like touching core code so I&#8217;m hoking the cake devs will be able to get on this for the next release, and it looks like I just missed the next release, as CakePHP 1.2.5 just popped up on my reader.</p>
<p>I have submitted a ticket at <a href="http://code.cakephp.org/tickets/view/76">http://code.cakephp.org/tickets/view/76</a></p>
]]></content:encoded>
			<wfw:commentRss>http://waww.com.au/ramblings/cakephp-custom-error-class-doesnt-work-when-providing-translations/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Ever wondered where the **** that query came from in CakePHP?</title>
		<link>http://waww.com.au/ramblings/ever-wondered-where-the-that-query-came-from-in-cakephp</link>
		<comments>http://waww.com.au/ramblings/ever-wondered-where-the-that-query-came-from-in-cakephp#comments</comments>
		<pubDate>Wed, 26 Aug 2009 00:22:33 +0000</pubDate>
		<dc:creator>Craig</dc:creator>
				<category><![CDATA[Ramblings]]></category>
		<category><![CDATA[cakephp]]></category>

		<guid isPermaLink="false">http://waww.com.au/?p=607</guid>
		<description><![CDATA[I&#8217;ve always been frustrated looking at the masses of queries generated by my CakePHP applications and really wondering where they originated from. It would be extremely useful when performing debugging. Sure enough I started looking into cakephp datasources and found that I could implement a solution without even touching the core!
Something like&#8230;

I&#8217;ve released the datasource [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve always been frustrated looking at the masses of queries generated by my CakePHP applications and really wondering where they originated from. It would be extremely useful when performing debugging. Sure enough I started looking into cakephp datasources and found that I could implement a solution without even touching the core!</p>
<p>Something like&#8230;</p>
<p><a href="http://waww.com.au/wp-content/uploads/sqllog.png"><img class="size-medium wp-image-608 alignnone" title="sqllog" src="http://waww.com.au/wp-content/uploads/sqllog-500x85.png" alt="sqllog" width="500" height="85" /></a></p>
<p>I&#8217;ve released the datasource to make this happen as part of my <a href="http://github.com/morrislaptop/util/tree/master">Util plugin for CakePHP</a>. To get started <a href="http://wiki.github.com/morrislaptop/util/debug-datasource">please see the Wiki page</a>.</p>
<p>Util is just a plugin full of unrelated libraries for CakePHP, most of the code there is from other people.</p>
<p><em>Currently only for MySQL but you only have to change one line for different databases.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://waww.com.au/ramblings/ever-wondered-where-the-that-query-came-from-in-cakephp/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Skills Connect</title>
		<link>http://waww.com.au/portfolio/content-management/skills-connect</link>
		<comments>http://waww.com.au/portfolio/content-management/skills-connect#comments</comments>
		<pubDate>Fri, 19 Jun 2009 07:09:01 +0000</pubDate>
		<dc:creator>Craig</dc:creator>
				<category><![CDATA[Content Management]]></category>

		<guid isPermaLink="false">http://waww.com.au/?p=598</guid>
		<description><![CDATA[Employment Management Systems went under a rebranding process with Topia and as a result a new name and hence a new website was to be born. The specifications of the site were a stock standard content managed site with a contact form. Following the success of content management within Without Surgery, Skills Connect is the [...]]]></description>
			<content:encoded><![CDATA[<p>Employment Management Systems went under a rebranding process with Topia and as a result a new name and hence a new website was to be born. The specifications of the site were a stock standard content managed site with a contact form. Following the success of content management within <a href="/portfolio/content-management/without-surgery">Without Surgery</a>, Skills Connect is the second website to be launched with <a href="/projects/baked-simple">Baked Simple</a> (bundled with <a href="/projects/cakephp-eav">EAV</a>) and it was launched only a week later.</p>
]]></content:encoded>
			<wfw:commentRss>http://waww.com.au/portfolio/content-management/skills-connect/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
