From 70051742afdd05ab66d9265edb063eb5b6615765 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 13 Nov 2021 18:21:04 +0300 Subject: experimental: also don't keep base plugin template as a non-analyzed file --- classes/plugin-template.php | 62 ++++++++++++++++++++++++++++++++ classes/plugin.tpl | 62 -------------------------------- utils/generate-plugin-hook-prototypes.sh | 5 ++- 3 files changed, 66 insertions(+), 63 deletions(-) create mode 100644 classes/plugin-template.php delete mode 100644 classes/plugin.tpl diff --git a/classes/plugin-template.php b/classes/plugin-template.php new file mode 100644 index 000000000..ad6d07ee0 --- /dev/null +++ b/classes/plugin-template.php @@ -0,0 +1,62 @@ +pdo = Db::pdo(); + } + + function flags() { + /* associative array, possible keys: + needs_curl = boolean + */ + return array(); + } + + function is_public_method($method) { + return false; + } + + function csrf_ignore($method) { + return false; + } + + function get_js() { + return ""; + } + + function get_prefs_js() { + return ""; + } + + function api_version() { + return Plugin::API_VERSION_COMPAT; + } + + /* gettext-related helpers */ + + function __($msgid) { + return _dgettext(PluginHost::object_to_domain($this), $msgid); + } + + function _ngettext($singular, $plural, $number) { + return _dngettext(PluginHost::object_to_domain($this), $singular, $plural, $number); + } + + function T_sprintf() { + $args = func_get_args(); + $msgid = array_shift($args); + + return vsprintf($this->__($msgid), $args); + } + + /** AUTO_GENERATED_HOOKS_GO_HERE **/ +} diff --git a/classes/plugin.tpl b/classes/plugin.tpl deleted file mode 100644 index 10f5b8ce7..000000000 --- a/classes/plugin.tpl +++ /dev/null @@ -1,62 +0,0 @@ -pdo = Db::pdo(); - } - - function flags() { - /* associative array, possible keys: - needs_curl = boolean - */ - return array(); - } - - function is_public_method($method) { - return false; - } - - function csrf_ignore($method) { - return false; - } - - function get_js() { - return ""; - } - - function get_prefs_js() { - return ""; - } - - function api_version() { - return Plugin::API_VERSION_COMPAT; - } - - /* gettext-related helpers */ - - function __($msgid) { - return _dgettext(PluginHost::object_to_domain($this), $msgid); - } - - function _ngettext($singular, $plural, $number) { - return _dngettext(PluginHost::object_to_domain($this), $singular, $plural, $number); - } - - function T_sprintf() { - $args = func_get_args(); - $msgid = array_shift($args); - - return vsprintf($this->__($msgid), $args); - } - - /** AUTO_GENERATED_HOOKS_GO_HERE **/ -} diff --git a/utils/generate-plugin-hook-prototypes.sh b/utils/generate-plugin-hook-prototypes.sh index 586f3f2c6..edf1ed5fe 100644 --- a/utils/generate-plugin-hook-prototypes.sh +++ b/utils/generate-plugin-hook-prototypes.sh @@ -15,8 +15,11 @@ grep 'hook_.*(' ../classes/pluginhost.php | sed -e 's#[\t ]*/[* ]*##' \ EOF done -cat ../classes/plugin.tpl | while IFS=\n read L; do +cat ../classes/plugin-template.php | while IFS=\n read L; do case $L in + *PluginTemplate* ) + echo "$L" | sed 's/PluginTemplate/Plugin/' + ;; *AUTO_GENERATED_HOOKS_GO_HERE* ) echo "\t/* plugin hook methods (auto-generated) */\n" cat $TMPFILE -- cgit v1.2.3-54-g00ecf