2025-04-06 06:43:26 +02:00
|
|
|
<?php
|
|
|
|
|
namespace Adminer;
|
|
|
|
|
|
2025-04-07 15:54:31 +02:00
|
|
|
// the overridable methods don't use return type declarations so that plugins can be compatible with PHP 5
|
2025-04-06 06:43:26 +02:00
|
|
|
abstract class Plugin {
|
2025-04-08 12:57:03 +02:00
|
|
|
/** @var array<literal-string, string|list<string>>[] */ protected $translations = array(); // key is language code
|
2025-04-06 06:43:26 +02:00
|
|
|
|
2025-04-07 15:54:31 +02:00
|
|
|
/** Get plain text plugin description; empty string means to use the first line of class doc-comment
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
|
|
|
|
function description() {
|
2025-04-07 17:00:59 +02:00
|
|
|
return $this->lang('');
|
2025-04-07 15:54:31 +02:00
|
|
|
}
|
|
|
|
|
|
2025-04-07 19:09:53 +02:00
|
|
|
/** Get URL of plugin screenshot
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
|
|
|
|
function screenshot() {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-08 20:10:30 +02:00
|
|
|
/** Translate a string from $this->translations; Adminer\lang() doesn't work for single language versions
|
2025-04-06 06:43:26 +02:00
|
|
|
* @param literal-string $idf
|
|
|
|
|
* @param float|string $number
|
|
|
|
|
*/
|
2025-04-07 15:54:31 +02:00
|
|
|
protected function lang(string $idf, $number = null): string {
|
2025-04-06 06:43:26 +02:00
|
|
|
$args = func_get_args();
|
2025-04-08 12:57:03 +02:00
|
|
|
$args[0] = idx($this->translations[LANG], $idf) ?: $idf;
|
2025-04-06 06:43:26 +02:00
|
|
|
return call_user_func_array('Adminer\lang_format', $args);
|
|
|
|
|
}
|
|
|
|
|
}
|