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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
<?php
/**
* Register polyfills for old PHP versions.
*
* This way, the real function will only be called if it
* is available, and we won't force the use of our own
* implementation.
*/
function register_polyfills()
{
}
register_polyfills();
/**
* Path to the _custom_ directory.
*
* @param string $file Append this filename to the returned path.
* @return string
* @deprecated
*/
function custom_path($file = '') : string
{
return __DIR__.'/../custom' . (!empty($file) ? '/'.$file : '');
}
/**
* Path to the _views_ directory.
*
* @param string $file Append this filename to the returned path.
* @return string
* @deprecated
*/
function views_path($file = '') : string
{
return custom_path('views/' . $file);
}
/**
* Path to the _admin_ directory.
*
* @param string $file Append this filename to the returned path.
* @return string
* @deprecated
*/
function admin_path($file = '') : string
{
return __DIR__.'/../admin' . (!empty($file) ? '/'.$file : '');
}
/**
* Path to the _config_ directory.
*
* @param string $file Append this filename to the returned path
* @param string $site Append this site as a sub-directory before the file
* @return string
*/
function config_path($file = '', $site = '') : string
{
$path = __DIR__ . '/../custom/config';
if (!empty($site)) {
$path .= '/' . $site;
}
if (!empty($file)) {
$path .= '/' . $file;
}
return $path;
}
function cache_path($site = '') : string
{
return __DIR__ . '/../cache';
}
/**
* Shortcut to Simplel10n::getString().
*
* @param string $str
* @param string $comment
* @return string
*/
function _g($str, $comment = '')
{
return Simplel10n::getString($str, $comment);
}
/**
* Reset the moonmoon instance.
*/
function removeCustomFiles()
{
$toRemove = [
config_path('config.yml'),
config_path('people.opml'),
config_path('people.opml.bak'),
cache_path('cache'),
// legacy location
custom_path('config.yml'),
custom_path('config.yml.bak'),
custom_path('people.opml'),
custom_path('people.opml.bak'),
];
foreach ($toRemove as $path) {
if (is_file($path)) {
unlink($path);
}
}
}
|