THIS FILE CONTAINS THE TEMPLATE LOGIC FOR THE UNLIMITED INHERITANCE SYSTEM. ****** USE TEMPLATE LOGIC ::: < DB STORAGE LOGIC > ****** CVS: $Id$ ############################################################################### RUN-TIME LOGIC ---------------------------------------- DB STYLE STORAGE ---------------------------------------- + Store a serialized array of the inheritance order, sorted by the inherit order starting from the master style + Store a serialized array of all the child styles + Store the value of the style that it is directly above the style ---------------------------------------- LOAD TEMPLATES FROM DATABASE ---------------------------------------- + First, get the current style row; figure out using the serialized parent inheritance branch what styles will also need to be received + Using the styleids in the above method, get all the templates for those styles. Store all of the templates in a multi-dimensional array formed as: array(STYLEID_ORDERED_BY_INHERITANCE => array(TEMPLATE DATA)). This setup will allow us to walk the array and replace the template each time with the value (if it exists) thus it inherits the template from the bottom most customized style ---------------------------------------- ADMIN TEMPLATE MANAGER ---------------------------------------- + First, get the current style row; figure out using the serialized parent inheritance branch what styles will also need to be received + Using the styleids in the above method, get all the templates for those styles. Store all of the templates in a multi-dimensional array formed as: array(STYLEID_ORDERED_BY_INHERITANCE => array(TEMPLATE DATA)). This setup will allow us to walk the array and replace the template each time with the value (if it exists) thus it inherits the template from the bottom most customized style + Output template information as template list ---------------------------------------- CONCLUDING REMARKS ---------------------------------------- This system requires a lot of run-time logic that could bring the system to its knees if there is a lot of inheritance and templates. On the other hand, it is very easy to implement and requires little style row storage. ############################################################################### DB STORAGE LOGIC ---------------------------------------- DB STYLE STORAGE ---------------------------------------- + Store a serialized array of the inheritance order, sorted by the inherit order starting from the master style + Store a serialized array of all the child styles + Store the value of the style that it is directly above the style + Store a serialized array of templateids that have the inheritance pattern already laid out (the templateid will be the bottom most customized template) ---------------------------------------- LOAD TEMPLATES FROM DATABASE ---------------------------------------- + Fetch the style row and unserialize the templateid array. Find the templates that are used in the page in the array and query those templateids ---------------------------------------- ADMIN TEMPLATE MANAGER ---------------------------------------- + Get all style row and fetch all the templates in the templateid column and output the template list + On update display order, update template, update style rebuild the templateid list, childid list, bottomparent, and inheritance list ---------------------------------------- CONCLUDING REMARKS ---------------------------------------- This system is good for lots of templates and inheritance. The data that sorts that information is cached and is only propagated upon administrative template action. On the other hand, it does require more database storage if there are a lot of templates. However database overhead < time taken for sorting the information, making this much more effective than the run-time logic.