release 2022.11.20
parent
13ce9e52ad
commit
99fb9bad55
|
@ -1,3 +1,6 @@
|
|||
2022.11.20
|
||||
- fix compatibility with Dotclear 2.24 (required)
|
||||
|
||||
2021.09.10
|
||||
- clean up code
|
||||
- Tested for Dotclear 2.19
|
||||
|
|
19
README.md
19
README.md
|
@ -1,5 +1,12 @@
|
|||
# README
|
||||
|
||||
[![Release](https://img.shields.io/github/v/release/JcDenis/licenseBootstrap)](https://github.com/JcDenis/licenseBootstrap/releases)
|
||||
[![Date](https://img.shields.io/github/release-date/JcDenis/licenseBootstrap)](https://github.com/JcDenis/licenseBootstrap/releases)
|
||||
[![Issues](https://img.shields.io/github/issues/JcDenis/licenseBootstrap)](https://github.com/JcDenis/licenseBootstrap/issues)
|
||||
[![Dotclear](https://img.shields.io/badge/dotclear-v2.24-blue.svg)](https://fr.dotclear.org/download)
|
||||
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-green.svg)](https://plugins.dotaddict.org/dc2/details/licenseBootstrap)
|
||||
[![License](https://img.shields.io/github/license/JcDenis/licenseBootstrap)](https://github.com/JcDenis/licenseBootstrap/blob/master/LICENSE)
|
||||
|
||||
## WHAT IS LICENSEBOOTSTRAP ?
|
||||
|
||||
licenseBootstrap is a plugins for the open-source
|
||||
|
@ -13,7 +20,7 @@ themes and plugins from Dotclear administration pages.
|
|||
licenseBootstrap requires:
|
||||
|
||||
* Super administrator permissions
|
||||
* Dotclear 2.6
|
||||
* Dotclear 2.24
|
||||
|
||||
## USAGE
|
||||
|
||||
|
@ -26,8 +33,14 @@ go to ''configure plugin'', fill in form.
|
|||
Once it's done you can manage your modules license from menu
|
||||
''License bootstrap'' on sidebar or you can add dashboard icon.
|
||||
|
||||
## MORE
|
||||
## LINKS
|
||||
|
||||
* License : GNU GPL v2
|
||||
* License : [GNU GPL v2](https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html)
|
||||
* Source & contribution : [GitHub Page](https://github.com/licenseBootstrap)
|
||||
* Packages & details : [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/licenseBootstrap)
|
||||
|
||||
## CONTRIBUTORS
|
||||
|
||||
* Jean-Christian Denis
|
||||
|
||||
You are welcome to contribute to this code.
|
33
_admin.php
33
_admin.php
|
@ -10,22 +10,21 @@
|
|||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$core->blog->settings->addNamespace('licenseBootstrap');
|
||||
dcCore::app()->blog->settings->addNamespace('licenseBootstrap');
|
||||
|
||||
$core->addBehavior('adminDashboardFavorites', [
|
||||
'licenseBootstrapBehaviors', 'adminDashboardFavorites'
|
||||
dcCore::app()->addBehavior('adminDashboardFavoritesV2', [
|
||||
'licenseBootstrapBehaviors', 'adminDashboardFavorites',
|
||||
]);
|
||||
|
||||
$core->addBehavior('packmanBeforeCreatePackage', [
|
||||
'licenseBootstrapBehaviors', 'packmanBeforeCreatePackage'
|
||||
dcCore::app()->addBehavior('packmanBeforeCreatePackage', [
|
||||
'licenseBootstrapBehaviors', 'packmanBeforeCreatePackage',
|
||||
]);
|
||||
|
||||
$_menu['Plugins']->addItem(
|
||||
dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
|
||||
__('License bootstrap'),
|
||||
'plugin.php?p=licenseBootstrap',
|
||||
'index.php?pf=licenseBootstrap/icon.png',
|
||||
|
@ -33,24 +32,24 @@ $_menu['Plugins']->addItem(
|
|||
'/plugin.php\?p=licenseBootstrap(&.*)?$/',
|
||||
$_SERVER['REQUEST_URI']
|
||||
),
|
||||
$core->auth->isSuperAdmin()
|
||||
dcCore::app()->auth->isSuperAdmin()
|
||||
);
|
||||
|
||||
class licenseBootstrapBehaviors
|
||||
{
|
||||
public static function adminDashboardFavorites($core, $favs)
|
||||
public static function adminDashboardFavorites($favs)
|
||||
{
|
||||
$favs->register('licenseBootstrap', array(
|
||||
$favs->register('licenseBootstrap', [
|
||||
'title' => __('License bootstrap'),
|
||||
'url' => 'plugin.php?p=licenseBootstrap',
|
||||
'small-icon' => 'index.php?pf=licenseBootstrap/icon.png',
|
||||
'large-icon' => 'index.php?pf=licenseBootstrap/icon-big.png',
|
||||
'permissions' => $core->auth->isSuperAdmin(),
|
||||
'active_cb' => array(
|
||||
'permissions' => dcCore::app()->auth->isSuperAdmin(),
|
||||
'active_cb' => [
|
||||
'licenseBootstrapBehaviors',
|
||||
'adminDashboardFavoritesActive'
|
||||
)
|
||||
));
|
||||
'adminDashboardFavoritesActive',
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
public static function adminDashboardFavoritesActive($request, $params)
|
||||
|
@ -60,8 +59,8 @@ class licenseBootstrapBehaviors
|
|||
&& $params['p'] == 'licenseBootstrap';
|
||||
}
|
||||
|
||||
public static function packmanBeforeCreatePackage($core, $module)
|
||||
public static function packmanBeforeCreatePackage($module)
|
||||
{
|
||||
licenseBootstrap::addLicense($core, $module);
|
||||
licenseBootstrap::addLicense($module);
|
||||
}
|
||||
}
|
30
_config.php
30
_config.php
|
@ -10,29 +10,27 @@
|
|||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_CONTEXT_MODULE')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$redir = empty($_REQUEST['redir']) ?
|
||||
$list->getURL() . '#plugins' : $_REQUEST['redir'];
|
||||
dcCore::app()->admin->list->getURL() . '#plugins' : $_REQUEST['redir'];
|
||||
|
||||
# -- Get settings --
|
||||
$core->blog->settings->addNamespace('licenseBootstrap');
|
||||
$s = $core->blog->settings->licenseBootstrap;
|
||||
dcCore::app()->blog->settings->addNamespace('licenseBootstrap');
|
||||
$s = dcCore::app()->blog->settings->licenseBootstrap;
|
||||
|
||||
$lb_overwrite = (boolean) $s->overwrite;
|
||||
$lb_write_full = (boolean) $s->write_full;
|
||||
$lb_write_php = (boolean) $s->write_php;
|
||||
$lb_write_js = (boolean) $s->write_js;
|
||||
$lb_exclude_locales = (boolean) $s->exclude_locales;
|
||||
$lb_overwrite = (bool) $s->overwrite;
|
||||
$lb_write_full = (bool) $s->write_full;
|
||||
$lb_write_php = (bool) $s->write_php;
|
||||
$lb_write_js = (bool) $s->write_js;
|
||||
$lb_exclude_locales = (bool) $s->exclude_locales;
|
||||
$lb_license_name = licenseBootstrap::getName($s->license_name);
|
||||
$lb_license_head = licenseBootstrap::gethead($s->license_name, licenseBootstrap::decode($s->license_head));
|
||||
|
||||
# -- Set settings --
|
||||
if (!empty($_POST['save'])) {
|
||||
|
||||
try {
|
||||
$lb_overwrite = !empty($_POST['lb_overwrite']);
|
||||
$lb_write_full = !empty($_POST['lb_write_full']);
|
||||
|
@ -54,12 +52,11 @@ if (!empty($_POST['save'])) {
|
|||
__('Configuration has been successfully updated.')
|
||||
);
|
||||
http::redirect(
|
||||
$list->getURL('module=licenseBootstrap&conf=1&redir='.
|
||||
$list->getRedir())
|
||||
dcCore::app()->admin->list->getURL('module=licenseBootstrap&conf=1&redir=' .
|
||||
dcCore::app()->admin->list->getRedir())
|
||||
);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
$core->error->add($e->getMessage());
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -99,7 +96,6 @@ __('Do not add license block to files from locales folder') .
|
|||
<h4>' . __('Licenses') . '</h4>';
|
||||
|
||||
foreach (licenseBootstrap::getLicenses() as $name) {
|
||||
|
||||
$check = false;
|
||||
$head = licenseBootstrap::getHead($name);
|
||||
if ($name == $lb_license_name) {
|
||||
|
@ -108,7 +104,7 @@ foreach(licenseBootstrap::getLicenses() as $name) {
|
|||
}
|
||||
echo '
|
||||
<p><label class="classic" for="license_' . $name . '">' .
|
||||
form::radio(array('lb_license_name', 'license_' . $name), $name, $check) . ' ' .
|
||||
form::radio(['lb_license_name', 'license_' . $name], $name, $check) . ' ' .
|
||||
sprintf(__('License %s:'), $name) . '</label></p>
|
||||
<p class="area">' .
|
||||
form::textarea('lb_license_head_' . $name, 50, 10, html::escapeHTML($head)) . '
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
|
@ -19,13 +18,13 @@ $this->registerModule(
|
|||
'License bootstrap',
|
||||
'Add license to your plugins and themes',
|
||||
'Jean-Christian Denis',
|
||||
'2021.09.10',
|
||||
'2022.11.20',
|
||||
[
|
||||
'requires' => [['core', '2.19']],
|
||||
'requires' => [['core', '2.24']],
|
||||
'permissions' => null,
|
||||
'type' => 'plugin',
|
||||
'support' => 'https://github.com/JcDenis/licenseBootstrap',
|
||||
'details' => 'https://plugins.dotaddict.org/dc2/details/licenseBootstrap',
|
||||
'repository' => 'https://raw.githubusercontent.com/JcDenis/licenseBootstrap/master/dcstore.xml'
|
||||
'repository' => 'https://raw.githubusercontent.com/JcDenis/licenseBootstrap/master/dcstore.xml',
|
||||
]
|
||||
);
|
85
_install.php
85
_install.php
|
@ -10,79 +10,76 @@
|
|||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
# -- Module specs --
|
||||
|
||||
$dc_min = '2.6';
|
||||
$dc_min = '2.24';
|
||||
$mod_id = 'licenseBootstrap';
|
||||
$mod_conf = array(
|
||||
array(
|
||||
$mod_conf = [
|
||||
[
|
||||
'overwrite',
|
||||
'Overwrite existing licence',
|
||||
false,
|
||||
'boolean'
|
||||
),
|
||||
array(
|
||||
'boolean',
|
||||
],
|
||||
[
|
||||
'write_full',
|
||||
'Add complete licence file',
|
||||
true,
|
||||
'boolean'
|
||||
),
|
||||
array(
|
||||
'boolean',
|
||||
],
|
||||
[
|
||||
'write_php',
|
||||
'Write license into php files',
|
||||
true,
|
||||
'boolean'
|
||||
),
|
||||
array(
|
||||
'boolean',
|
||||
],
|
||||
[
|
||||
'write_js',
|
||||
'Write license into js files',
|
||||
false,
|
||||
'boolean'
|
||||
),
|
||||
array(
|
||||
'boolean',
|
||||
],
|
||||
[
|
||||
'exclude_locales',
|
||||
'Exclude locales from license',
|
||||
true,
|
||||
'boolean'
|
||||
),
|
||||
array(
|
||||
'boolean',
|
||||
],
|
||||
[
|
||||
'license_name',
|
||||
'License short name',
|
||||
'gpl2',
|
||||
'string'
|
||||
),
|
||||
array(
|
||||
'string',
|
||||
],
|
||||
[
|
||||
'license_head',
|
||||
'File header licence text',
|
||||
licenseBootstrap::encode(
|
||||
licenseBootstrap::getHead('gpl2')
|
||||
),
|
||||
'string'
|
||||
),
|
||||
array(
|
||||
'string',
|
||||
],
|
||||
[
|
||||
'behavior_packman',
|
||||
'Add LicenceBootstrap to plugin pacKman',
|
||||
false,
|
||||
'boolean'
|
||||
)
|
||||
);
|
||||
'boolean',
|
||||
],
|
||||
];
|
||||
|
||||
# -- Nothing to change below --
|
||||
|
||||
try {
|
||||
|
||||
# Check module version
|
||||
if (version_compare(
|
||||
$core->getVersion($mod_id),
|
||||
$core->plugins->moduleInfo($mod_id, 'version'),
|
||||
dcCore::app()->getVersion($mod_id),
|
||||
dcCore::app()->plugins->moduleInfo($mod_id, 'version'),
|
||||
'>='
|
||||
)) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -90,28 +87,34 @@ try {
|
|||
if (!method_exists('dcUtils', 'versionsCompare')
|
||||
|| dcUtils::versionsCompare(DC_VERSION, $dc_min, '<', false)) {
|
||||
throw new Exception(sprintf(
|
||||
'%s requires Dotclear %s', $mod_id, $dc_min
|
||||
'%s requires Dotclear %s',
|
||||
$mod_id,
|
||||
$dc_min
|
||||
));
|
||||
}
|
||||
|
||||
# Set module settings
|
||||
$core->blog->settings->addNamespace($mod_id);
|
||||
dcCore::app()->blog->settings->addNamespace($mod_id);
|
||||
foreach ($mod_conf as $v) {
|
||||
$core->blog->settings->{$mod_id}->put(
|
||||
$v[0], $v[2], $v[3], $v[1], false, true
|
||||
dcCore::app()->blog->settings->{$mod_id}->put(
|
||||
$v[0],
|
||||
$v[2],
|
||||
$v[3],
|
||||
$v[1],
|
||||
false,
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
# Set module version
|
||||
$core->setVersion(
|
||||
dcCore::app()->setVersion(
|
||||
$mod_id,
|
||||
$core->plugins->moduleInfo($mod_id, 'version')
|
||||
dcCore::app()->plugins->moduleInfo($mod_id, 'version')
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception $e) {
|
||||
$core->error->add($e->getMessage());
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
|
||||
return false;
|
||||
}
|
|
@ -10,12 +10,9 @@
|
|||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$d = dirname(__FILE__).'/inc/';
|
||||
|
||||
$__autoload['licenseBootstrap'] = $d.'class.license.bootstrap.php';
|
||||
$__autoload['libLicenseBootstrap'] = $d.'lib.license.bootstrap.php';
|
||||
Clearbricks::lib()->autoload(['licenseBootstrap' => __DIR__ . '/inc/class.license.bootstrap.php']);
|
||||
Clearbricks::lib()->autoload(['libLicenseBootstrap' => __DIR__ . '/inc/lib.license.bootstrap.php']);
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
return null;
|
||||
}
|
||||
|
@ -18,29 +17,45 @@ if (!defined('DC_CONTEXT_ADMIN')) {
|
|||
$mod_id = 'pacKman';
|
||||
|
||||
$this->addUserAction(
|
||||
/* type */ 'settings',
|
||||
/* action */ 'delete_all',
|
||||
/* ns */ $mod_id,
|
||||
/* desc */ __('delete all settings')
|
||||
/* type */
|
||||
'settings',
|
||||
/* action */
|
||||
'delete_all',
|
||||
/* ns */
|
||||
$mod_id,
|
||||
/* desc */
|
||||
__('delete all settings')
|
||||
);
|
||||
|
||||
$this->addUserAction(
|
||||
/* type */ 'plugins',
|
||||
/* action */ 'delete',
|
||||
/* ns */ $mod_id,
|
||||
/* desc */ __('delete plugin files')
|
||||
/* type */
|
||||
'plugins',
|
||||
/* action */
|
||||
'delete',
|
||||
/* ns */
|
||||
$mod_id,
|
||||
/* desc */
|
||||
__('delete plugin files')
|
||||
);
|
||||
|
||||
$this->addDirectAction(
|
||||
/* type */ 'settings',
|
||||
/* action */ 'delete_all',
|
||||
/* ns */ $mod_id,
|
||||
/* desc */ sprintf(__('delete all %s settings'), $mod_id)
|
||||
/* type */
|
||||
'settings',
|
||||
/* action */
|
||||
'delete_all',
|
||||
/* ns */
|
||||
$mod_id,
|
||||
/* desc */
|
||||
sprintf(__('delete all %s settings'), $mod_id)
|
||||
);
|
||||
|
||||
$this->addDirectAction(
|
||||
/* type */ 'plugins',
|
||||
/* action */ 'delete',
|
||||
/* ns */ $mod_id,
|
||||
/* desc */ sprintf(__('delete %s plugin files'), $mod_id)
|
||||
/* type */
|
||||
'plugins',
|
||||
/* action */
|
||||
'delete',
|
||||
/* ns */
|
||||
$mod_id,
|
||||
/* desc */
|
||||
sprintf(__('delete %s plugin files'), $mod_id)
|
||||
);
|
|
@ -1,11 +1,12 @@
|
|||
<?xml version="1.0"?>
|
||||
<modules xmlns:da="http://dotaddict.org/da/">
|
||||
<module id="licenseBootstrap">
|
||||
<name>License bootstrap</name>
|
||||
<version>2021.09.10</version>
|
||||
<version>2022.11.20</version>
|
||||
<author>Jean-Christian Denis</author>
|
||||
<desc>Add license to your plugins and themes</desc>
|
||||
<file>https://github.com/JcDenis/licenseBootstrap/releases/download/v2021.09.10/plugin-licenseBootstrap.zip</file>
|
||||
<da:dcmin>2.19</da:dcmin>
|
||||
<file>https://github.com/JcDenis/licenseBootstrap/releases/download/v2022.11.20/plugin-licenseBootstrap.zip</file>
|
||||
<da:dcmin>2.24</da:dcmin>
|
||||
<da:details>https://plugins.dotaddict.org/dc2/details/licenseBootstrap</da:details>
|
||||
<da:support>https://github.com/JcDenis/licenseBootstrap</da:support>
|
||||
</module>
|
||||
|
|
|
@ -10,14 +10,13 @@
|
|||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
class licenseBootstrap
|
||||
{
|
||||
protected static $licenses = array();
|
||||
protected static $licenses = [];
|
||||
|
||||
/**
|
||||
* Add license to a module.
|
||||
|
@ -25,17 +24,15 @@ class licenseBootstrap
|
|||
* Note that you must check if module exists
|
||||
* before calling this method.
|
||||
*
|
||||
* @param object $core dcCore instance
|
||||
* @param array $module Module info
|
||||
*/
|
||||
public static function addLicense($core, $module)
|
||||
public static function addLicense($module)
|
||||
{
|
||||
$s = $core->blog->settings->licenseBootstrap;
|
||||
$s = dcCore::app()->blog->settings->licenseBootstrap;
|
||||
|
||||
# --BEHAVIOR-- licenseBootstrapBeforeAddLicense
|
||||
$core->callBehavior(
|
||||
dcCore::app()->callBehavior(
|
||||
'licenseBootstrapBeforeAddLicense',
|
||||
$core,
|
||||
$module
|
||||
);
|
||||
|
||||
|
@ -50,7 +47,7 @@ class licenseBootstrap
|
|||
$s->license_name,
|
||||
licenseBootstrap::decode($s->license_head),
|
||||
$module,
|
||||
$core->auth,
|
||||
dcCore::app()->auth,
|
||||
$s->overwrite,
|
||||
$s->write_php,
|
||||
$s->write_js,
|
||||
|
@ -58,9 +55,8 @@ class licenseBootstrap
|
|||
);
|
||||
|
||||
# --BEHAVIOR-- licenseBootstrapAfterAddLicense
|
||||
$core->callBehavior(
|
||||
dcCore::app()->callBehavior(
|
||||
'licenseBootstrapAfterAddLicense',
|
||||
$core,
|
||||
$module
|
||||
);
|
||||
}
|
||||
|
@ -74,7 +70,7 @@ class licenseBootstrap
|
|||
{
|
||||
if (empty(licenseBootstrap::$licenses)) {
|
||||
$file_reg = '/^([a-z0-9]+)\.head\.txt$/';
|
||||
$res = array();
|
||||
$res = [];
|
||||
foreach (files::scandir(dirname(__FILE__) . '/licenses/') as $file) {
|
||||
if (preg_match($file_reg, $file, $matches)) {
|
||||
$res[] = $matches[1];
|
||||
|
@ -140,7 +136,7 @@ class licenseBootstrap
|
|||
if (!in_array($name, self::getLicenses())) {
|
||||
$name = 'gpl2';
|
||||
}
|
||||
if (!in_array($part, array('head', 'full'))) {
|
||||
if (!in_array($part, ['head', 'full'])) {
|
||||
$part = 'head';
|
||||
}
|
||||
|
||||
|
@ -174,7 +170,6 @@ class licenseBootstrap
|
|||
);
|
||||
|
||||
foreach (self::getModuleFiles($module['root']) as $file) {
|
||||
|
||||
if ($locales && preg_match('/(\.lang\.php|libs)/', $file)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -191,8 +186,7 @@ class licenseBootstrap
|
|||
$overwrite
|
||||
)
|
||||
);
|
||||
}
|
||||
elseif ($js && $extension == 'js') {
|
||||
} elseif ($js && $extension == 'js') {
|
||||
file_put_contents(
|
||||
$file,
|
||||
self::replaceJsContent(
|
||||
|
@ -218,7 +212,6 @@ class licenseBootstrap
|
|||
throw new Exception();
|
||||
}
|
||||
if (file_exists($module['root'] . '/LICENSE') && !$overwrite) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -246,7 +239,6 @@ class licenseBootstrap
|
|||
);
|
||||
|
||||
if ($clean != $content && !$overwrite) {
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
|
@ -281,7 +273,6 @@ class licenseBootstrap
|
|||
);
|
||||
|
||||
if ($clean != $content && !$overwrite) {
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
|
@ -305,7 +296,7 @@ class licenseBootstrap
|
|||
protected static function replaceInfo($content, $module, $user)
|
||||
{
|
||||
return str_replace(
|
||||
array(
|
||||
[
|
||||
'%year%',
|
||||
'%module_id%',
|
||||
'%module_name%',
|
||||
|
@ -314,9 +305,9 @@ class licenseBootstrap
|
|||
'%user_cn%',
|
||||
'%user_name%',
|
||||
'%user_email%',
|
||||
'%user_url%'
|
||||
),
|
||||
array(
|
||||
'%user_url%',
|
||||
],
|
||||
[
|
||||
date('Y'),
|
||||
$module['id'],
|
||||
$module['name'],
|
||||
|
@ -325,8 +316,8 @@ class licenseBootstrap
|
|||
$user->getInfo('user_cn'),
|
||||
$user->getinfo('user_name'),
|
||||
$user->getInfo('user_email'),
|
||||
$user->getInfo('user_url')
|
||||
),
|
||||
$user->getInfo('user_url'),
|
||||
],
|
||||
$content
|
||||
);
|
||||
}
|
||||
|
@ -339,12 +330,11 @@ class licenseBootstrap
|
|||
* @param array $res Ignore
|
||||
* @return array List of files
|
||||
*/
|
||||
protected static function getModuleFiles($path, $dir='', $res=array())
|
||||
protected static function getModuleFiles($path, $dir = '', $res = [])
|
||||
{
|
||||
$path = path::real($path);
|
||||
if (!is_dir($path) || !is_readable($path)) {
|
||||
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
if (!$dir) {
|
||||
|
@ -353,18 +343,18 @@ class licenseBootstrap
|
|||
|
||||
$files = files::scandir($path);
|
||||
|
||||
foreach($files AS $file) {
|
||||
foreach ($files as $file) {
|
||||
if (substr($file, 0, 1) == '.') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_dir($path . '/' . $file)) {
|
||||
$res = self::getModuleFiles(
|
||||
$path . '/' . $file, $dir . '/' . $file,
|
||||
$path . '/' . $file,
|
||||
$dir . '/' . $file,
|
||||
$res
|
||||
);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$res[] = empty($dir) ? $file : $dir . '/' . $file;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,15 +10,13 @@
|
|||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
class libLicenseBootstrap
|
||||
{
|
||||
|
||||
public static function modules($core, $modules, $type, $title)
|
||||
public static function modules($modules, $type, $title)
|
||||
{
|
||||
$type = $type == 'themes' ? 'themes' : 'plugins';
|
||||
|
||||
|
@ -48,7 +46,7 @@ class libLicenseBootstrap
|
|||
echo
|
||||
'<tr class="line">' .
|
||||
'<td class="nowrap"><label class="classic">' .
|
||||
form::checkbox(array('modules[' . html::escapeHTML($id) . ']'), 1) .
|
||||
form::checkbox(['modules[' . html::escapeHTML($id) . ']'], 1) .
|
||||
html::escapeHTML($id) .
|
||||
'</label></td>' .
|
||||
'<td class="nowrap count">' .
|
||||
|
@ -67,18 +65,19 @@ class libLicenseBootstrap
|
|||
'</table>' .
|
||||
'<p class="checkboxes-helpers"></p>' .
|
||||
'<p>' .
|
||||
(!empty($_REQUEST['redir']) ?
|
||||
(
|
||||
!empty($_REQUEST['redir']) ?
|
||||
form::hidden(
|
||||
array('redir'),
|
||||
['redir'],
|
||||
html::escapeHTML($_REQUEST['redir'])
|
||||
) : ''
|
||||
) .
|
||||
form::hidden(array('p'), 'licenseBootstrap') .
|
||||
form::hidden(array('type'), $type) .
|
||||
form::hidden(array('action'),'addlicense') .
|
||||
form::hidden(['p'], 'licenseBootstrap') .
|
||||
form::hidden(['type'], $type) .
|
||||
form::hidden(['action'], 'addlicense') .
|
||||
'<input type="submit" name="addlicense" value="' .
|
||||
__('Add license to selected modules') . '" />' .
|
||||
$core->formNonce() . '</p>' .
|
||||
dcCore::app()->formNonce() . '</p>' .
|
||||
'</form>' .
|
||||
|
||||
'</div>';
|
||||
|
@ -86,7 +85,7 @@ class libLicenseBootstrap
|
|||
|
||||
protected static function sort($modules)
|
||||
{
|
||||
$sorter = array();
|
||||
$sorter = [];
|
||||
foreach ($modules as $id => $module) {
|
||||
$sorter[$id] = $id;
|
||||
}
|
||||
|
|
51
index.php
51
index.php
|
@ -10,7 +10,6 @@
|
|||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
return null;
|
||||
}
|
||||
|
@ -19,37 +18,33 @@ dcPage::checkSuper();
|
|||
|
||||
# Queries
|
||||
$p_url = 'plugin.php?p=licenseBootstrap';
|
||||
$action = isset($_POST['action']) ? $_POST['action'] : '';
|
||||
$type = isset($_POST['type']) && in_array($_POST['type'], array('plugins', 'themes')) ? $_POST['type'] : '';
|
||||
$action = $_POST['action'] ?? '';
|
||||
$type = isset($_POST['type']) && in_array($_POST['type'], ['plugins', 'themes']) ? $_POST['type'] : '';
|
||||
|
||||
# Settings
|
||||
$core->blog->settings->addNamespace('licenseBootstrap');
|
||||
$s = $core->blog->settings->licenseBootstrap;
|
||||
dcCore::app()->blog->settings->addNamespace('licenseBootstrap');
|
||||
$s = dcCore::app()->blog->settings->licenseBootstrap;
|
||||
|
||||
# Modules
|
||||
if (!isset($core->themes)) {
|
||||
$core->themes = new dcThemes($core);
|
||||
$core->themes->loadModules($core->blog->themes_path, null);
|
||||
if (!isset(dcCore::app()->themes)) {
|
||||
dcCore::app()->themes = new dcThemes();
|
||||
dcCore::app()->themes->loadModules(dcCore::app()->blog->themes_path, null);
|
||||
}
|
||||
$themes = $core->themes;
|
||||
$plugins = $core->plugins;
|
||||
$themes = dcCore::app()->themes;
|
||||
$plugins = dcCore::app()->plugins;
|
||||
|
||||
# Rights
|
||||
$is_editable =
|
||||
!empty($type)
|
||||
$is_editable = !empty($type)
|
||||
&& !empty($_POST['modules'])
|
||||
&& is_array($_POST['modules']);
|
||||
|
||||
# Actions
|
||||
try
|
||||
{
|
||||
try {
|
||||
# Add license to modules
|
||||
if ($action == 'addlicense' && $is_editable) {
|
||||
|
||||
$modules = array_keys($_POST['modules']);
|
||||
|
||||
foreach ($modules as $id) {
|
||||
|
||||
if (!${$type}->moduleExists($id)) {
|
||||
throw new Exception('No such module');
|
||||
}
|
||||
|
@ -58,19 +53,19 @@ try
|
|||
$module['id'] = $id;
|
||||
$module['type'] = $type == 'themes' ? 'theme' : 'plugin';
|
||||
|
||||
licenseBootstrap::addLicense($core, $module);
|
||||
licenseBootstrap::addLicense($module);
|
||||
}
|
||||
|
||||
dcPage::addSuccessNotice(
|
||||
dcAdminNotices::addSuccessNotice(
|
||||
__('License successfully added.')
|
||||
);
|
||||
http::redirect(empty($_POST['redir']) ?
|
||||
$p_url : $_POST['redir']
|
||||
http::redirect(
|
||||
empty($_POST['redir']) ?
|
||||
dcCore::app()->admin->getPageURL() : $_POST['redir']
|
||||
);
|
||||
}
|
||||
}
|
||||
catch(Exception $e) {
|
||||
$core->error->add($e->getMessage());
|
||||
} catch(Exception $e) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
|
||||
# Display
|
||||
|
@ -80,27 +75,25 @@ dcPage::jsPageTabs() .
|
|||
dcPage::jsLoad('index.php?pf=licenseBootstrap/js/licensebootstrap.js') .
|
||||
|
||||
# --BEHAVIOR-- licenseBootstrapAdminHeader
|
||||
$core->callBehavior('licenseBootstrapAdminHeader', $core) .
|
||||
dcCore::app()->callBehavior('licenseBootstrapAdminHeader') .
|
||||
|
||||
'</head><body>' .
|
||||
|
||||
dcPage::breadcrumb(
|
||||
array(
|
||||
[
|
||||
__('Plugins') => '',
|
||||
__('License bootstrap') => ''
|
||||
)
|
||||
__('License bootstrap') => '',
|
||||
]
|
||||
) .
|
||||
dcPage::notices();
|
||||
|
||||
libLicenseBootstrap::modules(
|
||||
$core,
|
||||
$plugins->getModules(),
|
||||
'plugins',
|
||||
__('Installed plugins')
|
||||
);
|
||||
|
||||
libLicenseBootstrap::modules(
|
||||
$core,
|
||||
$themes->getModules(),
|
||||
'themes',
|
||||
__('Installed themes')
|
||||
|
|
|
@ -1,48 +0,0 @@
|
|||
<?php
|
||||
// Language: Français
|
||||
// Module: licenseBootstrap - 2013.10.25
|
||||
// Date: 2013-10-28 10:27:46
|
||||
// Translated with dcTranslater - 2013.05.11
|
||||
|
||||
#_config.php:56
|
||||
$GLOBALS['__l10n']['Configuration has been successfully updated.'] = 'La configuration a été mise à jour avec succés.';
|
||||
|
||||
#_config.php:71
|
||||
#_config.php:124
|
||||
$GLOBALS['__l10n']['Files'] = 'Fichiers';
|
||||
|
||||
#_config.php:75
|
||||
$GLOBALS['__l10n']['Overwrite existing licenses'] = 'Écraser les licences existantes';
|
||||
|
||||
#_config.php:80
|
||||
$GLOBALS['__l10n']['Add full LICENSE file to module root'] = 'Ajouter le fichier de licence complet à la racine du module';
|
||||
|
||||
#_config.php:85
|
||||
$GLOBALS['__l10n']['Add license block to PHP files'] = 'Ajouter le bloc de licence aux ficheirs PHP';
|
||||
|
||||
#_config.php:90
|
||||
$GLOBALS['__l10n']['Add license block to JS files'] = 'Ajouter le bloc de licence aux ficheirs JS';
|
||||
|
||||
#_config.php:95
|
||||
$GLOBALS['__l10n']['Do not add license block to files from locales folder'] = 'Ne pas ajouter la licence aux fichiers du dossier locales';
|
||||
|
||||
#_config.php:101
|
||||
$GLOBALS['__l10n']['Licenses'] = 'Licences';
|
||||
|
||||
#_config.php:114
|
||||
$GLOBALS['__l10n']['License %s:'] = 'Licence %s :';
|
||||
|
||||
#inc/lib.license.bootstrap.php:40
|
||||
$GLOBALS['__l10n']['Id'] = 'Id';
|
||||
|
||||
#inc/lib.license.bootstrap.php:43
|
||||
$GLOBALS['__l10n']['Root'] = 'Racine';
|
||||
|
||||
#inc/lib.license.bootstrap.php:79
|
||||
$GLOBALS['__l10n']['Add license to selected modules'] = 'Ajouter la licence aux modules selectionner';
|
||||
|
||||
#index.php:67
|
||||
$GLOBALS['__l10n']['License successfully added.'] = 'Licence ajouter avec succès';
|
||||
|
||||
#index.php:119
|
||||
$GLOBALS['__l10n']['Configuration'] = 'Configuration';
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of licenseBootstrap, a plugin for Dotclear 2.
|
||||
|
@ -12,10 +13,9 @@
|
|||
# -- END LICENSE BLOCK ------------------------------------
|
||||
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!empty($_REQUEST['module']) && $_REQUEST['module'] == 'licenseBootstrap') {
|
||||
$__resources['help']['core_plugins_conf'] = dirname(__FILE__).'/help/help.html';
|
||||
dcCore::app()->resources['help']['core_plugins_conf'] = __DIR__ . '/help/help.html';
|
||||
}
|
Loading…
Reference in New Issue