<?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>M4d3L-Network Blog&#187; PHP</title>
	<atom:link href="http://www.m4d3l-network.com/category/developpement/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.m4d3l-network.com</link>
	<description>Ma seule limite est mon imagination</description>
	<lastBuildDate>Wed, 07 Jul 2010 21:43:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>How to use Flickr with Zend Framework?</title>
		<link>http://www.m4d3l-network.com/developpement/php/zend-framework/how-to-use-flickr-with-zend-framework/</link>
		<comments>http://www.m4d3l-network.com/developpement/php/zend-framework/how-to-use-flickr-with-zend-framework/#comments</comments>
		<pubDate>Wed, 16 Dec 2009 22:23:53 +0000</pubDate>
		<dc:creator>M4d3L</dc:creator>
				<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[flickr]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[service api]]></category>
		<category><![CDATA[zend cache]]></category>
		<category><![CDATA[Zend_Service_Flickr]]></category>
		<guid isPermaLink="false">http://www.m4d3l-network.com/?p=454</guid>
		<description><![CDATA[Zend Framework have a good API to play with Flickr Service. You will find it in the service API of Zend Framework. First of all, we take the tag we want to search on the Flickr database. 1 $flirktag = &#34;php, mysql&#34; After, we dont want to call each time the Flickr database so we [...]
Related posts:<ol><li><a href='http://www.m4d3l-network.com/developpement/php/autocomplete-field-with-zend-framework-and-dojo/' rel='bookmark' title='Permanent Link: Autocomplete field with Zend Framework and Dojo'>Autocomplete field with Zend Framework and Dojo</a></li>
<li><a href='http://www.m4d3l-network.com/developpement/php/zend-framework/add-language-route-to-your-zend-framework-project/' rel='bookmark' title='Permanent Link: Add language route to your Zend Framework project.'>Add language route to your Zend Framework project.</a></li>
<li><a href='http://www.m4d3l-network.com/developpement/php/zend-framework/phenix_wiki/' rel='bookmark' title='Permanent Link: Phenix_Wiki, a parser componant for Zend Framework'>Phenix_Wiki, a parser componant for Zend Framework</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>Zend Framework have a good API to play with Flickr Service. You will find it in the <a href="http://framework.zend.com/manual/en/zend.service.html">service </a>API of Zend Framework.<br />
<span id="more-454"></span><br />
First of all, we take the tag we want to search on the Flickr database.</p>
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$flirktag</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;php, mysql&quot;</span></pre></td></tr></table></div>
<p>After, we dont want to call each time the Flickr database so we will settup a cache of 10 minutes.</p>
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$frontendOptions</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
    <span style="color: #0000ff;">'lifetime'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">600</span><span style="color: #339933;">,</span>                   <span style="color: #666666; font-style: italic;">// cache lifetime of 10 minute</span>
    <span style="color: #0000ff;">'automatic_serialization'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">false</span>  <span style="color: #666666; font-style: italic;">// this is the default anyways</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$backendOptions</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'cache_dir'</span> <span style="color: #339933;">=&gt;</span> MYAPP_PATH_DATA<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$cache</span> <span style="color: #339933;">=</span> Zend_Cache<span style="color: #339933;">::</span><span style="color: #004000;">factory</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Output'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'File'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$frontendOptions</span><span style="color: #339933;">,</span> <span style="color: #000088;">$backendOptions</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>
<p>We check first if it already have cache for the query we want. If no cache we execute the query like this :</p>
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$flickrPlugin</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$cache</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;flickr&quot;</span><span style="color: #339933;">.</span><span style="color: #990000;">md5</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$flirktag</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$flickrPlugin</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$flickr</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Service_Flickr<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'###YOUR#ID###'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$options</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
        <span style="color: #0000ff;">'per_page'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'page'</span>     <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'tag_mode'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'all'</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'extras'</span>   <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'license, date_upload, date_taken, owner_name, icon_server'</span>
        <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$tags</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;, &quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$flirktag</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$flickr_results</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$flickr</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">tagSearch</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$tags</span><span style="color: #339933;">,</span> <span style="color: #000088;">$options</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>
<p>After, if we have some result, we can show data like this :</p>
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$result</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$flickrPlugin</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&lt;div class=&quot;flickr section&quot;&gt;&lt;ul class=&quot;gallery&quot;&gt;'</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$flickr_results</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$flickr_result</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$flickr_result</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">title</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$title</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$result</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">flickr</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$substring</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strtolower</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$flickr_result</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">title</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">4</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$substring</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;.jpg&quot;</span> or <span style="color: #000088;">$substring</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;.gif&quot;</span> or <span style="color: #000088;">$substring</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;.png&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                    <span style="color: #000088;">$title</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$result</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">flickr</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span>
                    <span style="color: #000088;">$title</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$flickr_result</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">title</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span>
            <span style="color: #000088;">$flickrPlugin</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&lt;li&gt;&lt;a rel=&quot;lightbox-tour&quot; href=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$flickr_result</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Medium</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">uri</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; title=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$flickr_result</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">title</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot;&gt;&lt;img class=&quot;thumb&quot; src=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$flickr_result</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Square</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">uri</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; /&gt;&lt;/a&gt;&lt;/li&gt;'</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #000088;">$flickrPlugin</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&lt;/ul&gt;&lt;/div&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>
<p>Finally, we save the cache for future request than print the result.</p>
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>38
39
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">    <span style="color: #000088;">$cache</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">save</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$flickrPlugin</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;flickr&quot;</span><span style="color: #339933;">.</span><span style="color: #990000;">md5</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$flirktag</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">print</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$flickrPlugin</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>
<p>This is a very simple exemple of what we can do with the Zend_Service_Flickr component.</p>
<!-- google_ad_section_end --><img src="http://www.m4d3l-network.com/?ak_action=api_record_view&id=454&type=feed" alt="" />
<p>Related posts:<ol><li><a href='http://www.m4d3l-network.com/developpement/php/autocomplete-field-with-zend-framework-and-dojo/' rel='bookmark' title='Permanent Link: Autocomplete field with Zend Framework and Dojo'>Autocomplete field with Zend Framework and Dojo</a></li>
<li><a href='http://www.m4d3l-network.com/developpement/php/zend-framework/add-language-route-to-your-zend-framework-project/' rel='bookmark' title='Permanent Link: Add language route to your Zend Framework project.'>Add language route to your Zend Framework project.</a></li>
<li><a href='http://www.m4d3l-network.com/developpement/php/zend-framework/phenix_wiki/' rel='bookmark' title='Permanent Link: Phenix_Wiki, a parser componant for Zend Framework'>Phenix_Wiki, a parser componant for Zend Framework</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.m4d3l-network.com/developpement/php/zend-framework/how-to-use-flickr-with-zend-framework/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Autocomplete field with Zend Framework and Dojo</title>
		<link>http://www.m4d3l-network.com/developpement/php/autocomplete-field-with-zend-framework-and-dojo/</link>
		<comments>http://www.m4d3l-network.com/developpement/php/autocomplete-field-with-zend-framework-and-dojo/#comments</comments>
		<pubDate>Sat, 07 Nov 2009 00:20:32 +0000</pubDate>
		<dc:creator>M4d3L</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[autocomplete]]></category>
		<category><![CDATA[dojo]]></category>
		<category><![CDATA[dojox]]></category>
		<category><![CDATA[field]]></category>
		<category><![CDATA[FilteringSelect]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[input]]></category>
		<category><![CDATA[QueryReadStore]]></category>
		<category><![CDATA[Zend_Form]]></category>
		<category><![CDATA[zf]]></category>
		<guid isPermaLink="false">http://www.m4d3l-network.com/?p=416</guid>
		<description><![CDATA[In this exemple, we will se how to create an autocomplete field with Zend Framework and Dojo in the ZF MVC environment. We will use the QueryReadStore Dojo component to load new data when input value change. Initialize Dojo in your layout In the header of your layout, you must be able to load Dojo [...]
Related posts:<ol><li><a href='http://www.m4d3l-network.com/developpement/php/zend-framework/zend_form-how-to-remove-decorator-from-hidden-field/' rel='bookmark' title='Permanent Link: Zend_Form : How to remove decorator from hidden field.'>Zend_Form : How to remove decorator from hidden field.</a></li>
<li><a href='http://www.m4d3l-network.com/developpement/php/zend-framework/add-language-route-to-your-zend-framework-project/' rel='bookmark' title='Permanent Link: Add language route to your Zend Framework project.'>Add language route to your Zend Framework project.</a></li>
<li><a href='http://www.m4d3l-network.com/developpement/php/zend-framework/how-to-use-flickr-with-zend-framework/' rel='bookmark' title='Permanent Link: How to use Flickr with Zend Framework?'>How to use Flickr with Zend Framework?</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>In this exemple, we will se how to create an autocomplete field with Zend Framework and Dojo in the ZF MVC environment. We will use the QueryReadStore Dojo component to load new data when input value change.</p>
<p><span id="more-416"></span></p>
<h3>Initialize Dojo in your layout</h3>
<p>In the header of your layout, you must be able to load Dojo in page that need it loaded only to not overload other page that doesn&#8217;t have Javascript in it.</p>
<p>Exemple :</p>
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">doctype</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'XHTML1_STRICT'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; lang=&quot;en&quot; xml:lang=&quot;en&quot;&gt;
&lt;head&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">headTitle</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$request</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getActionName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #339933;">-&gt;</span><span style="color: #004000;">headTitle</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$request</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getControllerName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?=</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">headLink</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #339933;">-&gt;</span><span style="color: #004000;">appendStylesheet</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">theme_url</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/css/style.css'</span><span style="color: #009900;">&#41;</span>
	<span style="color: #339933;">-&gt;</span><span style="color: #004000;">headLink</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'rel'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'favicon'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'href'</span> <span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'/images/favicon.ico'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'PREPEND'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?=</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">headMeta</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #339933;">-&gt;</span><span style="color: #004000;">appendHttpEquiv</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'expires'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Wed, 26 Feb 1997 08:21:57 GMT'</span><span style="color: #009900;">&#41;</span>
        <span style="color: #339933;">-&gt;</span><span style="color: #004000;">appendHttpEquiv</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'pragma'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'no-cache'</span><span style="color: #009900;">&#41;</span>
        <span style="color: #339933;">-&gt;</span><span style="color: #004000;">appendHttpEquiv</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Content-Type'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'text/html;charset=UTF-8'</span><span style="color: #009900;">&#41;</span>
        <span style="color: #339933;">-&gt;</span><span style="color: #004000;">appendHttpEquiv</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Cache-Control'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'no-cache'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">dojo</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">isEnabled</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
   <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">dojo</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setLocalPath</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">BaseUrl</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/plugins/dojo/dojo.js'</span><span style="color: #009900;">&#41;</span>
         <span style="color: #339933;">-&gt;</span><span style="color: #004000;">addStyleSheetModule</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'dijit.themes.tundra'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">dojo</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;/head&gt;</pre></td></tr></table></div>
<p>This code will add all javascript library needed and css style in the head of your page.</p>
<h3>Setup the form and choose the good element</h3>
<p>In your main view, you create the form and add the good element for your autocomplete input.</p>
<p>Dojo provide 2 type of Element : FilteringSelect and ComboBox. For this exemple, I have choose the FilteringSelect element.</p>
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #000088;">$form</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Form<span style="color: #339933;">;</span>
<span style="color: #000088;">$element</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Dojo_Form_Element_FilteringSelect<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'id'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$element</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setAutoComplete</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span>
			<span style="color: #339933;">-&gt;</span><span style="color: #004000;">setStoreId</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'tidStore'</span><span style="color: #009900;">&#41;</span>
			<span style="color: #339933;">-&gt;</span><span style="color: #004000;">setStoreType</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'dojox.data.QueryReadStore'</span><span style="color: #009900;">&#41;</span>
			<span style="color: #339933;">-&gt;</span><span style="color: #004000;">setStoreParams</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'url'</span><span style="color: #339933;">=&gt;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">BaseUrl</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/admin/translate/autocomplete'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
			<span style="color: #339933;">-&gt;</span><span style="color: #004000;">setAttrib</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;searchAttr&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;id&quot;</span><span style="color: #009900;">&#41;</span>
			<span style="color: #339933;">-&gt;</span><span style="color: #004000;">setRequired</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$submit</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$form</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'submit'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'submit'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$form</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addElements</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$element</span><span style="color: #339933;">,</span> <span style="color: #000088;">$submit</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">print</span> <span style="color: #000088;">$form</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>
<h3>Providing data for the autocomplete field</h3>
<p>Now in the controller, we create a new action autocompleteAction to generate data in json format.<br />
In this function, you must disable the view renderer and the layout.</p>
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> autocompleteAction<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_helper<span style="color: #339933;">-&gt;</span><span style="color: #004000;">viewRenderer</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setNoRender</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_helper<span style="color: #339933;">-&gt;</span><span style="color: #004000;">layout</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">disableLayout</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$id</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_getParam<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;id&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$id</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$id</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//fix : remove * at the end of the ID.</span>
&nbsp;
        <span style="color: #000088;">$MyTable</span><span style="color: #339933;">=</span> MyTable<span style="color: #339933;">::</span><span style="color: #004000;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$select</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$MyTable</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">select</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;id&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">limit</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">5</span><span style="color: #009900;">&#41;</span>
        <span style="color: #000088;">$select</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">where</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'id LIKE ?'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;%&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$id</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;%&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$results</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$MyTable</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fetchAll</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$select</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Dojo_Data<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'id'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$results</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// Send our output</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_helper<span style="color: #339933;">-&gt;</span><span style="color: #004000;">autoCompleteDojo</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>
<p>This action will be called by the form element each time the value will change in the input and add propose 5 new possibility for the user to select. </p>
<p>(This exemple was tested on Zend Framework 1.9.5 and Dojo 1.3.2)</p>
<!-- google_ad_section_end --><img src="http://www.m4d3l-network.com/?ak_action=api_record_view&id=416&type=feed" alt="" />
<p>Related posts:<ol><li><a href='http://www.m4d3l-network.com/developpement/php/zend-framework/zend_form-how-to-remove-decorator-from-hidden-field/' rel='bookmark' title='Permanent Link: Zend_Form : How to remove decorator from hidden field.'>Zend_Form : How to remove decorator from hidden field.</a></li>
<li><a href='http://www.m4d3l-network.com/developpement/php/zend-framework/add-language-route-to-your-zend-framework-project/' rel='bookmark' title='Permanent Link: Add language route to your Zend Framework project.'>Add language route to your Zend Framework project.</a></li>
<li><a href='http://www.m4d3l-network.com/developpement/php/zend-framework/how-to-use-flickr-with-zend-framework/' rel='bookmark' title='Permanent Link: How to use Flickr with Zend Framework?'>How to use Flickr with Zend Framework?</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.m4d3l-network.com/developpement/php/autocomplete-field-with-zend-framework-and-dojo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Phenix_Wiki, a parser componant for Zend Framework</title>
		<link>http://www.m4d3l-network.com/developpement/php/zend-framework/phenix_wiki/</link>
		<comments>http://www.m4d3l-network.com/developpement/php/zend-framework/phenix_wiki/#comments</comments>
		<pubDate>Sun, 01 Nov 2009 18:03:01 +0000</pubDate>
		<dc:creator>M4d3L</dc:creator>
				<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[BBcode]]></category>
		<category><![CDATA[componant]]></category>
		<category><![CDATA[Creole]]></category>
		<category><![CDATA[Liens sur Zend Framework]]></category>
		<category><![CDATA[parser]]></category>
		<category><![CDATA[parser class]]></category>
		<category><![CDATA[phenix]]></category>
		<category><![CDATA[Phenix_Wiki]]></category>
		<category><![CDATA[render]]></category>
		<category><![CDATA[singleton method]]></category>
		<category><![CDATA[superscript]]></category>
		<category><![CDATA[Wiki]]></category>
		<category><![CDATA[XHTML]]></category>
		<guid isPermaLink="false">http://www.m4d3l-network.com/?p=92</guid>
		<description><![CDATA[Phenix_Wiki is a new component of the PhenixApp project. This component parse structured wiki text and render it into arbitrary formats such as XHTML. How to use it with Factory method. Factory methode returns a Phenix_Wiki Parser class for the specified parser For Default parser : 1 2 $wiki = Phenix_Wiki::factory&#40;&#34;Default&#34;&#41;; echo $wiki-&#62;transform&#40;$text, 'xhtml'&#41;; For [...]
Related posts:<ol><li><a href='http://www.m4d3l-network.com/developpement/phenix_file_parser_csv/' rel='bookmark' title='Permanent Link: Phenix_File_Parser_Csv'>Phenix_File_Parser_Csv</a></li>
<li><a href='http://www.m4d3l-network.com/developpement/php/zend-framework/en-phenix_view_helper_text2image/' rel='bookmark' title='Permanent Link: Phenix_View_Helper_Text2image (English)'>Phenix_View_Helper_Text2image (English)</a></li>
<li><a href='http://www.m4d3l-network.com/developpement/php/autocomplete-field-with-zend-framework-and-dojo/' rel='bookmark' title='Permanent Link: Autocomplete field with Zend Framework and Dojo'>Autocomplete field with Zend Framework and Dojo</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>Phenix_Wiki is a new component of the <a href="http://www.phenixapp-project.net">PhenixApp project</a>. This component parse structured wiki text and render it into arbitrary formats such as XHTML.<br />
<span id="more-92"></span></p>
<h3>How to use it with Factory method.</h3>
<p>Factory methode returns a Phenix_Wiki Parser class for the specified parser</p>
<p>For Default parser :<br />
<code></p>
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$wiki</span> <span style="color: #339933;">=</span> Phenix_Wiki<span style="color: #339933;">::</span><span style="color: #004000;">factory</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Default&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$wiki</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">transform</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'xhtml'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>
<p></code><br />
For BBcode (with specified rules):<br />
<code></p>
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$rule</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Prefilter'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Delimiter'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Code'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Function'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Html'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Raw'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Include'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Embed'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Anchor'</span><span style="color: #339933;">,</span>
              <span style="color: #0000ff;">'Heading'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Toc'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Horiz'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Break'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Blockquote'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'List'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Deflist'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Table'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Image'</span><span style="color: #339933;">,</span>
              <span style="color: #0000ff;">'Phplookup'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Center'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Newline'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Paragraph'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Url'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Freelink'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Interwiki'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Wikilink'</span><span style="color: #339933;">,</span>
              <span style="color: #0000ff;">'Colortext'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Strong'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Bold'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Emphasis'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Italic'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Underline'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Tt'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Superscript'</span><span style="color: #339933;">,</span>
              <span style="color: #0000ff;">'Subscript'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Revise'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Tighten'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$wiki</span> <span style="color: #339933;">=</span> Phenix_Wiki<span style="color: #339933;">::</span><span style="color: #004000;">factory</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Bbcode&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$rule</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$wiki</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">transform</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'xhtml'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>
<p></code><br />
For Creole :<br />
<code></p>
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$wiki</span> <span style="color: #339933;">=</span> Phenix_Wiki<span style="color: #339933;">::</span><span style="color: #004000;">factory</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Creole&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$wiki</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">transform</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'xhtml'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>
<p></code></p>
<h3>How to use it with Singleton method</h3>
<p>This avoids instantiating multiple Phenix_Wiki instances where a number of objects are required in one call, e.g. to save memory in a CMS environment where several parsers are required in a single page.<br />
<code></p>
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$wiki</span> <span style="color: #339933;">=</span> Phenix_Wiki<span style="color: #339933;">::</span><span style="color: #004000;">singleton</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Bbcode&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$wiki</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">transform</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'xhtml'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>
<p></code></p>
<h3>Where to find the component?</h3>
<p>Web Repository : <a href="http://www.phenixapp-project.net/repositories/browse/phenixapp/trunk/PhenixApp/libs/Phenix/Wiki">http://www.phenixapp-project.net/repositories/browse/phenixapp/trunk/PhenixApp/libs/Phenix/Wiki</a><br />
To access via SVN : <strong>svn://phenixapp-project.net/phenixapp/trunk/PhenixApp/libs/Phenix/Wiki</strong></p>
<p>Note that this first version is not recommanded for production.</p>
<!-- google_ad_section_end --><img src="http://www.m4d3l-network.com/?ak_action=api_record_view&id=92&type=feed" alt="" />
<p>Related posts:<ol><li><a href='http://www.m4d3l-network.com/developpement/phenix_file_parser_csv/' rel='bookmark' title='Permanent Link: Phenix_File_Parser_Csv'>Phenix_File_Parser_Csv</a></li>
<li><a href='http://www.m4d3l-network.com/developpement/php/zend-framework/en-phenix_view_helper_text2image/' rel='bookmark' title='Permanent Link: Phenix_View_Helper_Text2image (English)'>Phenix_View_Helper_Text2image (English)</a></li>
<li><a href='http://www.m4d3l-network.com/developpement/php/autocomplete-field-with-zend-framework-and-dojo/' rel='bookmark' title='Permanent Link: Autocomplete field with Zend Framework and Dojo'>Autocomplete field with Zend Framework and Dojo</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.m4d3l-network.com/developpement/php/zend-framework/phenix_wiki/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dites non a Smarty</title>
		<link>http://www.m4d3l-network.com/developpement/php/dites-non-a-smarty/</link>
		<comments>http://www.m4d3l-network.com/developpement/php/dites-non-a-smarty/#comments</comments>
		<pubDate>Thu, 16 Jul 2009 17:00:47 +0000</pubDate>
		<dc:creator>M4d3L</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[smarty]]></category>
		<category><![CDATA[solution intelligente]]></category>
		<category><![CDATA[template engine]]></category>
		<category><![CDATA[zend]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[zend_layout]]></category>
		<category><![CDATA[Zend_View]]></category>
		<guid isPermaLink="false">http://www.m4d3l-network.com/?p=304</guid>
		<description><![CDATA[Sortit en janvier 2001, Smarty est devenue un projet stagnant et contenant encore beaucoup de bug. De plus est, Smarty est devenu, aujourd&#8217;hui, l&#8217;engin de template PHP le plus populaire et le plus utiliser. Mais cela ne devrait pas être le cas. Cet article est pour avertir les développeurs de ne pas utiliser cet engin [...]
No related posts.]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><div id="attachment_339" class="wp-caption alignleft" style="width: 260px"><a href="http://www.smarty.net" rel="nofollow" target="_blank"><img src="http://www.m4d3l-network.com/wp-content/uploads/2009/07/smarty-logo-orange.gif" alt="Smarty - Engin de template" title="Smarty - Engin de template" width="250" height="64" class="size-full wp-image-339" /></a><p class="wp-caption-text">Smarty - Engin de template</p></div>
<p>Sortit en janvier 2001, Smarty est devenue un projet stagnant et contenant encore beaucoup de bug. De plus est, Smarty est devenu, aujourd&#8217;hui, l&#8217;engin de template PHP le plus populaire et le plus utiliser. Mais cela ne devrait pas être le cas. Cet article est pour avertir les développeurs de ne pas utiliser cet engin et utiliser des alternatives qui sont de loin supérieures.</p>
<p>Cette articles est aussi, en partie, une traduction dans mes propres mots du site anglais <a rel="nofollow" href="http://nosmarty.net" target="_blank">nosmarty.net</a></p>
<p><span id="more-304"></span></p>
<h3>Est-ce que SMARTY est bon pour moi?</h3>
<p>Il ne faut pas se fier au nom de l&#8217;engin, car SMARTY n&#8217;est pas la solution la plus intelligente disponible actuellement. C&#8217;est vrai que SMARTY a recu <a href="http://solarphp.com/" rel="nofollow" target="_blank">plusieurs mentions</a> année après année. Mais quoi qu&#8217;il en soit, la plupart d&#8217;entre eux on été écrit par des développeur qui n&#8217;était vraisemblablement pas familier avec une <a href="http://en.wikipedia.org/wiki/Multitier_architecture" rel="nofollow" target="_blank">architecture multi-tier</a>. Pour ces utilisateurs,  le concept de séparation de la logique et de la présentation est un concept innovateur.  Mais SMARTY est seulement une façon pour parvenir a faire cette séparation (qui ne fait pas très bien d&#8217;ailleurs) et aujourd&#8217;hui totalement dépasser par les autres produits existants.</p>
<div class="moreinfo">
<h4>Quelques solutions de rechange plus intelligentes</h4>
<p>Il existe plusieurs alternatives à SMARTY.</p>
<ul>
<li><a rel="nofollow" href="http://framework.zend.com/docs/screencasts" target="_blank">Zend Framework</a></li>
<li><a rel="nofollow" href="http://solarphp.com/" target="_blank">Solar</a></li>
<li><a rel="nofollow" href="http://www.symfony-project.org/installation" target="_blank">Symfony</a></li>
<li><a rel="nofollow" href="http://phptal.motion-twin.com/download.html" target="_blank">PHPTAL</a></li>
<li><a rel="nofollow" href="http://en.wikipedia.org/wiki/XSL_Transformations" target="_blank">XSLT</a></li>
</ul>
<p>Personnellement, comme vous avez pu le remarquer sur mon blogue, je suis vendu à Zend Framework. Il fait une très belle job et assez simple a utiliser et intégrer.  Consultez la documentation sur Zend_View et Zend_Layout et vous pourrez juger par vous même.</p></div>
<p>SMARTY a sur son <a href="http://www.smarty.net" rel="nofollow" target="_blank">site web</a> une <a href="http://www.smarty.net/rightforme.php" rel="nofollow" target="_blank">liste des bénéfices (en anglais)</a>. Allons voir quelque un de ces bénéfices et descendons-les de leurs piédestaux. </p>
<h4>Caching</h4>
<p>Voici ce que SMARTY dit (en anglais) : </p>
<blockquote><p>Smarty provides fine-grained caching features for caching all or parts of a rendered web page, or leaving parts uncached. Programmers can register template functions as cacheable or non-cachable, group cached pages into logical units for easier management, etc.</p></blockquote>
<p>OK. Alors, jetons un oeil au système de cache de Smarty. Pour activer le cache, vous allez écrire quelque chose comme :</p>
<p><code></p>
<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$smarty</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Smarty<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$smarty</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">caching</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span></pre></div></div>
<p></code></p>
<p>Cela configure le cache avec un temps de vie de 3600 secondes (1 heure). Comment faire alors si vous voulez utiliser un <a href="http://fr.wikipedia.org/wiki/Time-To-Live" rel="nofollow" target="_blank">TTL</a>, disons, de 30 minutes? Vous allez écrire :</p>
<p><code></p>
<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$smarty</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Smarty<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$smarty</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">caching</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$smarty</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">cache_lifetime</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1800</span><span style="color: #339933;">;</span></pre></div></div>
<p></code></p>
<p>Oh, évidement, <em>$smarty->caching = 2;</em>. Quoi d&#8217;autre cela aurait pu être? Bien&#8230; une constante aux lieux d&#8217;un nombre magique aurait été, bien mieux je crois. Mais attendez, pourquoi le TTL dépend qu&#8217;un nombre magique soit configuré pour pouvoir s&#8217;appliquer? Si <em>caching</em> est accessible directement par une propriété publique de Smarty, ne devrait-il pas être au moins un boulean, soit vrai ou faux?</p>
<p>Il y a plusieurs casse-têtes comme cela un peu partout dans Smarty. Le fait que ce soit non intuitif à un impacte réelle sur notre usage au jour le jour de Smarty, car nous sommes forcés de nous référer à la documentation encore et encore pour des choses souvent très courantes.</p>
<p>La syntaxe n&#8217;est pas le seul problème. Utiliser le cache de Smarty dans un environnement avec plusieurs serveurs peut s&#8217;avérer un vrai mal de tête, car les fichiers générés ne peuvent pas être réutilisés par un autre serveur sauf s&#8217;il utilise des systèmes de fichier en cluster comme GFS ou OCFS.</p>
<h4>Configuration</h4>
<p>Jetons un oeil à la configuration (en anglais) :</p>
<blockquote><p>Smarty can assign variables pulled from configuration files. Template designers can maintain values common to several templates in one location without intervention from the programmer, and config variables can easily be shared between the programming and presentation portions of the application.</p></blockquote>
<p>Smarty vous permet de sauvegarder vos fichiers de configuration en format INI et ensuite les charger. Il y a déja une fonction php pour cela. Elle s&#8217;appelle <em>parse_ini_file()</em>. Sauf si vous êtes résistant a utiliser php dans vos template de vue, le chargement des configurations dois ce faire dans la partit logique de toute façons. (Incidemment, Smarty n&#8217;utilise pas cette fonction, il opte plutôt pour sont propre mécanisme de traitement pour aucune raison apparente).</p>
<h4>Sécurité</h4>
<p>Et maintenant la sécurité (toujours en anglais):</p>
<blockquote><p>Templates do not contain PHP code. Therefore, a template designer is not unleashed with the full power of PHP, but only the subset of functionality made available to them from the programmer (application code.)</p></blockquote>
<p>Ne penser jamais qu&#8217;une application est plus sécuritaire simplement parce que sont engin de template assure qu&#8217;il sécurise votre application. La seul sécurité que vous pouvez avoir c&#8217;est de désactiver le tag {php} et cela entraîne une augmentation énorme de l&#8217;inflexibilité qu&#8217;aura votre designer de template. Il faudra alors que votre développeur PHP développe de nombreux plug-ins au fur et à mesure que votre designer de template progressera. La plupart des sites qui utilise Smarty avec le tag {php} activé pour éviter d&#8217;avoir a faire milles courbettes pour arriver à leur résultat. Donc où est la véritable sécurité dans Smarty?</p>
<p> De toutes façons, aujourd&#8217;hui, les trous de sécurité les plus courants ne viennent pas des templates, mais des développeurs paresseux qui ne filtre pas les données entrantes. Si vous avez un trou de sécurité dans un template, je vous conseille de changer de développeur! La meilleure sécurité se trouve dans un bon développeur consciencieux! </p>
<h4>Facile à utiliser et à maintenir</h4>
<p>Smarty dit ceci à propos de sa facilité d&#8217;utilisation (encore et toujours en anglais) :</p>
<blockquote><p>Web page designers are not dealing with PHP code syntax, but instead an easy-to-use templating syntax not much different than plain HTML. The templates are a very close representation of the final output, dramatically shortening the design cycle.</p></blockquote>
<p>Par le passé, j&#8217;ai personnellement beaucoup utilisé Smarty. La syntax est relativement facile et on pouvais bien voir la séparation du html et de la syntax Smarty. J&#8217;ai appris Smarty, car j&#8217;utilisais le CMS XOOPS. Un système de portail évoluer qui existant sous PHP4. J&#8217;ai après PHP avec ce portail. Bien évidemment, ce portail utilisait Smarty comme engin de template. Cela m&#8217;aidait beaucoup dans le développement de nouveau thème pour ce CMS. Enfin, c&#8217;est ce que je croyais!</p>
<p>Mais regardons un peu cette syntaxe.<br />
<code></p>
<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009900;">&#123;</span><span style="color: #000088;">$foo</span><span style="color: #009900;">&#125;</span></pre></div></div>
<p></code></p>
<p>Ce n&#8217;est pas vraiment plus compliquer à utiliser et à maintenir que :</p>
<p><code></p>
<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?=</span> <span style="color: #000088;">$foo</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>
<p></code></p>
<p>Bon ok. 3 caractères de plus. Mais comparer à toute la compilation qu&#8217;il va faire pour traiter <em>{$foo}</em>, c&#8217;est pas sa qui devrais vous faire reculer.</p>
<p>Et Smarty demontre qu&#8217;il n&#8217;est pas facile a maintenir en comparaisons :<br />
<code></p>
<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?=</span> foo <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>
<p></code></p>
<p>Va afficher &laquo;&nbsp;foo&nbsp;&raquo;, vous donnant un indice que vous vouliez imprimer une variable, mais qu&#8217;il vous manque un signe de $ et puis</p>
<p><code></p>
<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009900;">&#123;</span>foo<span style="color: #009900;">&#125;</span></pre></div></div>
<p></code></p>
<p>Qui va afficher&#8230; rien! Vous laissant complètement dans ignorance que vous avez oublié le signe $.</p>
<p>Et quand vous assignez une variables :<br />
<code></p>
<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009900;">&#123;</span>assign <span style="color: #000000; font-weight: bold;">var</span><span style="color: #339933;">=</span>”foo” value<span style="color: #339933;">=</span>”bar”<span style="color: #009900;">&#125;</span></pre></div></div>
<p></code></p>
<p>c&#8217;est certainement plus facile a lire et plus intuitif que </p>
<p><code></p>
<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #000088;">$foo</span> <span style="color: #339933;">=</span> ‘bar’<span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>
<p></code></p>
<p>Bien sûr ce ne sont que des exemples très basiques. Le vrai test de syntaxe entre PHP et Smarty c&#8217;est avec une approche plus complexe par exemple :</p>
<p><code></p>
<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009900;">&#123;</span>capture assign<span style="color: #339933;">=</span>”foo”<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#123;</span>my_helper var1<span style="color: #339933;">=</span>”bar” var2<span style="color: #339933;">=</span>”qux”<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#123;</span><span style="color: #339933;">/</span>capture<span style="color: #009900;">&#125;</span></pre></div></div>
<p></code></p>
<p>qui est un peu trop bizarre pour les nouveaux utilisateurs comparés a quelque chose comme dans une application MVC :</p>
<p><code></p>
<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #000088;">$foo</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">myHelper</span><span style="color: #009900;">&#40;</span>‘bar’<span style="color: #339933;">,</span> ‘qux’<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>
<p></code></p>
<p>Qui va être beaucoup plus intuitif et facile a comprendre.</p>
<h4>&laquo;&nbsp;Variable Modifiers&nbsp;&raquo;</h4>
<blockquote><p>The content of assigned variables can easily be adjusted at display-time with modifiers, such as displaying in all upper-case, html-escaped, formatting dates, truncating text blocks, adding spaces between characters, etc. Again, this is accomplished with no intervention from the programmer.</p></blockquote>
<p>L&#8217;idée des &laquo;&nbsp;variable modifiers&nbsp;&raquo; est d&#8217;aider le monteur HTML a ne pas avoir a recourir au programmeur php pour faire ses templates. Smarty vient avec 22 de ces modifiés, mais le programmeur devra en créer plusieurs autres pour atteindre cet objectif. Et il y aura toujours de nouvelle demande, encore et encore, et au final, vous activerez <em>{php}</em> car ce sera moins compliqué. </p>
<h4>Fonction de template, Filtre, Plugins et Add-ons</h4>
<blockquote><p>
    Many functions are available to the template designer to handle tasks such as generating HTML code segments (dropdowns, tables, pop-ups, etc.), displaying content from other templates in-line, looping over arrays of content, formatting text for e-mail output, cycling though colors, etc.</p>
<p>    The programmer has complete control of template output and compiled template content with pre-filters, post-filters and output-filters.</p>
<p>    Almost every aspect of Smarty is controlled through the use of plugins. They are generally as easy as dropping them into the plugin directory and then mentioning them in the template or using them in the application code. Many user-community contributions are also available. (See the plugins section of the forum and wiki.)</p>
<p>    Many user-community contributed Add-ons are available such as Pagination, Form Validation, Drop Down Menus, Calander Date Pickers, etc. These tools help speed up the development cycle, there is no need to re-invent the wheel or debug code that is already stable and ready for deployment. (see the Add-ons section of the forum and wiki.)
</p></blockquote>
<p>Smarty a plusieurs noms pour ses aides de vue. Les aides de vue sont très pratiques, mais il existe des aides de vue bien meilleure que celle de Smarty avec un plus grand lot de fonctionnalité. La vérité c&#8217;est que les aides de vue par défaut de Smarty font le minimum pour aider le programmeur et plusieurs de ces addons contienne du code qui non pas leur place dans un engin de template. C&#8217;est le résultat d&#8217;une mauvaise séparation des logiques.</p>
<h4>Ressources</h4>
<blockquote><p>Templates can be pulled from any number of sources by creating new resource handlers, then using them in the templates.</p></blockquote>
<h4>Mode de debug</h4>
<p>Smarty dit ceci à propos de sont mode de débogage :</p>
<blockquote><p>Smarty comes with a built-in debugging console so the template designer can see all of the assigned variables and the programmer can investigate template rendering speeds.</p></blockquote>
<p>C&#8217;est de loin une interface à la Firebug. C&#8217;est simplement un dump de variable de 200 lignes et plus très difficile à suivre.</p>
<h4>Compilation</h4>
<blockquote><p>Smarty compiles templates into PHP code behind the scenes, eliminating run-time parsing of templates.</p></blockquote>
<p>Smarty va compiler ses templates en code PHP. Ça devrait vous donner une bonne piste! Vraiment!</p>
<h4>Performence</h4>
<blockquote><p>Smarty performs extremely well, despite its vast feature set. Most of Smarty’s capabilities lie in plugins that are loaded on-demand. Smarty comes with numerous presentation tools, minimizing your application code and resulting in quicker, less error-prone application development/deployment. Smarty templates get compiled to PHP files internally (once), eliminating costly template file scans and leveraging the speed of PHP op-code accelerators.</p></blockquote>
<p>Rien en PHP ne pourrait être plus rapide que PHP lui même! PHP est déjà lui même un engin de template à la base.</p>
<h3>Conclusion</h3>
<p>Pour conclure, si Smarty n&#8217;est pas le bon outil pour faire la job, quel autre outil puis-je utiliser? Il y a plusieurs alternatives qui font exactement ce que Smarty fait, mais encore mieux! Mon framework favori pour le moment est <a href="http://framework.zend.com/">Zend Framework</a>. Il supporte plusieurs types de cache, de configuration, de filtre, d&#8217;aide de vue et plus encore. Il est écrit en PHP5 et utilise PHP5 tout simplement pour ses templates. Il y aussi d&#8217;autre alternative que vous pourrez facilement trouver en faisant une petite recherche sur Google.</p>
<p><strong>Mais s&#8217;il vous plait&#8230; n&#8217;utiliserplus SMARTY!</strong></p>
<!-- google_ad_section_end --><img src="http://www.m4d3l-network.com/?ak_action=api_record_view&id=304&type=feed" alt="" />
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.m4d3l-network.com/developpement/php/dites-non-a-smarty/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>Migration vers PHP 5.3</title>
		<link>http://www.m4d3l-network.com/developpement/php/migration-vers-php-5-3/</link>
		<comments>http://www.m4d3l-network.com/developpement/php/migration-vers-php-5-3/#comments</comments>
		<pubDate>Thu, 02 Jul 2009 18:46:55 +0000</pubDate>
		<dc:creator>M4d3L</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[deprecated]]></category>
		<category><![CDATA[goto]]></category>
		<category><![CDATA[language]]></category>
		<category><![CDATA[méthode magiques]]></category>
		<category><![CDATA[migration]]></category>
		<category><![CDATA[namespace]]></category>
		<category><![CDATA[nouvelle version]]></category>
		<category><![CDATA[obsolete]]></category>
		<category><![CDATA[php 5.3]]></category>
		<category><![CDATA[tableau]]></category>
		<category><![CDATA[version final]]></category>
		<guid isPermaLink="false">http://www.m4d3l-network.com/?p=225</guid>
		<description><![CDATA[Cette article est basé sur &#171;&#160;iBuildings &#8211; Migrating to PHP 5.3&#171;&#160; Cette semaine, PHP 5.3 a été finalement releaser en version finale. Cette nouvelle version de PHP comprend plus de changement que toutes les dernières versions depuis 7 ans. Cela va beaucoup affecter les applications de demain et les changements dans le langage vont bouleverser [...]
No related posts.]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><blockquote><p>Cette article est basé sur &laquo;&nbsp;<a href="http://techportal.ibuildings.com/2009/06/30/migrating-to-php-5-3/" rel="nofollow">iBuildings &#8211; Migrating to PHP 5.3</a>&laquo;&nbsp;</p></blockquote>
<p>Cette semaine, PHP 5.3 a été finalement releaser en version finale. Cette nouvelle version de PHP comprend plus de changement que toutes les dernières versions depuis 7 ans. Cela va beaucoup affecter les applications de demain et les changements dans le langage vont bouleverser les applications d&#8217;hier.</p>
<p>La bonne nouvelle est que si vous avez bien maintenu le code de vos applications à jour, il n&#8217;y aura que très peu de changement à effectuer pour vous mettre a jour. La mauvaise nouvelle c&#8217;est que plus votre version actuelle de PHP est vielle, plus vous aller devoir ramer pour tout mettre a jour! Pour ceux qui utilisent la branche de PHP 5.2, il existe quelques situations qu&#8217;il vous faudra faire attention.</p>
<p>Ce qui suit n&#8217;est pas une liste de toutes les nouvelles fonctionnalités de PHP 5.3. Vous les trouverai au complet sur le site de <a title="PHP Guide de migration 5.2 vers 5.3" href="http://ca2.php.net/manual/fr/migration53.php">PHP.net</a>. Nous vous donnerons plutôt un résumer du guide de migration de PHP 5.3. Nous allons couvrir les articles les plus susceptibles de toucher l&#8217;héritage du code de la branche 5.x.<br />
<span id="more-225"></span></p>
<h3>Fonctions de traitement des Tableaux</h3>
<p>Avant la version 5.3, plusieurs des fonctions de traitement des tableaux pouvaient prendre des objets ou des tableaux comme paramètre et bien fonctionner. Avec la version 5.3, plusieurs d&#8217;entre eux prennent maintenant que les tableaux. Si vous voulez accéder à la propriter d&#8217;un objet avec l&#8217;une de ces fonctions, vous devrez d&#8217;abord le transformer en tableaux.</p>
<ul>
<li><a href="http://www.php.net/manual/fr/function.natsort.php">natsort</a>()</li>
<li><a href="http://www.php.net/manual/fr/function.natcasesort.php">natcasesort</a>()</li>
<li><a href="http://www.php.net/manual/fr/function.usort.php">usort</a>()</li>
<li><a href="http://www.php.net/manual/fr/function.uasort.php">uasort</a>()</li>
<li><a href="http://www.php.net/manual/fr/function.uksort.php">uksort</a>()</li>
<li><a href="http://www.php.net/manual/fr/function.array-flip.php">array_flip</a>()</li>
<li><a href="http://www.php.net/manual/fr/function.array-unique.php">array_unique</a>()</li>
</ul>
<h3>Changement pour les méthodes magiques</h3>
<p>Précèdament à la version 5.3, les <a href="http://www.php.net/manual/fr/language.oop5.magic.php">méthodes magiques</a> pouvais être déclarer comme étant autre chose que public.</p>
<ul>
<li>__get()</li>
<li>__set()</li>
<li>__isset()</li>
<li>__unset()</li>
<li>__call()</li>
</ul>
<p>Depuis PHP 5.3, ces méthodes ne peuvent être déclarées que public et ne peuvent pas être static.</p>
<h3>Deprecated</h3>
<p>PHP dispose d&#8217;une liste de fonctions qui ont été marquées pour être supprimées dans les prochaines versions. La plupart de c&#8217;est fonction ne sont pas communes, mais si vous du code assez vieux, vous souhaiterez surement les recherches et les retirer.</p>
<p>Les fonctions sont marqués comme obsolète:</p>
<ul>
<li><a href="http://www.php.net/manual/fr/function.call-user-method.php">call_user_method</a>()</li>
<li><a href="http://www.php.net/manual/fr/function.call-user-method-array.php">call_user_method_array</a>()</li>
<li><a href="http://www.php.net/manual/fr/function.define-syslog-variables.php">define_syslog_variables</a>()</li>
<li><a href="http://www.php.net/manual/fr/function.ereg.php">ereg</a>()</li>
<li><a href="http://www.php.net/manual/fr/function.ereg-replace.php">ereg_replace</a>()</li>
<li><a href="http://www.php.net/manual/fr/function.eregi.php">eregi</a>()</li>
<li><a href="http://www.php.net/manual/fr/function.eregi-replace.php">eregi_replace</a>()</li>
<li><a href="http://www.php.net/manual/fr/function.set-magic-quotes-runtime.php">set_magic_quotes_runtime</a>()/<a href="http://www.php.net/manual/fr/function.magic-quotes-runtime.php">magic_quotes_runtime</a>()</li>
<li><a href="http://www.php.net/manual/fr/function.session-register.php">session_register</a>()</li>
<li><a href="http://www.php.net/manual/fr/function.session-unregister.php">session_unregister</a>()</li>
<li><a href="http://www.php.net/manual/fr/function.session-is-registered.php">session_is_registered</a>()</li>
<li><a href="http://www.php.net/manual/fr/function.set-socket-blocking.php">set_socket_blocking</a>()</li>
<li><a href="http://www.php.net/manual/fr/function.split.php">split</a>()</li>
<li><a href="http://www.php.net/manual/fr/function.spliti.php">spliti</a>()</li>
<li><a href="http://www.php.net/manual/fr/function.sql-regcase.php">sql_regcase</a>()</li>
</ul>
<p>De plus, plusieurs directives dans le fichier <a href="http://www.php.net/manual/fr/ini.list.php">PHP.INI</a> sont maintenant obsolète. S&#8217;ils sont activés, vous aurez des messages d&#8217;erreur E_DEPRECATED.</p>
<ul>
<li>define_syslog_variables</li>
<li>register_globals</li>
<li>register_long_arrays</li>
<li>safe_mode</li>
<li>magic_quotes_gpc</li>
<li>magic_quotes_runtime</li>
<li>magic_quotes_sybase</li>
</ul>
<p>Toutes les directives émettant une erreur E_DEPRECATED vont êtres potentiellement retirer dans les versions futures du langage. Vous pouvez trouver plusieurs indices de cela dans la version PHP6.</p>
<h3>Undeprecated</h3>
<p>Dans la version PHP 5.0, la fonction <a href="http://www.php.net/manual/fr/function.is-a.php">is_a</a>() a été abandonné en faveur de instanceof. Toutefois, il n&#8217;a pas été retiré du langage. Avec PHP 5.3, cette décision a été infirmée et cette fonction ne produit plus d&#8217;erreur E_DEPRECATED.</p>
<h3>Terme réservé</h3>
<p>Ces 2 mots calés sont maintenant réservés:</p>
<ul>
<li><a href="http://www.php.net/manual/fr/control-structures.goto.php">GOTO</a></li>
<li><a href="http://www.php.net/manual/fr/language.namespaces.php">NAMESPACE</a></li>
</ul>
<p>Compte tenu de la nature de ces deux mots-clés, il serait douteux de les retrouver dans du vieux code. Il est une bonne idée d&#8217;effectuer une recherche dans votre code pour les modifier s&#8217;il existe. S&#8217;il vous ne faite pas les changements, vous aurez une erreur d&#8217;analyse au même titre que si vous oublier un point virgule à la fin d&#8217;une ligne dans votre code. Ils ne peuvent pas être utilisé comme nom de fonction, de class ou autre.</p>
<h3>Conclusion</h3>
<p>C&#8217;est pas mal ça en gros. N&#8217;oubliez pas de lire en détail le guide de <a href="http://ca2.php.net/manual/fr/migration53.php">migration de PHP 5.3</a> sur le site officiel de PHP et disponible en plusieurs langues. PHP 5.3 nous rapproche encore plus d&#8217;un vrai langage que d&#8217;un simple système de template qu&#8217;il était au départ. Si vous êtes inquièt par rapport à cette nouvelle version et votre vieux code, je vous conseil de vous monter un environnement de développement avec la version 5.3 de php installer et de tester votre application avant de migré votre environnement de production. Amusez-vous bien avec cette nouvelle version!</p>
<h3>AutreS liens d&#8217;intérêt : </h3>
<p><a href="http://g-rossolini.developpez.com/tutoriels/php/5.3/">Les nouveautés de PHP 5.3</a></p>
<!-- google_ad_section_end --><img src="http://www.m4d3l-network.com/?ak_action=api_record_view&id=225&type=feed" alt="" />
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.m4d3l-network.com/developpement/php/migration-vers-php-5-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Add language route to your Zend Framework project.</title>
		<link>http://www.m4d3l-network.com/developpement/php/zend-framework/add-language-route-to-your-zend-framework-project/</link>
		<comments>http://www.m4d3l-network.com/developpement/php/zend-framework/add-language-route-to-your-zend-framework-project/#comments</comments>
		<pubDate>Mon, 29 Jun 2009 20:59:00 +0000</pubDate>
		<dc:creator>M4d3L</dc:creator>
				<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[config]]></category>
		<category><![CDATA[controller plugin]]></category>
		<category><![CDATA[default controller]]></category>
		<category><![CDATA[default language]]></category>
		<category><![CDATA[default route]]></category>
		<category><![CDATA[demonstration]]></category>
		<category><![CDATA[dispatcher]]></category>
		<category><![CDATA[language]]></category>
		<category><![CDATA[language resources]]></category>
		<category><![CDATA[module resource]]></category>
		<category><![CDATA[module structure]]></category>
		<category><![CDATA[parameters]]></category>
		<category><![CDATA[reference guide]]></category>
		<category><![CDATA[resource]]></category>
		<category><![CDATA[router]]></category>
		<category><![CDATA[translate]]></category>
		<category><![CDATA[translation]]></category>
		<guid isPermaLink="false">http://www.m4d3l-network.com/?p=189</guid>
		<description><![CDATA[Today it&#8217;s easy to make business with other country and to join the most poeple as possible, our website must be translated in many language. This tutorial will show you how to integrate multi-language into your URL with Zend Framework controller route component and be able to use it with the Url helper in your [...]
Related posts:<ol><li><a href='http://www.m4d3l-network.com/developpement/php/autocomplete-field-with-zend-framework-and-dojo/' rel='bookmark' title='Permanent Link: Autocomplete field with Zend Framework and Dojo'>Autocomplete field with Zend Framework and Dojo</a></li>
<li><a href='http://www.m4d3l-network.com/developpement/php/zend-framework/how-to-use-flickr-with-zend-framework/' rel='bookmark' title='Permanent Link: How to use Flickr with Zend Framework?'>How to use Flickr with Zend Framework?</a></li>
<li><a href='http://www.m4d3l-network.com/developpement/php/zend-framework/phenix_wiki/' rel='bookmark' title='Permanent Link: Phenix_Wiki, a parser componant for Zend Framework'>Phenix_Wiki, a parser componant for Zend Framework</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>Today it&#8217;s easy to make business with other country and to join the most poeple as possible, our website must be translated in many language. This tutorial will show you how to integrate multi-language into your URL with Zend Framework controller route component and be able to use it with the Url helper in your layout.</p>
<p>This tutorial requiere Zend Framework 1.8.2 version or higher.<br />
<span id="more-189"></span><br />
Summary : </p>
<ul>
<li><a href="#Route">Route configuration</a></li>
<li><a href="#Plugin">Multilanguage Plugin</a></li>
<li><a href="#url_helper">Url Helper howto</a></li>
<li><a href="#Conclusion">Conclusion</a></li>
</ul>
<h4 id="Route">Route configuration</h4>
<p>This tutorial will show you how to setup your route in .ini config. But you can do it with any other configuration type.  The demonstration will also use the Module structure of Zend Framework.</p>
<p>Here we setup the default module route without any parameters because it will automatically use the Dispatcher to setup it. Note the abstract param. This part is not actually documented in the ZF Programmer&#8217;s reference guide but Abstract parameter make the route to be unusable outside a chain route.</p>
<p><code></p>
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="ini" style="font-family:monospace;">resources.router.routes.defaultmodule.type <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> Zend_Controller_Router_Route_Module</span>
resources.router.routes.defaultmodule.abstract <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> On    </span>
resources.router.routes.defaultmodule.defaults.module <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;system&quot;</span></pre></td></tr></table></div>
<p></code></p>
<p>After we setup the language route with default language if you need it and the regex of what is expected for the language value.<br />
<code></p>
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>4
5
6
7
</pre></td><td class="code"><pre class="ini" style="font-family:monospace;">resources.router.routes.language.type <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> Zend_Controller_Router_Route</span>
resources.router.routes.language.route <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;:language&quot;</span>
resources.router.routes.language.reqs.language <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;^(fr|en)$&quot;</span>
resources.router.routes.language.defaults.language <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;en&quot;</span></pre></td></tr></table></div>
<p></code></p>
<p>Than we setup the default route to overwrite the one create by default by the Front Controller.<br />
<code></p>
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>8
9
</pre></td><td class="code"><pre class="ini" style="font-family:monospace;">resources.router.routes.default.type <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> Zend_Controller_Router_Route_Chain</span>
resources.router.routes.default.chain <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;language, defaultmodule&quot;</span></pre></td></tr></table></div>
<p></code></p>
<p>This configuration mean that if you call url like http://www.exemple.com/, language will be English, module will be default, controller will be index and action will be index.<br />
If you call http://www.exemple.com/fr/articles , language will be french, and module will be articles.</p>
<blockquote><p>Dont forgot to setup your locale and translate resources!</p></blockquote>
<h4 id="Plugin">Multilanguage Plugin</h4>
<p>In this part I will explain how to create your multilanguage plugin for controller. I assume here you know how to setup your Controller plugin into your Front Controller and pass directly to the Plugin class. It&#8217;s very basic and you will have to adapte to your own use.</p>
<p>Create a new class in your own library componant with routeShutdown method.<br />
<code></p>
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> My_Controller_Plugin_Multilanguage <span style="color: #000000; font-weight: bold;">extends</span> Zend_Controller_Plugin_Abstract<span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> routeStartup <span style="color: #009900;">&#40;</span>Zend_Controller_Request_Abstract <span style="color: #000088;">$request</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> routeShutdown <span style="color: #009900;">&#40;</span>Zend_Controller_Request_Abstract <span style="color: #000088;">$request</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>
<p></code></p>
<p>In the routeStartup method, we add a quick fix to be sure the language is alway in each RequestUri. If the language parameter is not there, we force it.<br />
<code></p>
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$request</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getRequestUri</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$request</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getBaseUrl</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$request</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setRequestUri</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$request</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getRequestUri</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;en&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$request</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setParam</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;language&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;en&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>
<p></code></p>
<p>In the routeShutdown method you will catch the language and setup the local and translator object already created by the resource. After you setup the translator to the Zend_Controller_Router_Route. This will be something like this :<br />
<code></p>
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$language</span> <span style="color: #339933;">=</span>  <span style="color: #000088;">$request</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getParam</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;language&quot;</span><span style="color: #339933;">,</span> Zend_Registry<span style="color: #339933;">::</span><span style="color: #004000;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Zend_Locale</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getLanguage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$locale</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Locale<span style="color: #009900;">&#40;</span><span style="color: #000088;">$language</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Zend_Registry<span style="color: #339933;">::</span><span style="color: #004000;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Zend_Locale</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setLocale</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$locale</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$translate</span> <span style="color: #339933;">=</span> Zend_Registry<span style="color: #339933;">::</span><span style="color: #004000;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Zend_Translate</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$translate</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getAdapter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setLocale</span><span style="color: #009900;">&#40;</span>Zend_Registry<span style="color: #339933;">::</span><span style="color: #004000;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Zend_Locale</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Zend_Controller_Router_Route<span style="color: #339933;">::</span><span style="color: #004000;">setDefaultTranslator</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$translate</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>
<p></code></p>
<p>Once it done. Url helper will be very easy to use.</p>
<h4 id="url_helper">Url Helper howto</h4>
<p>Ok, here if you have lot of route setup, you will need the $currentRoute parameter in your url helper. If you play only with the default route, you don&#8217;t need the following part. Jump to the next step.<br />
<code></p>
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$front</span> <span style="color: #339933;">=</span> Zend_Controller_Front<span style="color: #339933;">::</span><span style="color: #004000;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$router</span> <span style="color: #339933;">=</span> Zend_Controller_Front<span style="color: #339933;">::</span><span style="color: #004000;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getRouter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$currentRoute</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$router</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getCurrentRouteName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$locale</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">registry</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Zend_Locale</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$currentRoute</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$currentRoute</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;language&quot;</span><span style="color: #009900;">&#41;</span>? <span style="color: #0000ff;">&quot;default&quot;</span><span style="color: #339933;">:</span> <span style="color: #000088;">$currentRoute</span><span style="color: #339933;">;</span></pre></td></tr></table></div>
<p></code></p>
<p>In the last part, I show you a basic Language Switch I did for my project. It check the current language and dont show the link of the current language.<br />
See the Zend_View_Helper_Url parameter. If I dont put the language param in the array, it will show the current one. This link will switch between the same page but in different language.<br />
<code></p>
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">&lt;div id=&quot;langswitch&quot;&gt;
	<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$locale</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getLanguage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">&quot;fr&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;a href=&quot;<span style="color: #000000; font-weight: bold;">&lt;?=</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">url</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;language&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;fr&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$currentRoute</span><span style="color: #009900;">&#41;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;Fran­­cais&lt;/a&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$locale</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getLanguage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">&quot;en&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;a href=&quot;<span style="color: #000000; font-weight: bold;">&lt;?=</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">url</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;language&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;en&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$currentRoute</span><span style="color: #009900;">&#41;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;English&lt;/a&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;/div&gt;</pre></td></tr></table></div>
<p></code></p>
<p>An other example that will output http://www.exemple.com/fr/articles/<br />
<code></p>
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">&lt;a href=&quot;<span style="color: #000000; font-weight: bold;">&lt;?=</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">url</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;language&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;fr&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;module&quot;</span> <span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">&quot;articles&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;action&quot;</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">&quot;list&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;default&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;Module Articles&lt;/a&gt;</pre></td></tr></table></div>
<p></code></p>
<h4 id="Conclusion">Conclusion</h4>
<p>This example is take from my current <a href="http://www.phenixapp-project.net">PhenixApp project</a>. All my source can be found in the repository. The code on my repository is not the same because I had more option like I take my default language from the database and I have some other route that I have to work with.</p>
<p>With the code in this tutorial, you get a working and easy multilanguage URL. You can integrate it very fast to your existing project because it use chain routing and dont broke any other route already exist.</p>
<p>If you like this tutorial or want to improve it, you can add comment.</p>
<!-- google_ad_section_end --><img src="http://www.m4d3l-network.com/?ak_action=api_record_view&id=189&type=feed" alt="" />
<p>Related posts:<ol><li><a href='http://www.m4d3l-network.com/developpement/php/autocomplete-field-with-zend-framework-and-dojo/' rel='bookmark' title='Permanent Link: Autocomplete field with Zend Framework and Dojo'>Autocomplete field with Zend Framework and Dojo</a></li>
<li><a href='http://www.m4d3l-network.com/developpement/php/zend-framework/how-to-use-flickr-with-zend-framework/' rel='bookmark' title='Permanent Link: How to use Flickr with Zend Framework?'>How to use Flickr with Zend Framework?</a></li>
<li><a href='http://www.m4d3l-network.com/developpement/php/zend-framework/phenix_wiki/' rel='bookmark' title='Permanent Link: Phenix_Wiki, a parser componant for Zend Framework'>Phenix_Wiki, a parser componant for Zend Framework</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.m4d3l-network.com/developpement/php/zend-framework/add-language-route-to-your-zend-framework-project/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Le projet PhenixApp</title>
		<link>http://www.m4d3l-network.com/developpement/php/le-projet-phenixapp/</link>
		<comments>http://www.m4d3l-network.com/developpement/php/le-projet-phenixapp/#comments</comments>
		<pubDate>Sat, 27 Jun 2009 19:49:51 +0000</pubDate>
		<dc:creator>M4d3L</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[application]]></category>
		<category><![CDATA[bootstrap]]></category>
		<category><![CDATA[briickwall]]></category>
		<category><![CDATA[cmf]]></category>
		<category><![CDATA[cms]]></category>
		<category><![CDATA[composant]]></category>
		<category><![CDATA[controleur]]></category>
		<category><![CDATA[controlleur]]></category>
		<category><![CDATA[développeur]]></category>
		<category><![CDATA[elements]]></category>
		<category><![CDATA[interface]]></category>
		<category><![CDATA[members]]></category>
		<category><![CDATA[module]]></category>
		<category><![CDATA[PhenixApp]]></category>
		<category><![CDATA[PhenixApp project]]></category>
		<category><![CDATA[repository]]></category>
		<category><![CDATA[structure definit]]></category>
		<category><![CDATA[system]]></category>
		<category><![CDATA[widgets]]></category>
		<guid isPermaLink="false">http://www.m4d3l-network.com/?p=168</guid>
		<description><![CDATA[PhenixApp est une application construite avec Zend Framework qui propose une structure définit pour que tous les développeur puisse contruire des modules compatible utilisable avec le composant principale de PhenixApp sois, Zend_Application qui permet de bien structurer le démarrage (bootstrap) de l&#8217;application. Chaque module peut écraser les configurations par défaut et donc contrôler le bootstrap. [...]
Related posts:<ol><li><a href='http://www.m4d3l-network.com/developpement/phenix_file_parser_csv/' rel='bookmark' title='Permanent Link: Phenix_File_Parser_Csv'>Phenix_File_Parser_Csv</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p><a href="http://www.phenixapp-project.net"><img class="alignleft size-thumbnail wp-image-177" title="PhenixApp project" src="http://www.m4d3l-network.com/wp-content/uploads/2009/06/phenix-150x150.png" alt="PhenixApp project" width="150" height="150" /></a>PhenixApp est une application construite avec <a href="http://framework.zend.com/">Zend Framework</a> qui propose une structure définit pour que tous les développeur puisse contruire des modules compatible utilisable avec le composant principale de PhenixApp sois, Zend_Application qui permet de bien structurer le démarrage (bootstrap) de l&#8217;application.<br />
<span id="more-168"></span></p>
<p>Chaque module peut écraser les configurations par défaut et donc contrôler le bootstrap. Ils peuvent avoir leurs propres ressource, configuration, composant, plug-in, contrôleur, etc. De base, il y a 2 modules principaux qui viennent avec PhenixApp. Le module System qui contrôle les composants de base, sois l&#8217;installation des modules, la configuration de ceux-ci, la gestion des widgets dans le thème appeler &laquo;&nbsp;Brickwall&nbsp;&raquo; et plusieurs autres élément. Ensuite, il y a le module members qui gère l&#8217;enregistrement des membres, les groupes et les permissions. PhenixApp est dépendant du module système, mais le module members peut être remplacé par d&#8217;autre module qui fait les choses autrement.</p>
<p>PhenixApp comprend 2 types de contrôleur d&#8217;action. Sois les contrôleur public et les contrôleur d&#8217;administration. Il sont sépararer dans 2 répertoires différents ce qui peut éviter des erreurs de routing du a la confusion de 2 différentes routes. Et permet aussi d&#8217;avoir des contrôleurs de même nom pour la partit public ou administrative ce qui facilite la création des vues.</p>
<p>Une des principales fonctions du projet qui est très intéressante est la gestion du multilanguage autant dans les textes que dans l&#8217;url et l&#8217;encodage. Un système avancé vous permet de modifier directement en ligne vos traductions et traque les textes non traduits. Vous pouvez aussi ajouter des éléments à traduire directement dans vos templates et le système va les ajouter dans la database dès qu&#8217;ils seront affichés pour une première fois. Ensuite il vous restera qu&#8217;à faire la traduction dans les différentes langues.</p>
<p>Par contre, PhenixApp n&#8217;est pas encore prêt pour la production. De nombreuses interfaces d&#8217;administration restent à être terminées avant qu&#8217;une première version bêta voie le jour. Il n&#8217;y a pas encore de Base de données fournie avec le code. Nous cherche des développeurs qui aimeraient investir du temps dans le projet. Tout le code source est sur le repository tu site officiel.</p>
<p>Site du projet : <a href="http://www.phenixapp-project.net">PhenixApp-Project.net</a></p>
<!-- google_ad_section_end --><img src="http://www.m4d3l-network.com/?ak_action=api_record_view&id=168&type=feed" alt="" />
<p>Related posts:<ol><li><a href='http://www.m4d3l-network.com/developpement/phenix_file_parser_csv/' rel='bookmark' title='Permanent Link: Phenix_File_Parser_Csv'>Phenix_File_Parser_Csv</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.m4d3l-network.com/developpement/php/le-projet-phenixapp/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Phenix_File_Parser_Csv</title>
		<link>http://www.m4d3l-network.com/developpement/phenix_file_parser_csv/</link>
		<comments>http://www.m4d3l-network.com/developpement/phenix_file_parser_csv/#comments</comments>
		<pubDate>Fri, 26 Jun 2009 04:45:54 +0000</pubDate>
		<dc:creator>M4d3L</dc:creator>
				<category><![CDATA[Développement]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[CSV]]></category>
		<category><![CDATA[csv file]]></category>
		<category><![CDATA[CSV parser]]></category>
		<category><![CDATA[phenix]]></category>
		<category><![CDATA[Phenix_File_Parser_Csv]]></category>
		<category><![CDATA[repository]]></category>
		<guid isPermaLink="false">http://www.m4d3l-network.com/?p=136</guid>
		<description><![CDATA[If you need a CSV parser in PHP, this class is for you. You can download the class from the repository of PhenixApp project : Phenix_File_Parser_Csv This class open the CSV file, parse the data into the object and after you just need to use the object like an array. 1 2 3 4 5 [...]
Related posts:<ol><li><a href='http://www.m4d3l-network.com/developpement/php/zend-framework/how-to-use-flickr-with-zend-framework/' rel='bookmark' title='Permanent Link: How to use Flickr with Zend Framework?'>How to use Flickr with Zend Framework?</a></li>
<li><a href='http://www.m4d3l-network.com/developpement/phenix_view_helper_text2image/' rel='bookmark' title='Permanent Link: Phenix_View_Helper_Text2image'>Phenix_View_Helper_Text2image</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>If you need a CSV parser in PHP, this class is for you. </p>
<p>You can download the class from the repository of <a href="http://www.phenixapp-project.net">PhenixApp project</a> : <a href="http://www.phenixapp-project.net/repositories/entry/phenixapp/trunk/PhenixApp/libs/Phenix/File/Parser/Csv.php">Phenix_File_Parser_Csv</a><br />
<span id="more-136"></span><br />
This class open the CSV file, parse the data into the object and after you just need to use the object like an array.</p>
<p><code></p>
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$csvParser</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Phenix_File_Parser_Csv<span style="color: #009900;">&#40;</span>
    <span style="color: #000088;">$filename</span><span style="color: #339933;">,</span>   <span style="color: #666666; font-style: italic;">//CSV file name</span>
    <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span>    <span style="color: #666666; font-style: italic;">//Start at row 1</span>
    <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;id&quot;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;title&quot;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;detail&quot;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">3</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;lastupdate&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">//Column expected to read in the CSV file.</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//use like an array</span>
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$csvParser</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$key</span><span style="color: #339933;">=&gt;</span><span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$date</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$value</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'lastupdate'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>
<p></code></p>
<!-- google_ad_section_end --><img src="http://www.m4d3l-network.com/?ak_action=api_record_view&id=136&type=feed" alt="" />
<p>Related posts:<ol><li><a href='http://www.m4d3l-network.com/developpement/php/zend-framework/how-to-use-flickr-with-zend-framework/' rel='bookmark' title='Permanent Link: How to use Flickr with Zend Framework?'>How to use Flickr with Zend Framework?</a></li>
<li><a href='http://www.m4d3l-network.com/developpement/phenix_view_helper_text2image/' rel='bookmark' title='Permanent Link: Phenix_View_Helper_Text2image'>Phenix_View_Helper_Text2image</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.m4d3l-network.com/developpement/phenix_file_parser_csv/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Phenix_View_Helper_Text2image (English)</title>
		<link>http://www.m4d3l-network.com/developpement/php/zend-framework/en-phenix_view_helper_text2image/</link>
		<comments>http://www.m4d3l-network.com/developpement/php/zend-framework/en-phenix_view_helper_text2image/#comments</comments>
		<pubDate>Fri, 26 Jun 2009 03:41:59 +0000</pubDate>
		<dc:creator>M4d3L</dc:creator>
				<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[helper]]></category>
		<category><![CDATA[Image generator]]></category>
		<category><![CDATA[PhenixApp]]></category>
		<category><![CDATA[Phenix_View]]></category>
		<category><![CDATA[Phenix_View_Helper]]></category>
		<category><![CDATA[Phenix_View_Helper_Text2image]]></category>
		<category><![CDATA[Text to image]]></category>
		<category><![CDATA[Zend_View]]></category>
		<category><![CDATA[Zend_View_Helper]]></category>
		<guid isPermaLink="false">http://www.m4d3l-network.com/?p=132</guid>
		<description><![CDATA[Did you already got the probleme to create a menu with image because the font was not a standard web font and you has to make again and again the menu because you clients ask you to do many change? This helper is the solution. What is Phenix_View_Helper_Text2image? This is a simple View Helper for [...]
Related posts:<ol><li><a href='http://www.m4d3l-network.com/developpement/phenix_view_helper_text2image/' rel='bookmark' title='Permanent Link: Phenix_View_Helper_Text2image'>Phenix_View_Helper_Text2image</a></li>
<li><a href='http://www.m4d3l-network.com/developpement/php/zend-framework/zend_form-how-to-remove-decorator-from-hidden-field/' rel='bookmark' title='Permanent Link: Zend_Form : How to remove decorator from hidden field.'>Zend_Form : How to remove decorator from hidden field.</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>Did you already got the probleme to create a menu with image because the font was not a standard web font and you has to make again and again the menu because you clients ask you to do many change? This helper is the solution.<br />
<span id="more-132"></span></p>
<h4>What is Phenix_View_Helper_Text2image?</h4>
<p>This is a simple View Helper for Zend Framework that allow you to transform on the fly a string texte to an image with the good font, size, background and position. When the image are generated, they are stored in an image folder and they are never regenereted else if you change a params of an image. This is a big avantage for the designer that doesnt have to care about the font or disposition to use.</p>
<p>Configuration :<br />
<code></p>
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #000088;">$param</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
<span style="color: #666666; font-style: italic;">/* For image menu with special font */</span>
<span style="color: #0000ff;">'imgdir'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;home/user/public_html/images&quot;</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'imgurl'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;/images&quot;</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'font'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;/home/user/App/Fonts/ITCKrist.TTF&quot;</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'fsize'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">11</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'flag'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;menu&quot;</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'width'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">170</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'height'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">26</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'tcolor'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;#4e6549&quot;</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'bgcolor'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;#FFFFFF&quot;</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'tposition_x'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'tposition_y'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">20</span>
<span style="color: #009900;">&#41;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>
<p></code><br />
Create all menu image :<br />
<code></p>
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">&lt;ul class=&quot;navmenu&quot;&gt;
&lt;li&gt;&lt;a href=&quot;<span style="color: #000000; font-weight: bold;">&lt;?=</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">url</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Text2image</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Acceuil&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$param</span><span style="color: #009900;">&#41;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;<span style="color: #000000; font-weight: bold;">&lt;?=</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">url</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Text2image</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Produits&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$param</span><span style="color: #009900;">&#41;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;<span style="color: #000000; font-weight: bold;">&lt;?=</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">url</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Text2image</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Contactez-nous&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$param</span><span style="color: #009900;">&#41;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</pre></td></tr></table></div>
<p></code><br />
Note that if image already exist, only the image tag will be generated.</p>
<h4>Where I can download this helper?</h4>
<p>You can download this helper on the repository of <a href="http://www.phenixapp-project.net">PhenixApp project</a>. <a href="http://www.phenixapp-project.net/repositories/browse/phenixapp/trunk/PhenixApp/libs/Phenix/View/Helper/">View_Helper repository</a></p>
<!-- google_ad_section_end --><img src="http://www.m4d3l-network.com/?ak_action=api_record_view&id=132&type=feed" alt="" />
<p>Related posts:<ol><li><a href='http://www.m4d3l-network.com/developpement/phenix_view_helper_text2image/' rel='bookmark' title='Permanent Link: Phenix_View_Helper_Text2image'>Phenix_View_Helper_Text2image</a></li>
<li><a href='http://www.m4d3l-network.com/developpement/php/zend-framework/zend_form-how-to-remove-decorator-from-hidden-field/' rel='bookmark' title='Permanent Link: Zend_Form : How to remove decorator from hidden field.'>Zend_Form : How to remove decorator from hidden field.</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.m4d3l-network.com/developpement/php/zend-framework/en-phenix_view_helper_text2image/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zend_Form : How to remove decorator from hidden field.</title>
		<link>http://www.m4d3l-network.com/developpement/php/zend-framework/zend_form-how-to-remove-decorator-from-hidden-field/</link>
		<comments>http://www.m4d3l-network.com/developpement/php/zend-framework/zend_form-how-to-remove-decorator-from-hidden-field/#comments</comments>
		<pubDate>Thu, 25 Jun 2009 16:25:25 +0000</pubDate>
		<dc:creator>M4d3L</dc:creator>
				<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[dd]]></category>
		<category><![CDATA[decorator]]></category>
		<category><![CDATA[dt]]></category>
		<category><![CDATA[DtDdWrapper]]></category>
		<category><![CDATA[form decorator]]></category>
		<category><![CDATA[form element]]></category>
		<category><![CDATA[helper]]></category>
		<category><![CDATA[hidden element]]></category>
		<category><![CDATA[hidden field]]></category>
		<category><![CDATA[phenix]]></category>
		<category><![CDATA[remove decorator]]></category>
		<category><![CDATA[Zend_Form]]></category>
		<guid isPermaLink="false">http://www.m4d3l-network.com/?p=106</guid>
		<description><![CDATA[This question come a lot in #ZFtalk channel on IRC. The Default decorator apply the DtDdWrapper to all form element when they are created. But hidden field does&#8217;nt need decorator and the actual hidden element class does&#8217;nt care about that. Actually, without decorator remove, hidden field will output like the following and this is bad. [...]
Related posts:<ol><li><a href='http://www.m4d3l-network.com/developpement/php/autocomplete-field-with-zend-framework-and-dojo/' rel='bookmark' title='Permanent Link: Autocomplete field with Zend Framework and Dojo'>Autocomplete field with Zend Framework and Dojo</a></li>
<li><a href='http://www.m4d3l-network.com/developpement/php/zend-framework/en-phenix_view_helper_text2image/' rel='bookmark' title='Permanent Link: Phenix_View_Helper_Text2image (English)'>Phenix_View_Helper_Text2image (English)</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>This question come a lot in #ZFtalk channel on IRC.</p>
<p>The Default decorator apply the DtDdWrapper to all form element when they are created. But hidden field does&#8217;nt need decorator and the actual hidden element class does&#8217;nt care about that.<br />
<span id="more-106"></span></p>
<p>Actually, without decorator remove, hidden field will output like the following and this is bad.<br />
<code></p>
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>dt id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;MyElement-label&quot;</span><span style="color: #339933;">&gt;&amp;</span>nbsp<span style="color: #339933;">;&lt;/</span>dt<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>dd id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;MyElement-element&quot;</span><span style="color: #339933;">&gt;&lt;</span>input type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;hidden&quot;</span> name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;MyElement&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;something&quot;</span> id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;MyElement&quot;</span><span style="color: #339933;">&gt;&lt;/</span>dd<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>
<p></code></p>
<p>So to remove the decorator, you can do this after create your hidden element:<br />
<code></p>
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$id</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$form</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'hidden'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'id'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$id</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">removeDecorator</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'DtDdWrapper'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$id</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">removeDecorator</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'HtmlTag'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$id</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">removeDecorator</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Label'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$form</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addElement</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$id</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>
<p></code></p>
<p>This is important because this will prevent to get unwanted result if you add css to your DT/Dd decorator. After remove these decorator, this will print only the input hidden field.</p>
<p><code></p>
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>input type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;hidden&quot;</span> name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;MyElement&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;something&quot;</span> id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;MyElement&quot;</span><span style="color: #339933;">&gt;</span></pre></td></tr></table></div>
<p></code></p>
<p>With the <a href="http://www.phenixapp-project.net">PhenixApp</a> project, I have decided to extends the default hidden element class to remove decorator of each hidden field indefinitely.<br />
I think this way is better because this prevent some method to be executed for nothing and this is more quick to add hidden field in all my form after.</p>
<p>Here is my class :<br />
<code></p>
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> Phenix_Form_Element_Hidden <span style="color: #000000; font-weight: bold;">extends</span> Zend_Form_Element_Hidden
<span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    	<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setDisableLoadDefaultDecorators</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    	<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addDecorator</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ViewHelper&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>
<p></code></p>
<!-- google_ad_section_end --><img src="http://www.m4d3l-network.com/?ak_action=api_record_view&id=106&type=feed" alt="" />
<p>Related posts:<ol><li><a href='http://www.m4d3l-network.com/developpement/php/autocomplete-field-with-zend-framework-and-dojo/' rel='bookmark' title='Permanent Link: Autocomplete field with Zend Framework and Dojo'>Autocomplete field with Zend Framework and Dojo</a></li>
<li><a href='http://www.m4d3l-network.com/developpement/php/zend-framework/en-phenix_view_helper_text2image/' rel='bookmark' title='Permanent Link: Phenix_View_Helper_Text2image (English)'>Phenix_View_Helper_Text2image (English)</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.m4d3l-network.com/developpement/php/zend-framework/zend_form-how-to-remove-decorator-from-hidden-field/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
