2012-12-23 11:29:16 +00:00
|
|
|
<?php
|
2017-05-23 18:16:30 +00:00
|
|
|
abstract class Plugin {
|
2013-04-19 13:26:22 +00:00
|
|
|
const API_VERSION_COMPAT = 1;
|
|
|
|
|
2021-03-02 09:15:42 +00:00
|
|
|
/** @var PDO $pdo */
|
2017-12-02 21:18:08 +00:00
|
|
|
protected $pdo;
|
|
|
|
|
2021-11-13 16:41:50 +00:00
|
|
|
/**
|
|
|
|
* @param PluginHost $host
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
* */
|
2021-11-13 16:36:24 +00:00
|
|
|
abstract function init($host);
|
2012-12-25 06:02:08 +00:00
|
|
|
|
2021-11-13 16:52:47 +00:00
|
|
|
/** @return array<null|float|string|bool> */
|
2021-11-13 16:36:24 +00:00
|
|
|
abstract function about();
|
2017-05-23 18:16:30 +00:00
|
|
|
// return array(1.0, "plugin", "No description", "No author", false);
|
2012-12-25 06:02:08 +00:00
|
|
|
|
2017-12-03 06:43:18 +00:00
|
|
|
function __construct() {
|
|
|
|
$this->pdo = Db::pdo();
|
|
|
|
}
|
|
|
|
|
2021-11-13 15:26:11 +00:00
|
|
|
/** @return array<string,int> */
|
2021-11-13 16:36:24 +00:00
|
|
|
function flags() {
|
2016-01-26 08:45:47 +00:00
|
|
|
/* associative array, possible keys:
|
|
|
|
needs_curl = boolean
|
|
|
|
*/
|
|
|
|
return array();
|
|
|
|
}
|
|
|
|
|
2021-11-13 16:41:50 +00:00
|
|
|
/**
|
|
|
|
* @param string $method
|
|
|
|
*
|
|
|
|
* @return bool */
|
2021-11-13 16:36:24 +00:00
|
|
|
function is_public_method($method) {
|
2017-02-10 13:04:28 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-11-13 16:41:50 +00:00
|
|
|
/**
|
|
|
|
* @param string $method
|
|
|
|
*
|
|
|
|
* @return bool */
|
2021-11-13 16:36:24 +00:00
|
|
|
function csrf_ignore($method) {
|
2021-03-02 09:15:42 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-11-13 16:41:50 +00:00
|
|
|
/** @return string */
|
2021-11-13 16:36:24 +00:00
|
|
|
function get_js() {
|
2012-12-25 06:02:08 +00:00
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2021-11-13 16:52:47 +00:00
|
|
|
/** @return string */
|
|
|
|
function get_css() {
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2021-11-13 16:41:50 +00:00
|
|
|
/** @return string */
|
2021-11-13 16:36:24 +00:00
|
|
|
function get_prefs_js() {
|
2012-12-25 06:02:08 +00:00
|
|
|
return "";
|
|
|
|
}
|
2013-04-19 13:26:22 +00:00
|
|
|
|
2021-11-13 16:41:50 +00:00
|
|
|
/** @return int */
|
2021-11-13 16:36:24 +00:00
|
|
|
function api_version() {
|
2013-04-19 13:26:22 +00:00
|
|
|
return Plugin::API_VERSION_COMPAT;
|
|
|
|
}
|
2019-03-05 07:26:23 +00:00
|
|
|
|
|
|
|
/* gettext-related helpers */
|
|
|
|
|
2021-11-13 16:41:50 +00:00
|
|
|
/**
|
|
|
|
* @param string $msgid
|
|
|
|
*
|
|
|
|
* @return string */
|
2021-11-13 16:36:24 +00:00
|
|
|
function __($msgid) {
|
2021-11-13 15:26:11 +00:00
|
|
|
/** @var Plugin $this -- this is a strictly template-related hack */
|
2019-03-05 07:26:23 +00:00
|
|
|
return _dgettext(PluginHost::object_to_domain($this), $msgid);
|
|
|
|
}
|
|
|
|
|
2021-11-13 16:41:50 +00:00
|
|
|
/**
|
|
|
|
* @param string $singular
|
|
|
|
* @param string $plural
|
|
|
|
* @param int $number
|
|
|
|
*
|
|
|
|
* @return string */
|
2021-11-13 16:36:24 +00:00
|
|
|
function _ngettext($singular, $plural, $number) {
|
2021-11-13 15:26:11 +00:00
|
|
|
/** @var Plugin $this -- this is a strictly template-related hack */
|
2019-03-05 07:26:23 +00:00
|
|
|
return _dngettext(PluginHost::object_to_domain($this), $singular, $plural, $number);
|
|
|
|
}
|
|
|
|
|
2021-11-13 16:41:50 +00:00
|
|
|
/** @return string */
|
2021-11-13 16:36:24 +00:00
|
|
|
function T_sprintf() {
|
2019-03-05 07:26:23 +00:00
|
|
|
$args = func_get_args();
|
|
|
|
$msgid = array_shift($args);
|
|
|
|
|
|
|
|
return vsprintf($this->__($msgid), $args);
|
|
|
|
}
|
|
|
|
}
|