aboutsummaryrefslogtreecommitdiffstats
path: root/include/plugin.php
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2018-01-13 15:54:45 -0800
committerzotlabs <mike@macgirvin.com>2018-01-13 15:54:45 -0800
commit76c8bbf7b83d6cdbd0b16ebbdaa4cab48662221f (patch)
treefb5d58779c5f4984a2e9cf354e154e06c997c1c9 /include/plugin.php
parente8958b1fb85ebcc4c51632a2de746b9aec6f354e (diff)
parentce10a44e722c9bbaceff64273641c3e08c6ad7a5 (diff)
downloadvolse-hubzilla-76c8bbf7b83d6cdbd0b16ebbdaa4cab48662221f.tar.gz
volse-hubzilla-76c8bbf7b83d6cdbd0b16ebbdaa4cab48662221f.tar.bz2
volse-hubzilla-76c8bbf7b83d6cdbd0b16ebbdaa4cab48662221f.zip
Merge branch 'dev' of https://github.com/redmatrix/hubzilla into dev_merge
Diffstat (limited to 'include/plugin.php')
-rwxr-xr-xinclude/plugin.php77
1 files changed, 77 insertions, 0 deletions
diff --git a/include/plugin.php b/include/plugin.php
index 95afdaeb5..67157dee7 100755
--- a/include/plugin.php
+++ b/include/plugin.php
@@ -404,6 +404,83 @@ function get_plugin_info($plugin){
return $info;
}
+/**
+ * @brief Parse widget comment in search of widget info.
+ *
+ * like
+ * \code
+ * * Name: MyWidget
+ * * Description: A widget
+ * * Version: 1.2.3
+ * * Author: John <profile url>
+ * * Author: Jane <email>
+ * *
+ *\endcode
+ * @param string $widget the name of the widget
+ * @return array with the information
+ */
+function get_widget_info($widget){
+ $m = array();
+ $info = array(
+ 'name' => $widget,
+ 'description' => '',
+ 'author' => array(),
+ 'maintainer' => array(),
+ 'version' => '',
+ 'requires' => ''
+ );
+
+ $ucwidget = ucfirst($widget);
+
+ $checkpaths = [
+ "Zotlabs/SiteWidget/$ucwidget.php",
+ "Zotlibs/Widget/$ucwidget.php",
+ "addon/$ucwidget/$ucwidget.php",
+ "addon/$widget.php"
+ ];
+
+ $widget_found = false;
+
+ foreach ($checkpaths as $path) {
+ if (is_file($path)) {
+ $widget_found = true;
+ $f = file_get_contents($path);
+ break;
+ }
+ }
+
+ if(! ($widget_found && $f))
+ return $info;
+
+ $f = escape_tags($f);
+ $r = preg_match("|/\*.*\*/|msU", $f, $m);
+
+ 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' || $k == 'maintainer'){
+ $r = preg_match("|([^<]+)<([^>]+)>|", $v, $m);
+ if ($r) {
+ $info[$k][] = array('name' => $m[1], 'link' => $m[2]);
+ } else {
+ $info[$k][] = array('name' => $v);
+ }
+ }
+ else {
+ $info[$k] = $v;
+ }
+ }
+ }
+ }
+
+ return $info;
+}
+
+
function check_plugin_versions($info) {
if(! is_array($info))