diff --git a/CHANGELOG b/CHANGELOG.md
similarity index 56%
rename from CHANGELOG
rename to CHANGELOG.md
index 5449683..cacd695 100644
--- a/CHANGELOG
+++ b/CHANGELOG.md
@@ -1,33 +1,29 @@
+licenseBootstrap 2021.08.17
+ * Move to Franck style
+
licenseBootstrap 2013.12.01
-===========================================================
* Fix install
* Fix user info
licenseBootstrap 2013.10.29
-===========================================================
* Fix full license bug
* Fix french help and support links
licenseBootstrap 2013.10.28
-===========================================================
* Switched to DC 2.6
* New icon
* Add dashboard icon
* Clean up code and (again) lighter admin interface
licenseBootstrap 2013.05.11
-===========================================================
* Fixed page title and messages and contents
licenseBootstrap 0.3 - 2010-06-05
-===========================================================
* Switched to DC 2.2
* Changed admin interface (easy, light, fast)
licenseBootstrap 0.2 - 2009-11-09
-===========================================================
* Changed lots of things
licenseBootstrap 0.1 - 2009-10-09
-===========================================================
* First lab release
\ No newline at end of file
diff --git a/README.md b/README.md
index 84f5d17..9803a45 100644
--- a/README.md
+++ b/README.md
@@ -24,4 +24,10 @@ Go to ''plugins manager'', expand licenseBootstrap information then
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.
\ No newline at end of file
+''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)
\ No newline at end of file
diff --git a/_admin.php b/_admin.php
index 1663626..fab326a 100644
--- a/_admin.php
+++ b/_admin.php
@@ -13,59 +13,56 @@
# -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_CONTEXT_ADMIN')) {
-
- return null;
+ return null;
}
$core->blog->settings->addNamespace('licenseBootstrap');
-$core->addBehavior(
- 'adminDashboardFavorites',
- array('licenseBootstrapBehaviors', 'adminDashboardFavorites')
-);
+$core->addBehavior('adminDashboardFavorites', [
+ 'licenseBootstrapBehaviors', 'adminDashboardFavorites'
+]);
-$core->addBehavior(
- 'packmanBeforeCreatePackage',
- array('licenseBootstrapBehaviors', 'packmanBeforeCreatePackage')
-);
+$core->addBehavior('packmanBeforeCreatePackage', [
+ 'licenseBootstrapBehaviors', 'packmanBeforeCreatePackage'
+]);
$_menu['Plugins']->addItem(
- __('License bootstrap'),
- 'plugin.php?p=licenseBootstrap',
- 'index.php?pf=licenseBootstrap/icon.png',
- preg_match(
- '/plugin.php\?p=licenseBootstrap(&.*)?$/',
- $_SERVER['REQUEST_URI']
- ),
- $core->auth->isSuperAdmin()
+ __('License bootstrap'),
+ 'plugin.php?p=licenseBootstrap',
+ 'index.php?pf=licenseBootstrap/icon.png',
+ preg_match(
+ '/plugin.php\?p=licenseBootstrap(&.*)?$/',
+ $_SERVER['REQUEST_URI']
+ ),
+ $core->auth->isSuperAdmin()
);
class licenseBootstrapBehaviors
{
- public static function adminDashboardFavorites($core, $favs)
- {
- $favs->register('licenseBootstrap', array(
- '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(
- 'licenseBootstrapBehaviors',
- 'adminDashboardFavoritesActive'
- )
- ));
- }
+ public static function adminDashboardFavorites($core, $favs)
+ {
+ $favs->register('licenseBootstrap', array(
+ '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(
+ 'licenseBootstrapBehaviors',
+ 'adminDashboardFavoritesActive'
+ )
+ ));
+ }
- public static function adminDashboardFavoritesActive($request, $params)
- {
- return $request == 'plugin.php'
- && isset($params['p'])
- && $params['p'] == 'licenseBootstrap';
- }
+ public static function adminDashboardFavoritesActive($request, $params)
+ {
+ return $request == 'plugin.php'
+ && isset($params['p'])
+ && $params['p'] == 'licenseBootstrap';
+ }
- public static function packmanBeforeCreatePackage($core, $module, $a, $b, $c, $d)
- {
- licenseBootstrap::addLicense($core, $module);
- }
-}
+ public static function packmanBeforeCreatePackage($core, $module, $a, $b, $c, $d)
+ {
+ licenseBootstrap::addLicense($core, $module);
+ }
+}
\ No newline at end of file
diff --git a/_config.php b/_config.php
index a282f64..2f86429 100644
--- a/_config.php
+++ b/_config.php
@@ -13,114 +13,113 @@
# -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_CONTEXT_MODULE')) {
-
- return null;
+ return null;
}
$redir = empty($_REQUEST['redir']) ?
- $list->getURL().'#plugins' : $_REQUEST['redir'];
+ $list->getURL() . '#plugins' : $_REQUEST['redir'];
# -- Get settings --
$core->blog->settings->addNamespace('licenseBootstrap');
$s = $core->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_license_name = licenseBootstrap::getName($s->license_name);
-$lb_license_head = licenseBootstrap::gethead($s->license_name, licenseBootstrap::decode($s->license_head));
+$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_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']);
- $lb_write_php = !empty($_POST['lb_write_php']);
- $lb_write_js = !empty($_POST['lb_write_js']);
- $lb_exclude_locales = !empty($_POST['lb_exclude_locales']);
- $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] : '');
+ try {
+ $lb_overwrite = !empty($_POST['lb_overwrite']);
+ $lb_write_full = !empty($_POST['lb_write_full']);
+ $lb_write_php = !empty($_POST['lb_write_php']);
+ $lb_write_js = !empty($_POST['lb_write_js']);
+ $lb_exclude_locales = !empty($_POST['lb_exclude_locales']);
+ $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] : '');
- $s->put('overwrite', $lb_overwrite);
- $s->put('write_full', $lb_write_full);
- $s->put('write_php', $lb_write_php);
- $s->put('write_js', $lb_write_js);
- $s->put('exclude_locales', $lb_exclude_locales);
- $s->put('license_name', licenseBootstrap::getName($lb_license_name));
- $s->put('license_head', licenseBootstrap::encode($lb_license_head));
+ $s->put('overwrite', $lb_overwrite);
+ $s->put('write_full', $lb_write_full);
+ $s->put('write_php', $lb_write_php);
+ $s->put('write_js', $lb_write_js);
+ $s->put('exclude_locales', $lb_exclude_locales);
+ $s->put('license_name', licenseBootstrap::getName($lb_license_name));
+ $s->put('license_head', licenseBootstrap::encode($lb_license_head));
- dcPage::addSuccessNotice(
- __('Configuration has been successfully updated.')
- );
- http::redirect(
- $list->getURL('module=licenseBootstrap&conf=1&redir='.
- $list->getRedir())
- );
- }
- catch (Exception $e) {
- $core->error->add($e->getMessage());
- }
+ dcPage::addSuccessNotice(
+ __('Configuration has been successfully updated.')
+ );
+ http::redirect(
+ $list->getURL('module=licenseBootstrap&conf=1&redir='.
+ $list->getRedir())
+ );
+ }
+ catch (Exception $e) {
+ $core->error->add($e->getMessage());
+ }
}
# -- Display form --
echo '
-
'.__('Files').'
+
' . __('Files') . '
-
-
'.__('Licenses').'
';
+
' . __('Licenses') . '
';
foreach(licenseBootstrap::getLicenses() as $name) {
- $check = false;
- $head = licenseBootstrap::getHead($name);
- if ($name == $lb_license_name) {
- $check = true;
- $head = licenseBootstrap::getHead($name, $lb_license_head);
- }
- echo '
-
'.
- form::radio(array('lb_license_name', 'license_'.$name), $name, $check).' '.
- sprintf(__('License %s:'),$name).'
-
'.
- form::textarea('lb_license_head_'.$name, 50, 10, html::escapeHTML($head)).'
-
';
+ $check = false;
+ $head = licenseBootstrap::getHead($name);
+ if ($name == $lb_license_name) {
+ $check = true;
+ $head = licenseBootstrap::getHead($name, $lb_license_head);
+ }
+ echo '
+
' .
+ form::radio(array('lb_license_name', 'license_' . $name), $name, $check) . ' ' .
+ sprintf(__('License %s:'), $name) . '
+
' .
+ form::textarea('lb_license_head_' . $name, 50, 10, html::escapeHTML($head)) . '
+
';
}
echo '
-
'.__('Files').'
+' . __('Files') . '
-';
+';
\ No newline at end of file
diff --git a/_define.php b/_define.php
index f128ae4..2e95c1e 100644
--- a/_define.php
+++ b/_define.php
@@ -13,25 +13,19 @@
# -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_RC_PATH')) {
-
- return null;
+ return null;
}
$this->registerModule(
- /* Name */
- "License bootstrap",
- /* Description*/
- "Add license to your plugins and themes",
- /* Author */
- "Jean-Christian Denis",
- /* Version */
- '2013.12.01',
- /* Properties */
- array(
- 'permissions' => null,
- 'type' => 'plugin',
- 'dc_min' => '2.6',
- 'support' => 'http://jcd.lv/q=licenseBootstrap',
- 'details' => 'http://plugins.dotaddict.org/dc2/details/licenseBootstrap'
- )
-);
+ 'License bootstrap', // Name
+ 'Add license to your plugins and themes', // Description
+ 'Jean-Christian Denis', // Author
+ '2021.08.17', // Version
+ [
+ 'permissions' => null,
+ 'type' => 'plugin',
+ 'dc_min' => '2.19',
+ 'support' => 'https://github.com/JcDenis/licenseBootstrap',
+ 'details' => 'https://plugins.dotaddict.org/dc2/details/licenseBootstrap'
+ ]
+);
\ No newline at end of file
diff --git a/_install.php b/_install.php
index 4739c2b..aa07f56 100644
--- a/_install.php
+++ b/_install.php
@@ -13,8 +13,7 @@
# -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_CONTEXT_ADMIN')) {
-
- return null;
+ return null;
}
# -- Module specs --
@@ -22,98 +21,98 @@ if (!defined('DC_CONTEXT_ADMIN')) {
$dc_min = '2.6';
$mod_id = 'licenseBootstrap';
$mod_conf = array(
- array(
- 'overwrite',
- 'Overwrite existing licence',
- false,
- 'boolean'
- ),
- array(
- 'write_full',
- 'Add complete licence file',
- true,
- 'boolean'
- ),
- array(
- 'write_php',
- 'Write license into php files',
- true,
- 'boolean'
- ),
- array(
- 'write_js',
- 'Write license into js files',
- false,
- 'boolean'
- ),
- array(
- 'exclude_locales',
- 'Exclude locales from license',
- true,
- 'boolean'
- ),
- array(
- 'license_name',
- 'License short name',
- 'gpl2',
- 'string'
- ),
- array(
- 'license_head',
- 'File header licence text',
- licenseBootstrap::encode(
- licenseBootstrap::getHead('gpl2')
- ),
- 'string'
- ),
- array(
- 'behavior_packman',
- 'Add LicenceBootstrap to plugin pacKman',
- false,
- 'boolean'
- )
+ array(
+ 'overwrite',
+ 'Overwrite existing licence',
+ false,
+ 'boolean'
+ ),
+ array(
+ 'write_full',
+ 'Add complete licence file',
+ true,
+ 'boolean'
+ ),
+ array(
+ 'write_php',
+ 'Write license into php files',
+ true,
+ 'boolean'
+ ),
+ array(
+ 'write_js',
+ 'Write license into js files',
+ false,
+ 'boolean'
+ ),
+ array(
+ 'exclude_locales',
+ 'Exclude locales from license',
+ true,
+ 'boolean'
+ ),
+ array(
+ 'license_name',
+ 'License short name',
+ 'gpl2',
+ 'string'
+ ),
+ array(
+ 'license_head',
+ 'File header licence text',
+ licenseBootstrap::encode(
+ licenseBootstrap::getHead('gpl2')
+ ),
+ 'string'
+ ),
+ array(
+ 'behavior_packman',
+ 'Add LicenceBootstrap to plugin pacKman',
+ false,
+ 'boolean'
+ )
);
# -- Nothing to change below --
try {
- # Check module version
- if (version_compare(
- $core->getVersion($mod_id),
- $core->plugins->moduleInfo($mod_id, 'version'),
- '>='
- )) {
+ # Check module version
+ if (version_compare(
+ $core->getVersion($mod_id),
+ $core->plugins->moduleInfo($mod_id, 'version'),
+ '>='
+ )) {
- return null;
- }
+ return null;
+ }
- # Check Dotclear version
- if (!method_exists('dcUtils', 'versionsCompare')
- || dcUtils::versionsCompare(DC_VERSION, $dc_min, '<', false)) {
- throw new Exception(sprintf(
- '%s requires Dotclear %s', $mod_id, $dc_min
- ));
- }
+ # Check Dotclear version
+ if (!method_exists('dcUtils', 'versionsCompare')
+ || dcUtils::versionsCompare(DC_VERSION, $dc_min, '<', false)) {
+ throw new Exception(sprintf(
+ '%s requires Dotclear %s', $mod_id, $dc_min
+ ));
+ }
- # Set module settings
- $core->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
- );
- }
+ # Set module settings
+ $core->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
+ );
+ }
- # Set module version
- $core->setVersion(
- $mod_id,
- $core->plugins->moduleInfo($mod_id, 'version')
- );
+ # Set module version
+ $core->setVersion(
+ $mod_id,
+ $core->plugins->moduleInfo($mod_id, 'version')
+ );
- return true;
+ return true;
}
catch (Exception $e) {
- $core->error->add($e->getMessage());
+ $core->error->add($e->getMessage());
- return false;
-}
+ return false;
+}
\ No newline at end of file
diff --git a/_prepend.php b/_prepend.php
index b645fb3..e131387 100644
--- a/_prepend.php
+++ b/_prepend.php
@@ -13,11 +13,10 @@
# -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_RC_PATH')) {
-
- return null;
+ return null;
}
$d = dirname(__FILE__).'/inc/';
-$__autoload['licenseBootstrap'] = $d.'class.license.bootstrap.php';
-$__autoload['libLicenseBootstrap'] = $d.'lib.license.bootstrap.php';
+$__autoload['licenseBootstrap'] = $d.'class.license.bootstrap.php';
+$__autoload['libLicenseBootstrap'] = $d.'lib.license.bootstrap.php';
\ No newline at end of file
diff --git a/_uninstall.php b/_uninstall.php
index 1c83ece..8710264 100644
--- a/_uninstall.php
+++ b/_uninstall.php
@@ -13,36 +13,35 @@
# -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_CONTEXT_ADMIN')) {
-
- return null;
+ return null;
}
$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)
+);
\ No newline at end of file
diff --git a/inc/class.license.bootstrap.php b/inc/class.license.bootstrap.php
index 512fa0a..beda63b 100644
--- a/inc/class.license.bootstrap.php
+++ b/inc/class.license.bootstrap.php
@@ -13,374 +13,373 @@
# -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_CONTEXT_ADMIN')) {
-
- return null;
+ return null;
}
class licenseBootstrap
{
- protected static $licenses = array();
+ protected static $licenses = array();
- /**
- * Add license to a module.
- *
- * 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)
- {
- $s = $core->blog->settings->licenseBootstrap;
+ /**
+ * Add license to a module.
+ *
+ * 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)
+ {
+ $s = $core->blog->settings->licenseBootstrap;
- # --BEHAVIOR-- licenseBootstrapBeforeAddLicense
- $core->callBehavior(
- 'licenseBootstrapBeforeAddLicense',
- $core,
- $module
- );
+ # --BEHAVIOR-- licenseBootstrapBeforeAddLicense
+ $core->callBehavior(
+ 'licenseBootstrapBeforeAddLicense',
+ $core,
+ $module
+ );
- if ($s->write_full) {
- licenseBootstrap::writeFullContent(
- $s->license_name,
- $module,
- $s->overwrite
- );
- }
- licenseBootstrap::writeHeadContent(
- $s->license_name,
- licenseBootstrap::decode($s->license_head),
- $module,
- $core->auth,
- $s->overwrite,
- $s->write_php,
- $s->write_js,
- $s->exclude_locales
- );
+ if ($s->write_full) {
+ licenseBootstrap::writeFullContent(
+ $s->license_name,
+ $module,
+ $s->overwrite
+ );
+ }
+ licenseBootstrap::writeHeadContent(
+ $s->license_name,
+ licenseBootstrap::decode($s->license_head),
+ $module,
+ $core->auth,
+ $s->overwrite,
+ $s->write_php,
+ $s->write_js,
+ $s->exclude_locales
+ );
- # --BEHAVIOR-- licenseBootstrapAfterAddLicense
- $core->callBehavior(
- 'licenseBootstrapAfterAddLicense',
- $core,
- $module
- );
- }
+ # --BEHAVIOR-- licenseBootstrapAfterAddLicense
+ $core->callBehavior(
+ 'licenseBootstrapAfterAddLicense',
+ $core,
+ $module
+ );
+ }
- /**
- * Get available licenses.
- *
- * @return array List of licenses names
- */
- public static function getLicenses()
- {
- if (empty(licenseBootstrap::$licenses)) {
- $file_reg = '/^([a-z0-9]+)\.head\.txt$/';
- $res = array();
- foreach (files::scandir(dirname(__FILE__).'/licenses/') as $file) {
- if (preg_match($file_reg, $file, $matches)) {
- $res[] = $matches[1];
- }
- }
- licenseBootstrap::$licenses = $res;
- }
+ /**
+ * Get available licenses.
+ *
+ * @return array List of licenses names
+ */
+ public static function getLicenses()
+ {
+ if (empty(licenseBootstrap::$licenses)) {
+ $file_reg = '/^([a-z0-9]+)\.head\.txt$/';
+ $res = array();
+ foreach (files::scandir(dirname(__FILE__) . '/licenses/') as $file) {
+ if (preg_match($file_reg, $file, $matches)) {
+ $res[] = $matches[1];
+ }
+ }
+ licenseBootstrap::$licenses = $res;
+ }
- return licenseBootstrap::$licenses;
- }
+ return licenseBootstrap::$licenses;
+ }
- /**
- * Get license name.
- *
- * Check requested license name and return existing one.
- *
- * @param string $name License name
- * @return string License name
- */
- public static function getName($name='gpl2')
- {
- return in_array($name, self::getLicenses()) ? $name : 'gpl2';
- }
+ /**
+ * Get license name.
+ *
+ * Check requested license name and return existing one.
+ *
+ * @param string $name License name
+ * @return string License name
+ */
+ public static function getName($name='gpl2')
+ {
+ return in_array($name, self::getLicenses()) ? $name : 'gpl2';
+ }
- /**
- * Get license header.
- *
- * @param string $name License name
- * @param string $content Header content
- * @return string Header content
- */
- public static function getHead($name='gpl2', $content='')
- {
- if (!in_array($name, self::getLicenses())) {
- $name = 'gpl2';
- $content = '';
- }
+ /**
+ * Get license header.
+ *
+ * @param string $name License name
+ * @param string $content Header content
+ * @return string Header content
+ */
+ public static function getHead($name='gpl2', $content='')
+ {
+ if (!in_array($name, self::getLicenses())) {
+ $name = 'gpl2';
+ $content = '';
+ }
- return empty($content) ?
- self::getContent($name, 'head') : $content;
- }
+ return empty($content) ?
+ self::getContent($name, 'head') : $content;
+ }
- /**
- * Get full license.
- *
- * @param string $name License name
- * @return string Full license content
- */
- public static function getFull($name='gpl2')
- {
- return self::getContent($name, 'full');
- }
+ /**
+ * Get full license.
+ *
+ * @param string $name License name
+ * @return string Full license content
+ */
+ public static function getFull($name='gpl2')
+ {
+ return self::getContent($name, 'full');
+ }
- /**
- * Get original license content.
- *
- * @param string $name License name
- * @param string $part License part (head or full)
- * @return string License content
- */
- public static function getContent($name='gpl2', $part='head')
- {
- if (!in_array($name, self::getLicenses())) {
- $name = 'gpl2';
- }
- if (!in_array($part, array('head', 'full'))) {
- $part = 'head';
- }
+ /**
+ * Get original license content.
+ *
+ * @param string $name License name
+ * @param string $part License part (head or full)
+ * @return string License content
+ */
+ public static function getContent($name='gpl2', $part='head')
+ {
+ if (!in_array($name, self::getLicenses())) {
+ $name = 'gpl2';
+ }
+ if (!in_array($part, array('head', 'full'))) {
+ $part = 'head';
+ }
- return file_get_contents(
- dirname(__FILE__).'/licenses/'.$name.'.'.$part.'.txt'
- );
- }
+ return file_get_contents(
+ dirname(__FILE__) . '/licenses/' . $name . '.' . $part . '.txt'
+ );
+ }
- /**
- * Write license block into module files headers
- *
- * @param string $name License name
- * @param string $content License block content
- * @param array $module Module info
- * @param object $user dcAuth instance
- * @param boolean $overwrite Overwrite existing license
- * @param boolean $php Write license in PHP
- * @param boolean $js Write license in JS
- * @param boolean $locales Excludes locales folder
- */
- public static function writeHeadContent($name, $content, $module, $user, $overwrite, $php, $js, $locales)
- {
- if (!isset($module['root']) || !is_writable($module['root'])) {
- throw new Exception();
- }
+ /**
+ * Write license block into module files headers
+ *
+ * @param string $name License name
+ * @param string $content License block content
+ * @param array $module Module info
+ * @param object $user dcAuth instance
+ * @param boolean $overwrite Overwrite existing license
+ * @param boolean $php Write license in PHP
+ * @param boolean $js Write license in JS
+ * @param boolean $locales Excludes locales folder
+ */
+ public static function writeHeadContent($name, $content, $module, $user, $overwrite, $php, $js, $locales)
+ {
+ if (!isset($module['root']) || !is_writable($module['root'])) {
+ throw new Exception();
+ }
- $license = self::replaceInfo(
- self::getHead($name, $content),
- $module,
- $user
- );
+ $license = self::replaceInfo(
+ self::getHead($name, $content),
+ $module,
+ $user
+ );
- foreach(self::getModuleFiles($module['root']) as $file) {
+ foreach(self::getModuleFiles($module['root']) as $file) {
- if ($locales && preg_match('/(\.lang\.php|libs)/', $file)) {
- continue;
- }
+ if ($locales && preg_match('/(\.lang\.php|libs)/', $file)) {
+ continue;
+ }
- $path = $module['root'].'/'.$file;
- $extension = files::getExtension($file);
+ $path = $module['root'] . '/' . $file;
+ $extension = files::getExtension($file);
- if ($php && $extension == 'php') {
- file_put_contents(
- $file,
- self::replacePhpContent(
- file_get_contents($file),
- $license,
- $overwrite
- )
- );
- }
- elseif ($js && $extension == 'js') {
- file_put_contents(
- $file,
- self::replaceJsContent(
- file_get_contents($file),
- $license,
- $overwrite
- )
- );
- }
- }
- }
+ if ($php && $extension == 'php') {
+ file_put_contents(
+ $file,
+ self::replacePhpContent(
+ file_get_contents($file),
+ $license,
+ $overwrite
+ )
+ );
+ }
+ elseif ($js && $extension == 'js') {
+ file_put_contents(
+ $file,
+ self::replaceJsContent(
+ file_get_contents($file),
+ $license,
+ $overwrite
+ )
+ );
+ }
+ }
+ }
- /**
- * Write full license file
- *
- * @param string $name License name
- * @param array $module Module info
- * @param boolean $overwrite Overwrite existing license
- */
- public static function writeFullContent($name, $module, $overwrite)
- {
- if (!isset($module['root']) || !is_writable($module['root'])) {
- throw new Exception();
- }
- if (file_exists($module['root'].'/LICENSE') && !$overwrite) {
+ /**
+ * Write full license file
+ *
+ * @param string $name License name
+ * @param array $module Module info
+ * @param boolean $overwrite Overwrite existing license
+ */
+ public static function writeFullContent($name, $module, $overwrite)
+ {
+ if (!isset($module['root']) || !is_writable($module['root'])) {
+ throw new Exception();
+ }
+ if (file_exists($module['root'] . '/LICENSE') && !$overwrite) {
- return null;
- }
+ return null;
+ }
- file_put_contents(
- $module['root'].'/LICENSE',
- self::getFull($name)
- );
- }
+ file_put_contents(
+ $module['root'] . '/LICENSE',
+ self::getFull($name)
+ );
+ }
- /**
- * Replace license block in PHP file
- *
- * @param string $content File content
- * @param string $license License content
- * @param boolean $overwrite Overwrite existing license
- * @return string File content
- */
- protected static function replacePhpContent($content, $license, $overwrite)
- {
- $clean = preg_replace(
- '/((# -- BEGIN LICENSE BLOCK ([-]+))(.*?)'.
- '(# -- END LICENSE BLOCK ([-]+))([\n|\r\n]+))/msi',
- '',
- $content
- );
+ /**
+ * Replace license block in PHP file
+ *
+ * @param string $content File content
+ * @param string $license License content
+ * @param boolean $overwrite Overwrite existing license
+ * @return string File content
+ */
+ protected static function replacePhpContent($content, $license, $overwrite)
+ {
+ $clean = preg_replace(
+ '/((# -- BEGIN LICENSE BLOCK ([-]+))(.*?)' .
+ '(# -- END LICENSE BLOCK ([-]+))([\n|\r\n]+))/msi',
+ '',
+ $content
+ );
- if ($clean != $content && !$overwrite) {
+ if ($clean != $content && !$overwrite) {
- return $content;
- }
+ return $content;
+ }
- return preg_replace(
- '/(\<\?php)/',
- 'getInfo('user_cn'),
- $user->getinfo('user_name'),
- $user->getInfo('user_email'),
- $user->getInfo('user_url')
- ),
- $content
- );
- }
+ /**
+ * Replace info in license
+ *
+ * @param string $content License content
+ * @param array $module Module info
+ * @param array $user User info
+ * @return string License content
+ */
+ protected static function replaceInfo($content, $module, $user)
+ {
+ return str_replace(
+ array(
+ '%year%',
+ '%module_id%',
+ '%module_name%',
+ '%module_author%',
+ '%module_type%',
+ '%user_cn%',
+ '%user_name%',
+ '%user_email%',
+ '%user_url%'
+ ),
+ array(
+ date('Y'),
+ $module['id'],
+ $module['name'],
+ $module['author'],
+ $module['type'],
+ $user->getInfo('user_cn'),
+ $user->getinfo('user_name'),
+ $user->getInfo('user_email'),
+ $user->getInfo('user_url')
+ ),
+ $content
+ );
+ }
- /**
- * Get list of module files
- *
- * @param string $path Path to scan
- * @param string $dir Ignore
- * @param array $res Ignore
- * @return array List of files
- */
- protected static function getModuleFiles($path, $dir='', $res=array())
- {
- $path = path::real($path);
- if (!is_dir($path) || !is_readable($path)) {
+ /**
+ * Get list of module files
+ *
+ * @param string $path Path to scan
+ * @param string $dir Ignore
+ * @param array $res Ignore
+ * @return array List of files
+ */
+ protected static function getModuleFiles($path, $dir='', $res=array())
+ {
+ $path = path::real($path);
+ if (!is_dir($path) || !is_readable($path)) {
- return array();
- }
+ return array();
+ }
- if (!$dir) {
- $dir = $path;
- }
-
- $files = files::scandir($path);
-
- foreach($files AS $file) {
- if (substr($file, 0, 1) == '.') {
- continue;
- }
+ if (!$dir) {
+ $dir = $path;
+ }
+
+ $files = files::scandir($path);
+
+ foreach($files AS $file) {
+ if (substr($file, 0, 1) == '.') {
+ continue;
+ }
- if (is_dir($path.'/'.$file)) {
- $res = self::getModuleFiles(
- $path.'/'.$file, $dir.'/'.$file,
- $res
- );
- }
- else {
- $res[] = empty($dir) ? $file : $dir.'/'.$file;
- }
- }
+ if (is_dir($path . '/' . $file)) {
+ $res = self::getModuleFiles(
+ $path . '/' . $file, $dir . '/' . $file,
+ $res
+ );
+ }
+ else {
+ $res[] = empty($dir) ? $file : $dir . '/' . $file;
+ }
+ }
- return $res;
- }
+ return $res;
+ }
- public static function encode($a)
- {
- return base64_encode(serialize($a));
- }
-
- public static function decode($a)
- {
- return unserialize(base64_decode($a));
- }
-}
+ public static function encode($a)
+ {
+ return base64_encode(serialize($a));
+ }
+
+ public static function decode($a)
+ {
+ return unserialize(base64_decode($a));
+ }
+}
\ No newline at end of file
diff --git a/inc/lib.license.bootstrap.php b/inc/lib.license.bootstrap.php
index 4d28685..97b57d9 100644
--- a/inc/lib.license.bootstrap.php
+++ b/inc/lib.license.bootstrap.php
@@ -13,87 +13,86 @@
# -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_CONTEXT_ADMIN')) {
-
- return null;
+ return null;
}
class libLicenseBootstrap
{
- public static function modules($core, $modules, $type, $title)
- {
- $type = $type == 'themes' ? 'themes' : 'plugins';
+ public static function modules($core, $modules, $type, $title)
+ {
+ $type = $type == 'themes' ? 'themes' : 'plugins';
- echo
- ''.
- '
'.$title.'
';
+ echo
+ '
' .
+ '
' . $title . '
';
- if (empty($modules) && !is_array($modules)) {
- echo
- '
'.__('There are no modules.').'
'.
- '
';
+ if (empty($modules) && !is_array($modules)) {
+ echo
+ '
' . __('There are no modules.') . '
' .
+ '
';
- return null;
- }
+ return null;
+ }
- echo
- '
' .
- '
';
- }
+ '
';
+ }
- protected static function sort($modules)
- {
- $sorter = array();
- foreach($modules as $id => $module) {
- $sorter[$id] = $id;
- }
- array_multisort($sorter, SORT_ASC, $modules);
+ protected static function sort($modules)
+ {
+ $sorter = array();
+ foreach($modules as $id => $module) {
+ $sorter[$id] = $id;
+ }
+ array_multisort($sorter, SORT_ASC, $modules);
- return $modules;
- }
-}
+ return $modules;
+ }
+}
\ No newline at end of file
diff --git a/index.php b/index.php
index 160fe0d..75b5150 100644
--- a/index.php
+++ b/index.php
@@ -13,8 +13,7 @@
# -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_CONTEXT_ADMIN')) {
-
- return null;
+ return null;
}
dcPage::checkSuper();
@@ -22,7 +21,7 @@ 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'] : '';
+$type = isset($_POST['type']) && in_array($_POST['type'], array('plugins', 'themes')) ? $_POST['type'] : '';
# Settings
$core->blog->settings->addNamespace('licenseBootstrap');
@@ -30,92 +29,85 @@ $s = $core->blog->settings->licenseBootstrap;
# Modules
if (!isset($core->themes)) {
- $core->themes = new dcThemes($core);
- $core->themes->loadModules($core->blog->themes_path,null);
+ $core->themes = new dcThemes($core);
+ $core->themes->loadModules($core->blog->themes_path, null);
}
$themes = $core->themes;
$plugins = $core->plugins;
# Rights
$is_editable =
- !empty($type)
- && !empty($_POST['modules'])
- && is_array($_POST['modules']);
+ !empty($type)
+ && !empty($_POST['modules'])
+ && is_array($_POST['modules']);
# Actions
try
{
- # Add license to modules
- if ($action == 'addlicense' && $is_editable) {
+ # Add license to modules
+ 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)) {
- throw new Exception('No such module');
- }
+ if (!${$type}->moduleExists($id)) {
+ throw new Exception('No such module');
+ }
- $module = ${$type}->getModules($id);
- $module['id'] = $id;
- $module['type'] = $type == 'themes' ? 'theme' : 'plugin';
+ $module = ${$type}->getModules($id);
+ $module['id'] = $id;
+ $module['type'] = $type == 'themes' ? 'theme' : 'plugin';
- licenseBootstrap::addLicense($core, $module);
- }
+ licenseBootstrap::addLicense($core, $module);
+ }
- dcPage::addSuccessNotice(
- __('License successfully added.')
- );
- http::redirect(empty($_POST['redir']) ?
- $p_url : $_POST['redir']
- );
- }
+ dcPage::addSuccessNotice(
+ __('License successfully added.')
+ );
+ http::redirect(empty($_POST['redir']) ?
+ $p_url : $_POST['redir']
+ );
+ }
}
catch(Exception $e) {
- $core->error->add($e->getMessage());
+ $core->error->add($e->getMessage());
}
# Display
echo
-'
'.__('License bootstrap').''.
-dcPage::jsPageTabs().
-dcPage::jsLoad('index.php?pf=licenseBootstrap/js/licensebootstrap.js').
+'
' . __('License bootstrap') . '' .
+dcPage::jsPageTabs() .
+dcPage::jsLoad('index.php?pf=licenseBootstrap/js/licensebootstrap.js') .
# --BEHAVIOR-- licenseBootstrapAdminHeader
-$core->callBehavior('licenseBootstrapAdminHeader', $core).
+$core->callBehavior('licenseBootstrapAdminHeader', $core) .
-''.
+'' .
dcPage::breadcrumb(
- array(
- __('Plugins') => '',
- __('License bootstrap') => ''
- )
-).
+ array(
+ __('Plugins') => '',
+ __('License bootstrap') => ''
+ )
+) .
dcPage::notices();
libLicenseBootstrap::modules(
- $core,
- $plugins->getModules(),
- 'plugins',
- __('Installed plugins')
+ $core,
+ $plugins->getModules(),
+ 'plugins',
+ __('Installed plugins')
);
libLicenseBootstrap::modules(
- $core,
- $themes->getModules(),
- 'themes',
- __('Installed themes')
+ $core,
+ $themes->getModules(),
+ 'themes',
+ __('Installed themes')
);
dcPage::helpBlock('licenseBootstrap');
echo
-'
-'.__('Configuration').' -
-licenseBootstrap - '.$core->plugins->moduleInfo('licenseBootstrap', 'version').'
-
-
-';
+'';
\ No newline at end of file