<?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>Web Development &#38; Stuff &#187; PHP</title>
	<atom:link href="http://web-development-blog.co.uk/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://web-development-blog.co.uk</link>
	<description>Some interesting findings from web-dev land...</description>
	<lastBuildDate>Thu, 22 Dec 2011 15:35:11 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>CakePHP 1.3 Custom validation rule error &#8211; preg_match() Delimiter must not be alphanumeric or backslash</title>
		<link>http://web-development-blog.co.uk/2011/12/22/cakephp-1-3-custom-validation-rule-error-preg_match-delimiter-must-not-be-alphanumeric-or-backslash/</link>
		<comments>http://web-development-blog.co.uk/2011/12/22/cakephp-1-3-custom-validation-rule-error-preg_match-delimiter-must-not-be-alphanumeric-or-backslash/#comments</comments>
		<pubDate>Thu, 22 Dec 2011 15:35:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web development]]></category>

		<guid isPermaLink="false">http://web-development-blog.co.uk/?p=485</guid>
		<description><![CDATA[If you get this error:
1Warning: Warning &#40;2&#41;: preg_match&#40;&#41; &#91;&#60;a href='function.preg-match'&#62;function.preg-match&#60;/a&#62;&#93;: Delimiter must not be alphanumeric or backslash in &#91;/var/www/vhosts/h2oservices.com/httpdocs/cake/libs/model/model.php, line 2611&#93;
When trying to use a custom validation rule, make sure the method visibility is set to public.
So this should work:
123public function myCustomValidateRule&#40;&#41;&#123;
&#160; &#160; // Custom validation code
&#125;
It seems protected visibility works on some versions of [...]]]></description>
			<content:encoded><![CDATA[<p>If you get this error:</p>
<div class="codecolorer-container php " style="overflow:auto;white-space:nowrap;width:100%"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace">Warning<span class="sy0">:</span> Warning <span class="br0">&#40;</span><span class="nu0">2</span><span class="br0">&#41;</span><span class="sy0">:</span> <span class="kw3">preg_match</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#91;</span><span class="sy0">&lt;</span>a href<span class="sy0">=</span><span class="st_h">'function.preg-match'</span><span class="sy0">&gt;</span>function<span class="sy0">.</span>preg<span class="sy0">-</span>match<span class="sy0">&lt;/</span>a<span class="sy0">&gt;</span><span class="br0">&#93;</span><span class="sy0">:</span> Delimiter must not be alphanumeric or backslash in <span class="br0">&#91;</span><span class="sy0">/</span><span class="kw2">var</span><span class="sy0">/</span>www<span class="sy0">/</span>vhosts<span class="sy0">/</span>h2oservices<span class="sy0">.</span>com<span class="sy0">/</span>httpdocs<span class="sy0">/</span>cake<span class="sy0">/</span>libs<span class="sy0">/</span>model<span class="sy0">/</span>model<span class="sy0">.</span>php<span class="sy0">,</span> line <span class="nu0">2611</span><span class="br0">&#93;</span></div></td></tr></tbody></table></div>
<p>When trying to use a custom validation rule, make sure the method visibility is set to public.</p>
<p>So this should work:</p>
<div class="codecolorer-container php " style="overflow:auto;white-space:nowrap;width:100%"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw2">public</span> <span class="kw2">function</span> myCustomValidateRule<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="co1">// Custom validation code</span><br />
<span class="br0">&#125;</span></div></td></tr></tbody></table></div>
<p>It seems protected visibility works on some versions of PHP (5.2.11 tested and working) and not others.</p>
]]></content:encoded>
			<wfw:commentRss>http://web-development-blog.co.uk/2011/12/22/cakephp-1-3-custom-validation-rule-error-preg_match-delimiter-must-not-be-alphanumeric-or-backslash/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ternary in PHP Heredoc</title>
		<link>http://web-development-blog.co.uk/2011/12/15/ternary-in-php-heredoc/</link>
		<comments>http://web-development-blog.co.uk/2011/12/15/ternary-in-php-heredoc/#comments</comments>
		<pubDate>Thu, 15 Dec 2011 15:26:57 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web development]]></category>

		<guid isPermaLink="false">http://web-development-blog.co.uk/?p=473</guid>
		<description><![CDATA[It can&#8217;t be done using the normal Ternary operator but you can emulate it with:
12345678910111213// So instead of:

$str = &#60;&#60;&#60;HTML
{$a ? 1 : 2}
HTML;

// You can do:

$values = array&#40;'1', '2'&#41;;

$str = &#60;&#60;&#60;HTML
{$values[$a]}
HTML;
]]></description>
			<content:encoded><![CDATA[<p>It can&#8217;t be done using the normal Ternary operator but you can emulate it with:</p>
<div class="codecolorer-container php " style="overflow:auto;white-space:nowrap;width:100%"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="co1">// So instead of:</span><br />
<br />
<span class="re0">$str</span> <span class="sy0">=</span> <span class="co3">&lt;&lt;&lt;HTML<br />
{$a ? 1 : 2}<br />
HTML</span><span class="sy0">;</span><br />
<br />
<span class="co1">// You can do:</span><br />
<br />
<span class="re0">$values</span> <span class="sy0">=</span> <span class="kw3">array</span><span class="br0">&#40;</span><span class="st_h">'1'</span><span class="sy0">,</span> <span class="st_h">'2'</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
<span class="re0">$str</span> <span class="sy0">=</span> <span class="co3">&lt;&lt;&lt;HTML<br />
{$values[$a]}<br />
HTML</span><span class="sy0">;</span></div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://web-development-blog.co.uk/2011/12/15/ternary-in-php-heredoc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Virtual/non existent model fields using CakePHP Security Component</title>
		<link>http://web-development-blog.co.uk/2011/10/13/virtualnon-existent-model-fields-using-cakephp-security-component/</link>
		<comments>http://web-development-blog.co.uk/2011/10/13/virtualnon-existent-model-fields-using-cakephp-security-component/#comments</comments>
		<pubDate>Thu, 13 Oct 2011 08:07:12 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web development]]></category>

		<guid isPermaLink="false">http://web-development-blog.co.uk/?p=463</guid>
		<description><![CDATA[If you have fields that don&#8217;t exist in your table schema and you want to submit those to an action that is protected by the Security component. You can tell the component to ignore (and therefore not black hole/404 your request) the field(s) using its $disabledFields attribute.
In this example I&#8217;m ignoring the security_code (captcha) field, [...]]]></description>
			<content:encoded><![CDATA[<p>If you have fields that don&#8217;t exist in your table schema and you want to submit those to an action that is protected by the Security component. You can tell the component to ignore (and therefore not black hole/404 your request) the field(s) using its $disabledFields attribute.</p>
<p>In this example I&#8217;m ignoring the security_code (captcha) field, which obviously I don&#8217;t store anywhere in the database table:</p>
<div class="codecolorer-container php " style="overflow:auto;white-space:nowrap;width:100%"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="re0">$this</span><span class="sy0">-&gt;</span><span class="me1">Security</span><span class="sy0">-&gt;</span><span class="me1">disabledFields</span> <span class="sy0">=</span> <span class="kw3">array</span><span class="br0">&#40;</span><br />
&nbsp; <span class="st_h">'Enquiry.security_code'</span><br />
<span class="br0">&#41;</span><span class="sy0">;</span></div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://web-development-blog.co.uk/2011/10/13/virtualnon-existent-model-fields-using-cakephp-security-component/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Saving CakePHP HABTM models with join table data</title>
		<link>http://web-development-blog.co.uk/2010/10/25/saving-cakephp-habtm-models-with-join-table-data/</link>
		<comments>http://web-development-blog.co.uk/2010/10/25/saving-cakephp-habtm-models-with-join-table-data/#comments</comments>
		<pubDate>Mon, 25 Oct 2010 18:16:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web development]]></category>

		<guid isPermaLink="false">http://web-development-blog.co.uk/?p=402</guid>
		<description><![CDATA[You can save has and belongs to many models in CakePHP (v1.3.4) whilst adding additional data to the join table, in a single operation.
In this example I&#8217;m saving Users that HABTM Videos. The users_videos join table has an order column. 
Firstly add the &#8216;with&#8217; parameter to the join, you can add the &#8216;order&#8217; parameter too [...]]]></description>
			<content:encoded><![CDATA[<p>You can save has and belongs to many models in CakePHP (v1.3.4) whilst adding additional data to the join table, in a single operation.</p>
<p>In this example I&#8217;m saving Users that HABTM Videos. The users_videos join table has an order column. </p>
<p>Firstly add the &#8216;with&#8217; parameter to the join, you can add the &#8216;order&#8217; parameter too if it makes sense in your context:</p>
<div class="codecolorer-container php " style="overflow:auto;white-space:nowrap;width:100%"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw2">class</span> User <span class="kw2">extends</span> AppModel <span class="br0">&#123;</span><br />
&nbsp; <br />
&nbsp; <span class="kw2">public</span> <span class="re0">$hasAndBelongsToMany</span> <span class="sy0">=</span> <span class="kw3">array</span><span class="br0">&#40;</span><br />
&nbsp; &nbsp; <span class="st_h">'Video'</span> <span class="sy0">=&gt;</span> <span class="kw3">array</span><span class="br0">&#40;</span><br />
&nbsp; &nbsp; &nbsp; <span class="st_h">'with'</span> <span class="sy0">=&gt;</span> <span class="st_h">'UsersVideo'</span><span class="sy0">,</span><br />
&nbsp; &nbsp; &nbsp; <span class="st_h">'order'</span> <span class="sy0">=&gt;</span> <span class="st_h">'UsersVideo.order'</span><br />
&nbsp; &nbsp; <span class="br0">&#41;</span><br />
&nbsp; <span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <br />
<span class="br0">&#125;</span></div></td></tr></tbody></table></div>
<p>Make sure you do a $model->saveAll() in the controller:</p>
<div class="codecolorer-container php " style="overflow:auto;white-space:nowrap;width:100%"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br />6<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw1">if</span><span class="br0">&#40;</span><span class="re0">$this</span><span class="sy0">-&gt;</span><span class="me1">User</span><span class="sy0">-&gt;</span><span class="me1">saveAll</span><span class="br0">&#40;</span><span class="re0">$this</span><span class="sy0">-&gt;</span><span class="me1">data</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; <span class="co1">// Success message</span><br />
&nbsp; <span class="co1">// Redirect &nbsp; &nbsp; </span><br />
<span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span><br />
&nbsp; <span class="co1">// Error message</span><br />
<span class="br0">&#125;</span></div></td></tr></tbody></table></div>
<p>The trick is in the naming of the form input elements. The format is Video.X.UsersVideo.field_name.</p>
<p>Here&#8217;s an example:</p>
<div class="codecolorer-container php " style="overflow:auto;white-space:nowrap;width:100%"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="sy1">&lt;?=</span> <span class="re0">$form</span><span class="sy0">-&gt;</span><span class="me1">input</span><span class="br0">&#40;</span><span class="st_h">'Video.id'</span><span class="br0">&#41;</span> <span class="sy1">?&gt;</span><br />
<br />
<span class="sy1">&lt;?=</span> <span class="re0">$form</span><span class="sy0">-&gt;</span><span class="me1">input</span><span class="br0">&#40;</span><span class="st_h">'Video.0.UsersVideo.video_id'</span><span class="sy0">,</span> <span class="kw3">array</span><span class="br0">&#40;</span><br />
&nbsp; <span class="st_h">'type'</span> <span class="sy0">=&gt;</span> <span class="st_h">'select'</span><span class="sy0">,</span><br />
&nbsp; <span class="st_h">'options'</span> <span class="sy0">=&gt;</span> <span class="re0">$videos</span><br />
<span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="sy1">?&gt;</span><br />
&nbsp; &nbsp; &nbsp; <br />
<span class="sy1">&lt;?=</span> <span class="re0">$form</span><span class="sy0">-&gt;</span><span class="me1">input</span><span class="br0">&#40;</span><span class="st_h">'Video.0.UsersVideo.order'</span><span class="sy0">,</span> <span class="kw3">array</span><span class="br0">&#40;</span><br />
&nbsp; <span class="st_h">'type'</span> <span class="sy0">=&gt;</span> <span class="st_h">'select'</span><span class="sy0">,</span><br />
&nbsp; <span class="st_h">'options'</span> <span class="sy0">=&gt;</span> <span class="kw3">range</span><span class="br0">&#40;</span><span class="nu0">1</span><span class="sy0">,</span> <span class="kw3">count</span><span class="br0">&#40;</span><span class="re0">$videos</span><span class="br0">&#41;</span><span class="br0">&#41;</span><br />
<span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="sy1">?&gt;</span><br />
<br />
<span class="sy1">&lt;?=</span> <span class="re0">$form</span><span class="sy0">-&gt;</span><span class="me1">input</span><span class="br0">&#40;</span><span class="st_h">'Video.0.UsersVideo.user_id'</span><span class="sy0">,</span> <span class="kw3">array</span><span class="br0">&#40;</span><br />
&nbsp; <span class="st_h">'type'</span> <span class="sy0">=&gt;</span> <span class="st_h">'hidden'</span><span class="sy0">,</span><br />
&nbsp; <span class="st_h">'value'</span> <span class="sy0">=&gt;</span> <span class="re0">$user</span><span class="br0">&#91;</span><span class="st_h">'User'</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st_h">'id'</span><span class="br0">&#93;</span><br />
<span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="sy1">?&gt;</span></div></td></tr></tbody></table></div>
<p>Which outputs:</p>
<div class="codecolorer-container php " style="overflow:auto;white-space:nowrap;width:100%"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="br0">&#91;</span>User<span class="br0">&#93;</span> <span class="sy0">=&gt;</span> <span class="kw3">Array</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span>id<span class="br0">&#93;</span> <span class="sy0">=&gt;</span> <span class="nu0">3</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#41;</span><br />
<span class="br0">&#91;</span>Video<span class="br0">&#93;</span> <span class="sy0">=&gt;</span> <span class="kw3">Array</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span> <span class="sy0">=&gt;</span> <span class="kw3">Array</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span>UsersVideo<span class="br0">&#93;</span> <span class="sy0">=&gt;</span> <span class="kw3">Array</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span>video_id<span class="br0">&#93;</span> <span class="sy0">=&gt;</span> <span class="nu0">9</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span>order<span class="br0">&#93;</span> <span class="sy0">=&gt;</span> <span class="nu0">2</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span>user_id<span class="br0">&#93;</span> <span class="sy0">=&gt;</span> <span class="nu0">3</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#41;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#41;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#41;</span></div></td></tr></tbody></table></div>
<p>This will add a record to the join table with the order value.</p>
<p>Obviously you can expand on this to save more users_videos records during the same saveAll call.</p>
]]></content:encoded>
			<wfw:commentRss>http://web-development-blog.co.uk/2010/10/25/saving-cakephp-habtm-models-with-join-table-data/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Insert CakePHP ACO nodes using CakeDC migrations plugin</title>
		<link>http://web-development-blog.co.uk/2010/10/12/insert-cakephp-aco-nodes-using-cakedc-migrations-plugin/</link>
		<comments>http://web-development-blog.co.uk/2010/10/12/insert-cakephp-aco-nodes-using-cakedc-migrations-plugin/#comments</comments>
		<pubDate>Tue, 12 Oct 2010 11:24:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web development]]></category>

		<guid isPermaLink="false">http://web-development-blog.co.uk/?p=380</guid>
		<description><![CDATA[I&#8217;m in the situation where most of my CMS components are extensible CakePHP plugs. 
I&#8217;ve just started to use the CakeDC migrations plugin (been meaning to for a long time as I always loved Rails migrations).
I had previously automated the insertion of plugin ACO node records using a Bash script that chugged through a stack [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m in the situation where most of my CMS components are extensible CakePHP plugs. </p>
<p>I&#8217;ve just started to use the CakeDC migrations plugin (been meaning to for a long time as I always loved Rails migrations).</p>
<p>I had previously automated the insertion of plugin ACO node records using a Bash script that chugged through a stack of &#8216;cake acl create aco bla/bla bla&#8217; commands.</p>
<p>After playing with the migration callbacks for a while I figured out how to insert ACO nodes. The killer part of this process is <strong>remembering to attach the Tree behavior</strong> to the ACL model. Otherwise your ACO tree hierarchy will get toasted!</p>
<p>My advice would be to <strong>SQL dump your database/ACO table</strong> before playing with this:</p>
<div class="codecolorer-container php " style="overflow:auto;white-space:nowrap;width:100%;height:300px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="co2"># Migration after callback</span><br />
<span class="co2"># Inserts a node for the Dashboard controller and then a single admin_index child action. </span><br />
<br />
<span class="kw2">public</span> <span class="kw2">function</span> after<span class="br0">&#40;</span><span class="re0">$direction</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <br />
&nbsp; <span class="re0">$aco</span> <span class="sy0">=</span> <span class="re0">$this</span><span class="sy0">-&gt;</span><span class="me1">generateModel</span><span class="br0">&#40;</span><span class="st_h">'Aco'</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
&nbsp; <span class="co1">// Be sure to attach this. Otherwise it's bye-bye tree hierarchy!!</span><br />
&nbsp; <span class="re0">$aco</span><span class="sy0">-&gt;</span><span class="me1">Behaviors</span><span class="sy0">-&gt;</span><span class="me1">attach</span><span class="br0">&#40;</span><span class="st_h">'Tree'</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; <span class="kw1">if</span><span class="br0">&#40;</span> <span class="re0">$direction</span> <span class="sy0">==</span> <span class="st_h">'up'</span> <span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="co1">// Insert ACO node for dashboard controller.</span><br />
&nbsp; &nbsp; <span class="re0">$data</span><span class="br0">&#91;</span><span class="st_h">'Aco'</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st_h">'parent_id'</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="nu0">1</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="re0">$data</span><span class="br0">&#91;</span><span class="st_h">'Aco'</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st_h">'alias'</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="st_h">'Dashboard'</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="re0">$aco</span><span class="sy0">-&gt;</span><span class="me1">save</span><span class="br0">&#40;</span><span class="re0">$data</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="co1">// Insert ACO node for dashboard admin_index action.</span><br />
&nbsp; &nbsp; <span class="re0">$data</span><span class="br0">&#91;</span><span class="st_h">'Aco'</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st_h">'parent_id'</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="re0">$aco</span><span class="sy0">-&gt;</span><span class="me1">id</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="re0">$data</span><span class="br0">&#91;</span><span class="st_h">'Aco'</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st_h">'alias'</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="st_h">'admin_index'</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="re0">$aco</span><span class="sy0">-&gt;</span><span class="me1">create</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="re0">$aco</span><span class="sy0">-&gt;</span><span class="me1">save</span><span class="br0">&#40;</span><span class="re0">$data</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
&nbsp; <span class="br0">&#125;</span> <span class="kw1">elseif</span><span class="br0">&#40;</span> <span class="re0">$direction</span> <span class="sy0">==</span> <span class="st_h">'down'</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="re0">$dashboard</span> <span class="sy0">=</span> <span class="re0">$aco</span><span class="sy0">-&gt;</span><span class="me1">findByAlias</span><span class="br0">&#40;</span><span class="st_h">'Dashboard'</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="co1">// Remove ACO nodes.</span><br />
&nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span> <span class="sy0">!</span><span class="kw3">empty</span><span class="br0">&#40;</span><span class="re0">$dashboard</span><span class="br0">&#41;</span> <span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span class="re0">$aco</span><span class="sy0">-&gt;</span><span class="me1">deleteAll</span><span class="br0">&#40;</span><span class="kw3">array</span><span class="br0">&#40;</span><span class="st_h">'Aco.parent_id'</span> <span class="sy0">=&gt;</span> <span class="re0">$dashboard</span><span class="br0">&#91;</span><span class="st_h">'Aco'</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st_h">'id'</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; <span class="re0">$aco</span><span class="sy0">-&gt;</span><span class="me1">delete</span><span class="br0">&#40;</span><span class="re0">$dashboard</span><span class="br0">&#91;</span><span class="st_h">'Aco'</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st_h">'id'</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; <span class="kw1">return</span> <span class="kw2">true</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <br />
<span class="br0">&#125;</span></div></td></tr></tbody></table></div>
<p>Coupling this with a create_table in the up stage of the migration will mean plugin installations should be a 2 stage process.</p>
<p>1) Import plugin using Piston/SVN external.<br />
2) Run the install migration creating table(s) and registering permit-table actions (ACO nodes).</p>
]]></content:encoded>
			<wfw:commentRss>http://web-development-blog.co.uk/2010/10/12/insert-cakephp-aco-nodes-using-cakedc-migrations-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>File uploads to PHP scripts hang in Safari bug</title>
		<link>http://web-development-blog.co.uk/2010/06/15/file-uploads-to-php-scripts-hang-in-safari-bug/</link>
		<comments>http://web-development-blog.co.uk/2010/06/15/file-uploads-to-php-scripts-hang-in-safari-bug/#comments</comments>
		<pubDate>Tue, 15 Jun 2010 17:37:31 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[Linux servers]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web development]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://web-development-blog.co.uk/?p=354</guid>
		<description><![CDATA[I was experiencing this issue with some larger file uploads using the CakePHP Media plugin.
https://bugs.webkit.org/show_bug.cgi?id=5760
I added this to the virtual host declaration in my Apache config file to fix it:
123456&#60;VirtualHost x.x.x.x:x&#62;

&#160; &#160; # Prevent Safari from hanging on uploads
&#160; &#160; BrowserMatch &#160;Safari&#160; nokeepalive

&#60;/VirtualHost&#62;
]]></description>
			<content:encoded><![CDATA[<p>I was experiencing this issue with some larger file uploads using the CakePHP Media plugin.</p>
<p><a href="https://bugs.webkit.org/show_bug.cgi?id=5760">https://bugs.webkit.org/show_bug.cgi?id=5760</a></p>
<p>I added this to the virtual host declaration in my Apache config file to fix it:</p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:100%"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br />6<br /></div></td><td><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="sy0">&lt;</span>VirtualHost x.x.x.x:x<span class="sy0">&gt;</span><br />
<br />
&nbsp; &nbsp; <span class="co0"># Prevent Safari from hanging on uploads</span><br />
&nbsp; &nbsp; BrowserMatch &nbsp;Safari&nbsp; nokeepalive<br />
<br />
<span class="sy0">&lt;/</span>VirtualHost<span class="sy0">&gt;</span></div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://web-development-blog.co.uk/2010/06/15/file-uploads-to-php-scripts-hang-in-safari-bug/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Call to undefined method Folder::ls() on line 277 &#8211; CakePHP 1.3 with Media plugin</title>
		<link>http://web-development-blog.co.uk/2010/04/17/call-to-undefined-method-folderls-on-line-277-cakephp-1-3-with-media-plugin/</link>
		<comments>http://web-development-blog.co.uk/2010/04/17/call-to-undefined-method-folderls-on-line-277-cakephp-1-3-with-media-plugin/#comments</comments>
		<pubDate>Sat, 17 Apr 2010 12:52:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web development]]></category>

		<guid isPermaLink="false">http://web-development-blog.co.uk/?p=329</guid>
		<description><![CDATA[If you&#8217;re trying to use the CakePHP Media plugin with 1.3 (I&#8217;m running RC3) and you get this error when deleting an attachment:
1Call to undefined method Folder::ls&#40;&#41; in /path_to_app/app/plugins/media/models/behaviors/media.php &#160;on line 277
ls() has been deprecated in favour of read(), change line 277 of /path_to_app/app/plugins/media/models/behaviors/media.php to:
1list&#40;$versions, &#41; = $Folder-&#62;read&#40;&#41;;
All should work fine thereafter ;]
]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re trying to use the CakePHP Media plugin with 1.3 (I&#8217;m running RC3) and you get this error when deleting an attachment:</p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:100%"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace">Call to undefined method Folder::<span class="kw2">ls</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="kw1">in</span> <span class="sy0">/</span>path_to_app<span class="sy0">/</span>app<span class="sy0">/</span>plugins<span class="sy0">/</span>media<span class="sy0">/</span>models<span class="sy0">/</span>behaviors<span class="sy0">/</span>media.php &nbsp;on line <span class="nu0">277</span></div></td></tr></tbody></table></div>
<p>ls() has been deprecated in favour of read(), change line 277 of /path_to_app/app/plugins/media/models/behaviors/media.php to:</p>
<div class="codecolorer-container php " style="overflow:auto;white-space:nowrap;width:100%"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw3">list</span><span class="br0">&#40;</span><span class="re0">$versions</span><span class="sy0">,</span> <span class="br0">&#41;</span> <span class="sy0">=</span> <span class="re0">$Folder</span><span class="sy0">-&gt;</span><span class="me1">read</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></td></tr></tbody></table></div>
<p>All should work fine thereafter ;]</p>
]]></content:encoded>
			<wfw:commentRss>http://web-development-blog.co.uk/2010/04/17/call-to-undefined-method-folderls-on-line-277-cakephp-1-3-with-media-plugin/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>CakePHP HABTM with single option select menu</title>
		<link>http://web-development-blog.co.uk/2010/02/27/cakephp-habtm-with-single-option-select-menu/</link>
		<comments>http://web-development-blog.co.uk/2010/02/27/cakephp-habtm-with-single-option-select-menu/#comments</comments>
		<pubDate>Sat, 27 Feb 2010 14:57:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web development]]></category>

		<guid isPermaLink="false">http://web-development-blog.co.uk/?p=307</guid>
		<description><![CDATA[I wasn&#8217;t having much luck with the example given in the CakePHP book for a Has and Belongs To Many relationship with a single option select menu in the view.
Anyway overriding the element type does the trick:
1&#60;?php echo $form-&#62;input&#40;'ResellerField', array&#40;'multiple' =&#62; false&#41;&#41; ?&#62;
]]></description>
			<content:encoded><![CDATA[<p>I wasn&#8217;t having much luck with the <a href="http://book.cakephp.org/view/85/Saving-Related-Model-Data-HABTM">example given in the CakePHP book</a> for a Has and Belongs To Many relationship with a single option select menu in the view.</p>
<p>Anyway overriding the element type does the trick:</p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:100%"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="sy0">&lt;</span>?php <span class="kw3">echo</span> <span class="re1">$form</span>-<span class="sy0">&gt;</span>input<span class="br0">&#40;</span><span class="st_h">'ResellerField'</span>, array<span class="br0">&#40;</span><span class="st_h">'multiple'</span> =<span class="sy0">&gt;</span> <span class="kw2">false</span><span class="br0">&#41;</span><span class="br0">&#41;</span> ?<span class="sy0">&gt;</span></div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://web-development-blog.co.uk/2010/02/27/cakephp-habtm-with-single-option-select-menu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CakePHP ACL console refresher</title>
		<link>http://web-development-blog.co.uk/2010/02/22/cakephp-acl-console-refresher/</link>
		<comments>http://web-development-blog.co.uk/2010/02/22/cakephp-acl-console-refresher/#comments</comments>
		<pubDate>Mon, 22 Feb 2010 19:56:57 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web development]]></category>

		<guid isPermaLink="false">http://web-development-blog.co.uk/?p=293</guid>
		<description><![CDATA[Quick refresher for my own records. CakePHP ACL component console commands:
1234567891011121314151617181920212223# View ACO tree
cake acl view aco

# Create root ACO container - in this instance site
cake acl create aco root site

# Create ACO controller node - in this instance the products controller
cake acl create aco site Products 

# Create ACO controller action node - in [...]]]></description>
			<content:encoded><![CDATA[<p>Quick refresher for my own records. CakePHP ACL component console commands:</p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:100%;height:300px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br /></div></td><td><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="co0"># View ACO tree</span><br />
cake acl view aco<br />
<br />
<span class="co0"># Create root ACO container - in this instance site</span><br />
cake acl create aco root site<br />
<br />
<span class="co0"># Create ACO controller node - in this instance the products controller</span><br />
cake acl create aco site Products <br />
<br />
<span class="co0"># Create ACO controller action node - in this instance admin_index</span><br />
cake acl create aco site<span class="sy0">/</span>Products admin_index<br />
<br />
<span class="co0"># Create regular ACO controller action node</span><br />
cake acl create aco site<span class="sy0">/</span>Products index - <span class="kw1">in</span> this instance index<br />
<br />
<span class="co0"># Delete ACO node - in this instance node id 5</span><br />
cake acl delete aco <span class="nu0">5</span><br />
<br />
<span class="co0"># Grant group (id 1) permission to the entire site - this will vary unless you called your root container site</span><br />
cake acl grant group.1 site all<br />
<br />
<span class="co0"># Grant group (id 3) permission to Users controller home action</span><br />
cake acl grant group.3 site<span class="sy0">/</span>Users<span class="sy0">/</span>home all</div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://web-development-blog.co.uk/2010/02/22/cakephp-acl-console-refresher/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Set CakePHP pageTitle in view (not in controller)</title>
		<link>http://web-development-blog.co.uk/2009/11/30/set-cakephp-pagetitle-in-view-not-in-controller/</link>
		<comments>http://web-development-blog.co.uk/2009/11/30/set-cakephp-pagetitle-in-view-not-in-controller/#comments</comments>
		<pubDate>Mon, 30 Nov 2009 17:33:57 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web development]]></category>

		<guid isPermaLink="false">http://web-development-blog.co.uk/?p=267</guid>
		<description><![CDATA[This is quite handy if you&#8217;re working in a team and you don&#8217;t want the designer/client poking about in the controllers to set page titles. You can set them in the view using this code:
UPDATE thanks for bringing the v1.3 change to my attention JT.
12345v1.3
&#60;? $this-&#62;viewVars&#91;'title_for_layout'&#93; = 'My page title' ?&#62;

v1.2
&#60;? $this-&#62;pageTitle = 'My page [...]]]></description>
			<content:encoded><![CDATA[<p>This is quite handy if you&#8217;re working in a team and you don&#8217;t want the designer/client poking about in the controllers to set page titles. You can set them in the view using this code:</p>
<p>UPDATE thanks for bringing the v1.3 change to my attention JT.</p>
<div class="codecolorer-container php " style="overflow:auto;white-space:nowrap;width:100%"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace">v1.3<br />
<span class="sy1">&lt;?</span> <span class="re0">$this</span><span class="sy0">-&gt;</span><span class="me1">viewVars</span><span class="br0">&#91;</span><span class="st_h">'title_for_layout'</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="st_h">'My page title'</span> <span class="sy1">?&gt;</span><br />
<br />
v1.2<br />
<span class="sy1">&lt;?</span> <span class="re0">$this</span><span class="sy0">-&gt;</span><span class="me1">pageTitle</span> <span class="sy0">=</span> <span class="st_h">'My page title'</span> <span class="sy1">?&gt;</span></div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://web-development-blog.co.uk/2009/11/30/set-cakephp-pagetitle-in-view-not-in-controller/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

