<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet title="XSL formatting" type="text/xsl" href="http://mirmodynamics.com/feed/rss2/xslt" ?><rss version="2.0"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:wfw="http://wellformedweb.org/CommentAPI/"
  xmlns:content="http://purl.org/rss/1.0/modules/content/"
  xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
  <title>Mirmo Dynamics - Tag - plugin</title>
  <link>http://mirmodynamics.com/</link>
  <atom:link href="http://mirmodynamics.com/feed/tag/plugin/rss2" rel="self" type="application/rss+xml"/>
  <description>Si tu kiffes pas reunoi, t'écoutes pas et puis c'est tout.</description>
  <language>en</language>
  <pubDate>Sun, 14 Mar 2010 19:59:01 +0100</pubDate>
  <copyright>2003-2009 &amp;copy; Geoffrey Bachelet</copyright>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Dotclear</generator>
  
    
  <item>
    <title>sfConsolePlugin, a console plugin for symfony</title>
    <link>http://mirmodynamics.com/post/2008/12/17/sfConsolePlugin%2C-a-console-plugin-for-symfony</link>
    <guid isPermaLink="false">urn:md5:b740e71397937f5de67118ce230981aa</guid>
    <pubDate>Wed, 17 Dec 2008 23:30:00 +0100</pubDate>
    <dc:creator>Geoffrey</dc:creator>
        <category>Symfony</category>
        <category>console</category><category>php</category><category>plugin</category><category>sfConsolePlugin</category><category>symfony</category>    
    <description>    &lt;p&gt;I've just release the first beta of my first symfony plugin: &lt;a href=&quot;http://www.symfony-project.org/plugins/sfConsolePlugin&quot;&gt;sfConsolePlugin&lt;/a&gt;. This plugins provides a PHP shell, with tab-completion, history support, and symfony capabilities. To install and use it, you need symfony 1.2 and the readline extension. From your project root:&lt;/p&gt;

&lt;pre&gt;
$ ./symfony plugin:install sfConsolePlugin --release=0.0.2
$ ./symfony console:run
&lt;/pre&gt;


&lt;p&gt;see &lt;a href=&quot;http://www.symfony-project.org/plugins/sfConsolePlugin/0_0_2?tab=plugin_readme&quot;&gt;the README file&lt;/a&gt; for more info.&lt;/p&gt;</description>
    
    
    
          <comments>http://mirmodynamics.com/post/2008/12/17/sfConsolePlugin%2C-a-console-plugin-for-symfony#comment-form</comments>
      <wfw:comment>http://mirmodynamics.com/post/2008/12/17/sfConsolePlugin%2C-a-console-plugin-for-symfony#comment-form</wfw:comment>
      <wfw:commentRss>http://mirmodynamics.com/feed/atom/comments/1162</wfw:commentRss>
      </item>
    
  <item>
    <title>Plugin &quot;related by tags&quot; pour dotclear 2, deuxième</title>
    <link>http://mirmodynamics.com/post/2008/03/10/Plugin-related-by-tags-pour-dotclear-2-deuxieme</link>
    <guid isPermaLink="false">urn:md5:5e7f17894657fe0198135403c49f72f8</guid>
    <pubDate>Mon, 10 Mar 2008 21:48:00 +0100</pubDate>
    <dc:creator>Geoffrey</dc:creator>
        <category>Coding</category>
        <category>dotclear2</category><category>plugin</category><category>related by tags</category>    
    <description>    &lt;p&gt;Après de longs mois d'attente, le &lt;em&gt;related by tags&lt;/em&gt; nouveau arrive enfin ! Au menu des réjouissances, une interface de configuration, ainsi qu'un widget font leur apparition. Vous disposez donc désormais de deux manières d'afficher les billets liés, directement en modifiant le template comme avant:&lt;/p&gt;

&lt;pre&gt;
{{tpl:include src=&amp;quot;_related_by_tags.html&amp;quot;}}
&lt;/pre&gt;


&lt;p&gt;ou tout simplement en activant le widget correspondant, que vous pouvez configurer comme vous l'entendez. Bien sur, ce widget ne s'affichera que lors de la visualisation d'un billet.&lt;/p&gt;


&lt;p&gt;Au chapitre des fonctionnalités / bugfix manquant(e)s, on notera le bug lié à l'utilisation de postgresql, ainsi que la traduction française, qui sera pour plus tard.&lt;/p&gt;


