kOOL basics for developers
Files and folders
The actual code of kOOL is stored in a lib directory which is the same for every kOOL installation on one server. This eases the update and allows the usage of php accelerators.
For every installation of kOOL there has to be one web directory that contains some files specific to this installation. Through the symbolic link kOOL_lib, which must point to the source lib directory, each web directory has access to these source files. Read the installation instruction for more details.
Structure of the code directory (lib)
||Is opened as a popup window to show a download link for a generated file
||Contains fpdf.php and mc_table.php from the FreePDF library
||XML access to some kOOL data. Can be used by external applications like TYPO3 extensions
||Script that generates an iCal (.ics) file of the events
||CSS specific to IE6
||CSS specific to IE7
||Globally used images
||Scripts for installation and update. Webbased installation. Default files for web folder
||Global CSS file which can be overwritten by ko.css in web folder
||Contains all language specific files
||Shows and processes login menus. Uses ko_menu.tpl
||Smarty template engine (see smarty.php.net)
||All the smarty templates
||One directory for every module
Directory structure for one module
- index.php (Main page for this module)
- MODULE.inc (PHP code only used in this module)
- ajax.php (AJAX used in this module)
- [...] (Any other module specific files)
- [...] (Any other module specific files)
Directory structure of the web folder (one for each installation of kOOL)
||Files with configurations specific to this installation
||Modules, db account, ldap account, sms account, plugins, etc.
||Additions to KOTA
||Layout for the form to edit people
||Files to be downloaded will be stored here. Must be writable for the webserver process
||Exported rota plans
||Exported Excel files
||Redirection to root directory
||Exported pdf files
||Footer on every page except for the front page
||Images used for PDF export in this installation of kOOL
||Fonts used for PDF export in this installation of kOOL
||Header on every page, displayed above the menu
||Real directory with linked files
||Webbased installation for the first installation
||CSS file specific to this installation which can overwrite definitions in kOOL.css
||Link to the source lib directory of kOOL. All other linked files in the web directory link to kOOL_lib
||Images specific to this installation
||Templates cache for smarty
||Folder used for the webfolders
||Contains the same folder structur as webfolders but only with the .htaccess files
||Real directory with linked contents. Additional files possible.
Code structure of MODULE/index.php
The basic structure of html is as simple as possible:
- Header with the menu (menu.php) plus header.php
- The main area which is split into three columns:
- Submenus to the left (id=main_left)
- Content (id=main_content)
- Submenus to the right (id=main_right)
- Footer: The last part of the main table, </table>
comes after footer.php
Structure of the PHP file
include_once($ko_path . "inc/ko.inc");
list($item_view, $item_new, $item_edit, $item_mod) = ko_get_admin("daten", $_SESSION["ses_userid"], $group_view, $group_new, $group_edit, $group_mod);
$hooks = hook_include_main("daten");
if(sizeof($hooks) > 0) foreach($hooks as $hook) include_once($hook);
include($ko_path . "menu.php");
print ko_get_submenu_code("daten", "left");
print ko_get_submenu_code("daten", "right");
include($ko_path . "footer.php"); ?>
The two main areas switch($do_action) and switch($_SESSION[„show“]):
The file index.php gets an action (with GET or POST) which will determine the further steps taken. There is a case block for every action. In the easiest case only the session variable „show“ will be set. The check for access rights is done here as well.
After setting the show variable the appropriate page will get rendered. This happens in a second switch block which is surrounded by HTML which means the content can be output right away (through a smarty->display()). Usually this is done by an appropriate function in inc/MODULE.inc which is called with the needed arguments.
Before and after the switch($do_action) area the user access rights are beeing read. The second one is needed to get any changes that happend in the action performed.
Templates with smarty
A new class Smarty_ko is defined in inc/smarty.inc which extends Smarty. The only extension done is the definition of the necessary paths: templates, templates_c, cache and configs.
This class get instantiated in MODULE/index.php und saved in $smarty. Like this the following code allows the render functions in MODULE/MODULE.inc to render smarty content:
Global functions in /inc/ko.inc
At the beginning of inc/ko.inc you'll find some general definitions and the code to include some necessary files. E.g. the installation specific configuration file /config/ko-config.inc.
After that there is a long list of commonly used functions, that are available in all modules. See the function reference of ko.inc for a complete list of them.