auth->isSuperAdmin()) { return null; } # admin behaviors $core->addBehavior('pluginsToolsTabs', ['csvBehaviors', 'pluginsToolsTabs']); $core->addBehavior('themesToolsTabs', ['csvBehaviors', 'themesToolsTabs']); class csvBehaviors { public const DC_MAX = '2.23.1'; # admin plugins page tab public static function pluginsToolsTabs(dcCore $core): void { self::modulesToolsTabs($core, $core->plugins, explode(',', DC_DISTRIB_PLUGINS), $core->adminurl->get('admin.plugins') . '#csv'); } # admin themes page tab public static function themesToolsTabs(dcCore $core): void { self::modulesToolsTabs($core, $core->themes, explode(',', DC_DISTRIB_THEMES), $core->adminurl->get('admin.blog.theme') . '#csv'); } # generic page tab protected static function modulesToolsTabs(dcCore $core, dcModules $modules, array $excludes, string $page_url): void { echo '
' . '

' . __('Check stores versions') . '

'; if (!method_exists('dcUtils', 'versionsCompare') || dcUtils::versionsCompare(DC_VERSION, self::DC_MAX, '>', false)) { echo '

' . sprintf(__('This version does not support Dotclear > %s'), self::DC_MAX) . '

'; return; } $list = []; foreach (array_merge($modules->getModules(), $modules->getDisabledModules()) as $id => $module) { if (!in_array($id, $excludes)) { $list[$id] = $module; } } if (!count($list)) { echo '
' . __('There is no module to check') . '
' . '
'; return; } echo '
' . '

' . $core->formNonce() . '

' . '
'; if (!empty($_POST['csvcheck'])) { $store = new csvStore($modules, dcCore::app()->blog->settings->system->store_plugin_url, true); self::modulesList($list, $store->get(true)); } echo ''; } private static function modulesList($modules, $repos) { echo '
' . '' . '' . '' . '' . '' . ''; if (DC_ALLOW_REPOSITORIES) { echo ''; } foreach ($modules as $id => $module) { if (!isset($repos[$id])) { $img = [__('No version available'), 'check-off.png']; } elseif (isset($repos[$id]) && dcUtils::versionsCompare(DC_VERSION, $repos[$id]['dc_min'], '>=', false)) { $img = [__('No update available'), 'check-wrn.png']; } else { $img = [__('Newer version available'), 'check-on.png']; } $img = sprintf('%1$s', $img[0], $img[1]); $default_icon = false; if (file_exists($module['root'] . '/icon.svg')) { $icon = dcPage::getPF($id . '/icon.svg'); } elseif (file_exists($module['root'] . '/icon.png')) { $icon = dcPage::getPF($id . '/icon.png'); } else { $icon = 'images/module.svg'; $default_icon = true; } if (file_exists($module['root'] . '/icon-dark.svg')) { $icon = [$icon, dcPage::getPF($id . '/icon-dark.svg')]; } elseif (file_exists($module['root'] . '/icon-dark.png')) { $icon = [$icon, dcPage::getPF($id . '/icon-dark.png')]; } elseif ($default_icon) { $icon = [$icon, 'images/module-dark.svg']; } echo '' . '' . '' . '' . '' . ''; if (DC_ALLOW_REPOSITORIES) { echo ''; } } else { echo '' . ''; } echo ''; } echo '
' . __('Name') . '' . __('Current version') . '' . __('Latest version') . '' . __('Written for Dotclear') . '' . __('Repository') . '
' . $img . '' . dcAdminHelper::adminIcon($icon, false, html::escapeHTML($id), html::escapeHTML($id)) . '' . html::escapeHTML($module['name']) . ($id != $module['name'] ? sprintf(__(' (%s)'), $id) : '') . ''; if (isset($repos[$id])) { echo '' . html::escapeHTML($repos[$id]['current_version']) . '' . html::escapeHTML($repos[$id]['version']) . '' . html::escapeHTML($repos[$id]['dc_min']) . '' . (empty($module['repository']) ? __('Official repository') : __('Third-party repository')) . '' . html::escapeHTML($module['version']) . '' . html::escapeHTML(__('No version available on stores')) . '
'; } }