Bearsampp
2026.7.11
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-2024 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, array($isEnabled ?
Config::DISABLED
:
Config::ENABLED
),
78
array(
$bearsamppLang
->getValue(
Lang::MENU_ENABLE
), $isEnabled ?
TplAestan::GLYPH_CHECK
:
''
),
79
false
, get_called_class()
80
);
81
$resultItems .= $tplEnable[
TplApp::SECTION_CALL
] . PHP_EOL;
82
$resultActions .= $tplEnable[
TplApp::SECTION_CONTENT
] . PHP_EOL;
83
84
if
($isEnabled) {
85
$resultItems .=
TplAestan::getItemSeparator
() . PHP_EOL;
86
87
// Versions
88
$tplVersions =
TplApp::getMenu
(
$bearsamppLang
->getValue(
Lang::VERSIONS
), self::MENU_VERSIONS, get_called_class());
89
$resultItems .= $tplVersions[
TplApp::SECTION_CALL
] . PHP_EOL;
90
$resultActions .= $tplVersions[
TplApp::SECTION_CONTENT
] . PHP_EOL;
91
92
// Service
93
$tplService =
TplApp::getMenu
(
$bearsamppLang
->getValue(
Lang::SERVICE
), self::MENU_SERVICE, get_called_class());
94
$resultItems .= $tplService[
TplApp::SECTION_CALL
] . PHP_EOL;
95
$resultActions .= $tplService[
TplApp::SECTION_CONTENT
] . PHP_EOL;
96
97
// Web page
98
$resultItems .=
TplAestan::getItemExe
(
99
$bearsamppLang
->getValue(
Lang::MAILPIT
),
100
$bearsamppConfig
->getBrowser(),
101
TplAestan::GLYPH_WEB_PAGE
,
102
Path::getLocalUrl
() .
':'
.
$bearsamppBins
->getMailpit()->getUiPort() .
'/'
.
$bearsamppBins
->getMailpit()->getWebRoot()
103
) . PHP_EOL;
104
105
// Log
106
$resultItems .=
TplAestan::getItemNotepad
(
$bearsamppLang
->getValue(
Lang::MENU_LOGS
),
$bearsamppBins
->getMailpit()->getLog()) . PHP_EOL;
107
}
108
109
return
$resultItems . PHP_EOL . $resultActions;
110
}
111
121
public
static
function
getMenuMailpitVersions
()
122
{
123
global
$bearsamppBins
;
124
$items =
''
;
125
$actions =
''
;
126
127
foreach
(
$bearsamppBins
->getMailpit()->getVersionList() as $version) {
128
$tplSwitchMailpitVersion =
TplApp::getActionMulti
(
129
self::ACTION_SWITCH_VERSION, array($version),
130
array($version, $version ==
$bearsamppBins
->getMailpit()->getVersion() ?
TplAestan::GLYPH_CHECK
:
''
),
131
false
, get_called_class()
132
);
133
134
// Item
135
$items .= $tplSwitchMailpitVersion[
TplApp::SECTION_CALL
] . PHP_EOL;
136
137
// Action
138
$actions .= PHP_EOL . $tplSwitchMailpitVersion[
TplApp::SECTION_CONTENT
];
139
}
140
141
return
$items . $actions;
142
}
143
154
public
static
function
getActionEnableMailpit
($enable)
155
{
156
global
$bearsamppBins
;
157
158
return
TplApp::getActionRun
(
Action::ENABLE
, array(
$bearsamppBins
->getMailpit()->getName(), $enable)) . PHP_EOL .
159
TplAppReload::getActionReload
();
160
}
161
172
public
static
function
getActionSwitchMailpitVersion
($version)
173
{
174
global
$bearsamppBins
;
175
176
return
TplApp::getActionRun
(
Action::SWITCH_VERSION
, array(
$bearsamppBins
->getMailpit()->getName(), $version)) . PHP_EOL .
177
TplAppReload::getActionReload
() . PHP_EOL;
178
}
179
192
public
static
function
getMenuMailpitService
()
193
{
194
global
$bearsamppRoot
,
$bearsamppLang
,
$bearsamppBins
;
195
196
$tplChangePort =
TplApp::getActionMulti
(
197
self::ACTION_CHANGE_PORT,
null
,
198
array(
$bearsamppLang
->getValue(
Lang::MENU_CHANGE_PORT
),
TplAestan::GLYPH_NETWORK
),
199
false
, get_called_class()
200
);
201
202
$isInstalled =
$bearsamppBins
->getMailpit()->getService()->isInstalled();
203
204
$result
=
TplAestan::getItemActionServiceStart
(
$bearsamppBins
->getMailpit()->getService()->getName()) . PHP_EOL .
205
TplAestan::getItemActionServiceStop
(
$bearsamppBins
->getMailpit()->getService()->getName()) . PHP_EOL .
206
TplAestan::getItemActionServiceRestart
(
$bearsamppBins
->getMailpit()->getService()->getName()) . PHP_EOL .
207
TplAestan::getItemSeparator
() . PHP_EOL .
208
TplApp::getActionRun
(
209
Action::CHECK_PORT
, array(
$bearsamppBins
->getMailpit()->getName(),
$bearsamppBins
->getMailpit()->getSmtpPort()),
210
array(sprintf(
$bearsamppLang
->getValue(
Lang::MENU_CHECK_PORT
),
$bearsamppBins
->getMailpit()->getSmtpPort()),
TplAestan::GLYPH_LIGHT
)
211
) . PHP_EOL .
212
$tplChangePort[
TplApp::SECTION_CALL
] . PHP_EOL .
213
TplAestan::getItemNotepad
(
$bearsamppLang
->getValue(
Lang::MENU_UPDATE_ENV_PATH
),
Path::getRootPath
() .
'/nssmEnvPaths.dat'
) . PHP_EOL;
214
215
if
(!$isInstalled) {
216
$tplInstallService =
TplApp::getActionMulti
(
217
self::ACTION_INSTALL_SERVICE,
null
,
218
array(
$bearsamppLang
->getValue(
Lang::MENU_INSTALL_SERVICE
),
TplAestan::GLYPH_SERVICE_INSTALL
),
219
$isInstalled, get_called_class()
220
);
221
222
$result
.= $tplInstallService[
TplApp::SECTION_CALL
] . PHP_EOL . PHP_EOL .
223
$tplInstallService[
TplApp::SECTION_CONTENT
] . PHP_EOL;
224
}
else
{
225
$tplRemoveService =
TplApp::getActionMulti
(
226
self::ACTION_REMOVE_SERVICE,
null
,
227
array(
$bearsamppLang
->getValue(
Lang::MENU_REMOVE_SERVICE
),
TplAestan::GLYPH_SERVICE_REMOVE
),
228
!$isInstalled, get_called_class()
229
);
230
231
$result
.= $tplRemoveService[
TplApp::SECTION_CALL
] . PHP_EOL . PHP_EOL .
232
$tplRemoveService[
TplApp::SECTION_CONTENT
] . PHP_EOL;
233
}
234
235
$result
.= $tplChangePort[
TplApp::SECTION_CONTENT
] . PHP_EOL;
236
237
return
$result
;
238
}
239
249
public
static
function
getActionChangeMailpitPort
()
250
{
251
global
$bearsamppBins
;
252
253
return
TplApp::getActionRun
(
Action::CHANGE_PORT
, array(
$bearsamppBins
->getMailpit()->getName())) . PHP_EOL .
254
TplAppReload::getActionReload
();
255
}
256
264
public
static
function
getActionInstallMailpitService
()
265
{
266
return
TplApp::getActionRun
(
Action::SERVICE
, array(
BinMailpit::SERVICE_NAME
,
ActionService::INSTALL
)) . PHP_EOL .
267
TplAppReload::getActionReload
();
268
}
269
277
public
static
function
getActionRemoveMailpitService
()
278
{
279
return
TplApp::getActionRun
(
Action::SERVICE
, array(
BinMailpit::SERVICE_NAME
,
ActionService::REMOVE
)) . PHP_EOL .
280
TplAppReload::getActionReload
();
281
}
282
}
283
$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:19
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:134
Lang\MENU_ENABLE
const MENU_ENABLE
Definition
class.lang.php:98
Lang\SERVICE
const SERVICE
Definition
class.lang.php:67
Lang\DOWNLOAD_MORE
const DOWNLOAD_MORE
Definition
class.lang.php:41
Lang\MENU_CHANGE_PORT
const MENU_CHANGE_PORT
Definition
class.lang.php:90
Lang\MENU_INSTALL_SERVICE
const MENU_INSTALL_SERVICE
Definition
class.lang.php:102
Lang\MENU_UPDATE_ENV_PATH
const MENU_UPDATE_ENV_PATH
Definition
class.lang.php:122
Lang\MENU_LOGS
const MENU_LOGS
Definition
class.lang.php:105
Lang\MENU_REMOVE_SERVICE
const MENU_REMOVE_SERVICE
Definition
class.lang.php:110
Lang\MENU_CHECK_PORT
const MENU_CHECK_PORT
Definition
class.lang.php:92
Lang\MAILPIT
const MAILPIT
Definition
class.lang.php:130
Lang\VERSIONS
const VERSIONS
Definition
class.lang.php:80
Path\getRootPath
static getRootPath($aetrayPath=false)
Definition
class.path.php:309
Path\getLocalUrl
static getLocalUrl($request=null)
Definition
class.path.php:407
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:232
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:335
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:188
TplAestan\getItemNotepad
static getItemNotepad($caption, $path)
Definition
class.tpl.aestan.php:211
TplAestan\getItemActionServiceStart
static getItemActionServiceStart($service)
Definition
class.tpl.aestan.php:313
TplAestan\getItemSeparator
static getItemSeparator()
Definition
class.tpl.aestan.php:125
TplAestan\getItemActionServiceRestart
static getItemActionServiceRestart($service)
Definition
class.tpl.aestan.php:357
TplApp\getActionMulti
static getActionMulti($action, $args=array(), $item=array(), $disabled=false, $class=false)
Definition
class.tpl.app.php:152
TplApp\getMenu
static getMenu($caption, $menu, $class)
Definition
class.tpl.app.php:190
TplApp\getActionRun
static getActionRun($action, $args=array(), $item=array(), $waitUntilTerminated=true)
Definition
class.tpl.app.php:115
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:212
TplAppMailpit
Definition
class.tpl.app.mailpit.php:18
TplAppMailpit\getActionInstallMailpitService
static getActionInstallMailpitService()
Definition
class.tpl.app.mailpit.php:264
TplAppMailpit\getActionEnableMailpit
static getActionEnableMailpit($enable)
Definition
class.tpl.app.mailpit.php:154
TplAppMailpit\getMenuMailpitService
static getMenuMailpitService()
Definition
class.tpl.app.mailpit.php:192
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:249
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:277
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:172
TplAppMailpit\getMenuMailpitVersions
static getMenuMailpitVersions()
Definition
class.tpl.app.mailpit.php:121
TplAppReload\getActionReload
static getActionReload()
Definition
class.tpl.app.reload.php:44
$bearsamppConfig
global $bearsamppConfig
Definition
homepage.php:41
sandbox
core
classes
tpls
app
class.tpl.app.mailpit.php
Generated by
1.17.0