Core::init PHP Method

init() public static method

Our initialization function. This is called on all page requests to initialize the Core object. Since it's also used during installation (when the database and/or plugins haven't been installed), the optional parameter controls whether or not the database object, plugins, sessions and user should be initialized. Different call contexts require different initialization.
public static init ( string $runtimeContext = "ui" )
$runtimeContext string This determines the context in which the Core is being initialized. This info is used to let plugins instantiate themselves differently, as well as prevent the loading of incomplete parts of the script.
installation: a fresh installation, DB not installed yet
installationDatabaseReady: during installation after the DB has been installed
ui: (default) for the main generator page
generation: when we're in the process of creating actual data resetPlugins: initialized everything except the plugins, which may be safely reset
    public static function init($runtimeContext = "ui")
    {
        self::loadSettingsFile();
        error_reporting(self::$errorReporting);
        // ensure the timezone is set. This is an arbitrary value (well, I live in Vancouver!) but it prevents warnings
        if (ini_get("date.timezone") == "") {
            ini_set("date.timezone", "Canada/Vancouver");
        }
        self::$translations = new Translations();
        // for all pages
        if ($runtimeContext == "installation") {
            session_start();
            $_SESSION["installing"] = true;
        } else {
            // the order is significant in all of this
            self::initDatabase();
            if (in_array($runtimeContext, array("installationDatabaseReady", "ui", "generation", "resetPlugins"))) {
                self::initSessions();
            }
            if ($runtimeContext == "installationDatabaseReady") {
                $_SESSION["installing"] = true;
            }
            $dbDefaultLanguage = Settings::getSetting("defaultLanguage");
            if (!empty($dbDefaultLanguage)) {
                self::$defaultLanguageFile = $dbDefaultLanguage;
            }
        }
        self::$language = new Language(self::$defaultLanguageFile);
        self::initSmarty();
        if ($runtimeContext == "generation") {
            self::initGeoData();
        }
        if ($runtimeContext == "ui" || $runtimeContext == "generation") {
            self::initCountries();
            self::initExportTypes($runtimeContext);
            self::initDataTypes($runtimeContext);
        }
        if (in_array($runtimeContext, array("ui", "generation", "resetPlugins"))) {
            self::initUser();
        }
        set_time_limit(self::$timeout);
    }

Usage Example

示例#1
0
文件: index.php 项目: AidaDC/to
<?php

/**
* @author Andreu Sanz Miedes y Aida Dahdah Castelló
* @author [email protected], [email protected]
* @copyright 2015 PROYECTO FINAL
* @version 1.0
*/
$time = microtime();
error_reporting(E_ALL);
ini_set('display_errors', '1');
include 'constants.php';
require 'sys/helper.php';
$conf = Registry::getInstance();
$conf->init();
// installation first if necessary
if (!file_exists('.deployed')) {
    $conf->deployed = 'false';
}
Session::init();
// setting init time
$conf->time;
//Coder::code_var($conf);
Core::init();
All Usage Examples Of Core::init