Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

There is a very basic autoloading applied, that changes with the front-controller that is being used.

It is useful, to work towards a PSR-4 autoloading. That is already used for tests.

Page-based autoloading

Index front controller

The index front-controller loads the module that is given in the page URI parameter:

lang/DE/page.lang.php
model/page.model.php (also reinitializes $db global with new PageModel if model file exists)
control/page.php

XHR front controller

The XHR front-controller does no autoloading. All methods are directly called ( xhr_func ), they are defined in xhr.inc.php

API front controller

See App-based autoloading below. 

App-based autoloading

After some time, a new module structure called "app" was invented. To use that, the auto-loaded controller has to explicitly call it (e.g. loadApp('basket')).

That will trigger the loading of some more files:

Code Block
php
php
	require_once ROOT_DIR.'app/core/core.control.php';
	require_once ROOT_DIR.'app/core/core.model.php';
	require_once ROOT_DIR.'app/core/core.view.php';
	
	require_once ROOT_DIR.'app/'.$app.'/'.$app.'.control.php';
	require_once ROOT_DIR.'app/'.$app.'/'.$app.'.model.php';
	require_once ROOT_DIR.'app/'.$app.'/'.$app.'.view.php';
	require_once ROOT_DIR.'lang/DE/'.$app.'.lang.php';
	if(isset($_GET['lang']) && $_GET['lang'] == 'en')
	{
		$fn = ROOT_DIR.'lang/EN/'.$app.'.lang.php';
		if(file_exists($fn))
		{
			require_once $fn;
		}
	}
	addJsFunc(file_get_contents(ROOT_DIR.'app/'.$app.'/'.$app.'.script.js'));
	addStyle(file_get_contents(ROOT_DIR.'app/'.$app.'/'.$app.'.style.css'));

Also, JavaScript and CSS are added into the header part of the generated page.