aboutsummaryrefslogtreecommitdiffstats
path: root/include/plugin.php
diff options
context:
space:
mode:
Diffstat (limited to 'include/plugin.php')
-rwxr-xr-xinclude/plugin.php89
1 files changed, 45 insertions, 44 deletions
diff --git a/include/plugin.php b/include/plugin.php
index 7eeb39ce8..c789ad522 100755
--- a/include/plugin.php
+++ b/include/plugin.php
@@ -7,13 +7,15 @@
/**
- * @brief Handle errors in plugin calls
+ * @brief Handle errors in plugin calls.
*
* @param string $plugin name of the addon
- * @param string $error_text text of error
- * @param bool $uninstall uninstall plugin
+ * @param string $notice UI visible text of error
+ * @param string $log technical error message for logging
+ * @param bool $uninstall (optional) default false
+ * uninstall plugin on error
*/
-function handleerrors_plugin($plugin,$notice,$log,$uninstall=false){
+function handleerrors_plugin($plugin, $notice, $log, $uninstall = false){
logger("Addons: [" . $plugin . "] Error: ".$log, LOGGER_ERROR);
if ($notice != '') {
notice("[" . $plugin . "] Error: ".$notice, LOGGER_ERROR);
@@ -23,7 +25,7 @@ function handleerrors_plugin($plugin,$notice,$log,$uninstall=false){
$idx = array_search($plugin, \App::$plugins);
unset(\App::$plugins[$idx]);
uninstall_plugin($plugin);
- set_config("system","addon", implode(", ",\App::$plugins));
+ set_config("system", "addon", implode(", ", \App::$plugins));
}
}
@@ -213,8 +215,8 @@ function reload_plugins() {
try {
$func();
} catch (Exception $e) {
- handleerrors_plugin($plugin,"","UNLOAD FAILED (uninstalling) : ".$e->getMessage(),true);
- continue;
+ handleerrors_plugin($pl, '', 'UNLOAD FAILED (uninstalling) : ' . $e->getMessage(),true);
+ continue;
}
}
if(function_exists($pl . '_load')) {
@@ -222,8 +224,8 @@ function reload_plugins() {
try {
$func();
} catch (Exception $e) {
- handleerrors_plugin($plugin,"","LOAD FAILED (uninstalling): ".$e->getMessage(),true);
- continue;
+ handleerrors_plugin($pl, '', 'LOAD FAILED (uninstalling): ' . $e->getMessage(),true);
+ continue;
}
}
q("UPDATE addon SET tstamp = %d WHERE id = %d",
@@ -305,7 +307,7 @@ function plugins_sync() {
* @return array
*/
function visible_plugin_list() {
-
+
$r = q("select * from addon where hidden = 0 order by aname asc");
$x = (($r) ? ids_to_array($r,'aname') : array());
$y = [];
@@ -315,7 +317,7 @@ function visible_plugin_list() {
$y[] = $xv;
}
}
- }
+ }
return $y;
}
@@ -381,8 +383,6 @@ function unregister_hook($hook, $file, $function) {
* array in their theme_init() and use this to customise the app behaviour.
* use insert_hook($hookname,$function_name) to do this.
*/
-
-
function load_hooks() {
App::$hooks = [];
@@ -456,21 +456,21 @@ function insert_hook($hook, $fn, $version = 0, $priority = 0) {
function call_hooks($name, &$data = null) {
$a = 0;
- if (isset(App::$hooks[$name])) {
+ if (isset(App::$hooks[$name])) {
foreach(App::$hooks[$name] as $hook) {
if ($name != 'permit_hook') { // avoid looping
$checkhook = [
- 'name'=>$name,
- 'hook'=>$hook,
- 'data'=>$data,
+ 'name'=>$name,
+ 'hook'=>$hook,
+ 'data'=>$data,
// Note: Since PHP uses COPY-ON-WRITE
- // for variables, there is no cost to
+ // for variables, there is no cost to
// passing the $data structure (unless
// the permit_hook processors change the
// information it contains.
- 'permit'=>true
- ];
+ 'permit'=>true
+ ];
call_hooks('permit_hook',$checkhook);
if (!$checkhook['permit']) {
continue;
@@ -618,7 +618,7 @@ function get_widget_info($widget){
}
}
- if(! ($widget_found && $f))
+ if(! ($widget_found && $f))
return $info;
$f = escape_tags($f);
@@ -1041,7 +1041,7 @@ function get_intltext_template($s, $root = '') {
if (isset(\App::$override_intltext_templates[$testroot][$s]["content"])) {
return \App::$override_intltext_templates[$testroot][$s]["content"];
} else {
- if (isset(\App::$override_intltext_templates[$testroot][$s]["root"]) &&
+ if (isset(\App::$override_intltext_templates[$testroot][$s]["root"]) &&
isset(\App::$override_intltext_templates[$testroot][$s]["file"])) {
$s = \App::$override_intltext_templates[$testroot][$s]["file"];
$root = \App::$override_intltext_templates[$testroot][$s]["root"];
@@ -1058,37 +1058,38 @@ function get_intltext_template($s, $root = '') {
}
function get_markup_template($s, $root = '') {
- $testroot = ($root=='') ? $testroot = "ROOT" : $root;
+ $testroot = ($root=='') ? $testroot = "ROOT" : $root;
- $t = App::template_engine();
+ $t = App::template_engine();
- if (isset(\App::$override_markup_templates[$testroot][$s]["content"])) {
- return \App::$override_markup_templates[$testroot][$s]["content"];
- } else {
- if (isset(\App::$override_markup_templates[$testroot][$s]["root"]) &&
- isset(\App::$override_markup_templates[$testroot][$s]["file"])) {
- $root = \App::$override_markup_templates[$testroot][$s]["root"];
- $s = \App::$override_markup_templates[$testroot][$s]["file"];
- $template = $t->get_markup_template($s, $root);
- } elseif (\App::$override_templateroot) {
- $newroot = \App::$override_templateroot;
- if ($newroot != '' && substr($newroot,-1) != '/' ) {
- $newroot .= '/';
- }
- $newroot .= $root;
- $template = $t->get_markup_template($s, $newroot);
- } else {
- $template = $t->get_markup_template($s, $root);
+ if (isset(\App::$override_markup_templates[$testroot][$s]["content"])) {
+ return \App::$override_markup_templates[$testroot][$s]["content"];
+ } else {
+ if (isset(\App::$override_markup_templates[$testroot][$s]["root"]) &&
+ isset(\App::$override_markup_templates[$testroot][$s]["file"])) {
+ $root = \App::$override_markup_templates[$testroot][$s]["root"];
+ $s = \App::$override_markup_templates[$testroot][$s]["file"];
+ $template = $t->get_markup_template($s, $root);
+ } elseif (\App::$override_templateroot) {
+ $newroot = \App::$override_templateroot;
+ if ($newroot != '' && substr($newroot,-1) != '/' ) {
+ $newroot .= '/';
+ }
+ $newroot .= $root;
+ $template = $t->get_markup_template($s, $newroot);
+ } else {
+ $template = $t->get_markup_template($s, $root);
}
- return $template;
- }
+ return $template;
+ }
}
/**
- * @brief
+ * @brief Test if a folder exists.
*
* @param string $folder
* @return boolean|string
+ * False if folder does not exist, or canonicalized absolute pathname
*/
function folder_exists($folder) {
// Get canonicalized absolute pathname