1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-08 07:36:44 +02:00

Plugins: Move lang() to Adminer\Plugin

This commit is contained in:
Jakub Vrana
2025-04-06 06:43:26 +02:00
parent 7ff1d82903
commit fb32c10f94
8 changed files with 30 additions and 31 deletions

View File

@@ -7,7 +7,7 @@
- MS SQL: Limit one INSERT in export to 1000 rows (bug #983) - MS SQL: Limit one INSERT in export to 1000 rows (bug #983)
- CSS: Add logo - CSS: Add logo
- Editor: Move mass sending e-mails to a plugin - Editor: Move mass sending e-mails to a plugin
- Plugins: Allow formatting translations using Adminer\lang_format() - Plugins: Support translations by extending Adminer\Plugin
- New plugin: Configure options by end-users and store them to a cookie - New plugin: Configure options by end-users and store them to a cookie
- New plugin: Configure menu table links - New plugin: Configure menu table links
- New plugin: Set up driver, server and database in Adminer Editor - New plugin: Set up driver, server and database in Adminer Editor

View File

@@ -79,14 +79,13 @@ include "../adminer/drivers/oracle.inc.php";
include "../adminer/drivers/mssql.inc.php"; include "../adminer/drivers/mssql.inc.php";
include "./include/adminer.inc.php"; include "./include/adminer.inc.php";
include "../adminer/include/plugins.inc.php"; include "../adminer/include/plugins.inc.php";
include "../adminer/include/plugin.inc.php";
if (function_exists('adminer_object')) { Adminer::$instance =
Adminer::$instance = adminer_object(); (function_exists('adminer_object') ? adminer_object() :
} elseif (is_dir("adminer-plugins") || file_exists("adminer-plugins.php")) { (is_dir("adminer-plugins") || file_exists("adminer-plugins.php") ? new Plugins(null) :
Adminer::$instance = new Plugins(null); new Adminer
} else { ));
Adminer::$instance = new Adminer;
}
// this is matched by compile.php // this is matched by compile.php
include "../adminer/drivers/mysql.inc.php"; // must be included as last driver include "../adminer/drivers/mysql.inc.php"; // must be included as last driver

View File

@@ -0,0 +1,16 @@
<?php
namespace Adminer;
abstract class Plugin {
/** @var array<literal-string, string|list<string>>[] */ protected static $translations = array(); // key is language code
/** Translate a string from static::$translations; use Adminer\lang() for strings used by Adminer
* @param literal-string $idf
* @param float|string $number
*/
protected function lang(string $idf, $number = null) {
$args = func_get_args();
$args[0] = idx(static::$translations[LANG], $idf) ?: $idf;
return call_user_func_array('Adminer\lang_format', $args);
}
}

View File

@@ -1,4 +1,4 @@
<?php <?php
namespace Adminer; namespace Adminer;
const VERSION = "5.1.2-dev"; const VERSION = "5.2.0-dev";

View File

@@ -6,7 +6,7 @@
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0 * @license https://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other) * @license https://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other)
*/ */
class AdminerConfig { class AdminerConfig extends Adminer\Plugin {
function headers() { function headers() {
static $called; // this function is called from page_header() and it also calls page_header() static $called; // this function is called from page_header() and it also calls page_header()
@@ -53,10 +53,6 @@ class AdminerConfig {
} }
} }
protected function lang($idf, $number = null) {
return Adminer\lang_format(Adminer\idx(self::$translations[Adminer\LANG], $idf) ?: $idf, $number);
}
protected static $translations = array( protected static $translations = array(
'cs' => array( 'cs' => array(
'Configuration' => 'Konfigurace', 'Configuration' => 'Konfigurace',

View File

@@ -6,7 +6,7 @@
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0 * @license https://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other) * @license https://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other)
*/ */
class AdminerMenuLinks { class AdminerMenuLinks extends Adminer\Plugin {
private $menu; private $menu;
/** @param ''|'table'|'select'|'auto' $menu see config() for explanation */ /** @param ''|'table'|'select'|'auto' $menu see config() for explanation */
@@ -65,10 +65,6 @@ class AdminerMenuLinks {
return true; return true;
} }
protected function lang($idf, $number = null) {
return Adminer\lang_format(Adminer\idx(self::$translations[Adminer\LANG], $idf) ?: $idf, $number);
}
protected static $translations = array( protected static $translations = array(
'cs' => array( 'cs' => array(
'Menu table links' => 'Odkazy na tabulky v menu', 'Menu table links' => 'Odkazy na tabulky v menu',

View File

@@ -6,7 +6,7 @@
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0 * @license https://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other) * @license https://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other)
*/ */
class AdminerSelectEmail { class AdminerSelectEmail extends Adminer\Plugin {
function selectEmailPrint($emailFields, $columns) { function selectEmailPrint($emailFields, $columns) {
if ($emailFields) { if ($emailFields) {
@@ -100,11 +100,7 @@ class AdminerSelectEmail {
return mail($email, $this->emailHeader($subject), $beginning . $message . $attachments, $headers); return mail($email, $this->emailHeader($subject), $beginning . $message . $attachments, $headers);
} }
private function lang($idf, $number = null) { protected static $translations = array(
return Adminer\lang_format(Adminer\idx(self::$translations[Adminer\LANG], $idf) ?: $idf, $number);
}
private static $translations = array(
'ar' => array('E-mail' => 'البريد الإلكتروني', 'From' => 'من', 'Subject' => 'الموضوع', 'Send' => 'إرسال', '%d e-mail(s) have been sent.' => 'تم إرسال %d رسالة.', 'Attachments' => 'ملفات مرفقة'), 'ar' => array('E-mail' => 'البريد الإلكتروني', 'From' => 'من', 'Subject' => 'الموضوع', 'Send' => 'إرسال', '%d e-mail(s) have been sent.' => 'تم إرسال %d رسالة.', 'Attachments' => 'ملفات مرفقة'),
'bg' => array('E-mail' => 'E-mail', 'From' => 'От', 'Subject' => 'Тема', 'Attachments' => 'Прикачени', 'Send' => 'Изпращане', '%d e-mail(s) have been sent.' => array('%d писмо беше изпратено.', '%d писма бяха изпратени.')), 'bg' => array('E-mail' => 'E-mail', 'From' => 'От', 'Subject' => 'Тема', 'Attachments' => 'Прикачени', 'Send' => 'Изпращане', '%d e-mail(s) have been sent.' => array('%d писмо беше изпратено.', '%d писма бяха изпратени.')),
'bn' => array('E-mail' => '​​ই-মেইল', 'From' => 'থেকে', 'Subject' => 'বিষয়', 'Send' => 'পাঠান', '%d e-mail(s) have been sent.' => array('%d ইমেইল(গুলি) পাঠানো হয়েছে।', '%d ইমেইল(গুলি) পাঠানো হয়েছে।'), 'Attachments' => 'সংযুক্তিগুলো'), 'bn' => array('E-mail' => '​​ই-মেইল', 'From' => 'থেকে', 'Subject' => 'বিষয়', 'Send' => 'পাঠান', '%d e-mail(s) have been sent.' => array('%d ইমেইল(গুলি) পাঠানো হয়েছে।', '%d ইমেইল(গুলি) পাঠানো হয়েছে।'), 'Attachments' => 'সংযুক্তিগুলো'),

View File

@@ -9,7 +9,7 @@
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0 * @license https://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other) * @license https://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other)
*/ */
class AdminerSqlGemini { class AdminerSqlGemini extends Adminer\Plugin {
private $apiKey; private $apiKey;
private $model; private $model;
@@ -92,11 +92,7 @@ geminiText.onkeydown = event => {
<?php <?php
} }
private function lang($idf, $number = null) { protected static $translations = array(
return Adminer\lang_format(Adminer\idx(self::$translations[Adminer\LANG], $idf) ?: $idf, $number);
}
private static $translations = array(
'cs' => array( 'cs' => array(
'Ask Gemini' => 'Zeptat se Gemini', 'Ask Gemini' => 'Zeptat se Gemini',
'Just a sec...' => 'Chviličku...', 'Just a sec...' => 'Chviličku...',