<?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>Drupal Blog</title>
	<atom:link href="http://juliendubois.fr/drupal_blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://juliendubois.fr/drupal_blog</link>
	<description>Pérégrinations en terres Drupaliennes</description>
	<lastBuildDate>Mon, 09 Aug 2010 11:13:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Ajouter une étape de confirmation à vos formulaires</title>
		<link>http://juliendubois.fr/drupal_blog/ajouter-une-etape-de-confirmation-a-vos-formulaires/</link>
		<comments>http://juliendubois.fr/drupal_blog/ajouter-une-etape-de-confirmation-a-vos-formulaires/#comments</comments>
		<pubDate>Mon, 09 Aug 2010 11:09:16 +0000</pubDate>
		<dc:creator>Julien Dubois</dc:creator>
				<category><![CDATA[Drupal 6]]></category>
		<category><![CDATA[Développement]]></category>

		<guid isPermaLink="false">http://juliendubois.fr/drupal_blog/?p=140</guid>
		<description><![CDATA[C&#8217;est une petite fonctionnalité dont vous pourriez avoir besoin, voici une présentation du fonctionnement d&#8217;une telle fonctionnalité. A première vue cela peut sembler très facile à implémenter mais au final ça ne l&#8217;est pas tant que ça. Prenons l&#8217;exemple d&#8217;un formulaire qui permet de clore des votes sur des sessions, cette action étant importante nous [...]]]></description>
			<content:encoded><![CDATA[<p>C&#8217;est une petite fonctionnalité dont vous pourriez avoir besoin, voici une présentation du fonctionnement d&#8217;une telle fonctionnalité.<br />
A première vue cela peut sembler très facile à implémenter mais au final ça ne l&#8217;est pas tant que ça.</p>
<p><a href="http://juliendubois.fr/drupal_blog/wp-content/uploads/2010/08/confirm1.jpg"><img class="aligncenter size-full wp-image-145" title="confirm" src="http://juliendubois.fr/drupal_blog/wp-content/uploads/2010/08/confirm1.jpg" alt="" width="630" height="220" /></a><span id="more-140"></span></p>
<p>Prenons l&#8217;exemple d&#8217;un formulaire qui permet de clore des votes sur des sessions, cette action étant importante nous allons ajouter une étape de confirmation avant de faire le traitement.</p>
<p>Je simplifie volontairement le formulaire que l&#8217;on créé, résumons le à un simple bouton d&#8217;action :</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #009933; font-style: italic;">/**
 * Form to close votes on sessions.
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> feature_conference_close_sessions_form<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span><span style="color: #000088;">$form_state</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
 <span style="color: #000088;">$form</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'submit'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
 <span style="color: #0000ff;">'#type'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'submit'</span><span style="color: #339933;">,</span>
 <span style="color: #0000ff;">'#value'</span> <span style="color: #339933;">=&gt;</span> t<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Clore les votes'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
 <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #b1b100;">return</span> <span style="color: #000088;">$form</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Ensuite dans le traitement de ce formulaire il faut faire une redirection vers le formulaire de confirmation. Aucun traitement ne doit être fait ici sachant que le formulaire n&#8217;a pas encore été confirmé par l&#8217;utilisateur.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #009933; font-style: italic;">/**
 * Redirect to confirmation form.
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> feature_conference_close_sessions_form_submit<span style="color: #009900;">&#40;</span><span style="color: #000088;">$form</span><span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span><span style="color: #000088;">$form_state</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
 <span style="color: #000088;">$form_state</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'redirect'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'sessions/close/confirm'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Sachant que nous faisons une redirection vers une entrée de menu, il faut la déclarer via un hook_menu().</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #009933; font-style: italic;">/**
 * Implement hook_menu().
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> feature_conference_menu<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
 <span style="color: #b1b100;">return</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
 <span style="color: #0000ff;">'sessions/close/confirm'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
 <span style="color: #0000ff;">'page callback'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'drupal_get_form'</span><span style="color: #339933;">,</span>
 <span style="color: #0000ff;">'page arguments'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'feature_conference_close_sessions_confirm_form'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
 <span style="color: #0000ff;">'access callback'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #339933;">,</span>
 <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Dans ce formulaire il vous faut utiliser la fonction confirm_form() (http://api.drupal.org/api/function/confirm_form/6) pour obtenir la page de confirmation.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #009933; font-style: italic;">/**
 * Confirmation form before closing sessions.
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> feature_conference_close_sessions_confirm_form<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span><span style="color: #000088;">$form_state</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
 <span style="color: #000088;">$form</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: #000088;">$desc</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Les votes ne seront plus possibles.&quot;</span><span style="color: #339933;">;</span>
 <span style="color: #b1b100;">return</span> confirm_form<span style="color: #009900;">&#40;</span><span style="color: #000088;">$form</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;Êtes-vous sûr de vouloir clore les votes ?&quot;</span><span style="color: #339933;">,</span>
 <span style="color: #0000ff;">&quot;&lt;front&gt;&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$desc</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Ensuite on retombe dans le fonctionnement classique des formulaires, il suffit de faire le traitement des données dans la fonction de submit du formulaire.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #009933; font-style: italic;">/**
 * Close votes on sessions, send email to rejected contributions' authors
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> feature_conference_close_sessions_confirm_form_submit<span style="color: #009900;">&#40;</span><span style="color: #000088;">$form</span><span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span><span style="color: #000088;">$form_state</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
 <span style="color: #666666; font-style: italic;">// Set a variable to status closed</span>
 variable_set<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'feature_conference_status'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'closed'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 drupal_set_message<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Les votes sur les sessions sont maintenant clos.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 drupal_goto<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&lt;front&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Et nous voilà avec un formulaire de confirmation fonctionnel. Le cas d&#8217;usage est simple, si vous souhaitez faire une action plus avancée comme par exemple clore une session précise, il faut que vous passiez les données dans le formulaire de confirmation via un ou plusieurs arguments à l&#8217;url de traitement car le fait d&#8217;effectuer une redirection entraine la perte des données soumise par le formulaire principal.</p>
]]></content:encoded>
			<wfw:commentRss>http://juliendubois.fr/drupal_blog/ajouter-une-etape-de-confirmation-a-vos-formulaires/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Exposer des critères supplémentaires à Context</title>
		<link>http://juliendubois.fr/drupal_blog/exposer-des-criteres-supplementaires-a-context/</link>
		<comments>http://juliendubois.fr/drupal_blog/exposer-des-criteres-supplementaires-a-context/#comments</comments>
		<pubDate>Tue, 20 Jul 2010 06:30:42 +0000</pubDate>
		<dc:creator>Julien Dubois</dc:creator>
				<category><![CDATA[Drupal 6]]></category>
		<category><![CDATA[Développement]]></category>
		<category><![CDATA[context]]></category>
		<category><![CDATA[development seeds]]></category>
		<category><![CDATA[panels]]></category>
		<category><![CDATA[spaces]]></category>

		<guid isPermaLink="false">http://juliendubois.fr/drupal_blog/?p=122</guid>
		<description><![CDATA[Est-il toujours nécessaire de présenter Context, le module de Development Seed (Grands utilisateurs du célèbre triptyque Panels, Context et Spaces utilisé dans la distribution Open Atrium) ? Oui ? Et bien je vais citer Marie-Hélène qui vous le présente sur Drupalistic Context est une manière pratique et relativement rationnelle de configurer l&#8217;affichage des blocs en [...]]]></description>
			<content:encoded><![CDATA[<p>Est-il toujours nécessaire de présenter <a title="Page projet du module Context sur Drupal.org" href="http://drupal.org/project/context">Context</a>, le module de <a href="http://developmentseed.org/">Development Seed</a> (Grands utilisateurs du célèbre triptyque <a title="Page projet du module Panels sur Drupal.org" href="http://drupal.org/project/panels">Panels</a>, <a title="Page projet du module Context sur Drupal.org" href="http://drupal.org/project/context">Context</a> et <a title="Page projet du module Spaces sur Drupal.org" href="http://drupal.org/project/spaces">Spaces</a> utilisé dans la distribution Open Atrium) ? Oui ? Et bien je vais citer Marie-Hélène qui vous le présente sur <a title="Article sur Context" href="http://www.drupalistic.net/module/context">Drupalistic</a><br />
<span id="more-122"></span></p>
<blockquote><p>Context est une manière pratique et relativement rationnelle de  configurer l&#8217;affichage des blocs en fonction de la &laquo;&nbsp;section&nbsp;&raquo; du site sur  laquelle on se trouve.</p>
<p>Un exemple couramment cité est de définir un <em>context </em>blog,  actif lorsque l&#8217;utilisateur visualise un billet de blog, dans lequel  vont apparaître les blocs &laquo;&nbsp;derniers commentaires&nbsp;&raquo;, ou &laquo;&nbsp;derniers  billets&nbsp;&raquo;, par exemple. Cela évite, lorsque l&#8217;on souhaite modifier  l&#8217;aspect d&#8217;une section, de devoir éditer la configuration de chaque bloc  et la modifier à la main, en risquant d&#8217;oublier un paramètre.</p></blockquote>
<p>Voilà pour la présentation, admettons maintenant que vous vouliez définir votre contexte en vous basant sur un type de contenu définit comme Organic Group de type &laquo;&nbsp;Group post&nbsp;&raquo;. Pour cela vous devez implémenter le hook <strong><em>hook_context_conditions()</em></strong> qui permet d&#8217;ajouter des conditions à remplir pour déterminer le contexte.<br />
Ce hook est assez simple, il doit retourner un ou plusieurs champs de formulaire qui représentent les conditions que vous voulez ajouter. Dans notre exemple, nous exposons les types de contenu définis en tant que &laquo;&nbsp;group post&nbsp;&raquo;.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
 * Implements hook_context_conditions().
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> group_post_expose_context_conditions<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
 <span style="color: #000088;">$items</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: #000088;">$groups</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: #000088;">$types</span> <span style="color: #339933;">=</span> node_get_types<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #666666; font-style: italic;">// Parcourir la liste des types de contenus pour trouver si des types de contenu</span>
 <span style="color: #666666; font-style: italic;">// sont des &quot;group&quot; (lire des &quot;group post&quot;)</span>
 <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$types</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$type</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>variable_get<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'og_content_type_usage_'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$type</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">type</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'omitted'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;group&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
     <span style="color: #000088;">$groups</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$type</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">type</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$type</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">name</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
 <span style="color: #009900;">&#125;</span>
 <span style="color: #666666; font-style: italic;">// Si des types de contenu sont des group post</span>
 <span style="color: #666666; font-style: italic;">// Il suffit de les ajouter à l'entrée de formulaire $items</span>
 <span style="color: #666666; font-style: italic;">// Ce champ est utilisé dans context</span>
 <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$groups</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #000088;">$items</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'group_posts'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
     <span style="color: #0000ff;">'#title'</span> <span style="color: #339933;">=&gt;</span> t<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Group post family'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
     <span style="color: #0000ff;">'#description'</span> <span style="color: #339933;">=&gt;</span> t<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'If the post is displayed as a child of the group (the group is in the url).'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
     <span style="color: #0000ff;">'#type'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'checkboxes'</span><span style="color: #339933;">,</span>
     <span style="color: #0000ff;">'#options'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$groups</span><span style="color: #339933;">,</span>
   <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
 <span style="color: #b1b100;">return</span> <span style="color: #000088;">$items</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<div id="attachment_123" class="wp-caption aligncenter" style="width: 578px"><a href="http://juliendubois.fr/drupal_blog/wp-content/uploads/2010/07/group_post_family.jpg"><img class="size-full wp-image-123" title="group_post_family" src="http://juliendubois.fr/drupal_blog/wp-content/uploads/2010/07/group_post_family.jpg" alt="" width="568" height="382" /></a><p class="wp-caption-text">Aperçu des données exposées</p></div>
<p>Vous pouvez donc définir de nouvelles conditions pour activer votre contexte, mais il manque une étape indispensable pour se faire, il vous faut déterminer le moment où vous donnez la valeur de votre contexte. Par exemple activer le contexte &laquo;&nbsp;concours&nbsp;&raquo; lorsque l&#8217;utilisateur visualise un group post de type &laquo;&nbsp;concours&nbsp;&raquo;.<br />
Pour cela, il vous faut simplement appeler la fonction context_set_by_condition() au bon moment. Cette fonction prends deux paramètres, le premier est la condition à laquelle vous voulez donner une valeur et le second est la valeur de cette condition.<br />
Voici un snippet dans le contexte de notre exemple :</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
* Implements hook_nodeapi().
*/</span>
<span style="color: #000000; font-weight: bold;">function</span> group_post_expose_nodeapi<span style="color: #009900;">&#40;</span><span style="color: #000088;">$node</span><span style="color: #339933;">,</span> <span style="color: #000088;">$op</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">type</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;concours&quot;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$op</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;view&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">// &quot;group_posts&quot; est le nom du champ définit dans le hook_context_conditions()</span>
    <span style="color: #666666; font-style: italic;">// $node-&gt;type représente la valeur à donner à cette condition (ce champ de formulaire) (ici &quot;concours&quot;).</span>
    context_set_by_condition<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'group_posts'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">type</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Et le tour est joué ! Lorsque nous afficherons un noeud de type concours, notre contexte sera actif, libre à vous de l&#8217;utiliser comme bon vous semble, vous pouvez afficher un bloc supplémentaire, cacher une région etc.</p>
<p>Si vous aussi vous avez des astuces à partager sur Context, n&#8217;hésitez pas à les publier dans les commentaires.</p>
]]></content:encoded>
			<wfw:commentRss>http://juliendubois.fr/drupal_blog/exposer-des-criteres-supplementaires-a-context/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Comment créer un profil d&#8217;installation</title>
		<link>http://juliendubois.fr/drupal_blog/creer-un-profil-installation-drupal/</link>
		<comments>http://juliendubois.fr/drupal_blog/creer-un-profil-installation-drupal/#comments</comments>
		<pubDate>Fri, 11 Jun 2010 09:00:31 +0000</pubDate>
		<dc:creator>Julien Dubois</dc:creator>
				<category><![CDATA[Drupal 6]]></category>
		<category><![CDATA[Développement]]></category>
		<category><![CDATA[installation]]></category>
		<category><![CDATA[productivité]]></category>
		<category><![CDATA[profil]]></category>

		<guid isPermaLink="false">http://91.121.95.57/?p=69</guid>
		<description><![CDATA[Plus Drupal mûrit plus on cherche à industrialiser la production de sites. Une des solutions que l&#8217;on propose maintenant courament face à cette demande est l&#8217;utilisation de profils d&#8217;installation. Oui, mais comment fait-on pour les créer ? C&#8217;est très simple, commençons par reprendre l&#8217;arborescence de Drupal. On passe tellement de temps à travailler dans /sites/all/modules [...]]]></description>
			<content:encoded><![CDATA[<p>Plus Drupal mûrit plus on cherche à industrialiser la production de sites. Une des solutions que l&#8217;on propose maintenant courament face à cette demande est l&#8217;utilisation de profils d&#8217;installation.<br />
Oui, mais comment fait-on pour les créer ?<span id="more-69"></span></p>
<p>C&#8217;est très simple, commençons par reprendre l&#8217;arborescence de Drupal. On passe tellement de temps à travailler dans <em><strong>/sites/all/modules</strong></em> que l&#8217;on en oublie parfois qu&#8217;il existe d&#8217;autres répertoires où l&#8217;on peut travailler (mais jamais dans <strong><em>/modules</em></strong> ! Pensez aux chatons).</p>
<p>A la racine du dossier de Drupal il existe un répertoire <em><strong>/profiles</strong></em> qui contient à minima un dossier <em><strong>default</strong></em>. C&#8217;est le profil qui est utilisé à chaque fois que vous faites une installation de base de Drupal 6. Si vous avez la curiosité de regarder le contenu de ce dossier vous allez vous rendre compte qu&#8217;il n&#8217;est pas très volumineux car il ne contient que le fichier <em><strong>default.profile</strong></em>.</p>
<h2>Organisation d&#8217;un profil d&#8217;installation</h2>
<p>Le profil d&#8217;installation est donc composé comme suit :</p>
<ul>
<li><strong><span style="color: #000000;">/profiles/monprofil/monprofil.profile</span></strong></li>
<li>/profiles/monprofil/modules</li>
<li>/profiles/monprofil/themes</li>
<li>/profiles/monprofil/translations</li>
</ul>
<p>Seul <em><strong>monprofil.profile</strong></em> est obligatoire, les dossiers supplémentaires modules, themes et translations sont respectivement présents pour permettre l&#8217;utilisation de modules supplémentaires, de thèmes additionnels ou de langue complémentaires.<br />
L&#8217;intérêt du profil d&#8217;installation est qu&#8217;il est distribuable, c&#8217;est pour cette raison que si vous utilisez des modules autres que ceux du core vous devez les placer au sein d&#8217;un répertoire modules. (Si les modules sont présents dans <em><strong>/sites/*/modules</strong></em> le code fonctionnera mais en terme le logique il est recommandé de placer ces modules dans <em><strong>/profiles/monprofil/modules</strong></em>).<br />
Il en va de même pour les thèmes.</p>
<h2>Et d&#8217;un point de vue code ?</h2>
<p>Dans la plus petite version possible d&#8217;un profil d&#8217;installation (identique à <strong><em>default.profile</em></strong>) il faut à minima déclarer ces fonctions :</p>
<ul>
<li>1) <a href="http://api.drupal.org/api/function/example_profile_modules/6">example_profile_modules()</a> // retourne un tableau des modules à installer</li>
<li>2) <a href="http://api.drupal.org/api/function/example_profile_details/6">example_profile_details()</a> // retourne un tableau avec les détails du profil avec les deux clés <em>name</em> et <em>description</em>)</li>
</ul>
<p>Optionnelles</p>
<ul>
<li>3) <a href="http://api.drupal.org/api/function/example_profile_task_list/6">example_profile_task_list()</a> // Etapes intermédiaires du profil</li>
<li>4) <a href="http://api.drupal.org/api/function/example_profile_tasks/6">example_profile_tasks(&#038;$task, $url)</a> // Execute les dernières taches du profil d&#8217;installation</li>
</ul>
<h3>example_profile_modules()</h3>
<p>Cette fonction est généralement utilisée pour activer les modules de core dont vous allez avoir besoin. Pour activer les modules contribs, on a l&#8217;habitude de créer une étape intermédiaire compte tenu du fait qu&#8217;ils dépendent très souvent des modules de core et qu&#8217;ils sont nombreux (on utilisera l&#8217;API de batch afin de ne pas faire tomber le serveur).</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> MONPROFIL_profile_modules<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'color'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'comment'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'help'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'menu'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'taxonomy'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'dblog'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<h3>example_profile_details()</h3>
<p>Difficile de sélectioner votre profil d&#8217;installation si cette fonction n&#8217;est pas présente car elle indique son petit nom et une description.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> MONPROFIL_profile_details<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
    <span style="color: #0000ff;">'name'</span> <span style="color: #339933;">=&gt;</span> st<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Custom installation profile'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'description'</span> <span style="color: #339933;">=&gt;</span> st<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'This is my first installation profile'</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><span style="text-decoration: underline;">Note :</span> Au sein d&#8217;un profil d&#8217;installation il faut utiliser la fonction st() au lieu de t() pour internationaliser vos chaines de caractères. Les fichiers .po doivent se trouver au sein du dossier <em><strong>/profiles/monprofil/translations</strong></em>.</p>
<h3>example_profile_task_list()</h3>
<p>Si vous créez des étapes intermédiaires dans votre profil il est intéressant d&#8217;indiquer à votre utilisateur sa progression. Ce sont les états que l&#8217;on retrouve à gauche au cours de l&#8217;installation.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> openatrium_profile_task_list<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
 <span style="color: #b1b100;">return</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
  <span style="color: #0000ff;">'intranet-modules-batch'</span> <span style="color: #339933;">=&gt;</span> st<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Install intranet modules'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
  <span style="color: #0000ff;">'intranet-configure-batch'</span> <span style="color: #339933;">=&gt;</span> st<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Configure intranet'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
 <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<h3>example_profile_tasks(&#038;$task,  $url)</h3>
<p>C&#8217;est <strong>la</strong> fonction la plus utile du profil d&#8217;installation car c&#8217;est dans cette dernière que l&#8217;on va faire la configuration des modules, la création de types de contenus, la création de nodes, d&#8217;utilisateurs bref c&#8217;est là que l&#8217;on fait réellement ce qui nous intéresse.<br />
Voici une copie de l&#8217;implémentation de cette fonction dans le profil d&#8217;installation d&#8217;<a href="http://openatrium.com/">Open Atrium</a>, je reviendrai ci-dessous en détails sur les parties importantes.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> openatrium_profile_tasks<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span><span style="color: #000088;">$task</span><span style="color: #339933;">,</span> <span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
 <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$profile</span><span style="color: #339933;">,</span> <span style="color: #000088;">$install_locale</span><span style="color: #339933;">;</span>
&nbsp;
 <span style="color: #666666; font-style: italic;">// Just in case some of the future tasks adds some output</span>
 <span style="color: #000088;">$output</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
&nbsp;
 <span style="color: #666666; font-style: italic;">// Download and install translation if needed</span>
 <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$task</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'profile'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
 <span style="color: #666666; font-style: italic;">// Rebuild the language list.</span>
 <span style="color: #666666; font-style: italic;">// When running through the CLI, the static language list will be empty</span>
 <span style="color: #666666; font-style: italic;">// unless we repopulate it from the ,newly available, database.</span>
 language_list<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'name'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
 <span style="color: #666666; font-style: italic;">// If we reach here, means no language install, move on to the next task</span>
 <span style="color: #000088;">$task</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'intranet-modules'</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
&nbsp;
 <span style="color: #666666; font-style: italic;">// We are running a batch task for this profile so basically do nothing and return page</span>
 <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">in_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$task</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'intranet-modules-batch'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'intranet-translation-batch'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'intranet-configure-batch'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
 <span style="color: #b1b100;">include_once</span> <span style="color: #0000ff;">'includes/batch.inc'</span><span style="color: #339933;">;</span>
 <span style="color: #000088;">$output</span> <span style="color: #339933;">=</span> _batch_page<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;">// Run additional configuration tasks</span>
 <span style="color: #666666; font-style: italic;">// @todo Review all the cache/rebuild options at the end, some of them may not be needed</span>
 <span style="color: #666666; font-style: italic;">// @todo Review for localization, the time zone cannot be set that way either</span>
 <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$task</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'intranet-configure'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
 <span style="color: #000088;">$batch</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> st<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Configuring @drupal'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'@drupal'</span> <span style="color: #339933;">=&gt;</span> drupal_install_profile_name<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: #339933;">;</span>
 <span style="color: #000088;">$batch</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'operations'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'_openatrium_intranet_configure'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #000088;">$batch</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'operations'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'_openatrium_intranet_configure_check'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #000088;">$batch</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'finished'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'_openatrium_intranet_configure_finished'</span><span style="color: #339933;">;</span>
 variable_set<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'install_task'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'intranet-configure-batch'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 batch_set<span style="color: #009900;">&#40;</span><span style="color: #000088;">$batch</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 batch_process<span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #339933;">,</span> <span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #666666; font-style: italic;">// Jut for cli installs. We'll never reach here on interactive installs.</span>
 <span style="color: #b1b100;">return</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>  
&nbsp;
 <span style="color: #b1b100;">return</span> <span style="color: #000088;">$output</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Premier point important, le déroulé des étapes :</p>
<ol>
<li>profile</li>
<li>intranet-modules</li>
<li>intranet-modules-batch</li>
<li>intranet-configure</li>
<li>intranet-configure-batch</li>
<li>profile-finished</li>
</ol>
<p>La première étape d&#8217;un profil d&#8217;installation à partir de laquelle l&#8217;installeur vous donne la main est toujours &laquo;&nbsp;profile&nbsp;&raquo; et vous devez avoir comme dernière étape &laquo;&nbsp;profile-finished&nbsp;&raquo; pour rendre la main à l&#8217;installeur. Vous ne pouvez donc pas intervenir sur ce qui se passe avant et après !</p>
<p>Votre profil d&#8217;installation va donc passer autant de fois que nécessaire dans la fonction <strong>hook_profile_tasks()</strong>, les seuls conditions nécessaires pour que la répétition cesse sont :</p>
<ul class="checklist">
<li>Vous donnez la valeur &laquo;&nbsp;profile-finished&nbsp;&raquo; à la variable $task</li>
<li>Vous ne changez pas la valeur de la variable $task</li>
</ul>
<p>Pour passer d&#8217;une étape à une autre vous devez changer la valeur de $task. Si vous affichez un formulaire ou exécutez une action en batch vous allez devoir utiliser <strong>variable_set(&#8216;install_task&#8217;, &#8216;valeur-tache&#8217;);</strong> pour stocker l&#8217;étape dans laquelle vous êtes.</p>
<p>On voit également dans le profil d&#8217;installation d&#8217;Open Atrium comment gérer une opération en batch, c&#8217;est une action en deux étapes, la première consiste à créer le batch, définir la(es) opération(s), la fonction à exécuter à la fin du batch et toutes les variables propres aux batchs (cf <a href="http://api.drupal.org/api/group/batch/6">Batch API</a> pour plus d&#8217;informations) et la seconde lance le traitement du batch<strong> _batch_page();</strong> . Difficile à inventer si on ne l&#8217;a jamais vu <img src='http://juliendubois.fr/drupal_blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> .</p>
<p>Je vais terminer avec un snippet pour afficher un formulaire comme étape du profil d&#8217;installation, c&#8217;est là aussi une opération particulière car il faut faire deux choses, il faut d&#8217;abord bloquer la redirection du formulaire avec <strong>$form['#redirect'] = FALSE;</strong> et ensuite préciser vers quelle url soumettre le formulaire grâce à <strong>$form['#action'] = $url;</strong> (en pensant à passer $url comme paramètre supplémentaire à votre formulaire) pour que votre formulaire permette la poursuite de l&#8217;exécution du profil.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Extract of the hook_profile_tasks</span>
 <span style="color: #666666; font-style: italic;">// Define extra actions if the development environment is enabled</span>
 <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$task</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'development-environment'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$output</span> <span style="color: #339933;">=</span> drupal_get_form<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'custom_profile_dev_form'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>variable_get<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'developement_environment_checked'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   drupal_set_title<span style="color: #009900;">&#40;</span>st<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Select the environment you want to setup'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">return</span> <span style="color: #000088;">$output</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;">$setup_dev_env</span> <span style="color: #339933;">=</span> variable_get<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'setup_dev_env'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   variable_del<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'developement_environment_checked'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   variable_del<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'setup_dev_env'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #666666; font-style: italic;">// Setup the environment dev if checked</span>
   <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$setup_dev_env</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$task</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'setup-dev-env'</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;">$task</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'install-extra-modules'</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
 <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// --</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Custom form</span>
<span style="color: #000000; font-weight: bold;">function</span> custom_profile_dev_form<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span><span style="color: #000088;">$form_state</span><span style="color: #339933;">,</span> <span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
 <span style="color: #000088;">$form</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: #000088;">$form</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'#redirect'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
 <span style="color: #000088;">$form</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'#action'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$url</span><span style="color: #339933;">;</span>
 <span style="color: #000088;">$form</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'development_environment'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
 <span style="color: #0000ff;">'#title'</span> <span style="color: #339933;">=&gt;</span> st<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Enable development environment'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
 <span style="color: #0000ff;">'#type'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'radios'</span><span style="color: #339933;">,</span>
 <span style="color: #0000ff;">'#options'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'No'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Yes'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
 <span style="color: #0000ff;">'#default_value'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span>
 <span style="color: #0000ff;">'#required'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #339933;">,</span>
 <span style="color: #0000ff;">'#description'</span> <span style="color: #339933;">=&gt;</span> st<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'This will install modules like Devel and create dummy content.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
 <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #000088;">$form</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'submit'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
 <span style="color: #0000ff;">'#type'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'submit'</span><span style="color: #339933;">,</span>
 <span style="color: #0000ff;">'#value'</span> <span style="color: #339933;">=&gt;</span> st<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Confirm'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
 <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #b1b100;">return</span> <span style="color: #000088;">$form</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Voilà qui termine un assez long article sur les profils d&#8217;installation, n&#8217;hésitez pas à partager vos astuces et à poser vos questions dans les commentaires.</p>
]]></content:encoded>
			<wfw:commentRss>http://juliendubois.fr/drupal_blog/creer-un-profil-installation-drupal/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Rediriger un utilisateur après avoir créé un noeud</title>
		<link>http://juliendubois.fr/drupal_blog/rediriger-un-utilisateur-apres-avoir-cree-un-noeud/</link>
		<comments>http://juliendubois.fr/drupal_blog/rediriger-un-utilisateur-apres-avoir-cree-un-noeud/#comments</comments>
		<pubDate>Wed, 09 Jun 2010 23:04:21 +0000</pubDate>
		<dc:creator>Julien Dubois</dc:creator>
				<category><![CDATA[Drupal 6]]></category>
		<category><![CDATA[Développement]]></category>

		<guid isPermaLink="false">http://juliendubois.fr/drupal_blog/?p=94</guid>
		<description><![CDATA[Super le nouvel article avec un sondage lité est bouclé, il ne reste plus qu&#8217;à créer ce sondage. Purée qu&#8217;est ce que c&#8217;est coûteux en clics d&#8217;aller ensuite  sur cette page de création de sondages&#8230; J&#8217;aimerais bien que mon équipe de production fasse en sorte que je sois redirigé directement vers la création de sondage [...]]]></description>
			<content:encoded><![CDATA[<p>Super le nouvel article avec un sondage lité est bouclé, il ne reste plus qu&#8217;à créer ce sondage. Purée qu&#8217;est ce que c&#8217;est coûteux en clics d&#8217;aller ensuite  sur cette page de création de sondages&#8230; J&#8217;aimerais bien que mon équipe de production fasse en sorte que je sois redirigé directement vers la création de sondage après avoir créé mes articles.</p>
<p>Vos désirs sont des ordres ! Petit tour de magie très simple pour accomplir une telle action.</p>
<p><a href="http://juliendubois.fr/drupal_blog/wp-content/uploads/2010/06/direction.jpg"><img class="aligncenter size-full wp-image-96" title="Quelle direction ?" src="http://juliendubois.fr/drupal_blog/wp-content/uploads/2010/06/direction.jpg" alt="" width="630" height="211" /></a></p>
<p><span id="more-94"></span>Dans un premier temps il nous faut ajouter une fonction de traitement à la soumission du formulaire de création de node.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
 * Implementation of hook_form_alter().
 * Ajouter une fonction qui redirige l'utilisateur automatiquement
 * vers le formulaire de création de contenu d'un autre type mon utilisateur
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> MONMODULE_form_alter<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span><span style="color: #000088;">$form</span><span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span><span style="color: #000088;">$form_state</span><span style="color: #339933;">,</span> <span style="color: #000088;">$form_id</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
 <span style="color: #666666; font-style: italic;">// Ajouter notre fonction si le formulaire est un formulaire</span>
 <span style="color: #666666; font-style: italic;">// de création de noeud et si le type de contenu créé est un article</span>
 <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$form</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;#id&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'node-form'</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> <span style="color: #000088;">$form</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;type&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;#value&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;story&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$form</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;#submit&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'MONMODULE_create_submit'</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Notre fonction est créée, il ne reste plus qu&#8217;à lui faire faire la redirection.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
 *  Rediriger vers le formulaire de création de sondages
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> MONMODULE_create_submit<span style="color: #009900;">&#40;</span><span style="color: #000088;">$form</span><span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span><span style="color: #000088;">$form_state</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
 <span style="color: #000088;">$_REQUEST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'destination'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'node/add/webform'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Et le tour est joué ! C&#8217;est aussi simple que ça.<br />
Un peu d&#8217;explications, pour faire une redirection depuis un formulaire il existe plusieurs méthodes.</p>
<h3>drupal_goto()</h3>
<p>Cette fonction permet de faire des redirection depuis Drupal vers des URLs interne ou externe et en passant une série de paramètres. Le seule détail qui fâche c&#8217;est que drupal_goto() stoppe complètement l&#8217;exécution  du script en effectuant la redirection. Si un traitement devait se faire  après l&#8217;exécution de votre fonction vous pouvez faire une croix dessus.</p>
<h3>$form['#redirect']</h3>
<p>Cette méthode permet d&#8217;ajouter une redirection après le traitement du formulaire, cette technique peut être utilisée à la création du formulaire ou depuis un hook_form_alter(). Si vous ne pouvez travailler que dans une fonction supplémentaire au moment de la soumission du formulaire cette technique ne peut être employée.</p>
<h3>$form_state['redirect']</h3>
<p>Cette fois si vous ne pouvez travailler que dans une fonction supplémentaire à la soumission du formulaire cette technique fonctionne, vous écrasez  la valeur définie dans $form['#redirect'] pour renvoyer l&#8217;utilisateur là où vous l&#8217;avez décidez à la fin du traitement de votre fonction. Cette technique ne fonctionne en revanche pas lorsque le formulaire que vous modifiez est le formulaire de création de noeud.</p>
<h3>$_REQUEST['destination']</h3>
<p>Pourquoi devoir employer cette méthode ? Il faut savoir qu&#8217;à la création d&#8217;un noeud la dernière fonction appelée est toujours node_form_submit(). Cette fonction fixe la valeur de $form_state['redirect'] à node/NID pour rediriger l&#8217;utilisateur vers le noeud qui vient d&#8217;être créé. La seule façon propre de détourner cette action est donc de recourir à $_REQUEST qui est l&#8217;unique option de passer outre les valeurs définies dans $form et $form_state.</p>
]]></content:encoded>
			<wfw:commentRss>http://juliendubois.fr/drupal_blog/rediriger-un-utilisateur-apres-avoir-cree-un-noeud/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Créer des templates (fichier.tpl.php) pour themer vos modules</title>
		<link>http://juliendubois.fr/drupal_blog/creer-des-templates-fichier-tpl-php-pour-themer-vos-modules/</link>
		<comments>http://juliendubois.fr/drupal_blog/creer-des-templates-fichier-tpl-php-pour-themer-vos-modules/#comments</comments>
		<pubDate>Mon, 04 Jan 2010 09:10:56 +0000</pubDate>
		<dc:creator>Julien Dubois</dc:creator>
				<category><![CDATA[Drupal]]></category>
		<category><![CDATA[Développement]]></category>
		<category><![CDATA[Theming]]></category>
		<category><![CDATA[hook]]></category>
		<category><![CDATA[module]]></category>
		<category><![CDATA[theme]]></category>

		<guid isPermaLink="false">http://juliendubois.fr/drupal_blog/?p=63</guid>
		<description><![CDATA[Lors de la création de vos modules vous pouvez être amenés à mettre en forme votre contenu pour garder une approche cohérence avec la dissociation fond / forme. Il est donc nécessaire de donner la possibilité au themer de pouvoir modifier la mise en forme du contenu que vous aller afficher. Afin de rendre une [...]]]></description>
			<content:encoded><![CDATA[<p>Lors de la création de vos modules vous pouvez être amenés à mettre en forme votre contenu pour garder une approche cohérence avec la dissociation fond / forme. Il est donc nécessaire de donner la possibilité au themer de pouvoir modifier la mise en forme du contenu que vous aller afficher.<br />
Afin de rendre une telle action possible, vous allez devoir déclarer au sein de votre module un hook_theme, qui va déclarer les éléments qui pourront être themés via vos templates.<span id="more-63"></span><br />
Le <strong>hook_theme</strong> est simplement constitué d&#8217;un tableau d&#8217;éléments skinnables avec pour chaque entrée une clé &laquo;&nbsp;template&nbsp;&raquo; qui correspond au nom du fichier .tpl.php utilisé pour le theme et une clé &laquo;&nbsp;arguments&nbsp;&raquo; correspondant à un tableau de paramètres à passer à la fonction de theme().</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> hook_theme<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
    <span style="color: #0000ff;">'my_themeable_call'</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
      <span style="color: #0000ff;">'template'</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">'gabarit.tpl.php'</span><span style="color: #339933;">,</span>
      <span style="color: #0000ff;">'arguments'</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;param1&quot;</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
    <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><strong>A noter :</strong> Le &laquo;&nbsp;.tpl.php&nbsp;&raquo; est facultatif car toujours suggéré par le moteur de template et il est recommandé d&#8217;utiliser le même nom comme clé et comme nom de fichier pour le template. (Les noms sont ici différents pour vous permettre de décortiquer la mécanique). <em>[Merci Cyril pour la remarque]</em></p>
<p>Voilà votre fonction de thème déclarée, il ne reste plus qu&#8217;à l&#8217;utiliser.<br />
Prenons l&#8217;exemple d&#8217;un bloc, vous souhaitez utiliser votre fonction de thème dans son contenu, il vous suffit d&#8217;utiliser dans le contenu du bloc (cf <a title="Document drupal 6 hook block" href="http://api.drupal.org/api/function/hook_block/6">hook_block</a>) votre fonction de theme : <strong>$bloc['content'] = theme(&#8216;my_themeable_call&#8217;, $param1);</strong><br />
De cette façon vous enverrez à votre fichier de template la variable <strong>$param1</strong> (pouvant contenir tout type de données). Si vous omettez de passer un argument, la valeur par défaut déclarée dans le <strong>hook_theme</strong> sera utilisée (dans notre exemple si j&#8217;omets <strong>$param1</strong>, sa valeur sera <em>NULL</em>).</p>
<p>Plaçons-nous maintenant dans notre fichier de template <strong>gabarit.tpl.php,</strong> c&#8217;est le fichier que votre themer pourra surcharger en le copiant collant dans le dossier de son thème.<br />
Les variables à disposition sont celles que vous avez passé en paramètres lors de l&#8217;appel de la fonction de thème (ici <strong>$param1</strong>) et les éventuelles variables ajoutées par les fonctions de <em>preprocess</em>. (La signature de la fonction est <strong>template_preprocess_my_themeable_call</strong>, surchargeable par <strong>THEME_preprocess_my_themeable_call</strong>).</p>
<p>De cette façon vous pouvez donc créer vos propres fichiers de theming lors de la publication de vos modules afin de vous faire adorer par les themers !</p>
<p><img class="aligncenter size-full wp-image-67" title="tag" src="http://juliendubois.fr/drupal_blog/wp-content/uploads/2010/01/tag.jpg" alt="tag" width="600" height="188" /></p>
]]></content:encoded>
			<wfw:commentRss>http://juliendubois.fr/drupal_blog/creer-des-templates-fichier-tpl-php-pour-themer-vos-modules/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Drupal 7, quoi de neuf à l&#039;horizon ?</title>
		<link>http://juliendubois.fr/drupal_blog/drupal-7-quoi-de-neuf-a-lhorizon/</link>
		<comments>http://juliendubois.fr/drupal_blog/drupal-7-quoi-de-neuf-a-lhorizon/#comments</comments>
		<pubDate>Mon, 30 Nov 2009 12:20:26 +0000</pubDate>
		<dc:creator>Julien Dubois</dc:creator>
				<category><![CDATA[Drupal 7]]></category>

		<guid isPermaLink="false">http://juliendubois.fr/drupal_blog/?p=57</guid>
		<description><![CDATA[Je vous propose de découvrir les principales nouveautés de cette version de Drupal au travers des slides de calibrate que vous pouvez consulter ci-dessous (Anglais). Une synthèse traduite en bon français se trouve à la suite de cette présentation. Drupal 7 &#8211; What&#8217;s new from an end-user perspective ? View more presentations from davyvdb. L&#8217;idée [...]]]></description>
			<content:encoded><![CDATA[<div id="__ss_2530929" style="width: 425px; text-align: left;">Je vous propose de découvrir les principales nouveautés de cette version de Drupal au travers des slides de calibrate que vous pouvez consulter ci-dessous (Anglais).</div>
<div style="width: 425px; text-align: left;">Une synthèse traduite en bon français se trouve à la suite de cette présentation.<span id="more-57"></span></div>
<div style="width: 425px; text-align: left;"><a style="font: 14px Helvetica,Arial,Sans-serif; display: block; margin: 12px 0 3px 0; text-decoration: underline;" title="Drupal 7 - What's new from an end-user perspective ?" href="http://www.slideshare.net/davyvdb/drupal-7-whats-new-from-an-enduser-perspective">Drupal 7 &#8211; What&#8217;s new from an end-user perspective ?</a><object style="margin: 0px;" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="355" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="src" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=drupal7-091118142935-phpapp02&amp;stripped_title=drupal-7-whats-new-from-an-enduser-perspective" /><param name="allowfullscreen" value="true" /><embed style="margin: 0px;" type="application/x-shockwave-flash" width="425" height="355" src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=drupal7-091118142935-phpapp02&amp;stripped_title=drupal-7-whats-new-from-an-enduser-perspective" allowscriptaccess="always" allowfullscreen="true"></embed></object></div>
<div id="__ss_2530929" style="width: 425px; text-align: left;">
<div style="font-size: 11px; font-family: tahoma,arial; height: 26px; padding-top: 2px;">View more <a style="text-decoration: underline;" href="http://www.slideshare.net/">presentations</a> from <a style="text-decoration: underline;" href="http://www.slideshare.net/davyvdb">davyvdb</a>.</div>
</div>
<p>L&#8217;idée pour cette nouvelle version était de se focaliser sur les besoins de la communauté, la réflexion a vraiment placé l&#8217;expérience utilisateur au coeur du process. Tous les besoins ont été remontés au travers d&#8217;un sondage. Il en est ressorti qu&#8217;il fallait améliorer plusieurs choses :</p>
<ul>
<li>Gestion des médias</li>
<li>Intégrer la personnalisation des types de contenu au coeur de Drupal (CCK)</li>
<li>Editeur de texte riche</li>
<li>Meilleures performances</li>
<li>Meilleurs outils pour gérer / structurer le contenu</li>
<li>Une fonctionnalité proche de Views (mais allégé)</li>
<li>Mises à jour automatisées</li>
<li>Amélioration du système d&#8217;accès aux noeuds</li>
<li>Meilleures API internes</li>
<li>Meilleures API externes (import / export, webservices)</li>
<li>Utilisabilité</li>
</ul>
<p>A découlé de ce sondage la mise en place du projet <a href="http://www.d7ux.org/">Drupal 7 UX</a> conduit par Mark Boulton et Lisa Reichelt qui ont permis de structurer et conduire le chantier de l&#8217;<strong>expérience utilisateur</strong> pour cette version.</p>
<p>Un<strong> nouveau thème</strong> est au programme et même deux à vrai dire, &laquo;&nbsp;Seven&nbsp;&raquo; est le digne successeur de Garland (qui tire sa révérance), et &laquo;&nbsp;Stark&nbsp;&raquo; est un thème livré par défaut destiné aux themers,  il est construit  avec le strict minimum, idéal pour démarrer votre nouveau thème.</p>
<p>La <strong>barre d&#8217;administration</strong> devient beaucoup plus <strong>facile à utiliser</strong> car elle migre vers le haut de la page et se voit garnie d&#8217;une barre de raccourcis personnalisable.<br />
Des <strong>liens contextuels</strong> font leur apparition pour effectuer des actions beaucoup plus rapidement.</p>
<p>Majeure évolution, <strong>les onglets verticaux font leur apparition</strong>, adieu la page qui faisait des kilomètres à scroller, tout est segmenté en onglets maintenant et c&#8217;est tant mieux !</p>
<p>Côté insertion de contenu, la gestion des résumés / teaser est améliorée, les formats d&#8217;insertion deviennent les formats de texte (plus cohérent) et l&#8217;utilisation d&#8217;éditeurs de texte riches est facilitée.</p>
<p>L&#8217;administration et la navigation en général ont été réorganisés, la gestion des permissions aura maintenant une description pour comprendre chacune d&#8217;elle (en plus de nom de permissions plus &laquo;&nbsp;user-friendly&nbsp;&raquo;). A noter que le rôle d&#8217;administrateur fait son apparition de façon native.</p>
<p>Grosse amélioration pour les themers, le contenu, l&#8217;aide et le footer deviennent des <strong>blocs</strong> ! Fini la galère pour themer ces parties et pour les placer là où bon vous semble et c&#8217;est d&#8217;ailleurs la gestion du contenu globale qui a été revue, tout est maintenant blocs et vous pouvez beaucoup plus facilement choisir les choses à cacher / monter. La gestion des mises à jour a été repensée, vous pouvez maintenant tout effectuer depuis votre tableau de bord (téléchargement et installation).</p>
<p>La personnalisation des types de contenus est maintenant intégrée dans le coeur de Drupal, c&#8217;est la <strong>Field API</strong> (bye bye CCK). Cela veut dire que vous pouvez personnaliser les types de contenus mais aussi les profils utilisateurs, les tags, tout est champ maintenant !</p>
<p>Concernant la gestion des médias, vous pouvez maintenant <strong>sans installer de module supplémentaire</strong> ajouter des actions sur les images comme le faisait imagecache (miniatures, teinte, etc).</p>
<p>Les contributeurs à la <strong>traduction </strong>n&#8217;ont pas été mis de côté, une des problématiques étant la contextualisation de certains termes qui pouvaient avoir des traductions différentes selon l&#8217;action effectuée sur le site s&#8217;est vu trouver une solution qui consiste à ajouter un <strong>contexte</strong> à toutes les chaines de caractères ! Fini les dilemmes cornéliens. L&#8217;interface de traduction a été améliorée et la gestion des fuseaux horaires également.</p>
<p>RDF est également au programme, ainsi que l&#8217;apparition des tests unitaires pour gagner du temps lors du développement de nouveaux modules  ou de patch pour s&#8217;assurer que rien n&#8217;est cassé. Une nouveau langage de dialogue avec la base de données basé sur PDO fait sont apparition, un peu rebutant mais très puissant au final. Le support des PostGreSQL est amélioré et la gestion des transactions, des maitres / esclaves et de SQLite est prise en compte. La connectivité aux webservices est améliorée et la gestion des proxies HTTP ont été revues.</p>
<p>Et tout ça, quand est ce qu&#8217;on pourra le tester ? A cette question <a href="http://buytaert.net/">Dries </a>répond que Drupal sortira quand il sortira. Et quand est ce qu&#8217;il sortira ? Et bien lorsque le nombre de bugs critiques sera égal à 0. (Actuellement il en reste 408).<br />
L&#8217;objectif de Drupal lors des migrations de version est de ne pas casser les données des utilisateurs, le code spécifique peut casser mais pas les données des gens, il y a toujours une façon de migrer leur contenu (plus ou moins simple) mais il existe toujours une façon de mettre à jour une version précédente.</p>
<p>Concernant le portage des modules de la version 6 à la version 7, tous les modules qui comportent le tag #D7CX indiquent qu&#8217;ils ont déjà réfléchis à la façon de faire le portage et que la mise à jour sera faite à la sortie de D7 ou dans le mois suivant au plus tard.</p>
<p>Si vous êtes impatients de tester toutes ces nouveautés vous pouvez d&#8217;ores et déjà <a href="http://ftp.drupal.org/files/projects/drupal-7.x-dev.tar.gz">télécharger la version de développement de Drupal 7</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://juliendubois.fr/drupal_blog/drupal-7-quoi-de-neuf-a-lhorizon/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Récupérer la valeur de l&#8217;autoincrément</title>
		<link>http://juliendubois.fr/drupal_blog/recuperer-la-valeur-de-lautoincrement/</link>
		<comments>http://juliendubois.fr/drupal_blog/recuperer-la-valeur-de-lautoincrement/#comments</comments>
		<pubDate>Fri, 14 Aug 2009 09:56:07 +0000</pubDate>
		<dc:creator>Julien Dubois</dc:creator>
				<category><![CDATA[Drupal]]></category>
		<category><![CDATA[Développement]]></category>
		<category><![CDATA[autoincrement]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[table]]></category>

		<guid isPermaLink="false">http://juliendubois.fr/drupal_blog/?p=49</guid>
		<description><![CDATA[Il peut vous arriver d&#8217;avoir besoin de récupérer la prochaine valeur utilisée par l&#8217;autoincrement au sein de vos applications, hors de question de récupérer la valeur de l&#8217;id, de lui ajouter un, de jouer le sioux en ajoutant une variable qui stockerait quelque part l&#8217;id en essayant de dupliquer l&#8217;autoincrément. Nul besoin de tout cela, [...]]]></description>
			<content:encoded><![CDATA[<p>Il peut vous arriver d&#8217;avoir besoin de récupérer la prochaine valeur utilisée par l&#8217;autoincrement au sein de vos applications, hors de question de récupérer la valeur de l&#8217;id, de lui ajouter un, de jouer le sioux en ajoutant une variable qui stockerait quelque part l&#8217;id en essayant de dupliquer l&#8217;autoincrément. Nul besoin de tout cela, MySQL peut nous retourner cette valeur comme un grand garçon !<span id="more-49"></span></p>
<p>Pour cela, il suffit d&#8217;utiliser la requête suivante :</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"> <span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> db_query<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SHOW TABLE STATUS LIKE '{node}'&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>En remplaçant bien sûr {node} par le nom de votre table. Notez que les accolades sont propres à drupal, cela permet d&#8217;ajouter le préfix spécifié par l&#8217;utilisateur dans la configuration de la base de données au moment de l&#8217;installation.</p>
<p>Cette requête vous retourne un tableau différentes informations sur la table. Je vous invite à <a title="Document MySQL pour la commade SHOW TABLE STATUS" href="http://www.mysql.be/doc/refman/5.0/fr/show-table-status.html">consulter la documentation de SHOW TABLE STATUS</a> pour connaître les champs retournés.<br />
Il ne vous reste plus qu&#8217;à stocker votre valeur dans une variable pour en faire ce que bon vous semble.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$row</span> <span style="color: #339933;">=</span> db_fetch_array<span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$next_id</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Auto_increment'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span></pre></div></div>

<p>En espérant que ça servira à certains d&#8217;entre vous.</p>
]]></content:encoded>
			<wfw:commentRss>http://juliendubois.fr/drupal_blog/recuperer-la-valeur-de-lautoincrement/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Récupérer le chemin d&#8217;un module ou d&#8217;un thème</title>
		<link>http://juliendubois.fr/drupal_blog/recuperer-le-chemin-dun-module-ou-dun-theme/</link>
		<comments>http://juliendubois.fr/drupal_blog/recuperer-le-chemin-dun-module-ou-dun-theme/#comments</comments>
		<pubDate>Thu, 09 Jul 2009 15:31:00 +0000</pubDate>
		<dc:creator>Julien Dubois</dc:creator>
				<category><![CDATA[Drupal 6]]></category>
		<category><![CDATA[chemin]]></category>
		<category><![CDATA[module]]></category>
		<category><![CDATA[theme]]></category>

		<guid isPermaLink="false">http://juliendubois.fr/drupal_blog/?p=47</guid>
		<description><![CDATA[Que vous développiez votre module ou que vous soyiez en plein templating, vous serez amené à recupérer le chemin de votre module ou de votre thème. Il existe plusieurs fonction pour vous aider dans votre tache, nous allons les passer en revue. path_to_theme() Cette fonction revoit le chemin courant, si vous êtes dans votre thème [...]]]></description>
			<content:encoded><![CDATA[<p>Que vous développiez votre module ou que vous soyiez en plein templating, vous serez amené à recupérer le chemin de votre module ou de votre thème.</p>
<p>Il existe plusieurs fonction pour vous aider dans votre tache, nous allons les passer en revue.<span id="more-47"></span></p>
<p style="padding-left: 30px;"><strong>path_to_theme()</strong></p>
<p>Cette fonction revoit le chemin courant, si vous êtes dans votre thème (sites/all/themes/montheme) ou si vous êtes dans votre module (sites/all/modules/monmodule/monmodule.module).</p>
<p style="padding-left: 30px;"><strong>drupal_get_path($type, $name)</strong></p>
<p>Cette fonction va vous permettre de récupérer le chemin de n&#8217;importe quel élément (thème ou module)  et ce qu&#8217;importe le fichier dans lequel vous travailler, plutôt pratique ! Il s&#8217;utilise de la façon suivante :</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Récupération du chemin vers un module</span>
drupal_get_path<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;module&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;views&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Récupération du chemin vers un thème</span>
drupal_get_path<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;theme&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;montheme&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>L&#8217;utilisation de ces deux fonctions vous permet de naviguer dans votre arborescence.</p>
<p>Documentation :</p>
<ul>
<li><a href="http://api.drupal.org/api/function/drupal_get_path">Fonction drupal_get_path()</a></li>
<li><a href="http://api.drupal.org/api/function/path_to_theme">Fonction path_to_theme()</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://juliendubois.fr/drupal_blog/recuperer-le-chemin-dun-module-ou-dun-theme/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Comment activer l&#8217;upload de fichier via FCKeditor ?</title>
		<link>http://juliendubois.fr/drupal_blog/comment-activer-lupload-de-fichier-via-fckeditor/</link>
		<comments>http://juliendubois.fr/drupal_blog/comment-activer-lupload-de-fichier-via-fckeditor/#comments</comments>
		<pubDate>Mon, 29 Jun 2009 07:00:44 +0000</pubDate>
		<dc:creator>Julien Dubois</dc:creator>
				<category><![CDATA[Drupal]]></category>
		<category><![CDATA[Drupal 6]]></category>
		<category><![CDATA[fckeditor]]></category>
		<category><![CDATA[upload]]></category>

		<guid isPermaLink="false">http://juliendubois.fr/drupal_blog/?p=31</guid>
		<description><![CDATA[Suite à la demande du client il se peut que vous ayez besoin d&#8217;activer l&#8217;upload de fichier via l&#8217;éditeur de texte riche afin de pouvoir facilement insérer des images dans votre contenu. FCKeditor vous donne la possibilité d&#8217;insérer des fichiers dans vos documents. Pour cela, il faut vous rendre sur la page d&#8217;administration de FCKeditor [...]]]></description>
			<content:encoded><![CDATA[<p>Suite à la demande du client il se peut que vous ayez besoin d&#8217;activer l&#8217;upload de fichier via l&#8217;éditeur de texte riche afin de pouvoir facilement insérer des images dans votre contenu.<br />
FCKeditor vous donne la possibilité d&#8217;insérer des fichiers dans vos documents.<span id="more-31"></span></p>
<p>Pour cela, il faut vous rendre sur la page d&#8217;administration de FCKeditor (<em>Administrer &gt; Configuration du contenu &gt; FCKeditor</em>)</p>
<p>Pour les profils auxquels vous souhaitez donner les droits en upload, cliquer sur <strong>Modifier</strong> et dans la partie <strong>File Browser settings</strong> faire deux choses :</p>
<ul>
<li>Passer l&#8217;option <strong>Allow quick uploads </strong>à true</li>
<li>Sélectionner la méthode d&#8217;upload de fichier via l&#8217;option <strong>File browser type</strong>.
<ul>
<li>Si vous sélectionnez &laquo;&nbsp;Aucun&nbsp;&raquo;, l&#8217;utilisateur aura juste un champ Parcourir pour envoyer son fichier.</li>
<li>Si vous choisissez &laquo;&nbsp;Built-in filebrowser&nbsp;&raquo; vous pourrez utiliser l&#8217;interface de FCKeditor qui permet entre autres de créer des sous-répertoires et de réinsérer des fichiers précédemment uploadés.</li>
</ul>
</li>
</ul>
<p>Après avoir fait cela il se peut que vous rencontriez le message d&#8217;erreur suivant si vous vous jetez sur votre champ de texte pour tester l&#8217;upload :</p>
<p><strong>This connector is disabled. Please check the &laquo;&nbsp;editor/filemanager/connectors/php/config.php&nbsp;&raquo; file.</strong></p>
<p>Pour corriger cette erreur il faut modifier le fichier de configuration de FCKeditor afin d&#8217;indiquer où uploader les fichiers sur votre serveur. Le fichier à modifier est le suivant :<em> &laquo;&nbsp;sites/all/modules/fckeditor/fckeditor/editor/filemanager/connectors/php/config.php&nbsp;&raquo;.</em></p>
<p>Les modifications à y apporter sont très simples, voilà une portion de code :</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Activer l'upload de fichier en passant la valeur à &quot;true&quot;</span>
<span style="color: #000088;">$Config</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Enabled'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span> <span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Indiquez le chemin relatif à votre DocumentRoot pour uploader les fichiers</span>
<span style="color: #000088;">$Config</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'UserFilesPath'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'/files/'</span> <span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Indiquez le même répertoire que $Config['UserFilesPath']</span>
<span style="color: #666666; font-style: italic;">// mais de façon absolue cette fois.</span>
<span style="color: #000088;">$Config</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'UserFilesAbsolutePath'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'/var/www/lequipe/www/files/'</span> <span style="color: #339933;">;</span></pre></div></div>

<p>Si un message d&#8217;erreur apparait lorsque vous tentez d&#8217;uploader un fichier, vérifier le chemin de votre répertoire d&#8217;upload (syntaxe et droits d&#8217;accès).</p>
<p>Après avoir fait cela vous devriez maintenant pouvoir jouir de l&#8217;upload de fichier grâce à votre éditeur de texte riche.</p>
]]></content:encoded>
			<wfw:commentRss>http://juliendubois.fr/drupal_blog/comment-activer-lupload-de-fichier-via-fckeditor/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Comment choisir entre Drupal et les autres CMS ?</title>
		<link>http://juliendubois.fr/drupal_blog/comment-choisir-entre-drupal-et-les-autres-cms/</link>
		<comments>http://juliendubois.fr/drupal_blog/comment-choisir-entre-drupal-et-les-autres-cms/#comments</comments>
		<pubDate>Fri, 26 Jun 2009 06:45:25 +0000</pubDate>
		<dc:creator>Julien Dubois</dc:creator>
				<category><![CDATA[Drupal]]></category>
		<category><![CDATA[cms made simple]]></category>
		<category><![CDATA[ez publish]]></category>
		<category><![CDATA[marketing]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://juliendubois.fr/drupal_blog/?p=33</guid>
		<description><![CDATA[Lors de la phase de lancement d&#8217;un projet, une question est récurrente, pour quelle solution technique opter ? Le chef de projet a assimilé les besoins du client, il a établi les fonctionnalités du site, il ne reste plus qu&#8217;à choisir la technologie à employer. Dans un premier temps il est en général simple de [...]]]></description>
			<content:encoded><![CDATA[<p>Lors de la phase de lancement d&#8217;un projet, une question est récurrente, pour quelle solution technique opter ? Le chef de projet a assimilé les besoins du client, il a établi les fonctionnalités du site, il ne reste plus qu&#8217;à choisir la technologie à employer.</p>
<p>Dans un premier temps il est en général simple de trancher entre CMS et framework, l&#8217;un étant adapté pour de la publication de contenu et l&#8217;autre étant plus adapté pour des besoins très précis, il faut préférer le framework au CMS lorsque la majorité des fonctionnalités du site ne sont pas couvertes par le CMS.<span id="more-33"></span></p>
<p>Mais si l&#8217;on doit se tourner vers un CMS, comment trancher ? Il y a beaucoup de produits sur le marché et quels sont les atouts des uns et des autres.</p>
<p>Je vous propose donc de découvrir une présentation que j&#8217;ai traduis d&#8217;une <a href="http://www.slideshare.net/exove/drupal-vsthe-others">version anglaise</a> (réalisée par la société finlandaise <a href="http://www.exove.fi/">Exove</a>) qui compare quatre CMS : <a href="http://fr.wordpress.com/">WordPress</a>, <a href="http://www.cmsmadesimple.fr">CMS Made Simple</a>, <a href="http://ez.no/fr/">eZ Publish</a> et <a href="http://drupalfr.org">Drupal</a>.<br />
Pour chaque CMS, les principales qualités et les principaux défauts sont listés, un comparatif est fait avec Drupal et une slide résume dans quelle situation préférer tel ou tel CMS à Drupal.</p>
<p>Cette présentation est amenée à évoluer, l&#8217;objectif qui pourrait être utile à Drupal serait d&#8217;élargir aux autres principaux CMS du marché afin d&#8217;en faire découler un tableau comparatif qui pourra être réutilisé par les commerciaux et autres décideurs lors des avant-ventes de vos projets. Cette démarche peut s&#8217;inclure dans <a href="http://groups.drupal.org/node/23626">le chantier marketing du groupe france de Drupal</a>.</p>
<p>Si vous êtes tenté(e) d&#8217;élargir cette présentation foncez publier un commentaire et si le coeur vous en dit, <a href="http://groups.drupal.org/france">rejoignez le groupe france de Drupal</a>.<br />
N&#8217;hésitez pas à vous impliquer ou à impliquer votre société, la communauté a besoin de vous pour grandir.</p>
<p style="text-align: center;"><a href="http://juliendubois.fr/drupal_blog/wp-content/uploads/2009/06/drupal_vs_others.pdf"><img class="size-full wp-image-34 aligncenter" title="Télécharger la présentation" src="http://juliendubois.fr/drupal_blog/wp-content/uploads/2009/06/drupal_vs_others.png" alt="Télécharger la présentation" width="450" height="200" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://juliendubois.fr/drupal_blog/comment-choisir-entre-drupal-et-les-autres-cms/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
