* @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 $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'); 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'); } } }