About 140 templates to change
Fortunately a lot of the changes can be automated, see below.
I'd be glad for any change to the current template/GUI code and I think the switch to smarty is the very simple and already gives a lot of benefit. Plus once everything is converted any additional change gets easier since we have less and smaller templates.
Going with another framework would be more like a complete rewrite.
Since I'd like to have this cleaned up I'll go ahead with the change until there is official word of a framework switch or similar. I'll try to sketch my current plan for you so you can imagine how long it will take and what will change:
- A global smarty object is created in the Initializer.php and put in the registry.
- Upon constuction of the smarty object a few default values like encoding and user logo are passed so this repetition can be eliminated from the .php files.
- The smarty template dir is set to "gui/themes/<theme>/" and "gui/themes/<theme>/<current user level>/". So calling $tpl->display( 'layout' ); in a client .php file and calling $tpl->display( 'client/layout.tpl' ); from a admin.php file will both use the same template: "gui/themes/<theme>/client/layout.tpl"
- For each user level (client, reseller, admin) there are three global base templates: layout.tpl, side_menu.tpl, top_menu.tpl. By default the reseller and admin versions just include the client version since everything uses the same layout in the default theme.
- For every page there is a content template. The "layout.tpl" contains the base page layout and {include}s both of the menu templates as well as the content template.
- The menus are now dynamic. Instead of "hardcoding" the menu items fully in the .tpl we'll have a single menu item in the generic menu templates and only need to fill in a few variables in the .php file to generate the whole menu (this also puts those TR_* in the right place).
This already gets rid of all the menu_ and mainmenu_ templates and it shortens all of the page templates by the header and footer as well as the menu include code.
Fortunately the existing templates can be reused with very few changes. A simple "s/{([A-Z])/{$\1/" already fixes most of the issues. Then the whole "define_dynamic" stuff can be removed and for the loops we can use "append" instead of "assign" and then loop over it using "{section}". Conditional parts just use {if} now.
This whole conversion process can actually be done gradually, i.e. having both the old and the new template system in use at the same time. There would be a lot of temporary code duplication for all the gen_* functions for which smarty versions would have to be implemented (mostly copies of the original function with minor modifications like getting rid of the "parse" and "define_dynamic" function calls and fixing the loops accordingly). As soon as every page is converted the old functions could be removed.
Now in case you are interested in this change:
I can provide you with a full patch as soon as I'm done, I would only request that there be as few changes as possible to the .php pages (meaning no major refactoring or re-styling) during my efforts in order to make the integration as painless as possible. I would provide status updates so nothing would be on hold with no end in sight.
As stated above this can also be done gradually, so with SVN access I could integrate this in smaller junks.
I can also provide a WIP patch if requested.