From 17faeca2417f576120da2218c73b48679f960df1 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 28 Jan 2018 00:05:28 -0500 Subject: [PATCH] Improve addon readme display - Add maintainer display support - Remove extra comma after author/maintainer lists --- src/Core/Addon.php | 41 ++++++++++++------------ view/templates/admin/plugins_details.tpl | 14 ++++---- 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/src/Core/Addon.php b/src/Core/Addon.php index b1f401d28..af1d71ac4 100644 --- a/src/Core/Addon.php +++ b/src/Core/Addon.php @@ -254,25 +254,26 @@ class Addon * * like * \code - *...* Name: addon - * * Description: An addon which plugs in - * . * Version: 1.2.3 - * * Author: John - * * Author: Jane - * * - * *\endcode - * @param string $addon the name of the addon - * @return array with the addon information - */ - + * * Name: addon + * * Description: An addon which plugs in + * . * Version: 1.2.3 + * * Author: John + * * Author: Jane + * * Maintainer: Jess + * * + * *\endcode + * @param string $addon the name of the addon + * @return array with the addon information + */ public static function getInfo($addon) { $a = get_app(); - $info=[ + $info = [ 'name' => $addon, 'description' => "", 'author' => [], + 'maintainer' => [], 'version' => "", 'status' => "" ]; @@ -292,18 +293,18 @@ class Addon 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); + list($type, $v) = array_map("trim", explode(":", $l, 2)); + $type = strtolower($type); + if ($type == "author" || $type == "maintainer") { + $r = preg_match("|([^<]+)<([^>]+)>|", $v, $m); if ($r) { - $info['author'][] = ['name'=>$m[1], 'link'=>$m[2]]; + $info[$type][] = ['name' => $m[1], 'link' => $m[2]]; } else { - $info['author'][] = ['name'=>$v]; + $info[$type][] = ['name' => $v]; } } else { - if (array_key_exists($k, $info)) { - $info[$k]=$v; + if (array_key_exists($type, $info)) { + $info[$type] = $v; } } } diff --git a/view/templates/admin/plugins_details.tpl b/view/templates/admin/plugins_details.tpl index cbeb4171e..05e3e8aa0 100644 --- a/view/templates/admin/plugins_details.tpl +++ b/view/templates/admin/plugins_details.tpl @@ -1,22 +1,22 @@

{{$title}} - {{$page}}

- +

{{$info.name}} - {{$info.version}} : {{$action}}

{{$info.description}}

- +

{{$str_author}} - {{foreach $info.author as $a}} - {{if $a.link}}{{$a.name}}{{else}}{{$a.name}}{{/if}}, + {{foreach $info.author as $a name=authors}} + {{if $a.link}}{{$a.name}}{{else}}{{$a.name}}{{/if}}{{if $smarty.foreach.authors.last}}{{else}}, {{/if}} {{/foreach}}

{{$str_maintainer}} - {{foreach $info.maintainer as $a}} - {{if $a.link}}{{$a.name}}{{else}}{{$a.name}}{{/if}}, + {{foreach $info.maintainer as $a name=maintainers}} + {{if $a.link}}{{$a.name}}{{else}}{{$a.name}}{{/if}}{{if $smarty.foreach.maintainers.last}}{{else}}, {{/if}} {{/foreach}}

- + {{if $screenshot}} {{$screenshot.1}} {{/if}}