Changes between Version 3 and Version 4 of WebTemplateProposal


Ignore:
Timestamp:
Nov 24, 2011, 5:25:25 AM (13 years ago)
Author:
Christian Beer
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • WebTemplateProposal

    v3 v4  
    1515All tools can be updated separately after implementing into BOINC source code.
    1616
    17 Problems to avoid '''(currently investigating)''':
    18  * make internationalization work with caching (old plugin: [http://smarty.incutio.com/?page=SmartyGettext Smarty gettext], still usefull?)
     17Problems to avoid:
     18 * find out how to tell the smarty compiler what language is currently used so cached files are useable (I already read this in the documentation just need to find it again)
    1919 * allow project specific template enhancements or replacement without tampering the standard templates
     20 * HTML is used widely in .php and .inc files and is echo'ed by a lot of functions directly, this must be changed so that functions in /inc return a string to the calling script or function
     21 * As this is a lengthy task and development and bug fixing goes on with the normal source code it will get difficult to merge changes with already transformed code
    2022
    2123What using Smarty means:
     
    2426 * Ouptut of lists must be assigned to arrays that can then be iterated by Smarty within the template (Sample follows)
    2527
    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
     28TODO 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