[ EN ]    [ DE ]   
kOOL Logo HomeAboutDownloadDocumentation
Rects
Documentation

  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)

File/Folder Description
download.php Is opened as a popup window to show a download link for a generated file
fpdf/ Contains fpdf.php and mc_table.php from the FreePDF library
get.php XML access to some kOOL data. Can be used by external applications like TYPO3 extensions
ical/ Script that generates an iCal (.ics) file of the events
ie6.css CSS specific to IE6
ie7.css CSS specific to IE7
images/ Globally used images
inc/ Globally used functions and javascript code
index.php Front page
install/ Scripts for installation and update. Webbased installation. Default files for web folder
kOOL.css Global CSS file which can be overwritten by ko.css in web folder
locallang/ Contains all language specific files
menu.php Shows and processes login menus. Uses ko_menu.tpl
smarty/ Smarty template engine (see smarty.php.net)
templates/ All the smarty templates
MODULE One directory for every module

Directory structure for one module

  • MODULE:
    • index.php (Main page for this module)
    • inc/
      • MODULE.inc (PHP code only used in this module)
      • js-MODULE.inc (Javascript 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)

File/Folder Description
config/ Files with configurations specific to this installation
config/ko-config.inc Modules, db account, ldap account, sms account, plugins, etc.
config/kota.inc Additions to KOTA
config/leute_formular.inc Layout for the form to edit people
download/ Files to be downloaded will be stored here. Must be writable for the webserver process
download/dp/ Exported rota plans
download/excel/ Exported Excel files
download/index.php Redirection to root directory
download/pdf/ Exported pdf files
footer.php Footer on every page except for the front page
fpdf/ Real directory
fpdf/images/ Images used for PDF export in this installation of kOOL
schriften/ Fonts used for PDF export in this installation of kOOL
header.php Header on every page, displayed above the menu
inc/ Real directory with linked files
install/index.php Webbased installation for the first installation
ko.css CSS file specific to this installation which can overwrite definitions in kOOL.css
kOOL_lib Link to the source lib directory of kOOL. All other linked files in the web directory link to kOOL_lib
my_images Images specific to this installation
plugins/ Plugins
templates_c/ Templates cache for smarty
webfolders/ Folder used for the webfolders
.webfolders/ Contains the same folder structur as webfolders but only with the .htaccess files
MODULE Real directory with linked contents. Additional files possible.

Code structure of MODULE/index.php

HTML structure

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:
    1. Submenus to the left (id=main_left)
    2. Content (id=main_content)
    3. 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

<?php

//INCLUDES

include_once($ko_path . "inc/ko.inc");

include_once("inc/daten.inc");

[..]

 

//ACCESS RIGHTS

list($item_view, $item_new, $item_edit, $item_mod) = ko_get_admin("daten", $_SESSION["ses_userid"], $group_view, $group_new, $group_edit, $group_mod);

 

//PLUGINS

$hooks = hook_include_main("daten");

if(sizeof($hooks) > 0) foreach($hooks as $hook) include_once($hook);

 

//ACTION

switch($do_action) {

case "set_filter_today":

}

 

//SUBMENUES

ko_set_submenues();

?>

 

<html>

<head>[..]</head>

<body>

<?php

//TOP NAVIGATION

include($ko_path . "menu.php");

//SUBMENUS LEFT

print ko_get_submenu_code("daten", "left");

 

//SHOW SWITCH

switch($_SESSION["show"]) {

}

 

//SUBMENUS RIGHT

print ko_get_submenu_code("daten", "right");

 

//FOOTER

include($ko_path . "footer.php"); ?>

?>

 

</body>

</html>

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 $smarty;

$smarty->display(“template.tpl“);

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.

Rects
©Renzo Lauper, CH-5000 Aarau, All rights reserved