Backend, index.php

Website Structure <file>.php

Structure of PHP-Files

  • <?php PHP Init
    • _init_page.php
      • masterdata/_init.php
        • global variables
        • includes for datadefinition and login
      • session_start()
      • include "masterdata/BasicFunctions.php"
      • set pages array
      • set menu array
      • init variables from $_GET
      • check database connection: isset($GLOBALS['k8db'])
      • init laguage support
      • include loginlogout_execute.php
      • session loss / cookie
      • set SESSION[domain_language]
      • $headtitle=$domain_name
      • $headdescription
      • $_GET Parameters
    • (masterdata/datadefinitions.php)
    • (masterdata/class_data_accessclass.php)
    • page=detail, load definition, load recordset
  • <html>
    • html lang=$domain_language
    • <head>
      • $headtitle
      • $headdescrtiption
      • _head_example.php
        • script declaration
        • CSS files
        • your libraries
        • masterdata/js/lang_sys_'.$domain_language
        • datadefinition head[] (JavaScript)
        • pages head[] (JavaScript)
      • _head_js.php
        • head_include (head_includedefault=true)
        • Variables from PHP
        • datadefinition settingsadditional[]
      • datadefinition head_end[] (JavaScript)
    • <body>
      • Page header with menu
        • _header_example.php
          • page banner
          • menu
      • Content
        • pages contentPHP (PHP-File)
        • masterdata
        • listing
        • html element
      • Page footer
        • script js/example.js
        • _footer_kit.php
          • legal notice
          • contact
          • bootstrap script
        • datadefinition foot[]
        • pages foot[]

_init_page.php

pages-array

structure of array pages[$_GET[page]]:

  • url
  • helpurl
  • login
  • datadefID
  • layout
  • js_display (masterdata1 or html1)
  • headtitle
  • headdescription
  • head
  • contentPHP
  • foot
Check cookie and login

If a login-cookie is set and the $_SESSION[userID] is lost, the user is logged in by the cookie again.

If an pages which requires a login is called, a redirect to the login is executed.

language support

the language can set by:

  • $_SESSSION[domain_language]
  • $_GET[domain_language]
  • $_SERVER['HTTP_ACCEPT_LANGUAGE']

Only languages set in the global array "domain_languages" are accepted.

masterdata/_init.php

Global variables:

  • for domain
    • title and description
    • language
    • name and email
  • for include
    • domain_datadeffiles
    • domain_selectfiles
    • [domain_includes]
      • login
      • logout

The include files allows to write individual project code in your project folder

_prepare_head.php

The datadefinition is loaded. The head meta data are prepared here:

  • title
  • description

This are the dependencies with a datadefinition:

  • datadefID set:
    • keyvalue set
      • headertitlecolumn
      • headerdescriptioncolumn
    • else
      • headertitle
      • headerdescription
  • else
    • domain_name
    • domain_description

more dependencies with a datadefinition:

  • head
    [this array lines are inserted into <head>]
  • head_include
    [all php array elements are includes into <head>]
  • foot
    [this array lines are inserted at the end]

If you insert an Javascript file at the end ("foot") this replaces the Standard Javascript file "example.js". So you have to append the elements by your self to the right html tags.

_head_js.php, Javascript variables from PHP

Here are variables from the PHP Locals trasferred to get a sophisticated date and number formatting.

The settings of the datadefinitions are also defined here.

_header.php, the navigation

2 Options:

  • menu with PHP and HTML
  • menu by JavaScript with js/menu.js

index.php (Website)

URL-Parameters:

  • page
    • Home
    • Register
    • My data
    • User list
    • Login
    • Contact
    • LegalNotice
    • Masterdata
    • List
    • Form
    • Html
    • Detail
    • Catalog
    • Lineedit
  • datadefID
  • page_mode (1=no header and footer)

SESSION lost

The web server ends automatically a session after a fixed period of inactivity. The following methods are provided to avoid errors:

  • automatic login by cookie
  • page timer with redirect to login without cookie
Automatic login by cookie

By login a cookie with the login data is set. If a data request requires a logged in user without that a user is logged in the cookie is read and user is logged in again.

Page timer

Without cookie the object k8pagetimer is initialized and an interval is set. By each Ajax request the interval is set back to maximum. If the maximum time is over the login page is called.

Pages array

The page array allows to configure the following properties

  • url
  • datadefID
  • helpurl
  • login

If a page with the property: login=true is requested, the login of the user is checked. If the user is logged in, the page is displayed, otherwise the url is saved and the login page is called. After succesful login the initial page is displayed.

element.php (Website template)

This website template contains header and footer.

Parameters:

  • page:
    • for recordsets
      • masterdata or empty
      • list
      • html
      • catalog
      • lineedit
    • for 1 record
      • detail
      • form
  • datadefID

The important meta data in a website are:

  • titel, $headtitle
  • description, $headdescription
for recordsets

detail, form

By form and detail the parameter keyvalue specifies the desired record.

the data is already read with php. The title and description in the head meta is filled out. To transfer the data to javascript use this command:

var data=<?php echo json_encode($dataws,JSON_NUMERIC_CHECK);?>;

You can also use it as template for your individual website.

objectdata_form.php (Test-File)

This file is for testing your datadefintion. In this simple file the login file is implemented. The following elements are supported:

  • page
    • Masterdata
    • List
    • Form
    • Html
    • Detail
    • Catalog
    • Lineedit
  • datadefID

masterdata_form.php (Test-File)

This easy template displays a masterdata form. Its implemented for compatibilty reasons.

?>