* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved. * @license GNU General Public License version 3 or later; see LICENSE */ namespace Joomla\Component\MokoBackup\Administrator\Field; defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Form\FormField; use Joomla\CMS\Language\Text; class DatabaseTablesField extends FormField { protected $type = 'DatabaseTables'; protected function getInput(): string { $db = Factory::getDbo(); $tables = $db->getTableList(); $prefix = $db->getPrefix(); // Parse current exclusions (newline-separated, with optional :data-only suffix) $excludeData = []; $excludeStructure = []; if (!empty($this->value)) { $lines = array_filter(array_map('trim', explode("\n", str_replace("\r", '', $this->value)))); foreach ($lines as $line) { // Normalize table name to real prefix for comparison if (str_ends_with($line, ':data-only')) { $tableName = str_replace('#__', $prefix, substr($line, 0, -10)); $excludeData[$tableName] = true; } elseif (str_ends_with($line, ':structure-only')) { $tableName = str_replace('#__', $prefix, substr($line, 0, -15)); $excludeStructure[$tableName] = true; } else { // No suffix = exclude both (backward compatible) $tableName = str_replace('#__', $prefix, $line); $excludeData[$tableName] = true; $excludeStructure[$tableName] = true; } } } $id = htmlspecialchars($this->id, ENT_QUOTES, 'UTF-8'); $name = htmlspecialchars($this->name, ENT_QUOTES, 'UTF-8'); $html = '
| '; $html .= ' | ' . Text::_('COM_MOKOBACKUP_FIELD_EXCLUDE_DATA') . ' | '; $html .= ''; $html .= ' | ' . Text::_('COM_MOKOBACKUP_FIELD_EXCLUDE_STRUCTURE') . ' | '; $html .= '' . Text::_('COM_MOKOBACKUP_FIELD_TABLE_NAME') . ' | '; $html .= '
|---|---|---|---|---|
| '; $html .= ' | '; $html .= ' | '; $html .= ' | '; $html .= ' | ' . $safeTable . ' | ';
$html .= '