1. Introduction

This document describes the project inosid for developers.

1.1. Purpose

sigui provides a toolkit for developing graphical interfaces for browser based applications.

1.2. Architecture

This is a template and plugin driven approach which can be extended and modified easily.

There is a skeleton offering flow control, handling of configuration, storing of user specific data and so on.

Each page of the application is handled by a plugin implemented by a class derived from Page to administrate this page.

The basic html page is defined in a template. The content area of the page will be created from the plugin.
This allows using one template for all pages (equal design).

1.3. Navigation

The standard http process only allows access to the input field values if a button inside the form has been pushed. Therefore the navigation uses buttons instead of links.

Without this construction the user must push a "store" button and the data will be lost if he does not (very uncomfortable).

With the navigation by buttons the plugin can store the field values and then it changes the page.

2. Plugins

2.1. Tasks of a Plugin

2.2. Methods to Overwrite (always)

The plugin class must overwrite the abstract methods of the class Page. See page.php.

2.3. Methods to Overwrite (optional)

The following methods are predefined but can be overwritten.

2.4. Plugin services

There are helper functions in the base class Page...

.. and in the class Session:

3. Page Template

The template contains markers which will be replaced by the core modules or the plugin.

3.1. Markers

4. Content Template

The content area will be filled by a plugin. It should use a template to divide design and code. The plugin should use markers to communicate with the template.

The filling of the input fields with values inserted earlier will be done by the core modules. Therefore the names of the fields must be known.

4.1. Markers

Note: X stands for an uppercase field name.

5. Configuration

5.1. Global Configuration Data

The file inosid.conf contains configuration data which are used for all clients.

# List of the page names separated by ','. 
# The series defines the effect of the Back and Next buttons.
# The page name is the name of the plugin. 
.gui.pages=home,boot,user,network,run

The configuration has a part for global definitions: these definitions starts with '.'. The other parts are plugin dependent. The definitions in these parts start with the plugin name.

5.2. User Data

When the user changes the pages (using the back or the next button) the field values will be stored in a file. The filename is client specific: the remote ip address is part of the name. This is not perfect but good enough.

user.user=jonny
user.pass=123
user.pass2=123

6. Data flow

6.1. Setting the Input Fields

If the http header ($_GET or $_POST) contains a button the input field will be set from the http header. Otherwise the fields will be set from the user data. Therefore the field values in the content template must contain markers: ###VAL_X### (X is the uppercase fieldname).

6.2. Field Validation

The field validation should be done inside the plugin method onButtonClick().

If a field value is valid the value must be stored in user data: $this->session->userData->setValue(pluginName, fieldName, fieldValue)

Otherwise an error message should be set: $this-<setFieldError(fieldName, errorMessage)

7. Menus

siguibui projects can maintance menus.

At this moment only projects with static pages handle automatically menus.

7.1. Content and Structure Definition

The content and the structure of a menu depends on the language and will be defined in the file config/menu_<language>.conf.

7.1.1. Example config/menu_en.conf

# Format: <indent-level>  <id> <link> <text>
*	sm1	welcome	siduction OS Manual
**	sm1a	welcome#welcome-gen	siduction OS Manual ⇒
***	-	credits#cred-team	Credits
**	sm1b	welcome#how-to	How to use this manual ⇒
***	-	welcome#how-to	How to use this manual
***	-	welcome#table-contents	Table of Contents
**	sm1c	help#help-gen	Getting Help ⇒
***	-	help#help-gen	Where and how to get help
***	-	help#paste	IRC !paste
**	-	wel-quickstart#welcome-quick	siduction Quick Start Guide
*	sm2	cd-dl-burning	ISO Content, Releases, Download Mirrors and Burning
**	sm2a	cd-content#cd-content	ISO Content and system requirements ⇒
***	-	sys-admin-release#rolling	Release Notes
**	sm2b	cd-dl-burning#download-siduction	siduction Mirrors, Downloading and Burning ⇒
***	-	cd-dl-burning#md5	md5 Checksum
***	-	cd-dl-burning#burn-nero	Burning in Windows
***	-	cd-dl-burning#burn-linux	Burning in Linux
***	-	cd-no-gui-burn#burning-no-gui	burniso script
***	-	cd-no-gui-burn#burn-no-gui-gen	Burning without a GUI
***	-	cd-dl-burning#download-siduction	siduction Download Mirrors

7.2. XML Definition

