<?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>Adventures in Keyframes and Code</title>
	<atom:link href="http://www.keyframesandcode.com/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.keyframesandcode.com/code</link>
	<description>MaxScript, ActionScript, PHP &#38; JavaScript</description>
	<lastBuildDate>Mon, 30 Aug 2010 15:12:36 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Export/import Outlook 2007 email account settings</title>
		<link>http://www.keyframesandcode.com/code/misc/export-outlook-email-account-settings/</link>
		<comments>http://www.keyframesandcode.com/code/misc/export-outlook-email-account-settings/#comments</comments>
		<pubDate>Mon, 30 Aug 2010 15:11:33 +0000</pubDate>
		<dc:creator>Dave Stewart</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.keyframesandcode.com/code/?p=293</guid>
		<description><![CDATA[I can&#8217;t believe I seem to be the only person on the web to work this one out, but here&#8217;s how you export and import email account settings between profiles &#8211; for which there is no option within Outlook itself.
First of all, open regedit32.exe from the search box in the start menu.
Then, navigate to this [...]]]></description>
			<content:encoded><![CDATA[<p>I can&#8217;t believe I seem to be the only person on the web to work this one out, but here&#8217;s how you export and import email account settings between profiles &#8211; for which there is no option within Outlook itself.</p>
<p>First of all, open regedit32.exe from the search box in the start menu.</p>
<p>Then, navigate to this key:</p>
<pre>[HKEY_USERS\S-1-5-21-xxxxxxxx-xxxxxxxx-xxxxxxxx-xxxx\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\</pre>
<p>This should be showing a list of the mail profiles you have on your machine:</p>
<p><img class="alignnone size-full wp-image-296" title="regedit-outlook-profile" src="http://www.keyframesandcode.com/code/wp-content/uploads/2010/08/regedit-outlook-profile.png" alt="regedit-outlook-profile" width="610" height="390" /></p>
<p>Navigate slightly further down the tree this time, to the key labelled:</p>
<pre>&lt;Profile Name&gt;\9375CFF0413111d3B88A00104B2A6676\</pre>
<p>This is the key that stores a list of all the email accounts in your Outlook profile:</p>
<p><img class="alignnone size-full wp-image-297" title="regedit-outlook-accounts" src="http://www.keyframesandcode.com/code/wp-content/uploads/2010/08/regedit-outlook-accounts.png" alt="regedit-outlook-accounts" width="610" height="390" /></p>
<p>To transfer these accounts to a different profile, or a different machine, do the following:</p>
<ol>
<li>export the registry branch 9375&#8230; to a new .reg file</li>
<li>open the new file in a text editor</li>
<li>do a find and replace for /&lt;Profile Name&gt;/ substituting the text between the slashes with your new profile name</li>
<li>save the reg file</li>
<li>double-click on the reg file to import it into the registry</li>
</ol>
<p>If you did everything correctly, and the named profile exists, when you reopen Outlook, and go to Tools &gt; Account settings&#8230; you should see your newly imported accounts:</p>
<p><img class="alignnone size-full wp-image-298" title="outlook-accounts" src="http://www.keyframesandcode.com/code/wp-content/uploads/2010/08/outlook-accounts.png" alt="outlook-accounts" width="521" height="424" /></p>
<p>It really does appear to be as simple as that. Yay <img src='http://www.keyframesandcode.com/code/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.keyframesandcode.com/code/misc/export-outlook-email-account-settings/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery Deconstructed</title>
		<link>http://www.keyframesandcode.com/code/development/javascript/jquery/jquery-deconstructed/</link>
		<comments>http://www.keyframesandcode.com/code/development/javascript/jquery/jquery-deconstructed/#comments</comments>
		<pubDate>Mon, 19 Jul 2010 15:08:51 +0000</pubDate>
		<dc:creator>Dave Stewart</dc:creator>
				<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.keyframesandcode.com/code/?p=258</guid>
		<description><![CDATA[UPDATE: jQuery Deconstructed is now JS Libs Deconstructed, also supporting Prototype, and soon, MooTools.
I&#8217;ve been interested in the internal structure of jQuery for as long as I can remember, but it can be overwhelming at the best of times, so I&#8217;ve recently made-good on my plan to build an interactive breakdown of the physical code.

Essentially, [...]]]></description>
			<content:encoded><![CDATA[<p><strong>UPDATE: jQuery Deconstructed is now <a href="http://www.keyframesandcode.com/resources/javascript/deconstructed/">JS Libs Deconstructed</a>, also supporting Prototype, and soon, MooTools.</strong></p>
<p>I&#8217;ve been interested in the internal structure of jQuery for as long as I can remember, but it can be overwhelming at the best of times, so I&#8217;ve recently made-good on my plan to build an interactive breakdown of the physical code.</p>
<p><a class="img" href="http://www.keyframesandcode.com/resources/javascript/deconstructed/jquery"><img src="http://www.keyframesandcode.com/code/wp-content/uploads/2010/07/visual-jquery-screenshot.gif" /></a></p>
<p>Essentially, it provides a rather handy birds-eye view of the jQuery library, making it easy to dig into and understand the coding behind the seemingly-simple syntax.</p>
<p>Points of note:</p>
<ul>
<li>It breaks the physical JavaScript into visual blocks that you can easiliy navigate.</li>
<li>Each block opens to reveal its internal code</li>
<li>Clickable hyperlinks allow you to follow program flow</li>
</ul>
<p>It now also has a few nice features such as:</p>
<ul>
<li>Live links to the online documentation</li>
<li>Color themes</li>
<li>Optional icons</li>
</ul>
<p>Check it out here: <a href="http://www.keyframesandcode.com/resources/javascript/deconstructed/">http://www.keyframesandcode.com/resources/javascript/deconstructed/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.keyframesandcode.com/code/development/javascript/jquery/jquery-deconstructed/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Excel export delimited text macro</title>
		<link>http://www.keyframesandcode.com/code/development/excel-export-tab-delimited-text-macro/</link>
		<comments>http://www.keyframesandcode.com/code/development/excel-export-tab-delimited-text-macro/#comments</comments>
		<pubDate>Fri, 30 Apr 2010 12:05:32 +0000</pubDate>
		<dc:creator>Dave Stewart</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[VBA]]></category>

		<guid isPermaLink="false">http://www.keyframesandcode.com/code/?p=252</guid>
		<description><![CDATA[I often need to save text from Excel to use with PHP, but I find Excel&#8217;s &#8220;Save As&#8221; functionality less that useful, as it converts your open worksheet to a text, which is a real pain.
This macro exports the current worksheet as a tab-delimited or comma-delimited text file, with the following features:

optionally exports the current [...]]]></description>
			<content:encoded><![CDATA[<p>I often need to save text from Excel to use with PHP, but I find Excel&#8217;s &#8220;Save As&#8221; functionality less that useful, as it converts your open worksheet to a text, which is a real pain.</p>
<p>This macro exports the current worksheet as a tab-delimited or comma-delimited text file, with the following features:</p>
<ul>
<li>optionally exports the current selection</li>
<li>outputs values as text</li>
<li>strips leading and trailing whitespace</li>
<li>quotes any cells with spaces (TSV only)</li>
<li>warns if the file is locked</li>
</ul>
<p>Here&#8217;s an example of the two file outputs:</p>
<p><b>Tab-separated values</b></p>
<pre>
id	word	words
1	hello	"hello there"
2	goodbye	"goodbye then"
3	a	"a, b, c"
</pre>
<p><b>Comma-separated values</b></p>
<pre>
id,word,words
1,hello,hello there
2,goodbye,goodby then
3,a,a, b, c
</pre>
<p><a href="http://www.keyframesandcode.com/resources/vba/Excel/ExportDelimitedText.zip">Download ExportDelimitedText</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.keyframesandcode.com/code/development/excel-export-tab-delimited-text-macro/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Accurate screen-to-print sizing in Photoshop</title>
		<link>http://www.keyframesandcode.com/code/misc/accurate-screen-to-print-sizing-in-photoshop/</link>
		<comments>http://www.keyframesandcode.com/code/misc/accurate-screen-to-print-sizing-in-photoshop/#comments</comments>
		<pubDate>Thu, 11 Feb 2010 14:30:19 +0000</pubDate>
		<dc:creator>Dave Stewart</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.keyframesandcode.com/code/?p=231</guid>
		<description><![CDATA[I learnt how to set up Photoshop today so that the screen displays images at the exact same size they will print out, which is great for previewing how your work will look without endless printing and reprinting.
Here&#8217;s what you do:

Note the size of your screen height in pixels (mine is 1024)
Measure the physical height [...]]]></description>
			<content:encoded><![CDATA[<p>I learnt how to set up Photoshop today so that the screen displays images at the exact same size they will print out, which is great for previewing how your work will look without endless printing and reprinting.</p>
<p>Here&#8217;s what you do:</p>
<ol>
<li>Note the size of your screen height in pixels (mine is 1024)</li>
<li>Measure the physical height of the pixel-area of your screen using a ruler (mine measured 27.0 cm exactly)</li>
<li>Divide the number of pixels by the number of centimetres (1024 / 27 = 37.925)</li>
<li>Enter this number in the Screen Resolution box under Preferences &gt; Units &amp; Rulers:</li>
</ol>
<p><img src="http://www.keyframesandcode.com/code/wp-content/uploads/2010/02/units.png" width="583" height="343" /></p>
<p>Photoshop will now display your images at the correct size when you choose View &gt; Print Size.</p>
<p>However, it&#8217;s a bit of pain to have to go to the menu option each time, but an easy solution is to simply map View &gt; Print Size to the CTRL + ` (top left key):</p>
<p><img src="http://www.keyframesandcode.com/code/wp-content/uploads/2010/02/keyboard.png" alt="keyboard" width="583" height="418" /></p>
<p>Now, you can easily swap between 100% and Print Size by alternating between CTRL+1 and CTRL+`</p>
]]></content:encoded>
			<wfw:commentRss>http://www.keyframesandcode.com/code/misc/accurate-screen-to-print-sizing-in-photoshop/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Disable password autocomplete in Firefox</title>
		<link>http://www.keyframesandcode.com/code/development/html/disable-password-autocomplete-in-firefox/</link>
		<comments>http://www.keyframesandcode.com/code/development/html/disable-password-autocomplete-in-firefox/#comments</comments>
		<pubDate>Sat, 05 Dec 2009 13:53:44 +0000</pubDate>
		<dc:creator>Dave Stewart</dc:creator>
				<category><![CDATA[HTML]]></category>

		<guid isPermaLink="false">http://www.keyframesandcode.com/code/?p=218</guid>
		<description><![CDATA[Firefox seems intent on autocompleting password fields, whether you want it to or not, which is not good for security if you&#8217;re building a web app with &#8220;old password / new password&#8221; functionality.
Luckily, I&#8217;ve found a way to trick it into not doing this.
Simply place a hidden password field, with no name, at the start [...]]]></description>
			<content:encoded><![CDATA[<p>Firefox seems intent on autocompleting password fields, whether you want it to or not, which is not good for security if you&#8217;re building a web app with &#8220;old password / new password&#8221; functionality.</p>
<p>Luckily, I&#8217;ve found a way to trick it into not doing this.</p>
<p>Simply place a hidden password field, with no name, at the start of your form:</p>
<pre>&lt;input type="password" style="display: none;"/&gt;</pre>
<p>This seems to trick firefox into thinking that this is the main password field, but as there&#8217;s no name it a) doesn&#8217;t get set and b) doesn&#8217;t get submitted.</p>
<p>Great <img src='http://www.keyframesandcode.com/code/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.keyframesandcode.com/code/development/html/disable-password-autocomplete-in-firefox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Documentor &#8211; PHP to HTML to Redmine Wiki syntax converter</title>
		<link>http://www.keyframesandcode.com/code/development/php/documentor/</link>
		<comments>http://www.keyframesandcode.com/code/development/php/documentor/#comments</comments>
		<pubDate>Thu, 23 Jul 2009 17:23:54 +0000</pubDate>
		<dc:creator>Dave Stewart</dc:creator>
				<category><![CDATA[Kohana]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.keyframesandcode.com/code/?p=204</guid>
		<description><![CDATA[Overview

I&#8217;ve released what I think is a pretty robust version of Documentor, my PHP &#62; HTML &#62; Redmine documentation app.
These are some of the nice features to make it in:
PHP

Classes, methods and properties are now supported
Excellent JavaDoc &#38; commenting conversion
Automatic grouping of properties based on comments structure

HTML

Full or partial HTML generation, with semantic markup, anchors [...]]]></description>
			<content:encoded><![CDATA[<h3>Overview</h3>
<div id="CommentBody_22508" class="CommentBody">
<p>I&#8217;ve released what I think is a pretty robust version of <a href="/resources/php/redmine/documentor/">Documentor</a>, my PHP &gt; HTML &gt; Redmine documentation app.</p>
<p>These are some of the nice features to make it in:</p>
<p><strong>PHP</strong></p>
<ul>
<li>Classes, methods and properties are now supported</li>
<li>Excellent JavaDoc &amp; commenting conversion</li>
<li>Automatic grouping of properties based on comments structure</li>
</ul>
<p><strong>HTML</strong></p>
<ul>
<li>Full or partial HTML generation, with semantic markup, anchors and full CSS support</li>
<li>Multiple structural options</li>
<li>Generation of sample code</li>
</ul>
<p><strong>Wiki format</strong></p>
<ul>
<li>Automatic conversion of almost all supported tags, including simple tables</li>
<li>Automatic link generation for external and internal links</li>
</ul>
<p><strong>UI</strong></p>
<ul>
<li>Elegant and easy-to use AJAX interface which remembers your settings between sessions</li>
<li>Sample code example included to quickly test all the features</li>
<li>Live preview of HTML results</li>
</ul>
<h3>Check it out</h3>
<p>It&#8217;s now got its own project page, so you can file issues or suggestions there:</p>
<p><a href="http://dev.kohanaphp.com/projects/documentor/wiki/">http://dev.kohanaphp.com/projects/documentor/wiki/</a></p>
<p>And the application is here to tinker with:</p>
<p><a href="/resources/php/redmine/documentor/">http://www.keyframesandcode.com/resources/php/redmine/documentor/</a></p>
<p>I think it&#8217;s fairly bullet-proof, but please get in there and test the latest version, let me know what you like, and if you find any bugs.</p></div>
<p><a href="http://www.keyframesandcode.com/resources/php/redmine/documentor/">Check it out online and have a play</a> &#8211; I&#8217;ve tried to make it super easy, and there&#8217;s <strong>sample code</strong> you can use to get you started. Also, try copying and pasting some of the code Kohana classes in to see what happens!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.keyframesandcode.com/code/development/php/documentor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Comment Headings</title>
		<link>http://www.keyframesandcode.com/code/development/comment-headings/</link>
		<comments>http://www.keyframesandcode.com/code/development/comment-headings/#comments</comments>
		<pubDate>Fri, 14 Nov 2008 12:26:47 +0000</pubDate>
		<dc:creator>Dave Stewart</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.keyframesandcode.com/code/development/comment-headings-beta/</guid>
		<description><![CDATA[When navigating through large classes, it can be a real pain to find certain bits of code if you don&#8217;t have a good IDE. As I often work in Flash IDE and DreamWeaver IDE, I have to rely on comment blocks here and there, with lots of &#8211; - &#8211; - &#8211; - &#8211; - [...]]]></description>
			<content:encoded><![CDATA[<p>When navigating through large classes, it can be a real pain to find certain bits of code if you don&#8217;t have a good IDE. As I often work in Flash IDE and DreamWeaver IDE, I have to rely on comment blocks here and there, with lots of &#8211; - &#8211; - &#8211; - &#8211; - &#8211; - delimiters, etc. which is an OK start.</p>
<p>However, I saw the PaperVision 3D classes had moved on a step from this, and had rather nice blocks at the top of each script with their logo, made out of characters. Why not extend this idea and actually build a small Flash application to let me build dirty-great big words that I can use in my scripts for navigation purposes?</p>
<h3>Comment Headings</h3>
<p>Edit the text in the left-hand text box to update the text in the right, then click Copy Text to copy the headings directly to the clipboard so you can paste to your IDE.</p>
<p>Note:Comment Headings works only with mono-spaced fonts! Mac users &#8211; you might have to experiment to find the best one.</p>
<p><span style="color: #ff0000;"><strong>Firefox 3 users:</strong><span style="color: #ff0000;"> due to FF3&#8217;s mono-spaced font tracking, the characters below <em>may not display correctly</em>, but rest-assured that in the final downloadable utility, and your IDE, the headings will appear just fine.</span><strong><br />
</strong></span></p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="670" height="660" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="bgcolor" value="#cccccc" /><param name="src" value="http://www.keyframesandcode.com/resources/flash/applications/Comment%20Headings/CommentHeadings.swf?url=http://www.keyframesandcode.com/resources/flash/applications/Comment%20Headings/presets.xml" /><embed type="application/x-shockwave-flash" width="670" height="660" src="http://www.keyframesandcode.com/resources/flash/applications/Comment%20Headings/CommentHeadings.swf?url=http://www.keyframesandcode.com/resources/flash/applications/Comment%20Headings/presets.xml" bgcolor="#cccccc"></embed></object></p>
<h3>Demonstration</h3>
<p>To demonstrate the differences between a comment-headered file and a normal file, compare the following two files, and see how much easier it is to skim through the one with larger comment headings.</p>
<ul>
<li>A file with <a href="http://www.keyframesandcode.com/resources/flash/applications/Comment%20Headings/example1.as.txt" target="_blank">comment headings</a>.</li>
<li>A file with <a href="http://www.keyframesandcode.com/resources/flash/applications/Comment%20Headings/example2.as.txt" target="_blank">normal text-based headings</a>.</li>
</ul>
<h3>Options</h3>
<p>The following options are available to customize your headings:</p>
<ul>
<li>Font &#8211; Choose from 12 available fonts of varying sizes and styles</li>
<li>Block &#8211; Various characters to create the block comments themselves</li>
<li>Comment &#8211; Various leading-comment styles to suit different languages</li>
<li>Delimiter &#8211; Various delimiter characters for the</li>
</ul>
<h3>Presets</h3>
<p>If you change programming languages / tasks regularly, you can save time by storing oft-used combinations as presets. For example:</p>
<ul>
<li>Input presets &#8211; Your most common heading text combinations</li>
<li>Output presets &#8211; Your most common settings for each language / editor / etc</li>
</ul>
<p>Presets can be quickly called up by selecting them from the dropdown lists, which automatically updates related dropdowns as well as the output text.</p>
<p>Both Input Templates and Output Settings are stored in an editable text file, <a href="http://www.keyframesandcode.com/resources/flash/applications/Comment%20Headings/presets.xml" target="_blank">presets.xml</a>, which is well-commented, allowing you to add or delete settings to suit your workflow.</p>
<p>To have the utility start with your chosen presets, for example having the MaxScript headings always open, just ensure its entry is first in the input list.</p>
<h3>Customization</h3>
<p>Once tinkering in the presets file, the following elements are configurable:</p>
<ul>
<li>Comments &#8211; Choose the leading comments (//, &#8211;, etc) according to programming language</li>
<li>Blocks &#8211; Choose which characters you want to physically build the words from</li>
<li>Delimiters &#8211; Choose which characters you want to use to delineate each comment block</li>
<li>Fonts &#8211; Choose from any of 12 fonts to be available</li>
</ul>
<h3>3dsmax users</h3>
<p>In order to display the full-block style of comments, you will need to set up the SCiTE editor to use the extended Unicode character set, and display code by default in a fixed width font. To do so, you will need to add the following lines to your User Preferences file:</p>
<pre>code.page = 65001
character.set = 204
font.base = font:Courier New,size:10
font.comment = font:Courier New,size:9
</pre>
<p>Obviously this is only applicable if you are using 3dsmax 2008 or above.</p>
<h3>Download</h3>
<ul>
<li><a href="http://www.keyframesandcode.com/resources/flash/applications/Comment%20Headings/CommentHeadings.exe.zip">Windows .exe version</a> for Windows users</li>
<li><a href="http://www.keyframesandcode.com/resources/flash/applications/Comment%20Headings/CommentHeadings.zip">Flash .swf version</a> for Mac users</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.keyframesandcode.com/code/development/comment-headings/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Kohana: Default controller for serving static pages</title>
		<link>http://www.keyframesandcode.com/code/development/php/kohana/kohana-default-controller-for-serving-static-pages/</link>
		<comments>http://www.keyframesandcode.com/code/development/php/kohana/kohana-default-controller-for-serving-static-pages/#comments</comments>
		<pubDate>Thu, 11 Sep 2008 14:28:03 +0000</pubDate>
		<dc:creator>Dave Stewart</dc:creator>
				<category><![CDATA[Kohana]]></category>

		<guid isPermaLink="false">http://www.keyframesandcode.com/code/?p=199</guid>
		<description><![CDATA[A brief overview of the problem
A framework such as Kohana is really useful when serving lots of dynamic pages, as it allows you organise both your thoughts and your code into folders, creating order from what could potentially be chaos, at the expense of having to adhere to a structured way of working, in this [...]]]></description>
			<content:encoded><![CDATA[<h3>A brief overview of the problem</h3>
<p>A framework such as Kohana is really useful when serving lots of dynamic pages, as it allows you organise both your thoughts and your code into folders, creating order from what could potentially be chaos, at the expense of having to adhere to a structured way of working, in this case setting up controllers and  methods that are correctly mapped from URLs (routes).</p>
<p>Whilst this is necessary for dynamic pages that need access to models, helpers and such like, for static pages that literally just need to be output to the browser, it&#8217;s quite a lot of overhead, and your controllers can very quickly end up bloated with itty-bitty &#8220;view this page&#8221; methods.</p>
<p>What would be great would be some magic method to automatically handle static pages, without having to set up an actual controller and method, that way all you really need to create is the view file, and you leave your controllers folder nice and lean.</p>
<p><em>Note: this tutorial is for Kohana 2.2. I haven&#8217;t investigated how it will work with 2.3 and the routing yet. Please comment if you have something to add!</em></p>
<h3>The Fallback controller</h3>
<p>The solution is using a default or &#8220;fallback&#8221; controller that takes care of serving views from routes that don&#8217;t map to an existing controller and method.</p>
<p>Essentially, this new controller kicks in just after the routing has drawn a blank, locates the appropriate view file, then serves it &#8211; instead of serving a 404 page.</p>
<h3>Step-by-step</h3>
<p>Let&#8217;s a take a look at how this works in a step-by-step approach from Kohana&#8217;s perspective. Don&#8217;t worry &#8211; it&#8217;s actually pretty simple, I&#8217;ve just mapped it out specifically so you can see what&#8217;s happening every step of the way.</p>
<p><strong>Let&#8217;s start with a route</strong></p>
<ul>
<li>The user navigates to a route, lets say <strong>/about/company/history</strong></li>
<li>Kohana looks for
<ul>
<li>an <strong>about</strong> controller, with</li>
<li>a <strong>company</strong> method, and intends to supply it with</li>
<li>a <strong>history</strong> argument</li>
</ul>
</li>
</ul>
<p>Here&#8217;s the thing though, because we did&#8217;t want the hassle of setting up ALL our controllers with methods just to load views, our <strong>about</strong> controller doesn&#8217;t have a <strong>company</strong> method! So what is Kohana to do?</p>
<p><strong>Let&#8217;s load the Fallback Controller!</strong><br />
Well, normally, a 404 page would be served, but using the magic of <a href="http://docs.kohanaphp.com/general/hooks">hooks</a>, we&#8217;re going to give Kohana one last chance to do something before serving that horrid 404 page.</p>
<p>So:</p>
<ul>
<li>The <a href="http://docs.kohanaphp.com/general/events#system.post_routing">system.post_routing</a> hook kicks in, and due to the way we&#8217;ve set up the hook file</li>
<li>It loads our <strong>Fallback controller</strong>, which is designed to do something useful with the route before bombing out.</li>
</ul>
<p><strong>Let&#8217;s have the Fallback Controller do it&#8217;s stuff and find the view!</strong><br />
In this case, we want it to attempt to find a view, so:</p>
<ul>
<li>The Fallback controller builds a path from the arguments <strong>/about</strong> that will (hopefully) map to a view, in this case <strong>views/main/about.php</strong>, then</li>
<li>Attempts to find this view using <a href="http://docs.kohanaphp.com/core/kohana#finding_files">Kohana::find_file</a>, and
<ul>
<li>if found &#8211; <strong>loads the view!</strong></li>
<li>if not found &#8211; serves the 404 page</li>
</ul>
</li>
</ul>
<h3>Summary</h3>
<p>Pretty useful, huh? Basically all that happened is</p>
<ul>
<li>Kohana couldn&#8217;t find a controller, so loaded a Fallback controller</li>
<li>The fallback controller took the route and found a view</li>
<li>Kohana loads the view (or the 404 page if the view didn&#8217;t exist)</li>
</ul>
<p>OK, perhaps it&#8217;s time to look at some code</p>
<h3>Code</h3>
<p>You will need to create or edit code in 3 separate places:</p>
<ol>
<li>Enable hooks in your application&#8217;s configuration file</li>
<li>Create a hook file which tells Kohana what to do in the system.post_routing event</li>
<li>Create the actual Fallback Controller that will do the finding and loading of your view files</li>
</ol>
<p>.</p>
<p><strong>application/config/config.php</strong> &#8211; Enable hooks in the main config file&#8230;</p>
<pre>$config['enable_hooks'] = TRUE;</pre>
<p>.</p>
<p><strong>application/hooks/fallback_page.php</strong> &#8211; Add a hook file to the hooks directory&#8230;</p>
<pre>Event::add('system.post_routing' ,'call_fallback_page');

function call_fallback_page()
{
    if (Router::$controller === NULL)
    {
        Router::$controller = 'fallback_page';
        Router::$arguments = Router::$segments;
        Router::$controller_path = APPPATH.'controllers/fallback_page.php';
    }
}</pre>
<p>.</p>
<p><strong>application/controllers/fallback_page.php</strong> &#8211; Set up a controller to do the business</p>
<pre>class Fallback_Page_Controller extends Page_Controller // page controller is my standard page template
{

    public function __construct()
    {

    // the constructor can be omitted if you're not doing anything special,
    // as the parent constructor it is called automatically
        parent::__construct();
    }

    public function __call($function, $arguments)
    {

    // search for a view, and load it if it exists
    // it's up to you how you handle the mapping of arguments to folders here!
        $route =  implode('/', $arguments);
        if(Kohana::find_file('views/main', $route))
        {
            $this-&gt;template-&gt;content = new View('main/'.$route);
        }

    // display alternative content if not found
        else
        {
            $view = new View('common/404');
            $view-&gt;info = array($function, $arguments);
            $this-&gt;template-&gt;content = $view;
        }
    }

}</pre>
<h3>Conculsion</h3>
<p>So now you should be able to set up a bunch of views, but needn&#8217;t worry about building controllers for them if nothing exciting is happening.</p>
<p>The fallback controller will run, will attempt to find a matching view, and if found, will echo it the page. The main thing is &#8211; it keeps your controllers folder and classes nice and lean, and you only need to build controllers that actually DO any controlling!</p>
<p>Nice.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.keyframesandcode.com/code/development/php/kohana/kohana-default-controller-for-serving-static-pages/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Kohana &#8216;filesystem&#8217; Helper</title>
		<link>http://www.keyframesandcode.com/code/development/kohana-filesystem-helper/</link>
		<comments>http://www.keyframesandcode.com/code/development/kohana-filesystem-helper/#comments</comments>
		<pubDate>Wed, 20 Aug 2008 12:49:24 +0000</pubDate>
		<dc:creator>Dave Stewart</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Kohana]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.keyframesandcode.com/code/?p=198</guid>
		<description><![CDATA[Kohana is just an excellent framework to work with, but one of my beefs is that the structure of its bundled libraries and helpers is a little haphazard, missing basic functions you&#8217;d expect to find in the core (so you can rely on them when writing modules) omitted!
For this reason, here&#8217;s my attempt at a [...]]]></description>
			<content:encoded><![CDATA[<p>Kohana is just an excellent framework to work with, but one of my beefs is that the structure of its bundled libraries and helpers is a little haphazard, missing basic functions you&#8217;d expect to find in the core (so you can rely on them when writing modules) omitted!</p>
<p>For this reason, here&#8217;s my attempt at a more integrated helper class. It&#8217;s somewhat of a Frankenstein&#8217;s monster with bits borrowed from Code Igniter, and my own code thrown in as well. Apart from this, it:</p>
<ul>
<li>Adds a few new methods</li>
<li>Improves on some existing methods</li>
<li>Combines the &#8216;download&#8217; helper functionality</li>
<li>Tidies up various method calls</li>
</ul>
<p>The methods are:</p>
<ul>
<li>map()</li>
<li>get_folders()</li>
<li>get_files()</li>
<li>delete_files()</li>
<li>read_file()</li>
<li>write_file()</li>
<li>make_path()</li>
<li>download()</li>
</ul>
<p>Download <a href="http://www.keyframesandcode.com/resources/php/kohana/helpers/filesystem.zip">filesystem.php</a> here.</p>
<p><span id="more-198"></span></p>
<h3 style="margin-top: 30px !important;">map<span style="font-weight:normal"> ($path, $levels = NULL, $structured = FALSE, $files_first = FALSE)</span></h3>
<p><strong>Returns a hierarchical array of folders and files from the specified path.</strong></p>
<p>The parameters are</p>
<ul>
<li><strong>path</strong> : <em>string</em> &#8211; path to the folder</li>
<li>[<strong>levels</strong>] : <em>number</em> &#8211; limit how many folders deep you want to recursively scan</li>
<li>[<strong>structured</strong>] : <em>boolean</em> &#8211; split each returned branch into <em>&#8216;/folder&#8217;</em> and <em>&#8216;/files&#8217;</em> sub-arrays</li>
<li>[<strong>files_first</strong>] : <em>boolean</em> &#8211; if not returning as a structured array, list files before folders</li>
</ul>
<h3 style="margin-top: 30px !important;">get_folders<span style="font-weight:normal"> ($path, $appendPath = false)</span></h3>
<p><strong>Returns an array of folders from the specified </strong><strong>path</strong><strong>.</strong></p>
<p>The parameters are</p>
<ul>
<li><strong>path</strong> : <em>string</em> &#8211; path to the folder</li>
<li>[<strong>append_path</strong>] : <em>boolean</em> &#8211; append the original path to the return output</li>
</ul>
<h3 style="margin-top: 30px !important;">get_files<span style="font-weight:normal"> ($path, $mask = NULL, $appendPath = false)</span></h3>
<p><strong>Returns an array of files from the specified </strong><strong>path</strong><strong>.</strong></p>
<p>The parameters are</p>
<ul>
<li><strong>path</strong> : <em>string</em> &#8211; path to the folder</li>
<li>[<strong>mask</strong>] : <em>mixed</em> &#8211; a file mask to determine which files to return. Can be either
<ul>
<li><em>null</em> &#8211; all files</li>
<li><em>string</em> &#8211; a single file extension</li>
<li><em>array</em> &#8211; an array of file extensions</li>
<li><em>regular expression</em> &#8211; any valid regular expression, for example &#8216;/^config/&#8217;</li>
</ul>
</li>
<li>[<strong>append_path</strong>] : <em>boolean</em> &#8211; append the original path to the return output</li>
</ul>
<h3 style="margin-top: 30px !important;">delete_files<span style="font-weight:normal"> ($path, $mask = NULL, $del_dir = FALSE, $del_root = FALSE)</span></h3>
<p><strong>Recursively deletes all files and optionally folders from the specified </strong><strong>path</strong><strong>.</strong></p>
<p>The parameters are</p>
<ul>
<li><strong>path</strong> : <em>string</em> &#8211; path to the folder</li>
<li>[<strong>mask</strong>] : <em>mixed</em> &#8211; a file mask to determine which files to delete. Can be either
<ul>
<li><em>null</em> &#8211; all files</li>
<li><em>string</em> &#8211; a single file extension</li>
<li><em>array</em> &#8211; an array of file extensions</li>
<li><em>regular expression</em> &#8211; any valid regular expression, for example &#8216;/^config/&#8217;</li>
</ul>
</li>
<li>[<strong>del_dir</strong>] : <em>boolean</em> &#8211; delete any directories encountered when prcoessing</li>
<li>[<strong>del_root</strong>] : <em>boolean</em> &#8211; delete the root directory after processing</li>
</ul>
<h3 style="margin-top: 30px !important;">read_file<span style="font-weight:normal"> ($file)</span></h3>
<p><strong>Opens the specified </strong><strong>file </strong><strong>and returns its contents as a string.</strong></p>
<p>The parameters are:</p>
<ul>
<li><strong>file</strong>: <em>string</em> &#8211; path to the folder</li>
</ul>
<h3 style="margin-top: 30px !important;">write_file<span style="font-weight:normal"> ($path, $data, $append = FALSE)</span></h3>
<p><strong>Writes data to the specified </strong><strong>file</strong><strong>.</strong></p>
<p>The parameters are</p>
<ul>
<li><strong>path</strong> : <em>string</em> &#8211; path to the folder</li>
<li><strong>data</strong> : <em>string</em> &#8211; the data you want written to the file</li>
<li>[<strong>append</strong>] &#8211; <em>boolean</em> &#8211; optionally append data to the file, rather than overwriting it</li>
</ul>
<h3 style="margin-top: 30px !important;">make_path<span style="font-weight:normal"> ($path, $permissions = 0755)</span></h3>
<p><strong>Recursively create folders to form the specified path.</strong></p>
<p>The parameters are</p>
<ul>
<li><strong>path</strong> : mixed &#8211; path or an array of paths</li>
<li>[<strong>permissions</strong>]: <em>number</em> &#8211; permissions you want granted to the new folders</li>
</ul>
<h3 style="margin-top: 30px !important;">download<span style="font-weight:normal"> ($filedata, $filename = NULL)</span></h3>
<p><strong>Download file content by popping up a download dialog in the user&#8217;s browser.</strong></p>
<p>The parameters are</p>
<ul>
<li><strong>filedata</strong> : <em>mixed</em> &#8211; can either be
<ul>
<li><em>filepath</em> &#8211; the path to an existing file</li>
<li><em>string</em> &#8211; data you want downloaded as a file</li>
</ul>
</li>
<li>[<strong>filename</strong>] : <em>string</em> &#8211;  a filename that will appear in the user&#8217;s download dialog</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.keyframesandcode.com/code/development/kohana-filesystem-helper/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>&#8220;List&#8221; struct</title>
		<link>http://www.keyframesandcode.com/code/development/maxscript/list-struct/</link>
		<comments>http://www.keyframesandcode.com/code/development/maxscript/list-struct/#comments</comments>
		<pubDate>Fri, 06 Jun 2008 18:21:21 +0000</pubDate>
		<dc:creator>Dave Stewart</dc:creator>
				<category><![CDATA[For Scripters]]></category>
		<category><![CDATA[Functions]]></category>
		<category><![CDATA[MaxScript]]></category>

		<guid isPermaLink="false">http://www.keyframesandcode.com/code/development/maxscript/for-scripters/list-struct/</guid>
		<description><![CDATA[As 3dsmax doesn&#8217;t allow for either associative arrays or dynamically-set object properties, it can be difficult to store unstructured, arbitrary variables.
Sometimes you just want to store lists of name/value pairs, to keep track of a few settings throughout your script, without relying on a host of variables, resorting to .ini files, or custom attributes.
Therefore, I [...]]]></description>
			<content:encoded><![CDATA[<p>As 3dsmax doesn&#8217;t allow for either associative arrays or dynamically-set object properties, it can be difficult to store unstructured, arbitrary variables.</p>
<p>Sometimes you just want to store lists of name/value pairs, to keep track of a few settings throughout your script, without relying on a host of variables, resorting to .ini files, or custom attributes.</p>
<p>Therefore, I set about writing a basic Dictionary, or List struct, similar to VB and other languages.</p>
<h3>Example code</h3>
<p>Here&#8217;s a really basic example of storing 5 named variables within a List:</p>
<pre>names = #("five", "four", "three", "two", "one")
values = #(5,4,3,2,1)
lst = List()

for i = 1 to 5 do lst.addItem names[i] values[i]</pre>
<p>So let&#8217;s get some data back out:</p>
<pre>lst.getValue "two"
-- 2

lst.getIndex "two"
-- 4

lst.getValues()
-- #(5, 4, 3, 2, 1)</pre>
<p>Or print the whole lot:</p>
<pre>lst.print() -- unsorted

five:	5
four:	4
three:	3
two:	2
one:	1</pre>
<p>How about some sorting:</p>
<pre>lst.sort() -- by name, alphabetically

five:	5
four:	4
one:	1
three:	3
two:	2

lst.sort field:#value -- by value

one:	1
two:	2
three:	3
four:	4
five:	5</pre>
<p>As you can see, it&#8217;s pretty straightforward stuff!</p>
<h3>Properties and Methods</h3>
<blockquote>
<h3>Properties</h3>
<ul>
<li>&lt;array&gt; <strong>items</strong> &lt;name&gt; &lt;value&gt; &#8211; the key/value pairs.
<ul>
<li>Names can be a #name, &#8220;string&#8221;, or even an index</li>
<li>Values can be any MaxWrapper value (i.e. anything)</li>
</ul>
</li>
</ul>
<h3>Setters</h3>
<ul>
<li>&lt;ListItem&gt; <strong>addItem </strong>&lt;name&gt; &lt;value&gt; &#8211; adds an item to the List, and if it already exists</li>
<li>&lt;ListItem&gt; <strong>setItem </strong>&lt;name&gt; &lt;value&gt; &#8211; synonym for the above</li>
</ul>
<h3>Getters</h3>
<ul>
<li>&lt;value&gt; <strong>getValue </strong>&lt;name&gt; &#8211; returns the value of the named item</li>
<li>&lt;index&gt; <strong>getIndex </strong>&lt;name&gt; &#8211; returns the index of the named item</li>
<li>&lt;name&gt; <strong>getName </strong>&lt;value&gt; &#8211; returns the name of the first item that matches the supplied value</li>
<li>&lt;ListItem&gt; <strong>getItem </strong>&lt;name&gt; &#8211; returns the List item corresponding to the supplied name (typically, you wouldn&#8217;t use this, as you know the name component already, it&#8217;s just included for completeness)</li>
<li>&lt;array&gt; <strong>getItems()</strong> &#8211; returns all items as an array of ListItem structs</li>
<li>&lt;array&gt; <strong>getNames()</strong> &#8211; returns all names as an array</li>
<li>&lt;array&gt; <strong>getValues() </strong>- returns all values as an array</li>
</ul>
<h3>Clear or delete</h3>
<ul>
<li>&lt;array&gt; <strong>clear()</strong> &#8211; clears the lit of all items, and returns the empty ListItems array</li>
<li>&lt;boolean&gt; <strong>deleteItem </strong>&lt;name&gt; &#8211; deletes the named item from the list, and returns it</li>
<li>&lt;boolean&gt; <strong>deleteIndex </strong>&lt;index&gt; &#8211; deletes the item at the index, and returns it</li>
</ul>
<h3>Utilities</h3>
<ul>
<li>&lt;array&gt; <strong>sort</strong> field:&lt;name&gt; order:&lt;name&gt; func:&lt;function&gt; &#8211; sorts the list in a variety of ways, even supply a comparison function (see the max help on qsort)</li>
<li>&lt;string&gt; <strong>print()</strong> &#8211; prints the List items to the Listener</li>
</ul>
</blockquote>
<h3>Next version</h3>
<p>Possible improvements in the next version might be:</p>
<ul>
<li>.ini file integration, with <strong>save()</strong> and <strong>load()</strong> methods</li>
<li>Support for hierarchical Lists, perhaps <strong>getValue #(#parent, #child, #grandchild, &#8230;)</strong></li>
</ul>
<h3>Download</h3>
<p>Download <a href="http://www.keyframesandcode.com/resources/maxscript/Functions/List.struct.ms">List.struct.ms</a> here.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.keyframesandcode.com/code/development/maxscript/list-struct/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
