Showing posts with label web dev. Show all posts
Showing posts with label web dev. Show all posts

Friday, June 18, 2010

Symfony Form widgets for many-to-many relationship: a new widget implementation - part II

Following part I, here is the final step to code a new symfony form widget in order to improve a many-to-many relationship. After discussing the best UI possible for a many-to-many relationship, we are now going to look how to code it as a symfony widget. I would not pretend it is the best solution, but I believe it is clean enough to be used and it definitively works!

One of the comment point me to the following approach: http://www.ryancramer.com/journal/entries/select_multiple/. It is also an elegant way to do it, unfortunately it does not work for me since my list of available object is extremely long, therefore a select is again not a good approach. Don't get me wrong, my approach is not necessarily the best but it fits a specific user case.

Before starting you can have a look at a demo of what we will get at the end. Here is a video to show the different interactions.

Pre-requisite:

  • symfony 1.3/1.4
  • jQuery 1.4+ and jQuery UI 1.8+. This might seems overkilling for a simple widget but most of the time you are using these 2 libraries in your project already. In jQuery UI you specifically need for this widget the new autocomplete widget.

Ok, no more talk, let's go to the code! You can find it as a gist at http://gist.github.com/443124. Feel free to clone, improve and share! This code need some refactoring for sure but I did not have time yet and many people where asking for it. Feel free to improve it and share it ;-)

Stay tuned, we will publish some new widgets in the coming months...

Thursday, January 21, 2010

a new version for sfAdminThemejRollerPlugin 0.2

Finally! We finally managed to catch up and prepare a new version of our Symfony plugin to generate nice admin generator based on jQuery UI Themes.

We tagged this version as 0.2.0 since we still consider this plugin as beta version (but usable on production) but the big news is the support of symfony 1.4! For this specific support I must thank you 2 people that submited 2 patches to make this compatibility possible. Thanks to ( jtexier , "merci Jerome ;-)") and dalexandre and of course I must named jeremyb for his dedication to the project, he did most of the latest development.

I also setup a live demo to allow you to play a little bit with the plugin. It is currently basic but we will add more stuff step by step.

What's new:
  • Theme switcher integrated
  • user interface fixes and enhancements
  • Symfony 1.4 compatibility

You can have some more details on my previous post.

The plugin is available as usual on github, I published as well the packaged plugin on symfony website.

jroller-v0.2-list.png



jroller-v0.2-filter.png


jroller-v0.2-listbottom.png


Screen shot 2010-01-21 at 10.48.44 AM.png

Monday, November 9, 2009

what's up on sfAdminThemejRollerPlugin?

I finally found some time to add new stuff on the unpronounceable plugin, and thanks to some new contributors more are to come (thanks JeremyB ;-). Here is the list of change:

  • As I mentioned in my previous post, I add a new config field named 'show' for the admin generator. I guess the meaning of this new option is quite obvious, isn't it? It adds the possibility to simply view one object details without editing it. It currently shows the list of fields like it is for the 'edit' view, meaning with a tab interface.
    jroller-list-showbutton.png
  • UI improvements (done by jeremyb): as you can see in the 2 screenshots below there are many improvements such as the new 'reset' button next to the filter button, the sort arrows, new css styles for object actions, new pager view and finally the batch action select box is now also supporting the theme roller


The top part looks like this:
sfAdminThemejRoller-20091109-1.png

  • notice the new 'reset' button next to 'filters'

  • the up and down arrow on the table column names

  • the new css style for the object actions



...and the bottom part (new paginator and the select box is also styled according to your roller theme):
sfAdminThemejRoller-20091109-2.png


the edit view (buttons are accessible both on top and button of the form, tabs are now vertical):
sfAdminThemejRoller-20091109-3.png


The current code is available in github only. It is not yet ready for a new plugin release, we are still missing some key elements.


Saturday, September 5, 2009

new version of sfAdminThemejRollerPlugin (v 0.1.4)

