Monday, August 24, 2009

sfAdminThemejRollerPlugin: Symfony admin generator on steroid

It's been a while since I wanted to work on my own admin generator theme. In symfony 1.0 the default admin generator was not really nice, it became a little bit better in 1.2 but still not to my taste (purely subjective I must admit ;-). For example, one thing get me mad is the css for the table list and the filter, I believe that the table list should be maximized and filters available only when we need them.
I spent quite some time to modify some admin generator in some projects but you always end up doing the same thing over and over (see this screenshot of what I have done with the list view based on a standard admin generator)...it was time to make things more to my taste. I now have a pretty clear idea of things that I would like out of the box from my new admin generator. Let me be more specific with the complete list of things I would like:

  1. Change css style to a more modern style (again purely subjective ;-) that can be changed easily. For this I am using jQuery UI with their new theme roller system. The plugin is packaged with only one theme but it is extremely (too?) easy to change to your favorite theme (long term will be to use the upcoming html5 grid).

  2. The filter box is hidden by default with a button to show/hide a modal window with the list of available filters. This allows to have a larger space for the table list.

  3. In the new/edit views fieldsets are replaced by tabs (again jQuery UI).

  4. Add a show only view, it makes sense for some application to allow read-only access.

  5. filters ala iTunes smart playlist, meaning you select fields you want to filter and add them (nice to have but not so important, although useful if you have a lot of filter options)

  6. Print preview (configuration in generator.yml): simply a non paginated table easy to print with sortable column (javascript grid style)

  7. live search (configuration in generator.yml): be able to quickly filter the table list while typing a few characters, ajax style. I did that before for one specific module, I now have to make it part of the admin generator.

  8. export to CSV format: we could have a modal window to select the fields we would like to get and export them or simply a list defined in the generator.yml (which can include getters that are not database fields).

  9. export to PDF: does it make sense at all, I am not yet sure!

  10. Import CSV to database: to be able to simply upload a csv file of data to import through the admin generator.



The first 3 items are easy to do just by modifying existing admin generator templates and are indeed already packaged in the plugin. The rest need more work (still learning how admin generator are working deeply).

I am also trying as much as possible to keep all actions accessible without javascript and make sure that I do not break any default admin generator css classes and ids in case you need them.

"Stop talking and show us the code"...here you go! It is published as a symfony plugin at http://www.symfony-project.com/plugins/sfAdminThemejRollerPlugin, meanwhile here are some screenshots:
jroller-list-themes.png

jroller-list-filters.png

jroller-form.png


How to install?


./symfony plugin:install sfAdminThemejRollerPlugin --stability=beta

