Files
MokoSuiteCross/source/packages/com_mokosuitecross/src/Helper/MokoSuiteCrossHelper.php
T
jmiller d6848e6b90
Universal: Pre-Release / Build Pre-Release (${{ inputs.stability || github.ref_name }}) (push) Successful in 11s
fix: resolve 10 critical/medium bugs from deep dive audit
- deleteFromPlatforms(): use CredentialHelper::decrypt() + Joomla 6
  dispatcher pattern instead of json_decode + deprecated triggerEvent (#226, #228)
- PostsController: add ACL checks on retryFailed/purgePosted (#224)
- QueueProcessor: recover stale posting entries stuck >10min (#235)
- onContentChangeState: respect post_on_first_publish_only (#238)
- Uninstall SQL: add analytics + category_rules table drops (#225)
- Dashboard/Calendar: remove deprecated Sidebar::render() (#250)
- AnalyticsHelper: rewrite AJAX endpoints to query posts table (#246)
- Submenu helper: remove duplicate calendar key (#248)
- CHANGELOG: remove 3 duplicate version headers (#240)

Authored-by: Moko Consulting

Claude-Session: https://claude.ai/code/session_014iwLv3vUVsSxP8LyZ6STTj
2026-06-29 11:27:48 -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',
'calendar' => 'COM_MOKOSUITECROSS_SUBMENU_CALENDAR',
'analytics' => 'COM_MOKOSUITECROSS_SUBMENU_ANALYTICS',
'logs' => 'COM_MOKOSUITECROSS_SUBMENU_LOGS',
];
// 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;
}
}