LEPTON Coding Styles
We periodicaly check our code with the tool from Sonarcloud to decrease number of bugs and security spots.
Naturally there are some internal conventions that may differ from Sonarcloud's standards.
Please see below the differences for LEPTON for our own standard. There are very good reasons to have sometimes our own defaults for example the LEPTON_autoloader searches for own classes (core and addons).
File Header
You have to include following code in every single php file to protect the whole cms and probably your custom addons.
- // include secure.php to protect this file and the whole CMS!
- if(!defined("SEC_FILE")){define("SEC_FILE",'/framework/secure.php' );}
- if (defined('LEPTON_PATH')) {
- include LEPTON_PATH.SEC_FILE;
- } else {
- $oneback = "../";
- $root = $oneback;
- $level = 1;
- while (($level < 10) && (!file_exists($root.SEC_FILE))) {
- $root .= $oneback;
- $level += 1;
- }
- if (file_exists($root.SEC_FILE)) {
- include $root.SEC_FILE;
- } else {
- trigger_error(sprintf("[ <b>%s</b> ] Can't include secure.php!", $_SERVER['SCRIPT_NAME']), E_USER_ERROR);
- }
- }
- // end include secure.php
Default Class Names
In LEPTON we got following internal standards:
1. LEPTON core classes are named LEPTON + _classname, for example LEPTON_admin
2. Addon classes are named like the template or module itself to be automatically loaded
via LEPTON_autoloader, for example semantic (for standard LEPTON template) or news (for news module)