Application Framework
The Contento Content Management System uses a custom framework created by Copyleft and is based in the popular Fusebox Application Framework, originally created for Macromedia Coldfusion.
The framework is aimed at making is easy to create and maintain web applications. It does this by helping us to structure our application and break things down into distinct “circuits”. The framework consists of a set of core files which handle much of the plumbing necessary when creating a web application. It also uses a few configuration files to define the application settings as well as declaring what each circuit does and what actions within each circuit executes.
Contento is Free Software.
Important Files
/index.php
Defines the main constants used in the website and transforms all the data sent by GET or POST into an array called $var. It also calls the main dispatcher file and calls the file action.
/includes/dispatcher.php
Defines the circuit and action to execute depending on the url.
/includes/database.php
Defines the class created to send queries to the MySQL database.
/includes/error404.php
Custom error 404 page.
/includes/functions.php
Defines most of the functions used in the application
/includes/lists.php
Custom functions to handle lists
/includes/imageheader.php
Function to generates PNG images of text, written in the font/size that you specify.
/includes/savecontent.php
Defines the main class used by the framework to structure the application.
Friendly URLs
In order to improve usability and Google compatibility the system uses what is commonly called “Friendly URLs” which provide URLs such as www.website.com/news/contento_is released.html instead of the typical www.website.com/index.php?id=23451?function=showit. Contento uses Apache’s mod_rewrite module to create friendly urls which need to be enabled. The Apache configuration file or .htaccess file should include something similar to this:
RewriteEngine on
Options +FollowSymlinks
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* ./index.php [L]
Apache also requires to set AllowOverride All in order to enable the options above.
Using Contento Framework
HOWTO: Locating Contento modules
For example:
- index.php separates /content/about_us.html from the url and put them into $url
- dispatcher.php breaks $url to get the module and permalink and put them into $dispatcher
- Look into the main case to find the module directory:
case "content":
$module = "frontend/content";
$action = "main";
break;
index.php searches for $module."/".$action.".php" if it exists includes the file else includes error404.php
DBQueries
DBQueries is a class created to reduce the amount of code needed to send queries to the MySQL database.
Initialize the class:
$DBQuery = new DBQueries;
Send login parameters:
$DBQuery->attrib['DBServer'] = “localhost”; (default localhost)
$DBQuery->attrib['DBUser'] = ”username”;
$DBQuery->attrib['DBPwd'] = ”password”;
$DBQuery->attrib['DBName'] = “database”;
Send query:
$DBQuery->attrib['query'] = "SELECT id_news, title FROM news";
Run query:
$getData = $DBQuery->RunQuery();
The class uses the first 6 characters to define the query type, it only accepts INSERT, SELECT, DELETE and UPDATE.
If the query type is SELECT the class returns an array containing all the records returned by the database, (example. Using the case above you can use $getData[0][‘id_news’] to get the first record or count($getData) to get the Record Count).
If the query type is INSERT the class returns the auto_increment ID returned by the database.
If the query type is UPDATE the class returns TRUE if successful or FALSE if the query failed.
If the query type is DELETE the class returns TRUE if successful or FALSE if the query failed.
In case of a SQL error the class returns FALSE and displays the error.