-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathbootstrap.php
More file actions
97 lines (88 loc) · 2.83 KB
/
bootstrap.php
File metadata and controls
97 lines (88 loc) · 2.83 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
define('GITPHP_BASEDIR', dirname(__FILE__) . '/');
define('GITPHP_CONFIGDIR', GITPHP_BASEDIR . '.config/');
define('GITPHP_INCLUDEDIR', GITPHP_BASEDIR . '.include/');
define('GITPHP_GITOBJECTDIR', GITPHP_INCLUDEDIR . 'git/');
define('GITPHP_CONTROLLERDIR', GITPHP_INCLUDEDIR . 'controller/');
define('GITPHP_CACHEDIR', GITPHP_INCLUDEDIR . 'cache/');
define('GITPHP_LOCALEDIR', GITPHP_BASEDIR . '.locale/');
define('GITPHP_TEMPLATESDIR', GITPHP_BASEDIR . '.templates/');
define('GITPHP_CSSDIR', GITPHP_BASEDIR . 'css/');
define('GITPHP_JSDIR', GITPHP_BASEDIR . 'js/');
define('GITPHP_LIBDIR', GITPHP_BASEDIR . 'lib/');
define('GITPHP_BASE_NS', 'GitPHP');
spl_autoload_register(
function($class) {
// psr4 autoload
$namespaces = explode('\\', $class);
if (count($namespaces) > 1 && $namespaces[0] == GITPHP_BASE_NS) {
$file_name = array_pop($namespaces) . ".php";
unset($namespaces[0]);
$file_name = GITPHP_INCLUDEDIR . join(DIRECTORY_SEPARATOR, array_map('strtolower', $namespaces)) . DIRECTORY_SEPARATOR . $file_name;
if (file_exists($file_name)) {
require_once $file_name;
}
}
}
);
class CountClass
{
protected $name, $value;
public function __construct($name, $value = null)
{
$this->name = $name;
$this->value = $value;
\GitPHP\Log::GetInstance()->timerStart();
}
public function __destruct()
{
\GitPHP\Log::GetInstance()->timerStop($this->name, $this->value);
}
}
/* strlen() can be overloaded in mbstring extension, so always using mb_orig_strlen */
if (!function_exists('mb_orig_strlen')) {
function mb_orig_strlen($str)
{
return strlen($str);
}
}
if (!function_exists('mb_orig_substr')) {
function mb_orig_substr($str, $offset, $len = null)
{
return isset($len) ? substr($str, $offset, $len) : substr($str, $offset);
}
}
if (!function_exists('mb_orig_strpos')) {
function mb_orig_strpos($haystack, $needle, $offset = 0)
{
return strpos($haystack, $needle, $offset);
}
}
/**
* Gettext wrapper function for readability, single string
*
* @param string $str string to translate
* @return string translated string
*/
function __($str)
{
if (\GitPHP\Resource::Instantiated())
return \GitPHP\Resource::GetInstance()->translate($str);
return $str;
}
/**
* Gettext wrapper function for readability, plural form
*
* @param string $singular singular form of string
* @param string $plural plural form of string
* @param int $count number of items
* @return string translated string
*/
function __n($singular, $plural, $count)
{
if (\GitPHP\Resource::Instantiated())
return \GitPHP\Resource::GetInstance()->ngettext($singular, $plural, $count);
if ($count > 1)
return $plural;
return $singular;
}