Bearsampp 2026.9.23
Loading...
Searching...
No Matches
TplAppMailpit Class Reference

Static Public Member Functions

static getActionChangeMailpitPort ()
static getActionEnableMailpit ($enable)
static getActionInstallMailpitService ()
static getActionRemoveMailpitService ()
static getActionSwitchMailpitVersion ($version)
static getMenuMailpit ()
static getMenuMailpitService ()
static getMenuMailpitVersions ()
static process ()

Data Fields

const ACTION_CHANGE_PORT = 'changeMailpitPort'
const ACTION_ENABLE = 'enableMailpit'
const ACTION_INSTALL_SERVICE = 'installMailpitService'
const ACTION_REMOVE_SERVICE = 'removeMailpitService'
const ACTION_SWITCH_VERSION = 'switchMailpitVersion'
const MENU = 'mailpit'
const MENU_SERVICE = 'mailpitService'
const MENU_VERSIONS = 'mailpitVersions'

Detailed Description

Class TplAppMailpit

This class provides methods to generate menus and actions for managing the Mailpit application. It includes functionalities for enabling/disabling Mailpit, switching versions, changing ports, and managing the Mailpit service.

Definition at line 17 of file class.tpl.app.mailpit.php.

Member Function Documentation

◆ getActionChangeMailpitPort()

getActionChangeMailpitPort ( )
static

Generates the action to change the Mailpit port.

This method creates the action string for changing the Mailpit port and includes a command to reload the application.

Returns
string The generated action string for changing the Mailpit port. @global object $bearsamppBins Provides access to system binaries and their configurations.

Definition at line 262 of file class.tpl.app.mailpit.php.

263 {
264 global $bearsamppBins;
265
266 return TplApp::getActionRun(Action::CHANGE_PORT, array($bearsamppBins->getMailpit()->getName())) . PHP_EOL .
268 }
global $bearsamppBins
const CHANGE_PORT
static getActionRun($action, $args=array(), $item=array(), $waitUntilTerminated=true)

References $bearsamppBins, Action\CHANGE_PORT, TplAppReload\getActionReload(), and TplApp\getActionRun().

Here is the call graph for this function:

◆ getActionEnableMailpit()

getActionEnableMailpit ( $enable)
static

Generates the action to enable or disable Mailpit.

This method creates the action string for enabling or disabling Mailpit and includes a command to reload the application.

Parameters
int$enableThe enable flag (1 to enable, 0 to disable).
Returns
string The generated action string for enabling or disabling Mailpit. @global object $bearsamppBins Provides access to system binaries and their configurations.

Definition at line 159 of file class.tpl.app.mailpit.php.

160 {
161 global $bearsamppBins;
162
163 return TplApp::getActionRun(Action::ENABLE, array($bearsamppBins->getMailpit()->getName(), $enable)) . PHP_EOL .
165 }
const ENABLE

References $bearsamppBins, Action\ENABLE, TplAppReload\getActionReload(), and TplApp\getActionRun().

Here is the call graph for this function:

◆ getActionInstallMailpitService()

getActionInstallMailpitService ( )
static

Generates the action to install the Mailpit service.

This method creates the action string for installing the Mailpit service and includes a command to reload the application.

Returns
string The generated action string for installing the Mailpit service.

Definition at line 277 of file class.tpl.app.mailpit.php.

References TplAppReload\getActionReload(), TplApp\getActionRun(), ActionService\INSTALL, Action\SERVICE, and BinMailpit\SERVICE_NAME.

Here is the call graph for this function:

◆ getActionRemoveMailpitService()

getActionRemoveMailpitService ( )
static

Generates the action to remove the Mailpit service.

This method creates the action string for removing the Mailpit service and includes a command to reload the application.

Returns
string The generated action string for removing the Mailpit service.

Definition at line 290 of file class.tpl.app.mailpit.php.

References TplAppReload\getActionReload(), TplApp\getActionRun(), ActionService\REMOVE, Action\SERVICE, and BinMailpit\SERVICE_NAME.

Here is the call graph for this function:

◆ getActionSwitchMailpitVersion()

getActionSwitchMailpitVersion ( $version)
static

Generates the action to switch the Mailpit version.