&lt;p&gt;Encore une fois, n'hésitez pas à poster tous vos commentaires ici même.&lt;/p&gt;</description>
    
    
    
          <comments>http://mirmodynamics.com/post/2008/03/10/Plugin-related-by-tags-pour-dotclear-2-deuxieme#comment-form</comments>
      <wfw:comment>http://mirmodynamics.com/post/2008/03/10/Plugin-related-by-tags-pour-dotclear-2-deuxieme#comment-form</wfw:comment>
      <wfw:commentRss>http://mirmodynamics.com/feed/atom/comments/1087</wfw:commentRss>
      </item>
    
  <item>
    <title>my first rails plugin: named_resources</title>
    <link>http://mirmodynamics.com/post/2007/11/28/my-first-rails-plugin%3A-named_resources</link>
    <guid isPermaLink="false">urn:md5:28c1356e1cfe998c3393fe046bb94dcb</guid>
    <pubDate>Wed, 28 Nov 2007 13:00:00 +0100</pubDate>
    <dc:creator>Geoffrey</dc:creator>
        <category>Coding</category>
        <category>plugin</category><category>rails</category><category>resources</category><category>ruby</category>    
    <description>    &lt;p&gt;It's a simple plugin (2 lines of code beside class and modules declarations) which allows routes created via the &lt;code&gt;map.resources&lt;/code&gt; mechanism to be customized. Say you have the following map:&lt;/p&gt;

&lt;pre&gt;
[ruby]
map.resources :members
&lt;/pre&gt;


&lt;p&gt;It will generate routes like:&lt;/p&gt;

&lt;pre&gt;
/members
/members/:id
/members/new
&lt;/pre&gt;


&lt;p&gt;No say you want to i18n your app, in french for example, what do you do ? You just can't out of the box. This is where my plugin enters into action, just add a &lt;code&gt;:route_name&lt;/code&gt; parameter to the &lt;code&gt;map.resources&lt;/code&gt; call and you're set:&lt;/p&gt;

&lt;pre&gt;
[ruby]
map.resources :members, :route_name =&amp;gt; 'utilisateurs'
&lt;/pre&gt;


&lt;p&gt;will generate routes like:&lt;/p&gt;
&lt;pre&gt;
/utilisateurs
/utilisateurs/:id
/utilisateurs/new
&lt;/pre&gt;


&lt;p&gt;It shall also work for nested resources, although I did not test that.&lt;/p&gt;


&lt;p&gt;The code is actually pretty simple:&lt;/p&gt;

&lt;pre&gt;
[ruby]
module ActionController
  module Resources
    class Resource
      def path
        route_name = @options.include?(:route_name) ? @options[:route_name] : @plural
        @path ||= &amp;quot;#{path_prefix}/#{route_name}&amp;quot;
      end 
    end 
  end 
end
&lt;/pre&gt;


&lt;p&gt;To install just use &lt;code&gt;script/plugin&lt;/code&gt;:&lt;/p&gt;

&lt;pre&gt;
script/plugin install http://tools.assembla.com/svn/riskle/rails/plugins/named_resources
&lt;/pre&gt;


&lt;p&gt;or to install as an svn:external resource:&lt;/p&gt;

&lt;pre&gt;
script/plugin install -x http://tools.assembla.com/svn/riskle/rails/plugins/named_resources
&lt;/pre&gt;</description>
    
    
    
          <comments>http://mirmodynamics.com/post/2007/11/28/my-first-rails-plugin%3A-named_resources#comment-form</comments>
      <wfw:comment>http://mirmodynamics.com/post/2007/11/28/my-first-rails-plugin%3A-named_resources#comment-form</wfw:comment>
      <wfw:commentRss>http://mirmodynamics.com/feed/atom/comments/1076</wfw:commentRss>
      </item>
    
  <item>
    <title>Plugin &quot;related by tags&quot; pour dotclear 2</title>
    <link>http://mirmodynamics.com/post/2007/10/04/plugin-related-by-tags-pour-dotclear-2</link>
    <guid isPermaLink="false">urn:md5:0512ecee686bfffdfce5d2a547b4b1dc</guid>
    <pubDate>Thu, 04 Oct 2007 20:50:00 +0200</pubDate>
    <dc:creator>Geoffrey</dc:creator>
        <category>Coding</category>
        <category>dotclear2</category><category>plugin</category><category>related by tags</category>    
    <description>    &lt;p&gt;&lt;strong&gt;update&lt;/strong&gt;: &lt;a href=&quot;http://mirmodynamics.com/post/2008/03/10/Plugin-related-by-tags-pour-dotclear-2-deuxieme&quot;&gt;nouvelle version disponible&lt;/a&gt;&lt;/p&gt;


