* @link https://www.tassos.gr * @copyright Copyright © 2024 Tassos All Rights Reserved * @license GNU GPLv3 or later */ // No direct access to this file defined('_JEXEC') or die; use Joomla\CMS\Form\FormField; use Joomla\CMS\Language\Text; use Joomla\CMS\Router\Route; class JFormFieldGeoDBChecker extends FormField { /** * Whether TGeoIP is disabled or not. * * @var boolean */ private $tgeoip_plugin_disabled = false; protected function getLabel() { return; } /** * Renders the field. * * @param array $options * * @return string */ public function renderField($options = []) { // Check if TGeoIP plugin is enabled if (!\NRFramework\Extension::pluginIsEnabled('tgeoip')) { $this->tgeoip_plugin_disabled = true; return parent::renderField($options); } // Do not render the field if the database is up-to-date if (!\NRFramework\Extension::geoPluginNeedsUpdate()) { return; } return parent::renderField($options); } /** * Shows a warning message when the Geolocation plugin is disabled. * * @return string */ private function disabledPluginWarning() { return '
' . '

' . Text::sprintf('NR_GEO_PLUGIN_DISABLED') . '

' . '

' . Text::sprintf('NR_GEO_PLUGIN_DISABLED_DESC', '', '') . '

' . '
'; } /** * If the geolocation database is missing or its outdated, then display a helpful message * to the usser notifying them that they need to update. * * @return string */ protected function getInput() { if ($this->tgeoip_plugin_disabled) { return $this->disabledPluginWarning(); } return '
' . '

' . Text::sprintf('NR_GEO_MAINTENANCE') . '

' . '

' . Text::sprintf('NR_GEO_MAINTENANCE_DESC') . '

' . ' Update Database' . '
'; } }