I have finally released a new version of this plugin with an unpronounceable name ;-) Here is the list of change:

  • I add a new field named 'show' for the admin generator. I guess the meaning of this new option is quite obvious, isn't it? It add the possibility to simply view one object details without editing it. It currently shows the list of fields like it is for the 'edit' view, meaning with a tab interface.

  • I also create a new class jRollerDoctrineGenerator to replace sfDoctrineGenerator if you want the default link (the one you create with the = sign before the field name in the generator.yml) to link to the 'show' view rather than by default going to the 'edit' view. So far this is the only added value of this class. Of course if you prefer to keep the link to the 'edit' view simply keep the default class sfDoctrineGenerator. To use it, you simply need to modify your generator.yml as followed:



generator:
class: jRollerDoctrineGenerator
params:
theme: jroller
....


The source code is available on github for the moment, I want to finalize a few things before packaging a new plugin version. I also need to put the source code on svn.

jroller-list-showbutton.png

Friday, August 14, 2009

Symfony batch and i18n + pdf generation

A few months ago, I wrote a post about i18n in batch and pdf generation. At that time I could not find a way to manage translation in symfony batch (for example when you need to send email to customers, etc...). In Symfony 1.2, batches are depreciated in favor of tasks but my project is still in symfony 1.0 (and I guess the same can be applicable in 1.2). Anyway, I finally found a way to do it:
sfLoader::loadHelpers('I18N');
$I18N = sfContext::getInstance()->getI18N();
$I18N->setMessageSourceDir(SF_ROOT_DIR.DIRECTORY_SEPARATOR.SF_APP.DIRECTORY_SEPARATOR.'i18n', $culture);
echo __('text to translate');

I am not sure if it is the best solution, but it definitively works.

On the pdf side, I was mentioning that in order to generate invoices in pdf, I created some pdf invoice templates with Open Office Draw. Following this step, I was able with Zend_Pdf to generate PDF files on the fly based on my templates. The big problem with this solution is that you have to positionned all your text at the pixel and cannot manage things like multiple lines text and so on. You end up writing a lot of stupid code and anything you want to modify you have to try again and make sure it works (and when you manage several languages it can even be more complex). Anyway I managed to do it like this for the billing system used in East-Timor but I always wanted another solution. I did find some promising project but nothing yet reach a usable state to my knowledge. However, I found to interesting projects:

  • odtPHP: it is not as such a pdf generator but it looks fantastic to generate open documents easily with a templating system. It is great and I am sure I will use it soon. Once you have an open document, it is a piece of cake for anybody to save it as pdf...even my grandma could do this ;-)

  • Podr: it's a kind of open office server to generate document on the server, including pdf. However it seems only working on windows and quite heavy installation, I am not sure if it is a good solution. Anyone using it?


odtPHP looks like a clean and nice php class and it should be easy to integrate in symfony. On the client side, if you do not have open office (or any odt compatible solution) you can simply install a plugin for Microsoft Office to support open document formats (it seems it is even native support in Office 2007 service pack 2): http://www.sun.com/software/star/odf_plugin/ or http://sourceforge.net/projects/odf-converter/.

Monday, December 22, 2008

Symfony batch in my i18n nightmares

I was working on a new version of the billing system for utilities (used by the national electricity company in East-Timor), adding a bunch of new features including PDF generation for invoice and some reports. I decided to use Zend_Pdf and I believe it is a good choice.

Generating PDF is not something really fun. I used a template pdf and feed it with all the customer information I want. For each single piece of data you want to add, you must provide the position in the page, the style (if you want to change it)...a real pain! I wish we can have a more powerful templating system. It seems some guys have some plans (and codes) but nothing yet release (see mailing list here)...hey! (almost) good news: while I was looking for the link I found that they did release their PDF library (not yet in Zend, nor compatible with Zend_Pdf) named "RE Framework". I need to have a look one of this day...

Anyway, I was thinking to generate all invoices (in DB + PDF version) through a batch in symfony. I started working on it when I faced a "simple" problem: I need to use i18n for each invoices (invoice in the language of the customer), but from a batch I am always getting an error message since it does not have a user and culture define. I tried to initalize a fake one...but no luck. I need to try harder... ;-)

Any ideas?

Wednesday, December 10, 2008

Thematic Mapping Engine

A very interesting web app (open source of course ;-): Thematic Mapping Engine.
You can play with it online, it is really well done. I hope I will have new opportunity to work on the geospatial arena later next year, I would love to do things like this...