-
Notifications
You must be signed in to change notification settings - Fork 0
/
Config.php
50 lines (42 loc) · 2.12 KB
/
Config.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php declare(strict_types=1);
namespace Saaze;
class Config { // Global config variables for Simplified Saaze
static public array $H; // hash for global config data
static public function getenv2(string $var) : string|null { // same as getenv(), but return null instead of false
$s = getenv($var);
return ($s ? $s : null);
}
static public function init() : void {
if (!defined('SAAZE_PATH')) {
throw new \Exception('SAAZE_PATH is not defined');
}
self::$H = array(
'global_rbase' => $GLOBALS['rbase'] ?? Config::getenv2('RBASE') ?? '',
'global_path_base' => SAAZE_PATH,
'global_path_content' => SAAZE_PATH . DIRECTORY_SEPARATOR . (Config::getenv2('CONTENT_PATH') ?? 'content'),
'global_path_public' => SAAZE_PATH . DIRECTORY_SEPARATOR . (Config::getenv2('PUBLIC_PATH') ?? 'public'),
'global_path_templates' => SAAZE_PATH . DIRECTORY_SEPARATOR . (Config::getenv2('TEMPLATES_PATH') ?? 'templates'),
'global_config_entries_per_page' => (int)(Config::getenv2('ENTRIES_PER_PAGE') ?? 20),
'global_excerpt_length' => 300,
// md4c called via PHP-FFI
//'global_ffi' => \FFI::cdef('char *md4c_toHtml(const char*);', SAAZE_PATH . DIRECTORY_SEPARATOR
// . 'vendor' . DIRECTORY_SEPARATOR . 'eklausme' . DIRECTORY_SEPARATOR . 'saaze'
// . DIRECTORY_SEPARATOR . 'php_md4c_toHtml.so'),
);
//printf("Config: H[global_path_public] = %s\n",self::$H['global_path_public']);
// Statistics for various functions
$GLOBALS['content'] = 0;
$GLOBALS['contentCached'] = 0;
$GLOBALS['renderCollection'] = 0;
$GLOBALS['renderCollectionNcall'] = 0;
$GLOBALS['renderEntry'] = 0;
$GLOBALS['renderEntryNcall'] = 0;
$GLOBALS['parseEntry'] = 0; // time spent in routine parseEntry()
$GLOBALS['parseEntryNcall'] = 0; // number of calls to parseEntry() = yaml_parse()
$GLOBALS['parseCollectionNcall'] = 0;
$GLOBALS['toHtml'] = 0; // time spent in toHtml() without MD4 processing
$GLOBALS['toHtmlNcall'] = 0; // number of calls of toHTML()
$GLOBALS['md2html'] = 0; // time spent in Markdown to HTML conversion
$GLOBALS['rbase'] = \Saaze\Config::$H['global_rbase']; // relative base
}
}