&lt;p&gt;Allez hop, j'ai codouillé rapidement aujourd'hui un plugin dotclear 2 pour afficher une liste des billets ayant le ou les mêmes tags que le billet en cours de lecture par l'internaute. Il est téléchargeable dès maintenant sous forme &lt;a href=&quot;http://mirmodynamics.com/public/plugin-related_by_tags-1.tar.gz&quot;&gt;d'archive tar gzipée&lt;/a&gt; ou directement de &lt;a href=&quot;http://mirmodynamics.com/public/plugin-related_by_tags-1.pkg.gz&quot;&gt;package dotclear&lt;/a&gt;. Pour l'utiliser, rien de plus simple, il suffit d'ajouter le tag suivant dans votre template, à l'endroit où vous souhaitez afficher la liste des billets:&lt;/p&gt;

&lt;pre&gt;
{{tpl:include src=&amp;quot;_related_by_tags.html&amp;quot;}}
&lt;/pre&gt;


&lt;p&gt;Et voilà c'est tout :-)&lt;/p&gt;


&lt;p&gt;Bon par contre, il faut faire gaffe a comment on tag ses billets (genre pour celui là j'ai preferré ne pas le taguer &lt;em&gt;php&lt;/em&gt; histoire d'avoir des résultats plus pertinents).&lt;/p&gt;


&lt;p&gt;ps: si quelqu'un connait un moyen d'éviter d'avoir a rajouter un bout de code au template je suis preneur (mais j'ai la flemme de chercher là tout de suite).&lt;/p&gt;</description>
    
    
    
          <comments>http://mirmodynamics.com/post/2007/10/04/plugin-related-by-tags-pour-dotclear-2#comment-form</comments>
      <wfw:comment>http://mirmodynamics.com/post/2007/10/04/plugin-related-by-tags-pour-dotclear-2#comment-form</wfw:comment>
      <wfw:commentRss>http://mirmodynamics.com/feed/atom/comments/1058</wfw:commentRss>
      </item>
    
  <item>
    <title>A Zend controller plugin to enable RESTful behaviour</title>
    <link>http://mirmodynamics.com/post/2007/07/14/A-Zend-controller-plugin-to-enable-REST-like-behaviour</link>
    <guid isPermaLink="false">urn:md5:a7322d8fa8be9d89dc76a2193831cfe0</guid>
    <pubDate>Sat, 14 Jul 2007 13:33:00 +0200</pubDate>
    <dc:creator>Geoffrey</dc:creator>
        <category>Coding</category>
        <category>controller</category><category>mvc</category><category>php</category><category>plugin</category><category>REST</category><category>zend framework</category>    
    <description>&lt;p&gt;This is a simple controller plugin for the &lt;a href=&quot;http://framework.zend.com/&quot;&gt;Zend Framework&lt;/a&gt; which enable &lt;acronym&gt;REST&lt;/acronym&gt;ful behaviour. It basically adds the &lt;acronym&gt;HTTP&lt;/acronym&gt; method name to the action name, so that the &lt;acronym&gt;URL&lt;/acronym&gt; &lt;code&gt;http://example.com/foo/bar&lt;/code&gt; will be dispatched to &lt;code&gt;FooController::barGetAction&lt;/code&gt; on a GET, &lt;code&gt;FooController::barPostAction&lt;/code&gt; on a POST, etc.&lt;/p&gt;    &lt;p&gt;Here is the actual code:&lt;/p&gt;

&lt;pre&gt;
&amp;lt;?php

class My_Controller_Plugin_Rest extends Zend_Controller_Plugin_Abstract {

        /**
         * Defines the format of the REST action name
         * Quite useless atm as the dispatcher will strip
         * any non alpha character
         */

        protected $_nameFormat = ':action:method';

        /**
         * Rewrites the action according to the http method
         */

        public function preDispatch() {
                $request = $this-&amp;gt;getRequest();
                $restActionName = $this-&amp;gt;_translateSpec($this-&amp;gt;_nameFormat, array(
                        'action' =&amp;gt; $request-&amp;gt;getActionName(),
                        'method' =&amp;gt; $request-&amp;gt;getMethod(),
                ));
                $request-&amp;gt;setActionName($restActionName);
        }

        /**
         * Inject values into a spec strings
         *
         * Allowed values are:
         *      :action =&amp;gt; the action name
         *      :method =&amp;gt; the http method
         *
         * @param string $spec
         * @param array $vars
         * @return string
         */

        protected function _translateSpec($spec, $vars = array()) {
                foreach($vars as $key =&amp;gt; $value) {
                        switch($key) {
                                case 'action':
                                case 'method':
                                        $$key = $value;
                                break;
                                default:
                                break;
                        }
                }

                $replacements = array(
                        ':action' =&amp;gt; $action,
                        ':method' =&amp;gt; $method,
                );

                $value = str_replace(array_keys($replacements), array_values($replacements),$spec);
                return $value;
        }
}
&lt;/pre&gt;


&lt;p&gt;Still, i'm not completly satisfied with this plugin. Plugins certainly allows for powerful control over what's going up in the dispatch process, but the dispatcher itself enforces a set of rules on actions naming (eg, you can't have a _ in it, it is stripped at dispatch time). Thus, I'm wondering on the pertinence of writting a custom dispatcher (read &lt;code&gt;My_Controller_Dispatcher_Rest&lt;/code&gt;) instead of just a plugin, which would enable far more possibilities.&lt;/p&gt;


&lt;p&gt;Btw, in case you're wondering, the plugins is used like this;&lt;/p&gt;

&lt;pre&gt;
$frontController = Zend_Controller_Front::getInstance();
$frontController-&amp;gt;registerPlugin(new My_Controller_Plugin_Rest);
&lt;/pre&gt;


&lt;p&gt;Easy heh ?&lt;/p&gt;


&lt;p&gt;Also, I'm not convinced that this plugin is &lt;em&gt;the way to go&lt;/em&gt; in matter of RESTful functionnality. I'm still wondering if it would not be better to have urls mapped to a single controller, replacing actions with &lt;em&gt;http methods&lt;/em&gt; (that is, &lt;code&gt;http://example.com/foo/bar&lt;/code&gt; would map to &lt;code&gt;FooController::getAction&lt;/code&gt;, etc).&lt;/p&gt;


&lt;p&gt;Any opinions around ?&lt;/p&gt;</description>
    
    
    
          <comments>http://mirmodynamics.com/post/2007/07/14/A-Zend-controller-plugin-to-enable-REST-like-behaviour#comment-form</comments>
      <wfw:comment>http://mirmodynamics.com/post/2007/07/14/A-Zend-controller-plugin-to-enable-REST-like-behaviour#comment-form</wfw:comment>
      <wfw:commentRss>http://mirmodynamics.com/feed/atom/comments/887</wfw:commentRss>
      </item>
    
  <item>
    <title>Zend Framework: Un plugin simple pour le Front Controller</title>
    <link>http://mirmodynamics.com/post/2006/11/19/Zend-Framework%3A-Un-plugin-simple-pour-le-Front-Controller</link>
    <guid isPermaLink="false">urn:md5:6c829cc8dbd18739b84ef7758d852a70</guid>
    <pubDate>Sun, 19 Nov 2006 21:30:00 +0100</pubDate>
    <dc:creator>Geoffrey</dc:creator>
        <category>Coding</category>
        <category>bootstrap</category><category>howto</category><category>MVC</category><category>organisation</category><category>php</category><category>plugin</category><category>vues</category><category>zend framework</category>    
    <description>&lt;p&gt;L'implémentation du &lt;code&gt;Front Controller&lt;/code&gt; du &lt;a href=&quot;http://framework.zend.com/&quot;&gt;Zend Framework&lt;/a&gt; inclue un système bien pratique de plugins, qui va nous permettre de réaliser plus simplement et proprement &lt;a href=&quot;http://fashion.hosmoz.net/blog/post/2006/08/30/Automatisation-des-vues&quot;&gt;l'automatisation des vues&lt;/a&gt;, initialement embarquée dans une extension de &lt;code&gt;Zend_Controller_Action&lt;/code&gt; (ce qui pose quelques problèmes, nottament au lors de l'utilisation de &lt;code&gt;__forward()&lt;/code&gt; et &lt;code&gt;_redirect()&lt;/code&gt;).&lt;/p&gt;    &lt;p&gt;Techniquement, un plugin est une classe qui implémente l'interface des plugins (&lt;code&gt;Zend_Controller_Plugin_Interface&lt;/code&gt;). Dans la pratique, une classe abstraite est fournie pour simplifier la tache (&lt;code&gt;Zend_Controller_Plugin_Abstract&lt;/code&gt;). Notre premier plugin s'appellera &lt;code&gt;AutoView&lt;/code&gt; (&lt;code&gt;My_Controller_Plugin_AutoView&lt;/code&gt;, stocké dans &lt;code&gt;My/Controller/Plugin/AutoView.php&lt;/code&gt;).&lt;/p&gt;


&lt;p&gt;Un plugin est donc une classe dont les méthodes seront appelées a différents moments de la &lt;em&gt;dispatch loop&lt;/em&gt; du controlleur frontal, comme on peut le voir dans &lt;code&gt;Zend_Controller_Front::dispatch()&lt;/code&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;routeStartup()&lt;/code&gt;, à la mise en route du routeur&lt;/li&gt;
&lt;li&gt;&lt;code&gt;routeShutdown($action)&lt;/code&gt;, à l'arrêt du routeur&lt;/li&gt;
&lt;li&gt;&lt;code&gt;dispatchLoopStartup($action)&lt;/code&gt;, avant la &lt;em&gt;dispatch loop&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;preDispatch($action)&lt;/code&gt;, avant d'executer une action&lt;/li&gt;
&lt;li&gt;&lt;code&gt;postDispatch($action)&lt;/code&gt;, après avoir executé une action&lt;/li&gt;
&lt;li&gt;&lt;code&gt;dispatchLoopShutdown()&lt;/code&gt;, pour finir.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A chaud, on pourrait se dire que &lt;code&gt;postDispatch&lt;/code&gt; est exactement ce dont on n'a besoin, et on se tromperait. Ce qu'il faut savoir, c'est que l'argument &lt;code&gt;$action&lt;/code&gt; passé à &lt;code&gt;postDispatch&lt;/code&gt; contient l'action qui suit celle qui vient d'être executé. Dans la majorité des cas, n'ayant qu'une seule action à executer, &lt;code&gt;$action&lt;/code&gt; sera vide, et on se retrouve l'air un peu con.&lt;/p&gt;


&lt;p&gt;Bon donc, on va user d'un stratagème: notre plugin va stocker les actions qui passent dans &lt;code&gt;preDispatch&lt;/code&gt;, pour s'occuper de la dernière à être passée dans &lt;code&gt;dispatchLoopShutdown&lt;/code&gt;. Dernier détail, notre plugin s'occupera lui même de gérer son instance de &lt;code&gt;Zend_View&lt;/code&gt;. Et sans plus attendre, le code, qui n'a finalement rien de compliqué:&lt;/p&gt;

&lt;pre&gt;
&amp;lt;?php

require_once 'Zend/Controller/Plugin/Abstract.php';

class My_Controller_Plugin_AutoView extends Zend_Controller_Plugin_Abstract {

	private $_lastAction;

	public function __construct() {
		$view = new Zend_View;
		$view-&amp;gt;setScriptPath(APP_ROOT.'/views/');
		Zend::register('view', $view);
	}

	public function preDispatch($action) {
		$this-&amp;gt;_lastAction = clone($action);
		return $action;
	}

	public function dispatchLoopShutdown() {
		if (!is_null($this-&amp;gt;_lastAction)) {
			$viewPath = sprintf('%s/%s.php', $this-&amp;gt;_lastAction-&amp;gt;getControllerName(), $this-&amp;gt;_lastAction-&amp;gt;getActionName());
			echo Zend::registry('view')-&amp;gt;render($viewPath);
		}
	}
}

?&amp;gt;
&lt;/pre&gt;


&lt;p&gt;Bien, notre plugin vaillament codé, il nous faut désormais expliquer au controlleur frontal qu'on aimerai bien qu'il en tienne compte. Cela se passe fort logiquement dans le &lt;em&gt;bootstrap&lt;/em&gt;, via la méthode &lt;code&gt;registerPlugin&lt;/code&gt; du sus-cité controlleur frontal, qui prend en argument une instance d'un objet implémentant &lt;code&gt;Zend_Controller_Plugin_Interface&lt;/code&gt;:&lt;/p&gt;

&lt;pre&gt;
$controller = Zend_Controller_Front::getInstance();
$controller-&amp;gt;registerPlugin(new My_Controller_Plugin_AutoView);
&lt;/pre&gt;


&lt;p&gt;And viola !&lt;/p&gt;</description>
    
    
    
          <comments>http://mirmodynamics.com/post/2006/11/19/Zend-Framework%3A-Un-plugin-simple-pour-le-Front-Controller#comment-form</comments>
      <wfw:comment>http://mirmodynamics.com/post/2006/11/19/Zend-Framework%3A-Un-plugin-simple-pour-le-Front-Controller#comment-form</wfw:comment>
      <wfw:commentRss>http://mirmodynamics.com/feed/atom/comments/720</wfw:commentRss>
      </item>
    
</channel>
</rss>