<?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 Symfony - Lexik Montpellier &#187; Non classé</title>
	<atom:link href="http://www.lexik.fr/blog/symfony/category/non-classe/feed" rel="self" type="application/rss+xml" />
	<link>http://www.lexik.fr/blog/symfony</link>
	<description>Blog sur le développement Web PHP</description>
	<lastBuildDate>Tue, 20 Jul 2010 08:35:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Retour sur le plugin Commentaires, partie administration</title>
		<link>http://www.lexik.fr/blog/symfony/non-classe/retour-sur-le-plugin-commentaires-partie-administration-1087</link>
		<comments>http://www.lexik.fr/blog/symfony/non-classe/retour-sur-le-plugin-commentaires-partie-administration-1087#comments</comments>
		<pubDate>Wed, 31 Mar 2010 08:39:13 +0000</pubDate>
		<dc:creator>Nikaw</dc:creator>
				<category><![CDATA[1.2.x]]></category>
		<category><![CDATA[1.3.x]]></category>
		<category><![CDATA[1.4.x]]></category>
		<category><![CDATA[Admingenerator 1.2.x]]></category>
		<category><![CDATA[Admingenerator 1.3.x]]></category>
		<category><![CDATA[Admingenerator 1.4.x]]></category>
		<category><![CDATA[Non classé]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[admin]]></category>
		<category><![CDATA[backend]]></category>
		<category><![CDATA[commentable]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://www.lexik.fr/blog/symfony/?p=1087</guid>
		<description><![CDATA[J&#8217;espère que vous vous souvenez du post concernant le plugin / behavior sfLexikDoctrineActAsCommentablePlugin. Je vous avais promis une deuxième partie sur l&#8217;administration des commentaires, et bien après quelques mois d&#8217;absence me revoilà pour tenir ma promesse. Tout d&#8217;abord un peu de configuration, puis nous verront quelles sont l&#8217;utilité et la problématique principales de cette partie. [...]]]></description>
			<content:encoded><![CDATA[<p>J&#8217;espère que vous vous souvenez du <a href="http://www.lexik.fr/blog/symfony/symfony/sflexikdoctrineactascommentableplugin-ou-comment-rendre-des-objets-commentables-via-un-behavior-plugin-1002">post concernant le plugin / behavior sfLexikDoctrineActAsCommentablePlugin</a>.<br />
Je vous avais promis une deuxième partie sur l&#8217;administration des commentaires, et bien après quelques mois d&#8217;absence me revoilà pour tenir ma promesse.<br />
<span id="more-1087"></span><br />
Tout d&#8217;abord un peu de configuration, puis nous verront quelles sont l&#8217;utilité et la problématique principales de cette partie.<br />
Nous verrons l&#8217;administration des commentaires dans leur ensemble, puis la gestion des commentaires depuis l&#8217;objet porteur.</p>
<p><strong><em>Configuration</em></strong><br />
Tout d&#8217;abord il ne faut pas oublier de charger le module dans les settings.<br />
apps/backend/config/settings.yml :</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('p1087code15'); return false;">View Code</a> YAML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p108715"><td class="code" id="p1087code15"><pre class="yaml" style="font-family:monospace;">all:
  .settings:
    enabled_modules: [..., comment]</pre></td></tr></table></div>

<p><strong><em>Problématique</em></strong></p>
<p>On veut ici pouvoir gérer facilement et rapidement les commentaires déposés par les utilisateurs.<br />
Une des problématiques sera donc la façon de lister les commentaires sur l&#8217;index.<br />
J&#8217;ai choisi par défaut de regrouper les commentaires par type d&#8217;objet, puis par objet, puis par date de modification.</p>
<p>Exemple : je liste tous les commentaires déposé sur les objets Message, je les regroupe par message, et je les classe par date de modification (la plupart du temps, un commentaire ne pouvant être modifié, on aura une concordance entre la date d&#8217;ajout et la date de modification).</p>
<p>Pour ceci, je spécifie dans le fichier de génération la méthode utilisée pour récupérer les commentaires :<br />
plugins/sfLexikDoctrineActAsCommentablePlugin/module/comment/config/generator.yml :</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('p1087code16'); return false;">View Code</a> YAML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p108716"><td class="code" id="p1087code16"><pre class="yaml" style="font-family:monospace;">generator:
  config:
    list:
      table_method: retrieveBackendCommentList</pre></td></tr></table></div>

<p>La méthode en question :<br />
plugins/sfLexikDoctrineActAsCommentablePlugin/lib/model/doctrine/PluginCommentTable.class.php :</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('p1087code17'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p108717"><td class="code" id="p1087code17"><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> retrieveBackendCommentList<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">createQuery</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'c'</span><span style="color: #009900;">&#41;</span>
            <span style="color: #339933;">-&gt;</span><span style="color: #004000;">orderBy</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'c.parent_class_name ASC'</span><span style="color: #009900;">&#41;</span>
            <span style="color: #339933;">-&gt;</span><span style="color: #004000;">addOrderBy</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'c.parent_id ASC'</span><span style="color: #009900;">&#41;</span>
            <span style="color: #339933;">-&gt;</span><span style="color: #004000;">addOrderBy</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'c.updated_at DESC'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$query</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Nous allons maintenant nous pencher sur les différents traitements que je propose.<br />
Il s&#8217;agit ici de publier / censurer, marquer comme spam / non spam, nettoyer les spams, et bien sûr supprimer des commentaires.</p>
<p>Tout d&#8217;abord je vous donne la configuration que j&#8217;ai choisie pour l&#8217;index, évidemment vous pouvez choisir de la changer, elle représente mes préférences rapportées au projet pour lequel j&#8217;ai créé ce plugin.<br />
plugins/sfLexikDoctrineActAsCommentablePlugin/module/comment/config/generator.yml :</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('p1087code18'); return false;">View Code</a> YAML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p108718"><td class="code" id="p1087code18"><pre class="yaml" style="font-family:monospace;">generator:
  class: sfDoctrineGenerator
  param:
    model_class:           Comment
    theme:                 admin
    non_verbose_templates: true
    with_show:             false
    singular:              ~
    plural:                ~
    route_prefix:          comment
    with_doctrine_route:     1
&nbsp;
    config:
      actions: ~
      fields:
      list:
        table_method: retrieveBackendCommentList
        display: [author_name, author_mail, text, is_published, is_spam]
        fields:
          author_name: {label: 'Nom auteur'}
        actions:
          _delete: ~
          CleanSpam: {label: 'Nettoyer les spams'}
        object_actions:
          Publish: {label: 'Publier'}
          UnPublish: {label: 'Censurer'}
          MakeSpam: {label: 'Spam !'}
          UnmakeSpam: {label: 'Pas spam'}
          _delete: ~
        batch_actions:
          _delete: ~
          Publish: {label: 'Publier'}
          UnPublish: {label: 'Censurer'}
          MakeSpam: {label: 'Marquer comme spams'}
          UnmakeSpam: {label: 'Retirer des spams'}
      filter: ~
      form: ~
      edit: ~
      new:     ~</pre></td></tr></table></div>

<p>Laissez moi maintenant vous décrire rapidement chaque méthode :<br />
<strong>Publish: {label: &#8216;Publier&#8217;}</strong><br />
permet d&#8217;afficher un commentaire</p>
<p><strong>UnPublish: {label: &#8216;Censurer&#8217;}</strong><br />
permet de censurer un commentaire, c&#8217;est à dire de bloquer sa publication</p>
<p><strong>MakeSpam: {label: &#8216;Spam !&#8217;}</strong><br />
permet de marquer un commentaire en tant que spam</p>
<p><strong>UnmakeSpam: {label: &#8216;Pas spam&#8217;}</strong><br />
permet de marquer un commentaire en tant que non spam</p>
<p>Ces méthodes dans la &laquo;&nbsp;list&nbsp;&raquo; s&#8217;appliquent sur un seul commentaire, et dans le &laquo;&nbsp;batch&nbsp;&raquo; sur un groupe de commentaires sélectionnés.</p>
<p>La méthode <strong>CleanSpam: {label: &#8216;Nettoyer les spams&#8217;}</strong> quant à elle permet de supprimer d&#8217;un coup tous les commentaires notifiés comme étant des spams.</p>
<p>Voici le code des méthodes ci-dessus :<br />
plugins/sfLexikDoctrineActAsCommentablePlugin/modules/comment/actions/actions.class.php :</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('p1087code19'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p108719"><td class="code" id="p1087code19"><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> executeListCleanSpam<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;">$nb</span> <span style="color: #339933;">=</span> Doctrine<span style="color: #339933;">::</span><span style="color: #004000;">getTable</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Comment'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">cleanSpam</span><span style="color: #009900;">&#40;</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: #000088;">$nb</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;">setFlash</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'notice'</span><span style="color: #339933;">,</span> <span style="color: #990000;">sprintf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'%d spam'</span><span style="color: #339933;">.</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$nb</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">1</span> ? <span style="color: #0000ff;">'s'</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">' supprimé'</span><span style="color: #339933;">.</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$nb</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">1</span> ? <span style="color: #0000ff;">'s'</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$nb</span><span style="color: #009900;">&#41;</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: #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;">'Pas de spams.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">redirect</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'@comment'</span><span style="color: #009900;">&#41;</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> executeListPublish<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;">$page</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;">'page'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</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;">comment</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>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">comment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setIsPublished</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">comment</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>
&nbsp;
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">redirect</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'@comment?page='</span><span style="color: #339933;">.</span><span style="color: #000088;">$page</span><span style="color: #009900;">&#41;</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> executeListUnPublish<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;">$page</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;">'page'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</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;">comment</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>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">comment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setIsPublished</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">false</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;">comment</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>
&nbsp;
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">redirect</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'@comment?page='</span><span style="color: #339933;">.</span><span style="color: #000088;">$page</span><span style="color: #009900;">&#41;</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> executeListMakeSpam<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;">$page</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;">'page'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</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;">comment</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>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">comment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setIsSpam</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">comment</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>
&nbsp;
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">redirect</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'@comment?page='</span><span style="color: #339933;">.</span><span style="color: #000088;">$page</span><span style="color: #009900;">&#41;</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> executeListUnmakeSpam<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;">$page</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;">'page'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</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;">comment</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>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">comment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setIsSpam</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">false</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;">comment</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>
&nbsp;
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">redirect</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'@comment?page='</span><span style="color: #339933;">.</span><span style="color: #000088;">$page</span><span style="color: #009900;">&#41;</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> executeBatchPublish<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;">$page</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;">'page'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$ids</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;">'ids'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ids</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$id</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;">comment</span> <span style="color: #339933;">=</span> Doctrine<span style="color: #339933;">::</span><span style="color: #004000;">getTable</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Comment'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">find</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$id</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;">comment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setIsPublished</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">comment</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>
&nbsp;
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">redirect</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'@comment?page='</span><span style="color: #339933;">.</span><span style="color: #000088;">$page</span><span style="color: #009900;">&#41;</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> executeBatchUnPublish<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;">$page</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;">'page'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$ids</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;">'ids'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ids</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$id</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;">comment</span> <span style="color: #339933;">=</span> Doctrine<span style="color: #339933;">::</span><span style="color: #004000;">getTable</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Comment'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">find</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$id</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;">comment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setIsPublished</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">false</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;">comment</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>
&nbsp;
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">redirect</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'@comment?page='</span><span style="color: #339933;">.</span><span style="color: #000088;">$page</span><span style="color: #009900;">&#41;</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> executeBatchMakeSpam<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;">$page</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;">'page'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$ids</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;">'ids'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ids</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$id</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;">comment</span> <span style="color: #339933;">=</span> Doctrine<span style="color: #339933;">::</span><span style="color: #004000;">getTable</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Comment'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">find</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$id</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;">comment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setIsSpam</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">comment</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>
&nbsp;
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">redirect</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'@comment?page='</span><span style="color: #339933;">.</span><span style="color: #000088;">$page</span><span style="color: #009900;">&#41;</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> executeBatchUnmakeSpam<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;">$page</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;">'page'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$ids</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;">'ids'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ids</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$id</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;">comment</span> <span style="color: #339933;">=</span> Doctrine<span style="color: #339933;">::</span><span style="color: #004000;">getTable</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Comment'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">find</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$id</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;">comment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setIsSpam</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">false</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;">comment</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>
&nbsp;
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">redirect</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'@comment?page='</span><span style="color: #339933;">.</span><span style="color: #000088;">$page</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>et la méthode cleanSpam() dans le modèle :<br />
plugins/sfLexikDoctrineActAsCommentablePlugin/lib/model/doctrine/PluginCommentTable.class.php :</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('p1087code20'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p108720"><td class="code" id="p1087code20"><pre class="php" style="font-family:monospace;">  <span style="color: #009933; font-style: italic;">/**
   * supprime tous les commentaires classifiés comme spam et retourne le nombre d'enregistrements supprimés
   *
   * @return int
   */</span>
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> cleanSpam<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$q</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">createQuery</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'c'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">delete</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">where</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'c.is_spam = ?'</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$q</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">execute</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Je n&#8217;ai pas touché au filtre, mais chacun peut décider que tel ou tel champ sera utile ou pas, ça dépendra très souvent du projet.</p>
<p>Donc voilà pour la première étape. Jusque là on peut afficher et traiter les commentaires un par un ou par lots, directement depuis leur index.</p>
<p>Voyons maintenant comment ajouter la gestion des commentaires depuis les objets porteurs.<br />
Attention, cette partie est une nouveauté par rapport au premier post, voici les nouvelles sources : plugin.</p>
<p>Tout d&#8217;abord il faut ajouter dans l&#8217;édition de l&#8217;objet porteur le partial qui permettra de gérer les commentaires.<br />
Pour éviter de devoir dupliquer le même template pour chaque type d&#8217;objet, on va créer un partial dans le module comment du plugin puis l&#8217;appeler dans le partial de l&#8217;objet porteur :<br />
/home/lexik/sfprojects/kelsms/plugins/sfLexikDoctrineActAsCommentablePlugin/modules/comment/templates/_backend_comments_list.php :</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('p1087code21'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p108721"><td class="code" id="p1087code21"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;container_16&quot;</span><span style="color: #339933;">&gt;</span>
  Commentaires <span style="color: #339933;">:</span>
<span style="color: #339933;">&lt;</span>ul <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;order&quot;</span><span style="color: #339933;">&gt;</span>
    <span style="color: #000088;">$comment</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
	<span style="color: #339933;">&lt;</span>li id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php echo <span style="color: #006699; font-weight: bold;">$comment-&gt;getId</span>() ?&gt;&quot;</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;row_&lt;?php echo <span style="color: #006699; font-weight: bold;">$key</span>%2 ?&gt;&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;show_&lt;?php echo <span style="color: #006699; font-weight: bold;">$comment-&gt;getId</span>() ?&gt;&quot;</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;grid_10&quot;</span><span style="color: #339933;">&gt;</span>
          <span style="color: #000088;">$comment</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: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;grid_4&quot;</span><span style="color: #339933;">&gt;</span>
          <span style="color: #000088;">$comment</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: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>ul<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;&lt;!--</span>mce<span style="color: #339933;">:</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">--&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>Il sera appelé de la manière suivant dans le partial de notre objet, par exemple ici un Message, grâce à la configuration du generator.yml :</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('p1087code22'); return false;">View Code</a> YAML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p108722"><td class="code" id="p1087code22"><pre class="yaml" style="font-family:monospace;">generator:
  config:
      edit:
        display: [..., _handle_comments]</pre></td></tr></table></div>

<p>apps/backend/modules/message/template/_handle_comments.php :</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('p1087code23'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p108723"><td class="code" id="p1087code23"><pre class="php" style="font-family:monospace;"><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;">findComments</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: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Bref.<br />
Dans le partial _backend_comments_list.php on remarque 3 choses :<br />
1) l&#8217;appel du partial backend_show<br />
2) l&#8217;appel du partial backend_comment_actions<br />
3) les fonctions javascript</p>
<p>1) le partial backend_show affiche tout simplement le contenu du commentaire :<br />
_backend_show.php</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('p1087code24'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p108724"><td class="code" id="p1087code24"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;show_comment_class&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;infos_class&quot;</span><span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>span <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;author_name_class&quot;</span><span style="color: #339933;">&gt;</span>
      getAuthorName<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
    <span style="color: #339933;">&lt;/</span>span<span style="color: #339933;">&gt;</span>
&nbsp;
    <span style="color: #339933;">&lt;</span>span <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;time_and_date_class&quot;</span><span style="color: #339933;">&gt;</span>
      <span style="color: #339933;">-</span> le <span style="color: #339933;">&lt;</span>span <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;date_class&quot;</span><span style="color: #339933;">&gt;</span>getCreatedAt<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'d/MM/yyyy'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'fr'</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>span<span style="color: #339933;">&gt;</span>
      à <span style="color: #339933;">&lt;</span>span <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;time_class&quot;</span><span style="color: #339933;">&gt;</span>getCreatedAt<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'hh:mm'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'fr'</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>span<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;/</span>span<span style="color: #339933;">&gt;&lt;/</span>div<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>hr <span style="color: #339933;">/&gt;</span>
<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text_class&quot;</span><span style="color: #339933;">&gt;</span>
    <span style="color: #990000;">getText</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: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>2) le partial _backend_comment_actions.php contient les actions pouvant être effectuées sur un commentaire :</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('p1087code25'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p108725"><td class="code" id="p1087code25"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>a onclick<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;publishComment(&lt;?php echo <span style="color: #006699; font-weight: bold;">$comment-&gt;getId</span>()?&gt;)&quot;</span> href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>publier<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;</span> <span style="color: #339933;">|</span>
<span style="color: #339933;">&lt;</span>a onclick<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;unPublishComment(&lt;?php echo <span style="color: #006699; font-weight: bold;">$comment-&gt;getId</span>()?&gt;)&quot;</span> href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>censurer<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;</span> <span style="color: #339933;">|</span>
<span style="color: #339933;">&lt;</span>a onclick<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;makeSpamComment(&lt;?php echo <span style="color: #006699; font-weight: bold;">$comment-&gt;getId</span>()?&gt;)&quot;</span> href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>spam<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;</span> <span style="color: #339933;">|</span>
<span style="color: #339933;">&lt;</span>a onclick<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;unMakeSpamComment(&lt;?php echo <span style="color: #006699; font-weight: bold;">$comment-&gt;getId</span>()?&gt;)&quot;</span> href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>pas spam<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;</span> <span style="color: #339933;">|</span>
<span style="color: #339933;">&lt;</span>a onclick<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;deleteComment(&lt;?php echo <span style="color: #006699; font-weight: bold;">$comment-&gt;getId</span>()?&gt;)&quot;</span> href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>supprimer<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;</span> <span style="color: #339933;">|</span>
<span style="color: #339933;">&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php echo url_for('@comment_edit?id='.<span style="color: #006699; font-weight: bold;">$comment-&gt;getId</span>()) ?&gt;&quot;</span><span style="color: #339933;">&gt;</span>editer<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>3) les fonctions javascript : elles permettent d&#8217;appeler respectivement les méthodes permettant d&#8217;effectuer les actions correspondante, tout ça en AJAX.</p>
<p>Ces différentes actions vont effectuer le même travail que les ListAction, à la différence près qu&#8217;elle sont appelée en Ajax, et n&#8217;ont donc pas le même template de retour.</p>
<p>Voilà d&#8217;abord le routing, puis les actions :</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('p1087code26'); return false;">View Code</a> YAML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p108726"><td class="code" id="p1087code26"><pre class="yaml" style="font-family:monospace;">comment_ajax_publish:
  url:   /comment_ajax_publish
  params: {module: comment, action: ajaxPublish}
comment_ajax_unpublish:
  url:   /comment_ajax_unpublish
  params: {module: comment, action: ajaxUnPublish}
comment_ajax_makespam:
  url:   /comment_ajax_markspam
  params: {module: comment, action: ajaxMakeSpam}
comment_ajax_unmakespam:
  url:   /comment_ajax_unmarkspam
  params: {module: comment, action: ajaxUnMakeSpam}
comment_ajax_delete:
  url:   /comment_ajax_delete
  params: {module: comment, action: ajaxDelete}</pre></td></tr></table></div>

<p>actions :</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('p1087code27'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p108727"><td class="code" id="p1087code27"><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> executeAjaxPublish<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;">comment</span> <span style="color: #339933;">=</span> Doctrine<span style="color: #339933;">::</span><span style="color: #004000;">getTable</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Comment'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">find</span><span style="color: #009900;">&#40;</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;">'id'</span><span style="color: #009900;">&#41;</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;">forward404Unless</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">comment</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;">publish</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">comment</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;">setTemplate</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ajaxAction'</span><span style="color: #009900;">&#41;</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> executeAjaxUnPublish<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;">comment</span> <span style="color: #339933;">=</span> Doctrine<span style="color: #339933;">::</span><span style="color: #004000;">getTable</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Comment'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">find</span><span style="color: #009900;">&#40;</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;">'id'</span><span style="color: #009900;">&#41;</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;">forward404Unless</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">comment</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;">unpublish</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">comment</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;">setTemplate</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ajaxAction'</span><span style="color: #009900;">&#41;</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> executeAjaxMakeSpam<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;">comment</span> <span style="color: #339933;">=</span> Doctrine<span style="color: #339933;">::</span><span style="color: #004000;">getTable</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Comment'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">find</span><span style="color: #009900;">&#40;</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;">'id'</span><span style="color: #009900;">&#41;</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;">forward404Unless</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">comment</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;">makespam</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">comment</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;">setTemplate</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ajaxAction'</span><span style="color: #009900;">&#41;</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> executeAjaxUnMakeSpam<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;">comment</span> <span style="color: #339933;">=</span> Doctrine<span style="color: #339933;">::</span><span style="color: #004000;">getTable</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Comment'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">find</span><span style="color: #009900;">&#40;</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;">'id'</span><span style="color: #009900;">&#41;</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;">forward404Unless</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">comment</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;">unmakespam</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">comment</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;">setTemplate</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ajaxAction'</span><span style="color: #009900;">&#41;</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> executeAjaxDelete<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;">comment</span> <span style="color: #339933;">=</span> Doctrine<span style="color: #339933;">::</span><span style="color: #004000;">getTable</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Comment'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">find</span><span style="color: #009900;">&#40;</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;">'id'</span><span style="color: #009900;">&#41;</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;">forward404Unless</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">comment</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;">comment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">delete</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;
  protected <span style="color: #000000; font-weight: bold;">function</span> publish<span style="color: #009900;">&#40;</span><span style="color: #000088;">$comment</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$comment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setIsPublished</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$comment</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>
  protected <span style="color: #000000; font-weight: bold;">function</span> unpublish<span style="color: #009900;">&#40;</span><span style="color: #000088;">$comment</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$comment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setIsPublished</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$comment</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>
  protected <span style="color: #000000; font-weight: bold;">function</span> makespam<span style="color: #009900;">&#40;</span><span style="color: #000088;">$comment</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$comment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setIsSpam</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$comment</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>
  protected <span style="color: #000000; font-weight: bold;">function</span> unmakespam<span style="color: #009900;">&#40;</span><span style="color: #000088;">$comment</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$comment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setIsSpam</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$comment</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></pre></td></tr></table></div>

<p><em>On remarque une certaine redondance de code dans le actions.class.php,c&#8217;est pour ça que j&#8217;ai factorisé. Pensez à corriger les autres actions (elles sont ok si vous récupérez les sources).</em></p>
<p>Et pour finir, dans les templates correspondant à ces actions, on reload la ligne du commentaire en cours, ce qui permettra de mette à jour ses état de publication et spam dans la liste des commentaires.</p>
<p>ajaxActionSuccess.php :</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('p1087code28'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p108728"><td class="code" id="p1087code28"><pre class="php" style="font-family:monospace;">include_partial<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'comment/backend_show'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'comment'</span><span style="color: #339933;">=&gt;</span><span style="color: #000088;">$comment</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span></pre></td></tr></table></div>

<p>Voilà, si vous avez des questions ou des incompréhensions, n&#8217;hésitez pas !</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lexik.fr/blog/symfony/non-classe/retour-sur-le-plugin-commentaires-partie-administration-1087/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Développeur Web Symfony Montpellier</title>
		<link>http://www.lexik.fr/blog/symfony/non-classe/travailler-chez-lexik-developpeur-web-symfony-1069</link>
		<comments>http://www.lexik.fr/blog/symfony/non-classe/travailler-chez-lexik-developpeur-web-symfony-1069#comments</comments>
		<pubDate>Fri, 26 Feb 2010 10:41:35 +0000</pubDate>
		<dc:creator>Samuel Breton</dc:creator>
				<category><![CDATA[Non classé]]></category>
		<category><![CDATA[developpeur]]></category>
		<category><![CDATA[montpellier]]></category>
		<category><![CDATA[Symfony]]></category>

		<guid isPermaLink="false">http://www.lexik.fr/blog/symfony/?p=1069</guid>
		<description><![CDATA[Lexik est une société spécialisée dans le développement Symfony et la conception de solutions orientées web. Sous la responsabilité d&#8217;un chef de projet technique, au sein d&#8217;une équipe de développeurs, vous aurez à charge de concevoir et de développer des solutions Intranet / Internet. De formation initiale informatique (de bac à +5), vous êtes un [...]]]></description>
			<content:encoded><![CDATA[<p>Lexik est une société spécialisée dans le développement Symfony et la conception de solutions orientées web.<br />
Sous la responsabilité d&#8217;un chef de projet technique, au sein d&#8217;une équipe de développeurs, vous aurez à charge de concevoir et de développer des solutions Intranet / Internet.</p>
<p>De formation initiale informatique (de bac à +5), vous êtes un développeur confirmé en PHP/MySQL (environnement LAMP et WAMP) avec une expérience d&#8217;au moins 1 ans au sein d&#8217;une SSII ou d&#8217;une web agency.</p>
<p>Compétences requises :<br />
- Framework PHP Symfony<br />
- bonnes connaissances des environnements WAMP (Windows) et LAMP<br />
- MySQL et SQL<br />
- PHP (programmation objet)<br />
- (X)HTML, DHTML , JavaScript, CSS.<br />
- AJAX<br />
- Javascript, jQuery<br />
- standards du web (W3C)<br />
- Connaissance de subversion</p>
<p>Qualités recherchées :<br />
- curiosité<br />
- force de proposition<br />
- sens du travail en équipe</p>
<p>Disponibilité :<br />
- ASAP</p>
<p>Poste à Montpellier 34000</p>
<p>Contactez Samuel Breton, Tél : 04 67 99 63 19<br />
Email : contact@lexik.fr<br />
CV + LM </p>
]]></content:encoded>
			<wfw:commentRss>http://www.lexik.fr/blog/symfony/non-classe/travailler-chez-lexik-developpeur-web-symfony-1069/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>se connecter du backend vers le frontend avec un utilisateur</title>
		<link>http://www.lexik.fr/blog/symfony/non-classe/se-connecter-du-backend-vers-le-frontend-avec-un-utilisateur-1018</link>
		<comments>http://www.lexik.fr/blog/symfony/non-classe/se-connecter-du-backend-vers-le-frontend-avec-un-utilisateur-1018#comments</comments>
		<pubDate>Fri, 11 Dec 2009 13:56:02 +0000</pubDate>
		<dc:creator>thomas</dc:creator>
				<category><![CDATA[Non classé]]></category>

		<guid isPermaLink="false">http://www.lexik.fr/blog/symfony/?p=1018</guid>
		<description><![CDATA[Pour certains projets, il peut être pratique de se connecter sur le compte d&#8217;un utilisateur parce qu&#8217;il est bloqué, pour vérifier que tout fonctionne bien, pour tester son application. Cependant les mots de passe sont cryptés en bases de données et sans connaître les identifiants il va être difficile de se connecter. Donc ce petit [...]]]></description>
			<content:encoded><![CDATA[<p>Pour certains projets, il peut être pratique de se connecter sur le compte d&#8217;un utilisateur parce qu&#8217;il est bloqué, pour vérifier que tout fonctionne bien, pour tester son application. Cependant les mots de passe sont cryptés en bases de données et sans connaître les identifiants il va être difficile de se connecter.<br />
Donc ce petit tuto est là pour nous aider.<br />
Le but est simple: dans le backend, on liste l&#8217;ensemble des utilisateurs du site et à coté de chaque nom on va rajouter un bouton &laquo;&nbsp;se connecter en tant que&nbsp;&raquo;.<br />
<span id="more-1018"></span><br />
Ainsi il suffit d&#8217;appuyer sur le bouton pour se retrouver sur le frontend, connecté avec cet user.</p>
<p>Tout d&#8217;abord nous créons un partial _connectWith.php dans le module souhaité dans le backend, par exemple le module sf_guard_user.</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('p1018code33'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p101833"><td class="code" id="p1018code33"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$link_connect_with</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'http://www.monsite.fr/connect_by_admin/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$sf_guard_user</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getSalt</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$sf_guard_user</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getPassword</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$sf_request</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getCookie</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'nomdemasessionbackend'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">echo</span> link_to<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'SE CONNECTER EN TANT QUE'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$link_connect_with</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'target'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'_blank'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>le $link_connect_with est défini à coté pour plus de lisibilité.<br />
connect_by_admin est le nom de ma route.<br />
getSalt et getPassword sont les méthodes de sf_guard_user pour récupérer les données correspondantes.<br />
$sf_request->getCookie(&#8216;nomdemasessionbackend&#8217;)  avec nomdemasessionbackend qui doit être défini dans le fichier backend/config/factories.yml, on verra après son utilité.</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('p1018code34'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p101834"><td class="code" id="p1018code34"><pre class="php" style="font-family:monospace;">all<span style="color: #339933;">:</span>
  storage<span style="color: #339933;">:</span>
    <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">:</span> sfSessionStorage
    param<span style="color: #339933;">:</span>
      <span style="color: #990000;">session_name</span><span style="color: #339933;">:</span> nomdemasessionbackend</pre></td></tr></table></div>

<p>pour simplifier, ici je n&#8217;ai pas utilisé de routing ou de fonction spéciale qui va récupérer automatiquement les routes du frontend, j&#8217;ai écris directement l&#8217;url souhaitée. C&#8217;est pas très beau mais plus facile pour ce tuto.<br />
c&#8217;est tout pour le backend.</p>
<p>maintenant sur le frontend:<br />
routing.yml je rajoute ma route appelée via le backend</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('p1018code35'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p101835"><td class="code" id="p1018code35"><pre class="php" style="font-family:monospace;">connect_with<span style="color: #339933;">:</span>
  url<span style="color: #339933;">:</span> <span style="color: #339933;">/</span>connect_by_admin<span style="color: #339933;">/:</span>salt<span style="color: #339933;">/:</span>password<span style="color: #339933;">/:</span>admin
  param<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span> module<span style="color: #339933;">:</span> connect<span style="color: #339933;">,</span> action<span style="color: #339933;">:</span> Admin<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>mon action:</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('p1018code36'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p101836"><td class="code" id="p1018code36"><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> executeAdmin<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: #666666; font-style: italic;">//etape 1</span>
    <span style="color: #000088;">$salt</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;">'salt'</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$password</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;">'password'</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$admin_session</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;">'admin'</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #666666; font-style: italic;">//etape 2</span>
    <span style="color: #000088;">$cookie</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getRequest</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getCookie</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'nomdemasessionbackend'</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;">$admin_session</span> <span style="color: #339933;">!=</span> <span style="color: #000088;">$cookie</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;">forward404</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;">//etape 3</span>
    <span style="color: #000088;">$user</span> <span style="color: #339933;">=</span> Doctrine<span style="color: #339933;">::</span><span style="color: #004000;">getTable</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'sfGuardUser'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">findOneBySaltAndPassword</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$salt</span><span style="color: #339933;">,</span> <span style="color: #000088;">$password</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;">forward404Unless</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$user</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #666666; font-style: italic;">//etape 4</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;">signin</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$user</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;">redirect</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'@homepage'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>étape 1: je récupère les informations de l&#8217;url<br />
étape 2: je vérifie si le cookie nomdemasessionbackend correspond à celui passé en paramètre, sinon ERREUR404.<br />
Ceci oblige l&#8217;administrateur à être authentifié dans le backend pour pouvoir &laquo;&nbsp;se connecter en tant que&nbsp;&raquo;.<br />
étape 3: je récupère l&#8217;utilisateur qui à ce salt et ce mot de passe, sinon ERREUR404.<br />
étape 4: je connecte cet utilisateur sur le site et je redirige vers la homepage.</p>
<p>Nous avons rajouté lé vérification de la session du backend pour sécurisée cette url, mais cela implique que votre frontend et votre backend n&#8217;utilise pas les mêmes nom de sessions: <a href="http://www.lexik.fr/blog/symfony/symfony/utilisation-de-sfsessionstorage-dans-symfony-901">voir http://www.lexik.fr/blog/symfony/symfony/utilisation-de-sfsessionstorage-dans-symfony-901</a></p>
<p>Un petit tips tout simple mais assez pratique.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lexik.fr/blog/symfony/non-classe/se-connecter-du-backend-vers-le-frontend-avec-un-utilisateur-1018/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Stofcplugin : faire de bien jolis graphiques avec symfony</title>
		<link>http://www.lexik.fr/blog/symfony/non-classe/stofcplugin-faire-de-bien-jolis-graphiques-avec-symfony-692</link>
		<comments>http://www.lexik.fr/blog/symfony/non-classe/stofcplugin-faire-de-bien-jolis-graphiques-avec-symfony-692#comments</comments>
		<pubDate>Thu, 18 Jun 2009 16:32:17 +0000</pubDate>
		<dc:creator>Bérenger Vidal</dc:creator>
				<category><![CDATA[Non classé]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[graphique]]></category>
		<category><![CDATA[Stofcplugin]]></category>
		<category><![CDATA[Symfony]]></category>

		<guid isPermaLink="false">http://www.lexik.fr/sfblog/?p=692</guid>
		<description><![CDATA[Aujourd&#8217;hui , nous allons découvrir un plugin symfony permettant de réaliser simplement des graphiques en flash à partir d&#8217;un tableau de donnée. Il gère les : Histogrammes Graphique en courbes Graphiques en secteurs Graphiques en barres Graphiques en aires Les graphiques générés sont entièrement paramétrables : choix des couleurs , des titres . L&#8217;installation du [...]]]></description>
			<content:encoded><![CDATA[<p>Aujourd&#8217;hui , nous allons découvrir un plugin symfony permettant de réaliser simplement des graphiques en flash à partir d&#8217;un tableau de donnée.</p>
<p>Il gère les :</p>
<ul>
<li>Histogrammes</li>
<li>Graphique en courbes</li>
<li>Graphiques en secteurs</li>
<li>Graphiques en barres</li>
<li>Graphiques en aires</li>
</ul>
<p><span id="more-692"></span><br />
Les graphiques générés sont entièrement paramétrables : choix des couleurs , des titres .</p>
<p>L&#8217;installation du plugin est très simple :</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('p692code42'); return false;">View Code</a> YML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p69242"><td class="code" id="p692code42"><pre class="yml" style="font-family:monospace;">symfony plugin:install stOfcPlugin</pre></td></tr></table></div>

<p>puis</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('p692code43'); return false;">View Code</a> YML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p69243"><td class="code" id="p692code43"><pre class="yml" style="font-family:monospace;">symfony cc</pre></td></tr></table></div>

<p>Ensuite , dans le template où l&#8217;on veut afficher le graphique on copie la ligne suivante :</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('p692code44'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p69244"><td class="code" id="p692code44"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>code<span style="color: #339933;">&gt;</span>
stOfc<span style="color: #339933;">::</span><span style="color: #004000;">createChart</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">500</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">300</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'quiz_sondage/pieChartData?slug='</span><span style="color: #339933;">.</span><span style="color: #000088;">$quiz</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>getSlug<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> fal
<span style="color: #339933;">&lt;/</span>code<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>Les premiers paramètres correspondent à la taille du graphique tandis que le second correspond à la route qui appelle la fonction qui génèrera le graphique.</p>
<p>Si vous ne voulez pas définir une route supplémentaire vous pouvez appelez la fonction comme ceci : module/action</p>
<p>Le readme du contient des exemples pour bien commencé :</p>
<p>http://www.symfony-project.org/plugins/stOfcPlugin</p>
<p>Ce plugin est basé sur un projet open-source, voici l&#8217;adresse :</p>
<p>http://teethgrinder.co.uk/open-flash-chart/</p>
<p>Le site contient toute la doc nécessaire</p>
<p>Et voici l&#8217;adresse du forum d&#8217;aide : ( ça peut toujours servir )</p>
<p>http://forums.openflashchart.com/</p>
<h2>Autre solution pour faire des graphique sans flash : jpgraph</h2>
<p>Pour télécharger la libraire jpgraph : http://www.aditus.nu/jpgraph</p>
<p>On va donc voir comment l&#8217;utiliser avec sympfony :</p>
<p>Télécharger la dernière realease pour <strong>PHP5</strong></p>
<p>Dans un premier temps copier le dossier jpgraph obtenu après la décompression de l&#8217;archive dans le dossier lib de votre projet</p>
<p>Faites un symfony cc</p>
<p>dans le template voulu copier la ligne suivante :</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('p692code45'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p69245"><td class="code" id="p692code45"><pre class="html" style="font-family:monospace;">&lt;code&gt;
&lt;img class=&quot;graph&quot; src=&quot;&amp;lt;?php echo url_for('@actionSouhaité'); ?&amp;gt;&quot; alt=&quot;&quot; /&gt;
&lt;/code&gt;</pre></td></tr></table></div>

<p>&nbsp;&raquo; /&gt;</p>
<p>@actionSouhaité = la route appelant l&#8217;action qui va générer l&#8217;image.</p>
<p>Maintenant on va voir un modèle d&#8217;action pour génèrer l&#8217;image :</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('p692code46'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p69246"><td class="code" id="p692code46"><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> executeGraph<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>
&nbsp;
      <span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$ydata</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: #666666; font-style: italic;">// Tableau des valeurs</span>
      <span style="color: #000088;">$xdata</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: #666666; font-style: italic;">// Tableau axis ( légénde des valeurs )</span>
&nbsp;
      <span style="color: #666666; font-style: italic;">// Code pour remplir les tableau comme vous voulez    </span>
&nbsp;
     <span style="color: #666666; font-style: italic;">// Création du graph type courbe</span>
      <span style="color: #000088;">$graph</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Graph<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1300</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">400</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;auto&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$graph</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>SetScale<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;textlin&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$graph</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>title<span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>Set<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Evolution du nombre d\'</span>inscription<span style="color: #0000ff;">');
      $graph-&amp;gt;title-&amp;gt;SetFont(FF_FONT1,FS_BOLD);
      $line = new LinePlot($ydata);
      $graph-&amp;gt;Add($line);
      $line-&amp;gt;SetColor(&quot;#36393D&quot;);
      $line-&amp;gt;SetWeight(2);
      $graph-&amp;gt;xaxis-&amp;gt;setTickLabels($xdata);
&nbsp;
      // Output graph
      $graph-&amp;gt;Stroke();
&nbsp;
      return sfView::NONE; // Important pour que l'</span>action retourne que le code de l<span style="color: #0000ff;">'image
    }</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.lexik.fr/blog/symfony/non-classe/stofcplugin-faire-de-bien-jolis-graphiques-avec-symfony-692/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Lexik @ Symfony Live</title>
		<link>http://www.lexik.fr/blog/symfony/non-classe/lexik-symfony-live-681</link>
		<comments>http://www.lexik.fr/blog/symfony/non-classe/lexik-symfony-live-681#comments</comments>
		<pubDate>Wed, 03 Jun 2009 09:04:02 +0000</pubDate>
		<dc:creator>Samuel Breton</dc:creator>
				<category><![CDATA[Non classé]]></category>
		<category><![CDATA[lexik]]></category>
		<category><![CDATA[live]]></category>
		<category><![CDATA[paris]]></category>
		<category><![CDATA[Symfony]]></category>

		<guid isPermaLink="false">http://www.lexik.fr/sfblog/?p=681</guid>
		<description><![CDATA[Lexik sera présent le 11 et 12 Juin prochain à la conférence Symfony Live à Paris. Un programme qui semble très intéressant est ici : http://www.symfony-live.com/schedule Si vous souhaitez participer aussi ne tardez plus à vous inscrire :  http://www.symfony-live.com/ Vous pourrez retrouver Yoann la bas.]]></description>
			<content:encoded><![CDATA[<p>Lexik sera présent le 11 et 12 Juin prochain à la conférence Symfony Live à Paris.</p>
<p>Un programme qui semble très intéressant est ici : <a href="http://www.symfony-live.com/schedule">http://www.symfony-live.com/schedule</a></p>
<p>Si vous souhaitez participer aussi ne tardez plus à vous inscrire :  <a href="http://www.symfony-live.com/">http://www.symfony-live.com/</a></p>
<p style="text-align: center;"><img class="size-full wp-image-684 alignnone" title="yoann" src="http://www.lexik.fr/blog/symfony/wp-content/uploads/2009/06/yoann.jpg" alt="yoann" width="110" height="137" /><br />
Vous pourrez retrouver Yoann la bas.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lexik.fr/blog/symfony/non-classe/lexik-symfony-live-681/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Stage chez Lexik été 2009</title>
		<link>http://www.lexik.fr/blog/symfony/non-classe/stage-chez-lexik-ete-2009-629</link>
		<comments>http://www.lexik.fr/blog/symfony/non-classe/stage-chez-lexik-ete-2009-629#comments</comments>
		<pubDate>Mon, 04 May 2009 09:10:25 +0000</pubDate>
		<dc:creator>Samuel Breton</dc:creator>
				<category><![CDATA[Non classé]]></category>
		<category><![CDATA[stage]]></category>

		<guid isPermaLink="false">http://www.lexik.fr/sfblog/?p=629</guid>
		<description><![CDATA[Lexik propose 2 stages à Montpellier pour cet été 2009 : Stage Développeur PHP : Compétence : Connaissance de PHP5, POO Profil : Rigoureux, curieux. Mission : Vous integrez notre équipe de développement sur la réalisation de projet Interne : Intranet/Site Internet. Développement avec le Framework Symfony Stage Marketing et gestion site Internet Compétence : [...]]]></description>
			<content:encoded><![CDATA[<p>Lexik propose 2 stages à Montpellier pour cet été 2009 :</p>
<p><strong>Stage Développeur PHP :</strong></p>
<p>Compétence : Connaissance de PHP5, POO<br />
  Profil : Rigoureux, curieux.<br />
Mission : Vous integrez notre équipe de développement sur la réalisation de projet Interne : Intranet/Site Internet.<br />
Développement avec le Framework Symfony</p>
<p><strong>Stage Marketing et gestion site Internet</strong></p>
<p>Compétence : Connaissance d&#8217;Internet, bureautique<br />
Profil : Appliqué, bonne rédaction<br />
Mission : Vous travaillerez sur la visibilité des projets mis en ligne ainsi que sur les actions marketing et le référencement.</p>
<p align="center">Envoyez CV : contact@lexik.fr</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lexik.fr/blog/symfony/non-classe/stage-chez-lexik-ete-2009-629/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