The design of the menu can be defined in config/menu.parts.txt. It contains a definition for each hierarchical level.

Only in very special cases the following example must be changed.

7.2.1. Example config/menu_en.conf

LEVEL_0:
 <ul>
###ENTRIES###
 </ul>

ENTRY_0:
  <li###class_current###>
   <a href="###link###">###title###</a>
###SUBMENUS###
  </li>

LEVEL_1:
   <ul ###id###>
###ENTRIES###
   </ul>

ENTRY_1:
    <li###class_current###>
     <a href="###link###">###title###</a>
###SUBMENUS###
    </li>

LEVEL_2:
     <ul class="sub2-menu"###id###>
###ENTRIES###
     </ul>

ENTRY_2:
      <li###class_current###><a href="###link###">###title###</a></li>

CLASS_CURRENT:
 class="current-item"

ID:
 id="###id###"

END:

If there are more than one menu the part names must be completed by a prefix, e.g. TOP_MENU_LEVEL_0, TOP_MENU_ENTRY_0 and so on.

8. Static Pages

A good example for a project with static pages is the siduction manual. There are more than 50 pages. Realized with true static pages the work for maintance is too large: If there is a change in the html-structure of the menu, each of the pages must be changed too.

The solution is a project derived from siguibui. The common design of all pages will be defined only once.

8.1. Directory Structure and Name Conventions

Every static page should exist in each language. This forms the directory tree.

8.2. Example of a Directory of the Static Pages

static
	en
		welcome-en.htm
		content-en.htm
	de
		welcome-de.htm
		content-de.htm
	pt-br
		welcome-pt-br.htm
		content-pt-br.htm

8.3. Content File

Because of data migration and easy development the content file of the static page can be a valid HTML or XML file. The system extracts the pure content (without header, menu...) and puts this content into the template config/<project>.html.

The extraction is driven by pattern matching:

There are 2 parameters in config/<project>_<language>.conf to control this extraction:

static.content.start=id="main-page"
static.content.end.ignoreddivs=1

9. I18n

All texts are stored in the configuration files, none in the program code and none in the templates.

For each supported language there must be a configuration file. The file name convention: <name>_<language>.<ext>, e.g. inosid_de.conf

Templates can contain markers ###txt_X### (X is being a name with letters, digits and '_'). Entries in the configuration must contain <plugin>.txt_X or default.txt_x. <plugin> is the name of a plugin. If the plugin using the template has a so defined entry this value will be substituted. If not, the plugin independent variant will be used.

10. Conventions

Rules are needed to integrate the plugins. For a simple explanation, an example: user (a page asking for username and password)

11. Cookbook

This chapter offers solutions for tasks belonging to development with the toolkit.

The example project is named net-center.

11.1. Building a Debian Package

There is a script build/build.sh which creates an installable Debian package. This is a good base for starting a new project.

11.2. Adding a Text Input Field

Task:
A input field for a ipaddress should be added to the page wlan.

Solution:

Note:
If the field value should be empty on a redisplay the makro ###VAL_...### must not be set.

11.3. Adding a Combobox with Fixed Alternatives

Task:
A combobox for a mode should be added to the page wlan. There are two alternatives (dhcp and static address) which do not change. But the values depend on the current language. Therefore they must be stored in the configuration file.

Solution:

11.4. Adding a Combobox with Dynamic Alternatives

Task:
A combobox for a device should be added to the page wlan. The values (e.g. wlan0 and wlan1) are dynamic: they must be calculated by the program.

Solution:

11.5. Field Validation and Error Messages

Task:
The value of the field ipaddress on the page wlan must be checked for a correct syntax. In the case of an error a message must be displayed.

Solution:

11.6. Conditional GUI Areas

Task:
A certain screen area should be displayed only under some conditions. The example is a division to show the last command log message. This will be showed only if a command is executed.

Solution: Syntax of a template definition file:
file ::= {<template-definition> }+
template-definition ::= <header> <body>
header ::= <name> ':' '\n'
body ::= { <body-line> }+
body-line ::= <html-code-or-makros> '\n'
Example of a template definition file:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="###LANGUAGE###">
<head>
	<title>###txt_title###</title>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<style type="text/css" media="all">@import url("../config/content.css");</style>
###META_DYNAMIC###
</head>
<body class="body-main">
<div><img class="header-img" alt="header logo siduction" src="../images/siduction-logo-web.png" />
</div>
<div id="content">
###CONTENT###
</div> <!--content -->
</body>
</html>