Files
MokoSuiteCross/source/packages/com_mokosuitecross/src/Helper/MokoSuiteCrossHelper.php
T
jmiller 7b0c3b2e4b
Universal: Pre-Release / Build Pre-Release (${{ inputs.stability || github.ref_name }}) (push) Successful in 10s
fix: add missing calendar/analytics submenu entries and language strings
- Add 'calendar' and 'analytics' entries to MokoSuiteCrossHelper submenu
- Add COM_MOKOSUITECROSS_CALENDAR_PREV_MONTH/NEXT_MONTH/TODAY strings
- Add COM_MOKOSUITECROSS_SUBMENU_CALENDAR string

Authored-by: Moko Consulting
2026-06-28 12:05:31 -05:00

99 lines
3.2 KiB
PHP

<?php
/**
* @package MokoSuiteCross
* @subpackage com_mokosuitecross
* @author Moko Consulting <hello@mokoconsulting.tech>
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
* @license GNU General Public License version 3 or later; see LICENSE
* SPDX-License-Identifier: GPL-3.0-or-later
*/
namespace Joomla\Component\MokoSuiteCross\Administrator\Helper;
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
/**
* Component helper — renders the admin submenu.
*
* Uses Joomla 5+ toolbar submenu API when available, falling back to the
* deprecated Sidebar API for Joomla 4 compatibility.
*/
class MokoSuiteCrossHelper
{
/**
* Configure the submenu links.
*
* Called from each view's display() to highlight the active item.
*
* @param string $activeView The current view name
*
* @return void
*/
public static function addSubmenu(string $activeView): void
{
$views = [
'dashboard' => 'COM_MOKOSUITECROSS_SUBMENU_DASHBOARD',
'posts' => 'COM_MOKOSUITECROSS_SUBMENU_POSTS',
'services' => 'COM_MOKOSUITECROSS_SUBMENU_SERVICES',
'templates' => 'COM_MOKOSUITECROSS_SUBMENU_TEMPLATES',
'logs' => 'COM_MOKOSUITECROSS_SUBMENU_LOGS',
'calendar' => 'COM_MOKOSUITECROSS_SUBMENU_CALENDAR',
'analytics' => 'COM_MOKOSUITECROSS_SUBMENU_ANALYTICS',
];
// Joomla 5+ toolbar submenu
if (class_exists('Joomla\CMS\Toolbar\Toolbar')) {
try {
$toolbar = Factory::getApplication()->getDocument()->getToolbar('submenu');
if ($toolbar && method_exists($toolbar, 'linkButton')) {
foreach ($views as $view => $langKey) {
$toolbar->linkButton($view, Text::_($langKey))
->url('index.php?option=com_mokosuitecross&view=' . $view)
->active($activeView === $view);
}
return;
}
} catch (\Throwable $e) {
// Fall through to legacy sidebar
}
}
// Legacy fallback for Joomla 4
foreach ($views as $view => $langKey) {
\Joomla\CMS\HTML\Sidebar::addEntry(
Text::_($langKey),
'index.php?option=com_mokosuitecross&view=' . $view,
$activeView === $view
);
}
}
/**
* Get a list of ACL actions for the component.
*
* @return \Joomla\CMS\Object\CMSObject
*/
public static function getActions(): \Joomla\CMS\Object\CMSObject
{
$user = \Joomla\CMS\Factory::getApplication()->getIdentity();
$result = new \Joomla\CMS\Object\CMSObject();
$actions = \Joomla\CMS\Access\Access::getActionsFromFile(
JPATH_ADMINISTRATOR . '/components/com_mokosuitecross/access.xml',
'/access/section[@name="component"]/'
);
foreach ($actions as $action) {
$result->set($action->name, $user->authorise($action->name, 'com_mokosuitecross'));
}
return $result;
}
}