Commit b2b295fe6207c4cfb3e4c5b50ed128cb10b6dcbc
1 parent
3e7887ad
Autodetect paths and server name, and componentise and modernise the
initialisation process. git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3000 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
93 additions
and
32 deletions
config/dmsDefaults.php
| 1 | 1 | <?php |
| 2 | +/* vim: set expandtab tabstop=4 shiftwidth=4 foldmethod=marker: */ | |
| 3 | + | |
| 2 | 4 | /** |
| 3 | 5 | * $Id$ |
| 4 | 6 | * |
| ... | ... | @@ -21,47 +23,106 @@ |
| 21 | 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 22 | 24 | */ |
| 23 | 25 | |
| 26 | +error_reporting(E_ALL & ~E_NOTICE); | |
| 27 | +ini_set('display_errors', '1'); | |
| 28 | +ini_set('display_startup_errors', '1'); | |
| 29 | + | |
| 30 | +// If not defined, set KT_DIR based on my usual location in the tree | |
| 31 | +if (!defined('KT_DIR')) { | |
| 32 | + define('KT_DIR', realpath(dirname(__FILE__) . '/..')); | |
| 33 | +} | |
| 34 | + | |
| 35 | +if (!defined('KT_LIB_DIR')) { | |
| 36 | + define('KT_LIB_DIR', KT_DIR . '/lib'); | |
| 37 | +} | |
| 38 | + | |
| 39 | +// PATH_SEPARATOR added in PHP 4.3.0 | |
| 40 | +if (!defined('PATH_SEPARATOR')) { | |
| 41 | + if (substr(PHP_OS, 0, 3) == 'WIN') { | |
| 42 | + define('PATH_SEPARATOR', ';'); | |
| 43 | + } else { | |
| 44 | + define('PATH_SEPARATOR', ':'); | |
| 45 | + } | |
| 46 | +} | |
| 47 | + | |
| 48 | +/// {{{ KTInit | |
| 49 | +class KTInit { | |
| 50 | + // {{{ prependPath() | |
| 51 | + function prependPath ($path) { | |
| 52 | + $include_path = ini_get('include_path'); | |
| 53 | + ini_set('include_path', $path . PATH_SEPARATOR . $include_path); | |
| 54 | + } | |
| 55 | + // }}} | |
| 56 | + | |
| 57 | + // {{{ setupLogging() | |
| 58 | + function setupLogging () { | |
| 59 | + global $default; | |
| 60 | + require_once("$default->fileSystemRoot/lib/Log.inc"); | |
| 61 | + $default->log = new Log($default->fileSystemRoot . "/log", INFO); | |
| 62 | + $default->timerLog = new Log($default->fileSystemRoot . "/log", INFO, "timer"); | |
| 63 | + } | |
| 64 | + // }}} | |
| 65 | + | |
| 66 | + // {{{ setupI18n() | |
| 67 | + /** | |
| 68 | + * setupI | |
| 69 | + * | |
| 70 | + */ | |
| 71 | + function setupI18n () { | |
| 72 | + global $default; | |
| 73 | + if (in_array("gettext", get_loaded_extensions()) && function_exists('gettext') && function_exists('_')) { | |
| 74 | + require_once("$default->fileSystemRoot/lib/i18n/languageFunctions.inc"); | |
| 75 | + require_once("$default->fileSystemRoot/lib/i18n/accept-to-gettext.inc"); | |
| 76 | + if ($default->useAcceptLanguageHeader) { | |
| 77 | + $aInstalledLocales = getInstalledLocales(); | |
| 78 | + $sLocale=al2gt($aInstalledLocales, 'text/html'); | |
| 79 | + $default->defaultLanguage = $sLocale; | |
| 80 | + } | |
| 81 | + putenv('LANG=' . $default->defaultLanguage); | |
| 82 | + setlocale(LC_ALL, $default->defaultLanguage); | |
| 83 | + // Set the text domain | |
| 84 | + $sDomain = 'knowledgeTree'; | |
| 85 | + bindtextdomain($sDomain, $default->fileSystemRoot . "/i18n"); | |
| 86 | + textdomain($sDomain); | |
| 87 | + } else { | |
| 88 | + $default->log->info("Gettext not installed, i18n disabled."); | |
| 89 | + // define a dummy _ function so gettext is not -required- | |
| 90 | + function _($sString) { | |
| 91 | + return $sString; | |
| 92 | + } | |
| 93 | + } | |
| 94 | + } | |
| 95 | + // }}} | |
| 96 | +} | |
| 97 | +// }}} | |
| 98 | + | |
| 99 | +$default->fileSystemRoot = KT_DIR; | |
| 100 | +$default->serverName = $_SERVER['HTTP_HOST']; | |
| 101 | + | |
| 24 | 102 | // include the environment settings |
| 25 | 103 | require_once("environment.php"); |
| 104 | + | |
| 105 | + | |
| 26 | 106 | // table mapping entries |
| 27 | 107 | include("tableMappings.inc"); |
| 108 | + | |
| 109 | +KTInit::prependPath($default->pear_path); | |
| 110 | + | |
| 28 | 111 | // instantiate log |
| 29 | -require_once("$default->fileSystemRoot/lib/Log.inc"); | |
| 30 | -$default->log = new Log($default->fileSystemRoot . "/log", INFO); | |
| 31 | -$default->timerLog = new Log($default->fileSystemRoot . "/log", INFO, "timer"); | |
| 32 | -// setup i18n if gettext is installed | |
| 33 | -if (in_array("gettext", get_loaded_extensions()) && function_exists('gettext') && function_exists('_')) { | |
| 34 | - require_once("$default->fileSystemRoot/lib/i18n/languageFunctions.inc"); | |
| 35 | - require_once("$default->fileSystemRoot/lib/i18n/accept-to-gettext.inc"); | |
| 36 | - if ($default->useAcceptLanguageHeader) { | |
| 37 | - $aInstalledLocales = getInstalledLocales(); | |
| 38 | - $sLocale=al2gt($aInstalledLocales, 'text/html'); | |
| 39 | - $default->defaultLanguage = $sLocale; | |
| 40 | - } | |
| 41 | - putenv('LANG=' . $default->defaultLanguage); | |
| 42 | - setlocale(LC_ALL, $default->defaultLanguage); | |
| 43 | - // Set the text domain | |
| 44 | - $sDomain = 'knowledgeTree'; | |
| 45 | - bindtextdomain($sDomain, $default->fileSystemRoot . "/i18n"); | |
| 46 | - textdomain($sDomain); | |
| 47 | -} else { | |
| 48 | - $default->log->info("Gettext not installed, i18n disabled."); | |
| 49 | - // define a dummy _ function so gettext is not -required- | |
| 50 | - function _($sString) { | |
| 51 | - return $sString; | |
| 52 | - } | |
| 53 | -} | |
| 112 | +KTInit::setupLogging(); | |
| 113 | + | |
| 114 | +KTInit::setupI18n(); | |
| 54 | 115 | |
| 55 | 116 | // site map definition |
| 56 | 117 | include("siteMap.inc"); |
| 57 | 118 | |
| 58 | -require_once("$default->fileSystemRoot/phpmailer/class.phpmailer.php"); | |
| 59 | -require_once("$default->fileSystemRoot/lib/session/Session.inc"); | |
| 60 | -require_once("$default->fileSystemRoot/lib/session/control.inc"); | |
| 61 | -require_once("$default->fileSystemRoot/presentation/Html.inc"); | |
| 119 | +require_once(KT_DIR . '/phpmailer/class.phpmailer.php'); | |
| 120 | +require_once(KT_LIB_DIR . '/session/Session.inc'); | |
| 121 | +require_once(KT_LIB_DIR . '/session/control.inc'); | |
| 122 | +require_once(KT_DIR . '/presentation/Html.inc'); | |
| 62 | 123 | // browser settings |
| 63 | -require_once("$default->fileSystemRoot/phpSniff/phpSniff.class.php"); | |
| 64 | -require("browsers.inc"); | |
| 124 | +require_once(KT_DIR . '/phpSniff/phpSniff.class.php'); | |
| 125 | +require_once('browsers.inc'); | |
| 65 | 126 | // import request variables and setup language |
| 66 | -require_once("$default->fileSystemRoot/lib/dms.inc"); | |
| 127 | +require_once(KT_LIB_DIR . '/dms.inc'); | |
| 67 | 128 | ?> | ... | ... |