When I say beta, it is beta ;-) I am not fully satisfied with the code and still thinking about the best approach for some features (not mentioning it's my first play with admin generator). Feel free to give me feedback.
I will publish the code on github later to ease collaboration if any of you are interested. Anyway, it's php right? so you can play with the code right now!

How to use it?


./symfony --theme=jroller doctrine:generate-admin


or if you have an existing admin generator, simply modify your generator.yml file with
theme: jroller
instead of theme: admin.

Configuration


I currently package jQuery 1.3.2 and jQuery UI 1.7.2 to make sure it can work out-of-the-box, but it is also easy to specify in your app.yml file that you do not want to use those versions (or because you already include those libraries in your project) and include your own jquery and UI.
jQuery UI is using at the minimum: Tabs, Dialog (Drag and drop and resizable recommended).


# inside your app.yml file
sf_admin_theme_jroller_plugin:
web_dir: /sfAdminThemejRollerPlugin # specify specific folder where to pick your jquery stuff, ui and themes.
use_jquery: true # default. use the packaged jquery/UI
theme: redmond # default.
css_reset: true # default. reset default css (from Blueprint CSS)


What's next?


I will try to implement the rest in the coming months (I just found out that sfDoctrineAdminGeneratorWithShowPlugin start to implement some of my ideas), again feel free to contribute to speed up the process.

Bugs? no way!



  • I still have a pixel problem with the caption and tfoot of my table, if anyone knows how to solve it?




You will probably find bugs, please report them.

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/.

Wednesday, August 12, 2009

A Mac tool for MySQL: Sequel Pro 0.9.6

In the past month or so I have been using SequelPro (http://sequelpro.com/) for my local MySQL usage. At that time it was version 0.9.5 and it was quite interesting for local usage, however it was still missing quite a bit of information compare to a tool like phpMyAdmin and one big limitation (at least for me) was the connection type used: only on the MySQL port. There was no way yet to establish a SSH connection to connect to remote databases. Most of the time a goog MySQL server should not accept external connection, therefore a ssh tunnel is the only solution for such cases when you want to use desktop app.

Fear not anymore! Version 0.9.6 has been released and I must admit it is a huge improvement regardless of the limited increment on the version number. It has ssh support and much much more. I can now connect to all my databases servers around the world easily through only one interface. On top of the ssh connection they add support for foreign key, add new view such as 'Relations' and 'Table info' and history of your actions. This is certainly now the tool I am going to use, even more than phpMyAdmin.

sequelpro096.png

Thursday, June 18, 2009

Are you tethering?

Connecting my laptop through the iPhone is extremely simple (go in Settings -> General -> Network) and a clear message is always available on top of the screen. Well done and very useful sometime.









What I found really useful is the landscape mode, when you need the keyboard is a big difference and a huge improvement for emails, blogging...



The last thing I tested so far is the copy/paste, this is a so basic feature but you end up using it a lot.
I'll come back as soon as I found new useful features...

-- Post From My iPhone

Wednesday, April 1, 2009

Charting Experiments

Data visualization on the web has been for a while an area without much innovation. You basically had 2 solutions:
  1. Generating a static image on the server side
  2. Using flash as a way to make more dynamic graphs
Unfortunately both solutions have their own limitations. For the server-side image generation it is obvious: the result is static. For flash: flash itself can be a limitation since it is not an open standard.
Since a year or so, we did see some simple solution based on canvas (html5) but now some groups are experimenting more advanced solutions based on web standard. 2 solutions that I really find interesting are Protovis from a Stanford University group and Processing.js from John Resig (Mr jQuery himself). They are still experimentation but they show a new approach with a real touch of innovation. Let's now wait to see if they will become more than lab research tools, I do believe!

Friday, March 6, 2009

(not) welcome to Macau

A drawing from South China Morning Post after a couple of HK residents have been rejected to enter in Macau (journalists, politicians...). Even China is accepting them...
Things are not really going well here related to human rights. There are more and more "VIP" people from HK rejected and nobody knows why. The local government did not explain anything...spring is going to be hot between Macau and HK ;-)



-- Post From My iPhone

Monday, March 2, 2009

Gmail on steroid


The guys in Google working on Gmail are not stopping their innovation while the crisis is around...and this is good for us! They have launched (in beta only, within the "labs") a couple of very useful features:
  • Tasks. You can simply add email to a todolist, it is simple but extremely useful. From there you manage your task (due date, completed, related email,notes...). I started to use it and did not stop.
  • Offline mode. This is a killer feature for sure! With Google Gears installed (while HTML5 is on the way) you can use Gmail even without any Internet connection. This is a big step forward to make Gmail a powerful tool. This offline is also available for Google Reader and Documents (Calendar is also coming). With those enhancements (plus a couple of smaller one), I gave up to use Apple Mail for my main pro email account, Gmail is really convenient.
  • Gtalk plugin. A few month ago Google release a browser plugin to add audio and video to your Gmail chat. Basically you got a skype replacement inside Gmail, this is great too.
There are many more new "Labs" features that could be useful for anyone, don't miss them!

Since I know that all those good guys in Google are reading my blog everyday ;-) I would like to request a few more things:
  1. please help us to easily manage multiple gmail accounts.
  2. If Google Gears was able to install in Mozilla Prism we could have a kind of desktop client for GMail...and first point would be already solved!
Don't forget that all those new features are provided in "Labs" and are still experimental.