SF Operation Overview
The diagram below represents SF running on 'default' values.
Figure 1 - phpSiteFramework Operational Overview
Setup
Due to the Apache directory settings made during setup there are two things which determine how SF enabled directories work:
- firstly all .html files are parsed by PHP
- secondly, all files parsed by PHP automatically start with SF_autoprepend.php
SF_autoprepend.php
SF_autoprepend.php is the 'core' module and does the following things:
- loads the SF_cacheconfig.php file;
- processes any query strings ;
- determines, if caching is on, whether this request can be delivered from cache ;
- loads SF_mainmodule.php ;
- if necessary deals with content pre-processing, text only display, or settings for print version display;
- 'includes' (displays) the configured header file (default=SF_defaultheader.html);
- 'includes' (displays) the current content page (essentially $_SERVER['DOCUMENT_ROOT'] + $_SERVER['PHP_SELF']);
- 'includes' (displays) the configured footer file (default=SF_defaultfooter.html); and
- does a 'hard' PHP exit().
It is a 'quirk' of the way the framework (and SF_autoprepend.php in particular) is designed that Apache/PHP never actually gets to deliver the content file in the traditional sense; SF_autoprepend.php does all it needs to do (including outputting the contents of the content file) and then PHP exit()'s before anything else can happen.
SF_mainmodule.php
SF_mainmodule.php does five important things:
- loads the SF_mainconfig.php file providing SF with its global configuration values
- it gets 'include'd - there by making all the SF functions which it contains available for use in header, content and footer pages;
- it processes the SF_config_site.csv file which tells SF which directory configuration file to load depending on which directory we are in (or more specifically, the path for content file which has been requested).
- it processes the nominated directory configuration file (default = SF_config_dir.csv) based on the directory we are in (or more specifically, the path of the content file which has been requested) which determines:
- which menu config file to load,
- which menuset and menusubset from that menufile should be made 'current'
- which header, footer and css files to use
- whether to pre-process content-files or not
- it processes the nominated menu configuration file which populates the global menu array and a current menu array (based on the currently loaded page or directory, whichever is the best match). This 'menu data' is then used by a range of SF functions, e.g. SF_GenerateNavigationMenu()