<?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 Blog</title>
	<atom:link href="http://binarykitten.me.uk/feed" rel="self" type="application/rss+xml" />
	<link>http://binarykitten.me.uk</link>
	<description></description>
	<lastBuildDate>Mon, 30 Aug 2010 09:01:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>BinaryKitten Presents&#8230;</title>
		<link>http://binarykitten.me.uk/personal/313-binarykitten-presents-html-css-for-novices.html</link>
		<comments>http://binarykitten.me.uk/personal/313-binarykitten-presents-html-css-for-novices.html#comments</comments>
		<pubDate>Mon, 30 Aug 2010 08:39:22 +0000</pubDate>
		<dc:creator>BinaryKitten</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[websites]]></category>
		<category><![CDATA[workshop]]></category>

		<guid isPermaLink="false">http://binarykitten.me.uk/?p=313</guid>
		<description><![CDATA[I'd Like to (possibly Prematurely, but definitely Proudly) Announce that I'm going to be giving a 2 day workshop entitled HTML/CSS for Novices. ]]></description>
			<content:encoded><![CDATA[<p>I&#8217;d Like to (possibly Prematurely, but definitely Proudly) Announce that I&#8217;m going to be giving a 2 day workshop entitled HTML/CSS for Novices.<br />
<span id="more-313"></span><br />
This workshop will cover (obviously) HTML + CSS on 1 day each.</p>
<p>The Course will be held on a Sunday and will split over two consecutive weekends.<br />
Day 1: HTML<br />
This will cover HTML, What it is, how it&#8217;s used and what you can do with it.<br />
It will also include covering of some of the currently usable HTML5 tags.</p>
<p>Day 2: CSS<br />
This will cover CSS, What it is, how it works and how that applies to HTML.<br />
We shall also cover a smidgeon of CSS3.</p>
<p>Provisionally this course will take place in October.<br />
Please do keep an eye out for more information, I shall be updating with more details as I have them</p>
]]></content:encoded>
			<wfw:commentRss>http://binarykitten.me.uk/personal/313-binarykitten-presents-html-css-for-novices.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Speaking at PHPNW10</title>
		<link>http://binarykitten.me.uk/personal/309-speaking-at-phpnw10.html</link>
		<comments>http://binarykitten.me.uk/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.me.uk/personal/309-speaking-at-phpnw10.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Active Module Config V2</title>
		<link>http://binarykitten.me.uk/dev/zend-framework/296-active-module-config-v2.html</link>
		<comments>http://binarykitten.me.uk/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.me.uk/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />
    }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://binarykitten.me.uk/dev/zend-framework/296-active-module-config-v2.html/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>HTML5 Data attributes and jQuery&#8217;s .data &#8211; pairing made in heaven</title>
		<link>http://binarykitten.me.uk/dev/jq-plugins/288-html5-data-attributes-and-jquerys-data-pairing-made-in-heaven.html</link>
		<comments>http://binarykitten.me.uk/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[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 wanted to make use of them in an application I&#8217;ve been using and [...]]]></description>
			<content:encoded><![CDATA[<p>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; 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.me.uk/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://binarykitten.me.uk/dev/jq-plugins/288-html5-data-attributes-and-jquerys-data-pairing-made-in-heaven.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Plans</title>
		<link>http://binarykitten.me.uk/personal/286-plans.html</link>
		<comments>http://binarykitten.me.uk/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.me.uk/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.me.uk/dev/zend-framework/274-per-form-stylesheet-with-zend_form.html</link>
		<comments>http://binarykitten.me.uk/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.me.uk/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.me.uk/dev/jq-plugins/259-jquery-keyz-plugin.html</link>
		<comments>http://binarykitten.me.uk/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.me.uk/dev/jq-plugins/259-jquery-keyz-plugin.html/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Integrating PHP CodeSniffer with Activestate Komodo Edit</title>
		<link>http://binarykitten.me.uk/dev/219-integrating-php-codesniffer-with-activestate-komodo-edit.html</link>
		<comments>http://binarykitten.me.uk/dev/219-integrating-php-codesniffer-with-activestate-komodo-edit.html#comments</comments>
		<pubDate>Mon, 15 Feb 2010 02:34:26 +0000</pubDate>
		<dc:creator>BinaryKitten</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Activestate]]></category>
		<category><![CDATA[Coding Standards]]></category>
		<category><![CDATA[Komodo]]></category>
		<category><![CDATA[Komodo Edit]]></category>
		<category><![CDATA[PHP_CodeSniffer]]></category>
		<category><![CDATA[Standards]]></category>

		<guid isPermaLink="false">http://binarykitten.me.uk/?p=219</guid>
		<description><![CDATA[I&#8217;ve recently been looking into standards of code and how they would apply to myself and my code. To enable this, I&#8217;ve recently installed PHP_CodeSniffer and for a few days been using this on the command line.. which by itself isn&#8217;t bad, though I really wanted to have something inside my editor of choice (happens [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve recently been looking into standards of code and how they would apply to myself and my code. To enable this, I&#8217;ve recently installed PHP_CodeSniffer and for a few days been using this on the command line.. which by itself isn&#8217;t bad, though I really wanted to have something inside my editor of choice (happens to be Komodo Edit).<span id="more-219"></span></p>
<h2>Setting up Pear</h2>
<p>Since I will be using Pear to install the code sniffer we might as well cover that to start with.<br />
There are lots of tutorials out there with the aim of helping you to get pear installed no matter what the platform. I Will leave that job for them. What I will do is cover how to get it running easily with WampServer from <a href="http://www.wampserver.com/en/">http://www.wampserver.com/en/</a> Please do Note that this is all on a Windows Based machine</p>
<ol>
<li>Open a command prompt</li>
<li>Make a note of your php Directory&#8230; you will need this in a few places<br />
&#8220;WAMPDIR\bin\php\PHPVERSION&#8221;<br />
where WAMPDIR = the directory WampServer is installed to<br />
and PHPVERSION = php+version number..<br />
i&#8217;m using php 5.2.11 on wampserver so the location for me looks like this<br />
&#8220;D:\Wamp\bin\php\php5.2.11&#8243;</li>
<li>CD /D PHPDIR &#8211; where PHPDIR is the location you should have noted down in the last step</li>
<li>Type go-pear and watch as it installs</li>
<li>bring up the Advanced system properties</li>
<li>Environment Variables</li>
<li>Edit Path to add your php folder prefixed with a ;<br />
e.g. for my path was already c:\SharedLibs  so that became<br />
c:\SharedLibs;d:\wamp\bin\php\php5.2.11 &#8211; Close and save all settings</li>
</ol>
<h2>Installing PHP_CodeSniffer via Pear</h2>
<p>Now that I had pear installed I could use it to install PHP_CodeSniffer, this was a simple task with 1 line of code..<br />
<code>pear install PHP_Codesniffer</code> and that was it.. Actually I tell a small lie here, to make it work within the confines of other folders was to do as follows:</p>
<ol>
<li>Open the phpcs.bat file that resides in the php folder outlined above in notepad or similar editor</li>
<li>Change &#8220;./php.exe&#8221; to &#8220;php.exe&#8221;, save the file and close</li>
</ol>
<p>Now we are ready to run PHP_Codesniffer.</p>
<h2>Setting up Komodo Edit</h2>
<p>To start with, I use Komodo Edit for this, that is because that is what I use. I thoroughly recommend it over the likes of notepad++ etc mainly because of its feature set, and the way that it handles code completion from the project. But enough of all this, lets get down to creating a &#8220;run Command&#8221; for the active Tab/File in Komodo.</p>
<ol>
<li>Click Tools, then Run Commandin the R<span style="text-decoration: underline;">u</span>n box enter the following:</li>
<li><code>phpcs -n --standard=%(ask:Which Standard do you wish to use?:ZEND) --report=emacs "%F"</code>Check the <span style="text-decoration: underline;">A</span>dd to Toolbox optionToggle the More options So you can see the Advanced Options Panemake sure the &#8220;Run in&#8221; is set to Command Output TabCheck the &#8220;Parse Output with:&#8221; checkbox and enter the following in the select field:
<pre class="brush: text">
^(?P&lt;file&gt;.*):(?P&lt;line&gt;\d+):(?P&lt;column&gt;\d+):(?P&lt;content&gt;.*)
                     </pre>
</li>
<li>Check the &#8220;Show parsed output as a list&#8221; checkbox</li>
<li>Click the <span style="text-decoration: underline;">N</span>ew button to begin adding a envrionment variable</li>
<li>Set the &#8220;Variable Name&#8221; to PATH and the &#8220;Variable Value&#8221; to the location of PHP_Codesniffer &#8211; If you are following through this is the same as step 2 of &#8220;setting up pear&#8221;- then click ok</li>
<li>click <span style="text-decoration: underline;">R</span>un button &#8211; PHP_CodeSniffer will run and then will ask you for the standard you wish to check against .. by default It&#8217;s set to ZEND</li>
<li>Lastly right click the toolbox entry and bring up the properties. The Top left Text entry is the &#8220;nice name&#8221; for this. You can also assign keys to launch this command later</li>
</ol>
<p>Now you have successfully created a run Tool in Komodo that will run PHP_Codesniffer against the active file and will output the results in a nice list in the command output tab at the bottom panel. I chose the emacs output method as it was easier to get nice looking format without the \&#8221; escape sequence appearing in the &#8220;content&#8221;. The Reason for the regex and the list is that it will now allow you to double click and entry and it will jump to the right spot in the file.</p>
<p>I&#8217;ve also included a Komodo Package of 3 run time commands .. 1 for file, 1 for all files in the project and 1 for all files the directory shared with the currently active file. You can download them here: <a href="/CodeSniff.kpz">CodeSniff Package</a> &#8211; <strong>Recommended to Right-Click &#8211; Save Target as etc</strong> &#8211; This packages comes with predefined keystrokes </p>
<ul>
<li>CTRL+L,CTRL+S,CTRL+F to Codesniff the currently Active file</li>
<li>CTRL+L,CTRL+S,CTRL+P to Codesniff all files in the Project</li>
<li>CTRL+L,CTRL+S,CTRL+D to Codesniff all files in the Active File&#8217;s Directory</li>
</ul>
<p>I do hope that this will prove as useful for someone else as it has for me, comments are welcome.</p>
]]></content:encoded>
			<wfw:commentRss>http://binarykitten.me.uk/dev/219-integrating-php-codesniffer-with-activestate-komodo-edit.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Word of the Day: &#8220;Spalooch&#8221;</title>
		<link>http://binarykitten.me.uk/general/buzzword-of-the-day/213-word-of-the-day-spalooch.html</link>
		<comments>http://binarykitten.me.uk/general/buzzword-of-the-day/213-word-of-the-day-spalooch.html#comments</comments>
		<pubDate>Sat, 30 Jan 2010 02:46:37 +0000</pubDate>
		<dc:creator>BinaryKitten</dc:creator>
				<category><![CDATA[Buzzword of the day]]></category>
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://binarykitten.me.uk/?p=213</guid>
		<description><![CDATA[Yep another delightful new word you can add to your dictionaries. Today&#8217;s Buzzword of the day is: Spalooch This is the sound that comes when you spill a liquid over the edge of its container onto your clothes. When it happens, you have been Spalooched..  it is accidental and you can&#8217;t spalooch someone.]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;">Yep another delightful new word you can add to your dictionaries.<br />
Today&#8217;s Buzzword of the day is:</p>
<h2 style="text-align: center;">Spalooch</h2>
<p style="text-align: center;">This is the sound that comes when you spill a liquid over the edge of its container onto your clothes.</p>
<p style="text-align: center;">When it happens, you have been Spalooched..  it is accidental and you can&#8217;t spalooch someone.</p>
]]></content:encoded>
			<wfw:commentRss>http://binarykitten.me.uk/general/buzzword-of-the-day/213-word-of-the-day-spalooch.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Active Module Based Config with Zend Framework</title>
		<link>http://binarykitten.me.uk/dev/zend-framework/177-active-module-based-config-with-zend-framework.html</link>
		<comments>http://binarykitten.me.uk/dev/zend-framework/177-active-module-based-config-with-zend-framework.html#comments</comments>
		<pubDate>Mon, 04 Jan 2010 22:41:41 +0000</pubDate>
		<dc:creator>BinaryKitten</dc:creator>
				<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[Component]]></category>
		<category><![CDATA[Framework]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[Zend]]></category>

		<guid isPermaLink="false">http://binarykitten.me.uk/?p=177</guid>
		<description><![CDATA[I&#8217;ve recently taken to using Zend Framework for a project that I needed to bring up to date. I won&#8217;t go into the pros and cons of choosing a framework as there are many much more qualified people who have done a much better job of this subject than I would or could. So Instead [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve recently taken to using Zend Framework for a project that I needed to bring up to date. I won&#8217;t go into the pros and cons of choosing a framework as there are many much more qualified people who have done a much better job of this subject than I would or could. So Instead I bring to you How I managed to get Active Module Based Configuration within Zend Framework.</p>
<h2><strong>The Problem</strong></h2>
<p>The Concept I wanted to achieve was to have unique Configuration based upon the module that was active. The Issue with this is that the Bootstrap files and the _init functions for ALL modules are called with no bias as to which module is active. Thus if you created a 3 modules wanted to make menu alterations in one, those alterations will be applied to all. I also wanted to have a a system where if i added extra modules i could just add extra functions to the bootstrap file and it would work in a similar way.</p>
<p>With this in mind, I set about trying to figure out the solution.<br />
<span id="more-177"></span></p>
<h2><strong>New Version</strong></h2>
<p>Though this version still works and you should read through the code to see how to implement the plugin, there is a new version available at:<br />
<a href="http://binarykitten.me.uk/dev/zend-framework/296-active-module-config-v2.html">http://binarykitten.me.uk/dev/zend-framework/296-active-module-config-v2.html</a> <br />
Please refer to this as the latest version.. Thanks</p>
<p>&#8212;&#8211; Original Post &#8212;&#8211;</p>
<h2><strong>Solution 1 &#8211; Failure</strong></h2>
<p>With the Idea that no-body is perfect, including myself. My 1st attempt ended in failure. This attempt was to modify/extend the Bootstrap class to add extra functions to the resources list.. In the end I couldn&#8217;t determine if the Module bootstrap was the active one. ok So Attempt 1 was a failure, onto the next</p>
<h2>Solution 2 &#8211; Success!</h2>
<p>A quick conversation with Matthew Weier O&#8217;Phinney (<a href="http://twitter.com/weierophinney">@weierophinney</a>) pointed me in the direction of Controller plugins and the routeShutdown method, as after the route had been finished which module was active would be able to be discerned.<br />
At this point I must apologise to Pieter Kokx ( @kokxie )  who I had a small disagreement with in the #zftalk channel. Pieter had done his best to point me down this route to start with, though being a stubborn mule I am refused to see the quality and precision of his comments.<br />
Thank you both for your help here.</p>
<p>The way that this works is that is scans the active modules bootstrap for functions starting with <span style="text-decoration: underline">activeInit</span> or <span style="text-decoration: underline">modulenameInit</span> just like the <a href="http://is.gd/64s1y">_init</a> functions but these would only be called if the module is active.<br />
I was successfully able to create the plugin and trigger the functions, unfortunately it was triggering/calling them in a static sense.. which meant that standard _init style code wouldn&#8217;t work. Luckily with a little digging in the source of the framework i found a storage of the modules and their initiated bootstrap classes. Lucky Me! So finally we call the methods within the right context.</p>
<p>So Here it is the Final Code, Please do comment, I learn from people as I hope that others can learn from me.</p>
<p>I&#8217;ve used the &#8220;Namespace&#8221; of BinaryKitten here. If you want to use a different &#8220;Namespace&#8221; Replace BinaryKitten with what you want.<br />
The &#8220;Namespace&#8221; allows for the use of the BinaryKitten folder within the Libray Folder.<br />
Remember the Controller Plugin should go in the right place for your application, if you are using the autoloader you can add the &#8220;Namespace&#8221; to be autoloaded via your application.ini</p>
<pre class="brush: text">
autoloadernamespaces[] = &quot;BinaryKitten&quot;
</pre>
<p>First off we have the Controller Plugin.<br />
This should go into the &#8220;Namespace&#8221; folder within the Library Folder and should be called ModuleConfig.php</p>
<pre class="brush: php">
&lt;?php
class BinaryKitten_ModuleConfig extends Zend_Controller_Plugin_Abstract
{
    public function routeShutdown(Zend_Controller_Request_Abstract $request)
    {
        $frontController = Zend_Controller_Front::getInstance();
        $bootstrap =  $frontController-&gt;getParam(&#039;bootstrap&#039;);
        $activeModuleName = $request-&gt;getModuleName();
        $moduleList = $bootstrap-&gt;modules;

        $moduleInitName = strtolower($activeModuleName).&quot;Init&quot;;
        $moduleInitNameLength = strlen($moduleInitName);

        if (isset($moduleList[$activeModuleName])) {
            $activeModule = $moduleList[$activeModuleName];

            $bootstrapMethodNames = get_class_methods($bootstrap);
            foreach ($bootstrapMethodNames as $key=&gt;$method) {
                $runMethod = false;
                $methodNameLength = strlen($method);
                if ($moduleInitNameLength &lt; $methodNameLength &amp;&amp;
                    $moduleInitName == substr($method, 0, $moduleInitNameLength)) {
                    call_user_func(array($bootstrap,$method));
                }
            }
        } else {
            $activeModule = $bootstrap;
        }

        $methodNames = get_class_methods($activeModule);
        foreach ($methodNames as $key=&gt;$method) {
            $runMethod = false;
            $methodNameLength = strlen($method);
            if (10 &lt; $methodNameLength &amp;&amp; &#039;activeInit&#039; === substr($method, 0, 10)) {
                $runMethod = true;
            } elseif ($moduleInitNameLength &lt; $methodNameLength &amp;&amp;
                    $moduleInitName == substr($method, 0, $moduleInitNameLength)) {
                $runMethod = true;
            }
            if ($runMethod) {
                call_user_func(array($activeModule,$method));
            }
        }
    }
}
</pre>
<p>Next we need to make sure the Controller Plugin is loaded.<br />
We can do this in one of two ways. Either in the Application Bootstrap via an _init function</p>
<pre class="brush: php">
public function _initControllerPlugins()
{
    $plugin = Zend_Controller_Front::getInstance()-&gt;registerPlugin(
        new BinaryKitten_ModuleConfig()
    );
}
</pre>
<p>*&#8211; Or &#8211;*</p>
<p>We can add a line to the application.ini</p>
<pre class="brush: text">
resources.frontController.plugins.BKModuleConfig = &quot;BinaryKitten_ModuleConfig&quot;
</pre>
<p>Finally some example init code from the module bootstrap.<br />
Please remember that the activeInit*() Functions need to be public for this to work properly</p>
<pre class="brush: php">
class Default_Bootstrap extends Zend_Application_Module_Bootstrap {
    public function activeInitMenus() {
        $layout = $this
                    -&gt;bootstrap(&#039;layout&#039;)
                    -&gt;getResource(&#039;layout&#039;);

        $view = $layout-&gt;getView();
        $config = new Zend_Config_Xml(APPLICATION_PATH.&#039;/configs/navigation_default.xml&#039;,&quot;menu&quot;);
        $navigation = new Zend_Navigation($config);
        $view-&gt;navigation($navigation);
    }
    public function activeInitDoSomethingElse() {
        /* some other code */
    }
    public function defaultInitSomething() {
    	/* more code */
    }
}
</pre>
<p>We can also add module inits to the application bootstrap like so:</p>
<pre class="brush: php">
    public function modulenameInitFunction() {
    	/* place code here */
    }
</pre>
<p>Where modulename is the lowercase version of the Modules name, eg if you have the Admin module, then you would use:</p>
<pre class="brush: php">
    public function adminInitFunction() {
    	/* place code here */
    }
</pre>
<p>Hopefully someone will find this code useful.</p>
<p>[ Edit January 5th 2010 ]<br />
Thanks to:<br />
	Matthew Weier O&#8217;Phinney for pointing out places for update.<br />
	Rob Allen (@Akrabat) for the info that the plugin could be loaded via the application.ini<br />
	Elizabeth Marie Smith and Matthew Turland for questioning the use of the Reflection.</p>
<ul>
<li>Updated the Bootstrap code to properly define the functions as Public</li>
<li>Removed the reflection as this wasn&#8217;t actually required any more.</li>
<li>Updated Post to make clean up the order of things and to properly designate that the BinaryKitten is the &#8220;Namespace&#8221;<br />
&#8220;Namespace&#8221; is used to reference that we&#8217;re not using PHP5.3 Namespaces, but the Namespaces within the Zend Framework.</li>
</ul>
<p>[ Edit January 11th 2010 ]<br />
Thanks to:<br />
	septem for pointing out a typo where i had $boostrap instead of $bootstrap<br />
	Gerard Roche for pointing out that by default, the default module doesn&#8217;t require a module bootstrap (in my code it has one)</p>
<ul>
<li>Updated to fix the typos</li>
<li>Added in a quick check to see if the module exists in the modules list of bootstraps</li>
<li>Removed the _ from the function name that it searches for, this should please the people who are adamant over the Zend Coding Standards</li>
<li>Added in the functionality to have $modulenameInit() functions as well in both active module bootstrap and the application bootstrap</li>
</ul>
<p>[ Edit February 13th 2010 ]<br />
Ran the code through codesniffer against the Zend Standard supplied.. updated so no errors found. 3 Warnings are left .. they are as follows:<br />
22 | WARNING | Line exceeds 80 characters; contains 83 characters<br />
35 | WARNING | Line exceeds 80 characters; contains 84 characters<br />
38 | WARNING | Line exceeds 80 characters; contains 83 characters<br />
Don&#8217;t think it&#8217;s worth the change for 3/4 characters </p>
]]></content:encoded>
			<wfw:commentRss>http://binarykitten.me.uk/dev/zend-framework/177-active-module-based-config-with-zend-framework.html/feed</wfw:commentRss>
		<slash:comments>29</slash:comments>
		</item>
	</channel>
</rss>
