2021-08-17 21:25:45 +00:00
|
|
|
<?php
|
2021-09-02 19:43:35 +00:00
|
|
|
/**
|
|
|
|
* @brief licenseBootstrap, a plugin for Dotclear 2
|
2022-11-20 21:36:32 +00:00
|
|
|
*
|
2021-09-02 19:43:35 +00:00
|
|
|
* @package Dotclear
|
|
|
|
* @subpackage Plugin
|
2022-11-20 21:36:32 +00:00
|
|
|
*
|
2021-09-02 19:43:35 +00:00
|
|
|
* @author Jean-Christian Denis
|
2022-11-20 21:36:32 +00:00
|
|
|
*
|
2021-09-02 19:43:35 +00:00
|
|
|
* @copyright Jean-Christian Denis
|
|
|
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
|
|
*/
|
2021-08-17 21:25:45 +00:00
|
|
|
if (!defined('DC_CONTEXT_ADMIN')) {
|
2021-08-17 21:46:17 +00:00
|
|
|
return null;
|
2021-08-17 21:25:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class libLicenseBootstrap
|
|
|
|
{
|
2022-11-20 21:36:32 +00:00
|
|
|
public static function modules($modules, $type, $title)
|
2021-08-17 21:46:17 +00:00
|
|
|
{
|
|
|
|
$type = $type == 'themes' ? 'themes' : 'plugins';
|
2021-08-17 21:25:45 +00:00
|
|
|
|
2022-11-20 21:36:32 +00:00
|
|
|
echo
|
2021-08-17 21:46:17 +00:00
|
|
|
'<div class="multi-part" ' .
|
|
|
|
'id="packman-' . $type . '" title="' . $title . '">' .
|
|
|
|
'<h3>' . $title . '</h3>';
|
2021-08-17 21:25:45 +00:00
|
|
|
|
2021-08-17 21:46:17 +00:00
|
|
|
if (empty($modules) && !is_array($modules)) {
|
2022-11-20 21:36:32 +00:00
|
|
|
echo
|
2021-08-17 21:46:17 +00:00
|
|
|
'<p><strong>' . __('There are no modules.') . '</strong></p>' .
|
|
|
|
'<div>';
|
2021-08-17 21:25:45 +00:00
|
|
|
|
2021-08-17 21:46:17 +00:00
|
|
|
return null;
|
|
|
|
}
|
2021-08-17 21:25:45 +00:00
|
|
|
|
2021-08-17 21:46:17 +00:00
|
|
|
echo
|
|
|
|
'<form action="plugin.php" method="post">' .
|
|
|
|
'<table class="clear"><tr>' .
|
2022-11-20 21:36:32 +00:00
|
|
|
'<th class="nowrap">' . __('Id') . '</th>' .
|
2021-08-17 21:46:17 +00:00
|
|
|
'<th class="nowrap">' . __('Version') . '</th>' .
|
|
|
|
'<th class="nowrap maximal">' . __('Name') . '</th>' .
|
|
|
|
'<th class="nowrap">' . __('Root') . '</th>' .
|
|
|
|
'</tr>';
|
2021-09-02 19:43:35 +00:00
|
|
|
|
2022-11-20 21:36:32 +00:00
|
|
|
foreach (self::sort($modules) as $id => $module) {
|
2021-08-17 21:46:17 +00:00
|
|
|
echo
|
|
|
|
'<tr class="line">' .
|
|
|
|
'<td class="nowrap"><label class="classic">' .
|
2022-11-20 21:36:32 +00:00
|
|
|
form::checkbox(['modules[' . html::escapeHTML($id) . ']'], 1) .
|
2021-08-17 21:46:17 +00:00
|
|
|
html::escapeHTML($id) .
|
2022-11-20 21:36:32 +00:00
|
|
|
'</label></td>' .
|
2021-08-17 21:46:17 +00:00
|
|
|
'<td class="nowrap count">' .
|
|
|
|
html::escapeHTML($module['version']) .
|
|
|
|
'</td>' .
|
|
|
|
'<td class="nowrap maximal">' .
|
|
|
|
__(html::escapeHTML($module['name'])) .
|
|
|
|
'</td>' .
|
|
|
|
'<td class="nowrap">' .
|
|
|
|
dirname(path::real($module['root'], false)) .
|
|
|
|
'</td>' .
|
|
|
|
'</tr>';
|
|
|
|
}
|
2021-08-17 21:25:45 +00:00
|
|
|
|
2021-08-17 21:46:17 +00:00
|
|
|
echo
|
|
|
|
'</table>' .
|
|
|
|
'<p class="checkboxes-helpers"></p>' .
|
|
|
|
'<p>' .
|
2022-11-20 21:36:32 +00:00
|
|
|
(
|
|
|
|
!empty($_REQUEST['redir']) ?
|
2021-08-17 21:46:17 +00:00
|
|
|
form::hidden(
|
2022-11-20 21:36:32 +00:00
|
|
|
['redir'],
|
2021-08-17 21:46:17 +00:00
|
|
|
html::escapeHTML($_REQUEST['redir'])
|
|
|
|
) : ''
|
2022-11-20 21:36:32 +00:00
|
|
|
) .
|
|
|
|
form::hidden(['p'], 'licenseBootstrap') .
|
|
|
|
form::hidden(['type'], $type) .
|
|
|
|
form::hidden(['action'], 'addlicense') .
|
2021-08-17 21:46:17 +00:00
|
|
|
'<input type="submit" name="addlicense" value="' .
|
|
|
|
__('Add license to selected modules') . '" />' .
|
2022-11-20 21:36:32 +00:00
|
|
|
dcCore::app()->formNonce() . '</p>' .
|
2021-08-17 21:46:17 +00:00
|
|
|
'</form>' .
|
2021-08-17 21:25:45 +00:00
|
|
|
|
2021-08-17 21:46:17 +00:00
|
|
|
'</div>';
|
|
|
|
}
|
2021-08-17 21:25:45 +00:00
|
|
|
|
2021-08-17 21:46:17 +00:00
|
|
|
protected static function sort($modules)
|
|
|
|
{
|
2022-11-20 21:36:32 +00:00
|
|
|
$sorter = [];
|
|
|
|
foreach ($modules as $id => $module) {
|
2021-08-17 21:46:17 +00:00
|
|
|
$sorter[$id] = $id;
|
|
|
|
}
|
|
|
|
array_multisort($sorter, SORT_ASC, $modules);
|
2021-08-17 21:25:45 +00:00
|
|
|
|
2021-08-17 21:46:17 +00:00
|
|
|
return $modules;
|
|
|
|
}
|
2022-11-20 21:36:32 +00:00
|
|
|
}
|