-
Notifications
You must be signed in to change notification settings - Fork 0
Structure
Here we have a look at how the page is rendered when surfing a jeff page. The Jeff's entry point is the index.php file. All requests (except from pointer type request, used for ajax tasks) pass through it.
##Permalinks Jeff supports permalinks thanks to some rewrite rule written in the .htaccess file. One TODO thing could be move the logic of rewriting inside Jeff, by writing something like a proxy.
So a permalink like
http://www.example.com/news/view/5
will result in a request like http://www.example.com/index.php?module=news&method=view&id=5
Onother example:
http://www.example.com/news/view/ctg/3
will result in http://www.example.com/index.php?module=news&method=view&ctg=3
Read the .htaccess for a complete understanding of how the rewriting works.
##What happens in index.php?
- the absolute path to the root directory is stored
- some files are included:
paths.php: sets some system paths used by the application
configuration.php: the configuration file edited during installation process
core/core.php: the core of the application - the core class is instantiated and its method renderApp is called (this is the method that outputs the entire document)
##What happens when constructing a core instance?
When creating the core instance, other files are included, tables.php file containing the definition of all tables used by jeff as constants, and include.php file which contains the php autoload methods and some other file inclusions.
Then comes a very important point: the registry object is instantiated and some of its properties are set (some jeff default privileges and the leading db instance).
The registry object is a sort of singleton working like a global object shared by all modules and objects throughout the application. It stores stuffs used by all objects and properties evaluated when rendering the document that are set at runtime by the modules instantiated.
##What does the core renderApp method do? Well here are set some important registry properties: used theme, navigation language, site settings object, a datetime manager object, the router object and some site properties. Then the application checks for user authentication and finally instantiate a document object. The output of the render method of the document object is flushed and so the document is generated.
The document object get the template in use (accordingly to the requested url). Its render method sets some initial document properties which may be overwritten by the modules called by the template engine. Then the template engine parses the template in use replacing its dynamic and static contents pointing to modules methods with the same methods outputs. So the entire document is rendered.
The template parsed by the engine called by the document object is the global one. It contains the xml declaration, and the entire site structure between <html> and </html>
Inside it variables (resolved with the matching registry properties) and module's outputs are mixed with html.
The variables are resolved using the values of the matching registry properties.
The modules' outputs are resolved using the return values of the methods called. Every module method which return an output generally (some forms methods except from that) makes use of a module level template system. That is every module has a default view instance which renders module's templates evaluating the context variables it finds.
Back to Index