aboutsummaryrefslogtreecommitdiffstats
path: root/boot.php
diff options
context:
space:
mode:
authorFabio Comuni <fabrix.xm@gmail.com>2011-06-14 14:21:43 +0200
committerFabio Comuni <fabrix.xm@gmail.com>2011-06-14 14:21:43 +0200
commit00e142e4f753005a8b4003585c6a88548f006315 (patch)
tree95ff3c0c6a7ad53be0d4e0042a93b8720f5c9941 /boot.php
parent283160901fcb5670b48c7897ccce615872cb956e (diff)
downloadvolse-hubzilla-00e142e4f753005a8b4003585c6a88548f006315.tar.gz
volse-hubzilla-00e142e4f753005a8b4003585c6a88548f006315.tar.bz2
volse-hubzilla-00e142e4f753005a8b4003585c6a88548f006315.zip
Load plugin info from plugin file. Show README.md or README from plugin dir in plugin details page
Diffstat (limited to 'boot.php')
-rw-r--r--boot.php52
1 files changed, 52 insertions, 0 deletions
diff --git a/boot.php b/boot.php
index 42b0ca41e..5d45de36f 100644
--- a/boot.php
+++ b/boot.php
@@ -2828,3 +2828,55 @@ function is_site_admin() {
return false;
}}
+/*
+ * parse plugin comment in search of plugin infos.
+ * like
+ *
+ * * Name: Plugin
+ * * Description: A plugin which plugs in
+ * * Version: 1.2.3
+ * * Author: John <profile url>
+ * * Author: Jane <email>
+ * *
+ */
+
+if (! function_exists('get_plugin_info')){
+function get_plugin_info($plugin){
+ if (!is_file("addon/$plugin/$plugin.php")) return false;
+
+ $f = file_get_contents("addon/$plugin/$plugin.php");
+ $r = preg_match("|/\*.*\*/|msU", $f, $m);
+
+ $info=Array(
+ 'name' => $plugin,
+ 'description' => "",
+ 'author' => array(),
+ 'version' => ""
+ );
+
+ if ($r){
+ $ll = explode("\n", $m[0]);
+ foreach( $ll as $l ) {
+ $l = trim($l,"\t\n\r */");
+ if ($l!=""){
+ list($k,$v) = array_map("trim", explode(":",$l,2));
+ $k= strtolower($k);
+ if ($k=="author"){
+ $r=preg_match("|([^<]+)<([^>]+)>|", $v, $m);
+ if ($r) {
+ $info['author'][] = array('name'=>$m[1], 'link'=>$m[2]);
+ } else {
+ $info['author'][] = array('name'=>$v);
+ }
+ } else {
+ if (array_key_exists($k,$info)){
+ $info[$k]=$v;
+ }
+ }
+
+ }
+ }
+
+ }
+ return $info;
+}}