<?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; zend framework</title>
	<atom:link href="http://www.leftcolumn.net/categories/zend-framework/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>Zend Framework one-line platform config: Configure, Don&#8217;t Integrate</title>
		<link>http://www.leftcolumn.net/2009/02/18/zend-framework-one-line-platform-config-configure-dont-integrate/</link>
		<comments>http://www.leftcolumn.net/2009/02/18/zend-framework-one-line-platform-config-configure-dont-integrate/#comments</comments>
		<pubDate>Wed, 18 Feb 2009 04:06:22 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[zend framework]]></category>
		<category><![CDATA[config]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.leftcolumn.net/?p=146</guid>
		<description><![CDATA[Separating config from code in Zend Framework is not as simple as it is in say, Ruby on Rails. And when your source code is version-controlled you want to minimise the manual configuration required. So here&#8217;s a nice way to keep it simple. The idea is to keep configuration data for your test and production [...]]]></description>
			<content:encoded><![CDATA[<p>Separating config from code in <a href="http://framework.zend.com/">Zend Framework</a> is not as simple as it is in say, <a href="http://rubyonrails.org/">Ruby on Rails</a>. And when your source code is version-controlled you want to minimise the manual configuration required. So here&#8217;s a nice way to keep it simple. The idea is to keep configuration data for your test and production environments in a single config file that does not change, then switch environments in a dedicated separate one-line config file.</p>
<p>Here&#8217;s a sample platforms.ini:</p>
<pre>
[test]
developer_mode = true
db.adapter = PDO_MYSQL
db.params.host = localhost
db.params.dbname = testdb
db.params.username = lkdf034k3k3b
db.params.password = SJGS43we3sdd

[production]
developer_mode = false
db.adapter = PDO_MYSQL
db.params.host = localhost
db.params.dbname = productiondb
db.params.username = ksjdhfkjjdhf
db.params.password = jfdhkjsdhdjk</pre>
<p>.. .And here&#8217;s active_platform.ini. This is where we define which of test or production is currently active:</p>
<pre>[platform]
setting = test</pre>
<p>&#8230;And here&#8217;s how index.php refers to active_platform.ini to first determine which platform it&#8217;s on, and second load the appropriate config from platforms.ini:</p>
<pre>// which platform mode are we on? i.e.: test or production
$active_platform = new Zend_Config_Ini('application/configs/active_platform.ini','active_platform');

// get the platform config
$config = new Zend_Config_Ini('application/configs/platforms.ini', $active_platform->setting);
Zend_Registry::set('config', $config);

// set up the db
$db = Zend_Db::factory($platform_config->db);
Zend_Db_Table::setDefaultAdapter($db);</pre>
<p>When you want to deploy to production, you change the setting in active_platform.ini to &#8216;production.&#8217; Simple as that.. this may be obvious but I&#8217;ve found it to speed up deployment and make it less error-prone. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.leftcolumn.net/2009/02/18/zend-framework-one-line-platform-config-configure-dont-integrate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Calling a View Helper from inside another View Helper in Zend Framework</title>
		<link>http://www.leftcolumn.net/2009/01/15/calling-a-view-helper-from-inside-another-view-helper-in-zend-framework/</link>
		<comments>http://www.leftcolumn.net/2009/01/15/calling-a-view-helper-from-inside-another-view-helper-in-zend-framework/#comments</comments>
		<pubDate>Thu, 15 Jan 2009 10:02:23 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[zend framework]]></category>

		<guid isPermaLink="false">http://www.leftcolumn.net/?p=35</guid>
		<description><![CDATA[Update 8th April 2009: Apparently as of 1.7.6 $this-&#62;view-&#62;[helperName()] now works with no extra work required so the info in this post is only necessary if you&#8217;re using &#60;= 1.7.5. Thanks to Mike van Lammeren for the heads up, Â see Mike&#8217;s comment below. If you&#8217;re relatively new to Zend Framework, some of the little details [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Update 8th April 2009: Apparently as of 1.7.6 $this-&gt;view-&gt;[helperName()] now works with no extra work required so the info in this post is only necessary if you&#8217;re using &lt;= 1.7.5. Thanks to Mike van Lammeren for the heads up, Â see Mike&#8217;s comment below. </strong></p>
<p>If you&#8217;re relatively new to Zend Framework, some of the little details can stump you. To call a view helper from within another view helper, you need to give the helper some, er, help. Helpers will try to call a function called setView to set up $_view, so just add it:</p>
<p>Add these lines to the view helper:</p>
<p><code>private $_view;<br />
public function setView($view) {<br />
$this-&gt;_view = $view;<br />
}</code><br />
then to call the View Helper you need, use $this-&gt;_view-&gt;anyHelperYouLike();</p>
<p>Edit: I found this information somewhere on the web, but can&#8217;t remember the source. Any information appreciated!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.leftcolumn.net/2009/01/15/calling-a-view-helper-from-inside-another-view-helper-in-zend-framework/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

