26 | | Steps to migrate to Smarty: |
27 | | 1. develop a directory structure to separate PHP files, Smarty files, Template files (including Stylesheets) and Image files |
28 | | 1. document available Smarty functions/modifiers to be used in templates, best practice for using Smarty within PHP files |
29 | | 1. develop templates based on Grid system for all public visible files (TODO: find a way to test Templates with Smarty but without BOINC server) |
30 | | 1. implement new directory structure, Smarty and templates into BOINC source |
31 | | 1. change PHP files to use Smarty templates |
| 28 | TODO list: |
| 29 | * write a tra block plugin to translate template text directly using the pre-compiled php files in /languages/compiled/ (no need to use gettext as we do not use it anywhere else at the moment) |
| 30 | * transform sample_index.php into a smarty_index.php and index.tpl (possibly also header.tpl and footer.tpl) as a proof-of-concept |
| 31 | * document available Smarty functions/modifiers to be used in templates, best practice for using Smarty within PHP files |
| 32 | * find a suitable way to transform all other files |
| 33 | * transform ;) |
| 34 | |
| 35 | '''Ideas to how the actual transformation can be done:''' |
| 36 | * In general one should start with /user/index.php and transform all files that are directly linked from there and so on |
| 37 | * create a separate directory structure (/smarty_inc, /smarty_project, /smarty_user) with same filenames as original but copy and change only those functions that are neccessary for current transformation state OR |
| 38 | * work in same directory structure but rename files that contain already transformed functions (prepend a unique string that can be easily replaced after transformation is complete) OR |
| 39 | * use some kind of hybrid method by changing filenames and function names by prepending a unique string |
| 40 | * other suggestions? |
| 41 | |
| 42 | == Concept for integrating Smarty Template Engine into BOINC == |
| 43 | |
| 44 | '''Current directory structure of /html/ (installed project):''' |
| 45 | /inc/:: contains .inc php files that are included by .php files in /ops and /user, normally it's outside of docroot but should be secured to prevent direct access via browser |
| 46 | /languages/:: contains .po and .po.inc files to be used by php scipts in /inc and /user, normally it's outside of docroot but should be secured to prevent direct access via browser |
| 47 | /project/:: contains .inc php files that are included by php scripts in /user and /ops,normally it's outside of docroot but should be secured to prevent direct access via browser |
| 48 | /ops/:: contains .php files that are used for administrative operations (called via browser AND command-line), is available via http://PROJECTURL/PROJECT_SHORT_NAME_ops by default |
| 49 | /user/:: contains .php files that are used to interact with the users via browser (http://PROJECTURL/PROJECT_SHORT_NAME by default) |
| 50 | |
| 51 | '''directories that need to be added for Smarty:''' |
| 52 | /libs/:: contains smarty library (file smarty.class.php needs to be required by each .php file), should be secured to prevent direct access |
| 53 | /cache/:: contains smarty cache, should be secured to prevent direct access |
| 54 | /configs/:: contains config files to alter smarty behaviour (should probably go into /project/project.inc if applicable) |
| 55 | /templates/:: contains .tpl files that specify the look of the individual pages, should be secured to prevent direct access |
| 56 | /templates_c/:: contains cached files of templates, should be secured to prevent direct access |
| 57 | |
| 58 | '''How the smarty system works:''' |
| 59 | * .php files in /user gather all the data that should be shown to the user and assign this data to smarty-variables (using $smarty->assign()), at the end they call a template to be used to show this page ($smarty->display()). NO html code should be used here! |
| 60 | * .tpl files specify what smarty-variables are shown where in HTML source code. NO php code should be used here. There are special modifiers and functions provided by smarty to automate lists, forms and other stuff. |
| 61 | * to make text translateable in .tpl files the {tra} block can be used which is replaced by smarty compiler with the information from the language directory. This plugin has to be written and should use the funtions from /inc/translation.inc |