/**
* Calculate an old info array from a new {@link Addon}.
*
* This is a backwards compatibility function only and should not be used for new code.
*
* @param Addon $addon The addon to calculate.
* @return array Returns an info array.
* @deprecated
*/
public static function calcOldInfoArray(Addon $addon)
{
$info = $addon->getInfo();
$capitalCaseSheme = new \Vanilla\Utility\CapitalCaseScheme();
$info = $capitalCaseSheme->convertArrayKeys($info, ['RegisterPermissions']);
// This is the basic information from scanPluginFile().
$name = $addon->getInfoValue('keyRaw', $addon->getKey());
$info['Index'] = $name;
$info['ClassName'] = $addon->getPluginClass();
$info['PluginFilePath'] = $addon->getClassPath($addon->getPluginClass(), Addon::PATH_FULL);
$info['PluginRoot'] = $addon->path();
touchValue('Name', $info, $name);
touchValue('Folder', $info, $name);
$info['Dir'] = $addon->path('', Addon::PATH_ADDON);
if ($icon = $addon->getIcon(Addon::PATH_ADDON)) {
$info['IconUrl'] = $icon;
}
// This is some additional information from indexSearchPath().
if ($info['PluginFilePath']) {
$info['RealFile'] = realpath($info['PluginFilePath']);
}
$info['RealRoot'] = realpath($info['PluginRoot']);
$info['SearchPath'] = dirname($addon->path());
// Rejoin the authors.
$names = [];
$emails = [];
$homepages = [];
foreach ($addon->getInfoValue('authors', []) as $author) {
if (isset($author['name'])) {
$names[] = $author['name'];
}
if (isset($author['email'])) {
$emails[] = $author['email'];
}
if (isset($author['homepage'])) {
$homepages[] = $author['homepage'];
}
}
if (!empty($names)) {
$info['Author'] = implode(', ', $names);
}
if (!empty($emails)) {
$info['AuthorEmail'] = implode(', ', $emails);
}
if (!empty($homepages)) {
$info['AuthorUrl'] = implode(', ', $homepages);
}
unset($info['Authors']);
// Themes have their own particular fields.
if ($addon->getType() === Addon::TYPE_THEME) {
$info['ThemeRoot'] = $addon->path('');
if (file_exists($addon->path('about.php'))) {
$info['AboutFile'] = $addon->path('about.php');
$info['RealAboutFile'] = realpath($info['AboutFile']);
}
if ($hooksClass = $addon->getPluginClass()) {
$info['HooksFile'] = $addon->getClassPath($hooksClass);
$info['RealHooksFile'] = realpath($info['HooksFile']);
}
if ($screenshot = $addon->getIcon(Addon::PATH_ADDON)) {
if (basename($screenshot) === 'mobile.png') {
$info['MobileScreenshotUrl'] = $screenshot;
} else {
$info['ScreenshotUrl'] = $screenshot;
}
}
}
return $info;
}