This method creates the action string for switching the Mailpit version and includes a command to reload the application.

Parameters
string$versionThe version to switch to.
Returns
string The generated action string for switching the Mailpit version. @global object $bearsamppBins Provides access to system binaries and their configurations.

Definition at line 178 of file class.tpl.app.mailpit.php.

179 {
180 global $bearsamppBins;
181
182 return TplApp::getActionRun(Action::SWITCH_VERSION, array($bearsamppBins->getMailpit()->getName(), $version)) . PHP_EOL .
184 }
const SWITCH_VERSION

References $bearsamppBins, TplAppReload\getActionReload(), TplApp\getActionRun(), and Action\SWITCH_VERSION.

Here is the call graph for this function:

◆ getMenuMailpit()

getMenuMailpit ( )
static

Generates the Mailpit menu.

This method creates the menu items and associated actions for Mailpit, including options for downloading, enabling, switching versions, managing the service, and viewing logs.

Returns
string The generated Mailpit menu items and actions. @global object $bearsamppConfig Provides access to the application configuration. @global object $bearsamppBins Provides access to system binaries and their configurations. @global object $bearsamppLang Provides language support for retrieving language-specific values.

@global object $bearsamppRoot Provides access to the root path of the application.

Definition at line 60 of file class.tpl.app.mailpit.php.

