0cb24b4759
access.xml: 12 component-specific actions added: - mokosuitecross.crosspost (auto cross-post on publish) - mokosuitecross.crosspost.manual (manually create posts) - mokosuitecross.delete.remote (delete from remote platforms) - mokosuitecross.services.manage (create/edit/delete services) - mokosuitecross.services.credentials (view decrypted credentials) - mokosuitecross.templates.manage (create/edit/delete templates) - mokosuitecross.logs.view (view activity logs) - mokosuitecross.logs.purge (purge old logs) - mokosuitecross.queue.manage (manage post queue) - mokosuitecross.queue.export (export posts as CSV) - mokosuitecross.dispatch (trigger REST API dispatch) - mokosuitecross.migrate (run Perfect Publisher migration) config.xml: permissions fieldset with rules field for admin UI. Enforcement: - DisplayController: core.manage gate on all views - ServicesController: publish/delete ACL checks - TemplatesController: publish/delete ACL checks - PostsController: queue.export permission - ServiceController: services.manage for test connection - DispatchController: dispatch permission for REST API - All list views: preferences button gated by core.admin - All edit views: save/apply buttons gated by section permission - MokoSuiteCrossHelper::getActions() centralizes ACL lookups
76 lines
2.3 KiB
PHP
76 lines
2.3 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\View\Dashboard;
|
|
|
|
defined('_JEXEC') or die;
|
|
|
|
use Joomla\CMS\Factory;
|
|
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
|
|
use Joomla\CMS\Toolbar\ToolbarHelper;
|
|
use Joomla\Component\MokoSuiteCross\Administrator\Helper\MokoSuiteCrossHelper;
|
|
|
|
class HtmlView extends BaseHtmlView
|
|
{
|
|
protected $stats;
|
|
protected $migrationAvailable;
|
|
protected $recentActivity;
|
|
protected $serviceBreakdown;
|
|
protected $dailyTrend;
|
|
protected $topArticles;
|
|
public $sidebar;
|
|
public $period;
|
|
|
|
public function display($tpl = null): void
|
|
{
|
|
$model = $this->getModel();
|
|
|
|
// Read period parameter for date range filtering
|
|
$this->period = Factory::getApplication()->input->getInt('period', 30);
|
|
$validPeriods = [7, 30, 90, 0];
|
|
|
|
if (!in_array($this->period, $validPeriods, true)) {
|
|
$this->period = 30;
|
|
}
|
|
|
|
// Calculate the since date based on period (0 = all time)
|
|
$since = null;
|
|
|
|
if ($this->period > 0) {
|
|
$since = Factory::getDate('now - ' . $this->period . ' days')->toSql();
|
|
}
|
|
|
|
$this->stats = $this->get('Stats');
|
|
$this->migrationAvailable = $this->get('MigrationAvailable');
|
|
$this->recentActivity = $model->getRecentActivity(10);
|
|
$this->serviceBreakdown = $model->getServiceBreakdown($since);
|
|
$this->dailyTrend = $model->getDailyTrend($this->period ?: 365);
|
|
$this->topArticles = $model->getTopArticles(5, $since);
|
|
|
|
$this->addToolbar();
|
|
|
|
MokoSuiteCrossHelper::addSubmenu('dashboard');
|
|
$this->sidebar = \Joomla\CMS\HTML\Sidebar::render();
|
|
|
|
parent::display($tpl);
|
|
}
|
|
|
|
protected function addToolbar(): void
|
|
{
|
|
$canDo = MokoSuiteCrossHelper::getActions();
|
|
|
|
ToolbarHelper::title('MokoSuiteCross — Dashboard', 'share-alt');
|
|
if ($canDo->get('core.admin')) {
|
|
ToolbarHelper::preferences('com_mokosuitecross');
|
|
}
|
|
}
|
|
}
|