master
Jean-Christian Paul Denis 2021-11-04 11:17:26 +01:00
parent 540872a178
commit 403f09a4f5
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
3 changed files with 64 additions and 23 deletions

View File

@ -1,16 +1,15 @@
<?php
/**
* @brief tweakStores, a plugin for Dotclear 2
*
*
* @package Dotclear
* @subpackage Plugin
*
*
* @author Jean-Christian Denis and Contributors
*
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_CONTEXT_ADMIN')) {
return null;
}
@ -30,11 +29,21 @@ if (!$core->blog->settings->tweakStores->active) {
if ($core->blog->settings->tweakStores->packman) {
$core->addBehavior('packmanBeforeCreatePackage', ['tweakStoresBehaviors', 'packmanBeforeCreatePackage']);
}
$core->addBehavior('pluginsToolsHeaders', ['tweakStoresBehaviors', 'modulesToolsHeaders']);
$core->addBehavior('themesToolsHeaders', ['tweakStoresBehaviors', 'modulesToolsHeaders']);
$core->addBehavior('pluginsToolsTabs', ['tweakStoresBehaviors', 'pluginsToolsTabs']);
$core->addBehavior('themesToolsTabs', ['tweakStoresBehaviors', 'themesToolsTabs']);
class tweakStoresBehaviors
{
# addd some js
public static function modulesToolsHeaders(dcCore $core, $plugin)
{
return
dcPage::jsVars(['dotclear.ts_copied' => __('Copied to clipboard')]) .
dcPage::jsLoad(dcPage::getPF('tweakStores/js/admin.js'));
}
# create dcstore.xml file on the fly when pack a module
public static function packmanBeforeCreatePackage(dcCore $core, $module)
{
@ -44,13 +53,13 @@ class tweakStoresBehaviors
# admin plugins page tab
public static function pluginsToolsTabs(dcCore $core)
{
self::modulesToolsTabs($core, $core->plugins->getModules(), explode(',', DC_DISTRIB_PLUGINS), $core->adminurl->get('admin.plugins').'#tweakStores');
self::modulesToolsTabs($core, $core->plugins->getModules(), explode(',', DC_DISTRIB_PLUGINS), $core->adminurl->get('admin.plugins') . '#tweakStores');
}
# admin themes page tab
public static function themesToolsTabs(dcCore $core)
{
self::modulesToolsTabs($core, $core->themes->getModules(), explode(',', DC_DISTRIB_THEMES), $core->adminurl->get('admin.blog.theme').'#tweakStores');
self::modulesToolsTabs($core, $core->themes->getModules(), explode(',', DC_DISTRIB_THEMES), $core->adminurl->get('admin.blog.theme') . '#tweakStores');
}
# generic page tab
@ -89,7 +98,7 @@ class tweakStoresBehaviors
}
}
if (count($combo) < 2) {
echo
echo
'<div class="info">' . __('There is no module to tweak') . '</div>' .
'</div>';
@ -102,7 +111,7 @@ class tweakStoresBehaviors
__('You must configure zip file pattern to complete xml code automatically.')
);
} else {
echo
echo
'<form method="post" action="' . $page_url . '" id="buildxml" class="fieldset">' .
'<h4>' . __('Generate xml code') . '</h4>' .
'<p>' . __('This helps to generate content of dcstore.xml for seleted module.') . '</p>' .
@ -114,7 +123,7 @@ class tweakStoresBehaviors
'</form>';
}
if (!empty($_POST['buildxml_id'])) {
echo
echo
'<form method="post" action="' . $page_url . '" id="writexml" class="fieldset">' .
'<h4>' . sprintf(__('Generated code for module: %s'), html::escapeHTML($_POST['buildxml_id'])) . '</h4>';
@ -131,20 +140,24 @@ class tweakStoresBehaviors
echo
'<pre>' . form::textArea('gen_xml', 165, 14, html::escapeHTML(str_replace('><', ">\n<", $xml_content)), 'maximal') . '</pre>';
if (empty(tweakStores::$failed)
&& $modules[$_POST['buildxml_id']]['root_writable']
if (empty(tweakStores::$failed)
&& $modules[$_POST['buildxml_id']]['root_writable']
&& $core->auth->isSuperAdmin()
) {
echo
echo
'<p class="field"><label for="your_pwd2" class="classic required"><abbr title="' . __('Required field') . '">*</abbr> ' . __('Your password:') . '</label> ' .
form::password(['your_pwd', 'your_pwd2'], 20, 255,
form::password(
['your_pwd', 'your_pwd2'],
20,
255,
[
'extra_html' => 'required placeholder="' . __('Password') . '"',
'autocomplete' => 'current-password'
]
) . '</p>' .
'<p><input type="submit" name="write_xml" value="' . __('Save to module directory') . '" />' .
form::hidden('buildxml_id', $_POST['buildxml_id']) .
'<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>' .
form::hidden('buildxml_id', $_POST['buildxml_id']) .
$core->formNonce() . '</p>';
}
echo sprintf(
@ -156,20 +169,21 @@ class tweakStoresBehaviors
echo
'</form>';
}
echo
echo
'</div>';
}
# create list of module for combo and remove official modules
protected static function comboModules($modules, array $excludes)
{
$combo = [ __('Select a module') => '0'];
$combo = [__('Select a module') => '0'];
foreach ($modules as $id => $module) {
if (in_array($id, $excludes)) {
continue;
}
$combo[$module['name'] . ' '. $module['version']] = $id;
$combo[$module['name'] . ' ' . $module['version']] = $id;
}
return $combo;
}
}
}

21
js/admin.js 100644
View File

@ -0,0 +1,21 @@
/*global $, dotclear */
'use strict';
$(function(){
$("#ts_copy_button").click(function() {
tsCopy("#gen_xml");
return false;
});
function tsCopy(element_id) {
$(element_id).attr("contenteditable", true)
.select()
.on("focus", function() {
document.execCommand('selectAll', false, null)
})
.focus()
document.execCommand("Copy");
$(element_id).removeAttr("contenteditable");
alert(dotclear.ts_copied);
}
});

View File

@ -1,15 +1,18 @@
msgid ""
msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Project-Id-Version: tweakStores 0.1.0\n"
"Project-Id-Version: tweakStores 0.2.0\n"
"POT-Creation-Date: \n"
"PO-Revision-Date: 2021-09-27T22:20:49+00:00\n"
"PO-Revision-Date: 2021-11-04T10:06:45+00:00\n"
"Last-Translator: Jean-Christian Denis\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
msgid "Copied to clipboard"
msgstr "Copié dans le presse-papier"
msgid "Tweak third-party repositories"
msgstr "Gestion de dépôts tiers"
@ -19,6 +22,9 @@ msgstr "Fichier enregistré avec succès"
msgid "There is no module to tweak"
msgstr "Il n'y a pas de module à gérer"
msgid "You must configure zip file pattern to complete xml code automatically."
msgstr "Vous devez configurer le modèle de fichier zip pour compléter le code XML automatiquement."
msgid "Generate xml code"
msgstr "Générer le code XML"
@ -46,8 +52,8 @@ msgstr "Le code est complet"
msgid "Save to module directory"
msgstr "Enregistrer dans le répertoire du module"
msgid "You must configure zip file pattern to complete xml code automatically."
msgstr "Vous devez configurer le modèle de fichier zip pour compléter le code XML automatiquement."
msgid "Copy to clipboard"
msgstr "Copier dans le presse-papier"
msgid "You can edit zip file pattern from configuration page."
msgstr "Vous pouvez modifier le modèle de fichier zip sur la page de configuration."