Files
adminer/adminer/include/plugin.inc.php

32 lines
941 B
PHP
Raw Normal View History

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 {
/** @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() {
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 "";
}
/** 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();
$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);
}
}