<?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>leftcolumn.net &#187; web development</title>
	<atom:link href="http://www.leftcolumn.net/tags/web-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.leftcolumn.net</link>
	<description>Covering Mac OS X, Mac Software, and other stuff</description>
	<lastBuildDate>Tue, 29 Nov 2011 04:30:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Zend Framework: How to add FCKeditor to a Zend_Form</title>
		<link>http://www.leftcolumn.net/2009/03/10/zend-framework-how-to-add-fckeditor-to-a-zend_form/</link>
		<comments>http://www.leftcolumn.net/2009/03/10/zend-framework-how-to-add-fckeditor-to-a-zend_form/#comments</comments>
		<pubDate>Tue, 10 Mar 2009 00:39:18 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[zend framework]]></category>
		<category><![CDATA[fckeditor]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[zend_form]]></category>

		<guid isPermaLink="false">http://www.leftcolumn.net/?p=157</guid>
		<description><![CDATA[There are around 1,083,367 JavaScript-based Rich-Text Editors out there, and I&#8217;m sure most are pretty good. But I&#8217;ve had good results with FCKeditor so I use it on all my projects. Here&#8217;s a step-by-step guide to adding the FCKeditor to your Zend Form Elements. 1 &#8211; The basics Download FCKeditor and Upload it to your [...]]]></description>
			<content:encoded><![CDATA[<p><strong><em>There are around 1,083,367 JavaScript-based Rich-Text Editors out there, and I&#8217;m sure most are pretty good. But I&#8217;ve had good results with FCKeditor so I use it on all my projects. Here&#8217;s a step-by-step guide to adding the FCKeditor to your Zend Form Elements. </em></strong></p>
<h3>1 &#8211; The basics</h3>
<p><span style="font-weight: normal;"><a href="http://www.fckeditor.net/">Download FCKeditor</a> and Upload it to your Web Server. It needs to be somewhere accessible to the world, for example: <strong>/js/fckeditor/</strong>, which on your server may be a path like <strong>/var/www/html/your_site/js/fckeditor/</strong>.</span></p>
<p><span style="font-weight: normal;"><br />
</span></p>
<h3>2 &#8211; .htaccess</h3>
<p><span style="font-weight: normal;">The .htaccess that sets up your index.php as the bootstrap needs to <em>exclude the files that FCKeditor uses</em>. If your bootstrap code in .htaccess looks like this:</span></p>
<pre>RewriteEngine on
RewriteRule !\.(js|ico|gif|jpg|png|css)$ index.php</pre>
<p>you&#8217;ll need to change it. I typically only rewrite to /index.php if the requested file <em>really</em> doesn&#8217;t exist. So .htaccess should be something like this:</p>
<pre>RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1</pre>
<p><span style="font-weight: normal;"><br />
</span></p>
<h3>3 &#8211; Zend_Form Elements</h3>
<p>In the Form code, you need to make sure that you know the id of the Element (In this case the id is &#8216;body&#8217;), and that you are filtering out all tags and attributes that you don&#8217;t want to explicitly allow. Create an allowed_tags list like the one below and ensure that the FormElement has a StripTags filter applied to it:</p>
<pre>$allowed_tags = array(
	'a' =&gt;	array('href', 'title'),
	'strong',
	'img'	=&gt;	array('src', 'alt'),
	'ul',
	'ol',
	'li',
	'em',
	'u',
	'strike');

$body = new Zend_Form_Element_Textarea('body');
$body-&gt;setLabel('Body')
	-&gt;setAttrib('rows', 12)
	-&gt;setAttrib('cols', 40)
	-&gt;setRequired(true)
	-&gt;addFilter('StringTrim')
	-&gt;addFilter('StripTags', $allowed_tags);</pre>
<p><span style="font-weight: normal;"><br />
</span></p>
<h3>4 &#8211; View Script</h3>
<p>Let&#8217;s Assume that you use Layouts, and that you only want to use the FCKeditor on a couple of pages on your site. You don&#8217;t want to include the FCKeditor code on every page because it just adds to the page size, so we do something like this in the View Script <em>(Note: WordPress is messing with the quote marks in this block, ensure you have single quotes after <strong>src=</strong> and before the last semicolon. The other quotes should be double quotes.)</em>:</p>
<pre>$this-&gt;custom_head = '&lt;script src="/js/fckeditor/fckeditor.js" type="text/javascript"&gt;&lt;/script&gt;';
$this-&gt;custom_head .= "&lt;script language='javascript' type='text/javascript' src='/js/customs.js'&gt;&lt;/script&gt;";
$this-&gt;custom_body = ' onload="setupFCK()"';</pre>
<p><span style="font-weight: normal;"><br />
</span></p>
<h3>5 &#8211; Layout Script</h3>
<p>The Layout Script needs to know about this new variable, so the Layout Script needs to know to refer to $this-&gt;custom_head if it is set. Drop the code below inside the &lt;head&gt; section of your layout script:</p>
<pre>&lt;?php

if ($this-&gt;custom_head) {
	echo $this-&gt;custom_head;
}
?&gt;</pre>
<p>&#8230;and change the html body element to look like this:</p>
<pre>&lt;body&lt;?php if ($this-&gt;custom_body) {
	echo $this-&gt;custom_body;
}?&gt;&gt;</pre>
<h3>6 &#8211; Loading the FCKEditor when the page loads</h3>
<p>Create /js/custom.js and put this in it:</p>
<pre><span style="font-weight: normal;">function setUpFCK() { if(document.getElementById('body')) { var oFCKeditor = new FCKeditor('body') ; oFCKeditor.BasePath = "/js/fckeditor/" ; oFCKeditor.Height = 400; oFCKeditor.ReplaceTextarea() ; } }</span></pre>
<h3>7 &#8211; FCKeditor changes</h3>
<p>I like to implement FCKeditor as a single row of buttons for basic editing, just to keep it from looking too big and clunky. I use a set of icons like this:</p>
<pre>FCKConfig.ToolbarSets["Default"] = [
	['Bold','Italic','Underline','StrikeThrough','OrderedList','UnorderedList','Blockquote','Link','Unlink','Image', 'SpecialChar','SpellCheck']
] ;</pre>
<p>And I don&#8217;t want to enable any kind of file uploads, so I make sure these configs are all set to false (edited to show the relevant bits):</p>
<pre>FCKConfig.LinkBrowser = false ;
...
FCKConfig.ImageBrowser = false ;
...
FCKConfig.FlashBrowser = false ;
...
FCKConfig.LinkUpload = false ;
...
FCKConfig.ImageUpload = false ;
...
FCKConfig.FlashUpload = false ;</pre>
<p><span style="font-weight: normal;"><br />
</span></p>
<h3>8 &#8211; Anything else?</h3>
<p>Not really! There are no Controller changes, which is good because this stuff all belongs in Views anyway. The Models know about the allowed tags, which is good because that&#8217;s the kind of work that Models should do. So to me this solution fits the MVC pattern and is not too hack-like. Feedback welcome&#8230;</p>
<h3>Update: 25/3/09</h3>
<p>Fixed various problems with the instructions and it should now all work properly.</p>
<h3>Update: 20/3/09</h3>
<p>I&#8217;ve been doing a bit of reading about Ruby on Rails with the intention of moving to it as my primary development platform. I haven&#8217;t quite got my head around the integration of front-end stuff like FCKeditor yet but Rails really does look like it simplifies the creation and maintenance of forms, which is, after all, about 70% of the work in websites. Need an example? Well Rails has a sensible defaults approach to forms where they can be created automatically based on the model. So compare that to Zend Framework, where I create a separate class for the Form that must match the structure of the model (and be updated when the model changes)! For a big site, that is significant: only one class per table/model!</p>
<h3>Update: 29/11/2011</h3>
<p>Fixed a typo. Also: check out Frost&#8217;s comment below for a tidier way to do this.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.leftcolumn.net/2009/03/10/zend-framework-how-to-add-fckeditor-to-a-zend_form/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Essential Web Development Software: DigitalColor Meter</title>
		<link>http://www.leftcolumn.net/2009/01/26/essential-web-development-software/</link>
		<comments>http://www.leftcolumn.net/2009/01/26/essential-web-development-software/#comments</comments>
		<pubDate>Mon, 26 Jan 2009 09:37:24 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[web development]]></category>
		<category><![CDATA[digitalcolor meter]]></category>
		<category><![CDATA[mac]]></category>

		<guid isPermaLink="false">http://www.leftcolumn.net/?p=48</guid>
		<description><![CDATA[Â  Installed with every Mac, DigitalColor Meter gives you accurate readings of on-screen colours: you can inspect individual pixels, and copy and paste RGB values. When used with Safari or Firefox and a great text editor, it&#8217;s a lightweight but powerful tool. Here&#8217;s an overview&#8230; Â  Find it in /Applications/Utilities/ For using with HTML and [...]]]></description>
			<content:encoded><![CDATA[<p>Â </p>
<div id="attachment_49" class="wp-caption alignleft" style="width: 236px"><img class="size-full wp-image-49  " title="DigitalColor Meter in use" src="http://www.leftcolumn.net/wp-content/uploads/2009/01/picture-3.png" alt="DigitalColor Meter is handy for sampling on-screen colour " width="226" height="113" /><p class="wp-caption-text">DigitalColor Meter is handy for sampling on-screen colour </p></div>
<p><em><strong>Installed with every Mac, DigitalColor Meter gives you accurate readings of on-screen colours: you can inspect individual pixels, and copy and paste RGB values. When used with Safari or Firefox and a great text editor, it&#8217;s a lightweight but powerful tool. Here&#8217;s an overview&#8230;</strong></em></p>
<p>Â </p>
<ul>
<li>Find it in /Applications/Utilities/</li>
<li>For using with HTML and CSS, Â set the colour type to &#8220;RGB as Hex Value, 8-bit&#8221;</li>
<li>Command+Shift+c to copy the current colour as text &#8211; perfect for pasting straight into a .css file, alternatively, click and drag from the swatch area to copy the current colour as text (switch this on in preferences first)</li>
<li>Command+Shift+h to hold the current colour</li>
<li>Set the magnification factor to maximum and the aperture size to minimum for pixel-perfect sampling. Handy for &#8216;borrowing&#8217; font colours from other sites!</li>
<li>Reduce the magnification factor and increase the aperture size for getting an averaged colour &#8211; say, when you&#8217;re working with gradients or photos</li>
<li>When DigitalColor Meter is the active app, you can use the arrow keys to move the aperture in one-pixel increments</li>
<li>You can also save the current hovered area as a .tiff file, or copy it to the clipboard.Â </li>
<li>Set the window to float and keep it in the bottom right of the screen, so it&#8217;s always there at a glance.Â </li>
</ul>
<p>One last point: on Tiger at least, if you switch users to a user who hasÂ DigitalColor MeterÂ running it will crash. But that&#8217;s an annoyance at worst&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.leftcolumn.net/2009/01/26/essential-web-development-software/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

