2024.8.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()

static TplAppMailpit::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.

@global object $bearsamppBins Provides access to system binaries and their configurations.

Returns
string The generated action string for changing the Mailpit port.

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

250 {
251 global $bearsamppBins;
252
253 return TplApp::getActionRun(Action::CHANGE_PORT, array($bearsamppBins->getMailpit()->getName())) . PHP_EOL .
255 }
global $bearsamppBins
const CHANGE_PORT
static getActionRun($action, $args=array(), $item=array(), $waitUntilTerminated=true)

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

◆ getActionEnableMailpit()

static TplAppMailpit::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.

@global object $bearsamppBins Provides access to system binaries and their configurations.

Parameters
int$enableThe enable flag (1 to enable, 0 to disable).
Returns
string The generated action string for enabling or disabling Mailpit.

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

155 {
156 global $bearsamppBins;
157
158 return TplApp::getActionRun(Action::ENABLE, array($bearsamppBins->getMailpit()->getName(), $enable)) . PHP_EOL .
160 }
const ENABLE

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

◆ getActionInstallMailpitService()

static TplAppMailpit::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 264 of file class.tpl.app.mailpit.php.

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

◆ getActionRemoveMailpitService()

static TplAppMailpit::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 277 of file class.tpl.app.mailpit.php.

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

◆ getActionSwitchMailpitVersion()

static TplAppMailpit::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.

@global object $bearsamppBins Provides access to system binaries and their configurations.

Parameters
string$versionThe version to switch to.
Returns
string The generated action string for switching the Mailpit version.

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

173 {
174 global $bearsamppBins;
175
176 return TplApp::getActionRun(Action::SWITCH_VERSION, array($bearsamppBins->getMailpit()->getName(), $version)) . PHP_EOL .
178 }
const SWITCH_VERSION

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

◆ getMenuMailpit()

static TplAppMailpit::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.

@global object $bearsamppRoot Provides access to the root path of the application. @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.

Returns
string The generated Mailpit menu items and actions.

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 Util::getWebsiteUrl('module/mailpit', '#releases'),
71 false,
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(
100 $bearsamppConfig->getBrowser(),
102 $bearsamppRoot->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 }
global $bearsamppLang
global $bearsamppRoot
const DISABLED
const MENU_LOGS
const VERSIONS
const DOWNLOAD_MORE
const SERVICE
const MAILPIT
static getItemSeparator()
static getItemLink($caption, $link, $local=false, $glyph=self::GLYPH_WEB_PAGE)
static getItemExe($caption, $exe, $glyph, $params=null)
static getItemNotepad($caption, $path)
static getActionMulti($action, $args=array(), $item=array(), $disabled=false, $class=false)
const SECTION_CALL
const SECTION_CONTENT
static getMenu($caption, $menu, $class)
static getWebsiteUrl($path='', $fragment='', $utmSource=true)
global $bearsamppConfig
Definition homepage.php:26

References $bearsamppBins, $bearsamppConfig, $bearsamppLang, $bearsamppRoot, Config\DISABLED, Lang\DOWNLOAD_MORE, Config\ENABLED, TplApp\getActionMulti(), TplAestan\getItemExe(), TplAestan\getItemLink(), TplAestan\getItemNotepad(), TplAestan\getItemSeparator(), TplApp\getMenu(), Util\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.

◆ getMenuMailpitService()

static TplAppMailpit::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.

@global object $bearsamppRoot Provides access to the root path of the application. @global object $bearsamppLang Provides language support for retrieving language-specific values. @global object $bearsamppBins Provides access to system binaries and their configurations.

Returns
string The generated Mailpit service menu items and actions.

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

193 {
195
196 $tplChangePort = TplApp::getActionMulti(
197 self::ACTION_CHANGE_PORT, null,
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 .
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), $bearsamppRoot->getRootPath() . '/nssmEnvPaths.dat') . PHP_EOL;
214
215 if (!$isInstalled) {
216 $tplInstallService = TplApp::getActionMulti(
217 self::ACTION_INSTALL_SERVICE, null,
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,
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 }
$result
const CHECK_PORT
const MENU_INSTALL_SERVICE
const MENU_UPDATE_ENV_PATH
const MENU_REMOVE_SERVICE
const MENU_CHECK_PORT
const MENU_CHANGE_PORT
const GLYPH_SERVICE_REMOVE
static getItemActionServiceStop($service)
static getItemActionServiceStart($service)
static getItemActionServiceRestart($service)
const GLYPH_SERVICE_INSTALL

References $bearsamppBins, $bearsamppLang, $bearsamppRoot, $result, Action\CHECK_PORT, TplApp\getActionMulti(), TplApp\getActionRun(), TplAestan\getItemActionServiceRestart(), TplAestan\getItemActionServiceStart(), TplAestan\getItemActionServiceStop(), TplAestan\getItemNotepad(), TplAestan\getItemSeparator(), 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.

◆ getMenuMailpitVersions()

static TplAppMailpit::getMenuMailpitVersions ( )
static

Generates the Mailpit versions menu.

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

@global object $bearsamppBins Provides access to system binaries and their configurations.

Returns
string The generated Mailpit versions menu items and actions.

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

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 }

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

◆ process()

static TplAppMailpit::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.

@global object $bearsamppLang Provides language support for retrieving language-specific values. @global object $bearsamppBins Provides access to system binaries and their configurations.

Returns
array The generated menu for enabling or disabling Mailpit.

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 caller graph for this function:

Field Documentation

◆ ACTION_CHANGE_PORT

const TplAppMailpit::ACTION_CHANGE_PORT = 'changeMailpitPort'

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

◆ ACTION_ENABLE

const TplAppMailpit::ACTION_ENABLE = 'enableMailpit'

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

◆ ACTION_INSTALL_SERVICE

const TplAppMailpit::ACTION_INSTALL_SERVICE = 'installMailpitService'

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

◆ ACTION_REMOVE_SERVICE

const TplAppMailpit::ACTION_REMOVE_SERVICE = 'removeMailpitService'

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

◆ ACTION_SWITCH_VERSION

const TplAppMailpit::ACTION_SWITCH_VERSION = 'switchMailpitVersion'

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

◆ MENU

const TplAppMailpit::MENU = 'mailpit'

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

◆ MENU_SERVICE

const TplAppMailpit::MENU_SERVICE = 'mailpitService'

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

◆ MENU_VERSIONS

const TplAppMailpit::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: