Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions administrator/language/en-GB/lib_joomla.ini
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,7 @@ JLIB_INSTALLER_ERROR_COMP_INSTALL_DIR_ADMIN="Component Install: Another componen
JLIB_INSTALLER_ERROR_COMP_INSTALL_DIR_SITE="Component Install: Another component is already using folder: %s"
JLIB_INSTALLER_ERROR_COMP_INSTALL_FAILED_TO_CREATE_DIRECTORY_ADMIN="Component Install: Failed to create administrator folder: %s"
JLIB_INSTALLER_ERROR_COMP_INSTALL_FAILED_TO_CREATE_DIRECTORY_SITE="Component Install: Failed to create site folder: %s"
JLIB_INSTALLER_ERROR_COMP_INSTALL_FAILED_TO_CREATE_DASHBOARD="Component Install: Failed to create extension dashboard: %s"
JLIB_INSTALLER_ERROR_COMP_REFRESH_MANIFEST_CACHE="Component Refresh manifest cache: Failed to store component details."
JLIB_INSTALLER_ERROR_COMP_REMOVING_ADMIN_MENUS_FAILED="Could not delete the Administrator menus."
JLIB_INSTALLER_ERROR_COMP_UNINSTALL_CUSTOM="Component Uninstall: Custom Uninstall script unsuccessful."
Expand Down
1 change: 1 addition & 0 deletions language/en-GB/lib_joomla.ini
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,7 @@ JLIB_INSTALLER_ERROR_COMP_INSTALL_DIR_ADMIN="Component Install: Another componen
JLIB_INSTALLER_ERROR_COMP_INSTALL_DIR_SITE="Component Install: Another component is already using folder: %s"
JLIB_INSTALLER_ERROR_COMP_INSTALL_FAILED_TO_CREATE_DIRECTORY_ADMIN="Component Install: Failed to create administrator folder: %s"
JLIB_INSTALLER_ERROR_COMP_INSTALL_FAILED_TO_CREATE_DIRECTORY_SITE="Component Install: Failed to create site folder: %s"
JLIB_INSTALLER_ERROR_COMP_INSTALL_FAILED_TO_CREATE_DASHBOARD="Component Install: Failed to create extension dashboard: %s"
JLIB_INSTALLER_ERROR_COMP_REFRESH_MANIFEST_CACHE="Component Refresh manifest cache: Failed to store component details."
JLIB_INSTALLER_ERROR_COMP_REMOVING_ADMIN_MENUS_FAILED="Could not delete the Administrator menus."
JLIB_INSTALLER_ERROR_COMP_UNINSTALL_CUSTOM="Component Uninstall: Custom Uninstall script unsuccessful."
Expand Down
46 changes: 46 additions & 0 deletions libraries/src/Installer/InstallerScript.php
Original file line number Diff line number Diff line change
Expand Up @@ -369,4 +369,50 @@ public function moveCliFiles()
}
}
}

/**
* Creates the dashboard menu module
*
* @param string $dashboard The name of the dashboard
* @param string $preset The name of the menu preset
*
* @return void
*
* @throws \Exception
* @since 4.0
*/
public function addDashboardMenu(string $dashboard, string $preset)
{
$model = Factory::getApplication()->bootComponent('com_modules')->getMVCFactory()->createModel('Module', 'Administrator', ['ignore_request' => true]);
$module = array(
'id' => 0,
'asset_id' => 0,
'language' => '*',
'note' => '',
'published' => 1,
'assignment' => 0,
'client_id' => 1,
'showtitle' => 0,
'content' => '',
'module' => 'mod_submenu',
'position' => 'cpanel-' . $dashboard,
);

// Try to get a translated module title, otherwise fall back to a fixed string.
$titleKey = strtoupper('COM_' . $this->extension . '_DASHBOARD_' . $dashboard . '_TITLE');
$title = Text::_($titleKey);
$module['title'] = ($title === $titleKey) ? ucfirst($dashboard) . ' Dashboard' : $title;

$module['access'] = (int) Factory::getApplication()->get('access', 1);
$module['params'] = array(
'menutype' => '*',
'preset' => $preset,
'style' => 'System-none',
);

if (!$model->save($module))
{
Factory::getApplication()->enqueueMessage(Text::sprintf('JLIB_INSTALLER_ERROR_COMP_INSTALL_FAILED_TO_CREATE_DASHBOARD', $model->getError()));
}
}
}