The blog of COil : PHP, symfony & Web 2.0

Strangebuzz...?

Réduire au titre / collapse all

25/03/2008

» symfony : traduction FR de la cheatsheet Ajax

[FR] J'avais traduis il y a quelque temps la cheatsheet sur les helpers ajax realisée par Andréia Bohner. En fait il ne m'avait pas répondu très vite donc elle était un peu tombée aux oubliettes. J'avais fais cette traduction un peu vite fait et mot à mot donc le résultat n'est pas tip-top. :/ Donc si vous avez des propositions de modifications à n'hésitez pas, je peux les regrouper et envoyer la mise à jour à Andréia. Sinon ça pourra toujours servir à quelqu'un ne parlant pas un mot d'anglais ni de portugais. ;)

Traduction française de la cheatsheet ajax symfony



18/03/2008

» Symfony tip : Registration of plugin routes

[En] Here is a little tip Fabien gave me. I am actually developing a plugin witch has quiet a lot of routes (about 40). Normally you can add the routes with the prependRoute function, like does the sfGuardplugin.

<?php
if (sfConfig::get('app_sf_guard_plugin_routes_register', true) && in_array('sfGuardAuth', sfConfig::get('sf_enabled_modules', array())))
{
  $r = sfRouting::getInstance();
 	
  // preprend our routes
  $r->prependRoute('sf_guard_signin', '/login', array('module' => 'sfGuardAuth', 'action' => 'signin'));
  $r->prependRoute('sf_guard_signout', '/logout', array('module' => 'sfGuardAuth', 'action' => 'signout'));
  $r->prependRoute('sf_guard_password', '/request_password', array('module' => 'sfGuardAuth', 'action' => 'password'));
}
?>


But for each prependRoute call an array_merge is done on all existing routes.

<?php
  /**
   * Adds a new route at the beginning of the current list of routes.
   *
   * @see connect
   */
  public function prependRoute($name, $route, $default = array(), $requirements = array())
  {
    $routes = $this->routes;
    $this->routes = array();
    $newroutes = $this->connect($name, $route, $default, $requirements);
    $this->routes = array_merge($newroutes, $routes);
 
    return $this->routes;
  }
?>


So the tip here is to save all routes, clear them, add the routes of the plugin and then append the saved routes. Witch can be done like this:

<?php
  // Save and clear all routes
  $r = sfRouting::getInstance();
  $routes = $r->getRoutes();
  $r->clearRoutes();
  
  // Plugin home
  $r->connect('plugin_home', '/my_super_plugin/homepage', array(
    'module' => 'my_plugin_module', 
    'action' => 'my_plugin_action',
    'additional_parameter'   => 1
    ));
 
  // Another route
  $r->connect('plugin_home', '/my_super_plugin/section1', array(
    'module' => 'my_plugin_module', 
    'action' => 'my_plugin_action_section1',
    'additional_parameter'   => 2
    ));
 
  // ... other routes
 
  // Then merge new routes with the saved one
  $r->setRoutes($r->getRoutes() + $routes);
?>


That's it. :) Of course it is always better to have all routes of the application in the routing.yml but in my case it was not possible.

02/03/2008

» sfLightboxPlugin 1.0.6

[En] New version with the last version of lightbox (2.03.3) + new helpers. You can check the demo here on my blog.

  • Updated lightbox library to v2.03.3
  • 3 new helpers (light_image_text, light_slide_image, light_slide_text)
  • New parameter for images slideshows to allow to display images as a html list (li..)
  • Slideshow navigation with the keyboard (left, right, ESC)


Thanks for your feedback ! Enjoy. :)



[Fr] Nouvelle version incluant la dernière version de lightbox (2.03.3) et quelques nouveaux helpers. Vous pouvez visualiser la demo ici sur mon blog.

  • Mise à jour de la librairie lightbox pour la version v2.03.3
  • 3 nouveaux helpers (light_image_text, light_slide_image, light_slide_text)
  • Nouveau paramètre pour les slideshows pour afficher les images comme une liste html (li..)
  • Navigation dans le slideshow à l'aide du clavier (gauche, droite, ESC)


Merci pour votre feedback ! Enjoy. :)

sfLightboxPlugin 1.0.6

» Autres billets / Other post