The Core
At the heart of the web-frontend of Confusa (yes, you have other sections, the
Robotic Interface and the
OAuth part). The framework does several things:
- Ensures a consistent layout of the page
- Places important security-measures in a single place
- Provides a catch-all error capability so even a severe error can be handled and presented to the user in an intelligent way
- Implements a central authentication schema. The authentication-assertions will be enforced in one central location.
The framework relies heavily upon PHPs object-oriented model. Each page that is rendered via the Framework must be a subclass of ContentPage. This then forces the class to implement a set of functions the framework will call.
At a minimum, process() must be implemented, but there are more tools available:
-
pre_process($person) (optional) This will be called before the main processing starts in Framework, but after the authentication happens. If you need to redirect the browser, you must do this here. Also, if you need to export variables that directs the main rendering of the page, this is also the place.
-
process() (required) is the main function. It is called after the page-rendering has begun, so redirects etc will not be possible from here. This is where you should place most of your logic.
-
post_process() (optional) should be called if you need to do post-processing after the main rendering has finished, but before variables have been unset etc. This function is normally not used.

How does Confusa render a given page
The following snippet is a rudimentary approach to what you need to make a page. It will not require authentication, it will be visible for both authenticated users and anonymous.
1 <?php
2 require_once 'confusa_include.php';
3 require_once 'Content_Page.php';
4 require_once 'Framework.php';
5
6 final class CP_Test extends Content_Page
7 {
8 function __construct()
9 {
10 parent::__construct($title = "Test", $protected = false);
11 }
12
13 function process()
14 {
15 $this->tpl->assign('content', "<h1>Hello World</h1>");
16 }
17 }
18 $fw = new Framework(new CP_Test());
19 $fw->start();
20 unset($fw);
21 ?>
Code walkthrough
- Line 2 includes the master include file. This sets the path correctly and makes the subsequent require-statements possible
- Line 3,4 gets the Framework and the Content_Page
- Line 8-11 instantiates the page-object, and notifies Content_page of the page-title and that it is not a protected page (does not require authentication).
- Line 13-16 implements a very basic process-function. This will cause Confusa to display "Hello World" in big letters, all in the same layout as all the other pages.
- Line 18 creates an instance of the Framework (this is, after all, what makes the page) and gives it the current page as argument.
- Line 19 then starts the process of rendering the page. During which, the Framework will use the callback-functions in Content_Page, eventually calling process(), resulting in the "Hello World" being added to the content-area of the 'Canvas'.