licenseBootstrap/inc/lib.license.bootstrap.php

97 lines
2.7 KiB
PHP
Raw Normal View History

2021-08-17 21:25:45 +00:00
<?php
2021-09-02 19:43:35 +00:00
/**
* @brief licenseBootstrap, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis
*
* @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
{
2021-08-17 21:46:17 +00:00
public static function modules($core, $modules, $type, $title)
{
$type = $type == 'themes' ? 'themes' : 'plugins';
2021-08-17 21:25:45 +00:00
2021-08-17 21:46:17 +00:00
echo
'<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)) {
echo
'<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>' .
'<th class="nowrap">' . __('Id') .'</th>' .
'<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
2021-08-17 21:46:17 +00:00
foreach (self::sort($modules) as $id => $module) {
echo
'<tr class="line">' .
'<td class="nowrap"><label class="classic">' .
form::checkbox(array('modules[' . html::escapeHTML($id) . ']'), 1) .
html::escapeHTML($id) .
'</label></td>'.
'<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>' .
(!empty($_REQUEST['redir']) ?
form::hidden(
array('redir'),
html::escapeHTML($_REQUEST['redir'])
) : ''
).
form::hidden(array('p'), 'licenseBootstrap') .
form::hidden(array('type'), $type) .
form::hidden(array('action'),'addlicense') .
'<input type="submit" name="addlicense" value="' .
__('Add license to selected modules') . '" />' .
$core->formNonce() . '</p>' .
'</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)
{
$sorter = array();
foreach($modules as $id => $module) {
$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;
}
}