Bearsampp
2026.9.23
Toggle main menu visibility
Loading...
Searching...
No Matches
class.tpl.app.mailpit.php
Go to the documentation of this file.
1
<?php
2
/*
3
* Copyright (c) 2021-2026 Bearsampp
4
* License: GNU General Public License version 3 or later; see LICENSE.txt
5
* Author: Bear
6
* Website: https://bearsampp.com
7
* Github: https://github.com/Bearsampp
8
*/
9
17
class
TplAppMailpit
18
{
19
const
MENU
=
'mailpit'
;
20
const
MENU_VERSIONS
=
'mailpitVersions'
;
21
const
MENU_SERVICE
=
'mailpitService'
;
22
23
const
ACTION_ENABLE
=
'enableMailpit'
;
24
const
ACTION_SWITCH_VERSION
=
'switchMailpitVersion'
;
25
const
ACTION_CHANGE_PORT
=
'changeMailpitPort'
;
26
const
ACTION_INSTALL_SERVICE
=
'installMailpitService'
;
27
const
ACTION_REMOVE_SERVICE
=
'removeMailpitService'
;
28
40
public
static
function
process
()
41
{
42
global
$bearsamppLang
,
$bearsamppBins
;
43
44
return
TplApp::getMenuEnable
(
$bearsamppLang
->getValue(
Lang::MAILPIT
), self::MENU, get_called_class(),
$bearsamppBins
->getMailpit()->isEnable());
45
}
46
60
public
static
function
getMenuMailpit
()
61
{
62
global
$bearsamppRoot
,
$bearsamppConfig
,
$bearsamppBins
,
$bearsamppLang
;
63
$resultItems = $resultActions =
''
;
64
65
$isEnabled =
$bearsamppBins
->getMailpit()->isEnable();
66
67
// Download
68
$resultItems .=
TplAestan::getItemLink
(
69
$bearsamppLang
->getValue(
Lang::DOWNLOAD_MORE
),
70
HttpClient::getWebsiteUrl
(
'module/mailpit'
,
'#releases'
),
71
false
,
72
TplAestan::GLYPH_BROWSER
73
) . PHP_EOL;
74
75
// Enable
76
$tplEnable =
TplApp::getActionMulti
(
77
self::ACTION_ENABLE,
78
array($isEnabled ?
Config::DISABLED
:
Config::ENABLED
),
79
array(
$bearsamppLang
->getValue(
Lang::MENU_ENABLE
), $isEnabled ?
TplAestan::GLYPH_CHECK
:
''
),
80
false
,
81
get_called_class()
82
);
83
$resultItems .= $tplEnable[
TplApp::SECTION_CALL
] . PHP_EOL;
84
$resultActions .= $tplEnable[
TplApp::SECTION_CONTENT
] . PHP_EOL;
85
86
if
($isEnabled) {
87
$resultItems .=
TplAestan::getItemSeparator
() . PHP_EOL;
88
89
// Versions
90
$tplVersions =
TplApp::getMenu
(
$bearsamppLang
->getValue(
Lang::VERSIONS
), self::MENU_VERSIONS, get_called_class());
91
$resultItems .= $tplVersions[
TplApp::SECTION_CALL
] . PHP_EOL;
92
$resultActions .= $tplVersions[
TplApp::SECTION_CONTENT
] . PHP_EOL;
93
94
// Service
95
$tplService =
TplApp::getMenu
(
$bearsamppLang
->getValue(
Lang::SERVICE
), self::MENU_SERVICE, get_called_class());
96
$resultItems .= $tplService[
TplApp::SECTION_CALL
] . PHP_EOL;
97
$resultActions .= $tplService[
TplApp::SECTION_CONTENT
] . PHP_EOL;
98
99
// Web page
100
$resultItems .=
TplAestan::getItemExe
(
101
$bearsamppLang
->getValue(
Lang::MAILPIT
),
102
$bearsamppConfig
->getBrowser(),
103
TplAestan::GLYPH_WEB_PAGE
,
104
Path::getLocalUrl
() .
':'
.
$bearsamppBins
->getMailpit()->getUiPort() .
'/'
.
$bearsamppBins
->getMailpit()->getWebRoot()
105
) . PHP_EOL;
106
107
// Log
108
$resultItems .=
TplAestan::getItemNotepad
(
$bearsamppLang
->getValue(
Lang::MENU_LOGS
),
$bearsamppBins
->getMailpit()->getLog()) . PHP_EOL;
109
}
110
111
return
$resultItems . PHP_EOL . $resultActions;
112
}
113
123
public
static
function
getMenuMailpitVersions
()
124
{
125
global
$bearsamppBins
;
126
$items =
''
;
127
$actions =
''
;
128
129
foreach
(
$bearsamppBins
->getMailpit()->getVersionList() as $version) {
130
$tplSwitchMailpitVersion =
TplApp::getActionMulti
(
131
self::ACTION_SWITCH_VERSION,
132
array($version),
133
array($version, $version ==
$bearsamppBins
->getMailpit()->getVersion() ?
TplAestan::GLYPH_CHECK
:
''
),
134
false
,
135
get_called_class()
136
);
137
138
// Item
139
$items .= $tplSwitchMailpitVersion[
TplApp::SECTION_CALL
] . PHP_EOL;
140
141
// Action
142
$actions .= PHP_EOL . $tplSwitchMailpitVersion[
TplApp::SECTION_CONTENT
];
143
}
144
145
return
$items . $actions;
146
}
147
159
public
static
function
getActionEnableMailpit
($enable)
160
{
161
global
$bearsamppBins
;
162
163
return
TplApp::getActionRun
(
Action::ENABLE
, array(
$bearsamppBins
->getMailpit()->getName(), $enable)) . PHP_EOL .
164
TplAppReload::getActionReload
();
165
}
166
178
public
static
function
getActionSwitchMailpitVersion
($version)
179
{
180
global
$bearsamppBins
;
181
182
return
TplApp::getActionRun
(
Action::SWITCH_VERSION
, array(
$bearsamppBins
->getMailpit()->getName(), $version)) . PHP_EOL .
183
TplAppReload::getActionReload
() . PHP_EOL;
184
}
185
198
public
static
function
getMenuMailpitService
()
199
{
200
global
$bearsamppRoot
,
$bearsamppLang
,
$bearsamppBins
;
201
202
$tplChangePort =
TplApp::getActionMulti
(
203
self::ACTION_CHANGE_PORT,
204
null
,
205
array(
$bearsamppLang
->getValue(
Lang::MENU_CHANGE_PORT
),
TplAestan::GLYPH_NETWORK
),
206
false
,
207
get_called_class()
208
);
209
210
$isInstalled =
$bearsamppBins
->getMailpit()->getService()->isInstalled();
211
212
$result
=
TplAestan::getItemActionServiceStart
(
$bearsamppBins
->getMailpit()->getService()->getName()) . PHP_EOL .
213
TplAestan::getItemActionServiceStop
(
$bearsamppBins
->getMailpit()->getService()->getName()) . PHP_EOL .
214
TplAestan::getItemActionServiceRestart
(
$bearsamppBins
->getMailpit()->getService()->getName()) . PHP_EOL .
215
TplAestan::getItemSeparator
() . PHP_EOL .
216
TplApp::getActionRun
(
217
Action::CHECK_PORT
,
218
array(
$bearsamppBins
->getMailpit()->getName(),
$bearsamppBins
->getMailpit()->getSmtpPort()),
219
array(sprintf(
$bearsamppLang
->getValue(
Lang::MENU_CHECK_PORT
),
$bearsamppBins
->getMailpit()->getSmtpPort()),
TplAestan::GLYPH_LIGHT
)
220
) . PHP_EOL .
221
$tplChangePort[
TplApp::SECTION_CALL
] . PHP_EOL .
222
TplAestan::getItemNotepad
(
$bearsamppLang
->getValue(
Lang::MENU_UPDATE_ENV_PATH
),
Path::getRootPath
() .
'/nssmEnvPaths.dat'
) . PHP_EOL;
223
224
if
(!$isInstalled) {
225
$tplInstallService =
TplApp::getActionMulti
(
226
self::ACTION_INSTALL_SERVICE,
227
null
,
228
array(
$bearsamppLang
->getValue(
Lang::MENU_INSTALL_SERVICE
),
TplAestan::GLYPH_SERVICE_INSTALL
),
229
$isInstalled,
230
get_called_class()
231
);
232
233
$result
.= $tplInstallService[
TplApp::SECTION_CALL
] . PHP_EOL . PHP_EOL .
234
$tplInstallService[
TplApp::SECTION_CONTENT
] . PHP_EOL;
235
}
else
{
236
$tplRemoveService =
TplApp::getActionMulti
(
237
self::ACTION_REMOVE_SERVICE,
238
null
,
239
array(
$bearsamppLang
->getValue(
Lang::MENU_REMOVE_SERVICE
),
TplAestan::GLYPH_SERVICE_REMOVE
),
240
!$isInstalled,
241
get_called_class()
242
);
243
244
$result
.= $tplRemoveService[
TplApp::SECTION_CALL
] . PHP_EOL . PHP_EOL .
245
$tplRemoveService[
TplApp::SECTION_CONTENT
] . PHP_EOL;
246
}
247
248
$result
.= $tplChangePort[
TplApp::SECTION_CONTENT
] . PHP_EOL;
249
250
return
$result
;
251
}
252
262
public
static
function
getActionChangeMailpitPort
()
263
{
264
global
$bearsamppBins
;
265
266
return
TplApp::getActionRun
(
Action::CHANGE_PORT
, array(
$bearsamppBins
->getMailpit()->getName())) . PHP_EOL .
267
TplAppReload::getActionReload
();
268
}
269
277
public
static
function
getActionInstallMailpitService
()
278
{
279
return
TplApp::getActionRun
(
Action::SERVICE
, array(
BinMailpit::SERVICE_NAME
,
ActionService::INSTALL
)) . PHP_EOL .
280
TplAppReload::getActionReload
();
281
}
282
290
public
static
function
getActionRemoveMailpitService
()
291
{
292
return
TplApp::getActionRun
(
Action::SERVICE
, array(
BinMailpit::SERVICE_NAME
,
ActionService::REMOVE
)) . PHP_EOL .
293
TplAppReload::getActionReload
();
294
}
295
}
296
$result
$result
Definition
ajax.apache.php:19
$bearsamppBins
global $bearsamppBins
Definition
ajax.apache.php:16
$bearsamppLang
global $bearsamppLang
Definition
ajax.apache.php:16
$bearsamppRoot
global $bearsamppRoot
Definition
ajax.apache.php:16
Action\SWITCH_VERSION
const SWITCH_VERSION
Definition
class.action.php:56
Action\SERVICE
const SERVICE
Definition
class.action.php:46
Action\CHANGE_PORT
const CHANGE_PORT
Definition
class.action.php:21
Action\CHECK_PORT
const CHECK_PORT
Definition
class.action.php:22
Action\ENABLE
const ENABLE
Definition
class.action.php:31
ActionService\REMOVE
const REMOVE
Definition
class.action.service.php:22
ActionService\INSTALL
const INSTALL
Definition
class.action.service.php:21
BinMailpit\SERVICE_NAME
const SERVICE_NAME
Definition
class.bin.mailpit.php:22
Config\DISABLED
const DISABLED
Definition
class.config.php:36
Config\ENABLED
const ENABLED
Definition
class.config.php:35
HttpClient\getWebsiteUrl
static getWebsiteUrl($path='', $fragment='', $utmSource=true)
Definition
class.httpclient.php:131
Lang\MENU_ENABLE
const MENU_ENABLE
Definition
class.lang.php:97
Lang\SERVICE
const SERVICE
Definition
class.lang.php:66
Lang\DOWNLOAD_MORE
const DOWNLOAD_MORE
Definition
class.lang.php:40
Lang\MENU_CHANGE_PORT
const MENU_CHANGE_PORT
Definition
class.lang.php:89
Lang\MENU_INSTALL_SERVICE
const MENU_INSTALL_SERVICE
Definition
class.lang.php:101
Lang\MENU_UPDATE_ENV_PATH
const MENU_UPDATE_ENV_PATH
Definition
class.lang.php:121
Lang\MENU_LOGS
const MENU_LOGS
Definition
class.lang.php:104
Lang\MENU_REMOVE_SERVICE
const MENU_REMOVE_SERVICE
Definition
class.lang.php:109
Lang\MENU_CHECK_PORT
const MENU_CHECK_PORT
Definition
class.lang.php:91
Lang\MAILPIT
const MAILPIT
Definition
class.lang.php:131
Lang\VERSIONS
const VERSIONS
Definition
class.lang.php:79
Path\getRootPath
static getRootPath($aetrayPath=false)
Definition
class.path.php:324
Path\getLocalUrl
static getLocalUrl($request=null)
Definition
class.path.php:430
TplAestan\GLYPH_LIGHT
const GLYPH_LIGHT
Definition
class.tpl.aestan.php:71
TplAestan\getItemExe
static getItemExe($caption, $exe, $glyph, $params=null)
Definition
class.tpl.aestan.php:237
TplAestan\GLYPH_CHECK
const GLYPH_CHECK
Definition
class.tpl.aestan.php:61
TplAestan\GLYPH_NETWORK
const GLYPH_NETWORK
Definition
class.tpl.aestan.php:74
TplAestan\GLYPH_SERVICE_REMOVE
const GLYPH_SERVICE_REMOVE
Definition
class.tpl.aestan.php:55
TplAestan\GLYPH_WEB_PAGE
const GLYPH_WEB_PAGE
Definition
class.tpl.aestan.php:75
TplAestan\getItemActionServiceStop
static getItemActionServiceStop($service)
Definition
class.tpl.aestan.php:346
TplAestan\GLYPH_SERVICE_INSTALL
const GLYPH_SERVICE_INSTALL
Definition
class.tpl.aestan.php:56
TplAestan\GLYPH_BROWSER
const GLYPH_BROWSER
Definition
class.tpl.aestan.php:53
TplAestan\getItemLink
static getItemLink($caption, $link, $local=false, $glyph=self::GLYPH_WEB_PAGE)
Definition
class.tpl.aestan.php:191
TplAestan\getItemNotepad
static getItemNotepad($caption, $path)
Definition
class.tpl.aestan.php:215
TplAestan\getItemActionServiceStart
static getItemActionServiceStart($service)
Definition
class.tpl.aestan.php:322
TplAestan\getItemSeparator
static getItemSeparator()
Definition
class.tpl.aestan.php:126
TplAestan\getItemActionServiceRestart
static getItemActionServiceRestart($service)
Definition
class.tpl.aestan.php:370
TplApp\getActionMulti
static getActionMulti($action, $args=array(), $item=array(), $disabled=false, $class=false)
Definition
class.tpl.app.php:153
TplApp\getMenu
static getMenu($caption, $menu, $class)
Definition
class.tpl.app.php:191
TplApp\getActionRun
static getActionRun($action, $args=array(), $item=array(), $waitUntilTerminated=true)
Definition
class.tpl.app.php:116
TplApp\SECTION_CALL
const SECTION_CALL
Definition
class.tpl.app.php:23
TplApp\SECTION_CONTENT
const SECTION_CONTENT
Definition
class.tpl.app.php:24
TplApp\getMenuEnable
static getMenuEnable($caption, $menu, $class, $enabled=true)
Definition
class.tpl.app.php:213
TplAppMailpit
Definition
class.tpl.app.mailpit.php:18
TplAppMailpit\getActionInstallMailpitService
static getActionInstallMailpitService()
Definition
class.tpl.app.mailpit.php:277
TplAppMailpit\getActionEnableMailpit
static getActionEnableMailpit($enable)
Definition
class.tpl.app.mailpit.php:159
TplAppMailpit\getMenuMailpitService
static getMenuMailpitService()
Definition
class.tpl.app.mailpit.php:198
TplAppMailpit\ACTION_ENABLE
const ACTION_ENABLE
Definition
class.tpl.app.mailpit.php:23
TplAppMailpit\MENU
const MENU
Definition
class.tpl.app.mailpit.php:19
TplAppMailpit\process
static process()
Definition
class.tpl.app.mailpit.php:40
TplAppMailpit\ACTION_SWITCH_VERSION
const ACTION_SWITCH_VERSION
Definition
class.tpl.app.mailpit.php:24
TplAppMailpit\MENU_VERSIONS
const MENU_VERSIONS
Definition
class.tpl.app.mailpit.php:20
TplAppMailpit\MENU_SERVICE
const MENU_SERVICE
Definition
class.tpl.app.mailpit.php:21
TplAppMailpit\getActionChangeMailpitPort
static getActionChangeMailpitPort()
Definition
class.tpl.app.mailpit.php:262
TplAppMailpit\getMenuMailpit
static getMenuMailpit()
Definition
class.tpl.app.mailpit.php:60
TplAppMailpit\ACTION_INSTALL_SERVICE
const ACTION_INSTALL_SERVICE
Definition
class.tpl.app.mailpit.php:26
TplAppMailpit\ACTION_REMOVE_SERVICE
const ACTION_REMOVE_SERVICE
Definition
class.tpl.app.mailpit.php:27
TplAppMailpit\getActionRemoveMailpitService
static getActionRemoveMailpitService()
Definition
class.tpl.app.mailpit.php:290
TplAppMailpit\ACTION_CHANGE_PORT
const ACTION_CHANGE_PORT
Definition
class.tpl.app.mailpit.php:25
TplAppMailpit\getActionSwitchMailpitVersion
static getActionSwitchMailpitVersion($version)
Definition
class.tpl.app.mailpit.php:178
TplAppMailpit\getMenuMailpitVersions
static getMenuMailpitVersions()
Definition
class.tpl.app.mailpit.php:123
TplAppReload\getActionReload
static getActionReload()
Definition
class.tpl.app.reload.php:47
$bearsamppConfig
global $bearsamppConfig
Definition
homepage.php:46
sandbox
core
classes
tpls
app
class.tpl.app.mailpit.php
Generated by
1.17.0