<?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>Blog Symfony2 - Lexik Montpellier &#187; Méthodologie</title>
	<atom:link href="http://www.lexik.fr/blog/symfony/category/methodologie/feed" rel="self" type="application/rss+xml" />
	<link>http://www.lexik.fr/blog/symfony</link>
	<description>Blog sur le développement Web PHP avec Symfony 2</description>
	<lastBuildDate>Thu, 02 Feb 2012 14:00:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Présentation du plugin lxJavascriptPlugin</title>
		<link>http://www.lexik.fr/blog/symfony/symfony/presentation-du-plugin-lxjavascriptplugin-1408</link>
		<comments>http://www.lexik.fr/blog/symfony/symfony/presentation-du-plugin-lxjavascriptplugin-1408#comments</comments>
		<pubDate>Tue, 18 Jan 2011 09:53:28 +0000</pubDate>
		<dc:creator>laurent</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[Méthodologie]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[error]]></category>

		<guid isPermaLink="false">http://www.lexik.fr/blog/symfony/?p=1408</guid>
		<description><![CDATA[L&#8217;article d&#8217;hier sur les bonnes pratiques Javascript dans un projet Symfony faisait mention d&#8217;un plugin que nous utilisons en interne et qui est maintenant disponible sur Github: lxJavascriptPlugin. Ce court article va brièvement présenter son fonctionnement et son utilisation. L&#8217;installation &#8230;<p class="more aright"><a href="http://www.lexik.fr/blog/symfony/symfony/presentation-du-plugin-lxjavascriptplugin-1408">...</a></p>]]></description>
			<content:encoded><![CDATA[<p>L&#8217;article d&#8217;hier sur les bonnes pratiques Javascript dans un projet Symfony faisait mention d&#8217;un plugin que nous utilisons en interne et qui est maintenant disponible sur Github: lxJavascriptPlugin. Ce court article va brièvement présenter son fonctionnement et son utilisation.</p>
<p><span id="more-1408"></span></p>
<p>L&#8217;installation du plugin est très rapide:</p>
<ul>
<li>téléchargez <a href="https://github.com/lexik/lxJavascriptPlugin" target="_blank">les sources sur Github</a> dans le répertoire plugins de votre projet,</li>
<li>éditez le fichier config/settings.yml pour y inclure le helper lxJavascript:

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1408code9'); return false;">View Code</a> YML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p14089"><td class="code" id="p1408code9"><pre class="yml" style="font-family:monospace;">all:
  .settings:
    standard_helpers: [ ... , lxJavascript ]</pre></td></tr></table></div>

</li>
</ul>
<p>Et c&#8217;est tout! Voyons maintenant le fonctionnement.</p>
<p>Le premier but du plugin est de solutionner les problèmes de granularité du code Javascript dans un projet Symfony. Lorsque l&#8217;on utilise par exemple des widgets JQuery, des partials pour les réseaux sociaux, ou des composants pour des GoogleMap, on se retrouve vite avec du code Javascript éparpillé dans tout notre projet, et par conséquent tout autant éparpillé dans le code des pages générées.</p>
<p>Pour régler ce problème lxJavascriptPlugin propose un premier outil: le helper lxJavascriptHelper. Son utilisation est très similaire à celle du javascriptHelper de Symfony, mais avec la méthode lx_javascript:</p>
<ul>
<li>pour inclure un fichier source externe à la page:

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1408code10'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p140810"><td class="code" id="p1408code10"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> lx_javascript<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js'</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

</li>
<li>pour inclure directement du code javascript, par exemple le bout de code pour Google Analytics, le fonctionnement est similaire à celui d&#8217;un slot:

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1408code11'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p140811"><td class="code" id="p1408code11"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> lx_javascript<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;">var</span> _gaq <span style="color: #339933;">=</span> _gaq <span style="color: #339933;">||</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
  _gaq<span style="color: #339933;">.</span>push<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'_setAccount'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'*********'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  _gaq<span style="color: #339933;">.</span>push<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'_trackPageview'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#40;</span><span style="color: #000000; 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: #000000; font-weight: bold;">var</span> ga <span style="color: #339933;">=</span> document<span style="color: #339933;">.</span>createElement<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'script'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    ga<span style="color: #339933;">.</span>src <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'https:'</span> <span style="color: #339933;">==</span> document<span style="color: #339933;">.</span>location<span style="color: #339933;">.</span>protocol ? <span style="color: #0000ff;">'https://ssl'</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">'http://www'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">'.google-analytics.com/ga.js'</span><span style="color: #339933;">;</span>
    ga<span style="color: #339933;">.</span>setAttribute<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'async'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'true'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    document<span style="color: #339933;">.</span>documentElement<span style="color: #339933;">.</span>firstChild<span style="color: #339933;">.</span>appendChild<span style="color: #009900;">&#40;</span>ga<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: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> lx_end_javascript<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Ici la balise &lt;script&gt; n&#8217;est pas nécessaire, mais vous pouvez l&#8217;utiliser si vous le souhaitez (par exemple pour garder la coloration syntaxique de votre IDE)</li>
<li>pour insérer tout le code javascript déclaré via lx_javascript() à la fin de votre layout.php:

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1408code12'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p140812"><td class="code" id="p1408code12"><pre class="html" style="font-family:monospace;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xml:lang=&quot;en&quot; lang=&quot;en&quot;&gt;
  &lt;head&gt;
    ...
  &lt;/head&gt;
  &lt;body&gt;
    ...
    &lt;?php lx_include_javascripts() ?&gt;
  &lt;/body&gt;
&lt;/html&gt;</pre></td></tr></table></div>

</li>
</ul>
<p>Le soucis de javascript dans les templates est adressé. Reste maintenant le problème du code javascript inséré via d&#8217;autres moyens, comme par exemple un widget qui utilise JQuery. Pour cela lxJavascriptPlugin propose une classe statique lxJavascriptStorage qui offre les fonctionnalités du helper depuis n&#8217;importe où dans votre code:</p>
<ul>
<li>pour ajouter une source externe:

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1408code13'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p140813"><td class="code" id="p1408code13"><pre class="php" style="font-family:monospace;">lxJavascriptStorage<span style="color: #339933;">::</span><span style="color: #004000;">addRemoteJavascript</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

</li>
<li>pour ajouter du code javascript. Voyons par exemple la méthode render() du widget sfWidgetFormJQueryDate:

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1408code14'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p140814"><td class="code" id="p1408code14"><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> render<span style="color: #009900;">&#40;</span><span style="color: #000088;">$name</span><span style="color: #339933;">,</span> <span style="color: #000088;">$value</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #000088;">$attributes</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$errors</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><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: #666666; font-style: italic;">//code</span>
  <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getOption</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'date_widget'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">render</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$name</span><span style="color: #339933;">,</span> <span style="color: #000088;">$value</span><span style="color: #339933;">,</span> <span style="color: #000088;">$attributes</span><span style="color: #339933;">,</span> <span style="color: #000088;">$errors</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;">renderTag</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'input'</span><span style="color: #339933;">,</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'type'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'hidden'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'size'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$id</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">generateId</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$name</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'_jquery_control'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'disabled'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'disabled'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>
           <a href="http://www.php.net/sprintf"><span style="color: #990000;">sprintf</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000cc; font-style: italic;">&lt;&lt;&lt;EOF
&lt;script type=&quot;text/javascript&quot;&gt;// &lt;![CDATA[
  [...]
// ]]&gt;&lt;/script&gt;
EOF</span>
    <span style="color: #339933;">,</span>
    <span style="color: #666666; font-style: italic;">//arguments du sprintf</span>
  <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Nous voyons bien le javascript retourné dans le code du widget, et donc en milieu de page. Cette fonction render() pourrait, avec lxJavascriptPlugin, ressembler à ça:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1408code15'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p140815"><td class="code" id="p1408code15"><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> render<span style="color: #009900;">&#40;</span><span style="color: #000088;">$name</span><span style="color: #339933;">,</span> <span style="color: #000088;">$value</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #000088;">$attributes</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$errors</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><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: #666666; font-style: italic;">//code &lt;/code&gt;</span>
&nbsp;
  <span style="color: #000088;">$js</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/sprintf"><span style="color: #990000;">sprintf</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000cc; font-style: italic;">&lt;&lt;&lt;EOF
&lt;script type=&quot;text/javascript&quot;&gt;// &lt;![CDATA[
  [...]
// ]]&gt;&lt;/script&gt;
EOF</span>
    <span style="color: #339933;">,</span>
    <span style="color: #666666; font-style: italic;">//arguments du sprintf</span>
  <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  lxJavascriptStorage<span style="color: #339933;">::</span><span style="color: #004000;">addJavascriptCode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$js</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getOption</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'date_widget'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">render</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$name</span><span style="color: #339933;">,</span> <span style="color: #000088;">$value</span><span style="color: #339933;">,</span> <span style="color: #000088;">$attributes</span><span style="color: #339933;">,</span> <span style="color: #000088;">$errors</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;">renderTag</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'input'</span><span style="color: #339933;">,</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'type'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'hidden'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'size'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$id</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">generateId</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$name</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'_jquery_control'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'disabled'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'disabled'</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></td></tr></table></div>

<p>Peu de changements, mais ici le javascript sera rendu avec tout le reste du javascript en pied de page. </code></li>
</ul>
<p>Notez enfin que la méthode lx_include_javascripts() rendra en premier les sources externes, puis le code javascript concaténé dans une unique balise &lt;script&gt;. Si tous les exemples précédents sont utilisés dans une application, le javascript en pied de page donnera ceci:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1408code16'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p140816"><td class="code" id="p1408code16"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script src<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&quot;</span> type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span>
<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: #006600; font-style: italic;">// &lt;![CDATA[</span>
  <span style="color: #006600; font-style: italic;">//javascript du widget</span>
&nbsp;
  <span style="color: #003366; font-weight: bold;">var</span> _gaq <span style="color: #339933;">=</span> _gaq <span style="color: #339933;">||</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
  _gaq.<span style="color: #660066;">push</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'_setAccount'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'*********'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  _gaq.<span style="color: #660066;">push</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'_trackPageview'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</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: #003366; font-weight: bold;">var</span> ga <span style="color: #339933;">=</span> document.<span style="color: #660066;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'script'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    ga.<span style="color: #660066;">src</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'https:'</span> <span style="color: #339933;">==</span> document.<span style="color: #660066;">location</span>.<span style="color: #660066;">protocol</span> <span style="color: #339933;">?</span> <span style="color: #3366CC;">'https://ssl'</span> <span style="color: #339933;">:</span> <span style="color: #3366CC;">'http://www'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'.google-analytics.com/ga.js'</span><span style="color: #339933;">;</span>
    ga.<span style="color: #660066;">setAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'async'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'true'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    document.<span style="color: #660066;">documentElement</span>.<span style="color: #660066;">firstChild</span>.<span style="color: #660066;">appendChild</span><span style="color: #009900;">&#40;</span>ga<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: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">/* ]]&gt; */</span><span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

</li>
</ul>
<p>Vous pouvez obtenir <a href="https://github.com/lexik/lxJavascriptPlugin">lxJavascriptPlugin sur Github</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lexik.fr/blog/symfony/symfony/presentation-du-plugin-lxjavascriptplugin-1408/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Réflexions sur l&#8217;élaboration d&#8217;un bon backend</title>
		<link>http://www.lexik.fr/blog/symfony/symfony/12x/reflexions-sur-lelaboration-dun-bon-backend-958</link>
		<comments>http://www.lexik.fr/blog/symfony/symfony/12x/reflexions-sur-lelaboration-dun-bon-backend-958#comments</comments>
		<pubDate>Wed, 30 Sep 2009 08:00:20 +0000</pubDate>
		<dc:creator>Calu</dc:creator>
				<category><![CDATA[1.2.x]]></category>
		<category><![CDATA[Admingenerator 1.2.x]]></category>
		<category><![CDATA[Méthodologie]]></category>
		<category><![CDATA[backend]]></category>
		<category><![CDATA[methode]]></category>
		<category><![CDATA[Symfony]]></category>

		<guid isPermaLink="false">http://www.lexik.fr/sfblog/?p=958</guid>
		<description><![CDATA[Lors de la réalisation de vos projets, l&#8217;étape de la construction du backend est devenue un passage obligatoire. Que cela soit un souhait initial du client ou une envie de pouvoir proposer une prise en main du site via une &#8230;<p class="more aright"><a href="http://www.lexik.fr/blog/symfony/symfony/12x/reflexions-sur-lelaboration-dun-bon-backend-958">...</a></p>]]></description>
			<content:encoded><![CDATA[<p>Lors de la réalisation de vos projets, l&#8217;étape de la construction du backend est devenue un passage obligatoire. Que cela soit un souhait initial du client ou une envie de  pouvoir proposer une prise en main du site via une interface, le backoffice justifie pleinement sa présence et son importance. Cette philosophie est très largement soutenue par Symfony avec son générateur CRUD d&#8217;admin, ses filters, l&#8217;extensibilité de ses templates, l&#8217;internationalisation&#8230;</p>
<p>Le but de cet article est de chercher plus loin dans les fonctionnalités de base proposées par Symfony pour l&#8217;élaboration de notre backend.</p>
<h3><span id="more-958"></span>La Homepage</h3>
<p>Proposer à l&#8217;administrateur l&#8217;affichage d&#8217;une page de listing d&#8217;un modèle, dès le login effectué,  est bien sûr une mauvaise idée. Une page d&#8217;accueil doit être présente et peut présenter les différentes informations pertinentes et vitales pour l&#8217;administrateur :</p>
<div id="attachment_960" class="wp-caption alignnone" style="width: 310px"><a href="http://www.lexik.fr/blog/symfony/wp-content/uploads/2009/09/Capture-1.png"><img class="size-medium wp-image-960" title="Accueil" src="http://www.lexik.fr/blog/symfony/wp-content/uploads/2009/09/Capture-1-300x91.png" alt="Accueil du backoffice : Statistiques et accés" width="300" height="91" /></a><p class="wp-caption-text">Accueil du backoffice : Statistiques et accés</p></div>
<p>Dans cette capture, l&#8217;accueil permet dès l&#8217;authentification, de connaitre les différentes statistiques du site et d&#8217;avoir un accés direct aux actions redondantes mais nécessaires : Utilisateurs en attente de validation, Visualisation de messages suspects etc&#8230;</p>
<p>Pour aller plus loin, vous pouvez afficher certaines indications propres à la fréquentation sur votre site. Si vous possédez un compte <a title="Google Analytics" href="www.Google.com/Analytics">Google Analytics</a>, c&#8217;est l&#8217;occasion d&#8217;en profiter ! En effet, une API pour accéder à ses statistiques est disponible depuis peu, et devinez quoi ? Il existe un plugin Symfony pour l&#8217;utiliser : <a title="sfGoogleAnalyticsPlugin : Un plugin Symfony pour Google Analytics" href="http://www.symfony-project.org/plugins/sfGoogleAnalyticsPlugin">sfGoogleAnalyticsPlugin</a>. Alors plus d&#8217;excuses pour ne plus proposer une page d&#8217;accueil efficace à votre client.</p>
<h3>Un listing précis et concis</h3>
<p>Par défault, Symfony propose un listing complet des différents champs de votre modèle. Cela est souvent beaucoup trop confus et non adapté pour les besoins d&#8217;un client :</p>
<p><a href="http://www.lexik.fr/blog/symfony/wp-content/uploads/2009/09/mauvais-listing.png"><img class="alignnone size-medium wp-image-963" title="Mauvais listing" src="http://www.lexik.fr/blog/symfony/wp-content/uploads/2009/09/mauvais-listing-300x19.png" alt="Mauvais listing" width="300" height="19" /></a></p>
<p>Il apparait comme  essentiel de sélectionner et de renommer  les différentes colonnes de votre modèle que vous souhaitez afficher. De même, selon la complexité de votre objet, il peut être intéressant de fournir des informations &laquo;&nbsp;associées&nbsp;&raquo; : Pour un objet <em>Article de Blog</em>, il est pertinent d&#8217;afficher le nombre de <em>Commentaire</em>s associés. Dans mon cas, j&#8217;affiche le nombre d&#8217;utilisateurs associés à un projet :</p>
<p><a href="http://www.lexik.fr/blog/symfony/wp-content/uploads/2009/09/listing.png"><img class="alignnone size-medium wp-image-967" title="listing" src="http://www.lexik.fr/blog/symfony/wp-content/uploads/2009/09/listing-300x54.png" alt="listing" width="300" height="54" /></a></p>
<p>Concernant les valeurs, il est déconseillé d&#8217;utiliser des IDs. Ils apportent aucune information quantitative ou qualitative pour l&#8217;administrateur. De plus, il est préférable de créer une action pour les tâches répétitives. Cela simplifie grandement l&#8217;administration pour un client et on évite ainsi de l&#8217;envoyer directement sur les pages d&#8217;éditions.</p>
<p>La <a href="http://www.symfony-project.org/book/1_2/14-Generators#chapter_14_generator_configuration">documentation</a> de Symfony étant très complète sur ce sujet, nous allons continuer notre tour d&#8217;horizon avec les filters.</p>
<h3>Les filtres au service de la navigation</h3>
<p>Symfony permet à l&#8217;aide du générateur d&#8217;administration, de trier vos modèles en fonction de filtres spécifiques. Mais comme pour la partie précédente, les problèmes sont similaires : Trop de champs renseignables, souvent complexes et non traduits. Outre la documentation de Symfony qui vient encore une fois à notre aide, il faudra faire un tour sur <a href="http://www.zen-in-progress.com/post/symfony-traduction-des-filtres-de-l-admin-generateur" target="_blank">cet article</a> pour compléter la traduction des filtres sur le backend.</p>
<p>Mais la véritable force des filtres, c&#8217;est leur utilisation de manière transparente par le client. En effet, si on reprend l&#8217;exemple de notre page d&#8217;accueil, on propose un lien &laquo;&nbsp;<em>3 projets en attente&nbsp;&raquo;</em> sensé rediriger sur les projets concernés.</p>
<h4>Comment cela est-il possible ?</h4>
<p>Tout simplement en créant le filtre qui nous permet de trier nos projets, dès le chargement de la page. La manière la plus simple est de passer nos filtres dans l&#8217;URL.</p>
<h4>Mise en place</h4>
<p>Il faut d&#8217;abord surcharger notre action index du module concerné :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p958code24'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p95824"><td class="code" id="p958code24"><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> executeIndex<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: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$request</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>getParameter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'filter'</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;">-&amp;</span>gt<span style="color: #339933;">;</span>setFilters<span style="color: #009900;">&#40;</span><span style="color: #000088;">$request</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>getParameter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'filter'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        parent<span style="color: #339933;">::</span><span style="color: #004000;">executeIndex</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$request</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>On vérifie si l&#8217;on passe un paramètre &laquo;&nbsp;filter&nbsp;&raquo; lors du chargement de la page. Le cas échéant, on applique les filtres renseignés.</p>
<p>Mon lien permettant de voir seulement les utilisateurs en attente de validation aura le routing :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p958code25'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p95825"><td class="code" id="p958code25"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">@</span>user_user?filter<span style="color: #009900;">&#91;</span>is_active<span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span></pre></td></tr></table></div>

<p>Pour mes projets en attente de validation, c&#8217;est la pratiquement la même chose, on indique en plus le type de l&#8217;argument.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p958code26'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p95826"><td class="code" id="p958code26"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">@</span>project_project?filter<span style="color: #009900;">&#91;</span>state<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>text<span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span></pre></td></tr></table></div>

<p>Pensez à bien regarder la structure de vos filtres en cas d&#8217;erreur.</p>
<h4>Allez plus loin</h4>
<p>Maintenant que vous savez filtrer directement à partir d&#8217;un lien, vous allez pouvoir vous servir de cette astuce autre part que sur la page d&#8217;accueil. Revenons sur nos listing. Nous avons vu qu&#8217;il était pratique pour le client d&#8217;afficher par exemple le nombre d&#8217;objet <em>Commentaire</em> associés à un objet <em>Article</em>. Nous sommes maintenant capables de rediriger directement vers les objets associés.</p>
<p>On ajoute une méthode d&#8217;affichage sur notre objet <em>Article</em> :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p958code27'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p95827"><td class="code" id="p958code27"><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> getCountPositioning<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">return</span> link_to<span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>getComments<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>count<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'@comment_comment?filter[article_id]='</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>Id<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;">&#125;</span></pre></td></tr></table></div>

<p>On retourne ainsi le lien contenant le filtre permettant de trier les commentaires en fonction de l&#8217;ID de l&#8217;article. Il suffit de modifer notre action index afin de correctement afficher notre entité HTML :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p958code28'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p95828"><td class="code" id="p958code28"><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> executeIndex<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>
        sfConfig<span style="color: #339933;">::</span><span style="color: #004000;">set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'sf_escaping_strategy'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$request</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>getParameter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'filter'</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;">-&amp;</span>gt<span style="color: #339933;">;</span>setFilters<span style="color: #009900;">&#40;</span><span style="color: #000088;">$request</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>getParameter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'filter'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        parent<span style="color: #339933;">::</span><span style="color: #004000;">executeIndex</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$request</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Voilà pour nos petites idées pour vous aider à parfaire votre back office. N&#8217;hésitez pas à parlez de vos astuces dans les commentaires.</p>
<h3>Mise à jour</h3>
<p lang="php">La désactivation de la stratégie d&#8217;échappement des caractères (<em>sfConfig::set(&#8216;sf_escaping_strategy&#8217;, false)) </em>est utilisée pour éviter l&#8217;affichage des balises &lt;a&gt; obtenues depuis notre modèle. Cette méthode à deux limites : D&#8217;une part, elle est inhérente à certaines failles de sécurité provoquées par une injection de code malicieux (cf commentaire de @Niko) ; D&#8217;autre part, on perd l&#8217;avantage lié à notre MVC en faisant parvenir le lien directement depuis le modèle.</p>
<p>Il est alors conseillé de déclarer dans notre <em>generator.yml </em>l&#8217;utilisation des partials pour afficher nos liens filtrants :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p958code29'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p95829"><td class="code" id="p958code29"><pre class="php" style="font-family:monospace;">display<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>_countComments<span style="color: #009900;">&#93;</span></pre></td></tr></table></div>

<p>Il suffit alors de créer notre partial <em>_countComments.php</em> dans le dossier <em>templates</em>/ de notre module :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p958code30'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p95830"><td class="code" id="p958code30"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>?php <span style="color: #b1b100;">echo</span> link_to<span style="color: #009900;">&#40;</span><span style="color: #000088;">$article</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>getComments<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>count<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'@comments_comments?filter[article_id]='</span><span style="color: #339933;">.</span><span style="color: #000088;">$article</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>getId<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: #339933;">&amp;</span>gt<span style="color: #339933;">;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.lexik.fr/blog/symfony/symfony/12x/reflexions-sur-lelaboration-dun-bon-backend-958/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Balsamiq Mockup et les wireframes graphiques</title>
		<link>http://www.lexik.fr/blog/symfony/methodologie/balsamiq-mockup-et-les-wireframes-graphiques-805</link>
		<comments>http://www.lexik.fr/blog/symfony/methodologie/balsamiq-mockup-et-les-wireframes-graphiques-805#comments</comments>
		<pubDate>Mon, 27 Jul 2009 13:36:33 +0000</pubDate>
		<dc:creator>jeremy</dc:creator>
				<category><![CDATA[Méthodologie]]></category>
		<category><![CDATA[gestion de projet]]></category>
		<category><![CDATA[webdesign]]></category>
		<category><![CDATA[wireframe]]></category>

		<guid isPermaLink="false">http://www.lexik.fr/sfblog/?p=805</guid>
		<description><![CDATA[Habituellement nous vous parlons du framework Symfony car c&#8217;est un des outils qui nous rend le plus de services pendant le développement. Mais n&#8217;oublions pas que la gestion d&#8217;un projet est primordiale à son bon déroulement. Cet article n&#8217;a pas &#8230;<p class="more aright"><a href="http://www.lexik.fr/blog/symfony/methodologie/balsamiq-mockup-et-les-wireframes-graphiques-805">...</a></p>]]></description>
			<content:encoded><![CDATA[<p>Habituellement nous vous parlons du framework Symfony car c&#8217;est un des outils qui nous rend le plus de services pendant le développement. Mais n&#8217;oublions pas que la gestion d&#8217;un projet est primordiale à son bon déroulement. Cet article n&#8217;a pas pour ambition de présenter toutes les ficelles de la gestion de projet mais simplement de se concentrer sur un point très important dans le Web à savoir <strong>le passage d&#8217;un prototype à la maquette graphique finale</strong>. Aussi cet article va vous présenter le concept des <strong>wireframes</strong> et d&#8217;un outil de conception à savoir <strong>Balsamiq Mockup</strong>.</p>
<p><span id="more-805"></span></p>
<h3>1. Qu&#8217;est ce qu&#8217;un prototype / user-story ?</h3>
<p>Dans le cadre de réunion autour d&#8217;un projet Web, on voit souvent quelqu&#8217;un sortir une feuille de papier, prendre un crayon, dessiner quelques traits hasardeux, des blocs par ci, par là, afin de présenter à un client ou un graphiste le rendu souhaité d&#8217;un site Internet ou d&#8217;un logiciel. C&#8217;est l&#8217;idée du wireframe, en beaucoup moins brouillon ! Le wireframe atteint un vrai niveau de précision, lorsque ce dernier est finalisé, on a une vision cohérente du futur rendu, il ne reste plus qu&#8217;au graphiste à ajouter sa touche graphique&#8230;</p>
<h2>2 logiques pour les prototypes / user-story :</h2>
<p>On peut globalement définir <strong>2 styles de prototypes d&#8217;interfaces</strong> :</p>
<p><strong>1. le wireframe &laquo;&nbsp;graphique&nbsp;&raquo; :</strong> il s&#8217;agit d&#8217;un prototype / scénario dont le but est de s&#8217;approcher au maximum du rendu final du site Internet. Dans un premier temps, on place les différentes zones à l&#8217;écran, cette étape s&#8217;appelle le <strong>zoning</strong>, elle permet d&#8217;organiser la page. Dans un second temps, on se concentre sur l&#8217;ergonomie, la communication générale, qui se clôture par le <strong>wireframe</strong>. A ce stade là, le wireframe détaille à la fois l&#8217;<strong>organisation de la page</strong> mais également l&#8217;<strong>ergonomie générale</strong>, l&#8217;étape suivante est naturellement la charte graphique.</p>
<p><em><strong>Note :</strong> le wireframe peut faire l&#8217;objet d&#8217;une validation auprès du client et joue un rôle de support dans la communication avec le graphiste.</em></p>
<p>On comprend bien l&#8217;intérêt de toutes ses étapes qui nous approche de manière réfléchi et construite vers la maquette graphique, cela peut se résumer par :</p>
<p style="text-align: center;"><strong>zoning &gt; wireframe &gt; charte graphique</strong></p>
<p><strong>Quelques outils :</strong><br />
- <a href="http://www.balsamiq.com/products/mockups" target="_blank">Balsamiq Mockup</a> ;<br />
- <a href="http://iplotz.com/" target="_blank">iPlotz</a>.</p>
<p><strong>2. le user-story ou histoires d&#8217;utilisateur</strong> implique un besoin moins statique, 1 seul écran ne suffit pas. L&#8217;idée est de présenter un cas, un besoin, une problématique sur plusieurs écrans, dans une idée de <strong>séquences</strong>. Ce type de wireframe est beaucoup moins lié au graphiste, d&#8217;ailleurs la touche graphique y est beaucoup moins importante. On est plus proche de la couche métier du projet et ces outils sont plus destinés au client et au développeur. C&#8217;est pour moi une étape parallèle au wireframe &laquo;&nbsp;graphique&nbsp;&raquo;, cet article n&#8217;en détaillera pas plus le fonctionnement.</p>
<h2><strong>Les gains d&#8217;un wireframe ?</strong></h2>
<p>Les gains sont multiples, en effet pour en arriver au wireframe, plusieurs briefs ont été réalisés. L&#8217;objectif final, les éléments à mettre en avant, l&#8217;ergonomie et la communication générale ont été débattus et travaillés. Le résultat n&#8217;en est que positif ! Imaginez si vous vous étiez lancés directement sur la maquette graphique, les changements a posteriori sont beaucoup plus longs et couteux.</p>
<h3>2. Balsamiq Mockup ?</h3>
<p>Ce logiciel possède une interface <strong>claire et intuitive</strong>, les différents composants sont très variés (<strong>environ 70</strong> répartis en : formulaires, blocs, player vidéo, calendrier, tree view, nuage de tags, etc.). Il possède des fonctionnalités basiques mais très pratiques telles que les raccourcis clavier et la sélection multiples d&#8217;objets à la souris.</p>
<table style="width: 100%;" border="0">
<tbody>
<tr>
<td style="width: 50%;"><a href="http://www.lexik.fr/blog/symfony/wp-content/uploads/2009/07/balsamiq-mockups-for-desktop-new-mockup.png" target="_blank"><img class="aligncenter size-medium wp-image-824" title="Capture d'écran de Balsamiq Mockup sous Mac osx" src="http://www.lexik.fr/blog/symfony/wp-content/uploads/2009/07/balsamiq-mockups-for-desktop-new-mockup-300x224.png" alt="balsamiq-mockups-for-desktop-new-mockup" width="275" height="205" /></a></td>
<td><a href="http://www.lexik.fr/blog/symfony/wp-content/uploads/2009/07/mockup.png" target="_blank"><img class="aligncenter size-medium wp-image-814" title="Exemple de wireframe avec Balsamiq Mockup" src="http://www.lexik.fr/blog/symfony/wp-content/uploads/2009/07/mockup-300x148.png" alt="mockup" width="268" height="132" /></a></td>
</tr>
</tbody>
</table>
<p>Il est possible de <strong>grouper</strong> les composants graphiques entre eux afin de les déplacer ensemble ou encore de les positionner l&#8217;un au dessus des autres, etc. Il est également possible d&#8217;inclure de véritables images, l&#8217;intégration au milieu de l&#8217;effet crayonné est étrange, mais peut s&#8217;avérer pratique dans le cadre d&#8217;un logo (cf. le cas pratique). Le logiciel inclut également <strong>une série d&#8217;icônes</strong>, dans un style crayonné, qui complète très bien certains manques de composants, notamment dans les boutons.</p>
<p>J&#8217;ai particulièrement apprécié dans le cadre d&#8217;un drag n&#8217; drop le clip des objets afin de les aligner de façon horizontale ou verticale. Avec un peu d&#8217;entraînement on peut presque se baser sur des grilles, très utiles en webdesign, ce qui permettrait plus tard de faire l&#8217;intégration avec un framework CSS, mais je m&#8217;avance, nous verrons ceci dans un futur article&#8230;</p>
<p>Le point fort de Balsamiq Mockup est son <strong>rendu crayonné et monochrome</strong> qui permet de le détacher du rendu final. En effet <strong>le danger dans un wireframe est qu&#8217;un client l&#8217;imagine comme maquette définitive</strong> ou encore qu&#8217;il s&#8217;attarde sur des problématiques graphiques qui ne seront vu qu&#8217;en étape suivante.</p>
<p>La version desktop est écrite en <strong>Adobe AIR</strong> ce qui lui confère l&#8217;avantage d&#8217;être multi-plateforme.</p>
<p>Balsamiq Mockup n&#8217;est pas complètement exempte de défauts, j&#8217;ai eu droit à quelques plantages avec plusieurs mockups ouverts et comme je le précise ci-dessus, il manque encore quelques composants graphiques, notamment sur les boutons.</p>
<p>Un autre défaut est qu&#8217;il ne permet pas de faire des liens entre prototypes. En ce sens, Balsamiq Mockup s&#8217;arrête au rang d&#8217;outil de création de prototypes &laquo;&nbsp;graphiques&nbsp;&raquo;, il ne permet pas de réaliser des scénarios / séquences d&#8217;écrans, ou plus communément appelé user-story (cf. ci-dessus).</p>
<h3>3. Cas pratique : Lexik</h3>
<p>Vous avez la chance, via cet article, de voir les premiers wireframes du futur site de Lexik.fr :</p>
<table style="width: 100%;" border="0">
<tbody>
<tr>
<td style="width: 50%; padding-bottom: 20px;"><a href="http://www.lexik.fr/blog/symfony/wp-content/uploads/2009/07/lexik-home_2.png" target="_blank"><img class="aligncenter size-medium wp-image-815" title="Lexik - page d'accueil de la nouvelle version" src="http://www.lexik.fr/blog/symfony/wp-content/uploads/2009/07/lexik-home_2-226x300.png" alt="lexik-home_2" width="226" height="300" /></a></td>
<td style="width: 50%; padding-bottom: 20px;"><a href="http://www.lexik.fr/blog/symfony/wp-content/uploads/2009/07/lexik-listing2.png" target="_blank"><img class="aligncenter size-medium wp-image-816" title="Lexik - listing de pages sur la nouvelle version" src="http://www.lexik.fr/blog/symfony/wp-content/uploads/2009/07/lexik-listing2-205x300.png" alt="lexik-listing2" width="205" height="300" /></a></td>
</tr>
<tr>
<td><a href="http://www.lexik.fr/blog/symfony/wp-content/uploads/2009/07/lexik-listing3.png" target="_blank"><img class="aligncenter size-medium wp-image-817" title="Lexik - listing de pages sur la nouvelle version" src="http://www.lexik.fr/blog/symfony/wp-content/uploads/2009/07/lexik-listing3-207x300.png" alt="lexik-listing3" width="207" height="300" /></a></td>
<td><a href="http://www.lexik.fr/blog/symfony/wp-content/uploads/2009/07/lexik-page.png" target="_blank"><img class="aligncenter size-medium wp-image-818" title="Lexik - modèle de page sur la nouvelle version" src="http://www.lexik.fr/blog/symfony/wp-content/uploads/2009/07/lexik-page-226x300.png" alt="lexik-page" width="226" height="300" /></a></td>
</tr>
</tbody>
</table>
<p><strong>Quelques liens :</strong><br />
- <a href="http://www.pixenjoy.com/zoning-et-wireframe" target="_blank">une présentation du zoning et des wireframes chez pixenjoy.com</a> ;<br />
- <a href="http://www.aubryconseil.com/post/2006/10/16/106-des-histoires-d-utilisateur" target="_blank">le user-story version frenchies</a> ;<br />
- <a href="http://www.superfiction.net/blog/index.php?2008/09/01/297-les-outils-online-de-conception-de-wireframes-introduction" target="_blank">présentation de quelques outils en ligne de conception de wireframes</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lexik.fr/blog/symfony/methodologie/balsamiq-mockup-et-les-wireframes-graphiques-805/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

