diff --git a/_admin.php b/_admin.php index 900fc05..a45a6e8 100644 --- a/_admin.php +++ b/_admin.php @@ -36,6 +36,12 @@ $core->addBehavior('themesToolsTabs', ['tweakStoresBehaviors', 'themesToolsTabs' class tweakStoresBehaviors { + # create dcstore.xml file on the fly when pack a module + public static function packmanBeforeCreatePackage(dcCore $core, $module) + { + tweakStores::writeXML($module['id'], $module, $core->blog->settings->tweakStores->file_pattern); + } + # addd some js public static function modulesToolsHeaders(dcCore $core, $plugin) { @@ -44,12 +50,6 @@ class tweakStoresBehaviors 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) - { - tweakStores::writeXML($module['id'], $module, $core->blog->settings->tweakStores->file_pattern); - } - # admin plugins page tab public static function pluginsToolsTabs(dcCore $core) { @@ -70,6 +70,32 @@ class tweakStoresBehaviors # zip file url pattern $file_pattern = $core->blog->settings->tweakStores->file_pattern; + # check dcstore repo + $file_content = ''; + if (!empty($_POST['checkxml_id']) && in_array($_POST['checkxml_id'], $combo)) { + if (empty($modules[$_POST['checkxml_id']]['repository'])) { + $file_content = __('This module has no repository set in its _define.php file.'); + } else { + try { + if (function_exists('curl_init')) { + $ch = curl_init(); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); + curl_setopt($ch, CURLOPT_HEADER, false); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); + curl_setopt($ch, CURLOPT_URL, $modules[$_POST['checkxml_id']]['repository']); + curl_setopt($ch, CURLOPT_REFERER, $modules[$_POST['checkxml_id']]['repository']); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); + $file_content = curl_exec($ch); + curl_close($ch); + } else { + $file_content = file_get_contents($modules[$_POST['checkxml_id']]['repository']); + } + } catch (Exception $e) { + $file_content = __('Failed to read third party repository'); + } + } + } + # generate xml code if (!empty($_POST['buildxml_id']) && in_array($_POST['buildxml_id'], $combo)) { $xml_content = tweakStores::generateXML($_POST['buildxml_id'], $modules[$_POST['buildxml_id']], $file_pattern); @@ -104,9 +130,33 @@ class tweakStoresBehaviors return; } + + echo + '
' . + '

' . __('Check repository') . '

' . + '

' . __('This checks if dcstore.xml file is present on third party repository.') . '

' . + '

' . + form::combo('checkxml_id', $combo, empty($_POST['checkxml_id']) ? '-' : html::escapeHTML($_POST['checkxml_id'])) . + '

' . + '

' . + $core->formNonce() . '

' . + '
'; + + if (!empty($file_content)) { + echo + '
' . + '

' . __('Repositiory contents') . '

' . + '
' . form::textArea('file_xml', 165, 14, [
+                'default'    => html::escapeHTML(str_replace('><', ">\n<", $file_content)),
+                'class'      => 'maximal',
+                'extra_html' => 'readonly="true"'
+            ]) . '
' . + '
'; + } + if (empty($file_pattern)) { echo sprintf( - '

%s

', + '

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

%s

', $core->adminurl->get('admin.plugins', ['module' => 'tweakStores', 'conf' => 1, 'redir' => $page_url]), __('You must configure zip file pattern to complete xml code automatically.') ); @@ -138,7 +188,11 @@ class tweakStoresBehaviors echo '

' . __('Code is complete') . '

'; } echo - '
' . form::textArea('gen_xml', 165, 14, html::escapeHTML(str_replace('><', ">\n<", $xml_content)), 'maximal') . '
'; + '
' . form::textArea('gen_xml', 165, 14, [
+                    'default'    => html::escapeHTML(str_replace('><', ">\n<", $xml_content)),
+                    'class'      => 'maximal',
+                    'extra_html' => 'readonly="true"'
+                ]) . '
'; if (empty(tweakStores::$failed) && $modules[$_POST['buildxml_id']]['root_writable'] diff --git a/locales/fr/main.po b/locales/fr/main.po index 8afb075..237dfc0 100644 --- a/locales/fr/main.po +++ b/locales/fr/main.po @@ -3,7 +3,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Project-Id-Version: tweakStores 0.2.0\n" "POT-Creation-Date: \n" -"PO-Revision-Date: 2021-11-04T10:06:45+00:00\n" +"PO-Revision-Date: 2021-11-04T23:40:14+00:00\n" "Last-Translator: Jean-Christian Denis\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -13,6 +13,12 @@ msgstr "" msgid "Copied to clipboard" msgstr "Copié dans le presse-papier" +msgid "This module has no repository set in its _define.php file." +msgstr "Ce module n'a aucun dépôt tiers définie dans son fichier _define.php" + +msgid "Failed to read third party repository" +msgstr "Impossible de lire le dépôt tiers" + msgid "Tweak third-party repositories" msgstr "Gestion de dépôts tiers" @@ -22,18 +28,27 @@ 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 "This checks if dcstore.xml file is present on third party repository." +msgstr "Ceci vérifie la présence du fichier dcstore.xml sur le dépôt tiers." + +msgid "Module to parse:" +msgstr "Module à traiter :" + +msgid "Check" +msgstr "Obtenir" + +msgid "Repositiory contents" +msgstr "Contenu du dépôts tiers" msgid "Generate xml code" msgstr "Générer le code XML" +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 "This helps to generate content of dcstore.xml for seleted module." msgstr "Ceci aide à générer le contenu du fichier dcstore.xml pour le module selectionné." -msgid "Module to parse:" -msgstr "Module à traiter :" - msgid "Generate" msgstr "Générer"