aboutsummaryrefslogtreecommitdiffstats
path: root/include/plugin.php
diff options
context:
space:
mode:
authorPaolo Tacconi <p.tacconi@giunti.it>2016-04-15 09:20:58 +0200
committerPaolo Tacconi <p.tacconi@giunti.it>2016-04-15 09:20:58 +0200
commit45a854762b451dafb882bc56efce054b64420627 (patch)
tree958fcd22f04546f40b6ac68bb58cfe1a1b1fb7f6 /include/plugin.php
parent1806da0851dd5cf5978b19d12783ae3101a11257 (diff)
parenta29c0371f1f3cceb9a9af3a62e5ed67886869c40 (diff)
downloadvolse-hubzilla-45a854762b451dafb882bc56efce054b64420627.tar.gz
volse-hubzilla-45a854762b451dafb882bc56efce054b64420627.tar.bz2
volse-hubzilla-45a854762b451dafb882bc56efce054b64420627.zip
Resolved conflict in view/it/hstrings.php
Diffstat (limited to 'include/plugin.php')
-rwxr-xr-xinclude/plugin.php131
1 files changed, 82 insertions, 49 deletions
diff --git a/include/plugin.php b/include/plugin.php
index 4a35a0170..8dceb8fb1 100755
--- a/include/plugin.php
+++ b/include/plugin.php
@@ -219,7 +219,7 @@ function unregister_hook($hook, $file, $function) {
//
-// It might not be obvious but themes can manually add hooks to the $a->hooks
+// It might not be obvious but themes can manually add hooks to the App::$hooks
// array in their theme_init() and use this to customise the app behaviour.
// UPDATE: use insert_hook($hookname,$function_name) to do this
//
@@ -227,19 +227,19 @@ function unregister_hook($hook, $file, $function) {
function load_hooks() {
$a = get_app();
-// if(! is_array($a->hooks))
- $a->hooks = array();
+// if(! is_array(App::$hooks))
+ App::$hooks = array();
$r = q("SELECT * FROM hook WHERE true ORDER BY priority DESC");
if($r) {
foreach($r as $rr) {
- if(! array_key_exists($rr['hook'],$a->hooks))
- $a->hooks[$rr['hook']] = array();
+ if(! array_key_exists($rr['hook'],App::$hooks))
+ App::$hooks[$rr['hook']] = array();
- $a->hooks[$rr['hook']][] = array($rr['file'],$rr['function']);
+ App::$hooks[$rr['hook']][] = array($rr['file'],$rr['function']);
}
}
-//logger('hooks: ' . print_r($a->hooks,true));
+//logger('hooks: ' . print_r(App::$hooks,true));
}
/**
@@ -261,13 +261,13 @@ function load_hooks() {
*/
function insert_hook($hook, $fn) {
$a = get_app();
- if(! is_array($a->hooks))
- $a->hooks = array();
+ if(! is_array(App::$hooks))
+ App::$hooks = array();
- if(! array_key_exists($hook, $a->hooks))
- $a->hooks[$hook] = array();
+ if(! array_key_exists($hook, App::$hooks))
+ App::$hooks[$hook] = array();
- $a->hooks[$hook][] = array('', $fn);
+ App::$hooks[$hook][] = array('', $fn);
}
/**
@@ -282,8 +282,8 @@ function insert_hook($hook, $fn) {
function call_hooks($name, &$data = null) {
$a = get_app();
- if((is_array($a->hooks)) && (array_key_exists($name, $a->hooks))) {
- foreach($a->hooks[$name] as $hook) {
+ if((is_array(App::$hooks)) && (array_key_exists($name, App::$hooks))) {
+ foreach(App::$hooks[$name] as $hook) {
if($hook[0])
@include_once($hook[0]);
@@ -291,7 +291,7 @@ function call_hooks($name, &$data = null) {
$func = $hook[1];
$func($a, $data);
} else {
- // remove orphan hooks
+
q("DELETE FROM hook WHERE hook = '%s' AND file = '%s' AND function = '%s'",
dbesc($name),
dbesc($hook[0]),
@@ -313,7 +313,6 @@ function call_hooks($name, &$data = null) {
* * Version: 1.2.3
* * Author: John <profile url>
* * Author: Jane <email>
- * * Compat: Red [(version)], Friendica [(version)]
* *
*\endcode
* @param string $plugin the name of the plugin
@@ -325,8 +324,9 @@ function get_plugin_info($plugin){
'name' => $plugin,
'description' => '',
'author' => array(),
+ 'maintainer' => array(),
'version' => '',
- 'compat' => ''
+ 'requires' => ''
);
if (!is_file("addon/$plugin/$plugin.php"))
@@ -342,17 +342,16 @@ function get_plugin_info($plugin){
if ($l != ""){
list($k, $v) = array_map("trim", explode(":", $l, 2));
$k = strtolower($k);
- if ($k == 'author'){
+ if ($k == 'author' || $k == 'maintainer'){
$r = preg_match("|([^<]+)<([^>]+)>|", $v, $m);
if ($r) {
- $info['author'][] = array('name' => $m[1], 'link' => $m[2]);
+ $info[$k][] = array('name' => $m[1], 'link' => $m[2]);
} else {
- $info['author'][] = array('name' => $v);
- }
- } else {
- if (array_key_exists($k, $info)){
- $info[$k] = $v;
+ $info[$k][] = array('name' => $v);
}
+ }
+ else {
+ $info[$k] = $v;
}
}
}
@@ -361,6 +360,51 @@ function get_plugin_info($plugin){
return $info;
}
+function check_plugin_versions($info) {
+
+ if(! is_array($info))
+ return true;
+
+ if(array_key_exists('minversion',$info)) {
+ if(! version_compare(STD_VERSION,trim($info['minversion']), '>=')) {
+ logger('minversion limit: ' . $info['name'],LOGGER_NORMAL,LOG_WARNING);
+ return false;
+ }
+ }
+ if(array_key_exists('maxversion',$info)) {
+ if(version_compare(STD_VERSION,trim($info['maxversion']), '>')) {
+ logger('maxversion limit: ' . $info['name'],LOGGER_NORMAL,LOG_WARNING);
+ return false;
+ }
+ }
+ if(array_key_exists('minphpversion',$info)) {
+ if(! version_compare(PHP_VERSION,trim($info['minphpversion']), '>=')) {
+ logger('minphpversion limit: ' . $info['name'],LOGGER_NORMAL,LOG_WARNING);
+ return false;
+ }
+ }
+
+ if(array_key_exists('requires',$info)) {
+ $arr = explode(',',$info['requires']);
+ $found = true;
+ if($arr) {
+ foreach($arr as $test) {
+ $test = trim($test);
+ if(! $test)
+ continue;
+ if(! in_array($test,App::$plugins))
+ $found = false;
+ }
+ }
+ if(! $found)
+ return false;
+ }
+
+ return true;
+}
+
+
+
/**
* @brief Parse theme comment in search of theme infos.
@@ -451,10 +495,10 @@ function get_theme_screenshot($theme) {
$exts = array('.png', '.jpg');
foreach($exts as $ext) {
if(file_exists('view/theme/' . $theme . '/img/screenshot' . $ext))
- return($a->get_baseurl() . '/view/theme/' . $theme . '/img/screenshot' . $ext);
+ return(z_root() . '/view/theme/' . $theme . '/img/screenshot' . $ext);
}
- return($a->get_baseurl() . '/images/blank.png');
+ return(z_root() . '/images/blank.png');
}
/**
@@ -464,19 +508,19 @@ function get_theme_screenshot($theme) {
* @param string $media change media attribute (default to 'screen')
*/
function head_add_css($src, $media = 'screen') {
- get_app()->css_sources[] = array($src, $media);
+ App::$css_sources[] = array($src, $media);
}
function head_remove_css($src, $media = 'screen') {
$a = get_app();
- $index = array_search(array($src, $media), $a->css_sources);
+ $index = array_search(array($src, $media), App::$css_sources);
if ($index !== false)
- unset($a->css_sources[$index]);
+ unset(App::$css_sources[$index]);
}
function head_get_css() {
$str = '';
- $sources = get_app()->css_sources;
+ $sources = App::$css_sources;
if (count($sources)) {
foreach ($sources as $source)
$str .= format_css_if_exists($source);
@@ -516,7 +560,7 @@ function script_path() {
// Some proxy setups may require using http_host
- if(intval(get_app()->config['system']['script_path_use_http_host']))
+ if(intval(App::$config['system']['script_path_use_http_host']))
$server_var = 'HTTP_HOST';
else
$server_var = 'SERVER_NAME';
@@ -532,19 +576,19 @@ function script_path() {
}
function head_add_js($src) {
- get_app()->js_sources[] = $src;
+ App::$js_sources[] = $src;
}
function head_remove_js($src) {
$a = get_app();
- $index = array_search($src, $a->js_sources);
+ $index = array_search($src, App::$js_sources);
if($index !== false)
- unset($a->js_sources[$index]);
+ unset(App::$js_sources[$index]);
}
function head_get_js() {
$str = '';
- $sources = get_app()->js_sources;
+ $sources = App::$js_sources;
if(count($sources))
foreach($sources as $source) {
if($source === 'main.js')
@@ -580,7 +624,7 @@ function theme_include($file, $root = '') {
if($root !== '' && $root[strlen($root)-1] !== '/')
$root = $root . '/';
- $theme_info = $a->theme_info;
+ $theme_info = App::$theme_info;
if(array_key_exists('extends',$theme_info))
$parent = $theme_info['extends'];
@@ -612,7 +656,7 @@ function theme_include($file, $root = '') {
function get_intltext_template($s, $root = '') {
$a = get_app();
- $t = $a->template_engine();
+ $t = App::template_engine();
$template = $t->get_intltext_template($s, $root);
return $template;
@@ -621,22 +665,11 @@ function get_intltext_template($s, $root = '') {
function get_markup_template($s, $root = '') {
$a = get_app();
- $t = $a->template_engine();
+ $t = App::template_engine();
$template = $t->get_markup_template($s, $root);
return $template;
}
-// return the standardised version. Since we can't easily compare
-// before the STD_VERSION definition was applied, we have to treat
-// all prior release versions the same. You can dig through them
-// with other means (such as RED_VERSION) if necessary.
-
-function get_std_version() {
- if(defined('STD_VERSION'))
- return STD_VERSION;
- return '0.0.0';
-}
-
function folder_exists($folder)
{