From 403f09a4f531087dbc407016cfdd241fe55c07ce Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Thu, 4 Nov 2021 11:17:26 +0100 Subject: [PATCH] add --- _admin.php | 52 +++++++++++++++++++++++++++++----------------- js/admin.js | 21 +++++++++++++++++++ locales/fr/main.po | 14 +++++++++---- 3 files changed, 64 insertions(+), 23 deletions(-) create mode 100644 js/admin.js diff --git a/_admin.php b/_admin.php index 2f7cf51..900fc05 100644 --- a/_admin.php +++ b/_admin.php @@ -1,16 +1,15 @@ 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 '
' . __('There is no module to tweak') . '
' . ''; @@ -102,7 +111,7 @@ class tweakStoresBehaviors __('You must configure zip file pattern to complete xml code automatically.') ); } else { - echo + echo '
' . '

' . __('Generate xml code') . '

' . '

' . __('This helps to generate content of dcstore.xml for seleted module.') . '

' . @@ -114,7 +123,7 @@ class tweakStoresBehaviors '
'; } if (!empty($_POST['buildxml_id'])) { - echo + echo '
' . '

' . sprintf(__('Generated code for module: %s'), html::escapeHTML($_POST['buildxml_id'])) . '

'; @@ -131,20 +140,24 @@ class tweakStoresBehaviors echo '
' . form::textArea('gen_xml', 165, 14, html::escapeHTML(str_replace('><', ">\n<", $xml_content)), 'maximal') . '
'; - 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 '

' . - form::password(['your_pwd', 'your_pwd2'], 20, 255, + form::password( + ['your_pwd', 'your_pwd2'], + 20, + 255, [ 'extra_html' => 'required placeholder="' . __('Password') . '"', 'autocomplete' => 'current-password' ] ) . '

' . - '

' . - form::hidden('buildxml_id', $_POST['buildxml_id']) . + '

' . + '' . __('Copy to clipboard') . '' . + form::hidden('buildxml_id', $_POST['buildxml_id']) . $core->formNonce() . '

'; } echo sprintf( @@ -156,20 +169,21 @@ class tweakStoresBehaviors echo '
'; } - echo + echo ''; } # 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; } -} \ No newline at end of file +} diff --git a/js/admin.js b/js/admin.js new file mode 100644 index 0000000..dff1a0b --- /dev/null +++ b/js/admin.js @@ -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); + } +}); \ No newline at end of file diff --git a/locales/fr/main.po b/locales/fr/main.po index c087656..8afb075 100644 --- a/locales/fr/main.po +++ b/locales/fr/main.po @@ -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."