moe to Franck style
parent
5f5fdfcb01
commit
836f6eaf88
|
@ -1,33 +1,29 @@
|
||||||
|
licenseBootstrap 2021.08.17
|
||||||
|
* Move to Franck style
|
||||||
|
|
||||||
licenseBootstrap 2013.12.01
|
licenseBootstrap 2013.12.01
|
||||||
===========================================================
|
|
||||||
* Fix install
|
* Fix install
|
||||||
* Fix user info
|
* Fix user info
|
||||||
|
|
||||||
licenseBootstrap 2013.10.29
|
licenseBootstrap 2013.10.29
|
||||||
===========================================================
|
|
||||||
* Fix full license bug
|
* Fix full license bug
|
||||||
* Fix french help and support links
|
* Fix french help and support links
|
||||||
|
|
||||||
licenseBootstrap 2013.10.28
|
licenseBootstrap 2013.10.28
|
||||||
===========================================================
|
|
||||||
* Switched to DC 2.6
|
* Switched to DC 2.6
|
||||||
* New icon
|
* New icon
|
||||||
* Add dashboard icon
|
* Add dashboard icon
|
||||||
* Clean up code and (again) lighter admin interface
|
* Clean up code and (again) lighter admin interface
|
||||||
|
|
||||||
licenseBootstrap 2013.05.11
|
licenseBootstrap 2013.05.11
|
||||||
===========================================================
|
|
||||||
* Fixed page title and messages and contents
|
* Fixed page title and messages and contents
|
||||||
|
|
||||||
licenseBootstrap 0.3 - 2010-06-05
|
licenseBootstrap 0.3 - 2010-06-05
|
||||||
===========================================================
|
|
||||||
* Switched to DC 2.2
|
* Switched to DC 2.2
|
||||||
* Changed admin interface (easy, light, fast)
|
* Changed admin interface (easy, light, fast)
|
||||||
|
|
||||||
licenseBootstrap 0.2 - 2009-11-09
|
licenseBootstrap 0.2 - 2009-11-09
|
||||||
===========================================================
|
|
||||||
* Changed lots of things
|
* Changed lots of things
|
||||||
|
|
||||||
licenseBootstrap 0.1 - 2009-10-09
|
licenseBootstrap 0.1 - 2009-10-09
|
||||||
===========================================================
|
|
||||||
* First lab release
|
* First lab release
|
|
@ -25,3 +25,9 @@ go to ''configure plugin'', fill in form.
|
||||||
|
|
||||||
Once it's done you can manage your modules license from menu
|
Once it's done you can manage your modules license from menu
|
||||||
''License bootstrap'' on sidebar or you can add dashboard icon.
|
''License bootstrap'' on sidebar or you can add dashboard icon.
|
||||||
|
|
||||||
|
## MORE
|
||||||
|
|
||||||
|
* License : GNU GPL v2
|
||||||
|
* Source & contribution : [GitHub Page](https://github.com/licenseBootstrap)
|
||||||
|
* Packages & details: [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/licenseBootstrap)
|
81
_admin.php
81
_admin.php
|
@ -13,59 +13,56 @@
|
||||||
# -- END LICENSE BLOCK ------------------------------------
|
# -- END LICENSE BLOCK ------------------------------------
|
||||||
|
|
||||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||||
|
return null;
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$core->blog->settings->addNamespace('licenseBootstrap');
|
$core->blog->settings->addNamespace('licenseBootstrap');
|
||||||
|
|
||||||
$core->addBehavior(
|
$core->addBehavior('adminDashboardFavorites', [
|
||||||
'adminDashboardFavorites',
|
'licenseBootstrapBehaviors', 'adminDashboardFavorites'
|
||||||
array('licenseBootstrapBehaviors', 'adminDashboardFavorites')
|
]);
|
||||||
);
|
|
||||||
|
|
||||||
$core->addBehavior(
|
$core->addBehavior('packmanBeforeCreatePackage', [
|
||||||
'packmanBeforeCreatePackage',
|
'licenseBootstrapBehaviors', 'packmanBeforeCreatePackage'
|
||||||
array('licenseBootstrapBehaviors', 'packmanBeforeCreatePackage')
|
]);
|
||||||
);
|
|
||||||
|
|
||||||
$_menu['Plugins']->addItem(
|
$_menu['Plugins']->addItem(
|
||||||
__('License bootstrap'),
|
__('License bootstrap'),
|
||||||
'plugin.php?p=licenseBootstrap',
|
'plugin.php?p=licenseBootstrap',
|
||||||
'index.php?pf=licenseBootstrap/icon.png',
|
'index.php?pf=licenseBootstrap/icon.png',
|
||||||
preg_match(
|
preg_match(
|
||||||
'/plugin.php\?p=licenseBootstrap(&.*)?$/',
|
'/plugin.php\?p=licenseBootstrap(&.*)?$/',
|
||||||
$_SERVER['REQUEST_URI']
|
$_SERVER['REQUEST_URI']
|
||||||
),
|
),
|
||||||
$core->auth->isSuperAdmin()
|
$core->auth->isSuperAdmin()
|
||||||
);
|
);
|
||||||
|
|
||||||
class licenseBootstrapBehaviors
|
class licenseBootstrapBehaviors
|
||||||
{
|
{
|
||||||
public static function adminDashboardFavorites($core, $favs)
|
public static function adminDashboardFavorites($core, $favs)
|
||||||
{
|
{
|
||||||
$favs->register('licenseBootstrap', array(
|
$favs->register('licenseBootstrap', array(
|
||||||
'title' => __('License bootstrap'),
|
'title' => __('License bootstrap'),
|
||||||
'url' => 'plugin.php?p=licenseBootstrap',
|
'url' => 'plugin.php?p=licenseBootstrap',
|
||||||
'small-icon' => 'index.php?pf=licenseBootstrap/icon.png',
|
'small-icon' => 'index.php?pf=licenseBootstrap/icon.png',
|
||||||
'large-icon' => 'index.php?pf=licenseBootstrap/icon-big.png',
|
'large-icon' => 'index.php?pf=licenseBootstrap/icon-big.png',
|
||||||
'permissions' => $core->auth->isSuperAdmin(),
|
'permissions' => $core->auth->isSuperAdmin(),
|
||||||
'active_cb' => array(
|
'active_cb' => array(
|
||||||
'licenseBootstrapBehaviors',
|
'licenseBootstrapBehaviors',
|
||||||
'adminDashboardFavoritesActive'
|
'adminDashboardFavoritesActive'
|
||||||
)
|
)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function adminDashboardFavoritesActive($request, $params)
|
public static function adminDashboardFavoritesActive($request, $params)
|
||||||
{
|
{
|
||||||
return $request == 'plugin.php'
|
return $request == 'plugin.php'
|
||||||
&& isset($params['p'])
|
&& isset($params['p'])
|
||||||
&& $params['p'] == 'licenseBootstrap';
|
&& $params['p'] == 'licenseBootstrap';
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function packmanBeforeCreatePackage($core, $module, $a, $b, $c, $d)
|
public static function packmanBeforeCreatePackage($core, $module, $a, $b, $c, $d)
|
||||||
{
|
{
|
||||||
licenseBootstrap::addLicense($core, $module);
|
licenseBootstrap::addLicense($core, $module);
|
||||||
}
|
}
|
||||||
}
|
}
|
133
_config.php
133
_config.php
|
@ -13,114 +13,113 @@
|
||||||
# -- END LICENSE BLOCK ------------------------------------
|
# -- END LICENSE BLOCK ------------------------------------
|
||||||
|
|
||||||
if (!defined('DC_CONTEXT_MODULE')) {
|
if (!defined('DC_CONTEXT_MODULE')) {
|
||||||
|
return null;
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$redir = empty($_REQUEST['redir']) ?
|
$redir = empty($_REQUEST['redir']) ?
|
||||||
$list->getURL().'#plugins' : $_REQUEST['redir'];
|
$list->getURL() . '#plugins' : $_REQUEST['redir'];
|
||||||
|
|
||||||
# -- Get settings --
|
# -- Get settings --
|
||||||
$core->blog->settings->addNamespace('licenseBootstrap');
|
$core->blog->settings->addNamespace('licenseBootstrap');
|
||||||
$s = $core->blog->settings->licenseBootstrap;
|
$s = $core->blog->settings->licenseBootstrap;
|
||||||
|
|
||||||
$lb_overwrite = (boolean) $s->overwrite;
|
$lb_overwrite = (boolean) $s->overwrite;
|
||||||
$lb_write_full = (boolean) $s->write_full;
|
$lb_write_full = (boolean) $s->write_full;
|
||||||
$lb_write_php = (boolean) $s->write_php;
|
$lb_write_php = (boolean) $s->write_php;
|
||||||
$lb_write_js = (boolean) $s->write_js;
|
$lb_write_js = (boolean) $s->write_js;
|
||||||
$lb_exclude_locales = (boolean) $s->exclude_locales;
|
$lb_exclude_locales = (boolean) $s->exclude_locales;
|
||||||
$lb_license_name = licenseBootstrap::getName($s->license_name);
|
$lb_license_name = licenseBootstrap::getName($s->license_name);
|
||||||
$lb_license_head = licenseBootstrap::gethead($s->license_name, licenseBootstrap::decode($s->license_head));
|
$lb_license_head = licenseBootstrap::gethead($s->license_name, licenseBootstrap::decode($s->license_head));
|
||||||
|
|
||||||
# -- Set settings --
|
# -- Set settings --
|
||||||
if (!empty($_POST['save'])) {
|
if (!empty($_POST['save'])) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$lb_overwrite = !empty($_POST['lb_overwrite']);
|
$lb_overwrite = !empty($_POST['lb_overwrite']);
|
||||||
$lb_write_full = !empty($_POST['lb_write_full']);
|
$lb_write_full = !empty($_POST['lb_write_full']);
|
||||||
$lb_write_php = !empty($_POST['lb_write_php']);
|
$lb_write_php = !empty($_POST['lb_write_php']);
|
||||||
$lb_write_js = !empty($_POST['lb_write_js']);
|
$lb_write_js = !empty($_POST['lb_write_js']);
|
||||||
$lb_exclude_locales = !empty($_POST['lb_exclude_locales']);
|
$lb_exclude_locales = !empty($_POST['lb_exclude_locales']);
|
||||||
$lb_license_name = $_POST['lb_license_name'];
|
$lb_license_name = $_POST['lb_license_name'];
|
||||||
$lb_license_head = licenseBootstrap::gethead($lb_license_name, !empty($_POST['lb_license_head_'.$lb_license_name]) ? $_POST['lb_license_head_'.$lb_license_name] : '');
|
$lb_license_head = licenseBootstrap::gethead($lb_license_name, !empty($_POST['lb_license_head_' . $lb_license_name]) ? $_POST['lb_license_head_' . $lb_license_name] : '');
|
||||||
|
|
||||||
$s->put('overwrite', $lb_overwrite);
|
$s->put('overwrite', $lb_overwrite);
|
||||||
$s->put('write_full', $lb_write_full);
|
$s->put('write_full', $lb_write_full);
|
||||||
$s->put('write_php', $lb_write_php);
|
$s->put('write_php', $lb_write_php);
|
||||||
$s->put('write_js', $lb_write_js);
|
$s->put('write_js', $lb_write_js);
|
||||||
$s->put('exclude_locales', $lb_exclude_locales);
|
$s->put('exclude_locales', $lb_exclude_locales);
|
||||||
$s->put('license_name', licenseBootstrap::getName($lb_license_name));
|
$s->put('license_name', licenseBootstrap::getName($lb_license_name));
|
||||||
$s->put('license_head', licenseBootstrap::encode($lb_license_head));
|
$s->put('license_head', licenseBootstrap::encode($lb_license_head));
|
||||||
|
|
||||||
dcPage::addSuccessNotice(
|
dcPage::addSuccessNotice(
|
||||||
__('Configuration has been successfully updated.')
|
__('Configuration has been successfully updated.')
|
||||||
);
|
);
|
||||||
http::redirect(
|
http::redirect(
|
||||||
$list->getURL('module=licenseBootstrap&conf=1&redir='.
|
$list->getURL('module=licenseBootstrap&conf=1&redir='.
|
||||||
$list->getRedir())
|
$list->getRedir())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
catch (Exception $e) {
|
catch (Exception $e) {
|
||||||
$core->error->add($e->getMessage());
|
$core->error->add($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# -- Display form --
|
# -- Display form --
|
||||||
echo '
|
echo '
|
||||||
<div class="fieldset">
|
<div class="fieldset">
|
||||||
<h4>'.__('Files').'</h4>
|
<h4>' . __('Files') . '</h4>
|
||||||
|
|
||||||
<p><label class="classic" for="lb_overwrite">'.
|
<p><label class="classic" for="lb_overwrite">' .
|
||||||
form::checkbox('lb_overwrite', 1, $lb_overwrite).' '.
|
form::checkbox('lb_overwrite', 1, $lb_overwrite) . ' ' .
|
||||||
__('Overwrite existing licenses').
|
__('Overwrite existing licenses') .
|
||||||
'</label></p>
|
'</label></p>
|
||||||
|
|
||||||
<p><label class="classic" for="lb_write_full">'.
|
<p><label class="classic" for="lb_write_full">' .
|
||||||
form::checkbox('lb_write_full', 1, $lb_write_full).' '.
|
form::checkbox('lb_write_full', 1, $lb_write_full) .' ' .
|
||||||
__('Add full LICENSE file to module root').
|
__('Add full LICENSE file to module root') .
|
||||||
'</label></p>
|
'</label></p>
|
||||||
|
|
||||||
<p><label class="classic" for="lb_write_php">'.
|
<p><label class="classic" for="lb_write_php">' .
|
||||||
form::checkbox('lb_write_php', 1, $lb_write_php).' '.
|
form::checkbox('lb_write_php', 1, $lb_write_php) . ' ' .
|
||||||
__('Add license block to PHP files').
|
__('Add license block to PHP files') .
|
||||||
'</label></p>
|
'</label></p>
|
||||||
|
|
||||||
<p><label class="classic" for="lb_write_js">'.
|
<p><label class="classic" for="lb_write_js">' .
|
||||||
form::checkbox('lb_write_js', 1, $lb_write_js).' '.
|
form::checkbox('lb_write_js', 1, $lb_write_js) . ' ' .
|
||||||
__('Add license block to JS files').
|
__('Add license block to JS files') .
|
||||||
'</label></p>
|
'</label></p>
|
||||||
|
|
||||||
<p><label class="classic" for="lb_exclude_locales">'.
|
<p><label class="classic" for="lb_exclude_locales">' .
|
||||||
form::checkbox('lb_exclude_locales', 1, $lb_exclude_locales).' '.
|
form::checkbox('lb_exclude_locales', 1, $lb_exclude_locales) . ' ' .
|
||||||
__('Do not add license block to files from locales folder').
|
__('Do not add license block to files from locales folder') .
|
||||||
'</label></p>
|
'</label></p>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="fieldset">
|
<div class="fieldset">
|
||||||
<h4>'.__('Licenses').'</h4>';
|
<h4>' . __('Licenses') . '</h4>';
|
||||||
|
|
||||||
foreach(licenseBootstrap::getLicenses() as $name) {
|
foreach(licenseBootstrap::getLicenses() as $name) {
|
||||||
|
|
||||||
$check = false;
|
$check = false;
|
||||||
$head = licenseBootstrap::getHead($name);
|
$head = licenseBootstrap::getHead($name);
|
||||||
if ($name == $lb_license_name) {
|
if ($name == $lb_license_name) {
|
||||||
$check = true;
|
$check = true;
|
||||||
$head = licenseBootstrap::getHead($name, $lb_license_head);
|
$head = licenseBootstrap::getHead($name, $lb_license_head);
|
||||||
}
|
}
|
||||||
echo '
|
echo '
|
||||||
<p><label class="classic" for="license_'.$name.'">'.
|
<p><label class="classic" for="license_' . $name . '">' .
|
||||||
form::radio(array('lb_license_name', 'license_'.$name), $name, $check).' '.
|
form::radio(array('lb_license_name', 'license_' . $name), $name, $check) . ' ' .
|
||||||
sprintf(__('License %s:'),$name).'</label></p>
|
sprintf(__('License %s:'), $name) . '</label></p>
|
||||||
<p class="area">'.
|
<p class="area">' .
|
||||||
form::textarea('lb_license_head_'.$name, 50, 10, html::escapeHTML($head)).'
|
form::textarea('lb_license_head_' . $name, 50, 10, html::escapeHTML($head)) . '
|
||||||
</p>';
|
</p>';
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="fieldset">
|
<div class="fieldset">
|
||||||
<h4>'.__('Files').'</h4>
|
<h4>' . __('Files') . '</h4>
|
||||||
|
|
||||||
</div>';
|
</div>';
|
30
_define.php
30
_define.php
|
@ -13,25 +13,19 @@
|
||||||
# -- END LICENSE BLOCK ------------------------------------
|
# -- END LICENSE BLOCK ------------------------------------
|
||||||
|
|
||||||
if (!defined('DC_RC_PATH')) {
|
if (!defined('DC_RC_PATH')) {
|
||||||
|
return null;
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->registerModule(
|
$this->registerModule(
|
||||||
/* Name */
|
'License bootstrap', // Name
|
||||||
"License bootstrap",
|
'Add license to your plugins and themes', // Description
|
||||||
/* Description*/
|
'Jean-Christian Denis', // Author
|
||||||
"Add license to your plugins and themes",
|
'2021.08.17', // Version
|
||||||
/* Author */
|
[
|
||||||
"Jean-Christian Denis",
|
'permissions' => null,
|
||||||
/* Version */
|
'type' => 'plugin',
|
||||||
'2013.12.01',
|
'dc_min' => '2.19',
|
||||||
/* Properties */
|
'support' => 'https://github.com/JcDenis/licenseBootstrap',
|
||||||
array(
|
'details' => 'https://plugins.dotaddict.org/dc2/details/licenseBootstrap'
|
||||||
'permissions' => null,
|
]
|
||||||
'type' => 'plugin',
|
|
||||||
'dc_min' => '2.6',
|
|
||||||
'support' => 'http://jcd.lv/q=licenseBootstrap',
|
|
||||||
'details' => 'http://plugins.dotaddict.org/dc2/details/licenseBootstrap'
|
|
||||||
)
|
|
||||||
);
|
);
|
163
_install.php
163
_install.php
|
@ -13,8 +13,7 @@
|
||||||
# -- END LICENSE BLOCK ------------------------------------
|
# -- END LICENSE BLOCK ------------------------------------
|
||||||
|
|
||||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||||
|
return null;
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# -- Module specs --
|
# -- Module specs --
|
||||||
|
@ -22,98 +21,98 @@ if (!defined('DC_CONTEXT_ADMIN')) {
|
||||||
$dc_min = '2.6';
|
$dc_min = '2.6';
|
||||||
$mod_id = 'licenseBootstrap';
|
$mod_id = 'licenseBootstrap';
|
||||||
$mod_conf = array(
|
$mod_conf = array(
|
||||||
array(
|
array(
|
||||||
'overwrite',
|
'overwrite',
|
||||||
'Overwrite existing licence',
|
'Overwrite existing licence',
|
||||||
false,
|
false,
|
||||||
'boolean'
|
'boolean'
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'write_full',
|
'write_full',
|
||||||
'Add complete licence file',
|
'Add complete licence file',
|
||||||
true,
|
true,
|
||||||
'boolean'
|
'boolean'
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'write_php',
|
'write_php',
|
||||||
'Write license into php files',
|
'Write license into php files',
|
||||||
true,
|
true,
|
||||||
'boolean'
|
'boolean'
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'write_js',
|
'write_js',
|
||||||
'Write license into js files',
|
'Write license into js files',
|
||||||
false,
|
false,
|
||||||
'boolean'
|
'boolean'
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'exclude_locales',
|
'exclude_locales',
|
||||||
'Exclude locales from license',
|
'Exclude locales from license',
|
||||||
true,
|
true,
|
||||||
'boolean'
|
'boolean'
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'license_name',
|
'license_name',
|
||||||
'License short name',
|
'License short name',
|
||||||
'gpl2',
|
'gpl2',
|
||||||
'string'
|
'string'
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'license_head',
|
'license_head',
|
||||||
'File header licence text',
|
'File header licence text',
|
||||||
licenseBootstrap::encode(
|
licenseBootstrap::encode(
|
||||||
licenseBootstrap::getHead('gpl2')
|
licenseBootstrap::getHead('gpl2')
|
||||||
),
|
),
|
||||||
'string'
|
'string'
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'behavior_packman',
|
'behavior_packman',
|
||||||
'Add LicenceBootstrap to plugin pacKman',
|
'Add LicenceBootstrap to plugin pacKman',
|
||||||
false,
|
false,
|
||||||
'boolean'
|
'boolean'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
# -- Nothing to change below --
|
# -- Nothing to change below --
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
# Check module version
|
# Check module version
|
||||||
if (version_compare(
|
if (version_compare(
|
||||||
$core->getVersion($mod_id),
|
$core->getVersion($mod_id),
|
||||||
$core->plugins->moduleInfo($mod_id, 'version'),
|
$core->plugins->moduleInfo($mod_id, 'version'),
|
||||||
'>='
|
'>='
|
||||||
)) {
|
)) {
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check Dotclear version
|
# Check Dotclear version
|
||||||
if (!method_exists('dcUtils', 'versionsCompare')
|
if (!method_exists('dcUtils', 'versionsCompare')
|
||||||
|| dcUtils::versionsCompare(DC_VERSION, $dc_min, '<', false)) {
|
|| dcUtils::versionsCompare(DC_VERSION, $dc_min, '<', false)) {
|
||||||
throw new Exception(sprintf(
|
throw new Exception(sprintf(
|
||||||
'%s requires Dotclear %s', $mod_id, $dc_min
|
'%s requires Dotclear %s', $mod_id, $dc_min
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
# Set module settings
|
# Set module settings
|
||||||
$core->blog->settings->addNamespace($mod_id);
|
$core->blog->settings->addNamespace($mod_id);
|
||||||
foreach($mod_conf as $v) {
|
foreach($mod_conf as $v) {
|
||||||
$core->blog->settings->{$mod_id}->put(
|
$core->blog->settings->{$mod_id}->put(
|
||||||
$v[0], $v[2], $v[3], $v[1], false, true
|
$v[0], $v[2], $v[3], $v[1], false, true
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
# Set module version
|
# Set module version
|
||||||
$core->setVersion(
|
$core->setVersion(
|
||||||
$mod_id,
|
$mod_id,
|
||||||
$core->plugins->moduleInfo($mod_id, 'version')
|
$core->plugins->moduleInfo($mod_id, 'version')
|
||||||
);
|
);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch (Exception $e) {
|
catch (Exception $e) {
|
||||||
$core->error->add($e->getMessage());
|
$core->error->add($e->getMessage());
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
|
@ -13,11 +13,10 @@
|
||||||
# -- END LICENSE BLOCK ------------------------------------
|
# -- END LICENSE BLOCK ------------------------------------
|
||||||
|
|
||||||
if (!defined('DC_RC_PATH')) {
|
if (!defined('DC_RC_PATH')) {
|
||||||
|
return null;
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$d = dirname(__FILE__).'/inc/';
|
$d = dirname(__FILE__).'/inc/';
|
||||||
|
|
||||||
$__autoload['licenseBootstrap'] = $d.'class.license.bootstrap.php';
|
$__autoload['licenseBootstrap'] = $d.'class.license.bootstrap.php';
|
||||||
$__autoload['libLicenseBootstrap'] = $d.'lib.license.bootstrap.php';
|
$__autoload['libLicenseBootstrap'] = $d.'lib.license.bootstrap.php';
|
|
@ -13,36 +13,35 @@
|
||||||
# -- END LICENSE BLOCK ------------------------------------
|
# -- END LICENSE BLOCK ------------------------------------
|
||||||
|
|
||||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||||
|
return null;
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$mod_id = 'pacKman';
|
$mod_id = 'pacKman';
|
||||||
|
|
||||||
$this->addUserAction(
|
$this->addUserAction(
|
||||||
/* type */ 'settings',
|
/* type */ 'settings',
|
||||||
/* action */ 'delete_all',
|
/* action */ 'delete_all',
|
||||||
/* ns */ $mod_id,
|
/* ns */ $mod_id,
|
||||||
/* desc */ __('delete all settings')
|
/* desc */ __('delete all settings')
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->addUserAction(
|
$this->addUserAction(
|
||||||
/* type */ 'plugins',
|
/* type */ 'plugins',
|
||||||
/* action */ 'delete',
|
/* action */ 'delete',
|
||||||
/* ns */ $mod_id,
|
/* ns */ $mod_id,
|
||||||
/* desc */ __('delete plugin files')
|
/* desc */ __('delete plugin files')
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->addDirectAction(
|
$this->addDirectAction(
|
||||||
/* type */ 'settings',
|
/* type */ 'settings',
|
||||||
/* action */ 'delete_all',
|
/* action */ 'delete_all',
|
||||||
/* ns */ $mod_id,
|
/* ns */ $mod_id,
|
||||||
/* desc */ sprintf(__('delete all %s settings'), $mod_id)
|
/* desc */ sprintf(__('delete all %s settings'), $mod_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->addDirectAction(
|
$this->addDirectAction(
|
||||||
/* type */ 'plugins',
|
/* type */ 'plugins',
|
||||||
/* action */ 'delete',
|
/* action */ 'delete',
|
||||||
/* ns */ $mod_id,
|
/* ns */ $mod_id,
|
||||||
/* desc */ sprintf(__('delete %s plugin files'), $mod_id)
|
/* desc */ sprintf(__('delete %s plugin files'), $mod_id)
|
||||||
);
|
);
|
|
@ -13,374 +13,373 @@
|
||||||
# -- END LICENSE BLOCK ------------------------------------
|
# -- END LICENSE BLOCK ------------------------------------
|
||||||
|
|
||||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||||
|
return null;
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class licenseBootstrap
|
class licenseBootstrap
|
||||||
{
|
{
|
||||||
protected static $licenses = array();
|
protected static $licenses = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add license to a module.
|
* Add license to a module.
|
||||||
*
|
*
|
||||||
* Note that you must check if module exists
|
* Note that you must check if module exists
|
||||||
* before calling this method.
|
* before calling this method.
|
||||||
*
|
*
|
||||||
* @param object $core dcCore instance
|
* @param object $core dcCore instance
|
||||||
* @param array $module Module info
|
* @param array $module Module info
|
||||||
*/
|
*/
|
||||||
public static function addLicense($core, $module)
|
public static function addLicense($core, $module)
|
||||||
{
|
{
|
||||||
$s = $core->blog->settings->licenseBootstrap;
|
$s = $core->blog->settings->licenseBootstrap;
|
||||||
|
|
||||||
# --BEHAVIOR-- licenseBootstrapBeforeAddLicense
|
# --BEHAVIOR-- licenseBootstrapBeforeAddLicense
|
||||||
$core->callBehavior(
|
$core->callBehavior(
|
||||||
'licenseBootstrapBeforeAddLicense',
|
'licenseBootstrapBeforeAddLicense',
|
||||||
$core,
|
$core,
|
||||||
$module
|
$module
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($s->write_full) {
|
if ($s->write_full) {
|
||||||
licenseBootstrap::writeFullContent(
|
licenseBootstrap::writeFullContent(
|
||||||
$s->license_name,
|
$s->license_name,
|
||||||
$module,
|
$module,
|
||||||
$s->overwrite
|
$s->overwrite
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
licenseBootstrap::writeHeadContent(
|
licenseBootstrap::writeHeadContent(
|
||||||
$s->license_name,
|
$s->license_name,
|
||||||
licenseBootstrap::decode($s->license_head),
|
licenseBootstrap::decode($s->license_head),
|
||||||
$module,
|
$module,
|
||||||
$core->auth,
|
$core->auth,
|
||||||
$s->overwrite,
|
$s->overwrite,
|
||||||
$s->write_php,
|
$s->write_php,
|
||||||
$s->write_js,
|
$s->write_js,
|
||||||
$s->exclude_locales
|
$s->exclude_locales
|
||||||
);
|
);
|
||||||
|
|
||||||
# --BEHAVIOR-- licenseBootstrapAfterAddLicense
|
# --BEHAVIOR-- licenseBootstrapAfterAddLicense
|
||||||
$core->callBehavior(
|
$core->callBehavior(
|
||||||
'licenseBootstrapAfterAddLicense',
|
'licenseBootstrapAfterAddLicense',
|
||||||
$core,
|
$core,
|
||||||
$module
|
$module
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get available licenses.
|
* Get available licenses.
|
||||||
*
|
*
|
||||||
* @return array List of licenses names
|
* @return array List of licenses names
|
||||||
*/
|
*/
|
||||||
public static function getLicenses()
|
public static function getLicenses()
|
||||||
{
|
{
|
||||||
if (empty(licenseBootstrap::$licenses)) {
|
if (empty(licenseBootstrap::$licenses)) {
|
||||||
$file_reg = '/^([a-z0-9]+)\.head\.txt$/';
|
$file_reg = '/^([a-z0-9]+)\.head\.txt$/';
|
||||||
$res = array();
|
$res = array();
|
||||||
foreach (files::scandir(dirname(__FILE__).'/licenses/') as $file) {
|
foreach (files::scandir(dirname(__FILE__) . '/licenses/') as $file) {
|
||||||
if (preg_match($file_reg, $file, $matches)) {
|
if (preg_match($file_reg, $file, $matches)) {
|
||||||
$res[] = $matches[1];
|
$res[] = $matches[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
licenseBootstrap::$licenses = $res;
|
licenseBootstrap::$licenses = $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
return licenseBootstrap::$licenses;
|
return licenseBootstrap::$licenses;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get license name.
|
* Get license name.
|
||||||
*
|
*
|
||||||
* Check requested license name and return existing one.
|
* Check requested license name and return existing one.
|
||||||
*
|
*
|
||||||
* @param string $name License name
|
* @param string $name License name
|
||||||
* @return string License name
|
* @return string License name
|
||||||
*/
|
*/
|
||||||
public static function getName($name='gpl2')
|
public static function getName($name='gpl2')
|
||||||
{
|
{
|
||||||
return in_array($name, self::getLicenses()) ? $name : 'gpl2';
|
return in_array($name, self::getLicenses()) ? $name : 'gpl2';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get license header.
|
* Get license header.
|
||||||
*
|
*
|
||||||
* @param string $name License name
|
* @param string $name License name
|
||||||
* @param string $content Header content
|
* @param string $content Header content
|
||||||
* @return string Header content
|
* @return string Header content
|
||||||
*/
|
*/
|
||||||
public static function getHead($name='gpl2', $content='')
|
public static function getHead($name='gpl2', $content='')
|
||||||
{
|
{
|
||||||
if (!in_array($name, self::getLicenses())) {
|
if (!in_array($name, self::getLicenses())) {
|
||||||
$name = 'gpl2';
|
$name = 'gpl2';
|
||||||
$content = '';
|
$content = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
return empty($content) ?
|
return empty($content) ?
|
||||||
self::getContent($name, 'head') : $content;
|
self::getContent($name, 'head') : $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get full license.
|
* Get full license.
|
||||||
*
|
*
|
||||||
* @param string $name License name
|
* @param string $name License name
|
||||||
* @return string Full license content
|
* @return string Full license content
|
||||||
*/
|
*/
|
||||||
public static function getFull($name='gpl2')
|
public static function getFull($name='gpl2')
|
||||||
{
|
{
|
||||||
return self::getContent($name, 'full');
|
return self::getContent($name, 'full');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get original license content.
|
* Get original license content.
|
||||||
*
|
*
|
||||||
* @param string $name License name
|
* @param string $name License name
|
||||||
* @param string $part License part (head or full)
|
* @param string $part License part (head or full)
|
||||||
* @return string License content
|
* @return string License content
|
||||||
*/
|
*/
|
||||||
public static function getContent($name='gpl2', $part='head')
|
public static function getContent($name='gpl2', $part='head')
|
||||||
{
|
{
|
||||||
if (!in_array($name, self::getLicenses())) {
|
if (!in_array($name, self::getLicenses())) {
|
||||||
$name = 'gpl2';
|
$name = 'gpl2';
|
||||||
}
|
}
|
||||||
if (!in_array($part, array('head', 'full'))) {
|
if (!in_array($part, array('head', 'full'))) {
|
||||||
$part = 'head';
|
$part = 'head';
|
||||||
}
|
}
|
||||||
|
|
||||||
return file_get_contents(
|
return file_get_contents(
|
||||||
dirname(__FILE__).'/licenses/'.$name.'.'.$part.'.txt'
|
dirname(__FILE__) . '/licenses/' . $name . '.' . $part . '.txt'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write license block into module files headers
|
* Write license block into module files headers
|
||||||
*
|
*
|
||||||
* @param string $name License name
|
* @param string $name License name
|
||||||
* @param string $content License block content
|
* @param string $content License block content
|
||||||
* @param array $module Module info
|
* @param array $module Module info
|
||||||
* @param object $user dcAuth instance
|
* @param object $user dcAuth instance
|
||||||
* @param boolean $overwrite Overwrite existing license
|
* @param boolean $overwrite Overwrite existing license
|
||||||
* @param boolean $php Write license in PHP
|
* @param boolean $php Write license in PHP
|
||||||
* @param boolean $js Write license in JS
|
* @param boolean $js Write license in JS
|
||||||
* @param boolean $locales Excludes locales folder
|
* @param boolean $locales Excludes locales folder
|
||||||
*/
|
*/
|
||||||
public static function writeHeadContent($name, $content, $module, $user, $overwrite, $php, $js, $locales)
|
public static function writeHeadContent($name, $content, $module, $user, $overwrite, $php, $js, $locales)
|
||||||
{
|
{
|
||||||
if (!isset($module['root']) || !is_writable($module['root'])) {
|
if (!isset($module['root']) || !is_writable($module['root'])) {
|
||||||
throw new Exception();
|
throw new Exception();
|
||||||
}
|
}
|
||||||
|
|
||||||
$license = self::replaceInfo(
|
$license = self::replaceInfo(
|
||||||
self::getHead($name, $content),
|
self::getHead($name, $content),
|
||||||
$module,
|
$module,
|
||||||
$user
|
$user
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach(self::getModuleFiles($module['root']) as $file) {
|
foreach(self::getModuleFiles($module['root']) as $file) {
|
||||||
|
|
||||||
if ($locales && preg_match('/(\.lang\.php|libs)/', $file)) {
|
if ($locales && preg_match('/(\.lang\.php|libs)/', $file)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$path = $module['root'].'/'.$file;
|
$path = $module['root'] . '/' . $file;
|
||||||
$extension = files::getExtension($file);
|
$extension = files::getExtension($file);
|
||||||
|
|
||||||
if ($php && $extension == 'php') {
|
if ($php && $extension == 'php') {
|
||||||
file_put_contents(
|
file_put_contents(
|
||||||
$file,
|
$file,
|
||||||
self::replacePhpContent(
|
self::replacePhpContent(
|
||||||
file_get_contents($file),
|
file_get_contents($file),
|
||||||
$license,
|
$license,
|
||||||
$overwrite
|
$overwrite
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
elseif ($js && $extension == 'js') {
|
elseif ($js && $extension == 'js') {
|
||||||
file_put_contents(
|
file_put_contents(
|
||||||
$file,
|
$file,
|
||||||
self::replaceJsContent(
|
self::replaceJsContent(
|
||||||
file_get_contents($file),
|
file_get_contents($file),
|
||||||
$license,
|
$license,
|
||||||
$overwrite
|
$overwrite
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write full license file
|
* Write full license file
|
||||||
*
|
*
|
||||||
* @param string $name License name
|
* @param string $name License name
|
||||||
* @param array $module Module info
|
* @param array $module Module info
|
||||||
* @param boolean $overwrite Overwrite existing license
|
* @param boolean $overwrite Overwrite existing license
|
||||||
*/
|
*/
|
||||||
public static function writeFullContent($name, $module, $overwrite)
|
public static function writeFullContent($name, $module, $overwrite)
|
||||||
{
|
{
|
||||||
if (!isset($module['root']) || !is_writable($module['root'])) {
|
if (!isset($module['root']) || !is_writable($module['root'])) {
|
||||||
throw new Exception();
|
throw new Exception();
|
||||||
}
|
}
|
||||||
if (file_exists($module['root'].'/LICENSE') && !$overwrite) {
|
if (file_exists($module['root'] . '/LICENSE') && !$overwrite) {
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
file_put_contents(
|
file_put_contents(
|
||||||
$module['root'].'/LICENSE',
|
$module['root'] . '/LICENSE',
|
||||||
self::getFull($name)
|
self::getFull($name)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replace license block in PHP file
|
* Replace license block in PHP file
|
||||||
*
|
*
|
||||||
* @param string $content File content
|
* @param string $content File content
|
||||||
* @param string $license License content
|
* @param string $license License content
|
||||||
* @param boolean $overwrite Overwrite existing license
|
* @param boolean $overwrite Overwrite existing license
|
||||||
* @return string File content
|
* @return string File content
|
||||||
*/
|
*/
|
||||||
protected static function replacePhpContent($content, $license, $overwrite)
|
protected static function replacePhpContent($content, $license, $overwrite)
|
||||||
{
|
{
|
||||||
$clean = preg_replace(
|
$clean = preg_replace(
|
||||||
'/((# -- BEGIN LICENSE BLOCK ([-]+))(.*?)'.
|
'/((# -- BEGIN LICENSE BLOCK ([-]+))(.*?)' .
|
||||||
'(# -- END LICENSE BLOCK ([-]+))([\n|\r\n]+))/msi',
|
'(# -- END LICENSE BLOCK ([-]+))([\n|\r\n]+))/msi',
|
||||||
'',
|
'',
|
||||||
$content
|
$content
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($clean != $content && !$overwrite) {
|
if ($clean != $content && !$overwrite) {
|
||||||
|
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
return preg_replace(
|
return preg_replace(
|
||||||
'/(\<\?php)/',
|
'/(\<\?php)/',
|
||||||
'<?php'.
|
'<?php' .
|
||||||
"\r\n# -- BEGIN LICENSE BLOCK ----------------------------------\r\n".
|
"\r\n# -- BEGIN LICENSE BLOCK ----------------------------------\r\n" .
|
||||||
"#\r\n".
|
"#\r\n" .
|
||||||
'# '.str_replace("\n", "\n# ", trim($license)).
|
'# ' . str_replace("\n", "\n# ", trim($license)).
|
||||||
"\r\n#".
|
"\r\n#" .
|
||||||
"\r\n# -- END LICENSE BLOCK ------------------------------------\r\n",
|
"\r\n# -- END LICENSE BLOCK ------------------------------------\r\n",
|
||||||
$clean,
|
$clean,
|
||||||
1
|
1
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replace license block in JS files
|
* Replace license block in JS files
|
||||||
*
|
*
|
||||||
* @param string $content File content
|
* @param string $content File content
|
||||||
* @param string $license License content
|
* @param string $license License content
|
||||||
* @param boolean $overwrite Overwrite existing license
|
* @param boolean $overwrite Overwrite existing license
|
||||||
* @return string File content
|
* @return string File content
|
||||||
*/
|
*/
|
||||||
protected static function replaceJsContent($content, $license, $overwrite)
|
protected static function replaceJsContent($content, $license, $overwrite)
|
||||||
{
|
{
|
||||||
$clean = preg_replace(
|
$clean = preg_replace(
|
||||||
'/((\/\* -- BEGIN LICENSE BLOCK ([-]+))(.*?)'.
|
'/((\/\* -- BEGIN LICENSE BLOCK ([-]+))(.*?)' .
|
||||||
'(\* -- END LICENSE BLOCK ([-]+)\*\/)([\n|\r\n]+))/msi',
|
'(\* -- END LICENSE BLOCK ([-]+)\*\/)([\n|\r\n]+))/msi',
|
||||||
'',
|
'',
|
||||||
$content
|
$content
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($clean != $content && !$overwrite) {
|
if ($clean != $content && !$overwrite) {
|
||||||
|
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
"/* -- BEGIN LICENSE BLOCK ----------------------------------\r\n".
|
"/* -- BEGIN LICENSE BLOCK ----------------------------------\r\n" .
|
||||||
" *\r\n".
|
" *\r\n" .
|
||||||
' * '.str_replace("\n", "\n * ", trim($license)).
|
' * ' . str_replace("\n", "\n * ", trim($license)).
|
||||||
"\r\n *".
|
"\r\n *" .
|
||||||
"\r\n * -- END LICENSE BLOCK ------------------------------------*/\r\n\r\n".
|
"\r\n * -- END LICENSE BLOCK ------------------------------------*/\r\n\r\n" .
|
||||||
$clean;
|
$clean;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replace info in license
|
* Replace info in license
|
||||||
*
|
*
|
||||||
* @param string $content License content
|
* @param string $content License content
|
||||||
* @param array $module Module info
|
* @param array $module Module info
|
||||||
* @param array $user User info
|
* @param array $user User info
|
||||||
* @return string License content
|
* @return string License content
|
||||||
*/
|
*/
|
||||||
protected static function replaceInfo($content, $module, $user)
|
protected static function replaceInfo($content, $module, $user)
|
||||||
{
|
{
|
||||||
return str_replace(
|
return str_replace(
|
||||||
array(
|
array(
|
||||||
'%year%',
|
'%year%',
|
||||||
'%module_id%',
|
'%module_id%',
|
||||||
'%module_name%',
|
'%module_name%',
|
||||||
'%module_author%',
|
'%module_author%',
|
||||||
'%module_type%',
|
'%module_type%',
|
||||||
'%user_cn%',
|
'%user_cn%',
|
||||||
'%user_name%',
|
'%user_name%',
|
||||||
'%user_email%',
|
'%user_email%',
|
||||||
'%user_url%'
|
'%user_url%'
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
date('Y'),
|
date('Y'),
|
||||||
$module['id'],
|
$module['id'],
|
||||||
$module['name'],
|
$module['name'],
|
||||||
$module['author'],
|
$module['author'],
|
||||||
$module['type'],
|
$module['type'],
|
||||||
$user->getInfo('user_cn'),
|
$user->getInfo('user_cn'),
|
||||||
$user->getinfo('user_name'),
|
$user->getinfo('user_name'),
|
||||||
$user->getInfo('user_email'),
|
$user->getInfo('user_email'),
|
||||||
$user->getInfo('user_url')
|
$user->getInfo('user_url')
|
||||||
),
|
),
|
||||||
$content
|
$content
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get list of module files
|
* Get list of module files
|
||||||
*
|
*
|
||||||
* @param string $path Path to scan
|
* @param string $path Path to scan
|
||||||
* @param string $dir Ignore
|
* @param string $dir Ignore
|
||||||
* @param array $res Ignore
|
* @param array $res Ignore
|
||||||
* @return array List of files
|
* @return array List of files
|
||||||
*/
|
*/
|
||||||
protected static function getModuleFiles($path, $dir='', $res=array())
|
protected static function getModuleFiles($path, $dir='', $res=array())
|
||||||
{
|
{
|
||||||
$path = path::real($path);
|
$path = path::real($path);
|
||||||
if (!is_dir($path) || !is_readable($path)) {
|
if (!is_dir($path) || !is_readable($path)) {
|
||||||
|
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$dir) {
|
if (!$dir) {
|
||||||
$dir = $path;
|
$dir = $path;
|
||||||
}
|
}
|
||||||
|
|
||||||
$files = files::scandir($path);
|
$files = files::scandir($path);
|
||||||
|
|
||||||
foreach($files AS $file) {
|
foreach($files AS $file) {
|
||||||
if (substr($file, 0, 1) == '.') {
|
if (substr($file, 0, 1) == '.') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_dir($path.'/'.$file)) {
|
if (is_dir($path . '/' . $file)) {
|
||||||
$res = self::getModuleFiles(
|
$res = self::getModuleFiles(
|
||||||
$path.'/'.$file, $dir.'/'.$file,
|
$path . '/' . $file, $dir . '/' . $file,
|
||||||
$res
|
$res
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$res[] = empty($dir) ? $file : $dir.'/'.$file;
|
$res[] = empty($dir) ? $file : $dir . '/' . $file;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function encode($a)
|
public static function encode($a)
|
||||||
{
|
{
|
||||||
return base64_encode(serialize($a));
|
return base64_encode(serialize($a));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function decode($a)
|
public static function decode($a)
|
||||||
{
|
{
|
||||||
return unserialize(base64_decode($a));
|
return unserialize(base64_decode($a));
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -13,87 +13,86 @@
|
||||||
# -- END LICENSE BLOCK ------------------------------------
|
# -- END LICENSE BLOCK ------------------------------------
|
||||||
|
|
||||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||||
|
return null;
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class libLicenseBootstrap
|
class libLicenseBootstrap
|
||||||
{
|
{
|
||||||
|
|
||||||
public static function modules($core, $modules, $type, $title)
|
public static function modules($core, $modules, $type, $title)
|
||||||
{
|
{
|
||||||
$type = $type == 'themes' ? 'themes' : 'plugins';
|
$type = $type == 'themes' ? 'themes' : 'plugins';
|
||||||
|
|
||||||
echo
|
echo
|
||||||
'<div class="multi-part" '.
|
'<div class="multi-part" ' .
|
||||||
'id="packman-'.$type.'" title="'.$title.'">'.
|
'id="packman-' . $type . '" title="' . $title . '">' .
|
||||||
'<h3>'.$title.'</h3>';
|
'<h3>' . $title . '</h3>';
|
||||||
|
|
||||||
if (empty($modules) && !is_array($modules)) {
|
if (empty($modules) && !is_array($modules)) {
|
||||||
echo
|
echo
|
||||||
'<p><strong>'.__('There are no modules.').'</strong></p>'.
|
'<p><strong>' . __('There are no modules.') . '</strong></p>' .
|
||||||
'<div>';
|
'<div>';
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
echo
|
echo
|
||||||
'<form action="plugin.php" method="post">'.
|
'<form action="plugin.php" method="post">' .
|
||||||
'<table class="clear"><tr>'.
|
'<table class="clear"><tr>' .
|
||||||
'<th class="nowrap">'.__('Id').'</th>'.
|
'<th class="nowrap">' . __('Id') .'</th>' .
|
||||||
'<th class="nowrap">'.__('Version').'</th>'.
|
'<th class="nowrap">' . __('Version') . '</th>' .
|
||||||
'<th class="nowrap maximal">'.__('Name').'</th>'.
|
'<th class="nowrap maximal">' . __('Name') . '</th>' .
|
||||||
'<th class="nowrap">'.__('Root').'</th>'.
|
'<th class="nowrap">' . __('Root') . '</th>' .
|
||||||
'</tr>';
|
'</tr>';
|
||||||
|
|
||||||
foreach (self::sort($modules) as $id => $module) {
|
foreach (self::sort($modules) as $id => $module) {
|
||||||
echo
|
echo
|
||||||
'<tr class="line">'.
|
'<tr class="line">' .
|
||||||
'<td class="nowrap"><label class="classic">'.
|
'<td class="nowrap"><label class="classic">' .
|
||||||
form::checkbox(array('modules['.html::escapeHTML($id).']'), 1).
|
form::checkbox(array('modules[' . html::escapeHTML($id) . ']'), 1) .
|
||||||
html::escapeHTML($id).
|
html::escapeHTML($id) .
|
||||||
'</label></td>'.
|
'</label></td>'.
|
||||||
'<td class="nowrap count">'.
|
'<td class="nowrap count">' .
|
||||||
html::escapeHTML($module['version']).
|
html::escapeHTML($module['version']) .
|
||||||
'</td>'.
|
'</td>' .
|
||||||
'<td class="nowrap maximal">'.
|
'<td class="nowrap maximal">' .
|
||||||
__(html::escapeHTML($module['name'])).
|
__(html::escapeHTML($module['name'])) .
|
||||||
'</td>'.
|
'</td>' .
|
||||||
'<td class="nowrap">'.
|
'<td class="nowrap">' .
|
||||||
dirname(path::real($module['root'], false)).
|
dirname(path::real($module['root'], false)) .
|
||||||
'</td>'.
|
'</td>' .
|
||||||
'</tr>';
|
'</tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
echo
|
echo
|
||||||
'</table>'.
|
'</table>' .
|
||||||
'<p class="checkboxes-helpers"></p>'.
|
'<p class="checkboxes-helpers"></p>' .
|
||||||
'<p>'.
|
'<p>' .
|
||||||
(!empty($_REQUEST['redir']) ?
|
(!empty($_REQUEST['redir']) ?
|
||||||
form::hidden(
|
form::hidden(
|
||||||
array('redir'),
|
array('redir'),
|
||||||
html::escapeHTML($_REQUEST['redir'])
|
html::escapeHTML($_REQUEST['redir'])
|
||||||
) : ''
|
) : ''
|
||||||
).
|
).
|
||||||
form::hidden(array('p'),'licenseBootstrap').
|
form::hidden(array('p'), 'licenseBootstrap') .
|
||||||
form::hidden(array('type'),$type).
|
form::hidden(array('type'), $type) .
|
||||||
form::hidden(array('action'),'addlicense').
|
form::hidden(array('action'),'addlicense') .
|
||||||
'<input type="submit" name="addlicense" value="'.
|
'<input type="submit" name="addlicense" value="' .
|
||||||
__('Add license to selected modules').'" />'.
|
__('Add license to selected modules') . '" />' .
|
||||||
$core->formNonce().'</p>'.
|
$core->formNonce() . '</p>' .
|
||||||
'</form>'.
|
'</form>' .
|
||||||
|
|
||||||
'</div>';
|
'</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static function sort($modules)
|
protected static function sort($modules)
|
||||||
{
|
{
|
||||||
$sorter = array();
|
$sorter = array();
|
||||||
foreach($modules as $id => $module) {
|
foreach($modules as $id => $module) {
|
||||||
$sorter[$id] = $id;
|
$sorter[$id] = $id;
|
||||||
}
|
}
|
||||||
array_multisort($sorter, SORT_ASC, $modules);
|
array_multisort($sorter, SORT_ASC, $modules);
|
||||||
|
|
||||||
return $modules;
|
return $modules;
|
||||||
}
|
}
|
||||||
}
|
}
|
100
index.php
100
index.php
|
@ -13,8 +13,7 @@
|
||||||
# -- END LICENSE BLOCK ------------------------------------
|
# -- END LICENSE BLOCK ------------------------------------
|
||||||
|
|
||||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||||
|
return null;
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dcPage::checkSuper();
|
dcPage::checkSuper();
|
||||||
|
@ -22,7 +21,7 @@ dcPage::checkSuper();
|
||||||
# Queries
|
# Queries
|
||||||
$p_url = 'plugin.php?p=licenseBootstrap';
|
$p_url = 'plugin.php?p=licenseBootstrap';
|
||||||
$action = isset($_POST['action']) ? $_POST['action'] : '';
|
$action = isset($_POST['action']) ? $_POST['action'] : '';
|
||||||
$type = isset($_POST['type']) && in_array($_POST['type'], array('plugins','themes')) ? $_POST['type'] : '';
|
$type = isset($_POST['type']) && in_array($_POST['type'], array('plugins', 'themes')) ? $_POST['type'] : '';
|
||||||
|
|
||||||
# Settings
|
# Settings
|
||||||
$core->blog->settings->addNamespace('licenseBootstrap');
|
$core->blog->settings->addNamespace('licenseBootstrap');
|
||||||
|
@ -30,92 +29,85 @@ $s = $core->blog->settings->licenseBootstrap;
|
||||||
|
|
||||||
# Modules
|
# Modules
|
||||||
if (!isset($core->themes)) {
|
if (!isset($core->themes)) {
|
||||||
$core->themes = new dcThemes($core);
|
$core->themes = new dcThemes($core);
|
||||||
$core->themes->loadModules($core->blog->themes_path,null);
|
$core->themes->loadModules($core->blog->themes_path, null);
|
||||||
}
|
}
|
||||||
$themes = $core->themes;
|
$themes = $core->themes;
|
||||||
$plugins = $core->plugins;
|
$plugins = $core->plugins;
|
||||||
|
|
||||||
# Rights
|
# Rights
|
||||||
$is_editable =
|
$is_editable =
|
||||||
!empty($type)
|
!empty($type)
|
||||||
&& !empty($_POST['modules'])
|
&& !empty($_POST['modules'])
|
||||||
&& is_array($_POST['modules']);
|
&& is_array($_POST['modules']);
|
||||||
|
|
||||||
# Actions
|
# Actions
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
# Add license to modules
|
# Add license to modules
|
||||||
if ($action == 'addlicense' && $is_editable) {
|
if ($action == 'addlicense' && $is_editable) {
|
||||||
|
|
||||||
$modules = array_keys($_POST['modules']);
|
$modules = array_keys($_POST['modules']);
|
||||||
|
|
||||||
foreach ($modules as $id) {
|
foreach ($modules as $id) {
|
||||||
|
|
||||||
if (!${$type}->moduleExists($id)) {
|
if (!${$type}->moduleExists($id)) {
|
||||||
throw new Exception('No such module');
|
throw new Exception('No such module');
|
||||||
}
|
}
|
||||||
|
|
||||||
$module = ${$type}->getModules($id);
|
$module = ${$type}->getModules($id);
|
||||||
$module['id'] = $id;
|
$module['id'] = $id;
|
||||||
$module['type'] = $type == 'themes' ? 'theme' : 'plugin';
|
$module['type'] = $type == 'themes' ? 'theme' : 'plugin';
|
||||||
|
|
||||||
licenseBootstrap::addLicense($core, $module);
|
licenseBootstrap::addLicense($core, $module);
|
||||||
}
|
}
|
||||||
|
|
||||||
dcPage::addSuccessNotice(
|
dcPage::addSuccessNotice(
|
||||||
__('License successfully added.')
|
__('License successfully added.')
|
||||||
);
|
);
|
||||||
http::redirect(empty($_POST['redir']) ?
|
http::redirect(empty($_POST['redir']) ?
|
||||||
$p_url : $_POST['redir']
|
$p_url : $_POST['redir']
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(Exception $e) {
|
catch(Exception $e) {
|
||||||
$core->error->add($e->getMessage());
|
$core->error->add($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
# Display
|
# Display
|
||||||
echo
|
echo
|
||||||
'<html><head><title>'.__('License bootstrap').'</title>'.
|
'<html><head><title>' . __('License bootstrap') . '</title>' .
|
||||||
dcPage::jsPageTabs().
|
dcPage::jsPageTabs() .
|
||||||
dcPage::jsLoad('index.php?pf=licenseBootstrap/js/licensebootstrap.js').
|
dcPage::jsLoad('index.php?pf=licenseBootstrap/js/licensebootstrap.js') .
|
||||||
|
|
||||||
# --BEHAVIOR-- licenseBootstrapAdminHeader
|
# --BEHAVIOR-- licenseBootstrapAdminHeader
|
||||||
$core->callBehavior('licenseBootstrapAdminHeader', $core).
|
$core->callBehavior('licenseBootstrapAdminHeader', $core) .
|
||||||
|
|
||||||
'</head><body>'.
|
'</head><body>' .
|
||||||
|
|
||||||
dcPage::breadcrumb(
|
dcPage::breadcrumb(
|
||||||
array(
|
array(
|
||||||
__('Plugins') => '',
|
__('Plugins') => '',
|
||||||
__('License bootstrap') => ''
|
__('License bootstrap') => ''
|
||||||
)
|
)
|
||||||
).
|
) .
|
||||||
dcPage::notices();
|
dcPage::notices();
|
||||||
|
|
||||||
libLicenseBootstrap::modules(
|
libLicenseBootstrap::modules(
|
||||||
$core,
|
$core,
|
||||||
$plugins->getModules(),
|
$plugins->getModules(),
|
||||||
'plugins',
|
'plugins',
|
||||||
__('Installed plugins')
|
__('Installed plugins')
|
||||||
);
|
);
|
||||||
|
|
||||||
libLicenseBootstrap::modules(
|
libLicenseBootstrap::modules(
|
||||||
$core,
|
$core,
|
||||||
$themes->getModules(),
|
$themes->getModules(),
|
||||||
'themes',
|
'themes',
|
||||||
__('Installed themes')
|
__('Installed themes')
|
||||||
);
|
);
|
||||||
|
|
||||||
dcPage::helpBlock('licenseBootstrap');
|
dcPage::helpBlock('licenseBootstrap');
|
||||||
|
|
||||||
echo
|
echo
|
||||||
'<hr class="clear"/><p class="right modules">
|
'</body></html>';
|
||||||
<a class="module-config" '.
|
|
||||||
'href="plugins.php?module=licenseBootstrap&conf=1&redir='.
|
|
||||||
urlencode('plugin.php?p=licenseBootstrap').'">'.__('Configuration').'</a> -
|
|
||||||
licenseBootstrap - '.$core->plugins->moduleInfo('licenseBootstrap', 'version').'
|
|
||||||
<img alt="'.__('licenseBootstrap').'" src="index.php?pf=licenseBootstrap/icon.png" />
|
|
||||||
</p>
|
|
||||||
</body></html>';
|
|
Loading…
Reference in New Issue