prepare to DC 2.24
This commit is contained in:
parent
e147da2fdd
commit
51f36fd6cc
5 changed files with 51 additions and 51 deletions
76
_admin.php
76
_admin.php
|
@ -15,68 +15,68 @@ if (!defined('DC_CONTEXT_ADMIN')) {
|
||||||
}
|
}
|
||||||
|
|
||||||
# only superadmin
|
# only superadmin
|
||||||
if (!$core->auth->isSuperAdmin()) {
|
if (!dcCore::app()->auth->isSuperAdmin()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
# only if activated
|
# only if activated
|
||||||
$core->blog->settings->addNamespace('tweakStores');
|
dcCore::app()->blog->settings->addNamespace('tweakStores');
|
||||||
if (!$core->blog->settings->tweakStores->active) {
|
if (!dcCore::app()->blog->settings->tweakStores->active) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
# admin behaviors
|
# admin behaviors
|
||||||
if ($core->blog->settings->tweakStores->packman) {
|
if (dcCore::app()->blog->settings->tweakStores->packman) {
|
||||||
$core->addBehavior('packmanBeforeCreatePackage', ['tweakStoresBehaviors', 'packmanBeforeCreatePackage']);
|
dcCore::app()->addBehavior('packmanBeforeCreatePackage', ['tweakStoresBehaviors', 'packmanBeforeCreatePackage']);
|
||||||
}
|
}
|
||||||
$core->addBehavior('pluginsToolsHeaders', ['tweakStoresBehaviors', 'modulesToolsHeaders']);
|
dcCore::app()->addBehavior('pluginsToolsHeadersV2', ['tweakStoresBehaviors', 'modulesToolsHeaders']);
|
||||||
$core->addBehavior('themesToolsHeaders', ['tweakStoresBehaviors', 'modulesToolsHeaders']);
|
dcCore::app()->addBehavior('themesToolsHeadersV2', ['tweakStoresBehaviors', 'modulesToolsHeaders']);
|
||||||
$core->addBehavior('pluginsToolsTabs', ['tweakStoresBehaviors', 'pluginsToolsTabs']);
|
dcCore::app()->addBehavior('pluginsToolsTabsV2', ['tweakStoresBehaviors', 'pluginsToolsTabs']);
|
||||||
$core->addBehavior('themesToolsTabs', ['tweakStoresBehaviors', 'themesToolsTabs']);
|
dcCore::app()->addBehavior('themesToolsTabsV2', ['tweakStoresBehaviors', 'themesToolsTabs']);
|
||||||
|
|
||||||
class tweakStoresBehaviors
|
class tweakStoresBehaviors
|
||||||
{
|
{
|
||||||
# create dcstore.xml file on the fly when pack a module
|
# create dcstore.xml file on the fly when pack a module
|
||||||
public static function packmanBeforeCreatePackage(dcCore $core, array $module): void
|
public static function packmanBeforeCreatePackage(array $module): void
|
||||||
{
|
{
|
||||||
tweakStores::writeXML($module['id'], $module, $core->blog->settings->tweakStores->file_pattern);
|
tweakStores::writeXML($module['id'], $module, dcCore::app()->blog->settings->tweakStores->file_pattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
# addd some js
|
# addd some js
|
||||||
public static function modulesToolsHeaders(dcCore $core, bool $is_plugin): string
|
public static function modulesToolsHeaders(bool $is_plugin): string
|
||||||
{
|
{
|
||||||
$core->auth->user_prefs->addWorkspace('interface');
|
dcCore::app()->auth->user_prefs->addWorkspace('interface');
|
||||||
|
|
||||||
return
|
return
|
||||||
dcPage::jsVars(['dotclear.ts_copied' => __('Copied to clipboard')]) .
|
dcPage::jsVars(['dotclear.ts_copied' => __('Copied to clipboard')]) .
|
||||||
dcPage::jsLoad(dcPage::getPF('tweakStores/js/admin.js')) .
|
dcPage::jsLoad(dcPage::getPF('tweakStores/js/admin.js')) .
|
||||||
(
|
(
|
||||||
!$core->auth->user_prefs->interface->colorsyntax ? '' :
|
!dcCore::app()->auth->user_prefs->interface->colorsyntax ? '' :
|
||||||
dcPage::jsLoadCodeMirror($core->auth->user_prefs->interface->colorsyntax_theme) .
|
dcPage::jsLoadCodeMirror(dcCore::app()->auth->user_prefs->interface->colorsyntax_theme) .
|
||||||
dcPage::jsLoad(dcPage::getPF('tweakStores/js/cms.js'))
|
dcPage::jsLoad(dcPage::getPF('tweakStores/js/cms.js'))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
# admin plugins page tab
|
# admin plugins page tab
|
||||||
public static function pluginsToolsTabs(dcCore $core): void
|
public static function pluginsToolsTabs(): void
|
||||||
{
|
{
|
||||||
self::modulesToolsTabs($core, $core->plugins->getModules(), explode(',', DC_DISTRIB_PLUGINS), $core->adminurl->get('admin.plugins') . '#tweakStores');
|
self::modulesToolsTabs(dcCore::app()->plugins->getModules(), explode(',', DC_DISTRIB_PLUGINS), dcCore::app()->adminurl->get('admin.plugins') . '#tweakStores');
|
||||||
}
|
}
|
||||||
|
|
||||||
# admin themes page tab
|
# admin themes page tab
|
||||||
public static function themesToolsTabs(dcCore $core): void
|
public static function themesToolsTabs(): void
|
||||||
{
|
{
|
||||||
self::modulesToolsTabs($core, $core->themes->getModules(), explode(',', DC_DISTRIB_THEMES), $core->adminurl->get('admin.blog.theme') . '#tweakStores');
|
self::modulesToolsTabs(dcCore::app()->themes->getModules(), explode(',', DC_DISTRIB_THEMES), dcCore::app()->adminurl->get('admin.blog.theme') . '#tweakStores');
|
||||||
}
|
}
|
||||||
|
|
||||||
# generic page tab
|
# generic page tab
|
||||||
protected static function modulesToolsTabs(dcCore $core, array $modules, array $excludes, string $page_url): void
|
protected static function modulesToolsTabs(array $modules, array $excludes, string $page_url): void
|
||||||
{
|
{
|
||||||
$core->auth->user_prefs->addWorkspace('interface');
|
dcCore::app()->auth->user_prefs->addWorkspace('interface');
|
||||||
$user_ui_colorsyntax = $core->auth->user_prefs->interface->colorsyntax;
|
$user_ui_colorsyntax = dcCore::app()->auth->user_prefs->interface->colorsyntax;
|
||||||
$user_ui_colorsyntax_theme = $core->auth->user_prefs->interface->colorsyntax_theme;
|
$user_ui_colorsyntax_theme = dcCore::app()->auth->user_prefs->interface->colorsyntax_theme;
|
||||||
$combo = self::comboModules($modules, $excludes);
|
$combo = self::comboModules($modules, $excludes);
|
||||||
$file_pattern = $core->blog->settings->tweakStores->file_pattern;
|
$file_pattern = dcCore::app()->blog->settings->tweakStores->file_pattern;
|
||||||
|
|
||||||
# check dcstore repo
|
# check dcstore repo
|
||||||
$url = '';
|
$url = '';
|
||||||
|
@ -115,12 +115,12 @@ class tweakStoresBehaviors
|
||||||
|
|
||||||
# write dcstore.xml file
|
# write dcstore.xml file
|
||||||
if (!empty($_POST['write_xml'])) {
|
if (!empty($_POST['write_xml'])) {
|
||||||
if (empty($_POST['your_pwd']) || !$core->auth->checkPassword($_POST['your_pwd'])) {
|
if (empty($_POST['your_pwd']) || !dcCore::app()->auth->checkPassword($_POST['your_pwd'])) {
|
||||||
$core->error->add(__('Password verification failed'));
|
dcCore::app()->error->add(__('Password verification failed'));
|
||||||
} else {
|
} else {
|
||||||
$ret = tweakStores::writeXML($_POST['buildxml_id'], $modules[$_POST['buildxml_id']], $file_pattern);
|
$ret = tweakStores::writeXML($_POST['buildxml_id'], $modules[$_POST['buildxml_id']], $file_pattern);
|
||||||
if (!empty(tweakStores::$failed)) {
|
if (!empty(tweakStores::$failed)) {
|
||||||
$core->error->add(implode(' ', tweakStores::$failed));
|
dcCore::app()->error->add(implode(' ', tweakStores::$failed));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -129,8 +129,8 @@ class tweakStoresBehaviors
|
||||||
'<h3>' . __('Tweak third-party repositories') . '</h3>';
|
'<h3>' . __('Tweak third-party repositories') . '</h3>';
|
||||||
|
|
||||||
if (!empty($_POST['write_xml'])) {
|
if (!empty($_POST['write_xml'])) {
|
||||||
if ($core->error->flag()) {
|
if (dcCore::app()->error->flag()) {
|
||||||
echo '<p class="error">' . implode(' ', $core->error->getErrors()) . '</p>';
|
echo dcCore::app()->error->toHTML();
|
||||||
} else {
|
} else {
|
||||||
echo '<p class="success">' . __('File successfully written') . '</p>';
|
echo '<p class="success">' . __('File successfully written') . '</p>';
|
||||||
}
|
}
|
||||||
|
@ -151,7 +151,7 @@ class tweakStoresBehaviors
|
||||||
form::combo('checkxml_id', $combo, empty($_POST['checkxml_id']) ? '-' : html::escapeHTML($_POST['checkxml_id'])) .
|
form::combo('checkxml_id', $combo, empty($_POST['checkxml_id']) ? '-' : html::escapeHTML($_POST['checkxml_id'])) .
|
||||||
'</p>' .
|
'</p>' .
|
||||||
'<p><input type="submit" name="check_xml" value="' . __('Check') . '" />' .
|
'<p><input type="submit" name="check_xml" value="' . __('Check') . '" />' .
|
||||||
$core->formNonce() . '</p>' .
|
dcCore::app()->formNonce() . '</p>' .
|
||||||
'</form>';
|
'</form>';
|
||||||
|
|
||||||
if (!empty($url)) {
|
if (!empty($url)) {
|
||||||
|
@ -164,7 +164,7 @@ class tweakStoresBehaviors
|
||||||
'<pre>' . form::textArea('file_xml', 165, 14, [
|
'<pre>' . form::textArea('file_xml', 165, 14, [
|
||||||
'default' => html::escapeHTML(tweakStores::prettyXML($file_content)),
|
'default' => html::escapeHTML(tweakStores::prettyXML($file_content)),
|
||||||
'class' => 'maximal',
|
'class' => 'maximal',
|
||||||
'extra_html' => 'readonly="true"'
|
'extra_html' => 'readonly="true"',
|
||||||
]) . '</pre>' .
|
]) . '</pre>' .
|
||||||
(
|
(
|
||||||
!$user_ui_colorsyntax ? '' :
|
!$user_ui_colorsyntax ? '' :
|
||||||
|
@ -177,7 +177,7 @@ class tweakStoresBehaviors
|
||||||
if (empty($file_pattern)) {
|
if (empty($file_pattern)) {
|
||||||
echo sprintf(
|
echo sprintf(
|
||||||
'<div class="fieldset"><h4>' . __('Generate xml code') . '</h4><p class="info"><a href="%s">%s</a></p></div>',
|
'<div class="fieldset"><h4>' . __('Generate xml code') . '</h4><p class="info"><a href="%s">%s</a></p></div>',
|
||||||
$core->adminurl->get('admin.plugins', ['module' => 'tweakStores', 'conf' => 1, 'redir' => $page_url]),
|
dcCore::app()->adminurl->get('admin.plugins', ['module' => 'tweakStores', 'conf' => 1, 'redir' => $page_url]),
|
||||||
__('You must configure zip file pattern to complete xml code automatically.')
|
__('You must configure zip file pattern to complete xml code automatically.')
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
@ -189,7 +189,7 @@ class tweakStoresBehaviors
|
||||||
form::combo('buildxml_id', $combo, empty($_POST['buildxml_id']) ? '-' : html::escapeHTML($_POST['buildxml_id'])) .
|
form::combo('buildxml_id', $combo, empty($_POST['buildxml_id']) ? '-' : html::escapeHTML($_POST['buildxml_id'])) .
|
||||||
'</p>' .
|
'</p>' .
|
||||||
'<p><input type="submit" name="build_xml" value="' . __('Generate') . '" />' .
|
'<p><input type="submit" name="build_xml" value="' . __('Generate') . '" />' .
|
||||||
$core->formNonce() . '</p>' .
|
dcCore::app()->formNonce() . '</p>' .
|
||||||
'</form>';
|
'</form>';
|
||||||
}
|
}
|
||||||
if (!empty($_POST['buildxml_id'])) {
|
if (!empty($_POST['buildxml_id'])) {
|
||||||
|
@ -211,7 +211,7 @@ class tweakStoresBehaviors
|
||||||
'<pre>' . form::textArea('gen_xml', 165, 14, [
|
'<pre>' . form::textArea('gen_xml', 165, 14, [
|
||||||
'default' => html::escapeHTML(tweakStores::prettyXML($xml_content)),
|
'default' => html::escapeHTML(tweakStores::prettyXML($xml_content)),
|
||||||
'class' => 'maximal',
|
'class' => 'maximal',
|
||||||
'extra_html' => 'readonly="true"'
|
'extra_html' => 'readonly="true"',
|
||||||
]) . '</pre>' .
|
]) . '</pre>' .
|
||||||
(
|
(
|
||||||
!$user_ui_colorsyntax ? '' :
|
!$user_ui_colorsyntax ? '' :
|
||||||
|
@ -220,7 +220,7 @@ class tweakStoresBehaviors
|
||||||
|
|
||||||
if (empty(tweakStores::$failed)
|
if (empty(tweakStores::$failed)
|
||||||
&& $modules[$_POST['buildxml_id']]['root_writable']
|
&& $modules[$_POST['buildxml_id']]['root_writable']
|
||||||
&& $core->auth->isSuperAdmin()
|
&& dcCore::app()->auth->isSuperAdmin()
|
||||||
) {
|
) {
|
||||||
echo
|
echo
|
||||||
'<p class="field"><label for="your_pwd2" class="classic required"><abbr title="' . __('Required field') . '">*</abbr> ' . __('Your password:') . '</label> ' .
|
'<p class="field"><label for="your_pwd2" class="classic required"><abbr title="' . __('Required field') . '">*</abbr> ' . __('Your password:') . '</label> ' .
|
||||||
|
@ -230,17 +230,17 @@ class tweakStoresBehaviors
|
||||||
255,
|
255,
|
||||||
[
|
[
|
||||||
'extra_html' => 'required placeholder="' . __('Password') . '"',
|
'extra_html' => 'required placeholder="' . __('Password') . '"',
|
||||||
'autocomplete' => 'current-password'
|
'autocomplete' => 'current-password',
|
||||||
]
|
]
|
||||||
) . '</p>' .
|
) . '</p>' .
|
||||||
'<p><input type="submit" name="write_xml" value="' . __('Save to module directory') . '" /> ' .
|
'<p><input type="submit" name="write_xml" value="' . __('Save to module directory') . '" /> ' .
|
||||||
'<a class="hidden-if-no-js button" href="#tweakStores" id="ts_copy_button">' . __('Copy to clipboard') . '</a>' .
|
'<a class="hidden-if-no-js button" href="#tweakStores" id="ts_copy_button">' . __('Copy to clipboard') . '</a>' .
|
||||||
form::hidden('buildxml_id', $_POST['buildxml_id']) .
|
form::hidden('buildxml_id', $_POST['buildxml_id']) .
|
||||||
$core->formNonce() . '</p>';
|
dcCore::app()->formNonce() . '</p>';
|
||||||
}
|
}
|
||||||
echo sprintf(
|
echo sprintf(
|
||||||
'<p class="info"><a href="%s">%s</a></p>',
|
'<p class="info"><a href="%s">%s</a></p>',
|
||||||
$core->adminurl->get('admin.plugins', ['module' => 'tweakStores', 'conf' => 1, 'redir' => $page_url]),
|
dcCore::app()->adminurl->get('admin.plugins', ['module' => 'tweakStores', 'conf' => 1, 'redir' => $page_url]),
|
||||||
__('You can edit zip file pattern from configuration page.')
|
__('You can edit zip file pattern from configuration page.')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
10
_config.php
10
_config.php
|
@ -17,11 +17,11 @@ if (!defined('DC_CONTEXT_MODULE')) {
|
||||||
dcPage::checkSuper();
|
dcPage::checkSuper();
|
||||||
|
|
||||||
$redir = empty($_REQUEST['redir']) ?
|
$redir = empty($_REQUEST['redir']) ?
|
||||||
$list->getURL() . '#plugins' : $_REQUEST['redir'];
|
dcCore::app()->admin->list->getURL() . '#plugins' : $_REQUEST['redir'];
|
||||||
|
|
||||||
# -- Get settings --
|
# -- Get settings --
|
||||||
$core->blog->settings->addNamespace('tweakStores');
|
dcCore::app()->blog->settings->addNamespace('tweakStores');
|
||||||
$s = $core->blog->settings->tweakStores;
|
$s = dcCore::app()->blog->settings->tweakStores;
|
||||||
|
|
||||||
$tweakStores_active = $s->active;
|
$tweakStores_active = $s->active;
|
||||||
$tweakStores_packman = $s->packman;
|
$tweakStores_packman = $s->packman;
|
||||||
|
@ -42,10 +42,10 @@ if (!empty($_POST['save'])) {
|
||||||
__('Configuration successfully updated')
|
__('Configuration successfully updated')
|
||||||
);
|
);
|
||||||
http::redirect(
|
http::redirect(
|
||||||
$list->getURL('module=tweakStores&conf=1&redir=' . $list->getRedir())
|
dcCore::app()->admin->list->getURL('module=tweakStores&conf=1&redir=' . dcCore::app()->admin->list->getRedir())
|
||||||
);
|
);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$core->error->add($e->getMessage());
|
dcCore::app()->error->add($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,13 +18,13 @@ $this->registerModule(
|
||||||
'Tweak stores',
|
'Tweak stores',
|
||||||
'Helper to manage external repositories',
|
'Helper to manage external repositories',
|
||||||
'Jean-Christian Denis and Contributors',
|
'Jean-Christian Denis and Contributors',
|
||||||
'0.4',
|
'0.5',
|
||||||
[
|
[
|
||||||
'requires' => [['core', '2.19']],
|
'requires' => [['core', '2.24']],
|
||||||
'permissions' => null,
|
'permissions' => null,
|
||||||
'type' => 'plugin',
|
'type' => 'plugin',
|
||||||
'support' => 'https://github.com/JcDenis/tweakStores',
|
'support' => 'https://github.com/JcDenis/tweakStores',
|
||||||
'details' => 'https://plugins.dotaddict.org/dc2/details/tweakStores',
|
'details' => 'https://plugins.dotaddict.org/dc2/details/tweakStores',
|
||||||
'repository' => 'https://raw.githubusercontent.com/JcDenis/tweakStores/master/'
|
'repository' => 'https://raw.githubusercontent.com/JcDenis/tweakStores/master/',
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
|
@ -14,4 +14,4 @@ if (!defined('DC_RC_PATH')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$__autoload['tweakStores'] = dirname(__FILE__) . '/inc/class.tweakstores.php';
|
Clearbricks::lib()->autoload(['tweakStores' => __DIR__ . '/inc/class.tweakstores.php']);
|
||||||
|
|
|
@ -48,7 +48,7 @@ class tweakStores
|
||||||
'requires' => [],
|
'requires' => [],
|
||||||
'settings' => [],
|
'settings' => [],
|
||||||
'repository' => '',
|
'repository' => '',
|
||||||
'dc_min' => 0
|
'dc_min' => 0,
|
||||||
],
|
],
|
||||||
# Module's values
|
# Module's values
|
||||||
$module,
|
$module,
|
||||||
|
@ -59,7 +59,7 @@ class tweakStores
|
||||||
'label' => $label,
|
'label' => $label,
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'oname' => $oname,
|
'oname' => $oname,
|
||||||
'sname' => self::sanitizeString($name)
|
'sname' => self::sanitizeString($name),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -79,13 +79,13 @@ class tweakStores
|
||||||
'%type%',
|
'%type%',
|
||||||
'%id%',
|
'%id%',
|
||||||
'%version%',
|
'%version%',
|
||||||
'%author%'
|
'%author%',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
$module['type'],
|
$module['type'],
|
||||||
$module['id'],
|
$module['id'],
|
||||||
$module['version'],
|
$module['version'],
|
||||||
$module['author']
|
$module['author'],
|
||||||
],
|
],
|
||||||
$file_pattern
|
$file_pattern
|
||||||
));
|
));
|
||||||
|
|
Loading…
Reference in a new issue