<?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>Grummfy&#039;s project &#187; programmation</title>
	<atom:link href="http://grummfy.be/blog/key/programmation/feed" rel="self" type="application/rss+xml" />
	<link>http://grummfy.be/blog</link>
	<description>Mes projets, mes rêves, mes envies, ...</description>
	<lastBuildDate>Mon, 02 Jan 2012 00:03:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Création de nouveau formulaire facilement avec Zend Form Maker</title>
		<link>http://grummfy.be/blog/381#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://grummfy.be/blog/381#comments</comments>
		<pubDate>Sat, 29 Oct 2011 22:29:52 +0000</pubDate>
		<dc:creator>Grummfy</dc:creator>
				<category><![CDATA[Développement]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[programmation]]></category>
		<category><![CDATA[trucs et astuces]]></category>
		<category><![CDATA[ZF]]></category>

		<guid isPermaLink="false">http://grummfy.be/blog/?p=381</guid>
		<description><![CDATA[La création de formulaire avec zend framework peut être facilitée grâce à un petit développement : Zend Form Maker. Projet disponible sur github. À la base créer pour des besoins scolaires, sarlak a eu la bonne idée de rendre le dev open source sous licence GPL 3.0. Le but du logiciel est de permettre via [...]]]></description>
			<content:encoded><![CDATA[<p>La création de formulaire avec zend framework peut être facilitée grâce à un petit développement : Zend Form Maker. Projet disponible sur github. À la base créer pour des besoins scolaires, sarlak a eu la bonne idée de rendre le dev open source sous licence GPL 3.0.</p>
<p>Le but du logiciel est de permettre via une interface très simple d&#8217;accès, de créer des formulaires et ensuite de forger une classe PHP, basé sur zend framework afin d&#8217;obtenir un formulaire tout frais moulu. Ultra pratique, et ultra simple, et surtout cela fait gagner un temps de dingue!</p>
<p>Pour l&#8217;installer, il vous faut de quoi faire fonctionner zend framework (celui-ci doit être installé). Sous Unix cela donnera ceci :<br />
<code><br />
git clone https://github.com/sarlak/Zend-Form-Maker.git<br />
ln -s pathToYourZFLibrary<br />
chmod 0777 Zend-Form-Maker/public/resources/xml<br />
chmod 0777 Zend-Form-Maker/public/resources/form_made<br />
</code></p>
<p>Bien entendu, à peu de choses près ceci est adaptable sous MS-Windows</p>
<p>Pour créer votre premier formulaire, il vous suffit de vous rendre sur l&#8217;URL adéquate, aller sur &laquo;&nbsp;form list&nbsp;&raquo; et &laquo;&nbsp;Bazinga!&nbsp;&raquo;. Une <a href="http://demo.zfm.matthieudiblasio.ch/" title="démo" target="_blank">démo</a> existe en ligne!</p>
<p>Une petite capture d&#8217;écran :<br />
<a href="http://grummfy.be/blog/381/capture-zend-form-maker-v1-0-mozilla-firefox" rel="attachment wp-att-383"><img src="http://grummfy.be/blog/wp/wp-content/uploads/2011/10/Capture-Zend-Form-Maker-v1.0-Mozilla-Firefox-300x185.png" alt="" title="Capture-Zend Form Maker v1.0" width="300" height="185" class="aligncenter size-medium wp-image-383" /></a></p>
<p>À noter que j&#8217;ai corrigé un ou deux petits trucs qui me dérangeaient, il y a un bout de temps.</p>
<p><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F381&amp;linkname=Cr%C3%A9ation%20de%20nouveau%20formulaire%20facilement%20avec%20Zend%20Form%20Maker" title="Delicious" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_technorati_favorites" href="http://www.addtoany.com/add_to/technorati_favorites?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F381&amp;linkname=Cr%C3%A9ation%20de%20nouveau%20formulaire%20facilement%20avec%20Zend%20Form%20Maker" title="Technorati Favorites" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/technorati.png" width="16" height="16" alt="Technorati Favorites"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F381&amp;linkname=Cr%C3%A9ation%20de%20nouveau%20formulaire%20facilement%20avec%20Zend%20Form%20Maker" title="Twitter" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F381&amp;linkname=Cr%C3%A9ation%20de%20nouveau%20formulaire%20facilement%20avec%20Zend%20Form%20Maker" title="Facebook" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F381&amp;linkname=Cr%C3%A9ation%20de%20nouveau%20formulaire%20facilement%20avec%20Zend%20Form%20Maker" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_button_netvibes_share" href="http://www.addtoany.com/add_to/netvibes_share?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F381&amp;linkname=Cr%C3%A9ation%20de%20nouveau%20formulaire%20facilement%20avec%20Zend%20Form%20Maker" title="Netvibes Share" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/netvibes.png" width="16" height="16" alt="Netvibes Share"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fgrummfy.be%2Fblog%2F381&amp;title=Cr%C3%A9ation%20de%20nouveau%20formulaire%20facilement%20avec%20Zend%20Form%20Maker" id="wpa2a_2"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://grummfy.be/blog/381/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Git, gitolite et mutualisé OVH</title>
		<link>http://grummfy.be/blog/368#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://grummfy.be/blog/368#comments</comments>
		<pubDate>Wed, 10 Aug 2011 21:46:37 +0000</pubDate>
		<dc:creator>Grummfy</dc:creator>
				<category><![CDATA[Développement]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[OVH]]></category>
		<category><![CDATA[programmation]]></category>
		<category><![CDATA[trucs et astuces]]></category>

		<guid isPermaLink="false">http://grummfy.be/blog/?p=368</guid>
		<description><![CDATA[Pouvoir utilisé gitolite sur un hébergement mutualisé OVH.]]></description>
			<content:encoded><![CDATA[<p>Hello,<br />
Sur les mutualisés OVH, la version fournie de git est plus qu’out-of-date : version 1.4.4. Ceci signifie impossibilité d&#8217;installé des outils tels que gitolite ou inferno. Ce billet est l&#8217;occasion d&#8217;un guide pour installer gitolite.</p>
<p>Le guide suivant a été rédigé sur un compte OVH pro, donc avec accès un ssh. En utilisant git 1.7.6 et gitolite 2.0.3. L&#8217;ensemble exécuter sur une machine Linux.</p>
<h2>Téléchargement</h2>
<p>La première étape, consiste a récupérer les différentes archives nécessaires, a savoir git et gitolite.</p>
<p>Pour git, il vous suffit de prendre la dernière version http://git-scm.com/download.</p>
<p>Pour gitolite, il suffit d&#8217;utiliser git!</p>
<pre>git clone https://github.com/sitaramc/gitolite.git</pre>
<h2>Préparation de l&#8217;environnement</h2>
<p>Nous allons installer les exécutables de git dans ~/opt/bin. De ce fait ajoutons le path a l&#8217;utilisateur ssh.<br />
Ouvrir ~/.bash_profile et modifier le path. Pour ce faire ajouter, avant le export :</p>
<pre>PATH=$HOME/opt/bin:$PATH</pre>
<h2>Installation de git</h2>
<p>Uploader votre archive dans un dossier (ici ~/opt/src/). En mode console par ssh, donc sur le serveur, ouvrir l&#8217;archive et compiler les sources.</p>
<pre>tar -xvzf git-1.7.6.tar.gz
cd git-1.7.6
./configure --prefix=$HOME/opt --without-tcltk
make
make install</pre>
<p>Une fois compilé, les exécutables seront présents dans ~/opt/bin. Pour vérifier, que tout est bien en place :</p>
<pre>git --version</pre>
<h2>Gitolite</h2>
<p>Il faut se rendre dans le répertoire du clone du repository. <strong>Tout s&#8217;exécute uniquement sur la machine cliente (donc pas chez ovh)</strong>. Si l&#8217;utilisateur est &laquo;&nbsp;toto&nbsp;&raquo;, l&#8217;host &laquo;&nbsp;tata.com&nbsp;&raquo; et le futur administrateur &laquo;&nbsp;moiadmin&nbsp;&raquo;</p>
<pre>./src/gl-easy-install toto tata.com moiadmin</pre>
<p>Il suffit de faire enter. Dans tous les cas (mise à jour du script compris!), le fait de réexecuter la commande permet de rectifier les erreurs éventuelles. À l&#8217;étape de l&#8217;édition du fichier de configuration, il faut modifier la variable $GIT_PATH pour quelle pointe vers le répertoire contenant notre git. Dans notre cas :</p>
<pre>$GIT_PATH = $ENV{HOME} . "/opt/bin/";</pre>
<h2>Configuration de Gitolite</h2>
<p>La configuration de gitolite est simple et s&#8217;exécute avec &#8230; git! En principe, un répertoire reprenant la config a été créé sur votre home dans ~/gitolite-admin, dans le cas contraire, il vous suffit de faire</p>
<pre>git clone gitolite:gitolite-admin.git</pre>
<p>Pour ajouter des clefs ssh, il suffit de les mettre dans le dossier keys. Pour ce qui est de la config, il vous suffit d&#8217;éditer le fichier gitolite.conf et puis de faire</p>
<pre>git add conf/gitolite.conf
git commit -m 'update config'
git push</pre>
<p>Et c&#8217;est tout!</p>
<p>Sources :<br />
<a href="http://forum.ovh.com/showthread.php?t=71543" target="_blank">http://forum.ovh.com/showthread.php?t=71543</a><br />
<a href="http://blog.lyrixx.info/admin-sys/installer-gitolite-sur-une-machine-debian-5/" target="_blank">http://blog.lyrixx.info/admin-sys/installer-gitolite-sur-une-machine-debian-5/</a><br />
<a href="http://sitaramc.github.com/gitolite/doc/gitolite.rc.html" target="_blank" class="broken_link">http://sitaramc.github.com/gitolite/doc/gitolite.rc.html</a><br />
<a href="http://sitaramc.github.com/gitolite/doc/gitolite.conf.html#_groups" target="_blank" class="broken_link">http://sitaramc.github.com/gitolite/doc/gitolite.conf.html#_groups</a></p>
<p>Pour vos interfaces web, trois solutions correctes :<br />
<a href="http://hjemli.net/git/cgit/" target="_blank">CGit</a><br />
<a href="http://viewgit.sourceforge.net/" target="_blank">View Git</a><br />
<a href="http://projects.ceondo.com/p/indefero/" target="_blank">Indefero</a></p>
]]></content:encoded>
			<wfw:commentRss>http://grummfy.be/blog/368/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SQL : différences entre LEFT JOIN, RIGHT JOIN, etc</title>
		<link>http://grummfy.be/blog/364#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://grummfy.be/blog/364#comments</comments>
		<pubDate>Mon, 07 Mar 2011 12:47:21 +0000</pubDate>
		<dc:creator>Grummfy</dc:creator>
				<category><![CDATA[Réflexion du jour]]></category>
		<category><![CDATA[MySql]]></category>
		<category><![CDATA[programmation]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[trucs et astuces]]></category>

		<guid isPermaLink="false">http://grummfy.be/blog/?p=364</guid>
		<description><![CDATA[J&#8217;ai toujours eu quelques diffuculté a bien visualisé les différence qu&#8217;il y avait entre left join, right join, join, etc lorsque je fait des requêtes SQL. Aujourd&#8217;hui je suis tombé sur un exemple frappant, et je me suis dit que cela pouvait en aider plus d&#8217;un! Comme une image vaux mieux qu&#8217;un long discours, en [...]]]></description>
			<content:encoded><![CDATA[<p>J&#8217;ai toujours eu quelques diffuculté a bien visualisé les différence qu&#8217;il y avait entre left join, right join, join, etc lorsque je fait des requêtes SQL. Aujourd&#8217;hui je suis tombé sur un exemple frappant, et je me suis dit que cela pouvait en aider plus d&#8217;un! Comme une image vaux mieux qu&#8217;un long discours, en voici l&#8217;essence.</p>
<p>L&#8217;exemple suivant se base sur une base de donnée mysql :<br />
<code lang="SQL"><br />
CREATE TABLE IF NOT EXISTS `acl_roles` (<br />
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,<br />
`name` varchar(30) CHARACTER SET utf8 NOT NULL,<br />
`build_on` int(11) unsigned DEFAULT NULL,<br />
PRIMARY KEY (`id`),<br />
KEY `build_on` (`build_on`)<br />
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_bin;</p>
<p>INSERT INTO `acl_roles` (`id`, `name`, `build_on`) VALUES<br />
(1, 'guest', NULL),<br />
(2, 'normal', 1),<br />
(3, 'modo', 2),<br />
(4, 'admin', 3);</p>
<p>ALTER TABLE `acl_roles`  ADD CONSTRAINT FOREIGN KEY (`build_on`) REFERENCES `acl_roles` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;<br />
</code></p>
<p>Nous avons donc une table avec des clefs de référence pour marquer les dépendance entre les roles. En images cela donne ceci :</p>
<table boder="1">
<thead>
<tr>
<th>id</th>
<th>name</th>
<th>build_on</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>guest</td>
<td>NULL</td>
</tr>
<tr>
<td>2</td>
<td>normal</td>
<td>1</td>
</tr>
<tr>
<td>3</td>
<td>modo</td>
<td>2</td>
</tr>
<tr>
<td>4</td>
<td>admin</td>
<td>3</td>
</tr>
</tbody>
</table>
<p>Maintenant regardons le résultats de divers SELECT, le résultat parle de lui-même.</p>
<p>SELECT ar.*, arp.name AS parent_name FROM acl_roles ar, acl_roles arp WHERE arp.id = ar.build_on</p>
<table boder="1">
<thead>
<tr>
<th>id</th>
<th>name</th>
<th>build_on</th>
<th>parent_name</th>
</tr>
</thead>
<tbody>
<tr>
<td align="right">2</td>
<td>normal</td>
<td align="right">1</td>
<td>guest</td>
</tr>
<tr>
<td align="right">3</td>
<td>modo</td>
<td align="right">2</td>
<td>normal</td>
</tr>
<tr>
<td align="right">4</td>
<td>admin</td>
<td align="right">3</td>
<td>modo</td>
</tr>
</tbody>
</table>
<p>SELECT ar.*, arp.name AS parent_name FROM acl_roles ar LEFT JOIN acl_roles arp ON arp.id = ar.build_on</p>
<table boder="1">
<thead>
<tr>
<th>id</th>
<th> name</th>
<th> build_on</th>
<th> parent_name</th>
</tr>
</thead>
<tbody>
<tr>
<td align="right">1</td>
<td>guest</td>
<td align="right"><em>NULL</em></td>
<td><em>NULL</em></td>
</tr>
<tr>
<td align="right">2</td>
<td>normal</td>
<td align="right">1</td>
<td>guest</td>
</tr>
<tr>
<td align="right">3</td>
<td>modo</td>
<td align="right">2</td>
<td>normal</td>
</tr>
<tr>
<td align="right">4</td>
<td>admin</td>
<td align="right">3</td>
<td>modo</td>
</tr>
</tbody>
</table>
<p>SELECT ar.*, arp.name AS parent_name FROM acl_roles ar JOIN acl_roles arp ON arp.id = ar.build_on</p>
<table boder="1">
<thead>
<tr>
<th>id</th>
<th> name</th>
<th> build_on</th>
<th> parent_name</th>
</tr>
</thead>
<tbody>
<tr>
<td align="right">2</td>
<td>normal</td>
<td align="right">1</td>
<td>guest</td>
</tr>
<tr>
<td align="right">3</td>
<td>modo</td>
<td align="right">2</td>
<td>normal</td>
</tr>
<tr>
<td align="right">4</td>
<td>admin</td>
<td align="right">3</td>
<td>modo</td>
</tr>
</tbody>
</table>
<p>SELECT ar.*, arp.name AS parent_name FROM acl_roles ar RIGHT JOIN acl_roles arp ON arp.id = ar.build_on</p>
<table boder="1">
<thead>
<tr>
<th>id</th>
<th> name</th>
<th> build_on</th>
<th> parent_name</th>
</tr>
</thead>
<tbody>
<tr>
<td align="right">2</td>
<td>normal</td>
<td align="right">1</td>
<td>guest</td>
</tr>
<tr>
<td align="right">3</td>
<td>modo</td>
<td align="right">2</td>
<td>normal</td>
</tr>
<tr>
<td align="right">4</td>
<td>admin</td>
<td align="right">3</td>
<td>modo</td>
</tr>
<tr>
<td align="right"><em>NULL</em></td>
<td><em>NULL</em></td>
<td align="right"><em>NULL</em></td>
<td>admin</td>
</tr>
</tbody>
</table>
<p>J&#8217;espère que l&#8217;exemple servira a certain et que cela en aidera plus d&#8217;un!</p>
<p><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F364&amp;linkname=SQL%20%3A%20diff%C3%A9rences%20entre%20LEFT%20JOIN%2C%20RIGHT%20JOIN%2C%20etc" title="Delicious" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_technorati_favorites" href="http://www.addtoany.com/add_to/technorati_favorites?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F364&amp;linkname=SQL%20%3A%20diff%C3%A9rences%20entre%20LEFT%20JOIN%2C%20RIGHT%20JOIN%2C%20etc" title="Technorati Favorites" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/technorati.png" width="16" height="16" alt="Technorati Favorites"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F364&amp;linkname=SQL%20%3A%20diff%C3%A9rences%20entre%20LEFT%20JOIN%2C%20RIGHT%20JOIN%2C%20etc" title="Twitter" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F364&amp;linkname=SQL%20%3A%20diff%C3%A9rences%20entre%20LEFT%20JOIN%2C%20RIGHT%20JOIN%2C%20etc" title="Facebook" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F364&amp;linkname=SQL%20%3A%20diff%C3%A9rences%20entre%20LEFT%20JOIN%2C%20RIGHT%20JOIN%2C%20etc" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_button_netvibes_share" href="http://www.addtoany.com/add_to/netvibes_share?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F364&amp;linkname=SQL%20%3A%20diff%C3%A9rences%20entre%20LEFT%20JOIN%2C%20RIGHT%20JOIN%2C%20etc" title="Netvibes Share" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/netvibes.png" width="16" height="16" alt="Netvibes Share"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fgrummfy.be%2Fblog%2F364&amp;title=SQL%20%3A%20diff%C3%A9rences%20entre%20LEFT%20JOIN%2C%20RIGHT%20JOIN%2C%20etc" id="wpa2a_4"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://grummfy.be/blog/364/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ZF : ACL et ressources multiple</title>
		<link>http://grummfy.be/blog/360#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://grummfy.be/blog/360#comments</comments>
		<pubDate>Wed, 13 Oct 2010 21:19:21 +0000</pubDate>
		<dc:creator>Grummfy</dc:creator>
				<category><![CDATA[Développement]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[programmation]]></category>
		<category><![CDATA[trucs et astuces]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[ZF]]></category>

		<guid isPermaLink="false">http://grummfy.be/blog/?p=360</guid>
		<description><![CDATA[Utiliser les ACL dans Zend Framework en ajoutant le support de ressource multiple via '*'.]]></description>
			<content:encoded><![CDATA[<p>Lorsque l&#8217;on utilise des ACL dans Zend Framework, une chose assez embêtante est de devoir tout mettre en place<sup class='footnote'><a href='#fn-360-1' id='fnref-360-1'>1</a></sup>. Pour ma part, j&#8217;ai par facilité voulu ajouté le support de ressource multiple.</p>
<p>Avant de commencer, il convient de contextualisé les choses, les ACL de ZF pouvant être utilisé de bien des manière.</p>
<p>Dans le cas qui nous intéresse, j&#8217;ai simplement défini ceci :</p>
<ul>
<li>les ressources<sup class='footnote'><a href='#fn-360-2' id='fnref-360-2'>2</a></sup> = module.controller</li>
<li>les privilèges<sup class='footnote'><a href='#fn-360-3' id='fnref-360-3'>3</a></sup> = action</li>
</ul>
<p>Ce que je voulait c&#8217;est pouvoir définir une ressource pour tous les contrôleurs. La syntaxe évidente qu&#8217;il m&#8217;est venu est la suivante : module.*</p>
<p>Dans ma classe qui étend Zend_ACL j&#8217;ai simplement fait ceci :</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> isAllowed<span style="color: #009900;">&#40;</span><span style="color: #000088;">$role</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #000088;">$resource</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #000088;">$privilege</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
    	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">null</span> <span style="color: #339933;">===</span> <span style="color: #000088;">$resource</span><span style="color: #009900;">&#41;</span>
    		<span style="color: #b1b100;">return</span> parent<span style="color: #339933;">::</span><span style="color: #004000;">isAllowed</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$role</span><span style="color: #339933;">,</span> <span style="color: #000088;">$resource</span><span style="color: #339933;">,</span> <span style="color: #000088;">$privilege</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    	<span style="color: #000088;">$resources</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>getResourcesPossibility<span style="color: #009900;">&#40;</span><span style="color: #000088;">$resource</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;">$resources</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$resource</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;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>has<span style="color: #009900;">&#40;</span><span style="color: #000088;">$resource</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> parent<span style="color: #339933;">::</span><span style="color: #004000;">isAllowed</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$role</span><span style="color: #339933;">,</span> <span style="color: #000088;">$resource</span><span style="color: #339933;">,</span> <span style="color: #000088;">$privilege</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
    		<span style="color: #009900;">&#123;</span>
    			<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
    		<span style="color: #009900;">&#125;</span>
    	<span style="color: #009900;">&#125;</span>
    	<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getResourcesPossibility<span style="color: #009900;">&#40;</span><span style="color: #000088;">$resource</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
    	<span style="color: #000088;">$ret</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$resource</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: #009900; font-weight: bold;">null</span> <span style="color: #339933;">!==</span> <span style="color: #000088;">$resource</span><span style="color: #009900;">&#41;</span>
    	<span style="color: #009900;">&#123;</span>
    		<span style="color: #000088;">$resources</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'.'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$resource</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    		<span style="color: #000088;">$cptRessources</span> <span style="color: #339933;">=</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$resources</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;">$cptRessources</span> <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;=</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span>
    		<span style="color: #009900;">&#123;</span>
    			<span style="color: #000088;">$resources</span><span style="color: #009900;">&#91;</span> <span style="color: #000088;">$cptRessources</span> <span style="color: #339933;">-</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'*'</span><span style="color: #339933;">;</span>
    		<span style="color: #009900;">&#125;</span>
    		<span style="color: #000088;">$ret</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">implode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'.'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$resources</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;">$ret</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span></pre></div></div>

<p>Ceci peut bien entendu être enrichi mais permet au moins de profiter de l&#8217;utilisation des ACL dans le menu et sur des aides de vue qui serait éventuellement définie comme expliqué dans la plupart des tutoriaux.</p>
<p>Pour en savoir plus sur les ACL et Zend Framework, je vous renvoi a un très bon <a href="http://julien-pauli.developpez.com/tutoriels/zend-framework/atelier/aclmvc/" target="_blank">article</a>.</p>
<div class='footnotes'>
<div class='footnotedivider'></div>
<ol>
<li id='fn-360-1'>surtout si on utilise l&#8217;aide de vue pour généré un menu (Zend_navigation) <span class='footnotereverse'><a href='#fnref-360-1'>&#8617;</a></span></li>
<li id='fn-360-2'>resource <span class='footnotereverse'><a href='#fnref-360-2'>&#8617;</a></span></li>
<li id='fn-360-3'>privilege <span class='footnotereverse'><a href='#fnref-360-3'>&#8617;</a></span></li>
</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://grummfy.be/blog/360/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ZF : module et autoloader</title>
		<link>http://grummfy.be/blog/343#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://grummfy.be/blog/343#comments</comments>
		<pubDate>Sun, 22 Aug 2010 22:00:55 +0000</pubDate>
		<dc:creator>Grummfy</dc:creator>
				<category><![CDATA[Développement]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[programmation]]></category>
		<category><![CDATA[trucs et astuces]]></category>
		<category><![CDATA[ZF]]></category>

		<guid isPermaLink="false">http://grummfy.be/blog/?p=343</guid>
		<description><![CDATA[Avec Zend Framework, lorsque l&#8217;on travail un projet conséquent il devient vite utile de travailler avec le mécanisme des modules. Celui-ci permet d&#8217;étendre pas mal de chose et surtout une séparation poussée en &#8230; module. Le problème de ce mécanisme1 est qu&#8217;il faut définir le chemin pour le chargement automatique à l&#8217;aide de ceci : [...]]]></description>
			<content:encoded><![CDATA[<p>Avec Zend Framework, lorsque l&#8217;on travail un projet conséquent il devient vite utile de travailler avec le mécanisme des <a href="http://framework.zend.com/manual/fr/zend.controller.modular.html" target="_blank">modules</a>. Celui-ci permet d&#8217;étendre pas mal de chose et surtout une séparation poussée en &#8230; module.</p>
<p>Le problème de ce mécanisme<sup class='footnote'><a href='#fn-343-1' id='fnref-343-1'>1</a></sup> est qu&#8217;il faut définir le chemin pour le chargement automatique à l&#8217;aide de ceci :</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$autoloader</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Application_Module_Autoloader<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
	<span style="color: #0000ff;">'namespace'</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">'SuperModule'</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'basePath'</span>  <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">'path to super module'</span><span style="color: #339933;">,</span>
<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Je vous propose donc de faire une petite amélioration afin que ce chargement soit fait automatiquement.</p>
<p>Avant tout, dans votre configuration (ici en .ini) vous devez au moins avoir ceci de présent :</p>

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;">resources.frontController.moduleDirectory <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> APPLICATION_PATH </span><span style="color: #933;">&quot;/modules&quot;</span>
resources.modules <span style="color: #000066; font-weight:bold;">=</span></pre></div></div>

<p>Ensuite, à la base de chaque dossier module créer un fichier Bootstrap.php<sup class='footnote'><a href='#fn-343-2' id='fnref-343-2'>2</a></sup> :</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>?php
<span style="color: #000000; font-weight: bold;">class</span> SuperModule_Bootstrap <span style="color: #000000; font-weight: bold;">extends</span> Grummfy_Bootstrap<span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span>
<span style="color: #666666; font-style: italic;"># EOF</span></pre></div></div>

<p>Et pour finir créer le fichier<sup class='footnote'><a href='#fn-343-3' id='fnref-343-3'>3</a></sup> library/Grummfy/Bootstrap.php</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>?php
&nbsp;
abstract <span style="color: #000000; font-weight: bold;">class</span> Grummfy_Bootstrap <span style="color: #000000; font-weight: bold;">extends</span> Zend_Application_Bootstrap_Bootstrap
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">function</span> _initAutoload<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$className</span> <span style="color: #339933;">=</span> <span style="color: #990000;">get_class</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$zf_namespace</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'_'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$className</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$reflector</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ReflectionClass<span style="color: #009900;">&#40;</span><span style="color: #000088;">$className</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$autoloader</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Application_Module_Autoloader<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
			<span style="color: #0000ff;">'namespace'</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #000088;">$zf_namespace</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'basePath'</span>  <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #990000;">dirname</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$reflector</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>getFileName<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
		<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$autoloader</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># EOF</span></pre></div></div>

<div class='footnotes'>
<div class='footnotedivider'></div>
<ol>
<li id='fn-343-1'>sauf si j&#8217;ai loupé un truc&#8230; <span class='footnotereverse'><a href='#fnref-343-1'>&#8617;</a></span></li>
<li id='fn-343-2'>ne pas oublier de changer le nom du module &#8230; <span class='footnotereverse'><a href='#fnref-343-2'>&#8617;</a></span></li>
<li id='fn-343-3'>n&#8217;oubliez pas de déclarer le &laquo;&nbsp;namespace&nbsp;&raquo; Grummfy ou bien d&#8217;inclure le fichier <span class='footnotereverse'><a href='#fnref-343-3'>&#8617;</a></span></li>
</ol>
</div>
<p><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F343&amp;linkname=ZF%20%3A%20module%20et%20autoloader" title="Delicious" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_technorati_favorites" href="http://www.addtoany.com/add_to/technorati_favorites?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F343&amp;linkname=ZF%20%3A%20module%20et%20autoloader" title="Technorati Favorites" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/technorati.png" width="16" height="16" alt="Technorati Favorites"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F343&amp;linkname=ZF%20%3A%20module%20et%20autoloader" title="Twitter" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F343&amp;linkname=ZF%20%3A%20module%20et%20autoloader" title="Facebook" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F343&amp;linkname=ZF%20%3A%20module%20et%20autoloader" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_button_netvibes_share" href="http://www.addtoany.com/add_to/netvibes_share?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F343&amp;linkname=ZF%20%3A%20module%20et%20autoloader" title="Netvibes Share" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/netvibes.png" width="16" height="16" alt="Netvibes Share"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fgrummfy.be%2Fblog%2F343&amp;title=ZF%20%3A%20module%20et%20autoloader" id="wpa2a_6"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://grummfy.be/blog/343/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ZF : génération automatique du fichier de navigation et ACL</title>
		<link>http://grummfy.be/blog/333#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://grummfy.be/blog/333#comments</comments>
		<pubDate>Mon, 16 Aug 2010 20:47:14 +0000</pubDate>
		<dc:creator>Grummfy</dc:creator>
				<category><![CDATA[Développement]]></category>
		<category><![CDATA[délire]]></category>
		<category><![CDATA[jouons]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[programmation]]></category>
		<category><![CDATA[trucs et astuces]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[ZF]]></category>

		<guid isPermaLink="false">http://grummfy.be/blog/?p=333</guid>
		<description><![CDATA[Lors de l&#8217;utilisation du mécanisme d&#8217;ACL et de génération de menu dans Zend Framework, il est intéressant de limiter l&#8217;affichage de ce menu en utilisant les ressources et privilèges associer. Pour ma part, j&#8217;utilise un fichier XML pour construire mon menu, mon sitemap, &#8230; 1. Et comme beaucoup je génère mon projet ZF à l&#8217;aide [...]]]></description>
			<content:encoded><![CDATA[<p>Lors de l&#8217;utilisation du mécanisme d&#8217;ACL et de génération de menu dans Zend Framework, il est intéressant de limiter l&#8217;affichage de ce menu en utilisant les ressources et privilèges associer.</p>
<p>Pour ma part, j&#8217;utilise un fichier XML pour construire mon menu, mon sitemap, &#8230; <sup class='footnote'><a href='#fn-333-1' id='fnref-333-1'>1</a></sup>. Et comme beaucoup je génère mon projet ZF à l&#8217;aide de Zend_Tool. Je trouvais donc dommage de devoir réécrire pratiquement la même chose que ce que j&#8217;avais déclaré dans Zend_Tool pour reconstruire mon menu. J&#8217;ai donc décidé de <em>rapidement</em> écrire un petit script qui reprendrait le fichier XML du projet et le transformerait en menu &#8230;</p>
<p>À noter que le script devrait certainement être amélioré, mais que cela permet un gain de temps considérable &#8230;</p>
<p><a href="http://grummfy.com/download/PlusScript/zfProject2Navigation.phps" target="_blank">Téléchargement</a></p>
<div class='footnotes'>
<div class='footnotedivider'></div>
<ol>
<li id='fn-333-1'>Comme expliquer dans le manuel http://framework.zend.com/manual/fr/zend.navigation.html <span class='footnotereverse'><a href='#fnref-333-1'>&#8617;</a></span></li>
</ol>
</div>
<p><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F333&amp;linkname=ZF%20%3A%20g%C3%A9n%C3%A9ration%20automatique%20du%20fichier%20de%20navigation%20et%20ACL" title="Delicious" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_technorati_favorites" href="http://www.addtoany.com/add_to/technorati_favorites?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F333&amp;linkname=ZF%20%3A%20g%C3%A9n%C3%A9ration%20automatique%20du%20fichier%20de%20navigation%20et%20ACL" title="Technorati Favorites" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/technorati.png" width="16" height="16" alt="Technorati Favorites"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F333&amp;linkname=ZF%20%3A%20g%C3%A9n%C3%A9ration%20automatique%20du%20fichier%20de%20navigation%20et%20ACL" title="Twitter" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F333&amp;linkname=ZF%20%3A%20g%C3%A9n%C3%A9ration%20automatique%20du%20fichier%20de%20navigation%20et%20ACL" title="Facebook" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F333&amp;linkname=ZF%20%3A%20g%C3%A9n%C3%A9ration%20automatique%20du%20fichier%20de%20navigation%20et%20ACL" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_button_netvibes_share" href="http://www.addtoany.com/add_to/netvibes_share?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F333&amp;linkname=ZF%20%3A%20g%C3%A9n%C3%A9ration%20automatique%20du%20fichier%20de%20navigation%20et%20ACL" title="Netvibes Share" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/netvibes.png" width="16" height="16" alt="Netvibes Share"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fgrummfy.be%2Fblog%2F333&amp;title=ZF%20%3A%20g%C3%A9n%C3%A9ration%20automatique%20du%20fichier%20de%20navigation%20et%20ACL" id="wpa2a_8"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://grummfy.be/blog/333/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Android : Tri d&#8217;une ListView tout en gardant les ids</title>
		<link>http://grummfy.be/blog/312#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://grummfy.be/blog/312#comments</comments>
		<pubDate>Sat, 19 Jun 2010 22:50:19 +0000</pubDate>
		<dc:creator>Grummfy</dc:creator>
				<category><![CDATA[Développement]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[programmation]]></category>
		<category><![CDATA[Projet]]></category>
		<category><![CDATA[trucs et astuces]]></category>

		<guid isPermaLink="false">http://grummfy.be/blog/?p=312</guid>
		<description><![CDATA[Menu ListView dans une ListActivity, trié selon un ordre alphabétique. Récupération de l'élément cliqué...]]></description>
			<content:encoded><![CDATA[<p>Durant le développement du projet <a title="Projet B-Box" href="http://code.google.com/p/b-box/" target="_blank">b-box</a> j&#8217;ai rencontré un problème avec mon menu. Ce menu est présent sous forme de ListActivity (comprenant une ListView), était trié selon un ordre alphabétique qui est susceptible de changer puisque l&#8217;application peut-être traduite.</p>
<p>Au début, j&#8217;ai essayé diverses méthodes, mais les id de position étant perdus&#8230; pas moyen de savoir à quoi correspond quoi.</p>
<p>J&#8217;ai donc du trouver <a href="http://forum.frandroid.com/forum/viewtopic.php?id=15727" target="_blank" class="broken_link">une solution</a>, solution que je vous présente.</p>
<h2>But</h2>
<p>Le but est de créer un menu sous forme de liste (ListView) dont chaque élément est cliquable et permet de récupérer l&#8217;id du clic. Cet id servant à lancer une autre Activity, par exemple.</p>
<h2>Exemple</h2>
<p>Tout d&#8217;abord la classe Menu :</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">org.android.bbox</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Comparator</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> <span style="color: #003399;">Menu</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">int</span> id<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> label<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">Menu</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> id, <span style="color: #003399;">String</span> label<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">id</span> <span style="color: #339933;">=</span> id<span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">label</span> <span style="color: #339933;">=</span> label<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> getLabel<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">label</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: #000066; font-weight: bold;">int</span> getId<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">id</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;">static</span> <span style="color: #003399;">Menu</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> factory<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> menus<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #003399;">Menu</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> menu <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Menu</span><span style="color: #009900;">&#91;</span>menus.<span style="color: #006633;">length</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> menus.<span style="color: #006633;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			menu<span style="color: #009900;">&#91;</span> i <span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Menu</span><span style="color: #009900;">&#40;</span>i, menus<span style="color: #009900;">&#91;</span> i <span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">return</span> menu<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;">static</span> <span style="color: #003399;">Comparator</span> getComparator<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Comparator</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			@Override
			<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">int</span> compare<span style="color: #009900;">&#40;</span><span style="color: #003399;">Menu</span> m1, <span style="color: #003399;">Menu</span> m2<span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #000000; font-weight: bold;">return</span> m1.<span style="color: #006633;">getLabel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">compareTo</span><span style="color: #009900;">&#40;</span>m2.<span style="color: #006633;">getLabel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</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: #003399;">String</span> toString<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">getLabel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Et la classe de l&#8217;activité :</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// ...</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onCreate<span style="color: #009900;">&#40;</span>Bundle savedInstanceState<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">//...</span>
		<span style="color: #003399;">Menu</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> m <span style="color: #339933;">=</span> <span style="color: #003399;">Menu</span>.<span style="color: #006633;">factory</span><span style="color: #009900;">&#40;</span>getResources<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getStringArray</span><span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">array</span>.<span style="color: #006633;">main_list_array</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//récupération d'un tableau de string et création d'un tableau de Menu</span>
		ArrayAdapter adapter <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ArrayAdapter<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>, android.<span style="color: #006633;">R</span>.<span style="color: #006633;">layout</span>.<span style="color: #006633;">simple_list_item_1</span>, m<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//création de l'adaptateur permettant l'affichage</span>
		adapter.<span style="color: #006633;">sort</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">Menu</span>.<span style="color: #006633;">getComparator</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: #666666; font-style: italic;">//tri du menu</span>
		<span style="color: #003399;">ListView</span> myList <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">ListView</span><span style="color: #009900;">&#41;</span> findViewById<span style="color: #009900;">&#40;</span>android.<span style="color: #006633;">R</span>.<span style="color: #006633;">id</span>.<span style="color: #006633;">list</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		myList.<span style="color: #006633;">setAdapter</span><span style="color: #009900;">&#40;</span>adapter<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//ajotu du menu à la ListView</span>
		myList.<span style="color: #006633;">setOnItemClickListener</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">//...</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	@Override
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onItemClick<span style="color: #009900;">&#40;</span>AdapterView parent, <span style="color: #003399;">View</span> view, <span style="color: #000066; font-weight: bold;">int</span> position, <span style="color: #000066; font-weight: bold;">long</span> id<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">print</span><span style="color: #009900;">&#40;</span>position<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">print</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot; | &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">print</span><span style="color: #009900;">&#40;</span>parent.<span style="color: #006633;">getItemAtPosition</span><span style="color: #009900;">&#40;</span>position<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">print</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot; | &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">print</span><span style="color: #009900;">&#40;</span>parent.<span style="color: #006633;">getItemAtPosition</span><span style="color: #009900;">&#40;</span>position<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getClass</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: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">print</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot; | &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">print</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">Menu</span><span style="color: #009900;">&#41;</span>parent.<span style="color: #006633;">getItemAtPosition</span><span style="color: #009900;">&#40;</span>position<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getId</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: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">print</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot; | &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>id<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">//...</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #666666; font-style: italic;">// ...</span></pre></div></div>

<p><strong>Remarque</strong> : la méthode toString permet l&#8217;affichage de l&#8217;élément dans la liste.</p>
]]></content:encoded>
			<wfw:commentRss>http://grummfy.be/blog/312/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WebHook Google Code &#8211; recevoir un mail à chaque commit</title>
		<link>http://grummfy.be/blog/310#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://grummfy.be/blog/310#comments</comments>
		<pubDate>Fri, 18 Jun 2010 23:58:59 +0000</pubDate>
		<dc:creator>Grummfy</dc:creator>
				<category><![CDATA[Développement]]></category>
		<category><![CDATA[découverte]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[programmation]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[trucs et astuces]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://grummfy.be/blog/?p=310</guid>
		<description><![CDATA[Google code et webhook : envoyer un email a chaque commit]]></description>
			<content:encoded><![CDATA[<p>Dans Google code il y a la possibilité d&#8217;utiliser un gestionnaire de version tel que subversion (svn) ou mercurial (hg). C&#8217;est bien pratique, mais malheureusement, de base, rien n&#8217;est prévu pour prévenir (excepté par flux RSS) les gens de ces mises à jour. Cependant, Google code permet d&#8217;utiliser un webhook en post commit.</p>
<h2>Qu&#8217;est-ce qu&#8217;un webhook?</h2>
<p>Un webhook c&#8217;est un &laquo;&nbsp;crochet web&nbsp;&raquo;, c&#8217;est-à-dire une URL a appelée après (avant ou pendant) une action X. Dans notre cas, après chaque commit une URL est appelée.</p>
<h2>Utilisation</h2>
<p>Voici un exemple de code que j&#8217;utilise pour plusieurs de mes projets :</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: #666666; font-style: italic;">// project name</span>
<span style="color: #000088;">$projects</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'mon-super-projet'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// google code webhook key</span>
<span style="color: #000088;">$keys</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
	<span style="color: #0000ff;">'b-box'</span>	<span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Top-Secret_key_fourni_par_google-dans-l-adminsitration'</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//user agent from google code</span>
<span style="color: #000088;">$useragent</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Google Code Project Hosting (+http://code.google.com/p/support/wiki/PostCommitWebHooks)'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//email of all owner (eg. project chief)</span>
<span style="color: #000088;">$owners</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'vous@example.com'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//email of all team members except owners</span>
<span style="color: #000088;">$users</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'toi@example.com'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//sender of email</span>
<span style="color: #000088;">$sender</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'WebHook mailer&lt;webmaster@exemple.com&gt;'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//----------------------------------------------------------------------</span>
<span style="color: #000088;">$project</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'p'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>?<span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'p'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">:</span><span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$revision</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'r'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>?<span style="color: #990000;">intval</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'r'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:-</span><span style="color: #cc66cc;">99</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #990000;">file_get_contents</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'php://input'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$digest</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_GOOGLE_CODE_PROJECT_HOSTING_HOOK_HMAC'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>?<span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_GOOGLE_CODE_PROJECT_HOSTING_HOOK_HMAC'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">:</span><span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//----------------------------------------------------------------------</span>
<span style="color: #009933; font-style: italic;">/**
 * Send a mail
 * @param string $from email of the sender : sample@example.com or &quot;name&quot;&lt;sample@example.com&gt;;
 * @param array $to [a] =&gt; list of email [cc], [bcc] (hidden), ...
 * @param string $subject
 * @param string $body
 * @return bool true if success
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> mailer<span style="color: #009900;">&#40;</span><span style="color: #000088;">$from</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span> <span style="color: #000088;">$to</span><span style="color: #339933;">,</span> <span style="color: #000088;">$subject</span><span style="color: #339933;">,</span> <span style="color: #000088;">$body</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: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$to</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000088;">$headers</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'From: '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$from</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$a</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$to</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'a'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> <span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$to</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'a'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$a</span> <span style="color: #339933;">=</span> <span style="color: #990000;">implode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">','</span><span style="color: #339933;">,</span> <span style="color: #000088;">$to</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'a'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$to</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'bcc'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> <span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$to</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'bcc'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$headers</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'Bcc: '</span> <span style="color: #339933;">.</span> <span style="color: #990000;">implode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">','</span><span style="color: #339933;">,</span> <span style="color: #000088;">$to</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'bcc'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$to</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'cc'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> <span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$to</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'cc'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$headers</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'Cc: '</span> <span style="color: #339933;">.</span> <span style="color: #990000;">implode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">','</span><span style="color: #339933;">,</span> <span style="color: #000088;">$to</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'cc'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000088;">$headers</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'MIME-Version: 1.0'</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$headers</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'Content-Type: text/plain; charset=&quot;UTF-8&quot;'</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$headers</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'Content-Transfer-Encoding: 8bit'</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$headers</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'X-Mailer: PHP/'</span> <span style="color: #339933;">.</span> <span style="color: #990000;">phpversion</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> <span style="color: #990000;">mail</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$a</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'[webhook]'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$subject</span><span style="color: #339933;">,</span> <span style="color: #000088;">$body</span><span style="color: #339933;">,</span> <span style="color: #000088;">$headers</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;">function</span> failed<span style="color: #009900;">&#40;</span><span style="color: #000088;">$test_id</span><span style="color: #339933;">,</span> <span style="color: #000088;">$msg</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;">$sender</span><span style="color: #339933;">,</span> <span style="color: #000088;">$owners</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$msg</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>--<span style="color: #000099; font-weight: bold;">\n</span>WebHook mail from the Google code project&quot;</span><span style="color: #339933;">;</span>
&nbsp;
	mailer<span style="color: #009900;">&#40;</span><span style="color: #000088;">$sender</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'bcc'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$owners</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'failed test #'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$test_id</span><span style="color: #339933;">,</span> <span style="color: #000088;">$msg</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'KO'</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;">function</span> get_ip<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: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_X_FORWARDED_FOR'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>?<span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_X_FORWARDED_FOR'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">:</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_CLIENT_IP'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>?<span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_CLIENT_IP'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">:</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REMOTE_ADDR'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//----------------------------------------------------------------------</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$useragent</span> <span style="color: #339933;">!=</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_USER_AGENT'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">// failed 1</span>
	failed<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'User agent is bad : '</span> <span style="color: #339933;">.</span> <span style="color: #990000;">htmlspecialchars</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_USER_AGENT'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>From : &quot;</span> <span style="color: #339933;">.</span> get_ip<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$project</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #339933;">!</span><span style="color: #990000;">in_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$project</span><span style="color: #339933;">,</span> <span style="color: #000088;">$projects</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">// failed 2</span>
	failed<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'No project set : '</span> <span style="color: #339933;">.</span> <span style="color: #990000;">htmlspecialchars</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$project</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>From : &quot;</span> <span style="color: #339933;">.</span> get_ip<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">else</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$hmac</span> <span style="color: #339933;">=</span> <span style="color: #990000;">hash_hmac</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'md5'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$data</span><span style="color: #339933;">,</span> <span style="color: #000088;">$keys</span><span style="color: #009900;">&#91;</span> <span style="color: #000088;">$project</span> <span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #990000;">json_decode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</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: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$digest</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #000088;">$digest</span> <span style="color: #339933;">!=</span> <span style="color: #000088;">$hmac</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// failed 3</span>
		failed<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">3</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Bad digest : '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$digest</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">' vs '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$hmac</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>From : &quot;</span> <span style="color: #339933;">.</span> get_ip<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">intval</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'revision_count'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'revisions'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// failed 4</span>
		failed<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">4</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Bad count : '</span> <span style="color: #339933;">.</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'revisions'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">' vs '</span> <span style="color: #339933;">.</span> <span style="color: #990000;">intval</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'revision_count'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>From : &quot;</span> <span style="color: #339933;">.</span> get_ip<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">else</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$mail_body</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'revisions'</span><span style="color: #009900;">&#93;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$_revision</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$mail_body</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'Revision : '</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span> <span style="color: #339933;">.</span> <span style="color: #990000;">htmlentities</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_revision</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'revision'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">' from '</span> <span style="color: #339933;">.</span> <span style="color: #990000;">htmlentities</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_revision</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'author'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">' at '</span> <span style="color: #339933;">.</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Y-m-d H:i'</span><span style="color: #339933;">,</span> <span style="color: #990000;">intval</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_revision</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'timestamp'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$mail_body</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'Added : '</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span> <span style="color: #339933;">.</span> <span style="color: #990000;">implode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #990000;">htmlentities</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_revision</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'added'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$mail_body</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'Modified : '</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span> <span style="color: #339933;">.</span> <span style="color: #990000;">implode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #990000;">htmlentities</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_revision</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'modified'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$mail_body</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'Removed : '</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span> <span style="color: #339933;">.</span> <span style="color: #990000;">implode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #990000;">htmlentities</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_revision</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'removed'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//			$mail_body .= 'URL : ' . &quot;\t\t&quot; . htmlentities($_revision['url']) . &quot;\n\n&quot;;</span>
			<span style="color: #000088;">$mail_body</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'Message : '</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span> <span style="color: #339933;">.</span> <span style="color: #990000;">htmlentities</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_revision</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'message'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//			$_revision['path_count'];</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000088;">$mail_body</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>--<span style="color: #000099; font-weight: bold;">\n</span>WebHook mail from the Google code project : &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$project</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>http://code.google.com/p/&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$project</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;/<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
&nbsp;
		mailer<span style="color: #009900;">&#40;</span><span style="color: #000088;">$sender</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'bcc'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$owners</span> <span style="color: #339933;">+</span> <span style="color: #000088;">$users</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;">$project</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">']New revision #'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$revision</span><span style="color: #339933;">,</span> <span style="color: #000088;">$mail_body</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #990000;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'OK'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># EOF</span></pre></div></div>

</p>
<p>Plus d&#8217;info : <a href="http://code.google.com/p/support/wiki/PostCommitWebHooks">PostCommitWebHooks</a></p>
]]></content:encoded>
			<wfw:commentRss>http://grummfy.be/blog/310/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Espace de nom PHP et chargement automatique</title>
		<link>http://grummfy.be/blog/285#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://grummfy.be/blog/285#comments</comments>
		<pubDate>Mon, 07 Jun 2010 08:42:44 +0000</pubDate>
		<dc:creator>Grummfy</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[namespace]]></category>
		<category><![CDATA[programmation]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://grummfy.be/blog/?p=285</guid>
		<description><![CDATA[PHP 5.3 ajoute une notion intéressante : les espaces de nom. Voyons voir comment créer un chargeur automatique (ou autoloader) comprenant ceux-ci.]]></description>
			<content:encoded><![CDATA[<p><a href="./zend-framework#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed">PHP</a> 5.3 ajoute une notion intéressante : les espaces de nom (ou namespace en anglais). Les espaces de nom permettent de séparer différents &#8230; &laquo;&nbsp;<em>espace</em>&laquo;&nbsp;, permettant ainsi d&#8217;avoir deux classe portant le même nom. Idéal pour l&#8217;utilisation de framework mais aussi de &laquo;&nbsp;l&#8217;isolation&nbsp;&raquo; de certains composants. Voyons voir comment créer un chargeur automatique (ou autoloader) comprenant les espaces de nom.</p>
<p>Si vous êtes sous Ms Windows, aucun problème un simple <em>spl_autoload_register();</em> suffit. Malheureusement, sous *nix un <a href="http://bugs.php.net/bug.php?id=51991" target="_blank">bug existe</a> il faudra donc implémenté une solution maison.</p>
<h2>Le code</h2>
<p>Ce code provient du &laquo;&nbsp;<a href="http://groups.google.com/group/php-standards/web/psr-0-final-proposal" class="broken_link">PHP  Standards Working Group</a>&nbsp;&raquo; :</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> autoload<span style="color: #009900;">&#40;</span><span style="color: #000088;">$className</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$className</span> <span style="color: #339933;">=</span> <span style="color: #990000;">ltrim</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$className</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;">$fileName</span>  <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$namespace</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$lastNsPos</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strripos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$className</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'\\'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$namespace</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$className</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #000088;">$lastNsPos</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$className</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$className</span><span style="color: #339933;">,</span> <span style="color: #000088;">$lastNsPos</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$fileName</span>  <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'\\'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">DIRECTORY_SEPARATOR</span><span style="color: #339933;">,</span> <span style="color: #000088;">$namespace</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #009900; font-weight: bold;">DIRECTORY_SEPARATOR</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000088;">$fileName</span> <span style="color: #339933;">.=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'_'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">DIRECTORY_SEPARATOR</span><span style="color: #339933;">,</span> <span style="color: #000088;">$className</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'.php'</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">require</span> <span style="color: #000088;">$fileName</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

</p>
<p>Pour l&#8217;utiliser, il faut définir deux choses :</p>
<ol>
<li>Ne pas oublier de modifier l&#8217;include path si nécessaire.</li>
<li>Ajouter cette fonction au chargeur de classes présent.</li>
</ol>
<h2>L&#8217;exemple</h2>
<p>Voici un exemple un peu plus complet.<br />
index.php</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: #990000;">set_include_path</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">get_include_path</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> PATH_SEPARATOR <span style="color: #339933;">.</span> <span style="color: #990000;">dirname</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/lib/'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//on ajoute le dossier lib dans l'include path</span>
<span style="color: #990000;">spl_autoload_register</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;">//sur windows ceci devrait suffire .</span>
<span style="color: #666666; font-style: italic;">//le code pour les autres</span>
<span style="color: #666666; font-style: italic;">//----------------------------------------------------------</span>
<span style="color: #000000; font-weight: bold;">function</span> autoload<span style="color: #009900;">&#40;</span><span style="color: #000088;">$className</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$className</span> <span style="color: #339933;">=</span> <span style="color: #990000;">ltrim</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$className</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;">$fileName</span>  <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$namespace</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$lastNsPos</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strripos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$className</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'\\'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$namespace</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$className</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #000088;">$lastNsPos</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$className</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$className</span><span style="color: #339933;">,</span> <span style="color: #000088;">$lastNsPos</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$fileName</span>  <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'\\'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">DIRECTORY_SEPARATOR</span><span style="color: #339933;">,</span> <span style="color: #000088;">$namespace</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #009900; font-weight: bold;">DIRECTORY_SEPARATOR</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000088;">$fileName</span> <span style="color: #339933;">.=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'_'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">DIRECTORY_SEPARATOR</span><span style="color: #339933;">,</span> <span style="color: #000088;">$className</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'.php'</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">require</span> <span style="color: #000088;">$fileName</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #990000;">spl_autoload_register</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'autoload'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//----------------------------------------------------------</span>
<span style="color: #666666; font-style: italic;">//fin du code de fix</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">use</span> grummfy\test\Test<span style="color: #339933;">;</span>
Test<span style="color: #339933;">::</span><span style="color: #004000;">sayHello</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
\grummfy\std\Test<span style="color: #339933;">::</span><span style="color: #004000;">sayHello</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># EOF</span></pre></div></div>

<p>./lib/grummfy/test/Test.php</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: #000000; font-weight: bold;">namespace</span> grummfy\test<span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//pour rappel ceci doit-être la première instruction php (et on ne doit pas avoir de HTML avant)</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Je suis inclus ('</span> <span style="color: #339933;">.</span> <span style="color: #009900; font-weight: bold;">__FILE__</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">')!'</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">class</span> Test
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> static <span style="color: #000000; font-weight: bold;">function</span> sayHello<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Bonjour depuis '</span> <span style="color: #339933;">.</span> <span style="color: #009900; font-weight: bold;">__CLASS__</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># EOF</span></pre></div></div>

<p>./lib/grummfy/std/Test.php</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: #000000; font-weight: bold;">namespace</span> grummfy\std<span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Je suis inclus ('</span> <span style="color: #339933;">.</span> <span style="color: #009900; font-weight: bold;">__FILE__</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">')!'</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">class</span> Test
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> static <span style="color: #000000; font-weight: bold;">function</span> sayHello<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Bonjour depuis '</span> <span style="color: #339933;">.</span> <span style="color: #009900; font-weight: bold;">__CLASS__</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># EOF</span></pre></div></div>

<p>Le résultat devrait être :<br />
<code><br />
Je suis inclus (/.../lib/grummfy/test/Test.php)!<br />
Bonjour depuis grummfy\test\Test<br />
Je suis inclus (/.../lib/grummfy/std/Test.php)!<br />
Bonjour depuis grummfy\std\Test<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://grummfy.be/blog/285/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wampserver : quick switch xdebug menu</title>
		<link>http://grummfy.be/blog/250#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://grummfy.be/blog/250#comments</comments>
		<pubDate>Wed, 24 Mar 2010 22:22:42 +0000</pubDate>
		<dc:creator>Grummfy</dc:creator>
				<category><![CDATA[Développement]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[deboguage]]></category>
		<category><![CDATA[découverte]]></category>
		<category><![CDATA[jouons]]></category>
		<category><![CDATA[programmation]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[trucs et astuces]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[XDebug]]></category>

		<guid isPermaLink="false">http://grummfy.be/blog/?p=250</guid>
		<description><![CDATA[Activer et désactiver XDebug sur Wampserver à souhait! Ceci via un menu supplémentaire.]]></description>
			<content:encoded><![CDATA[<p>Pour une fois, un article sous Ms Windows. Stage oblige, je passe du temps sous celui-ci (XP <img src='http://grummfy.be/blog/wp/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' />  ). Afin d&#8217;optimiser son travail, il y a parfois des petites choses bien pratiques, telles que ce que je vais vous présenter.</p>
<p>XDebug est un outil merveilleux, parfois capricieux, certes, mais très utile. Il permet, notamment<sup class='footnote'><a href='#fn-250-1' id='fnref-250-1'>1</a></sup> :</p>
<ul>
<li>Affichage de tracé d&#8217;erreur</li>
<li>Meilleures lectures des exceptions</li>
<li>Débogage pas-à-pas</li>
<li>Profiling d&#8217;application</li>
<li>&#8230;</li>
</ul>
<p>Bref, des choses essentielles en développement. Et, contrairement à ce que certains IDE<sup class='footnote'><a href='#fn-250-2' id='fnref-250-2'>2</a></sup> font, il permet surtout de le faire sur un serveur &laquo;&nbsp;réel&nbsp;&raquo;, donc avec une utilisation &laquo;&nbsp;réel&nbsp;&raquo;.</p>
<p>Le but de ce billet n&#8217;est pas de présenter XDebug, d&#8217;autres le font mieux que moi <sup class='footnote'><a href='#fn-250-3' id='fnref-250-3'>3</a></sup>, mais bien de vous présenter un petit script vous permettant d&#8217;activer et désactiver XDebug sur wampserver.</p>
<h2>Installation</h2>
<ol>
<li>Téléchargez le fichier <sup class='footnote'><a href='#fn-250-4' id='fnref-250-4'>4</a></sup> et décompressez-le.</li>
<li>Suivez les instructions d&#8217;installation décrite dans le fichier installe. Il y a seulement 1 fichier à modifier + 1 fichier par version de PHP installée.</li>
<li>Relancer wampserver et tester!</li>
</ol>
<p>Si vous avez des questions, n&#8217;hésitez pas.</p>
<h2>Plus d&#8217;informations</h2>
<ul>
<li><a href="http://blog.pascal-martin.fr/post/xdebug-installation-premiers-pas" target="_blank">Xdebug : Installation et premier pas</a></li>
<li><a href="http://blog.wampserver.com/index.php/2009/08/28/debugger-avec-wampserver-xdebug-et-pdt/" target="_self" class="broken_link">Débugger avec WampServer, Xdebug et PDT</a></li>
<li><a href="http://evoilliot.u7n.org/2010/02/installer-xdebug-avec-xampp/" target="_blank" class="broken_link">Installer Xdebug avec XAMPP</a></li>
<li><a href="http://www.wampserver.com" target="_blank">Wampserver</a></li>
<li><a href="http://xdebug.com/" target="_blank">XDebug</a></li>
<li>Pièce jointe : <a href="http://grummfy.be/blog/250/xdebug-tar">XDebug quick switch menu for wampserver</a></li>
</ul>
<div class='footnotes'>
<div class='footnotedivider'></div>
<ol>
<li id='fn-250-1'>On parle de serveur web avec PHP &#8230; <span class='footnotereverse'><a href='#fnref-250-1'>&#8617;</a></span></li>
<li id='fn-250-2'>Par exemple, Zend Studio permet un débogage pas à pas mais en interne donc réduit &#8230;  <span class='footnotereverse'><a href='#fnref-250-2'>&#8617;</a></span></li>
<li id='fn-250-3'>cf. plus d&#8217;informations <span class='footnotereverse'><a href='#fnref-250-3'>&#8617;</a></span></li>
<li id='fn-250-4'><a href="http://grummfy.be/blog/250/xdebug-tar">XDebug quick switch menu for wampserver</a> <span class='footnotereverse'><a href='#fnref-250-4'>&#8617;</a></span></li>
</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://grummfy.be/blog/250/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Vitesse et référencement</title>
		<link>http://grummfy.be/blog/243#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://grummfy.be/blog/243#comments</comments>
		<pubDate>Tue, 23 Mar 2010 09:34:38 +0000</pubDate>
		<dc:creator>Grummfy</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Réflexion du jour]]></category>
		<category><![CDATA[HTTP]]></category>
		<category><![CDATA[optimisation]]></category>
		<category><![CDATA[programmation]]></category>
		<category><![CDATA[référencement]]></category>
		<category><![CDATA[trucs et astuces]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[web sémantique]]></category>

		<guid isPermaLink="false">http://grummfy.be/blog/?p=243</guid>
		<description><![CDATA[La vitesse d&#8217;affichage d&#8217;une page web est actuellement, et ce depuis un certain temps, devenu importante. Surtout en ce qui concerne l&#8217;optimisation et par conséquent le référencement. Afin de gagner ces quelques millisecondes qui feront la différence, il existe plusieurs méthodes et techniques. En voici quelques-unes, avec des exemples. Diminuer le nombre de requêtes HTTP [...]]]></description>
			<content:encoded><![CDATA[<p><!-- 		@page { margin: 2cm } 		P { margin-bottom: 0.21cm } 		A:link { so-language: zxx } --></p>
<p>La vitesse d&#8217;affichage d&#8217;une page web est actuellement, et ce depuis un certain temps, devenu importante. Surtout en ce qui concerne l&#8217;optimisation et par conséquent le référencement. Afin de gagner ces quelques millisecondes qui feront la différence, il existe plusieurs méthodes et techniques. En voici quelques-unes, avec des exemples.</p>
<h2>Diminuer le nombre de requêtes HTTP</h2>
<p>Chaque requête HTTP au sein du fichier prend un certain temps, mais surtout bloque le chargement global de la page web. En effet, HTTP et HTML chargent les ressources au fur et à mesure que la page le demande.</p>
<p><span id="more-243"></span></p>
<p>Restreindre le nombre de fichiers, par exemple, en regroupant les css et javascript est une bonne solution. Une autre possibilité est aussi de charger l&#8217;essentiel de la page et à la fin de celle-ci, exécuter du code javascript qui sera chargé de téléverser du javascript ou encore des css.</p>
<h2>Diminuer le nombre de requêtes DNS</h2>
<p>Que dire, si ce n&#8217;est l&#8217;essentiel, une requête DNS prend du temps, et le temps est pris sur le chargement de votre page.</p>
<h2>Se rapprocher du visiteur</h2>
<p>La distance entre un serveur et un visiteur peut faire varier énormément le temps d&#8217;affichage. En effet, une information située sur un serveur a un point X du globe peut parfois faire plusieurs fois le tour de celui-ci avant d&#8217;arriver chez le visiteur Y. Tout dépends des accords entre les gestionnaires des différents réseaux, le chemin le plus économique est celui qui sera choisi<sup class='footnote'><a href='#fn-243-1' id='fnref-243-1'>1</a></sup>!!!!! En résumé, plus vous êtes proches, plus cela arrive vite.</p>
<p>Une solution peut venir de l&#8217;utilisation de <a title="Content Delivery Network" href="http://fr.wikipedia.org/wiki/Content_Delivery_Network" target="_blank">CDN</a> qui suivant la provenance de l&#8217;IP oriente le visiteur vers le serveur le plus proche.</p>
<h2>Diminuer la quantité de données envoyées</h2>
<p>Cela peut paraître bête, mais moins il y a de données, moins il faut attendre pour recevoir celle-ci. Le but n&#8217;est pas de supprimer du contenu, mais bien de faire une diète, par exemple, en optimisant le code (X)HTML, CSS, javascript, &#8230; Ceci en enlevant les espaces superflus et en compressant les données envoyées. On peut notamment citer <a href="http://javascript.crockford.com/jsmin.html" target="_blank">jsmin</a> et <a href="http://yuilibrary.com/downloads/#yuicompressor" target="_blank">YUI Compressor</a></p>
<p>Mais aussi utiliser le mode deflate et gzip de votre serveur web (Apache par exemple). Ceci fera prochainement l&#8217;objet d&#8217;un article.</p>
<h2>Utiliser le cache des navigateurs</h2>
<p>HTTP prévois un mécanisme de cache, pensez à l&#8217;utiliser. Envoyer une bonne entête HTTP sur vos fichiers afin que seul le contenu qui ai changé soit chargé par le visiteur qui revient sur votre site.</p>
<p>Parallèlement à cela, si vous utilisez des librairies ou des framework css ou javascript vous pouvez très bien utiliser un CDN tel que celui que <a href="http://code.google.com/apis/ajaxlibs/documentation/" target="_blank">Google met à votre disposition</a>. Le cache sera le même pour tous les sites qui utiliseront ce CDN et donc le gain « risque » d&#8217;être présent même si le visiteur visite votre site pour la première fois!</p>
<h2>Pour finir</h2>
<p>Et il existe au moins des dizaines d&#8217;autres techniques, c&#8217;est dire si le sujet et étendu et intéressant. Certaines, sont réalisable à l&#8217;échelle de l&#8217;individu tandis que d&#8217;autres nécessitent un investissement, parfois conséquent.</p>
<p>Le but de cet article était d&#8217;intriguer et de vous pousser à aller plus loin. Un web plus rapide est l&#8217;affaire de tous et est bénéfique pour tous : le visiteur, le webmaster, le référencement du site, les FAI (qui paierons moins de bande passante), les hébergeurs, la planète (ben oui, un web optimiser = un web qui consomme moins!), &#8230;</p>
<div class='footnotes'>
<div class='footnotedivider'></div>
<ol>
<li id='fn-243-1'>L&#8217;écologie au niveau d&#8217;internet ce n&#8217;est donc pas ça! Imaginez la consommation de tous ces routeurs et switchs. <span class='footnotereverse'><a href='#fnref-243-1'>&#8617;</a></span></li>
</ol>
</div>
<p><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F243&amp;linkname=Vitesse%20et%20r%C3%A9f%C3%A9rencement" title="Delicious" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_technorati_favorites" href="http://www.addtoany.com/add_to/technorati_favorites?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F243&amp;linkname=Vitesse%20et%20r%C3%A9f%C3%A9rencement" title="Technorati Favorites" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/technorati.png" width="16" height="16" alt="Technorati Favorites"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F243&amp;linkname=Vitesse%20et%20r%C3%A9f%C3%A9rencement" title="Twitter" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F243&amp;linkname=Vitesse%20et%20r%C3%A9f%C3%A9rencement" title="Facebook" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F243&amp;linkname=Vitesse%20et%20r%C3%A9f%C3%A9rencement" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_button_netvibes_share" href="http://www.addtoany.com/add_to/netvibes_share?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F243&amp;linkname=Vitesse%20et%20r%C3%A9f%C3%A9rencement" title="Netvibes Share" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/netvibes.png" width="16" height="16" alt="Netvibes Share"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fgrummfy.be%2Fblog%2F243&amp;title=Vitesse%20et%20r%C3%A9f%C3%A9rencement" id="wpa2a_10"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://grummfy.be/blog/243/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Activation, désactivation du wifi sur un D-Link DSL-2640B via PHP</title>
		<link>http://grummfy.be/blog/233#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://grummfy.be/blog/233#comments</comments>
		<pubDate>Wed, 17 Mar 2010 23:06:52 +0000</pubDate>
		<dc:creator>Grummfy</dc:creator>
				<category><![CDATA[Développement]]></category>
		<category><![CDATA[Logiciel]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Réflexion du jour]]></category>
		<category><![CDATA[cli]]></category>
		<category><![CDATA[programmation]]></category>
		<category><![CDATA[réseaux]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[wifi]]></category>

		<guid isPermaLink="false">http://grummfy.be/blog/?p=233</guid>
		<description><![CDATA[Un script PHP en ligne de commande pour activer // désactiver le wifi sur un modem D-Link DSL-2640B. Cela permet d&#8217;illustrer un peu l&#8217;intérêt de faire du scripting &#8230; Je ne ferais pas de commentaires, mais n&#8217;hésitez pas à poser des questions &#8230; #!/usr/bin/php &#60;?php &#160; //Variable definition // //router $login = 'admin'; $password = [...]]]></description>
			<content:encoded><![CDATA[<p>Un script PHP en ligne de commande pour activer // désactiver le wifi sur un modem D-Link DSL-2640B. Cela permet d&#8217;illustrer un peu l&#8217;intérêt de faire du scripting &#8230;</p>
<p>Je ne ferais pas de commentaires, mais n&#8217;hésitez pas à poser des questions &#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">#!/usr/bin/php
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Variable definition</span>
<span style="color: #666666; font-style: italic;">//</span>
<span style="color: #666666; font-style: italic;">//router</span>
<span style="color: #000088;">$login</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'admin'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$password</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'admin'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$ip</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'192.168.1.1'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//</span>
<span style="color: #666666; font-style: italic;">//wifi</span>
<span style="color: #000088;">$wifi</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
	<span style="color: #666666; font-style: italic;">// /!\ don't touch this /!\</span>
	<span style="color: #0000ff;">'wlSsidIdx'</span>	<span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'wlEnbl'</span>	<span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'wlCountry'</span>	<span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'GB'</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'wlBasicRate'</span>	<span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//ssid name</span>
	<span style="color: #0000ff;">'wlSsid'</span>	<span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'monSuperRéseauxWifi'</span><span style="color: #339933;">,</span>
	<span style="color: #666666; font-style: italic;">//0 = visible, 1 = hide</span>
	<span style="color: #0000ff;">'wlHide'</span>	<span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span>
	<span style="color: #666666; font-style: italic;">//number of chanel or 0 for auto selection</span>
	<span style="color: #0000ff;">'wlChannel'</span>	<span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span>
	<span style="color: #666666; font-style: italic;">//Transmission Speed</span>
	<span style="color: #0000ff;">'wlRate'</span>	<span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span>
	<span style="color: #666666; font-style: italic;">//wifi mode 0=802.11b only, 1=Mixed 802.11g and 802.11b, 4=802.11g only</span>
	<span style="color: #0000ff;">'wlgMode'</span>	<span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">4</span><span style="color: #339933;">,</span>
&nbsp;
	<span style="color: #0000ff;">'wlWpaGTKRekey'</span>	<span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">750</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'wlWpa'</span>			<span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'aes'</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'wlAuthMode'</span>	<span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'psk2'</span><span style="color: #339933;">,</span>
	<span style="color: #666666; font-style: italic;">//authentification mode : 0 = none, 1 = wep, 2 = auto (wpa or wpa2), 3 = wpa2 only, 4 = wpa only</span>
	<span style="color: #0000ff;">'wlAuth'</span>	<span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'wlWpaPsk'</span>	<span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'masuperclefdelamortquitue'</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'wlWep'</span>		<span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'disabled'</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'wlPreauth'</span>	<span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/////////////////////</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> cli
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">const</span> LINE_BREAK <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">const</span> LINE_NO_BREAK <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">const</span> LINE_RETURN <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\r</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">const</span> LINE_NOTHING <span style="color: #339933;">=</span> <span style="color: #0000ff;">' '</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$_TEMP</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">250000</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//1/4 of seconds</span>
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$_MULTIPLICATOR</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">4</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//1/4 -&gt; 4</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$_LENGTH</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">60</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">function</span> _write_empty_space<span style="color: #009900;">&#40;</span><span style="color: #000088;">$lng</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$lng</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_LENGTH<span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">' '</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$lng</span><span style="color: #339933;">++;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">function</span> _echo<span style="color: #009900;">&#40;</span><span style="color: #000088;">$message</span><span style="color: #339933;">,</span> <span style="color: #000088;">$break</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$message</span><span style="color: #339933;">,</span> <span style="color: #000088;">$break</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$break</span> <span style="color: #339933;">==</span> <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #004000;">LINE_NO_BREAK</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>_write_empty_space<span style="color: #009900;">&#40;</span><span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$message</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: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">function</span> _sleep<span style="color: #009900;">&#40;</span><span style="color: #000088;">$second</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$second</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$second</span> <span style="color: #339933;">*</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_MULTIPLICATOR<span style="color: #339933;">;</span>
		<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;">$j</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$second</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #990000;">usleep</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_TEMP<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;">$i</span> <span style="color: #339933;">%</span> <span style="color: #cc66cc;">4</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>_echo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'.'</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #004000;">LINE_NOTHING</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #000088;">$i</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: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$j</span> <span style="color: #339933;">%</span> <span style="color: #cc66cc;">2</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>_echo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #004000;">LINE_RETURN</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_write_empty_space<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_echo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #004000;">LINE_RETURN</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>_echo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Please wait'</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #004000;">LINE_NOTHING</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #000088;">$i</span><span style="color: #339933;">++;</span>
				<span style="color: #009900;">&#125;</span>
				<span style="color: #000088;">$j</span><span style="color: #339933;">++;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_echo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #004000;">LINE_RETURN</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> wifi <span style="color: #000000; font-weight: bold;">extends</span> cli
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$_ch</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$_baseUrl</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #000088;">$wifi</span><span style="color: #339933;">,</span> <span style="color: #000088;">$ip</span><span style="color: #339933;">,</span> <span style="color: #000088;">$login</span><span style="color: #339933;">,</span> <span style="color: #000088;">$password</span><span style="color: #339933;">,</span> <span style="color: #000088;">$activation</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>_baseUrl <span style="color: #339933;">=</span> <span style="color: #0000ff;">'http://'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$ip</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/'</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_ch <span style="color: #339933;">=</span> <span style="color: #990000;">curl_init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_ch<span style="color: #339933;">,</span> CURLOPT_HEADER<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_ch<span style="color: #339933;">,</span> CURLOPT_RETURNTRANSFER<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: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_auth<span style="color: #009900;">&#40;</span><span style="color: #000088;">$login</span><span style="color: #339933;">,</span> <span style="color: #000088;">$password</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$activation</span> <span style="color: #339933;">=</span> <span style="color: #990000;">intval</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$activation</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;">$activation</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">1</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>_activation<span style="color: #009900;">&#40;</span><span style="color: #000088;">$wifi</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>_disactivation<span style="color: #009900;">&#40;</span><span style="color: #000088;">$wifi</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</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> __destruct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #990000;">curl_close</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_ch<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;">protected</span> <span style="color: #000000; font-weight: bold;">function</span> _activation<span style="color: #009900;">&#40;</span><span style="color: #000088;">$wifi</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>_echo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Activation ...'</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #004000;">LINE_NO_BREAK</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$wifi</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'wlBasicRate'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$wifi</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'wlgMode'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">4</span><span style="color: #009900;">&#41;</span> ? <span style="color: #0000ff;">'wifi2'</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">'default'</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_doQuery<span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_baseUrl <span style="color: #339933;">.</span> <span style="color: #0000ff;">'wirelesssetting.wl?'</span> <span style="color: #339933;">.</span> <span style="color: #990000;">http_build_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$wifi</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&amp;'</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>_sleep<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">5</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;">protected</span> <span style="color: #000000; font-weight: bold;">function</span> _disactivation<span style="color: #009900;">&#40;</span><span style="color: #000088;">$wifi</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>_echo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Disactivation ...'</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #004000;">LINE_NO_BREAK</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$wifiDown</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
			<span style="color: #0000ff;">'wlEnbl'</span>	<span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'wlSsidIdx'</span>	<span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$wifi</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'wlSsidIdx'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'wlCountry'</span>	<span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$wifi</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'wlCountry'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</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>_doQuery<span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_baseUrl <span style="color: #339933;">.</span> <span style="color: #0000ff;">'wirelesssetting.wl?'</span> <span style="color: #339933;">.</span> <span style="color: #990000;">http_build_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$wifiDown</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&amp;'</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>_sleep<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">5</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;">protected</span> <span style="color: #000000; font-weight: bold;">function</span> _doQuery<span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #339933;">,</span> <span style="color: #000088;">$post</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_ch<span style="color: #339933;">,</span> CURLOPT_URL<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><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_ch<span style="color: #339933;">,</span> CURLOPT_POST<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>
			<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_ch<span style="color: #339933;">,</span> CURLOPT_POSTFIELDS<span style="color: #339933;">,</span> <span style="color: #000088;">$post</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: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_ch<span style="color: #339933;">,</span> CURLOPT_HTTPGET<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>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">curl_exec</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_ch<span style="color: #009900;">&#41;</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;">&#123;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_echo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #004000;">LINE_BREAK</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_echo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Error Curl : '</span> <span style="color: #339933;">.</span> <span style="color: #990000;">curl_error</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ch</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #004000;">LINE_BREAK</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>_echo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'DONE'</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #004000;">LINE_BREAK</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">function</span> _auth<span style="color: #009900;">&#40;</span><span style="color: #000088;">$login</span><span style="color: #339933;">,</span> <span style="color: #000088;">$password</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>_echo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Authentification ...'</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #004000;">LINE_NO_BREAK</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$post</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
			<span style="color: #0000ff;">'username'</span>	<span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$login</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'password'</span>	<span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$password</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>_doQuery<span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_baseUrl <span style="color: #339933;">.</span> <span style="color: #0000ff;">'index.html'</span><span style="color: #339933;">,</span> <span style="color: #990000;">http_build_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&amp;'</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: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$argc</span> <span style="color: #339933;">!=</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">' synthaxe : scriptname.php 1 for activation or 0 for desactivation '</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">exit</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: #000000; font-weight: bold;">new</span> wifi<span style="color: #009900;">&#40;</span><span style="color: #000088;">$wifi</span><span style="color: #339933;">,</span> <span style="color: #000088;">$ip</span><span style="color: #339933;">,</span> <span style="color: #000088;">$login</span><span style="color: #339933;">,</span> <span style="color: #000088;">$password</span><span style="color: #339933;">,</span> <span style="color: #000088;">$argv</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># EOF</span></pre></div></div>

<p>Certes, le script ne gère pas tout, mais le but était de jouer avec la ligne de commande tout en n’allant pas dans les extensions exotiques de gestion de celle-ci &#8230;.</p>
<p><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F233&amp;linkname=Activation%2C%20d%C3%A9sactivation%20du%20wifi%20sur%20un%20D-Link%20DSL-2640B%20via%20PHP" title="Delicious" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_technorati_favorites" href="http://www.addtoany.com/add_to/technorati_favorites?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F233&amp;linkname=Activation%2C%20d%C3%A9sactivation%20du%20wifi%20sur%20un%20D-Link%20DSL-2640B%20via%20PHP" title="Technorati Favorites" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/technorati.png" width="16" height="16" alt="Technorati Favorites"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F233&amp;linkname=Activation%2C%20d%C3%A9sactivation%20du%20wifi%20sur%20un%20D-Link%20DSL-2640B%20via%20PHP" title="Twitter" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F233&amp;linkname=Activation%2C%20d%C3%A9sactivation%20du%20wifi%20sur%20un%20D-Link%20DSL-2640B%20via%20PHP" title="Facebook" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F233&amp;linkname=Activation%2C%20d%C3%A9sactivation%20du%20wifi%20sur%20un%20D-Link%20DSL-2640B%20via%20PHP" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_button_netvibes_share" href="http://www.addtoany.com/add_to/netvibes_share?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F233&amp;linkname=Activation%2C%20d%C3%A9sactivation%20du%20wifi%20sur%20un%20D-Link%20DSL-2640B%20via%20PHP" title="Netvibes Share" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/netvibes.png" width="16" height="16" alt="Netvibes Share"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fgrummfy.be%2Fblog%2F233&amp;title=Activation%2C%20d%C3%A9sactivation%20du%20wifi%20sur%20un%20D-Link%20DSL-2640B%20via%20PHP" id="wpa2a_12"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://grummfy.be/blog/233/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tri de listing sql via des liens dans Zend Framework</title>
		<link>http://grummfy.be/blog/222#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://grummfy.be/blog/222#comments</comments>
		<pubDate>Sun, 10 Jan 2010 02:23:44 +0000</pubDate>
		<dc:creator>Grummfy</dc:creator>
				<category><![CDATA[Développement]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Projet]]></category>
		<category><![CDATA[programmation]]></category>
		<category><![CDATA[ZF]]></category>

		<guid isPermaLink="false">http://grummfy.be/blog/?p=222</guid>
		<description><![CDATA[Dans la plupart des cas lorsque l'on affiche un listing provenant d'une requête sql on aimerait pouvoir offrir le tri à l'utilisateur. Dans l'article qui suit, je vous propose de découvrir une manière de le faire assez facilement.]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Dans la plupart des cas lorsque l&#8217;on affiche un listing provenant d&#8217;une requête sql on aimerait pouvoir offrir le tri à l&#8217;utilisateur. Dans l&#8217;article qui suit, je vous propose de découvrir une manière de le faire assez facilement.</p>
<p><span id="more-222"></span></p>
<p style="text-align: justify;">Comme exemple nous prendrons le cas d&#8217;une liste via l&#8217;appelle du contrôleur membres et de l&#8217;action liste.</p>
<p style="text-align: justify;">Dans le fichier <em>MembresController.php</em> nous aurons donc une méthode <em>listeAction()</em></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> listeAction<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$membres</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Default_Model_DbTable_Membres<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;">view</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">entries</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$membres</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fetchAll</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></div></div>

<p>Et dans la vue <em>membres/liste.phtml</em> nous aurons :</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>
&nbsp;
<span style="color: #000088;">$rowCount</span> <span style="color: #339933;">=</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">entries</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;">$rowCount</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: #000000; font-weight: bold;">?&gt;</span>
&lt;table&gt;
	&lt;tr&gt;
		&lt;th&gt;Nom&lt;/th&gt;
		&lt;th&gt;Adresse&lt;/th&gt;
		&lt;th&gt;Code postal&lt;/th&gt;
		&lt;th&gt;Ville&lt;/th&gt;
		&lt;th&gt;Email&lt;/th&gt;
	&lt;/tr&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">entrie</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$entry</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
	&lt;tr&gt;
		&lt;td&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">escape</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$entry</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">name</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/td&gt;
		&lt;td&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">escape</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$entry</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addrese</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/td&gt;
		&lt;td&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$entry</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">postCode</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/td&gt;
		&lt;td&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">escape</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$entry</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">cityName</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/td&gt;
		&lt;td&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">escape</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$entry</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">email</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/td&gt;
	&lt;/tr&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
	<span style="color: #b1b100;">endforeach</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;/table&gt;'</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: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;div&gt;Aucun membre n\'est enregistré!&lt;br /&gt;;)&lt;br /&gt;&lt;/div&gt;'</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>Jusque là, normalement, rien de bien complexe pour celui qui connait ZF.</p>
<p style="text-align: justify;">Ajoutons deux fichiers (cf <a rel="attachment wp-att-223" href="http://grummfy.be/blog/222/zf-tuto-order-by">pièce jointe</a>) dans le dossier librairy/Gru.</p>
<p style="text-align: justify;">
Nous devons ensuite les charger de manière automatique. Pour ce faire, dans le bootstrap.php (dont un extrait possible est présent ci-dessous) ajoutons les informations nécessaires au chargement des fichiers :</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">function</span> _initAutoload<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// nos deux lignes ajoutées</span>
		<span style="color: #000088;">$autoloader</span> <span style="color: #339933;">=</span> Zend_Loader_Autoloader<span style="color: #339933;">::</span><span style="color: #004000;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$autoloader</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">registerNamespace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Gru'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">// fin de l'ajout</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// Exemple de ce qu'il pourrait y avoir en plus!</span>
		<span style="color: #000088;">$autoloader</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Application_Module_Autoloader<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
			<span style="color: #0000ff;">'namespace'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Default'</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'basePath'</span>  <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">dirname</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</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;">$autoloader</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">function</span> _initView<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$view</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_View<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$viewRenderer</span> <span style="color: #339933;">=</span> Zend_Controller_Action_HelperBroker<span style="color: #339933;">::</span><span style="color: #004000;">getStaticHelper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ViewRenderer'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$viewRenderer</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setView</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$view</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//début ajout</span>
		<span style="color: #000088;">$view</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addHelperPath</span><span style="color: #009900;">&#40;</span>APPLICATION_PATH <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/../library/Gru/View/Helper/'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Gru_View_Helper_'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">// fin de l'ajout</span>
&nbsp;
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$view</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Maintenant, modifions notre application pour ajouter le tri. Reprenons notre contrôleur et modifions la méthode <em>listeAction().</em></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> listeAction<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">// Gestion du tri</span>
	<span style="color: #000088;">$order</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Gru_OrderBy<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'membre'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//Ajout des clefs de tri</span>
	<span style="color: #000088;">$order</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addKey</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'name'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Nom'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'asc'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$order</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addKey</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'add'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Adresse'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$order</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addKey</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'postCode'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Code postal'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'asc'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$order</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addKey</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'cityName'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Ville'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'asc'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$order</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addKey</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'email'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Courriel'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'asc'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// injection des requêtes get</span>
	<span style="color: #000088;">$order</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">insertRequestParams</span><span style="color: #009900;">&#40;</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;">getParam</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'order'</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;">getRequest</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getParam</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'by'</span><span style="color: #009900;">&#41;</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;">view</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">orderKeys</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$order</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getKeys</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
&nbsp;
	<span style="color: #000088;">$membres</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Default_Model_DbTable_Membres<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #666666; font-style: italic;">//ne pas oubleir d'ajouter les champs trier au moment de la requête sql</span>
	<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">view</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">entries</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$membres</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fetchAll</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #000088;">$order</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getSqlKeys</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Et pour finir notre vue :</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>
&nbsp;
<span style="color: #000088;">$rowCount</span> <span style="color: #339933;">=</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">entries</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;">$rowCount</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: #000000; font-weight: bold;">?&gt;</span>
&lt;table&gt;
	&lt;tr&gt;
		<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">orderBy</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">th</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">orderKeys</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">baseUrl</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/themes/images/'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
	&lt;/tr&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">entrie</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$entry</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
	&lt;tr&gt;
		&lt;td&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">escape</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$entry</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">name</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/td&gt;
		&lt;td&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">escape</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$entry</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addrese</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/td&gt;
		&lt;td&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$entry</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">postCode</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/td&gt;
		&lt;td&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">escape</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$entry</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">cityName</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/td&gt;
		&lt;td&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">escape</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$entry</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">email</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/td&gt;
	&lt;/tr&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
	<span style="color: #b1b100;">endforeach</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;/table&gt;'</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: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;div&gt;Aucun membre n\'est enregistré!&lt;br /&gt;;)&lt;br /&gt;&lt;/div&gt;'</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 l&#8217;exemple, nous afficherons des icônes suivant le sens du tri, icônes se trouvant dans le répertoire spécifié. Un clic sur les titres permet de trier suivant la colonne cliquée. A noter qu&#8217;ici Adresse ne sera pas triable du au fait de la non précision de l&#8217;ordre.</p>
<p style="text-align: justify;">Il y aurait moyen d&#8217;améliorer le script :</p>
<ul>
<li>utilisations de décorateurs</li>
<li>utilisation de traduction</li>
<li>Gru_OrderBy devrait être un plugins</li>
<li>&#8230;</li>
</ul>
<p style="text-align: justify;">En attendant, j&#8217;espère que ce bout de code vous facilitera la vie!</p>
<p style="text-align: justify;">Des remarques, des questions? Postez un commentaire!</p>
]]></content:encoded>
			<wfw:commentRss>http://grummfy.be/blog/222/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>[note]Zend Framework et dojo : auto-complétion</title>
		<link>http://grummfy.be/blog/216#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://grummfy.be/blog/216#comments</comments>
		<pubDate>Sat, 02 Jan 2010 15:32:29 +0000</pubDate>
		<dc:creator>Grummfy</dc:creator>
				<category><![CDATA[Développement]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[découverte]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[programmation]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[ZF]]></category>

		<guid isPermaLink="false">http://grummfy.be/blog/?p=216</guid>
		<description><![CDATA[Ceci est une note rapide ... j'espère produire un article plus intéressant une autre fois ...
Nous allons regarder les bases de l'auto-complétion  avec ZF et Dojo. Dojo simplement parce qu'il est le mieux intégré des frameworks javascript. Sachant que pour l'instant seul jQuery et Dojo sont intégré...]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Ceci est une note rapide &#8230; j&#8217;espère produire un article plus intéressant une autre fois &#8230;</p>
<p style="text-align: justify;">Nous allons regarder les bases de l&#8217;auto-complétion  avec <a href="./?tag=zf#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed">ZF</a> et Dojo. Dojo simplement parce qu&#8217;il est le mieux intégré des frameworks javascript. Sachant que pour l&#8217;instant seul jQuery et Dojo sont intégré</p>
<h2>Le code</h2>
<p><em>application/views/scripts/test/index.phtml</em></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">dojo</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">enable</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;">//activation de dojo</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">comboBox</span><span style="color: #009900;">&#40;</span>
	<span style="color: #0000ff;">'toto'</span><span style="color: #339933;">,</span>	<span style="color: #666666; font-style: italic;">//id html de l'élément</span>
	<span style="color: #0000ff;">''</span><span style="color: #339933;">,</span>	<span style="color: #666666; font-style: italic;">//valeur par défaut</span>
	<span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
		<span style="color: #0000ff;">'autocomplete'</span>	<span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span>								<span style="color: #666666; font-style: italic;">//activation de l'auto-complétion</span>
		<span style="color: #0000ff;">'store'</span>		<span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'stateStore'</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'storeType'</span>		<span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'dojo.data.ItemFileReadStore'</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'storeParams'</span>	<span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'url'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">baseUrl</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/test/records'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>	<span style="color: #666666; font-style: italic;">//url où les données JSON sont récupérée</span>
		<span style="color: #0000ff;">'searchAttr'</span>		<span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'title'</span><span style="color: #339933;">,</span>								<span style="color: #666666; font-style: italic;">//donnée recherchée pour remplir le combobox</span>
	<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p><em>application/layoutes/scripts/layout.phtml</em></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// ...</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">dojo</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">isEnabled</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>	<span style="color: #666666; font-style: italic;">//Évite les chargement inutile ....</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">dojo</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setDjConfigOption</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'isDebug'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span>APPLICATION_ENV <span style="color: #339933;">==</span> <span style="color: #0000ff;">'development'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	<span style="color: #666666; font-style: italic;">//affiche une console de deboguage si on est en mode dev</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">dojo</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setDjConfigOption</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'usePlainJson'</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>						<span style="color: #666666; font-style: italic;">//utilise du json texte</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">dojo</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setLocalPath</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">baseUrl</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/themes/js/dojo/dojo/dojo.js'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>			<span style="color: #666666; font-style: italic;">//chemin vers les fichier dojo</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">dojo</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addStyleSheetModule</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'dijit.themes.tundra'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>					<span style="color: #666666; font-style: italic;">//thème à chargé</span>
			<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">dojo</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>												<span style="color: #666666; font-style: italic;">//affichage du tout ...</span>
		<span style="color: #009900;">&#125;</span>
<span style="color: #666666; font-style: italic;">// viennent ensuite nos jabvascript, css, etc</span>
<span style="color: #666666; font-style: italic;">//...</span>
<span style="color: #666666; font-style: italic;">//&lt;/head&gt;</span>
<span style="color: #666666; font-style: italic;">// ne pas oublier la class tundra dans le body</span>
<span style="color: #339933;">&lt;</span>body <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;tundra&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #666666; font-style: italic;">//...</span></pre></div></div>

<p><em>application/Bootstrap.php</em></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//...</span>
<span style="color: #666666; font-style: italic;">//dans _initView()</span>
		<span style="color: #666666; font-style: italic;">//dojo</span>
		Zend_Dojo<span style="color: #339933;">::</span><span style="color: #004000;">enableView</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$view</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//...</span></pre></div></div>

<p><em>application/controllers/TestController.php</em></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>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> TestController <span style="color: #000000; font-weight: bold;">extends</span> Zend_Controller_Action
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> indexAction<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</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> recordsAction<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// on désactive l'affichage</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_helper<span style="color: #339933;">-&gt;</span><span style="color: #004000;">layout</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">disableLayout</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//on va cherchée les données et les met dans un objet Zend_Dojo_Data</span>
		<span style="color: #000088;">$book</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Default_Model_DbTable_Book<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$dojo</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Dojo_Data<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'title'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$book</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fetchAll</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: #b1b100;">echo</span> <span style="color: #000088;">$dojo</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">toJson</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// on sort ... c'est pas joli mais en attendant cela fonctionne!</span>
		<span style="color: #990000;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># EOF</span></pre></div></div>

<h2>Choses à <span style="text-decoration: line-through;">retenir</span> comprendre</h2>
<p>Les choses à retenir :</p>
<ul>
<li><em>storeParams</em> est l&#8217;url où les donnée au format JSON seront prise</li>
<li><em>searchAttr</em> est l&#8217;élément qui va servir pour recherchée les données dans la masse de donnée JSON</li>
<li>ne pas oublier de mettre la class css &#8216;tundra&#8217;</li>
<li>Dojo peut, via ses styles css modifier votre rendu &#8230;</li>
</ul>
<h2>Remarque</h2>
<p>Version de ZF : 1.9.6</p>
<p>Version de Dojo (fourni avec zf dans extras) : 1.3</p>
]]></content:encoded>
			<wfw:commentRss>http://grummfy.be/blog/216/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zend Framework aide de vue partialLoop et cycle</title>
		<link>http://grummfy.be/blog/199#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://grummfy.be/blog/199#comments</comments>
		<pubDate>Wed, 30 Dec 2009 14:16:39 +0000</pubDate>
		<dc:creator>Grummfy</dc:creator>
				<category><![CDATA[Développement]]></category>
		<category><![CDATA[découverte]]></category>
		<category><![CDATA[programmation]]></category>
		<category><![CDATA[trucs et astuces]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[ZF]]></category>

		<guid isPermaLink="false">http://grummfy.be/blog/?p=199</guid>
		<description><![CDATA[Il y a des moment où l&#8217;on se dit que la doc est vraiment incomplète &#8230; Voici un exemple assez tordu&#8230; Rappel L&#8217;aide de vue (view helper)  cycle permet d&#8217;alterner des valeurs dans la vue, L&#8217;aide de vue partialLoop permet de faire une boucle sur une vue (fichier) afin de l&#8217;incorporer dans un autre fichier&#8230; [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Il y a des moment où l&#8217;on se dit que la doc est vraiment incomplète &#8230; Voici un exemple assez tordu&#8230;</p>
<h2>Rappel</h2>
<ul>
<li>L&#8217;aide de vue (view helper)  <a href="http://framework.zend.com/manual/en/zend.view.helpers.html#zend.view.helpers.initial.cycle">cycle</a> permet d&#8217;alterner des valeurs dans la vue,</li>
<li>L&#8217;aide de vue <a href="http://framework.zend.com/manual/en/zend.view.helpers.html#zend.view.helpers.initial.partial">partialLoop</a> permet de faire une boucle sur une vue (fichier) afin de l&#8217;incorporer dans un autre fichier&#8230;</li>
</ul>
<h2>Utilisation</h2>
<p style="text-align: justify;">Pour utiliser les deux ensembles, par exemple dans le cas d&#8217;un listing dont la sortie serait dans un tableau, il vous suffit de définir les valeurs assigner au cycle <strong><em>avant</em></strong> de faire le partialLoop.<br />
Exemple :<br />
Vue <em>views/scripts/membres/listing.phtml</em></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;table class=&quot;table&quot;&gt;
	&lt;thead&gt;
		&lt;tr&gt;
			&lt;th&gt;Nom&lt;/th&gt;
			&lt;th&gt;Prénom&lt;/th&gt;
			&lt;th&gt;Adresse&lt;/th&gt;
			&lt;th&gt;Code postal&lt;/th&gt;
			&lt;th&gt;Ville&lt;/th&gt;
			&lt;th&gt;Pays&lt;/th&gt;
			&lt;th&gt;Téléphone&lt;/th&gt;
		&lt;/tr&gt;
	&lt;/thead&gt;
	&lt;tbody&gt;
	<span style="color: #000000; font-weight: bold;">&lt;?php</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">cycle</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">assign</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'tr_1'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'tr_2'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'tr_3'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'_user_listing'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">partialLoop</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'utilisateurs/_user_list_listing.phtml'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">entries</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">?&gt;</span>
	&lt;/tbody&gt;
&lt;/table&gt;</pre></div></div>

<p>Vue <em>views/scripts/utilisateurs/_user_list_listing.phtml</em></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;tr class=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">cycle</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'_user_listing'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">next</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;
	&lt;td&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">escape</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">name</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/td&gt;
	&lt;td&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">escape</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">firstName</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/td&gt;
	&lt;td&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">escape</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Addrese</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/td&gt;
	&lt;td&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">postCode</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/td&gt;
	&lt;td&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">escape</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">cityName</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/td&gt;
	&lt;td&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">escape</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">countryName</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/td&gt;
	&lt;td&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">tel_prefix</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/td&gt;
&lt;/tr&gt;</pre></div></div>
</p>
<p><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F199&amp;linkname=Zend%20Framework%20aide%20de%20vue%20partialLoop%20et%20cycle" title="Delicious" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_technorati_favorites" href="http://www.addtoany.com/add_to/technorati_favorites?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F199&amp;linkname=Zend%20Framework%20aide%20de%20vue%20partialLoop%20et%20cycle" title="Technorati Favorites" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/technorati.png" width="16" height="16" alt="Technorati Favorites"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F199&amp;linkname=Zend%20Framework%20aide%20de%20vue%20partialLoop%20et%20cycle" title="Twitter" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F199&amp;linkname=Zend%20Framework%20aide%20de%20vue%20partialLoop%20et%20cycle" title="Facebook" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F199&amp;linkname=Zend%20Framework%20aide%20de%20vue%20partialLoop%20et%20cycle" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_button_netvibes_share" href="http://www.addtoany.com/add_to/netvibes_share?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F199&amp;linkname=Zend%20Framework%20aide%20de%20vue%20partialLoop%20et%20cycle" title="Netvibes Share" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/netvibes.png" width="16" height="16" alt="Netvibes Share"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fgrummfy.be%2Fblog%2F199&amp;title=Zend%20Framework%20aide%20de%20vue%20partialLoop%20et%20cycle" id="wpa2a_14"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://grummfy.be/blog/199/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Utilisation de FlashMessenger via un view helper dans Zend Framework</title>
		<link>http://grummfy.be/blog/191#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://grummfy.be/blog/191#comments</comments>
		<pubDate>Sun, 27 Dec 2009 18:21:56 +0000</pubDate>
		<dc:creator>Grummfy</dc:creator>
				<category><![CDATA[Développement]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Projet]]></category>
		<category><![CDATA[programmation]]></category>
		<category><![CDATA[trucs et astuces]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[ZF]]></category>

		<guid isPermaLink="false">http://grummfy.be/blog/?p=191</guid>
		<description><![CDATA[FlashMessanger est à la base un action helper, donc confiné au contrôleur. Cependant, c'est tellement pratique qu'il est dommage de ne pas pouvoir l'utiliser a travers les vue (view)... Je vous propose donc de l'utiliser via un view helper!]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><a title="Manuel Zend Framework sur FlashMessenger" href="http://framework.zend.com/manual/en/zend.controller.actionhelpers.html#zend.controller.actionhelpers.flashmessenger">FlashMessanger</a> est à la base un action helper, donc confiné au contrôleur. Celui-ci permet de passer un message d&#8217;une page à l&#8217;autre via le mécanisme des sessions . Après un formulaire on doit souvent ajouter un message de confirmation, on peux par exemple utilisé le FlashMessenger pour le faire et ainsi au ré-affichage suivant  afficher ce message!  C&#8217;est tellement pratique qu&#8217;il est dommage de ne pas pouvoir l&#8217;utiliser a travers les vue (view) de manière automatique&#8230;</p>
<p>Je vous propose donc de l&#8217;utiliser via un view helper!</p>
<p><span id="more-191"></span></p>
<h2>L&#8217;aide de vue</h2>
<p style="text-align: justify;">Voici l&#8217;aide de vue (view helper) FlashMessenger (du même nom que l&#8217;action helper). Il est à placer dans application/views/helpers/FlashMessenger.php</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>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * @see Zend_Controller_Action_Helper_FlashMessenger
 */</span>
<span style="color: #b1b100;">require_once</span> <span style="color: #0000ff;">'Zend/Controller/Action/Helper/FlashMessenger.php'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * @author grummfy
 */</span>
<span style="color: #000000; font-weight: bold;">class</span> Zend_View_Helper_FlashMessenger <span style="color: #000000; font-weight: bold;">extends</span> Zend_View_Helper_Abstract implements IteratorAggregate<span style="color: #339933;">,</span> Countable
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$_fm</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_fm <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Controller_Action_Helper_FlashMessenger<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: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> flashMessenger<span style="color: #009900;">&#40;</span><span style="color: #000088;">$cur</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;">&#123;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$cur</span><span style="color: #009900;">&#41;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">else</span>
			<span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getMessages</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: #009933; font-style: italic;">/**
	 * Return currents FlashMessegenr object
	 * @return Zend_Controller_Action_Helper_FlashMessenger
	 */</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getFlasMessenger<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: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_fm<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #009933; font-style: italic;">/**
	 * Return previous emmited messages
	 * @return array
	 */</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getMessages<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: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_fm<span style="color: #339933;">-&gt;</span><span style="color: #004000;">getMessages</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: #009933; font-style: italic;">/**
	 * Renvoi le nombre de messages passé
	 * @return int
	 */</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> hasMessages<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;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_fm<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> getIterator<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: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_fm<span style="color: #339933;">-&gt;</span><span style="color: #004000;">getIterator</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: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #990000;">count</span><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: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_fm<span style="color: #339933;">-&gt;</span><span style="color: #004000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># EOF</span></pre></div></div>

</p>
<h2>Utilisation</h2>
<p style="text-align: justify;">
Pour l&#8217;utiliser rien de plus simple, par exemple dans le layout :</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: #666666; font-style: italic;">// flashmessage</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">flashMessenger</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">hasMessages</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span>
	<span style="color: #000000; font-weight: bold;">?&gt;</span>
	&lt;div id=&quot;flashMessengers&quot;&gt;
		<span style="color: #000000; font-weight: bold;">&lt;?php</span>
			<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">flashMessenger</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$msg</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;div class=&quot;flashMessenger&quot;&gt;'</span><span style="color: #339933;">;</span>
				<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">is_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$msg</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
					<span style="color: #b1b100;">echo</span> <span style="color: #990000;">implode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&lt;br /&gt;'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$msg</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #b1b100;">else</span>
					<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$msg</span><span style="color: #339933;">;</span>
				<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;/div&gt;'</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">?&gt;</span>
	&lt;/div&gt;
	<span style="color: #000000; font-weight: bold;">&lt;?php</span>
		<span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// fin flashmessage</span>
	<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Ceci peut très bien être utilisé dans votre vue (view) avec exactement le même code!</p>
<p style="text-align: justify;">Pour envoyer le message il vous suffit de simplement faire, dans votre contrôleur :</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_helper<span style="color: #339933;">-&gt;</span><span style="color: #004000;">flashMessenger</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Mise à jour du truc effectuées avec succès!'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

</p>
<p></p>
<p style="text-align: justify;">
Et c&#8217;est tout!</p>
]]></content:encoded>
			<wfw:commentRss>http://grummfy.be/blog/191/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Créer et ajouter un validateur de session dans Zend Framework</title>
		<link>http://grummfy.be/blog/186#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://grummfy.be/blog/186#comments</comments>
		<pubDate>Sat, 19 Dec 2009 16:30:17 +0000</pubDate>
		<dc:creator>Grummfy</dc:creator>
				<category><![CDATA[Développement]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Projet]]></category>
		<category><![CDATA[programmation]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[ZF]]></category>

		<guid isPermaLink="false">http://grummfy.be/blog/?p=186</guid>
		<description><![CDATA[Zend Framework possède divers mécanismes de sécurisation, parmi ceux-ci l&#8217;on trouvent les validateurs. Ces validateurs vérifie que la ou les données à validées sont valide et par là même sécurise celle-ci. Dans notre cas nous allons nous intéresser aux sessions et plus particulièrement à la validation de celle-ci au moment de sont démarrage, ceci afin [...]]]></description>
			<content:encoded><![CDATA[<div style="text-align: justify;">
<p>Zend Framework possède divers mécanismes de sécurisation, parmi ceux-ci l&#8217;on trouvent les validateurs. Ces validateurs vérifie que la ou les données à validées sont valide et par là même sécurise celle-ci.</p>
<p>Dans notre cas nous allons nous intéresser aux sessions et plus particulièrement à la validation de celle-ci au moment de sont démarrage, ceci afin de, par exemple, <span style="text-decoration: line-through;">empêcher le</span> diminuer les possibilités de vol de celle-ci. Nous allons créer un validateur d&#8217;ip &#8230; (oui je sais y a moyen de passer outre, si on derrière un proxy gnagnagna &#8230;. mais ici c&#8217;est un exemple!).</p>
<p><span id="more-186"></span></p>
<h2>Rermarque</h2>
<p>Nous utiliserons Zend Framework en version 1.9.<br />
De plus, nous allons créer notre librairie qui se nomera &laquo;&nbsp;Biblio&nbsp;&raquo;. Donc, il faudra penser à créer dasn votre répertoire library le dossier Biblio!</p>
<h2>Les sessions</h2>
<p>Tout d&#8217;abord mettons en place le mécanisme de session. Dans le Bootstrap nous ajoutons la méthode suivante :</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">function</span> _initSession<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	Zend_Session<span style="color: #339933;">::</span><span style="color: #004000;">start</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></div></div>

<h2>Le validateur</h2>
<p>Passons à la création proporement dite, créons le fichier /library/Biblio/Session/Validator/Ip.php, dont le contenu sera</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">setValidData<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REMOTE_ADDR'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>? <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REMOTE_ADDR'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">:</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #009933; font-style: italic;">/**
	 * Validate() - this method will determine if the ip matches the
	 * ip we stored when we initialized this variable.
	 *
	 * @return bool
	 */</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> validate<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: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>getValidData<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">===</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REMOTE_ADDR'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>?<span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REMOTE_ADDR'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">:</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># EOF</span></pre></div></div>

<p>Ensuite, il nous faut ajouter ce validateur à la session. Donc, on réédite le Bootstrap et on modifie la méthode _initSession() :</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">function</span> _initSession<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">require_once</span> <span style="color: #0000ff;">'Biblio/Session/Validator/Ip.php'</span><span style="color: #339933;">;</span>
	Zend_Session<span style="color: #339933;">::</span><span style="color: #004000;">registerValidator</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Biblio_Session_Validator_Ip<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	Zend_Session<span style="color: #339933;">::</span><span style="color: #004000;">start</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></div></div>

<h2>conclusion</h2>
<p>Encore une fois Zend nous montre sa puissance et sa facilité d&#8217;ajout de fonctionnalité. A noter qu&#8217;il existe déjà un validateur pour els session qui contrôle l&#8217;user agent (Zend_Session_Validator_HttpUserAgent()).<br />
N&#8217;hésitez pas a en ajouter!</p>
</div>
<p><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F186&amp;linkname=Cr%C3%A9er%20et%20ajouter%20un%20validateur%20de%20session%20dans%20Zend%20Framework" title="Delicious" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_technorati_favorites" href="http://www.addtoany.com/add_to/technorati_favorites?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F186&amp;linkname=Cr%C3%A9er%20et%20ajouter%20un%20validateur%20de%20session%20dans%20Zend%20Framework" title="Technorati Favorites" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/technorati.png" width="16" height="16" alt="Technorati Favorites"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F186&amp;linkname=Cr%C3%A9er%20et%20ajouter%20un%20validateur%20de%20session%20dans%20Zend%20Framework" title="Twitter" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F186&amp;linkname=Cr%C3%A9er%20et%20ajouter%20un%20validateur%20de%20session%20dans%20Zend%20Framework" title="Facebook" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F186&amp;linkname=Cr%C3%A9er%20et%20ajouter%20un%20validateur%20de%20session%20dans%20Zend%20Framework" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_button_netvibes_share" href="http://www.addtoany.com/add_to/netvibes_share?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F186&amp;linkname=Cr%C3%A9er%20et%20ajouter%20un%20validateur%20de%20session%20dans%20Zend%20Framework" title="Netvibes Share" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/netvibes.png" width="16" height="16" alt="Netvibes Share"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fgrummfy.be%2Fblog%2F186&amp;title=Cr%C3%A9er%20et%20ajouter%20un%20validateur%20de%20session%20dans%20Zend%20Framework" id="wpa2a_16"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://grummfy.be/blog/186/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>java : Drag &amp; Drop sur un JTable</title>
		<link>http://grummfy.be/blog/141#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://grummfy.be/blog/141#comments</comments>
		<pubDate>Mon, 07 Sep 2009 23:26:32 +0000</pubDate>
		<dc:creator>Grummfy</dc:creator>
				<category><![CDATA[Développement]]></category>
		<category><![CDATA[découverte]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[libre]]></category>
		<category><![CDATA[programmation]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[trucs et astuces]]></category>

		<guid isPermaLink="false">http://grummfy.be/blog/?p=141</guid>
		<description><![CDATA[Drag &#38; Drop sur un JTable Dans nos application moderne il semble logique de pouvoir faire du DND à gogo, pourtant ce n&#8217;est pas des plus simple, avec certain langage de le faire,  d&#8217;où cette exemple qui m&#8217;a fait un peu travaillez et arrachez un ou deux cheveux de ma longue chevelure de geek&#8230; Bref, [...]]]></description>
			<content:encoded><![CDATA[<h1>Drag &amp; Drop sur un JTable</h1>
<p style="text-align: justify;">Dans nos application moderne il semble logique de pouvoir faire du <acronym title="Drag&amp;Drop">DND</acronym> à gogo, pourtant ce n&#8217;est pas des plus simple, avec certain langage de le faire,  d&#8217;où cette exemple qui m&#8217;a fait un peu travaillez et arrachez un ou deux cheveux de ma longue chevelure de geek&#8230;</p>
<p style="text-align: justify;">Bref, voici l&#8217;essentiel :</p>
<ol>
<li>Il faut que le composant puisse être pris (drag) et/ou déposé (drop)</li>
<li>Il faut convertir le composant en donnée exportable et transportable (Transferable)</li>
<li>Il faut pouvoir restaurer les donnée correctement et suivant le type les restaurer de tel ou tel manière &#8230;</li>
</ol>
<p><span id="more-141"></span>Par défaut, java implémente tout une série de composant déjà &laquo;&nbsp;drag&amp;drop ready&nbsp;&raquo; :</p>
<p><img src="file:///tmp/moz-screenshot.jpg" alt="" /><img class="alignnone size-full wp-image-159" title="Tableau DND java" src="http://grummfy.be/blog/wp/wp-content/uploads/2009/09/Sans-titre.png" alt="Tableau DND java" width="340" height="338" /></p>
<p>Dans notre cas le JTable peut-être pris par copie mais on ne peux droper dedans&#8230;</p>
<p>Donc nous devons géré :</p>
<ul>
<li>Transport des données : ici nos lignes → Class JTableRowTransferable</li>
<li>Faire en sorte que le gestionnaire de DND accepte le drop et surtout l&#8217;accepte de notre transport de donnée → Class MyTransferHandler (class interne)</li>
<li>Et bien entendu faire comprendre à notre Jtable → il suffit de faire myJtable.setDragEnable(true); <img src='http://grummfy.be/blog/wp/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </li>
</ul>
<p style="text-align: justify;">Une fois tout cela fait je me suis vite rendu compte que pour l&#8217;utilisateur ce n&#8217;était pas simple!!! En fait, l&#8217;utilisateur devait sélectionner la ligne (et pas plusieurs) et ensuite légèrement décalé sur le coté (pour ne pas partir vers la sélection d&#8217;autre ligne) et puis seulement bouger le tout &#8230; INGÉRABLE ! Bref, je me suis dit &laquo;&nbsp;let&#8217;s go pour un bouton de <span style="text-decoration: line-through;">drague</span> drag!&nbsp;&raquo; J&#8217;ai donc chercher avec un JButton.  Mais<sup class='footnote'><a href='#fn-141-1' id='fnref-141-1'>1</a></sup> malheureusement pour utiliser un JButton il faudrait implémenter un render (une class qui dit comment doit s&#8217;afficher un objet dans une JTable) pour la JTable. Donc on oublie!</p>
<p style="text-align: justify;">Pour finir, je me suis rabattu vers une ImageIcon <img class="size-full wp-image-143" title="Appuyez sur le &quot;bouton&quot; vert et glissez la ligne vers le haut ou le bas ..." src="http://grummfy.be/blog/wp/wp-content/uploads/2009/09/drag_me_green.png" alt="Appuyez sur le &quot;bouton&quot; vert et glissez la ligne vers le haut ou le bas ..." width="47" height="14" /> (ou rien du tout cela aurait été pareil&#8230;) et un MouseListener sur mon JTable.</p>
<p style="text-align: justify;">Bref, je ne vais pas vous faire un cours, pour cela je vous renvoi plus bas! Donc, je vous propose de télécharger l&#8217;exemple : <a title="Télécharger l'exemple" rel="attachment wp-att-148" href="http://grummfy.be/blog/?attachment_id=148">DragTableExample.tar</a></p>
<h2>Plus d&#8217;info sur le DND en java ?</h2>
<ul>
<li>Excellent article sur le fonctionnement du DND : <a href="http://mbaron.developpez.com/javase/dnddt/" target="_blank">Introduction au Drag and Drop : transfert de données</a>[fr]</li>
<li><a href="http://gfx.developpez.com/tutoriel/java/swing/drag/" target="_blank">Drag &amp; Drop avec Style et l&#8217;API Swing</a>[fr]</li>
<li>Larticle de sun : <a href="http://java.sun.com/docs/books/tutorial/uiswing/dnd/index.html">Lesson: Drag and Drop and Data Transfer</a>[en]</li>
<li>Encore un autre très bon article : <a href="http://www.javaworld.com/javaworld/jw-03-1999/jw-03-dragndrop.html">How to drag and drop with Java 2</a>[en]</li>
</ul>
<div class='footnotes'>
<div class='footnotedivider'></div>
<ol>
<li id='fn-141-1'>puisque mais il y a sinon cela ne serait pas marrant <span class='footnotereverse'><a href='#fnref-141-1'>&#8617;</a></span></li>
</ol>
</div>
<p><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F141&amp;linkname=java%20%3A%20Drag%20%26%23038%3B%20Drop%20sur%20un%20JTable" title="Delicious" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_technorati_favorites" href="http://www.addtoany.com/add_to/technorati_favorites?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F141&amp;linkname=java%20%3A%20Drag%20%26%23038%3B%20Drop%20sur%20un%20JTable" title="Technorati Favorites" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/technorati.png" width="16" height="16" alt="Technorati Favorites"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F141&amp;linkname=java%20%3A%20Drag%20%26%23038%3B%20Drop%20sur%20un%20JTable" title="Twitter" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F141&amp;linkname=java%20%3A%20Drag%20%26%23038%3B%20Drop%20sur%20un%20JTable" title="Facebook" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F141&amp;linkname=java%20%3A%20Drag%20%26%23038%3B%20Drop%20sur%20un%20JTable" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_button_netvibes_share" href="http://www.addtoany.com/add_to/netvibes_share?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F141&amp;linkname=java%20%3A%20Drag%20%26%23038%3B%20Drop%20sur%20un%20JTable" title="Netvibes Share" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/netvibes.png" width="16" height="16" alt="Netvibes Share"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fgrummfy.be%2Fblog%2F141&amp;title=java%20%3A%20Drag%20%26%23038%3B%20Drop%20sur%20un%20JTable" id="wpa2a_18"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://grummfy.be/blog/141/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Utilisation de l&#8217;ellipse en java ou comment avoir un nombre indéfini de paramètre</title>
		<link>http://grummfy.be/blog/136#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://grummfy.be/blog/136#comments</comments>
		<pubDate>Sat, 29 Aug 2009 23:52:04 +0000</pubDate>
		<dc:creator>Grummfy</dc:creator>
				<category><![CDATA[Développement]]></category>
		<category><![CDATA[découverte]]></category>
		<category><![CDATA[programmation]]></category>
		<category><![CDATA[trucs et astuces]]></category>

		<guid isPermaLink="false">http://grummfy.be/blog/?p=136</guid>
		<description><![CDATA[Depuis Tiger (java 5.0 ou 1.5 &#8230;), la structure du langage java à intégré l&#8217;ellipse. Voici un exemple d&#8217;utilisation JPanel mkEntry(String label, javax.swing.JComponent... jc) { JPanel p = new JPanel(new FlowLayout()); p.add(new JLLabel(label)); for (javax.swing.JComponent comp: jc) p.add(comp); return p; } void test() { JPanel p = new JPanel(); p.add(mkEntry("test", new JTextField(), new JButton("valider")); } [...]]]></description>
			<content:encoded><![CDATA[<p>Depuis Tiger (java 5.0 ou 1.5 &#8230;), la structure du langage java à intégré l&#8217;ellipse.</p>
<p>Voici un exemple d&#8217;utilisation<br />
<code><br />
JPanel mkEntry(String label, javax.swing.JComponent... jc)<br />
{<br />
JPanel p = new JPanel(new FlowLayout());<br />
p.add(new JLLabel(label));<br />
for (javax.swing.JComponent comp: jc)<br />
p.add(comp);<br />
return p;<br />
}</p>
<p>void test()<br />
{<br />
JPanel p = new JPanel();<br />
p.add(mkEntry("test", new JTextField(), new JButton("valider"));<br />
}<br />
</code></p>
<p>Bon malheureusement on est obligé de n&#8217;avoir qu&#8217;un seul paramètre avec ellipse mais perso je trouve cela plus élégant que d&#8217;utiliser un tableau créer d&#8217;un côté puis de l&#8217;autre. Au passage cela revient au même que de créer un tableau (puisque ce qu&#8217;on récupère est un tableau) mais l&#8217;écriture en est simplifié.</p>
<p><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F136&amp;linkname=Utilisation%20de%20l%26%238217%3Bellipse%20en%20java%20ou%20comment%20avoir%20un%20nombre%20ind%C3%A9fini%20de%20param%C3%A8tre" title="Delicious" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_technorati_favorites" href="http://www.addtoany.com/add_to/technorati_favorites?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F136&amp;linkname=Utilisation%20de%20l%26%238217%3Bellipse%20en%20java%20ou%20comment%20avoir%20un%20nombre%20ind%C3%A9fini%20de%20param%C3%A8tre" title="Technorati Favorites" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/technorati.png" width="16" height="16" alt="Technorati Favorites"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F136&amp;linkname=Utilisation%20de%20l%26%238217%3Bellipse%20en%20java%20ou%20comment%20avoir%20un%20nombre%20ind%C3%A9fini%20de%20param%C3%A8tre" title="Twitter" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F136&amp;linkname=Utilisation%20de%20l%26%238217%3Bellipse%20en%20java%20ou%20comment%20avoir%20un%20nombre%20ind%C3%A9fini%20de%20param%C3%A8tre" title="Facebook" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F136&amp;linkname=Utilisation%20de%20l%26%238217%3Bellipse%20en%20java%20ou%20comment%20avoir%20un%20nombre%20ind%C3%A9fini%20de%20param%C3%A8tre" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_button_netvibes_share" href="http://www.addtoany.com/add_to/netvibes_share?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F136&amp;linkname=Utilisation%20de%20l%26%238217%3Bellipse%20en%20java%20ou%20comment%20avoir%20un%20nombre%20ind%C3%A9fini%20de%20param%C3%A8tre" title="Netvibes Share" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/netvibes.png" width="16" height="16" alt="Netvibes Share"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fgrummfy.be%2Fblog%2F136&amp;title=Utilisation%20de%20l%26%238217%3Bellipse%20en%20java%20ou%20comment%20avoir%20un%20nombre%20ind%C3%A9fini%20de%20param%C3%A8tre" id="wpa2a_20"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://grummfy.be/blog/136/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java : chargement de class et instanciantion depuis une chemin</title>
		<link>http://grummfy.be/blog/130#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://grummfy.be/blog/130#comments</comments>
		<pubDate>Fri, 28 Aug 2009 23:54:51 +0000</pubDate>
		<dc:creator>Grummfy</dc:creator>
				<category><![CDATA[Développement]]></category>
		<category><![CDATA[Projet]]></category>
		<category><![CDATA[découverte]]></category>
		<category><![CDATA[étrange]]></category>
		<category><![CDATA[fsb-tools]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[programmation]]></category>
		<category><![CDATA[trucs et astuces]]></category>

		<guid isPermaLink="false">http://grummfy.be/blog/?p=130</guid>
		<description><![CDATA[J'ai toujours trouvé frustrant de ne pas pouvoir me dire que connaissance le nom d'une classe (sous format de String) je ne pouvait, comme je le fait en PHP, instancier un objet. En fait, cela un bout de temps que c'est réalisable mais je n'avais jamais réussi à trouvé comment, malgré des piste déjà essayé ...]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">J&#8217;ai toujours trouvé frustrant de ne pas pouvoir me dire que connaissance le nom d&#8217;une classe (sous format de String) je ne pouvait, comme je le fait en PHP, instancier un objet. En fait, cela un bout de temps que c&#8217;est réalisable mais je n&#8217;avais jamais réussi à trouvé comment, malgré des piste déjà essayé &#8230;</p>
<p style="text-align: justify;">Donc, pour ceux qui comme mois désire faire cela :</p>
<p style="text-align: justify;">Chargement d&#8217;une classe situé dans le package test, nommé MaClasse (<strong><span style="text-decoration: underline;">/!\</span> java est case-sensitive</strong>)<code> et création de l'objet lié.<br />
Object monInstance = Class.forName("test.MaClasse").newInstance();</code></p>
<p style="text-align: justify;">En espérant que cela serve à plus d&#8217;un!</p>
]]></content:encoded>
			<wfw:commentRss>http://grummfy.be/blog/130/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 4.666 seconds -->