61 {
63 $resultItems = $resultActions = '';
64
65 $isEnabled = $bearsamppBins->getMailpit()->isEnable();
66
67 // Download
68 $resultItems .= TplAestan::getItemLink(
70 HttpClient::getWebsiteUrl('module/mailpit', '#releases'),
71 false,
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(),
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 }
global $bearsamppLang
global $bearsamppRoot
const DISABLED
const ENABLED
static getWebsiteUrl($path='', $fragment='', $utmSource=true)
const MENU_ENABLE
const SERVICE
const DOWNLOAD_MORE
const MENU_LOGS
const MAILPIT
const VERSIONS
static getLocalUrl($request=null)
static getItemExe($caption, $exe, $glyph, $params=null)
static getItemLink($caption, $link, $local=false, $glyph=self::GLYPH_WEB_PAGE)
static getItemNotepad($caption, $path)
static getItemSeparator()
static getActionMulti($action, $args=array(), $item=array(), $disabled=false, $class=false)
static getMenu($caption, $menu, $class)
const SECTION_CALL
const SECTION_CONTENT
global $bearsamppConfig
Definition homepage.php:46

References $bearsamppBins, $bearsamppConfig, $bearsamppLang, $bearsamppRoot, Config\DISABLED, Lang\DOWNLOAD_MORE, Config\ENABLED, TplApp\getActionMulti(), TplAestan\getItemExe(), TplAestan\getItemLink(), TplAestan\getItemNotepad(), TplAestan\getItemSeparator(), Path\getLocalUrl(), TplApp\getMenu(), HttpClient\getWebsiteUrl(), TplAestan\GLYPH_BROWSER, TplAestan\GLYPH_CHECK, TplAestan\GLYPH_WEB_PAGE, Lang\MAILPIT, Lang\MENU_ENABLE, Lang\MENU_LOGS, TplApp\SECTION_CALL, TplApp\SECTION_CONTENT, Lang\SERVICE, and Lang\VERSIONS.

Here is the call graph for this function:

◆ getMenuMailpitService()

getMenuMailpitService ( )
static

Generates the Mailpit service menu.

This method creates the menu items and associated actions for managing the Mailpit service, including starting, stopping, restarting, changing ports, and installing or removing the service.

Returns
string The generated Mailpit service menu items and actions. @global object $bearsamppLang Provides language support for retrieving language-specific values. @global object $bearsamppBins Provides access to system binaries and their configurations.

@global object $bearsamppRoot Provides access to the root path of the application.

Definition at line 198 of file class.tpl.app.mailpit.php.

199 {
201
202 $tplChangePort = TplApp::getActionMulti(
203 self::ACTION_CHANGE_PORT,
204 null,
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 .
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,
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,
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 }
$result
const CHECK_PORT
const MENU_CHANGE_PORT
const MENU_INSTALL_SERVICE
const MENU_UPDATE_ENV_PATH
const MENU_REMOVE_SERVICE
const MENU_CHECK_PORT
static getRootPath($aetrayPath=false)
const GLYPH_SERVICE_REMOVE
static getItemActionServiceStop($service)
const GLYPH_SERVICE_INSTALL
static getItemActionServiceStart($service)
static getItemActionServiceRestart($service)

References $bearsamppBins, $bearsamppLang, $bearsamppRoot, $result, Action\CHECK_PORT, TplApp\getActionMulti(), TplApp\getActionRun(), TplAestan\getItemActionServiceRestart(), TplAestan\getItemActionServiceStart(), TplAestan\getItemActionServiceStop(), TplAestan\getItemNotepad(), TplAestan\getItemSeparator(), Path\getRootPath(), TplAestan\GLYPH_LIGHT, TplAestan\GLYPH_NETWORK, TplAestan\GLYPH_SERVICE_INSTALL, TplAestan\GLYPH_SERVICE_REMOVE, Lang\MENU_CHANGE_PORT, Lang\MENU_CHECK_PORT, Lang\MENU_INSTALL_SERVICE, Lang\MENU_REMOVE_SERVICE, Lang\MENU_UPDATE_ENV_PATH, TplApp\SECTION_CALL, and TplApp\SECTION_CONTENT.

Here is the call graph for this function:

◆ getMenuMailpitVersions()

getMenuMailpitVersions ( )
static

Generates the Mailpit versions menu.

This method creates the menu items and associated actions for switching between different versions of Mailpit.

Returns
string The generated Mailpit versions menu items and actions. @global object $bearsamppBins Provides access to system binaries and their configurations.

Definition at line 123 of file class.tpl.app.mailpit.php.

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 }

References $bearsamppBins, TplApp\getActionMulti(), TplAestan\GLYPH_CHECK, TplApp\SECTION_CALL, and TplApp\SECTION_CONTENT.

Here is the call graph for this function:

◆ process()

process ( )
static

Processes the Mailpit menu.

This method generates the menu for enabling or disabling Mailpit. It uses the global language object to retrieve the localized string for Mailpit.

Returns
array The generated menu for enabling or disabling Mailpit. @global object $bearsamppBins Provides access to system binaries and their configurations.

@global object $bearsamppLang Provides language support for retrieving language-specific values.

Definition at line 40 of file class.tpl.app.mailpit.php.

41 {
43
44 return TplApp::getMenuEnable($bearsamppLang->getValue(Lang::MAILPIT), self::MENU, get_called_class(), $bearsamppBins->getMailpit()->isEnable());
45 }
static getMenuEnable($caption, $menu, $class, $enabled=true)

References $bearsamppBins, $bearsamppLang, TplApp\getMenuEnable(), and Lang\MAILPIT.

Referenced by TplApp\getSectionMenuLeft().

Here is the call graph for this function:
Here is the caller graph for this function:

Field Documentation

◆ ACTION_CHANGE_PORT

const ACTION_CHANGE_PORT = 'changeMailpitPort'

Definition at line 25 of file class.tpl.app.mailpit.php.

◆ ACTION_ENABLE

const ACTION_ENABLE = 'enableMailpit'

Definition at line 23 of file class.tpl.app.mailpit.php.

◆ ACTION_INSTALL_SERVICE

const ACTION_INSTALL_SERVICE = 'installMailpitService'

Definition at line 26 of file class.tpl.app.mailpit.php.

◆ ACTION_REMOVE_SERVICE

const ACTION_REMOVE_SERVICE = 'removeMailpitService'

Definition at line 27 of file class.tpl.app.mailpit.php.

◆ ACTION_SWITCH_VERSION

const ACTION_SWITCH_VERSION = 'switchMailpitVersion'

Definition at line 24 of file class.tpl.app.mailpit.php.

◆ MENU

const MENU = 'mailpit'

Definition at line 19 of file class.tpl.app.mailpit.php.

◆ MENU_SERVICE

const MENU_SERVICE = 'mailpitService'

Definition at line 21 of file class.tpl.app.mailpit.php.

◆ MENU_VERSIONS

const MENU_VERSIONS = 'mailpitVersions'

Definition at line 20 of file class.tpl.app.mailpit.php.


The documentation for this class was generated from the following file: