<?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</title>
	<atom:link href="http://web-development-blog.co.uk/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>PHP large file upload fails error code 7 (Apache)</title>
		<link>http://web-development-blog.co.uk/2011/11/08/php-large-file-upload-fails-error-code-7-apache/</link>
		<comments>http://web-development-blog.co.uk/2011/11/08/php-large-file-upload-fails-error-code-7-apache/#comments</comments>
		<pubDate>Tue, 08 Nov 2011 09:29:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://web-development-blog.co.uk/?p=469</guid>
		<description><![CDATA[Don&#8217;t forget kids to check the size of the tmp partition if you are having issues uploading large files with PHP.
After setting all the usual configuration directives (upload_max_filesize, post_max_size etc) uploads were still failing for me returning error code 7.
After poking around on the Debian VPS for a while I realised the /tmp partition was [...]]]></description>
			<content:encoded><![CDATA[<p>Don&#8217;t forget kids to check the size of the tmp partition if you are having issues uploading large files with PHP.</p>
<p>After setting all the usual configuration directives (upload_max_filesize, post_max_size etc) uploads were still failing for me returning error code 7.</p>
<p>After poking around on the Debian VPS for a while I realised the /tmp partition was 128mb!!</p>
<p>Luckily you can set the path for file uploads using the following directive:</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">upload_tmp_dir <span class="sy0">=</span> <span class="sy0">/</span>path<span class="sy0">/</span>to<span class="sy0">/</span>somewhere<span class="sy0">/</span>with<span class="sy0">/</span>some<span class="sy0">/</span>disk<span class="sy0">/</span>space</div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://web-development-blog.co.uk/2011/11/08/php-large-file-upload-fails-error-code-7-apache/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>Using CakePHP log() in a vendor class</title>
		<link>http://web-development-blog.co.uk/2011/07/20/using-cakephp-log-in-a-vendor-class/</link>
		<comments>http://web-development-blog.co.uk/2011/07/20/using-cakephp-log-in-a-vendor-class/#comments</comments>
		<pubDate>Wed, 20 Jul 2011 10:48:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://web-development-blog.co.uk/?p=452</guid>
		<description><![CDATA[The proper way to do this is with a static call to Debugger:
1Debugger::log&#40;$output&#41;;
]]></description>
			<content:encoded><![CDATA[<p>The proper way to do this is with a static call to Debugger:</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">Debugger<span class="sy0">::</span><span class="kw3">log</span><span class="br0">&#40;</span><span class="re0">$output</span><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/07/20/using-cakephp-log-in-a-vendor-class/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux batch file rename</title>
		<link>http://web-development-blog.co.uk/2011/05/24/linux-batch-file-rename/</link>
		<comments>http://web-development-blog.co.uk/2011/05/24/linux-batch-file-rename/#comments</comments>
		<pubDate>Tue, 24 May 2011 13:59:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux servers]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://web-development-blog.co.uk/?p=448</guid>
		<description><![CDATA[For my own records. Batch file rename using shell:
123Rename all jpg files that contain the string 19_ and replace it with 28_

for file in *.jpg ; do mv $file `echo $file &#124; sed 's/19_/28_/g'` ; done
]]></description>
			<content:encoded><![CDATA[<p>For my own records. Batch file rename using shell:</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="kw3">Rename</span> all jpg files that contain the string <span class="nu0">19</span>_ and replace it with <span class="nu0">28</span>_<br />
<br />
<span class="kw1">for</span> <span class="kw3">file</span> in <span class="sy0">*.</span>jpg <span class="sy0">;</span> <span class="kw1">do</span> mv <span class="re0">$file</span> `<span class="kw3">echo</span> <span class="re0">$file</span> <span class="sy0">|</span> sed <span class="st_h">'s/19_/28_/g'</span>` <span class="sy0">;</span> done</div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://web-development-blog.co.uk/2011/05/24/linux-batch-file-rename/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CakePHP virtual field count another model/table</title>
		<link>http://web-development-blog.co.uk/2011/03/08/cakephp-virtual-field-count-another-modeltable/</link>
		<comments>http://web-development-blog.co.uk/2011/03/08/cakephp-virtual-field-count-another-modeltable/#comments</comments>
		<pubDate>Tue, 08 Mar 2011 10:37:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[Web development]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://web-development-blog.co.uk/?p=428</guid>
		<description><![CDATA[Just managed to count another table using a model virtual field, obviously preserving the association with the sub query conditions.
So in my ProductTemplate model I have this:
123var $virtualFields = array&#40;
&#160; &#160; 'page_count' =&#62; 'SELECT COUNT(*) FROM pages as Page WHERE Page.product_template_id = ProductTemplate.id'
&#160; &#41;;
The nice thing about this is you can use the field with [...]]]></description>
			<content:encoded><![CDATA[<p>Just managed to count another table using a <a href="http://book.cakephp.org/view/1608/Virtual-fields">model virtual field</a>, obviously preserving the association with the sub query conditions.</p>
<p>So in my ProductTemplate model I have this:</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">var</span> <span class="re0">$virtualFields</span> <span class="sy0">=</span> <span class="kw3">array</span><span class="br0">&#40;</span><br />
&nbsp; &nbsp; <span class="st_h">'page_count'</span> <span class="sy0">=&gt;</span> <span class="st_h">'SELECT COUNT(*) FROM pages as Page WHERE Page.product_template_id = ProductTemplate.id'</span><br />
&nbsp; <span class="br0">&#41;</span><span class="sy0">;</span></div></td></tr></tbody></table></div>
<p>The nice thing about this is you can use the field with the CakePHP Model::find ordering and with the pagination component.</p>
]]></content:encoded>
			<wfw:commentRss>http://web-development-blog.co.uk/2011/03/08/cakephp-virtual-field-count-another-modeltable/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>CKEditor in iFrame / jQuery UI dialog top offset bug</title>
		<link>http://web-development-blog.co.uk/2010/10/15/ckeditor-in-iframe-jquery-ui-dialog-top-offset-bug/</link>
		<comments>http://web-development-blog.co.uk/2010/10/15/ckeditor-in-iframe-jquery-ui-dialog-top-offset-bug/#comments</comments>
		<pubDate>Fri, 15 Oct 2010 16:37:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web development]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://web-development-blog.co.uk/?p=395</guid>
		<description><![CDATA[I had a couple of CKEditors in a jQuery UI dialog box today. The dialog box contained an iFrame with the actual CKEditors inside that.
On the odd occasion when the modal box opened (tested in FireFox 3.6 on the Mac and PC) the vertical scroll position of the iFrame would not be at the top. [...]]]></description>
			<content:encoded><![CDATA[<p>I had a couple of CKEditors in a jQuery UI dialog box today. The dialog box contained an iFrame with the actual CKEditors inside that.</p>
<p>On the odd occasion when the modal box opened (tested in FireFox 3.6 on the Mac and PC) the vertical scroll position of the iFrame would not be at the top. Instead it was focused on one of the lower CKEditors.</p>
<p>After some Googling and hacking and still no solution I placed this in each CKeditor onReady/instanceReady callback, which did the trick:</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">CKEditor<span class="sy0">.</span>on<span class="br0">&#40;</span><span class="st0">&quot;instanceReady&quot;</span><span class="sy0">,</span> <span class="kw2">function</span><span class="br0">&#40;</span>event<span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; $<span class="br0">&#40;</span>window<span class="br0">&#41;</span><span class="sy0">.</span>scrollTop<span class="br0">&#40;</span><span class="nu0">0</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span><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/2010/10/15/ckeditor-in-iframe-jquery-ui-dialog-top-offset-bug/feed/</wfw:commentRss>
		<slash:comments>2</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>
	</channel>
</rss>

