aboutsummaryrefslogtreecommitdiffstats
path: root/include/plugin.php
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2022-02-20 20:18:24 +0000
committerMario <mario@mariovavti.com>2022-02-20 20:18:24 +0000
commit2a60f1cc6ed49ab559090c831788308fe3df0706 (patch)
tree1a5a0a28cbf4aaeb38dc0b08f03c874833500e78 /include/plugin.php
parent2ddff785e55745045bc9a742b2287a500e5370a6 (diff)
downloadvolse-hubzilla-2a60f1cc6ed49ab559090c831788308fe3df0706.tar.gz
volse-hubzilla-2a60f1cc6ed49ab559090c831788308fe3df0706.tar.bz2
volse-hubzilla-2a60f1cc6ed49ab559090c831788308fe3df0706.zip
merge branch pdledit_gui into dev - many widgets still miss their description and requirements (this is work in progress)
Diffstat (limited to 'include/plugin.php')
-rw-r--r--include/plugin.php73
1 files changed, 73 insertions, 0 deletions
diff --git a/include/plugin.php b/include/plugin.php
index 95c9882d0..25fa22e10 100644
--- a/include/plugin.php
+++ b/include/plugin.php
@@ -794,6 +794,79 @@ function get_theme_info($theme){
}
/**
+ * @brief Parse template comment in search of template info.
+ *
+ * like
+ * \code
+ * * Name: MyWidget
+ * * Description: A widget
+ * * Version: 1.2.3
+ * * Author: John <profile url>
+ * * Author: Jane <email>
+ * * ContentRegionID: some_id
+ * * ContentRegionID: some_other_id
+ * *
+ *\endcode
+ * @param string $widget the name of the widget
+ * @return array with the information
+ */
+function get_template_info($template){
+ $m = array();
+ $info = array(
+ 'name' => $template,
+ 'description' => '',
+ 'author' => array(),
+ 'maintainer' => array(),
+ 'version' => '',
+ 'content_regions' => []
+ );
+
+ $checkpaths = [
+ "view/php/$template.php",
+ ];
+
+ $template_found = false;
+
+ foreach ($checkpaths as $path) {
+ if (is_file($path)) {
+ $template_found = true;
+ $f = file_get_contents($path);
+ break;
+ }
+ }
+
+ if(! ($template_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;
+}
+
+/**
* @brief Returns the theme's screenshot.
*
* The screenshot is expected as view/theme/$theme/img/screenshot.[png|jpg].