<?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>BinaryKitten&#039;s Development Dropbox</title>
	<atom:link href="http://binarykitten.com/feed" rel="self" type="application/rss+xml" />
	<link>http://binarykitten.com</link>
	<description>Curently a work in progress. Please be patient</description>
	<lastBuildDate>Thu, 27 Oct 2011 21:49:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Royal Mail Postage by Weight &#8211; Zend Framework Module</title>
		<link>http://binarykitten.com/dev/zend-framework/354-royal-mail-postage-by-weight-zend-framework-module.html</link>
		<comments>http://binarykitten.com/dev/zend-framework/354-royal-mail-postage-by-weight-zend-framework-module.html#comments</comments>
		<pubDate>Sun, 17 Jul 2011 23:24:39 +0000</pubDate>
		<dc:creator>BinaryKitten</dc:creator>
				<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[Calculator]]></category>
		<category><![CDATA[Royal Mail]]></category>
		<category><![CDATA[Shipping]]></category>

		<guid isPermaLink="false">http://binarykitten.me.uk/?p=354</guid>
		<description><![CDATA[For a recent project I have had to calculate weight based shipping costs. Before I had this as a db table, but that became a mess to manage.

So I've created this small shipping calculator. It's set to use KG in weight and prices inclusive of vat taken from the Royal Mail's 2011 Prices.]]></description>
			<content:encoded><![CDATA[<p>For a recent project I have had to calculate weight based shipping costs. Before I had this as a db table, but that became a mess to manage.</p>
<p>So I&#8217;ve created this small shipping calculator. It&#8217;s set to use KG in weight and prices inclusive of vat taken from the Royal Mail&#8217;s 2011 Prices.</p>
<p>Follows are the config ini file, the class and a basic usage.</p>
<pre class="brush: php">
[EUR]
prices[0.01] =1.79
prices[0.12] =1.94
prices[0.14] =2.15
prices[0.16] =2.32
prices[0.18] =2.54
prices[0.2] =2.63
prices[0.22] =2.75
prices[0.24] =2.87
prices[0.26] =2.99
prices[0.28] =3.08
prices[0.3] =3.14
prices[0.32] =3.8
prices[0.42] =4.46
prices[0.52] =5.12
prices[0.62] =5.78
prices[0.72] =6.44
prices[0.82] =7.1
prices[0.92] =7.76
prices[1] =7.76

above.start = 1.1
above.increment = 0.1
above.valuePerIncrement = 0.55

[ITL]
prices[0.01] =2.49
prices[0.12] =2.79
prices[0.14] =3.12
prices[0.16] =3.48
prices[0.18] =3.84
prices[0.2] =4.2
prices[0.22] =4.56
prices[0.24] =4.76
prices[0.26] =4.88
prices[0.28] =5
prices[0.3] =5.12
prices[0.32] =6.45
prices[0.42] =7.78
prices[0.52] =9.11
prices[0.62] =10.44
prices[0.72] =11.78
prices[0.82] =13.11
prices[0.92] =14.44
prices[1] =14.44

above.start = 1.1
above.increment = 0.1
above.valuePerIncrement = 0.66

[UK]
prices[0.1] =1.9
prices[0.25] =2.36
prices[0.5] =2.98
prices[0.75] =3.66
prices[1] =4.46
prices[1.25] =5.88
prices[1.5] =6.8
prices[1.75] =7.71
prices[2] =8.62
prices[4] =10.74

above.start = 6
above.increment = 2
above.valuePerIncrement = 3.66
</pre>
<pre class="brush: php">
&lt;?php
class BinaryKitten_Shipping {
    private $_cfg;
    private $_curCfg;
    public function __construct($postalZone=null) {
        $this-&gt;_curCfg = $this-&gt;_cfg = new Zend_Config_Ini(APPLICATION_PATH .&#039;/configs/postal.ini&#039;);
        if (isset($postalZone)) {
            $this-&gt;setPostalZone($postalZone);
        }
    }
    public function setPostalZone($postalZone)
    {
        if (self::validatePostalZone($postalZone)) {
            $this-&gt;_curCfg = $this-&gt;_cfg-&gt;get($postalZone, $this-&gt;_cfg);
        }

    }
    public static function validatePostalZone($postalZone)
    {
        return in_array(strtoupper($postalZone), array(&#039;UK&#039;,&#039;EUR&#039;,&#039;ITL&#039;));
    }
    public function getPriceForWeight($weight)
    {
        $priceOut = -1;
        foreach($this-&gt;_curCfg-&gt;prices as $weightBoundary=&gt;$price) {
            if ($weightBoundary &lt; $weight) continue;
            if ($weightBoundary &gt;= $weight) {
                $priceOut = $price;
                break;
            }
        }
        if ($priceOut == -1) {
            for($weightBoundary = (float)$this-&gt;_curCfg-&gt;above-&gt;start;$weightBoundary &lt; $weight;$weightBoundary += $this-&gt;_curCfg-&gt;above-&gt;increment) {
                $price+=$this-&gt;_curCfg-&gt;above-&gt;valuePerIncrement;
            }

            $priceOut = $price;
            //try to calculate the difference
        }
        return (float)$priceOut;
    }
}
</pre>
<pre class="brush: php">
$prices = new BinaryKitten_Shipping();
$prices-&gt;setPostalZone(&#039;EUR&#039;);
$price = $prices-&gt;getPriceForWeight(5);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://binarykitten.com/dev/zend-framework/354-royal-mail-postage-by-weight-zend-framework-module.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>TinyMCE and Zend_Auth &#8211; Simple Authentication checking.</title>
		<link>http://binarykitten.com/dev/zend-framework/332-tinymce-and-zend_auth-simple-authentication-checking.html</link>
		<comments>http://binarykitten.com/dev/zend-framework/332-tinymce-and-zend_auth-simple-authentication-checking.html#comments</comments>
		<pubDate>Fri, 11 Mar 2011 22:35:28 +0000</pubDate>
		<dc:creator>BinaryKitten</dc:creator>
				<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://binarykitten.me.uk/?p=332</guid>
		<description><![CDATA[I&#8217;ve been using TinyMCE for a good long while and wanted to integrate their fantastic FileManager plugin and ImageManager plugin&#8217;s (Both Commercial) in with my ZF client site. This is relatively easy, the easiest way is to create a controller action and a iframe in the view that points to the location of the imagemanager [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been using TinyMCE for a good long while and wanted to integrate their fantastic FileManager plugin and ImageManager plugin&#8217;s (Both Commercial) in with my ZF client site. This is relatively easy, the easiest way is to create a controller action and a iframe in the view that points to the location of the imagemanager or filemanager plugins.  eg<br />
<code><br />
&lt;iframe src="/js/tiny_mce/plugins/filemanager/index.php?type=fm"&gt;<br />
</code></p>
<p>This works well, but I wanted to make sure that the plugn was not accessible unless the user logged in. I already used Zend_Auth and this doesn&#8217;t exactly play well with the basic SessionAuthenticator. So I set out to create a basic simple plugin for TinyMCE that would allow it to work with the Zend_Auth System.</p>
<p><strong>- Creating the plugin -</strong><br />
first off we have to create our plugin and plugin folder within the tinymce plugin&#8217;s plugin folder. If you think that&#8217;s a lot of use of plugin, you can understand where my brain decided to up and leave.</p>
<p>1st locate your tinymce folder, in there you should find plugins and then go into the filemanager folder. Of course this assumes you have purchased and installed the filemanager plugin. Your path should be something like the following:<br />
<code>&lt;path_to_tiny_mce&gt;/plugins/filemanager/</code> &#8211; this is what we shall refer to our &#8220;Base Path&#8221; from now on.</p>
<p>now we are at a comfortable location to proceed, we can go ahead and create our folder and file<br />
<code>&lt;Base Path&gt;/plugins/ZendAuthenticator</code><br />
in here place a file name ZendAuthenticator.php containing this code:</p>
<pre class="brush: php">&lt;?php
/**
 * Use Zend_Auth to validate the logged in user.
 *
 * <a href="http://twitter.com/author">@author</a> BinaryKitten
 */
class BinaryKitten_ZendAuthenticator extends Moxiecode_ManagerPlugin {

    private $auth = null;
    public function  __construct($man)
    {
        $config = $man-&gt;getConfig();
        if (isset($config[&#039;ZendAuthenticator.LibraryPath&#039;]) &amp;&amp; !empty($config[&#039;ZendAuthenticator.LibraryPath&#039;])) {
            set_include_path(
                implode(
                    PATH_SEPARATOR, array(
                        realpath(
                        $config[&#039;ZendAuthenticator.LibraryPath&#039;]
                        ),
                        get_include_path(),
                    )
                )
            );
        }
        require &quot;Zend/Auth.php&quot;;
        $this-&gt;auth = Zend_Auth::getInstance();
    }

    //put your code here
    public function onAuthenticate(&amp;$man)
    {
        return $this-&gt;auth-&gt;hasIdentity();
    }
}

$man-&gt;registerPlugin(&quot;ZendAuthenticator&quot;, new BinaryKitten_ZendAuthenticator($man));
</pre>
<p>Voila the plugin is ready.</p>
<p><strong>- Configuring the plugin -</strong><br />
Now open up the config.php found in the &#8220;Base Path&#8221; mentioned earlier.<br />
locate: <code>$mcFileManagerConfig['authenticator']</code> and set it&#8217;s value to the following<br />
<code>$mcFileManagerConfig['authenticator'] = 'ZendAuthenticator';</code></p>
<p><strong>- Library Location -</strong></p>
<p>Finally, If your Zend_Framework is not located on the include path (like mine is) then you will need to tell the system where to find the library, to do this add the following to the config.php<br />
<code>$mcFileManagerConfig['ZendAuthenticator.LibraryPath'] = '
<path_to_library>';</code><br />
Please remember though that this is relative to the &#8220;Base Path&#8221; and not the Document_Root unless you specify it as such. </p>
<p><strong> &#8211; - &#8211; - &#8211; </strong><br />
The last thing I will leave you with is that this only checks to see if there is a stored session for Zend_Auth. I&#8217;ll leave it up to you if you want to get roles and other fancy stuff integrated.</p>
]]></content:encoded>
			<wfw:commentRss>http://binarykitten.com/dev/zend-framework/332-tinymce-and-zend_auth-simple-authentication-checking.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PHP Test Fest</title>
		<link>http://binarykitten.com/personal/326-php-test-fest.html</link>
		<comments>http://binarykitten.com/personal/326-php-test-fest.html#comments</comments>
		<pubDate>Mon, 13 Sep 2010 23:55:43 +0000</pubDate>
		<dc:creator>BinaryKitten</dc:creator>
				<category><![CDATA[Personal]]></category>

		<guid isPermaLink="false">http://binarykitten.me.uk/?p=326</guid>
		<description><![CDATA[Title: PHP Test FestLocation: MadLabLink out: Click hereDescription: Come Test PHP!Start Time: 12:00Date: 2010-09-11 I came, I saw and a I tested. A good test fest for PHP and my 1st. I managed to get two tests complete.. mainly because of my inability to follow instructions anyway was all good and great to see so [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Title: </strong>PHP Test Fest<br /><strong>Location: </strong>MadLab<br /><strong>Link out: </strong><a href="http://madlab.org.uk/content/php-testfest/" target="_blanck">Click here</a><br /><strong>Description: </strong>Come Test PHP!<br /><strong>Start Time: </strong>12:00<br /><strong>Date: </strong>2010-09-11</p>
<p>I came, I saw and a I tested.<br />
A good test fest for PHP and my 1st. I managed to get two tests complete.. mainly because of my inability to follow instructions <img src='http://binarykitten.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>anyway was all good and great to see so many people there.</p>
]]></content:encoded>
			<wfw:commentRss>http://binarykitten.com/personal/326-php-test-fest.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Don&#8217;t use IsValid in your Doctrine Models &#8211; a warning</title>
		<link>http://binarykitten.com/dev/324-dont-use-isvalid-in-your-doctrine-models-a-warning.html</link>
		<comments>http://binarykitten.com/dev/324-dont-use-isvalid-in-your-doctrine-models-a-warning.html#comments</comments>
		<pubDate>Thu, 09 Sep 2010 10:33:55 +0000</pubDate>
		<dc:creator>BinaryKitten</dc:creator>
				<category><![CDATA[Doctrine]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[DB]]></category>
		<category><![CDATA[dev]]></category>
		<category><![CDATA[doctrine]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://binarykitten.me.uk/?p=324</guid>
		<description><![CDATA[Recently for a project i&#8217;ve been making heavy use of Doctrine. In one of the models I had a method to check to see if the object was valid under a certain set of conditions. I named this function isValid .. and it had 2 params. Little did I know that this was actually overriding [...]]]></description>
			<content:encoded><![CDATA[<p>Recently for a project i&#8217;ve been making heavy use of Doctrine. In one of the models I had a method to check to see if the object was valid under a certain set of conditions. I named this function isValid .. and it had 2 params. Little did I know that this was actually overriding an existing deep rooted isValid which gets fired on saving the object to the DB. Bummer. </p>
<p>So this is a quick warning to all you Doctrine users. Unless you want to actually override the isValid method for saving, call your check method function something else!</p>
]]></content:encoded>
			<wfw:commentRss>http://binarykitten.com/dev/324-dont-use-isvalid-in-your-doctrine-models-a-warning.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Speaking at PHPNW10</title>
		<link>http://binarykitten.com/personal/309-speaking-at-phpnw10.html</link>
		<comments>http://binarykitten.com/personal/309-speaking-at-phpnw10.html#comments</comments>
		<pubDate>Mon, 02 Aug 2010 21:15:07 +0000</pubDate>
		<dc:creator>BinaryKitten</dc:creator>
				<category><![CDATA[Personal]]></category>

		<guid isPermaLink="false">http://binarykitten.me.uk/?p=309</guid>
		<description><![CDATA[Just a quick note as am really shocked and grateful to be speaking at this years PHP North West Conference in the UK. I shall be presenting a talk entitled &#8220;Using Zend_Tool&#8221; which I hope that many people will find useful. If you haven&#8217;t got your ticket yet, please do. The Conference is not only [...]]]></description>
			<content:encoded><![CDATA[<p>Just a quick note as am really shocked and grateful to be speaking at this years PHP North West Conference in the UK.<br />
I shall be presenting a talk entitled &#8220;Using Zend_Tool&#8221; which I hope that many people will find useful.</p>
<p>If you haven&#8217;t got your ticket yet, please do. The Conference is not only a great way to learn new things but it&#8217;s also a great place to socialise with your fellow developers.</p>
<p>I Hope to see you all there.</p>
]]></content:encoded>
			<wfw:commentRss>http://binarykitten.com/personal/309-speaking-at-phpnw10.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Active Module Config V2</title>
		<link>http://binarykitten.com/dev/zend-framework/296-active-module-config-v2.html</link>
		<comments>http://binarykitten.com/dev/zend-framework/296-active-module-config-v2.html#comments</comments>
		<pubDate>Fri, 18 Jun 2010 00:55:26 +0000</pubDate>
		<dc:creator>BinaryKitten</dc:creator>
				<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://binarykitten.me.uk/?p=296</guid>
		<description><![CDATA[A brand new version of my previously Released Front controller plugin for Zend Framework. Since the last version of the plugin, I&#8217;ve used and cleaned and tried to maintain it. It just ended up unwieldy. So I set about creating this new version. Does exactly the same as the last one, just should be a [...]]]></description>
			<content:encoded><![CDATA[<p>A brand new version of my previously Released Front controller plugin for Zend Framework.<br />
<span id="more-296"></span><br />
Since the last version of the plugin, I&#8217;ve used and cleaned and tried to maintain it. It just ended up unwieldy. So I set about creating this new version. Does exactly the same as the last one, just should be a lot easier to see what it&#8217;s doing and when.</p>
<p>So I present to you active Module Config V2</p>
<p>Many thanks to Paul Bouzakis (<a href="http://twitter.com/paul_eye">@paul_eye</a>) for the pointers in ways to make this more readable and concise</p>
<pre class="brush: php">
&lt;?php
class BinaryKitten_ModuleConfig extends Zend_Controller_Plugin_Abstract
{
    /**@var string The Init Name aka initModule */
    private $_moduleInitName = &#039;&#039;;

    public function routeShutdown(Zend_Controller_Request_Abstract $request)
    {
        $activeModuleName = $request-&gt;getModuleName();
        $this-&gt;_moduleInitName = $activeModuleName.&quot;Init&quot;;

        $appBootstrap = $this-&gt;_getMainBootstrap();
        $activeModuleBootstrap = $this-&gt;_getActiveBootstrap($appBootstrap, $activeModuleName);
        $this-&gt;_processApplicationBootstrap($appBootstrap);
        if ($activeModuleBootstrap instanceof Zend_Application_Module_Bootstrap) {
            $this-&gt;_processActiveModuleBootstrap($activeModuleBootstrap);
        }
    }

    /*****************************************************************
     * Gets the Main Boostrap Object
     *
     * @return Zend_Application_Bootstrap_Bootstrap Main Bootstrap
     *****************************************************************/
    private function _getMainBootstrap()
    {
        $frontController = Zend_Controller_Front::getInstance();
        $bootstrap =  $frontController-&gt;getParam(&#039;bootstrap&#039;);
        return $bootstrap;
    }

    /*******************************************************************************
     * Gets the Current Active Module&#039;s Boostrap Object
     *
     * @param Zend_Application_Bootstrap_Bootstap $appBootstrap The Main Bootstrap
     * @param String $activeModuleName The name to find.
     * @return Zend_Application_Module_Bootstrap Active Module Bootstrap
     ******************************************************************************/
    private function _getActiveBootstrap($appBootstrap, $activeModuleName)
    {
        $moduleList = $appBootstrap-&gt;modules;
        if (isset($moduleList[$activeModuleName])) {
            $activeModule = $moduleList[$activeModuleName];
        } else {
            $activeModule = $appBootstrap;
        }
        return $activeModule;
    }

     /*********************************************************
     * Process the methods from within the main bootstrap
     * @param Zend_Application_Bootstrap_BootstrapAbstract $appBootstrap The Application Bootstrap;
     **********************************************************/
    private function _processApplicationBootstrap($appBootstrap)
    {
        $moduleInitNameLength = strlen($this-&gt;_moduleInitName);
        $bootstrapMethodNames = get_class_methods($appBootstrap);
        foreach ($bootstrapMethodNames as $key=&gt;$method) {
            $runMethod = false;
            $methodNameLength = strlen($method);
            if ($this-&gt;_isModuleNameInitMethod($method)) {
                $resource = call_user_func(array($appBootstrap, $method));
                $resourceName = substr($method, $moduleInitNameLength);
                if (!is_null($resource)) {
                    $this-&gt;storeResource($resource, $resourceName, $appBootstrap);
                }
            }
        }
    }

    /*********************************************************
     * Process the methods from within the main bootstrap
     * @param Zend_Application_Module_Bootstrap $activeModuleBootstrap The &quot;Active&quot;  Modules&#039;s Bootstrap;
     **********************************************************/
    private function _processActiveModuleBootstrap($activeModuleBootstrap)
    {
        $moduleInitNameLength = strlen($this-&gt;_moduleInitName);
        $methodNames = get_class_methods($activeModuleBootstrap);
        foreach ($methodNames as $key=&gt;$method) {
            $runMethod = false;
            if ($this-&gt;_isActiveInitMethod($method)) {
                $resourceName = substr($method, 10);
                $runMethod = true;
            } elseif ($this-&gt;_isModuleNameInitMethod($method)) {
                $resourceName = substr($method, $moduleInitNameLength);
                $runMethod = true;
            }
            if ($runMethod) {
                $resource = call_user_func(array($activeModuleBootstrap, $method));
                if (!is_null($resource)) {
                    $this-&gt;storeResource($resource, $resourceName, $activeModuleBootstrap);
                }
            }
        }
    }

    /*******************************************************
     * Check to see if the method is in style of ModulenameInitXXX
     * @param string $method The method name to check
     ********************************************************/
    private function _isModuleNameInitMethod($method)
    {
        $methodNameLength = strlen($method);
        $moduleInitNameLength = strlen($this-&gt;_moduleInitName);
        $methodNameLonger = ($moduleInitNameLength &lt; $methodNameLength);
        $methodNameBeginMatch = $this-&gt;_moduleInitName == substr($method, 0, $moduleInitNameLength);
        return $methodNameLonger &amp;&amp; $methodNameBeginMatch;
    }

    /*******************************************************
     * Check to see if the method is in style of activeInitXXX
     * @param string $method The method name to check
     ********************************************************/
    private function _isActiveInitMethod($method)
    {
        $methodNameLength = strlen($method);
        $methodNameLonger = ($methodNameLength &gt; 10);
        $methodNameBeginMatch = &#039;activeInit&#039; === substr($method, 0, 10);
        return $methodNameLonger &amp;&amp; $methodNameBeginMatch;
    }

    /***********************************
     * Store the resource returned by the function so that it can be &quot;bootstrapped&quot;
     * @param misc $resource The Resource to be stored
     * @param string $name the name of the resource
     * @param Zend_Application_Bootstrap_BootstrapAbstract $bootstrap The Bootstrap against which to store the resource
     ********************/
    private function storeResource($resource, $name, $bootstrap)
    {
        // Store the resource.. not sure how to do this yet.. if you do let me know! <img src='http://binarykitten.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />
    }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://binarykitten.com/dev/zend-framework/296-active-module-config-v2.html/feed</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>HTML5 Data attributes and jQuery&#8217;s .data &#8211; pairing made in heaven</title>
		<link>http://binarykitten.com/dev/jq-plugins/288-html5-data-attributes-and-jquerys-data-pairing-made-in-heaven.html</link>
		<comments>http://binarykitten.com/dev/jq-plugins/288-html5-data-attributes-and-jquerys-data-pairing-made-in-heaven.html#comments</comments>
		<pubDate>Wed, 12 May 2010 17:19:20 +0000</pubDate>
		<dc:creator>BinaryKitten</dc:creator>
				<category><![CDATA[jQuery Plugins]]></category>

		<guid isPermaLink="false">http://binarykitten.me.uk/?p=288</guid>
		<description><![CDATA[UPDATE jQuery 1.4.3+ now does this in core. No need for this plugin! I really like the idea of the data-* properties in the spec for HTML5, unfortunately they&#8217;re not supported directly by any browser it seems yet; even jQuery 1.4.2 doesn&#8217;t really support them (due to the non-browser support I guess). Anyway, I really [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><strong>UPDATE</strong><br />
jQuery 1.4.3+ now does this in core. <br />
No need for this plugin!
</p>
<hr />
I really like the idea of the data-* properties in the spec for HTML5, unfortunately they&#8217;re not supported directly by any browser it seems yet; even jQuery 1.4.2 doesn&#8217;t really support them (due to the non-browser support I guess).</p>
<p>Anyway, I really wanted to make use of them in an application I&#8217;ve been using and after reading John Resig&#8217;s (<a href="http://twitter.com/jresig">@jresig</a>) post on the subject (<a href="http://ejohn.org/blog/html-5-data-attributes/" target="_blank">http://ejohn.org/blog/html-5-data-attributes/</a>) I set about adding a little snippet to extend jQuery&#8217;s .data so that it would support these parameters. So here is the small plugin that will extend the data function in jQuery to enable access to this functionality.</p>
<p>Enjoy</p>
<pre class="brush: javascript">
(function($){
    $.fn.extend({
        &#039;_data&#039;: $.fn.data,
        &#039;data&#039; : function( key, value ) {
            if ( typeof key === &quot;undefined&quot; &amp;amp;&amp;amp; this.length ) {
                return jQuery.data( this[0] );
            } else if ( typeof key === &quot;object&quot; ) {
                return this.each(function() {
                    jQuery.data( this, key );
                });
            }
            var retValue;
            retValue = $.fn._data(key, value);
            if (&#039;undefined&#039; == (typeof retValue) || retValue.length == 0) {
                var nakedElem = this.get(0);
                if (nakedElem.hasOwnProperty(&#039;dataset&#039;)) {
                    if (&#039;undefined&#039; != (typeof nakedElem.dataset[key])) {
                        retValue = nakedElem.dataset[key];
                    }
                } else {
                    retValue = this.attr(&#039;data-&#039;+key);
                }
            }
            return retValue;
        }
    });
})(jQuery);
</pre>
<p>All comments are gratefully received <img src='http://binarykitten.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://binarykitten.com/dev/jq-plugins/288-html5-data-attributes-and-jquerys-data-pairing-made-in-heaven.html/feed</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Plans</title>
		<link>http://binarykitten.com/personal/286-plans.html</link>
		<comments>http://binarykitten.com/personal/286-plans.html#comments</comments>
		<pubDate>Wed, 05 May 2010 15:55:00 +0000</pubDate>
		<dc:creator>BinaryKitten</dc:creator>
				<category><![CDATA[Personal]]></category>

		<guid isPermaLink="false">http://binarykitten.me.uk/?p=286</guid>
		<description><![CDATA[Recently i&#8217;ve been working on new bits and pieces for projects.. updating existing items and working towards having a nice base of extended components for both Zend Framework and jQuery. On My Workbench at the moment is an update to the keyz jQuery plugin which adds all but the keychain functionality to the system. Also [...]]]></description>
			<content:encoded><![CDATA[<p>Recently i&#8217;ve been working on new bits and pieces for projects.. updating existing items and working towards having a nice base of extended components for both Zend Framework and jQuery. </p>
<p>On My Workbench at the moment is an update to the keyz jQuery plugin which adds all but the keychain functionality to the system. Also have been working on a multi page form component for Zend Framework.</p>
<p>Still working on working out the kinks in both before making a release.</p>
<p>Yesterday (May 4th &#8212; Star Wars Day .. lol) saw me sign the Zend Framwork Contributor License Agreement and send it off to Zend. Still no word as yet, but fingers crossed. </p>
<p>I&#8217;ve also bought myself an XBOX 360 (and a few games), you&#8217;ll find me on XBL as my usual nick.</p>
<p>Things seem to be going well at the moment, but only time will tell.</p>
]]></content:encoded>
			<wfw:commentRss>http://binarykitten.com/personal/286-plans.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Per form stylesheet with Zend_Form</title>
		<link>http://binarykitten.com/dev/zend-framework/274-per-form-stylesheet-with-zend_form.html</link>
		<comments>http://binarykitten.com/dev/zend-framework/274-per-form-stylesheet-with-zend_form.html#comments</comments>
		<pubDate>Mon, 01 Mar 2010 21:58:04 +0000</pubDate>
		<dc:creator>BinaryKitten</dc:creator>
				<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://binarykitten.me.uk/?p=274</guid>
		<description><![CDATA[I needed to have certain form styles attached when a form is in use. I didn&#8217;t want to do this from the controller each and every time as it was really was only to do with the form and I might want to use the form with it&#8217;s own stylesheet in other places. The Solution [...]]]></description>
			<content:encoded><![CDATA[<p>I needed to have certain form styles attached when a form is in use. I didn&#8217;t want to do this from the controller each and every time as it was really was only to do with the form and I might want to use the form with it&#8217;s own stylesheet in other places.<br />
<span id="more-274"></span></p>
<h3>The Solution</h3>
<p>The solution is to extend Zend_form and use the extended version as the basis for all the forms in the application. Here is my Form class.<br />
<code>
<pre class="brush: php">
&lt;?php
class BinaryKitten_Form extends Zend_Form
{
    private $_stylesheets = array(
        &#039;main&#039;=&gt;array(&#039;href&#039;=&gt;&#039;/css/form.css&#039;, &#039;media&#039;=&gt;&#039;screen&#039;)
    );

    public function addStylesheet($href,$media=&#039;screen&#039;)
    {
        $this-&gt;_stylesheets[basename($href)] = array(
            &quot;href&quot;=&gt;$href,
            &quot;media&quot;=&gt;$media
        );
    }

    public function removeStylesheet($href)
    {
        unset($this-&gt;_stylesheets[basename($href)]);
    }

    public function clearStylesheets()
    {
        $this-&gt;_stylesheets = array();
    }

    public function render(Zend_View_Interface $view = null)
    {
        if (null !== $view) {
            $this-&gt;setView($view);
        }
        else {
            $view = $this-&gt;getView();
        }

        foreach ($this-&gt;_stylesheets as $stylesheet) {
            $view-&gt;headLink()-&gt;appendStylesheet($stylesheet[&#039;href&#039;], $stylesheet[&#039;media&#039;]);
        }

        $content = &#039;&#039;;
        foreach ($this-&gt;getDecorators() as $decorator) {
            $decorator-&gt;setElement($this);
            $content = $decorator-&gt;render($content);
        }
        return $content;
    }
}
</pre>
<p></code></p>
<p>Of course you would extend it as usual to create a new form&#8230;.</p>
<pre class="brush: php">
&lt;?php
class BinaryKitten_Form_LoginForm extends BinaryKitten_Form
{
    public function __construct($option = null)
    {
        parent::__construct($option);
        $decorators = array(
            array(&#039;ViewHelper&#039;),
            array(&#039;Label&#039;, array(
                &#039;requiredSuffix&#039;=&gt;&quot; *&quot;
            )),
            array(&#039;HtmlTag&#039;, array(&#039;tag&#039;=&gt;&#039;div&#039;))
        );

        $username = new Zend_Form_Element_Text(&#039;username&#039;);
        $username
            -&gt;setLabel(&#039;Username&#039;)
            -&gt;setRequired(true)
            -&gt;addValidator(&#039;NotEmpty&#039;, true)
            -&gt;addFilter(&quot;StringTrim&quot;)
            -&gt;addErrorMessage(&#039;Please Enter your Username&#039;)
            -&gt;setDecorators($decorators);

        $password = new Zend_Form_Element_Password(&#039;password&#039;);
        $password
            -&gt;setLabel(&#039;Password&#039;)
            -&gt;setRequired(true)
            -&gt;addValidator(&#039;NotEmpty&#039;, true)
            -&gt;addFilter(&quot;StringTrim&quot;)
            -&gt;addErrorMessage(&#039;Please Enter your Password&#039;)
            -&gt;setDecorators($decorators);

        $loginButton = new Zend_Form_Element_Submit(&#039;login&#039;);
        $loginButton
            -&gt;setValue(&#039;login&#039;);

        $this
            -&gt;addElements(
                array(
                    $username,
                    $password,
                    $loginButton
                )
            )
            -&gt;setMethod(&#039;post&#039;)
            -&gt;setName(&#039;loginForm&#039;)
            -&gt;addDecorator(
                array(&#039;mytag&#039; =&gt; &#039;HtmlTag&#039;), array(&#039;tag&#039; =&gt; &#039;div&#039;)
            )
            -&gt;removeDecorator(&#039;HtmlTag&#039;);

        $this-&gt;addStylesheet(&#039;/css/loginform.css&#039;,&#039;screen&#039;);
    }
}
</pre>
<p>And then as usual in you controller:</p>
<pre class="brush: php">
$form = new BinaryKitten_Form_LoginForm();
$this-&gt;view-&gt;form = $form;
</pre>
<p>and of course, echo it out in the view<br />
[sourcecoe lang="php"]<br />
echo $this->form;<br />
[/sourcecode]</p>
<p>And that&#8217;s it, Simple.<br />
Hopefully this will help someone out there</p>
]]></content:encoded>
			<wfw:commentRss>http://binarykitten.com/dev/zend-framework/274-per-form-stylesheet-with-zend_form.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>jQuery Keyz Plugin</title>
		<link>http://binarykitten.com/dev/jq-plugins/259-jquery-keyz-plugin.html</link>
		<comments>http://binarykitten.com/dev/jq-plugins/259-jquery-keyz-plugin.html#comments</comments>
		<pubDate>Wed, 24 Feb 2010 15:20:45 +0000</pubDate>
		<dc:creator>BinaryKitten</dc:creator>
				<category><![CDATA[jQuery Plugins]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[keypress]]></category>
		<category><![CDATA[plugins]]></category>

		<guid isPermaLink="false">http://binarykitten.me.uk/?p=259</guid>
		<description><![CDATA[The purpose of this plugin is to easily facilitate the end user to create and hook key presses for their own use. Usually you would need to know what key links with which keycode etc. Usage It&#8217;s as easy as these steps: Include jquery &#8211; either from CDN or local source Include jquery.keyz.js call the [...]]]></description>
			<content:encoded><![CDATA[<p>The purpose of this plugin is to easily facilitate the end user to  create and hook key presses for their own use. Usually you would need to know what key links with which keycode etc.</p>
<h3>Usage</h3>
<p>It&#8217;s as easy as these steps:</p>
<ol>
<li>Include jquery &#8211; either from CDN or local source</li>
<li>Include jquery.keyz.js</li>
<li>call the following within your document ready or after the item exists</li>
</ol>
<pre class="brush: javascript">
$(&#039;selector&#039;).keyz({
&quot;enter&quot;: function(ctl,sft,alt,event) {
alert(&#039;you pressed enter!&#039;);
}
});
</pre>
<p>this will hook the enter key and raise an alert when pressed.</p>
<p>If you  want to cancel the key either return false from the function or set the  value to false like so:</p>
<pre class="brush: javascript">
$(&#039;selector&#039;).keyz({
&quot;enter&quot;: function(ctl,sft,alt,event) {
return false;
}
});
</pre>
<p>OR</p>
<pre class="brush: javascript">
$(&#039;selector&#039;).keyz({
&quot;enter&quot;:false
});</pre>
<p>You can either use the key names in singular or in a grouping like so:</p>
<pre class="brush: javascript">
$(&#039;selector&#039;).keyz({
&quot;enter&quot;: function(ctl,sft,alt,event) {
/* single key */
return false;
},
&quot;F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12&quot;: function(ctl,sft,alt,event) {
/* mapped to all F-Keys */
return false;
}
});
</pre>
<p>Download jquery.keyz.js here: <a href="/keyzDemo/jquery.keyz.js">Full Source</a> &amp;&amp;  <a href="/keyzDemo/jquery.keyz.gc.js">Google Closure Compiled version</a></p>
<p>Visit the demo page here: <a href="/keyzDemo/">Full Source</a></p>
<h3>Planned Features</h3>
<ul>
<li>support for keypress chains .. passing a sequence of keys and an event firing upon completion</li>
<li><span style="text-decoration: line-through;">support for all three key states &#8211; presently only triggers on key down</span> &#8211; Added in 1.0.2</li>
<li>to add some <a href="http://paulirish.com/2010/duck-punching-with-jquery/" target="_blank">duck punching</a> to add the keyname to the event for the three standard events</li>
</ul>
<h3>Supported Keys</h3>
<p>The keys listed below are the current ones supported by the plugin.<br />
They also support the hyphenated name eg numpad-1 or in upper case like &#8220;F1&#8243; or &#8220;f1&#8243;</p>
<ul>
<li>enter</li>
<li>return</li>
<li>esc</li>
<li>escape</li>
<li>numerics</li>
<li>upper</li>
<li>lower</li>
<li>alphanumeric</li>
<li>tab</li>
<li>shift</li>
<li>alt</li>
<li>ctrl</li>
<li>f1</li>
<li>f2</li>
<li>f3</li>
<li>f4</li>
<li>f5</li>
<li>f6</li>
<li>f7</li>
<li>f8</li>
<li>f9</li>
<li>f10</li>
<li>f11</li>
<li>f12</li>
<li>caps</li>
<li>capslock</li>
<li>numlock</li>
<li>winflag</li>
<li>winkey</li>
<li>windows</li>
<li>scrolllock</li>
<li>left</li>
<li>up</li>
<li>right</li>
<li>down</li>
<li>volumeup</li>
<li>volumedown</li>
<li>menu</li>
<li>contextmenu</li>
<li>backspace</li>
<li>pause</li>
<li>break</li>
<li>pausebreak</li>
<li>pageup</li>
<li>pagedown</li>
<li>end</li>
<li>home</li>
<li>insert</li>
<li>del</li>
<li>delete</li>
<li>numpad0</li>
<li>numpad1</li>
<li>numpad2</li>
<li>numpad3</li>
<li>numpad4</li>
<li>numpad5</li>
<li>numpad6</li>
<li>numpad7</li>
<li>numpad8</li>
<li>numpad9</li>
<li>*</li>
<li>multiply</li>
<li>+</li>
<li>add</li>
<li>-</li>
<li>subtract</li>
<li>.</li>
<li>fullstop</li>
<li>decimal</li>
<li>/</li>
<li>divide</li>
<li>;</li>
<li>semicolon</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://binarykitten.com/dev/jq-plugins/259-jquery-keyz-plugin.html/feed</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
	</channel>
</rss>

