mirror of
https://github.com/friendica/friendica
synced 2025-04-26 10:30:11 +00:00
Fix support for multiple authors and maintainers
This commit is contained in:
parent
a80bf0ddf1
commit
b0e3f1f64d
4 changed files with 55 additions and 35 deletions
|
@ -24,8 +24,8 @@ final class AddonInfo
|
||||||
$id = array_key_exists('id', $info) ? (string) $info['id'] : '';
|
$id = array_key_exists('id', $info) ? (string) $info['id'] : '';
|
||||||
$name = array_key_exists('name', $info) ? (string) $info['name'] : '';
|
$name = array_key_exists('name', $info) ? (string) $info['name'] : '';
|
||||||
$description = array_key_exists('description', $info) ? (string) $info['description'] : '';
|
$description = array_key_exists('description', $info) ? (string) $info['description'] : '';
|
||||||
$author = array_key_exists('author', $info) ? self::parseContributor($info['author']) : [];
|
$authors = array_key_exists('authors', $info) ? self::parseContributors($info['authors']) : [];
|
||||||
$maintainer = array_key_exists('maintainer', $info) ? self::parseContributor($info['maintainer']) : [];
|
$maintainers = array_key_exists('maintainers', $info) ? self::parseContributors($info['maintainers']) : [];
|
||||||
$version = array_key_exists('version', $info) ? (string) $info['version'] : '';
|
$version = array_key_exists('version', $info) ? (string) $info['version'] : '';
|
||||||
$status = array_key_exists('status', $info) ? (string) $info['status'] : '';
|
$status = array_key_exists('status', $info) ? (string) $info['status'] : '';
|
||||||
|
|
||||||
|
@ -33,32 +33,42 @@ final class AddonInfo
|
||||||
$id,
|
$id,
|
||||||
$name,
|
$name,
|
||||||
$description,
|
$description,
|
||||||
$author,
|
$authors,
|
||||||
$maintainer,
|
$maintainers,
|
||||||
$version,
|
$version,
|
||||||
$status
|
$status
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function parseContributor($entry): array
|
private static function parseContributors($entries): array
|
||||||
{
|
{
|
||||||
if (!is_array($entry)) {
|
if (!is_array($entries)) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!array_key_exists('name', $entry)) {
|
$contributors = [];
|
||||||
return [];
|
|
||||||
|
foreach ($entries as $entry) {
|
||||||
|
if (!is_array($entry)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!array_key_exists('name', $entry)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$contributor = [
|
||||||
|
'name' => (string) $entry['name'],
|
||||||
|
];
|
||||||
|
|
||||||
|
if (array_key_exists('link', $entry)) {
|
||||||
|
$contributor['link'] = (string) $entry['link'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$contributors[] = $contributor;
|
||||||
}
|
}
|
||||||
|
|
||||||
$contributor = [
|
return $contributors;
|
||||||
'name' => (string) $entry['name'],
|
|
||||||
];
|
|
||||||
|
|
||||||
if (array_key_exists('link', $entry)) {
|
|
||||||
$contributor['link'] = (string) $entry['link'];
|
|
||||||
}
|
|
||||||
|
|
||||||
return $contributor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private string $id = '';
|
private string $id = '';
|
||||||
|
@ -67,9 +77,9 @@ final class AddonInfo
|
||||||
|
|
||||||
private string $description = '';
|
private string $description = '';
|
||||||
|
|
||||||
private array $author = [];
|
private array $authors = [];
|
||||||
|
|
||||||
private array $maintainer = [];
|
private array $maintainers = [];
|
||||||
|
|
||||||
private string $version = '';
|
private string $version = '';
|
||||||
|
|
||||||
|
@ -79,16 +89,16 @@ final class AddonInfo
|
||||||
string $id,
|
string $id,
|
||||||
string $name,
|
string $name,
|
||||||
string $description,
|
string $description,
|
||||||
array $author,
|
array $authors,
|
||||||
array $maintainer,
|
array $maintainers,
|
||||||
string $version,
|
string $version,
|
||||||
string $status
|
string $status
|
||||||
) {
|
) {
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
$this->description = $description;
|
$this->description = $description;
|
||||||
$this->author = $author;
|
$this->authors = $authors;
|
||||||
$this->maintainer = $maintainer;
|
$this->maintainers = $maintainers;
|
||||||
$this->version = $version;
|
$this->version = $version;
|
||||||
$this->status = $status;
|
$this->status = $status;
|
||||||
}
|
}
|
||||||
|
@ -108,14 +118,14 @@ final class AddonInfo
|
||||||
return $this->description;
|
return $this->description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAuthor(): array
|
public function getAuthors(): array
|
||||||
{
|
{
|
||||||
return $this->author;
|
return $this->authors;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMaintainer(): array
|
public function getMaintainers(): array
|
||||||
{
|
{
|
||||||
return $this->maintainer;
|
return $this->maintainers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getVersion(): string
|
public function getVersion(): string
|
||||||
|
|
|
@ -103,6 +103,14 @@ final class AddonProxy implements AddonHelper
|
||||||
// add addon ID
|
// add addon ID
|
||||||
$data['id'] = $addonId;
|
$data['id'] = $addonId;
|
||||||
|
|
||||||
|
// rename author to authors
|
||||||
|
$data['authors'] = $data['author'];
|
||||||
|
unset($data['author']);
|
||||||
|
|
||||||
|
// rename maintainer to maintainers
|
||||||
|
$data['maintainers'] = $data['maintainer'];
|
||||||
|
unset($data['maintainer']);
|
||||||
|
|
||||||
return AddonInfo::fromArray($data);
|
return AddonInfo::fromArray($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -94,6 +94,8 @@ class Details extends BaseAdmin
|
||||||
|
|
||||||
$t = Renderer::getMarkupTemplate('admin/addons/details.tpl');
|
$t = Renderer::getMarkupTemplate('admin/addons/details.tpl');
|
||||||
|
|
||||||
|
throw new \Exception('ff');
|
||||||
|
|
||||||
return Renderer::replaceMacros($t, [
|
return Renderer::replaceMacros($t, [
|
||||||
'$title' => DI::l10n()->t('Administration'),
|
'$title' => DI::l10n()->t('Administration'),
|
||||||
'$page' => DI::l10n()->t('Addons'),
|
'$page' => DI::l10n()->t('Addons'),
|
||||||
|
@ -107,8 +109,8 @@ class Details extends BaseAdmin
|
||||||
'name' => $addonInfo->getName(),
|
'name' => $addonInfo->getName(),
|
||||||
'version' => $addonInfo->getVersion(),
|
'version' => $addonInfo->getVersion(),
|
||||||
'description' => $addonInfo->getDescription(),
|
'description' => $addonInfo->getDescription(),
|
||||||
'author' => $addonInfo->getAuthor(),
|
'author' => $addonInfo->getAuthors(),
|
||||||
'maintainer' => $addonInfo->getMaintainer(),
|
'maintainer' => $addonInfo->getMaintainers(),
|
||||||
],
|
],
|
||||||
'$str_author' => DI::l10n()->t('Author: '),
|
'$str_author' => DI::l10n()->t('Author: '),
|
||||||
'$str_maintainer' => DI::l10n()->t('Maintainer: '),
|
'$str_maintainer' => DI::l10n()->t('Maintainer: '),
|
||||||
|
|
|
@ -20,8 +20,8 @@ class AddonInfoTest extends TestCase
|
||||||
'id' => '',
|
'id' => '',
|
||||||
'name' => '',
|
'name' => '',
|
||||||
'description' => '',
|
'description' => '',
|
||||||
'author' => [],
|
'authors' => [],
|
||||||
'maintainer' => [],
|
'maintainers' => [],
|
||||||
'version' => '',
|
'version' => '',
|
||||||
'status' => '',
|
'status' => '',
|
||||||
];
|
];
|
||||||
|
@ -35,8 +35,8 @@ class AddonInfoTest extends TestCase
|
||||||
'id' => 'test',
|
'id' => 'test',
|
||||||
'name' => 'Test-Addon',
|
'name' => 'Test-Addon',
|
||||||
'description' => 'This is an addon for tests',
|
'description' => 'This is an addon for tests',
|
||||||
'author' => ['name' => 'Sam'],
|
'authors' => [['name' => 'Sam']],
|
||||||
'maintainer' => ['name' => 'Sam', 'link' => 'https://example.com'],
|
'maintainers' => [['name' => 'Sam', 'link' => 'https://example.com']],
|
||||||
'version' => '0.1',
|
'version' => '0.1',
|
||||||
'status' => 'In Development',
|
'status' => 'In Development',
|
||||||
];
|
];
|
||||||
|
@ -47,8 +47,8 @@ class AddonInfoTest extends TestCase
|
||||||
$this->assertSame($data['name'], $info->getName());
|
$this->assertSame($data['name'], $info->getName());
|
||||||
$this->assertSame($data['description'], $info->getDescription());
|
$this->assertSame($data['description'], $info->getDescription());
|
||||||
$this->assertSame($data['description'], $info->getDescription());
|
$this->assertSame($data['description'], $info->getDescription());
|
||||||
$this->assertSame($data['author'], $info->getAuthor());
|
$this->assertSame($data['authors'], $info->getAuthors());
|
||||||
$this->assertSame($data['maintainer'], $info->getMaintainer());
|
$this->assertSame($data['maintainers'], $info->getMaintainers());
|
||||||
$this->assertSame($data['version'], $info->getVersion());
|
$this->assertSame($data['version'], $info->getVersion());
|
||||||
$this->assertSame($data['status'], $info->getStatus());
|
$this->assertSame($data['status'], $info->getStatus());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue