<?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>Amicalement Web - Astuces et Bons plans dans le développement web &#187; howto</title>
	<atom:link href="http://www.amicalement-web.net/tag/howto/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.amicalement-web.net</link>
	<description>Astuces et bons plans d&#039;un web developpeur</description>
	<lastBuildDate>Wed, 04 Jan 2012 14:54:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Symfony: Domptez les filtres de l&#8217;admin generator</title>
		<link>http://www.amicalement-web.net/symfony-domptez-les-filtres-de-ladmin-generator/2009/06/16/</link>
		<comments>http://www.amicalement-web.net/symfony-domptez-les-filtres-de-ladmin-generator/2009/06/16/#comments</comments>
		<pubDate>Tue, 16 Jun 2009 16:26:01 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[admin]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[widget]]></category>

		<guid isPermaLink="false">http://www.amicalement-web.net/?p=348</guid>
		<description><![CDATA[Un détail qui m&#8217;a toujours titillé dans le fabuleux admin generator de symfony, c&#8217;est le bloc de filtre. Le concept est bien sûr génial. Sans rien faire, vous avez déjà la possibilité de filtrer vos résultats, un gain de temps énorme, surtout quand on a un client qui sait ce qu&#8217;il veut. Mais voilà, même [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.amicalement-web.net/wp-content/uploads/system-run.png" alt="system-run" title="system-run" width="48" height="48" class="alignleft size-full wp-image-38" /> Un détail qui m&#8217;a toujours titillé dans le fabuleux <a  href="http://www.symfony-project.org/jobeet/1_2/Propel/en/12" class="extern">admin generator de symfony</a>, c&#8217;est le bloc de filtre. Le concept est bien sûr génial. Sans rien faire, vous avez déjà la possibilité de filtrer vos résultats, un gain de temps énorme, surtout quand on a un client qui sait ce qu&#8217;il veut. Mais voilà, même si depuis la 1.2, le layout de l&#8217;admin generator par défaut a subit un lifting qui le rend beau de série:<br />
<a  href="http://www.amicalement-web.net/wp-content/uploads/Image-56.png"><img src="http://www.amicalement-web.net/wp-content/uploads/Image-56-300x44.png" alt="Image 56" title="Image 56" width="300" height="44" class="alignnone size-medium wp-image-349" /></a><br />
<span id="more-348"></span><br />
On rencontre très vite, dans le cas d&#8217;un tableau avec beaucoup de colonnes, le fameux &laquo;&nbsp;bug&nbsp;&raquo; css sur un écran plus petit que mon 20&#8243; (oui parce que chez moi, c&#8217;est toujours très beau, chez mes chefs de projets et leur portable, beaucoup moins :D):<br />
<a  href="http://www.amicalement-web.net/wp-content/uploads/Image-57.png"><img src="http://www.amicalement-web.net/wp-content/uploads/Image-57-300x48.png" alt="Image 57" title="Image 57" width="300" height="48" class="alignnone size-medium wp-image-350" /></a></p>
<p>Alors bien sûr, la solution radicale, c&#8217;est de réduire le nombre de colonnes, mais souvent le client, il les veut ses colonnes! La 2e solution est de supprimer ce bloc de filtre. On fait ça très simplement dans le generator.yml:</p>

<div class="wp_syntax"><div class="code"><pre class="yaml" style="font-family:monospace;">filter:
  class: false</pre></div></div>

<p>Cependant, il arrive quand même que le filtrage soit nécessaire mais bien souvent, seulement 2 ou 3 valeurs. J&#8217;ai donc décidé de prendre le taureau par les cornes et faire la modification dont je rêve depuis longtemps, passer ce bloc de filtre, au dessus du tableau! Pour ce faire, j&#8217;ai modifié 2 fichiers. Tout d&#8217;abord, le fichier <code>_filters.php</code> qu&#8217;il faudra rajouter dans le dossier templates de vos modules visés:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;div class=&quot;sf_admin_filter&quot;&gt;
&nbsp;
	&lt;div class=&quot;content_filter&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;">$form</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">hasGlobalErrors</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;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$form</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">renderGlobalErrors</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
  <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
&nbsp;
  &lt;form action=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> url_for<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'produits_collection'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'action'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'filter'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; method=&quot;post&quot;&gt;
	  <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$configuration</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getFormFilterFields</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$form</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$name</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$field</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
	  &lt;div class=&quot;bloc_filter&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: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$form</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$name</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$form</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$name</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">isHidden</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: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$form</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$name</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$field</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">isReal</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">continue</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
          <span style="color: #000000; font-weight: bold;">&lt;?php</span> include_partial<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'produits/filters_field'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
            <span style="color: #0000ff;">'name'</span>       <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$name</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'attributes'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$field</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getConfig</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'attributes'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</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: #0000ff;">'label'</span>      <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$field</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getConfig</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: #0000ff;">'help'</span>       <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$field</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getConfig</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'help'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'form'</span>       <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$form</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'field'</span>      <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$field</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'class'</span>      <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'sf_admin_form_row sf_admin_'</span><span style="color: #339933;">.</span><span style="color: #990000;">strtolower</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$field</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getType</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: #0000ff;">' sf_admin_filter_field_'</span><span style="color: #339933;">.</span><span style="color: #000088;">$name</span><span style="color: #339933;">,</span>
          <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
    &lt;/div&gt;
    <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endforeach</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
     <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$form</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">renderHiddenFields</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
     <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> link_to<span style="color: #009900;">&#40;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Reset'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'sf_admin'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'produits_collection'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'action'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'filter'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'query_string'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'_reset'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'method'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'post'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
     &lt;input type=&quot;submit&quot; value=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Filter'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'sf_admin'</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; /&gt;
  &lt;/form&gt;
  &lt;/div&gt;
&lt;/div&gt;</pre></div></div>

<p>Au final, j&#8217;ai simplement supprimé le tableau, par défaut et mis chaque widget dans un div. On obtient donc quelque chose qui change pas vraiment la donne pour l&#8217;instant:<br />
<a  href="http://www.amicalement-web.net/wp-content/uploads/Image-58.png"><img src="http://www.amicalement-web.net/wp-content/uploads/Image-58-300x36.png" alt="Image 58" title="Image 58" width="300" height="36" class="alignnone size-medium wp-image-353" /></a></p>
<p>Mais en lui appliquant un peu de css:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">div<span style="color: #cc00cc;">#sf_admin_bar</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#sf_admin_bar</span> <span style="color: #6666ff;">.sf_admin_filter</span> form div<span style="color: #6666ff;">.bloc_filter</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">inline</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span> <span style="color: #933;">20px</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
div<span style="color: #cc00cc;">#sf_admin_container</span> <span style="color: #cc00cc;">#sf_admin_bar</span> label <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">inline</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>On commence à approcher de ce que l&#8217;on souhaite:<br />
<a  href="http://www.amicalement-web.net/wp-content/uploads/Image-60.png"><img src="http://www.amicalement-web.net/wp-content/uploads/Image-60-300x29.png" alt="Image 60" title="Image 60" width="300" height="29" class="alignnone size-medium wp-image-354" /></a></p>
<p>Maintenant, on habille un peu la chose, histoire de gagner en clarté:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#sf_admin_bar</span> <span style="color: #6666ff;">.sf_admin_filter</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#FFF</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #933;">12px</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#sf_admin_bar</span> <span style="color: #6666ff;">.sf_admin_filter</span> <span style="color: #6666ff;">.content_filter</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#DDDDDD</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>Pour obtenir finalement:<br />
<a  href="http://www.amicalement-web.net/wp-content/uploads/Image-61.png"><img src="http://www.amicalement-web.net/wp-content/uploads/Image-61-300x38.png" alt="Image 61" title="Image 61" width="300" height="38" class="alignnone size-medium wp-image-355" /></a></p>
<p>Un dernier détail, le filtre &laquo;&nbsp;référence&nbsp;&raquo; avec sa colonne &laquo;&nbsp;is_empty&nbsp;&raquo; casse un peu notre rendu. Personnellement, je ne me sers pas de cette checkbox, on va donc redéfinir notre filtre pour la supprimer dans <code>lib/filters/MonModuleFilters.class.php</code>:</p>

<div class="wp_syntax"><div 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> configure<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;">widgetSchema</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'reference'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> sfWidgetFormFilterInput<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
      <span style="color: #0000ff;">'template'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'%input%'</span>
    <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span></pre></div></div>

<p>Et voilà, une jolie barre de recherche beaucoup plus du goût des clients en général :)<br />
<a  href="http://www.amicalement-web.net/wp-content/uploads/Image-62.png"><img src="http://www.amicalement-web.net/wp-content/uploads/Image-62-300x32.png" alt="Image 62" title="Image 62" width="300" height="32" class="alignnone size-medium wp-image-352" /></a></p>
<p>Alors bien sûr, cette solution ne fonctionne qu&#8217;avec un nombre limité de filtre, sinon on aurait un rendu un peu moins visuel, mais je pense que ça reste toujours mieux que 2 blocs qui se chevauchent.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.amicalement-web.net/symfony-domptez-les-filtres-de-ladmin-generator/2009/06/16/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>How-to Symfony: Gestion d’un arbre en Propel via les NestedSet &#8211; Part 2</title>
		<link>http://www.amicalement-web.net/how-to-symfony-gestion-d%e2%80%99un-arbre-en-propel-via-les-nestedset-part-2/2009/05/19/</link>
		<comments>http://www.amicalement-web.net/how-to-symfony-gestion-d%e2%80%99un-arbre-en-propel-via-les-nestedset-part-2/2009/05/19/#comments</comments>
		<pubDate>Tue, 19 May 2009 11:31:07 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[admin]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[nestedset]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[propel]]></category>
		<category><![CDATA[Symfony]]></category>

		<guid isPermaLink="false">http://www.amicalement-web.net/?p=246</guid>
		<description><![CDATA[La dernière fois, on avait vu comment construire l&#8217;aspect graphique de notre gestion de catégorie via Symfony et Propel. On va voir maintenant comme lui associer les actions symfony qui vont bien. Au programme donc dans l&#8217;ordre: la remise en état des liens modifier/supprimer l&#8217;ajout d&#8217;un lien pour ajouter un enfant à une catégorie la [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.amicalement-web.net/wp-content/uploads/system-run.png" alt="system-run" title="system-run" width="48" height="48" class="alignleft size-full wp-image-38" /> La dernière fois, on avait vu comment construire l&#8217;aspect graphique de notre <a  href="/symfony-gestion-d-un-arbre-en-propel-via-les-nestedset-part-1/2009/05/12/">gestion de catégorie</a> via <a  href="http://www.symfony-project.org" class="extern">Symfony</a> et Propel. On va voir maintenant comme lui associer les actions symfony qui vont bien.<br />
Au programme donc dans l&#8217;ordre:</p>
<ul>
<li>la remise en état des liens modifier/supprimer</li>
<li>l&#8217;ajout d&#8217;un lien pour ajouter un enfant à une catégorie</li>
<li>la sauvegarde de l&#8217;ordre de l&#8217;arbre</li>
</ul>
<p>Ya du boulot, alors on se lance.<br />
<span id="more-246"></span><br />
Le seul problème à la remise des liens modifier/supprimer c&#8217;est leur structure HTML, en ul/li qui pose souci avec le plugin NestedSortable. On va donc revoir la chose en les mettant dans un &laquo;&nbsp;p&nbsp;&raquo; avec de simples liens. Pour cela on va éditer dans notre module le fichier <code>lib/categoriesGeneratorHelper.class.php</code> (qui doit être vierge pour l&#8217;instant) et on va surcharger les méthodes, linkToEdit et linkToDelete:</p>

<div class="wp_syntax"><div 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> linkToEdit<span style="color: #009900;">&#40;</span><span style="color: #000088;">$object</span><span style="color: #339933;">,</span> <span style="color: #000088;">$params</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">'&lt;span class=&quot;sf_admin_action_edit&quot;&gt;'</span><span style="color: #339933;">.</span>link_to<span style="color: #009900;">&#40;</span>__<span style="color: #009900;">&#40;</span><span style="color: #000088;">$params</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'label'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'sf_admin'</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;">getUrlForAction</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'edit'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$object</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/span&gt;'</span><span style="color: #339933;">;</span>
  <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> linkToDelete<span style="color: #009900;">&#40;</span><span style="color: #000088;">$object</span><span style="color: #339933;">,</span> <span style="color: #000088;">$params</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;">$object</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">isNew</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: #b1b100;">return</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">'&lt;span class=&quot;sf_admin_action_delete&quot;&gt;'</span><span style="color: #339933;">.</span>link_to<span style="color: #009900;">&#40;</span>__<span style="color: #009900;">&#40;</span><span style="color: #000088;">$params</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'label'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'sf_admin'</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;">getUrlForAction</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'delete'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$object</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'method'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'delete'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'confirm'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$params</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'confirm'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> ? __<span style="color: #009900;">&#40;</span><span style="color: #000088;">$params</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'confirm'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'sf_admin'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$params</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'confirm'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/span&gt;'</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span></pre></div></div>

<p>Les seules modifications concernant le changement d&#8217;un li par un span.</p>
<p>Maintenant on va modifier le partial <code>_list_td_actions.php</code> et donc le rajouter dans notre répertoire templates de notre module:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;p class=&quot;sf_admin_td_actions list_action&quot;&gt;
  &lt;span class=&quot;sf_admin_action_new&quot;&gt;
    <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> link_to<span style="color: #009900;">&#40;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Ajout Enfant'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'categories/addChild?id='</span><span style="color: #339933;">.</span><span style="color: #000088;">$categories</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getId</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'messages'</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
  &lt;/span&gt;
  <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$helper</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">linkToEdit</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$categories</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>  <span style="color: #0000ff;">'params'</span> <span style="color: #339933;">=&gt;</span>   <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>  <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>  <span style="color: #0000ff;">'class_suffix'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'edit'</span><span style="color: #339933;">,</span>  <span style="color: #0000ff;">'label'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Edit'</span><span style="color: #339933;">,</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
  <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$helper</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">linkToDelete</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$categories</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>  <span style="color: #0000ff;">'params'</span> <span style="color: #339933;">=&gt;</span>   <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>  <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>  <span style="color: #0000ff;">'confirm'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Are you sure?'</span><span style="color: #339933;">,</span>  <span style="color: #0000ff;">'class_suffix'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'delete'</span><span style="color: #339933;">,</span>  <span style="color: #0000ff;">'label'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Delete'</span><span style="color: #339933;">,</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;/p&gt;</pre></div></div>

<p>A noter qu&#8217;on a ajouté au passage l&#8217;action Ajout d&#8217;enfant.<br />
Il nous reste plus qu&#8217;à rajouter l&#8217;appel à ce partial dans notre <code>_tree.php</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">[...]
&lt;div class=&quot;sort-handle&quot;&gt;
   <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getTitre</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;/div&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> include_partial<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'categories/list_td_actions'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'categories'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$node</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'helper'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$helper</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
[...]</pre></div></div>

<p>Le résultat nous donne ceci:<br />
<a  href="http://www.amicalement-web.net/wp-content/uploads/image-311.png"><img src="http://www.amicalement-web.net/wp-content/uploads/image-311-300x134.png" alt="image-311" title="image-311" width="300" height="134" class="alignnone size-medium wp-image-247" /></a></p>
<p>Alors oui c&#8217;est moche, mais ca fonctionne! Maintenant, on passe un petit coup de CSS comme d&#8217;habitude:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.list_action</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">right</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">350px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.list_action</span> span <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">10px</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.current-nesting</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#FFE</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#sf_admin_container</span> <span style="color: #cc00cc;">#sf_admin_content</span> p span<span style="color: #6666ff;">.sf_admin_action_new</span> a <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">transparent</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">/sfPropelPlugin/images/new.png</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">no-repeat</span> <span style="color: #993333;">scroll</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#sf_admin_container</span> <span style="color: #cc00cc;">#sf_admin_content</span> p span<span style="color: #6666ff;">.sf_admin_action_edit</span> a <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">transparent</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">/sfPropelPlugin/images/edit.png</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">no-repeat</span> <span style="color: #993333;">scroll</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#sf_admin_container</span> <span style="color: #cc00cc;">#sf_admin_content</span> p span<span style="color: #6666ff;">.sf_admin_action_delete</span> a<span style="color: #00AA00;">,</span><span style="color: #6666ff;">.link_delete</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">transparent</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">/sfPropelPlugin/images/delete.png</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">no-repeat</span> <span style="color: #993333;">scroll</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>Et la magie opère de nouveau:<br />
<a  href="http://www.amicalement-web.net/wp-content/uploads/image-331.png"><img src="http://www.amicalement-web.net/wp-content/uploads/image-331-300x90.png" alt="image-331" title="image-331" width="300" height="90" class="alignnone size-medium wp-image-249" /></a></p>
<p>On va maintenant créer les actions liées à cette nouvelle action dans notre fichier d&#8217;actions de notre module:</p>

<div class="wp_syntax"><div 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> executeAddChild<span style="color: #009900;">&#40;</span>sfWebRequest <span style="color: #000088;">$request</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;">categories</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getRoute</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getObject</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// On récupère le parent pour insérer la nouvelle catégorie sous ce parent et on le fait transiter via session </span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getUser</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'categories.addChild'</span><span style="color: #339933;">,</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">categories</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getPrimaryKey</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'admin_module'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">form</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">configuration</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getForm</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><span style="color: #004000;">setTemplate</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'new'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #009933; font-style: italic;">/**
   * On surcharge le processForm pour récupérer le parent de la catégorie à ajouter s'il existe
   *
   * @param sfWebRequest $request
   * @param sfForm $form
   */</span>
  <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">function</span> processForm<span style="color: #009900;">&#40;</span>sfWebRequest <span style="color: #000088;">$request</span><span style="color: #339933;">,</span> sfForm <span style="color: #000088;">$form</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;">$parent</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getUser</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'categories.addChild'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'admin_module'</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;">getUser</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getAttributeHolder</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'categories.addChild'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'admin_module'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$root</span> <span style="color: #339933;">=</span> CategoriesPeer<span style="color: #339933;">::</span><span style="color: #004000;">retrieveByPk</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$parent</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;">getObject</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">insertAsLastChildOf</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$root</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    parent<span style="color: #339933;">::</span><span style="color: #004000;">processForm</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$request</span><span style="color: #339933;">,</span><span style="color: #000088;">$form</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span></pre></div></div>

<p>Si vous cliquez maintenant sur &laquo;&nbsp;Ajouter un enfant&#8217; d&#8217;une des catégories déjà présente vous obtenez alors:<br />
<a  href="http://www.amicalement-web.net/wp-content/uploads/image-34.png"><img src="http://www.amicalement-web.net/wp-content/uploads/image-34-300x180.png" alt="image-34" title="image-34" width="300" height="180" class="alignnone size-medium wp-image-258" /></a></p>
<p>Vu que les tree left et tree right sont définis par Propel, on va les supprimer du formulaire.<br />
Dans notre <code>CategoriesForm.class.php</code> on rajoute:</p>

<div class="wp_syntax"><div 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> configure<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    <span style="color: #990000;">unset</span><span style="color: #009900;">&#40;</span>
      <span style="color: #000088;">$this</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'tree_left'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
      <span style="color: #000088;">$this</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'tree_right'</span><span style="color: #009900;">&#93;</span>
    <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span></pre></div></div>

<p>Maintenant, il ne manque plus qu&#8217;à pouvoir sauvegarder les modifications d&#8217;ordre effectuées via javascript. Pour cela on va rajouter une batch actions (elles soumettent un formulaire, il sera ainsi plus facile de faire passer les modifications faites à l&#8217;arbre).<br />
Dans notre <code>generator.yml</code> on rajoute dans l&#8217;entrée list:</p>

<div class="wp_syntax"><div class="code"><pre class="yaml" style="font-family:monospace;">  batch_actions:
    saveOrder:
      label: Sauvegarder ordre
      action: saveOrder</pre></div></div>

<p>Et dans notre partial <code>_list.php</code>, juste avant le javascript:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;div&gt;
	&lt;input type=&quot;hidden&quot; id=&quot;hashValue&quot; name=&quot;hashValue&quot; value=&quot;&quot; /&gt;
	&lt;input type=&quot;hidden&quot; name=&quot;ids&quot; value=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$item</span><span style="color: #009900;">&#41;</span>?<span style="color: #000088;">$item</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getPrimaryKey</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #0000ff;">'1'</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; /&gt;
&lt;/div&gt;</pre></div></div>

<p>Le premier pour récupérer la sérialisation de la nestedlist en javascript, le deuxième pour passer outre le système de batch qui demande de sélectionner au moins un ids pour lancer l&#8217;action ensuite.</p>
<p>On obtient donc:<br />
<a  href="http://www.amicalement-web.net/wp-content/uploads/image-351.png"><img src="http://www.amicalement-web.net/wp-content/uploads/image-351.png" alt="image-351" title="image-351" width="278" height="100" class="alignnone size-full wp-image-262" /></a></p>
<p>Il ne reste plus qu&#8217;à faire l&#8217;action correspondante dans notre fichier d&#8217;actions:</p>

<div class="wp_syntax"><div 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> executeBatchSaveOrder<span style="color: #009900;">&#40;</span>sfWebRequest <span style="color: #000088;">$request</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$hash</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$request</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getParameter</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'hashValue'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #990000;">parse_str</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$hash</span><span style="color: #339933;">,</span> <span style="color: #000088;">$list</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    CategoriesPeer<span style="color: #339933;">::</span><span style="color: #004000;">saveOrder</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$list</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;">getUser</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setFlash</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'notice'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Ordre mis à jour'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span></pre></div></div>

<p>Et les fonctions de sauvegarde dans notre modèle. La fonction mère dans le <code>CategoriesPeer.php</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> static <span style="color: #000000; font-weight: bold;">function</span> saveOrder<span style="color: #009900;">&#40;</span><span style="color: #000088;">$hash</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$root</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #004000;">retrieveRoot</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$hash</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'main_list'</span><span style="color: #009900;">&#93;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$categorie</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span> 
      <span style="color: #000088;">$u</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #004000;">retrieveByPk</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$categorie</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'id'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
      <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$categorie</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'children'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
      <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$u</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">saveChildren</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$categorie</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'children'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
&nbsp;
      <span style="color: #000088;">$u</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">moveToLastChildOf</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$root</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$u</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">save</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: #009900;">&#125;</span></pre></div></div>

<p>Qui gère les &laquo;&nbsp;racines&nbsp;&raquo; et son équivalent récursif dans le model <code>Categories.php</code>:</p>

<div class="wp_syntax"><div 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> saveChildren<span style="color: #009900;">&#40;</span><span style="color: #000088;">$children</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
	  <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$children</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$child</span><span style="color: #009900;">&#41;</span>
	  <span style="color: #009900;">&#123;</span>
	    <span style="color: #000088;">$item</span> <span style="color: #339933;">=</span> CategoriesPeer<span style="color: #339933;">::</span><span style="color: #004000;">retrieveByPk</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$child</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'id'</span><span style="color: #009900;">&#93;</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: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$child</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'children'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
	    <span style="color: #009900;">&#123;</span>
	      <span style="color: #000088;">$item</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">saveChildren</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$child</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'children'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	    <span style="color: #009900;">&#125;</span>
	    <span style="color: #000088;">$item</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">moveToLastChildOf</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$item</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">save</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: #009900;">&#125;</span></pre></div></div>

<p>Et voilà! Vous pouvez maintenant déplacer vos catégories et sauvegarder leur position dans l&#8217;arbre.</p>
<p>Evidemment toute question, suggestion sont bien sûr les bienvenues. Je pense mettre les source et une démo en ligne très bientôt, voir en faire un plugin si jamais je rencontre un réel intérêt pour ce genre de gadget.</p>
<p>En attendant, une petit illustration en vidéo:<br />
<object id='stUE1TSkxIR11dR15eX1taVV5V' width='425' height='344' type='application/x-shockwave-flash' data='http://www.screentoaster.com/swf/STPlayer.swf'  codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0'><param name='movie' value='http://www.screentoaster.com/swf/STPlayer.swf'/><param name='allowFullScreen' value='true'/><param name='allowScriptAccess' value='always'/><param name='flashvars' value='video=stUE1TSkxIR11dR15eX1taVV5V'/></object>
<div style='width: 425px; text-align: right;'><a  href="http://www.screentoaster.com/">Screencasts and videos online</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.amicalement-web.net/how-to-symfony-gestion-d%e2%80%99un-arbre-en-propel-via-les-nestedset-part-2/2009/05/19/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>How-to Symfony: Gestion d&#8217;un arbre en Propel via les NestedSet &#8211; Part 1</title>
		<link>http://www.amicalement-web.net/symfony-gestion-d-un-arbre-en-propel-via-les-nestedset-part-1/2009/05/12/</link>
		<comments>http://www.amicalement-web.net/symfony-gestion-d-un-arbre-en-propel-via-les-nestedset-part-1/2009/05/12/#comments</comments>
		<pubDate>Tue, 12 May 2009 16:34:01 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[admin]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[nestedset]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[propel]]></category>
		<category><![CDATA[Symfony]]></category>

		<guid isPermaLink="false">http://www.amicalement-web.net/?p=203</guid>
		<description><![CDATA[Les arbres en informatique c&#8217;est un peu le sujet qui fait rêver mais qui embête souvent, moi le premier. Car qui dit arbre, dit récursivité et là en général on commence à se prendre la tête dans les mains. Bah oui gérer quelque chose dont on ne connait pas la fin, ca fait toujours un [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.amicalement-web.net/wp-content/uploads/accessories-text-editor.png" alt="accessories-text-editor" title="accessories-text-editor" width="48" height="48" class="alignleft size-full wp-image-28" /> Les arbres en informatique c&#8217;est un peu le sujet qui fait rêver mais qui embête souvent, moi le premier. Car qui dit arbre, dit <a  href="http://fr.wikipedia.org/wiki/Algorithme_r%C3%A9cursif" class="extern">récursivité</a> et là en général on commence à se prendre la tête dans les mains. Bah oui gérer quelque chose dont on ne connait pas la fin, ca fait toujours un peu peur.</p>
<p>Ici, le principe va être justement de gérer un arbre de catégories, un cas qui peut revenir assez régulièrement. A noter que le concept reprend la version doctrine de <a  href="http://redotheoffice.com/?p=74" class="extern">redotheoffice</a> avec une modification quant au plugin jquery utilisé. En effet, on essaiera ici de gérer l&#8217;ordre des catégories également par drag and drop.<br />
<span id="more-203"></span><br />
En général, quand on part la tête dans le guidon, on crée une table categories, et pour créer la notion de parent, on applique une clé étrangère sur cette même table. Oui mais voilà, autant pour les opérations de suppression et d&#8217;ajout, voir même de déplacement dans l&#8217;arbre cette démarche est très performante, autant quand il s&#8217;agit d&#8217;afficher l&#8217;arbre, la galère commence.<br />
Et pourtant, c&#8217;est bien cette deuxième qu&#8217;on fait à chaque affichage de page!</p>
<p>Il existe pourtant une alternative à cette clé étrangère: les Nested Set. En français, les représentations intervallaires. Le but n&#8217;étant pas d&#8217;expliquer dans le détail ce que c&#8217;est, je vous invite à faire un tour sur développez.com où on retrouve <a  href="http://sqlpro.developpez.com/cours/arborescence/" class="extern">un très bon article illustré à ce sujet</a>.</p>
<p>Brièvement, cette méthode consiste à rajouter des champs en base, left, right et scope permettant de retrouver ses petits. Le diagramme de developpez.com résume bien:<br />
<a  href="http://www.amicalement-web.net/wp-content/uploads/sqltree3.gif"><img src="http://www.amicalement-web.net/wp-content/uploads/sqltree3-300x194.gif" alt="Nested set" title="sqltree3" width="300" height="194" class="size-medium wp-image-204" /></a></p>
<p>Ok, c&#8217;est bien, mais appliquer tout ça à symfony ca doit être lourd! Et bien nan, Propel dans sa dernière version (1.3) intègre déjà cet algorithme en tant que behavior. (Cela sous entend qu&#8217;il faut utiliser symfony 1.2)</p>
<p>Pour se faire, on va donc créer un project vierge en 1.2 histoire d&#8217;éviter tout parasitage qu&#8217;on mènera en 2 parties. La première pour la partie visuel, la deuxième pour la partie code admin generator.</p>
<p>Voici le résultat attendu à la fin de cette première partie:<br />
<a  href="http://www.amicalement-web.net/wp-content/uploads/image-301.png"><img src="http://www.amicalement-web.net/wp-content/uploads/image-301-300x109.png" alt="image-301" title="image-301" width="300" height="109" class="alignnone size-medium wp-image-237" /></a></p>
<p>On se lance donc, notre beau projet est créé, on ouvre le schema.yml que l&#8217;on modifie comme ceci:</p>

<div class="wp_syntax"><div class="code"><pre class="yaml" style="font-family:monospace;">propel:
  categories:
    _attributes: { phpName: Categories, treeMode: NestedSet }
    id: ~
    titre: { type: VARCHAR, size: '50', required: true }
    tree_left: { type: INTEGER, size: '11', required: true, nestedSetLeftKey: true }
    tree_right: { type: INTEGER, size: '11', required: true, nestedSetRightKey: true }
    tree_parent: { type: INTEGER, size: '11', required: true }</pre></div></div>

<p>Vous noterez donc l&#8217;ajout du treeMode et la définition des nesetSetLeftKey et nestedSetRightKey, le tree_parent, n&#8217;est là que pour un certain confort à l&#8217;affichage, mais pas indispensable.</p>
<p>Votre schema ainsi terminé (vous pouvez y rajouter d&#8217;autres tables, même pas peur), on construit la base correspondante (en ayant au préalable configuré notre database.yml évidemment:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">php symfony propel:build-all</pre></div></div>

<p>Et là on constate dans notre dossier lib, deux nouvelles classes que vous n&#8217;avez sans doute jamais vu:<br />
<img src="http://www.amicalement-web.net/wp-content/uploads/image-25.png" alt="image-25" title="image-25" width="304" height="218" class="alignnone size-full wp-image-220" /><br />
- BaseCategoriesNestedSet<br />
- BaseCategoriesNestedSetPeer<br />
qui viennent se placer entre entre les classes classiques et les classes &laquo;&nbsp;Base&nbsp;&raquo;</p>
<p>Afin de jouer rapidement, on va ajouter quelques valeurs test dans data/fixtures/fixtures.yml comme suit:</p>

<div class="wp_syntax"><div class="code"><pre class="yaml" style="font-family:monospace;">Categories:
  cat_1:
    titre: root
    tree_left: 1
    tree_right: 10
  cat_2:
    titre: Hi-Tech
    tree_left: 2
    tree_right: 7
  cat_3:
    titre: Developpement
    tree_left: 3
    tree_right: 4
  cat_4:
    titre: Internet
    tree_left: 5
    tree_right: 6
  cat_5:
    titre: Culture
    tree_left: 8
    tree_right: 9</pre></div></div>

<p>que l&#8217;on va charger dès à présent:</p>

<div class="wp_syntax"><div class="code"><pre class="yaml" style="font-family:monospace;">php symfony propel:data-load</pre></div></div>

<p>A noter que la notion de root est ici très importante. En effet, j&#8217;ai choisi délibérément de travailler avec un seul scope (une seule racine) pour la simple et bonne raison que les manipulations entre scope sont très limitées et l&#8217;intérêt et de pouvoir y faire tout et n&#8217;importe quoi. Il nous faut donc un élément parent de tous, que l&#8217;on ne modifiera jamais, que l&#8217;on n&#8217;affichera jamais.</p>
<p>Maintenant, les choses sérieuses commencent. On va commencer par générer un module admin generator:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">php symfony generate:app main
php symfony propel:generate-admin main Categories</pre></div></div>

<p>Et vous devriez arriver via http://monlocal/categories sur quelque chose d&#8217;assez classique:<br />
<a  href="http://www.amicalement-web.net/wp-content/uploads/image-26.png"><img src="http://www.amicalement-web.net/wp-content/uploads/image-26-300x218.png" alt="image-26" title="image-26" width="300" height="218" class="alignnone size-medium wp-image-221" /></a></p>
<p>L&#8217;idée est maintenant d&#8217;inclure un plugin jquery qui va matérialiser notre arbre, propel ne s&#8217;occupant évidemment que de la logique métier.<br />
J&#8217;ai choisi le très bon <a  href="http://code.google.com/p/nestedsortables/wiki/NestedSortableDocumentation" class="extern">NestedSortable</a> qui répond très bien en terme de performance et très flexible à configurer. Vous pouvez donc télécharger <a  href="http://code.google.com/p/nestedsortables/downloads/list" class="extern">la dernière version</a>. Seul bémol, il nécessite <a  href="http://interface.eyecon.ro" class="extern">Interface</a>, un équivalent à jquery UI, que l&#8217;on va donc <a  href="http://interface.eyecon.ro/download" class="extern">télécharger également</a>.<br />
Pour jQuery, on laissera google faire.</p>
<p>On a donc nos js comme ceci:<br />
<img src="http://www.amicalement-web.net/wp-content/uploads/image-281.png" alt="image-281" title="image-281" width="250" height="111" class="alignnone size-full wp-image-222" /></p>
<p>et on les intègre à notre projet via notre view.yml (la notation en ligne étant plus claire à mon goût):</p>

<div class="wp_syntax"><div class="code"><pre class="yaml" style="font-family:monospace;">  javascripts: 
    - http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js
    - interface.js
    - inestedsortable-1.0.1.pack.js</pre></div></div>

<p>On va devoir maintenant modifier un peu quelques partials car le plugin jquery nécessite une imbrication de tag html, ici on utilisera ce qui semble être le plus apte sémantiquement parlant, des couples ul/li.</p>
<p>L&#8217;idée est donc d&#8217;afficher tout l&#8217;arbre quelque soit le nombre d&#8217;élément et de n&#8217;afficher que l&#8217;info qui nous interesse, en l&#8217;occurrence le titre. Première chose, voici la modification sur le generator.yml:</p>

<div class="wp_syntax"><div class="code"><pre class="yaml" style="font-family:monospace;">      list:
        peer_method: retrieveTree
        max_per_page: 99999
        display: [titre]</pre></div></div>

<p>Vous n&#8217;avez maintenant plus qu&#8217;un seul élément affiché dans votre tableau, l&#8217;élément root et c&#8217;est normal. </p>
<p>La suite se passe dans le partial _list.php. Rapide brief pour ceux qui n&#8217;ont jamais modifier un partial de l&#8217;admin generator. On récupère la version qui est dans le dossier <code>cache/[APP]/[ENV]/modules/auto[MODULE]/templates</code> et on la copie dans notre dossier templates de notre module généré.</p>
<p>Une fois cette opération effectuée, rien n&#8217;a du changer, mais maintenant on a la possibilité de modifier le partial, et voici un extrait de ce qu&#8217;il faut modifier dans la balise tbody:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">     &lt;tbody&gt;
        &lt;tr&gt;
            &lt;td class=&quot;container_main_list&quot; colspan=&quot;3&quot;&gt;
              <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$pager</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getResults</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$item</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> include_partial<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'categories/tree'</span><span style="color: #339933;">,</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'tree'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$item</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'i'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'helper'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$helper</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
              <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endforeach</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
            &lt;/td&gt;
        &lt;/tr&gt;
      &lt;/tbody&gt;</pre></div></div>

<p>Puis dans la partie script tout en base (vous pouvez retirer l&#8217;ancienne fonction checkAll, on ne pourra plus s&#8217;en servir:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #009966; font-style: italic;">/* &lt;![CDATA[ */</span>
$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>  <span style="color: #009900;">&#123;</span>
  $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#main_list'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">NestedSortable</span><span style="color: #009900;">&#40;</span>
    <span style="color: #009900;">&#123;</span>
      accept<span style="color: #339933;">:</span> <span style="color: #3366CC;">'item_list'</span><span style="color: #339933;">,</span>
      opacity<span style="color: #339933;">:</span> <span style="color: #CC0000;">0.6</span><span style="color: #339933;">,</span>
      autoScroll<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
      revert<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
      nestingPxSpace<span style="color: #339933;">:</span> <span style="color: #3366CC;">'15'</span><span style="color: #339933;">,</span>
      handle<span style="color: #339933;">:</span> <span style="color: #3366CC;">'.sort-handle'</span><span style="color: #339933;">,</span>
      currentNestingClass<span style="color: #339933;">:</span> <span style="color: #3366CC;">'current-nesting'</span><span style="color: #339933;">,</span>
      noNestingClass<span style="color: #339933;">:</span> <span style="color: #3366CC;">'sf_admin_td_actions'</span><span style="color: #339933;">,</span>
      onChange<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>serialized<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#hashValue'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span>serialized<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">hash</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span> 
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009966; font-style: italic;">/* ]]&gt; */</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

<p>Bon si vous avez suivi, vous vous doutez que si vous actualisez, symfony vous dira gentiment qu&#8217;il manque le partial _tree.php. Et bien créons le! C&#8217;est la base même du tuto, car c&#8217;est un partial récursif, qui va donc s&#8217;auto inclure:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;ul <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#41;</span>?<span style="color: #0000ff;">'id=&quot;main_list&quot; '</span><span style="color: #339933;">:</span><span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>class=&quot;page-list&quot;&gt;
  <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$tree</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getChildren</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$node</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
    &lt;li class=&quot;item_list clear-element&quot; id=&quot;ele-<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getPrimaryKey</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;
      &lt;div class=&quot;sort-handle&quot;&gt;
        <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getTitre</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
			&lt;/div&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;">$node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">hasChildren</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;?php</span> include_partial<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'categories/tree'</span><span style="color: #339933;">,</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'tree'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$node</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'helper'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$helper</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
      <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
    &lt;/li&gt;
  <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endforeach</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;/ul&gt;</pre></div></div>

<p>Et là, un petit coup de F5 et la magie comment à opérer. Vous pouvez maintenant déplacer les éléments de branche en branche tel un hibou&#8230; bref, ca fonctionne!</p>
<p>Un petit coup de css s&#8217;impose pour que ca se rapproche le plus possible des autres modules classiques:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#sf_admin_container</span> table tr<span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#FFF</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
ul<span style="color: #cc00cc;">#menu</span> li<span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">list-style</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">inline</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">10px</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#admin_content</span> ul <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">list-style-position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">inside</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#admin_content</span> ul<span style="color: #cc00cc;">#list-container</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">margin-left</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1em</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#FFF</span> <span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">10px</span> <span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#admin_content</span> ul li <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">list-style-position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">inside</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
li img <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">vertical-align</span><span style="color: #00AA00;">:</span> text-<span style="color: #000000; font-weight: bold;">bottom</span> <span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#list-container</span> li span <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">cursor</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">pointer</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#sortHelper</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#FFE</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#dragHelper</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#EEE</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
div<span style="color: #6666ff;">.wrap</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#BBBBBB</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1em</span> <span style="color: #933;">1em</span> <span style="color: #933;">1em</span> <span style="color: #933;">1em</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#main_list</span><span style="color: #00AA00;">,</span><span style="color: #cc00cc;">#contenu_list</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">700px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#main_list</span> li <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">list-style-type</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">list-style-position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.page-list</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">list-style</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">block</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.clear-element</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">clear</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">both</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">relative</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.sort-handle</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">cursor</span><span style="color: #00AA00;">:</span>move<span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #933;">0.25em</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">2px</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">2px</span> <span style="color: #933;">18px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#f3F3F3</span> <span style="color: #000000; font-weight: bold;">left</span> <span style="color: #993333;">center</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">../images/toggleexpanddark.png</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">no-repeat</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
div<span style="color: #6666ff;">.item-title</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#DDD</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #933;">0.25em</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">2px</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">2px</span> <span style="color: #933;">18px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.list-action</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #808080; font-style: italic;">/*background-color: #f3F3F3;*/</span>
	<span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">right</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">350px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>Et l&#8217;image qui va bien (récupéré de redotheoffice):<br />
<img src="http://www.amicalement-web.net/wp-content/uploads/toggleexpanddark.png" alt="toggleexpanddark" title="toggleexpanddark" width="16" height="16" class="alignnone size-full wp-image-229" /></p>
<p>Et voilà, la première étape s&#8217;achève ici, on peut s&#8217;amuser à déplacer ces éléments. La suite très prochainement, pour remettre les actions et ajouter une action pour sauvegarder l&#8217;arbre.</p>
<p>A noter que je ne détaille pas forcément toutes les étapes de création d&#8217;un projet symfony, <a  href="http://www.symfony-project.org/jobeet/1_2/Propel/en/" class="extern">Jobeet</a> le fais si bien.</p>
<p>Évidemment, toutes remarques, questions, propositions, meilleurs solutions sont les bienvenues! Je suis aussi là pour apprendre : )</p>
]]></content:encoded>
			<wfw:commentRss>http://www.amicalement-web.net/symfony-gestion-d-un-arbre-en-propel-via-les-nestedset-part-1/2009/05/12/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>IE6 sur Mac OS X, quand Linux inspire Mac</title>
		<link>http://www.amicalement-web.net/ie6-sur-mac-os-x-quand-linux-inspire-mac/2009/02/18/</link>
		<comments>http://www.amicalement-web.net/ie6-sur-mac-os-x-quand-linux-inspire-mac/2009/02/18/#comments</comments>
		<pubDate>Wed, 18 Feb 2009 10:56:46 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Bons plans]]></category>
		<category><![CDATA[astuce]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[IE6]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[navigateur]]></category>

		<guid isPermaLink="false">http://www.amicalement-web.net/?p=119</guid>
		<description><![CDATA[Tous les Linuxiens, en particulier les développeurs web ont du passer le pas un jour, installer une solution le permettant de tester leur page web dans ces magnifique navigateurs qui ralentissent l&#8217;avancée technologique du web, j&#8217;ai nommée IE6 et IE7. Là où la virtualisation se banalise grâce à des logiciels comme VirtualBox, certains utilisent encore [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.amicalement-web.net/wp-content/uploads/applications-internet.png" alt="applications-internet" title="applications-internet" width="48" height="48" class="alignleft size-full wp-image-29" /> Tous les Linuxiens, en particulier les développeurs web ont du passer le pas un jour, installer une solution le permettant de tester leur page web dans ces magnifique navigateurs qui ralentissent l&#8217;avancée technologique du web, j&#8217;ai nommée IE6 et IE7.</p>
<p>Là où la <a  href="http://fr.wikipedia.org/wiki/Virtualisation" class="extern">virtualisation</a> se banalise grâce à des logiciels comme <a  href="http://www.virtualbox.org/" class="extern">VirtualBox</a>, certains utilisent encore des émulateurs dont le célèbre <a  href="http://www.tatanka.com.br/ies4linux/page/Main_Page" class="extern">ie4linux</a>.</p>
<p>Et bien, l&#8217;alternative pour Mac OS X existe, preuve que la pomme a quand même bien fait les choses. Et pour l&#8217;installer rien de plus simple.<br />
<span id="more-119"></span><br />
Commençons par s&#8217;assurer que nous disposons de X11 qui sera utilisé pour afficher la fenêtre de notre futur IE6. Si vous ne l&#8217;avez pas spécifié à l&#8217;installation de Léopard, il  faudra l&#8217;installer via <a  href="http://developer.apple.com/tools/xcode/" class="extern">Xcode</a>, mais que tout bon développeur sous Mac aura déjà installé. L&#8217;application X11 devrait donc se situer dans Applications > Utilitaires</p>
<p>Ensuite, installer <a  href="http://www.kronenberg.org/darwine/" class="extern">Darwine</a> (via un joli .dmg et un simple glissez/déposer à la mac), qui n&#8217;est d&#8217;autre qu&#8217;un portage de Wine sur Mac OS X. </p>
<p>Maintenant tous les exe seront ouvert via Darwine. Il ne vous reste plus qu&#8217;à installer <a  href="http://www.kronenberg.org/ies4osx/" class="extern">ie4osx</a> et voilà le travail:<br />
<a  href="http://www.amicalement-web.net/wp-content/uploads/image-11.png"><img src="http://www.amicalement-web.net/wp-content/uploads/image-11-300x229.png" alt="image-11" title="image-11" width="300" height="229" class="alignnone size-medium wp-image-121" /></a></p>
<p>Alors ça reste moche hein, Mac ne fait pas de miracle, mais ca permet de dépanner rapidement pour des tests bateau, quand vous ne faites qu&#8217;assurer le service minimum pour ce navigateur ;)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.amicalement-web.net/ie6-sur-mac-os-x-quand-linux-inspire-mac/2009/02/18/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Uploadez en Symfony</title>
		<link>http://www.amicalement-web.net/uploadez-en-symfony/2009/02/10/</link>
		<comments>http://www.amicalement-web.net/uploadez-en-symfony/2009/02/10/#comments</comments>
		<pubDate>Tue, 10 Feb 2009 11:22:18 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Astuces]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[upload]]></category>

		<guid isPermaLink="false">http://www.amicalement-web.net/?p=14</guid>
		<description><![CDATA[Quand on utilise un framework PHP aussi propre et bien pensé que symfony, on a souvent envie de continuer ce beau travail en ajoutant notre code de la meilleur des façons pour conserver la logique de l&#8217;application, MVC, héritage, composition&#8230; Mais ce n&#8217;est pas toujours simple. Voici un petit exemple qui concerne un passage obscur [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.amicalement-web.net/wp-content/uploads/accessories-text-editor.png" alt="accessories-text-editor" title="accessories-text-editor" width="48" height="48" class="alignleft size-full wp-image-28" /> Quand on utilise un <a  href="http://fr.wikipedia.org/wiki/Framework" class="extern">framework</a> PHP aussi propre et bien pensé que <a  href="http://www.symfony-project.org" class="extern">symfony</a>, on a souvent envie de continuer ce beau travail en ajoutant notre code de la meilleur des façons pour conserver la logique de l&#8217;application, MVC, héritage, composition&#8230;</p>
<p>Mais ce n&#8217;est pas toujours simple. Voici un petit exemple qui concerne un passage obscur de la <a  href="http://www.symfony-project.org/book/forms/1_2/en/" class="extern">documentation officielle des formulaires dans symfony</a>, l&#8217;upload de fichier.</p>
<p>Pour commencer, il faut souvent définir dans la définition de notre formulaire le widget et le validator correspondant. Dans notre exemple, on prendra un champ nommé avatar, imaginons un classe Profil:</p>

<div class="wp_syntax"><div 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> configure<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;">widgetSchema</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'avatar'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> sfWidgetFormInputFile<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">// Un upload étant rarement obligatoire, </span>
   <span style="color: #666666; font-style: italic;">// le cas de l'avatar est un bon exemple, on le rend facultatif ici</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">validatorSchema</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'avatar'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> sfValidatorFile<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'required'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span> 
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Maintenant on a bien notre formulaire qui s&#8217;affiche correctement. Le problème, si on n&#8217;upload pas de nouvel avatar, à la prochaine sauvegarde, le champ avatar sera remis à sa valeur par défaut, fonctionnement tout à fait normal en l&#8217;état.<br />
Pour éviter ceci, voici la fonction à rajouter, toujours dans notre classe de notre formulaire Profil, c&#8217;est en fait une surcharge de la méthode save:</p>

<div class="wp_syntax"><div 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> save<span style="color: #009900;">&#40;</span><span style="color: #000088;">$con</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">// On test si le champ avatar a été renseigné dans le formulaire</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'avatar'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
      <span style="color: #666666; font-style: italic;">// Si oui, on sauvegarde le fichier</span>
      <span style="color: #000088;">$filename</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'nomDuFichier'</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$extension</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$file</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getExtension</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getOriginalExtension</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;">$file</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">save</span><span style="color: #009900;">&#40;</span>sfConfig<span style="color: #339933;">::</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'sf_upload_dir'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #000088;">$filename</span><span style="color: #339933;">.</span><span style="color: #000088;">$extension</span><span style="color: #009900;">&#41;</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: #666666; font-style: italic;">// Si non, on récupère la version actuelle dans l'objet Père (ici profil), </span>
      <span style="color: #666666; font-style: italic;">// que l'on insère dans le tableau de valeur du formulaire</span>
      <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">values</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'avatar'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getObject</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getAvatar</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// Puis on lance la sauvegarde normal de la classe mère</span>
    <span style="color: #b1b100;">return</span> parent<span style="color: #339933;">::</span><span style="color: #004000;">save</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$con</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Et voilà, nous sommes restés dans la logique métier de symfony, en surchargeant l&#8217;existant et surtout en permettant de garder notre action identique, les modifications ayant été apportées dans le modèle.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.amicalement-web.net/uploadez-en-symfony/2009/02/10/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Un terminal mac os x plus sexy</title>
		<link>http://www.amicalement-web.net/un-terminal-mac-os-x-plus-sexy/2009/02/05/</link>
		<comments>http://www.amicalement-web.net/un-terminal-mac-os-x-plus-sexy/2009/02/05/#comments</comments>
		<pubDate>Thu, 05 Feb 2009 19:12:16 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[terminal]]></category>

		<guid isPermaLink="false">http://www.amicalement-web.net/?p=73</guid>
		<description><![CDATA[<img src="http://www.amicalement-web.net/wp-content/uploads/utilities-terminal.png" alt="utilities-terminal" title="utilities-terminal" width="48" height="48" class="alignleft size-full wp-image-41" /> Quand on vient de l'univers Linux vers le monde merveilleux de la pomme, on est vite en manque de notre cher terminal, celui qui permet de faire tout ce qu'on veut rapidement et sans se heurter à une interface peu bavarde parfois.

Mais quel choc quand on a le malheur de lancer le terminal mac dans sa configuration de base:
<a href="http://www.amicalement-web.net/wp-content/uploads/image-30.png"><img src="http://www.amicalement-web.net/wp-content/uploads/image-30-300x229.png" alt="image-30" title="image-30" width="300" height="229" class="alignnone size-medium wp-image-76" /></a>

Assez tristounet, aucune couleur et le panel de configuration est peu enclin à nous aider efficacement. Et pourtant, quand on sait que mac os x est construit sur une base unix, il serait dommage de se priver d'un terminal qui pourrait se révéler très utile, surtout pour un développeur comme moi.

On va donc se lancer dans un petit tuning de terminal. ]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.amicalement-web.net/wp-content/uploads/utilities-terminal.png" alt="utilities-terminal" title="utilities-terminal" width="48" height="48" class="alignleft size-full wp-image-41" /> Quand on vient de l&#8217;univers Linux vers le monde merveilleux de la pomme, on est vite en manque de notre cher terminal, celui qui permet de faire tout ce qu&#8217;on veut rapidement et sans se heurter à une interface peu bavarde parfois.</p>
<p>Mais quel choc quand on a le malheur de lancer le terminal mac dans sa configuration de base:<br />
<a  href="http://www.amicalement-web.net/wp-content/uploads/image-30.png"><img src="http://www.amicalement-web.net/wp-content/uploads/image-30-300x229.png" alt="image-30" title="image-30" width="300" height="229" class="alignnone size-medium wp-image-76" /></a></p>
<p>Assez tristounet, aucune couleur et le panel de configuration est peu enclin à nous aider efficacement. Et pourtant, quand on sait que mac os x est construit sur une base unix, il serait dommage de se priver d&#8217;un terminal qui pourrait se révéler très utile, surtout pour un développeur comme moi.</p>
<p>On va donc se lancer dans un petit tuning de terminal.<br />
<span id="more-73"></span></p>
<p>Première étape, si vous ne l&#8217;avez pas déjà fait, il va falloir <a  href="http://www.macports.org/install.php" class="extern">installer MacPort</a>, pour ceux qui ne connaissent pas, c&#8217;est un gestionnaire de paquet un peu comme l&#8217;est <a  href="http://doc.ubuntu-fr.org/apt" class="extern">APT</a> pour debian/ubuntu.</p>
<p>Une fois MacPort dans la place, on va justement se servir de notre cher terminal et installer le paquet coreutils grâce à la ligne suivante:</p>
<pre>
sudo port install coreutils +with_default_names
</pre>
<p>Une fois l&#8217;installation complète (attention elle peut prendre un peu de temps), on va pouvoir commencer le tuning.</p>
<p>Première chose, le fond blanc n&#8217;est pas l&#8217;idéal surtout que les autres couleurs à notre disposition seront aussi assez claires. Il suffit pour ça d&#8217;aller dans les préférences du Terminal > Réglages > Fenêtre et changer la couleur d&#8217;arrière plan. Personnellement j&#8217;ai mis noir avec une transparence à 60%, moins flashy pour les yeux.<br />
Voici un petit récap de mes autres paramètres à affiner selon vos souhaits:<br />
<a  href="http://www.amicalement-web.net/wp-content/uploads/image-32.png"><img src="http://www.amicalement-web.net/wp-content/uploads/image-32-300x239.png" alt="image-32" title="image-32" width="300" height="239" class="alignnone size-medium wp-image-88" /></a></p>
<p>On continue en éditant le profil de notre terminal grâce au fichier <code>~/.bash_profile</code>. L&#8217;idéal serait de se faire la main avec <a  href="http://fr.wikipedia.org/wiki/Vim" class="extern">VIM</a> mais n&#8217;importe quelle éditeur ira très bien. A noter que si vous n&#8217;aviez jamais mis le nez dans le terminal, il est probable que le fichier n&#8217;existe pas. Aucun souci pour le créer.</p>
<p>Je vous met ici mon fichier, rien d&#8217;énorme juste des couleurs que je trouve agréables, le listing des couleurs disponibles est plus bas:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">PATH</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>bin:<span style="color: #000000; font-weight: bold;">/</span>sw<span style="color: #000000; font-weight: bold;">/</span>bin:<span style="color: #000000; font-weight: bold;">/</span>sw<span style="color: #000000; font-weight: bold;">/</span>sbin:<span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin:<span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>sbin:<span style="color: #007800;">$PATH</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">MANPATH</span>=<span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">man</span>:<span style="color: #007800;">$MANPATH</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Couleurs du préfix du terminal</span>
<span style="color: #007800;">NM</span>=<span style="color: #ff0000;">&quot;\[\033[0;38m\]&quot;</span> 
<span style="color: #007800;">HI</span>=<span style="color: #ff0000;">&quot;\[\033[0;37m\]&quot;</span> 
<span style="color: #007800;">HII</span>=<span style="color: #ff0000;">&quot;\[\033[0;36m\]&quot;</span> 
<span style="color: #007800;">SI</span>=<span style="color: #ff0000;">&quot;\[\033[0;33m\]&quot;</span>
<span style="color: #007800;">IN</span>=<span style="color: #ff0000;">&quot;\[\033[0m\]&quot;</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">PS1</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$NM</span>[ <span style="color: #007800;">$HI</span>\u <span style="color: #007800;">$HII</span>\h <span style="color: #007800;">$SI</span>\w<span style="color: #007800;">$NM</span> ] <span style="color: #007800;">$IN</span>&quot;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$TERM</span>&quot;</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #ff0000;">&quot;dumb&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">LS_OPTIONS</span>=<span style="color: #ff0000;">'--color=auto'</span>
    <span style="color: #7a0874; font-weight: bold;">eval</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">dircolors</span> ~<span style="color: #000000; font-weight: bold;">/</span>.dir_colors<span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># alias</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">ls</span>=<span style="color: #ff0000;">'ls $LS_OPTIONS -hF'</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">ll</span>=<span style="color: #ff0000;">'ls $LS_OPTIONS -lAhF'</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> cd..=<span style="color: #ff0000;">&quot;cd ..&quot;</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">c</span>=<span style="color: #ff0000;">&quot;clear&quot;</span></pre></div></div>

<p>Puis le fichier <code>~/.dir_colors</code></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Below, there should be one TERM entry for each termtype that is colorizable</span>
TERM linux
TERM linux-c
TERM mach-color
TERM console
TERM con132x25
TERM con132x30
TERM con132x43
TERM con132x60
TERM con80x25
TERM con80x28
TERM con80x30
TERM con80x43
TERM con80x50
TERM con80x60
TERM xterm
TERM xterm-color
TERM xterm-debian      
&nbsp;
<span style="color: #666666; font-style: italic;"># Below are the color init strings for the basic file types. A color init</span>
<span style="color: #666666; font-style: italic;"># string consists of one or more of the following numeric codes:</span>
<span style="color: #666666; font-style: italic;"># Attribute codes:</span>
<span style="color: #666666; font-style: italic;"># 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed</span>
<span style="color: #666666; font-style: italic;"># Text color codes:</span>
<span style="color: #666666; font-style: italic;"># 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white</span>
<span style="color: #666666; font-style: italic;"># Background color codes:</span>
<span style="color: #666666; font-style: italic;"># 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white</span>
NORMAL 00	<span style="color: #666666; font-style: italic;"># global default, although everything should be something.</span>
FILE 00 	<span style="color: #666666; font-style: italic;"># normal file</span>
DIR 01;<span style="color: #000000;">36</span> 	<span style="color: #666666; font-style: italic;"># directory</span>
LINK 01;<span style="color: #000000;">37</span> 	<span style="color: #666666; font-style: italic;"># symbolic link.  (If you set this to 'target' instead of a</span>
           	<span style="color: #666666; font-style: italic;"># numerical value, the color is as for the file pointed to.)</span>
FIFO <span style="color: #000000;">40</span>;<span style="color: #000000;">33</span>	<span style="color: #666666; font-style: italic;"># pipe</span>
SOCK 01;<span style="color: #000000;">35</span>	<span style="color: #666666; font-style: italic;"># socket</span>
DOOR 01;<span style="color: #000000;">35</span>	<span style="color: #666666; font-style: italic;"># door</span>
BLK <span style="color: #000000;">40</span>;<span style="color: #000000;">33</span>;01	<span style="color: #666666; font-style: italic;"># block device driver</span>
CHR <span style="color: #000000;">40</span>;<span style="color: #000000;">33</span>;01 	<span style="color: #666666; font-style: italic;"># character device driver</span>
ORPHAN <span style="color: #000000;">40</span>;<span style="color: #000000;">31</span>;01 <span style="color: #666666; font-style: italic;"># symlink to nonexistent file</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># This is for files with execute permission:</span>
EXEC 01;<span style="color: #000000;">35</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># List any file extensions like '.gz' or '.tar' that you would like ls</span>
<span style="color: #666666; font-style: italic;"># to colorize below. Put the extension, a space, and the color init string.</span>
<span style="color: #666666; font-style: italic;"># (and any comments you want to add after a '#')</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># If you use DOS-style suffixes, you may want to uncomment the following:</span>
<span style="color: #666666; font-style: italic;">#.cmd 01;32 # executables (bright green)</span>
<span style="color: #666666; font-style: italic;">#.exe 01;32</span>
<span style="color: #666666; font-style: italic;">#.com 01;32</span>
<span style="color: #666666; font-style: italic;">#.btm 01;32</span>
<span style="color: #666666; font-style: italic;">#.bat 01;32</span>
&nbsp;
.tar 01;<span style="color: #000000;">31</span> <span style="color: #666666; font-style: italic;"># archives or compressed (bright red)</span>
.tgz 01;<span style="color: #000000;">31</span>
.arj 01;<span style="color: #000000;">31</span>
.taz 01;<span style="color: #000000;">31</span>
.lzh 01;<span style="color: #000000;">31</span>
.zip 01;<span style="color: #000000;">31</span>
.z   01;<span style="color: #000000;">31</span>
.Z   01;<span style="color: #000000;">31</span>
.gz  01;<span style="color: #000000;">31</span>
.bz2 01;<span style="color: #000000;">31</span>
.deb 01;<span style="color: #000000;">31</span>
.rpm 01;<span style="color: #000000;">31</span>
.jar 01;<span style="color: #000000;">31</span>
.dmg 01;<span style="color: #000000;">31</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># image formats</span>
.jpg 01;<span style="color: #000000;">34</span>
.png 01;<span style="color: #000000;">34</span>
.gif 01;<span style="color: #000000;">34</span>
.bmp 01;<span style="color: #000000;">34</span>
.ppm 01;<span style="color: #000000;">34</span>
.tga 01;<span style="color: #000000;">34</span>
.xbm 01;<span style="color: #000000;">34</span>
.xpm 01;<span style="color: #000000;">34</span>
.tif 01;<span style="color: #000000;">34</span>
.png 01;<span style="color: #000000;">34</span>
.mpg 01;<span style="color: #000000;">34</span>
.avi 01;<span style="color: #000000;">34</span>
.fli 01;<span style="color: #000000;">34</span>
.gl 01;<span style="color: #000000;">35</span>
.dl 01;<span style="color: #000000;">35</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># source code files</span>
.pl 00;<span style="color: #000000;">33</span>
.PL 00;<span style="color: #000000;">33</span>
.pm 00;<span style="color: #000000;">33</span>
.tt 00;<span style="color: #000000;">33</span>
.yml 00;<span style="color: #000000;">33</span>
.sql 00;<span style="color: #000000;">33</span>
.html 00;<span style="color: #000000;">33</span>
.css 00;<span style="color: #000000;">33</span>
.js 00;<span style="color: #000000;">33</span></pre></div></div>

<p>On obtient alors ceci:<br />
<a  href="http://www.amicalement-web.net/wp-content/uploads/image-33.png"><img src="http://www.amicalement-web.net/wp-content/uploads/image-33-300x155.png" alt="image-33" title="image-33" width="300" height="155" class="alignnone size-medium wp-image-89" /></a></p>
<p>C&#8217;est déjà plus agréable mais il manque la geek touch. Pour arranger ça, on va rendre notre terminal accessible tout le temps, avec un style quake like.</p>
<p>Pour ce faire, première chose, <a  href="http://www.culater.net/software/SIMBL/SIMBL.php" class="extern">installer SIMBL</a>. Une application, qui permet ensuite de faire des plugins pour des applications cocoas (comme notre terminal). Une fois installé, <a  href="http://code.google.com/p/blacktree-visor/" class="extern">téléchargez visor</a>, un plugin SIMBL.</p>
<p>Voilà, killez votre terminal s&#8217;il est encore ouvert et quand vous le relancez, celui-ci ne s&#8217;ouvre pas mais un petit icone est apparu dans votre menubar:<br />
<img src="http://www.amicalement-web.net/wp-content/uploads/image-35-300x38.png" alt="image-35" title="image-35" width="300" height="38" class="alignnone size-medium wp-image-90" /></p>
<p>Choisissez &laquo;&nbsp;Visor Preferences&#8230;&nbsp;&raquo;, définissez le raccourci que vous souhaitez et testez! Voilà, plus besoin de fermer votre terminal, celui-ci se range dans votre menubar. Pour les sceptiques, une petite vidéo du résultat:<br />
<object width='425' height='344' type='application/x-shockwave-flash' data='http://www.screentoaster.com/swf/STPlayer.swf'><param name='movie' value='http://www.screentoaster.com/swf/STPlayer.swf'/><param name='allowFullScreen' value='true'/><param name='flashvars' value='video=stUE1TSkxIR1pcSFtYXlhbX1BR'/></object>
<div style='width: 425px; text-align: right;'><a  href="http://www.screentoaster.com/">Screencasts and videos online</a></div>
<p>Attention, un petit bonus s&#8217;est caché dans ce billet.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.amicalement-web.net/un-terminal-mac-os-x-plus-sexy/2009/02/05/feed/</wfw:commentRss>
		<slash:comments>45</slash:comments>
		</item>
		<item>
		<title>Un PHP5 toutes options pour votre Léopard</title>
		<link>http://www.amicalement-web.net/un-php5-toutes-options-pour-votre-leopard/2009/01/31/</link>
		<comments>http://www.amicalement-web.net/un-php5-toutes-options-pour-votre-leopard/2009/01/31/#comments</comments>
		<pubDate>Sat, 31 Jan 2009 15:53:22 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Astuces]]></category>
		<category><![CDATA[Bons plans]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.amicalement-web.net/?p=51</guid>
		<description><![CDATA[La dernière version de Mac Os X, Léopard est maintenant livrée avec un couple PHP5/Apache 2 de série. Il vous suffit d&#8217;activer le partage web pour lancer l&#8217;apache et une ligne à décommenter dans le php.ini pour bénéficier du support de PHP5 et ce sans rien faire de plus. Cette combinaison suffit la plupart du [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.amicalement-web.net/wp-content/uploads/computer.png" alt="computer" title="computer" width="48" height="48" class="alignleft size-full wp-image-32" />La dernière version de Mac Os X, Léopard est maintenant livrée avec un couple PHP5/Apache 2 de série.</p>
<p>Il vous suffit d&#8217;activer le partage web pour lancer l&#8217;apache et une ligne à décommenter dans le php.ini pour bénéficier du support de PHP5 et ce sans rien faire de plus. </p>
<p>Cette combinaison suffit la plupart du temps, mais dès qu&#8217;il faut rajouter un module, librairie, PHP, ca devient vite compliqué. Que se soit GD ou ZIP, il est rarement simple, sans aucune recompilation d&#8217;installer ces librairies, pourtant assez classiques sur votre mac.</p>
<p>Et bien, un monsieur l&#8217;a compris, <a  href="http://www.entropy.ch" class="extern">Marc Liyanage</a>, qui maintient des versions de PHP5 recompilées pour mac avec toutes les options.</p>
<p>Pour l&#8217;installer, rien de compliqué, lancer un terminal puis si vous souhaitez faire un backup de votre version actuelle de PHP.</p>
<pre>
sudo mv /usr/local/php5 ~/Desktop/php5.old
</pre>
<p>Puis placez vous dans votre dossier de téléchargement habituel et télécharger la dernière version et dézippez là là où se trouvait l&#8217;ancienne.</p>
<pre>
wget http://www2.entropy.ch/download/php5-5.2.5-6-beta.tar.gz
tar -xzf php5-*-beta.tar.gz
sudo mv php5 /usr/local/
</pre>
<p>Il faut ensuite changer rajouter la conf de cette nouvelle version à notre apache</p>
<pre>
sudo ln -sf /usr/local/php5/entropy-php.conf /etc/apache2/other/+entropy-php.conf
</pre>
<p>Et on redémarre apache</p>
<pre>
sudo apachectl restart
</pre>
<p>Voilà, vous pouvez jeter un oeil à un <code>phpinfo()</code>, vous disposez maintenant de toutes les options pour votre PHP5.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.amicalement-web.net/un-php5-toutes-options-pour-votre-leopard/2009/01/31/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simplifiez vos conditions</title>
		<link>http://www.amicalement-web.net/simplifiez-vos-conditions/2009/01/25/</link>
		<comments>http://www.amicalement-web.net/simplifiez-vos-conditions/2009/01/25/#comments</comments>
		<pubDate>Sun, 25 Jan 2009 19:05:50 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Astuces]]></category>
		<category><![CDATA[astuce]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.amicalement-web.net/?p=5</guid>
		<description><![CDATA[Les conditions font partie intégrante de tous les langages de programmation, PHP ne déroge pas à la règle. Cependant il n&#8217;est pas rare qu&#8217;elles gâchent la lisibilité d&#8217;un code quand elles s&#8217;imbriquent ou quand les différents états sont à plusieurs dizaines de lignes d&#8217;écart. Un moyen simple d&#8217;y voir plus clair et de tourner vos [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.amicalement-web.net/wp-content/uploads/accessories-text-editor.png" alt="accessories-text-editor" title="accessories-text-editor" width="48" height="48" class="alignleft size-full wp-image-28" />Les conditions font partie intégrante de tous les langages de programmation, PHP ne déroge pas à la règle.</p>
<p>Cependant il n&#8217;est pas rare qu&#8217;elles gâchent la lisibilité d&#8217;un code quand elles s&#8217;imbriquent ou quand les différents états sont à plusieurs dizaines de lignes d&#8217;écart.</p>
<p>Un moyen simple d&#8217;y voir plus clair et de tourner vos conditions différemment.</p>
<p>Par exemple, on a souvent tendance à écrire:</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: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$condition</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">/* Tout mon traitement qui peut faire plusieurs dizaines de ligne */</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">/* Traitement de l'erreur, par exemple */</span>
    <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span> <span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Au final, la condition n&#8217;est utilisée que pour gérer le cas d&#8217;erreur, mais celui-ci se retrouve retranché en bas de script.</p>
<p>Pour gagner en lisibilité, on pourrait donc écrire:</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: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$condition</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">/* Traitement de l'erreur, par exemple */</span>
    <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span> <span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #666666; font-style: italic;">/* Tout mon traitement qui peut faire plusieurs dizaines de ligne */</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>La gestion de notre erreur, est maintenant dans la continuité de notre script et se révèle beaucoup plus confortable à lire. Attention toutefois, ce genre de pratique demande à ce que votre gestion d&#8217;erreur coupe l&#8217;exécution du script avec en général l&#8217;utilisation de <code>return</code>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.amicalement-web.net/simplifiez-vos-conditions/2009/01/25/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
