Update hook names
update hook names and other plugin references.
This commit is contained in:
parent
ac374f7773
commit
5d03735238
4 changed files with 286 additions and 283 deletions
|
@ -62,8 +62,8 @@ function admin_post(App $a)
|
|||
if ($a->argc > 2 &&
|
||||
is_file("addon/" . $a->argv[2] . "/" . $a->argv[2] . ".php")) {
|
||||
@include_once("addon/" . $a->argv[2] . "/" . $a->argv[2] . ".php");
|
||||
if (function_exists($a->argv[2] . '_plugin_admin_post')) {
|
||||
$func = $a->argv[2] . '_plugin_admin_post';
|
||||
if (function_exists($a->argv[2] . '_addon_admin_post')) {
|
||||
$func = $a->argv[2] . '_addon_admin_post';
|
||||
$func($a);
|
||||
}
|
||||
}
|
||||
|
@ -1790,7 +1790,7 @@ function admin_page_addons(App $a)
|
|||
$admin_form = "";
|
||||
if (in_array($addon, $a->addons_admin)) {
|
||||
@require_once("addon/$addon/$addon.php");
|
||||
$func = $addon . '_plugin_admin';
|
||||
$func = $addon . '_addon_admin';
|
||||
$func($a, $admin_form);
|
||||
}
|
||||
|
||||
|
|
|
@ -176,7 +176,8 @@ function settings_post(App $a)
|
|||
dbesc($redirect),
|
||||
dbesc($icon),
|
||||
local_user(),
|
||||
dbesc($key));
|
||||
dbesc($key)
|
||||
);
|
||||
} else {
|
||||
q("INSERT INTO clients
|
||||
(client_id, pw, name, redirect_uri, icon, uid)
|
||||
|
@ -186,7 +187,8 @@ function settings_post(App $a)
|
|||
dbesc($name),
|
||||
dbesc($redirect),
|
||||
dbesc($icon),
|
||||
local_user());
|
||||
local_user()
|
||||
);
|
||||
}
|
||||
}
|
||||
goaway(System::baseUrl(true)."/settings/oauth/");
|
||||
|
@ -196,12 +198,12 @@ function settings_post(App $a)
|
|||
if (($a->argc > 1) && ($a->argv[1] == 'addon')) {
|
||||
check_form_security_token_redirectOnErr('/settings/addon', 'settings_addon');
|
||||
|
||||
Addon::callHooks('plugin_settings_post', $_POST);
|
||||
Addon::callHooks('addon_settings_post', $_POST);
|
||||
return;
|
||||
}
|
||||
|
||||
if (($a->argc > 1) && ($a->argv[1] == 'connectors')) {
|
||||
|
||||
if (($a->argc > 1) && ($a->argv[1] == 'connectors'))
|
||||
{
|
||||
check_form_security_token_redirectOnErr('/settings/connectors', 'settings_connectors');
|
||||
|
||||
if (x($_POST, 'general-submit')) {
|
||||
|
@ -749,12 +751,12 @@ function settings_content(App $a)
|
|||
if (($a->argc > 1) && ($a->argv[1] === 'addon')) {
|
||||
$settings_addons = "";
|
||||
|
||||
$r = q("SELECT * FROM `hook` WHERE `hook` = 'plugin_settings' ");
|
||||
$r = q("SELECT * FROM `hook` WHERE `hook` = 'addon_settings' ");
|
||||
if (!DBM::is_result($r)) {
|
||||
$settings_addons = t('No Addon settings configured');
|
||||
}
|
||||
|
||||
Addon::callHooks('plugin_settings', $settings_addons);
|
||||
Addon::callHooks('addon_settings', $settings_addons);
|
||||
|
||||
|
||||
$tpl = get_markup_template('settings/addons.tpl');
|
||||
|
|
|
@ -55,7 +55,7 @@ class Addon
|
|||
$func = $addon . '_install';
|
||||
$func();
|
||||
|
||||
$addon_admin = (function_exists($addon."_plugin_admin") ? 1 : 0);
|
||||
$addon_admin = (function_exists($addon."_addon_admin") ? 1 : 0);
|
||||
|
||||
dba::insert('addon', ['name' => $addon, 'installed' => true,
|
||||
'timestamp' => $t, 'plugin_admin' => $addon_admin]);
|
||||
|
@ -81,7 +81,6 @@ class Addon
|
|||
{
|
||||
$addons = Config::get('system', 'addon');
|
||||
if (strlen($addons)) {
|
||||
|
||||
$r = dba::select('addon', [], ['installed' => 1]);
|
||||
if (DBM::is_result($r)) {
|
||||
$installed = $r;
|
||||
|
@ -93,9 +92,7 @@ class Addon
|
|||
|
||||
if (count($addon_list)) {
|
||||
foreach ($addon_list as $addon) {
|
||||
|
||||
$addon = trim($addon);
|
||||
|
||||
$fname = 'addon/' . $addon . '/' . $addon . '.php';
|
||||
|
||||
if (file_exists($fname)) {
|
||||
|
@ -171,14 +168,17 @@ class Addon
|
|||
return $r;
|
||||
}
|
||||
|
||||
|
||||
public static function loadHooks() {
|
||||
/**
|
||||
* Load hooks
|
||||
*/
|
||||
public static function loadHooks()
|
||||
{
|
||||
$a = get_app();
|
||||
$a->hooks = [];
|
||||
$r = dba::select('hook', ['hook', 'file', 'function'], [], ['order' => ['priority' => 'desc', 'file']]);
|
||||
|
||||
while ($rr = dba::fetch($r)) {
|
||||
if (! array_key_exists($rr['hook'],$a->hooks)) {
|
||||
if (! array_key_exists($rr['hook'], $a->hooks)) {
|
||||
$a->hooks[$rr['hook']] = [];
|
||||
}
|
||||
$a->hooks[$rr['hook']][] = [$rr['file'],$rr['function']];
|
||||
|
@ -216,8 +216,9 @@ class Addon
|
|||
public static function callSingleHook($a, $name, $hook, &$data = null)
|
||||
{
|
||||
// Don't run a theme's hook if the user isn't using the theme
|
||||
if (strpos($hook[0], 'view/theme/') !== false && strpos($hook[0], 'view/theme/'.current_theme()) === false)
|
||||
if (strpos($hook[0], 'view/theme/') !== false && strpos($hook[0], 'view/theme/'.current_theme()) === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
@include_once($hook[0]);
|
||||
if (function_exists($hook[1])) {
|
||||
|
@ -234,16 +235,17 @@ class Addon
|
|||
* check if an app_menu hook exist for addon $name.
|
||||
* Return true if the addon is an app
|
||||
*/
|
||||
function isApp($name)
|
||||
public static function isApp($name)
|
||||
{
|
||||
$a = get_app();
|
||||
|
||||
if (is_array($a->hooks) && (array_key_exists('app_menu',$a->hooks))) {
|
||||
if (is_array($a->hooks) && (array_key_exists('app_menu', $a->hooks))) {
|
||||
foreach ($a->hooks['app_menu'] as $hook) {
|
||||
if ($hook[0] == 'addon/'.$name.'/'.$name.'.php')
|
||||
if ($hook[0] == 'addon/'.$name.'/'.$name.'.php') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -264,8 +266,8 @@ class Addon
|
|||
* @return array with the addon information
|
||||
*/
|
||||
|
||||
public static function getInfo($addon) {
|
||||
|
||||
public static function getInfo($addon)
|
||||
{
|
||||
$a = get_app();
|
||||
|
||||
$info=[
|
||||
|
@ -288,10 +290,10 @@ class Addon
|
|||
|
||||
if ($r) {
|
||||
$ll = explode("\n", $m[0]);
|
||||
foreach ( $ll as $l ) {
|
||||
$l = trim($l,"\t\n\r */");
|
||||
foreach ($ll as $l) {
|
||||
$l = trim($l, "\t\n\r */");
|
||||
if ($l != "") {
|
||||
list($k,$v) = array_map("trim", explode(":",$l,2));
|
||||
list($k,$v) = array_map("trim", explode(":", $l, 2));
|
||||
$k= strtolower($k);
|
||||
if ($k == "author") {
|
||||
$r=preg_match("|([^<]+)<([^>]+)>|", $v, $m);
|
||||
|
@ -301,11 +303,10 @@ class Addon
|
|||
$info['author'][] = ['name'=>$v];
|
||||
}
|
||||
} else {
|
||||
if (array_key_exists($k,$info)) {
|
||||
if (array_key_exists($k, $info)) {
|
||||
$info[$k]=$v;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -661,7 +661,7 @@ class DBStructure {
|
|||
$database = [];
|
||||
|
||||
$database["addon"] = [
|
||||
"comment" => "registered plugins",
|
||||
"comment" => "registered addons",
|
||||
"fields" => [
|
||||
"id" => ["type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
|
||||
"name" => ["type" => "varchar(190)", "not null" => "1", "default" => "", "comment" => ""],
|
||||
|
@ -1081,7 +1081,7 @@ class DBStructure {
|
|||
]
|
||||
];
|
||||
$database["hook"] = [
|
||||
"comment" => "plugin hook registry",
|
||||
"comment" => "addon hook registry",
|
||||
"fields" => [
|
||||
"id" => ["type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
|
||||
"hook" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
|
||||
|
|
Loading…
Reference in a new issue