diff --git a/libraries/classes/Rte/Events.php b/libraries/classes/Rte/Events.php index 24ce86f600..178b6921d3 100644 --- a/libraries/classes/Rte/Events.php +++ b/libraries/classes/Rte/Events.php @@ -33,9 +33,6 @@ class Events /** @var General */ private $general; - /** @var Words */ - private $words; - /** @var DatabaseInterface */ private $dbi; @@ -50,7 +47,6 @@ class Events $this->dbi = $dbi; $this->export = new Export($this->dbi); $this->general = new General($this->dbi); - $this->words = new Words(); $this->template = new Template(); } @@ -311,7 +307,7 @@ class Events } // Get the data for the form (if any) if (! empty($_REQUEST['add_item'])) { - $title = $this->words->get('add'); + $title = __('Add event'); $item = $this->getDataFromRequest(); $mode = 'add'; } elseif (! empty($_REQUEST['edit_item'])) { diff --git a/libraries/classes/Rte/Export.php b/libraries/classes/Rte/Export.php index e89df076e2..0472d12fb7 100644 --- a/libraries/classes/Rte/Export.php +++ b/libraries/classes/Rte/Export.php @@ -19,9 +19,6 @@ use function trim; */ class Export { - /** @var Words */ - private $words; - /** @var DatabaseInterface */ private $dbi; @@ -31,7 +28,6 @@ class Export public function __construct(DatabaseInterface $dbi) { $this->dbi = $dbi; - $this->words = new Words(); } /** @@ -39,19 +35,34 @@ class Export * and it completes the handling of the export functionality. * * @param string $export_data The SQL query to create the requested item + * @param string $type RTE type (routine|trigger|event). * * @return void */ - private function handle($export_data) + private function handle($export_data, string $type) { global $db; $response = Response::getInstance(); + $exportMessage = ''; + $noViewMessage = ''; + if ($type === 'routine') { + $exportMessage = __('Export of routine %s'); + $noViewMessage = __( + 'No routine with name %1$s found in database %2$s. ' + . 'You might be lacking the necessary privileges to view/export this routine.' + ); + } elseif ($type === 'event') { + $exportMessage = __('Export of event %s'); + } elseif ($type === 'trigger') { + $exportMessage = __('Export of trigger %s'); + } + $item_name = htmlspecialchars(Util::backquote($_GET['item_name'])); if ($export_data !== false) { $export_data = htmlspecialchars(trim($export_data)); - $title = sprintf($this->words->get('export'), $item_name); + $title = sprintf($exportMessage, $item_name); if ($response->isAjax()) { $response->addJSON('message', $export_data); $response->addJSON('title', $title); @@ -67,7 +78,7 @@ class Export } else { $_db = htmlspecialchars(Util::backquote($db)); $message = __('Error in processing request:') . ' ' - . sprintf($this->words->get('no_view'), $item_name, $_db); + . sprintf($noViewMessage, $item_name, $_db); $message = Message::error($message); if ($response->isAjax()) { @@ -96,7 +107,7 @@ class Export if (! $export_data) { $export_data = false; } - $this->handle($export_data); + $this->handle($export_data, 'event'); } } @@ -129,7 +140,7 @@ class Export . "$$\nDELIMITER ;\n"; } - $this->handle($export_data); + $this->handle($export_data, 'routine'); } } } @@ -154,7 +165,7 @@ class Export break; } } - $this->handle($export_data); + $this->handle($export_data, 'trigger'); } } } diff --git a/libraries/classes/Rte/General.php b/libraries/classes/Rte/General.php index ebbbbb62e9..ec7860c673 100644 --- a/libraries/classes/Rte/General.php +++ b/libraries/classes/Rte/General.php @@ -74,7 +74,6 @@ class General { $events = new Events($this->dbi); $triggers = new Triggers($this->dbi); - $words = new Words(); $response = Response::getInstance(); if ($item !== false) { // Show form @@ -92,9 +91,15 @@ class General } exit; } else { + if ($type == 'TRI') { + $notFound = __('No trigger with name %1$s found in database %2$s.'); + } else { // EVN + $notFound = __('No event with name %1$s found in database %2$s.'); + } + $message = __('Error in processing request:') . ' '; $message .= sprintf( - $words->get('not_found'), + $notFound, htmlspecialchars(Util::backquote($_REQUEST['item_name'])), htmlspecialchars(Util::backquote($db)) ); diff --git a/libraries/classes/Rte/Routines.php b/libraries/classes/Rte/Routines.php index cc3a033cb7..c0fb93ce10 100644 --- a/libraries/classes/Rte/Routines.php +++ b/libraries/classes/Rte/Routines.php @@ -50,9 +50,6 @@ class Routines /** @var General */ private $general; - /** @var Words */ - private $words; - /** @var DatabaseInterface */ private $dbi; @@ -67,7 +64,6 @@ class Routines $this->dbi = $dbi; $this->export = new Export($this->dbi); $this->general = new General($this->dbi); - $this->words = new Words(); $this->template = new Template(); } @@ -207,7 +203,7 @@ class Routines $mode = null; $title = null; if (! empty($_REQUEST['add_item'])) { - $title = $this->words->get('add'); + $title = __('Add routine'); $routine = $this->getDataFromRequest(); $mode = 'add'; } elseif (! empty($_REQUEST['edit_item'])) { @@ -243,7 +239,10 @@ class Routines } else { $message = __('Error in processing request:') . ' '; $message .= sprintf( - $this->words->get('no_edit'), + __( + 'No routine with name %1$s found in database %2$s. ' + . 'You might be lacking the necessary privileges to edit this routine.' + ), htmlspecialchars( Util::backquote($_REQUEST['item_name']) ), @@ -1374,7 +1373,7 @@ class Routines if ($routine === false) { $message = __('Error in processing request:') . ' '; $message .= sprintf( - $this->words->get('not_found'), + __('No routine with name %1$s found in database %2$s.'), htmlspecialchars(Util::backquote($_POST['item_name'])), htmlspecialchars(Util::backquote($db)) ); @@ -1579,7 +1578,7 @@ class Routines } elseif ($response->isAjax()) { $message = __('Error in processing request:') . ' '; $message .= sprintf( - $this->words->get('not_found'), + __('No routine with name %1$s found in database %2$s.'), htmlspecialchars(Util::backquote($_GET['item_name'])), htmlspecialchars(Util::backquote($db)) ); diff --git a/libraries/classes/Rte/Triggers.php b/libraries/classes/Rte/Triggers.php index ddc6610380..de7a2b79b9 100644 --- a/libraries/classes/Rte/Triggers.php +++ b/libraries/classes/Rte/Triggers.php @@ -32,9 +32,6 @@ class Triggers /** @var General */ private $general; - /** @var Words */ - private $words; - /** @var DatabaseInterface */ private $dbi; @@ -49,7 +46,6 @@ class Triggers $this->dbi = $dbi; $this->export = new Export($this->dbi); $this->general = new General($this->dbi); - $this->words = new Words(); $this->template = new Template(); } @@ -282,7 +278,7 @@ class Triggers $title = null; // Get the data for the form (if any) if (! empty($_REQUEST['add_item'])) { - $title = $this->words->get('add'); + $title = __('Add trigger'); $item = $this->getDataFromRequest(); $mode = 'add'; } elseif (! empty($_REQUEST['edit_item'])) { diff --git a/libraries/classes/Rte/Words.php b/libraries/classes/Rte/Words.php deleted file mode 100644 index 1e19df4f9d..0000000000 --- a/libraries/classes/Rte/Words.php +++ /dev/null @@ -1,84 +0,0 @@ - __('Add routine'), - 'docu' => 'STORED_ROUTINES', - 'export' => __('Export of routine %s'), - 'human' => __('routine'), - 'no_create' => __( - 'You do not have the necessary privileges to create a routine.' - ), - 'no_edit' => __( - 'No routine with name %1$s found in database %2$s. ' - . 'You might be lacking the necessary privileges to edit this routine.' - ), - 'no_view' => __( - 'No routine with name %1$s found in database %2$s. ' - . 'You might be lacking the necessary privileges to view/export this routine.' - ), - 'not_found' => __('No routine with name %1$s found in database %2$s.'), - 'nothing' => __('There are no routines to display.'), - 'title' => __('Routines'), - ]; - break; - case 'TRI': - $words = [ - 'add' => __('Add trigger'), - 'docu' => 'TRIGGERS', - 'export' => __('Export of trigger %s'), - 'human' => __('trigger'), - 'no_create' => __( - 'You do not have the necessary privileges to create a trigger.' - ), - 'not_found' => __('No trigger with name %1$s found in database %2$s.'), - 'nothing' => __('There are no triggers to display.'), - 'title' => __('Triggers'), - ]; - break; - case 'EVN': - $words = [ - 'add' => __('Add event'), - 'docu' => 'EVENTS', - 'export' => __('Export of event %s'), - 'human' => __('event'), - 'no_create' => __( - 'You do not have the necessary privileges to create an event.' - ), - 'not_found' => __('No event with name %1$s found in database %2$s.'), - 'nothing' => __('There are no events to display.'), - 'title' => __('Events'), - ]; - break; - default: - $words = []; - break; - } - - return $words[$index] ?? ''; - } -}