From 08b8f43df92117b778ca02f19b1251122955f580 Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Tue, 28 Sep 2021 00:45:10 +0200 Subject: [PATCH] enhance interface --- _admin.php | 115 ++++++++++++++++++++++++----------------------------- 1 file changed, 51 insertions(+), 64 deletions(-) diff --git a/_admin.php b/_admin.php index 39626cc..54ce2ed 100644 --- a/_admin.php +++ b/_admin.php @@ -1,15 +1,15 @@ blog->settings->tweakStores->file_pattern; $combo = self::comboModules($modules, $excludes); + # zip file url pattern + $file_pattern = $core->blog->settings->tweakStores->file_pattern; + # 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); @@ -75,11 +77,17 @@ class tweakStoresBehaviors } } } - echo '
' . '

' . __('Tweak third-party repositories') . '

'; + if (!empty($_POST['write_xml'])) { + if ($core->error->flag()) { + echo '

' . implode(' ', $core->error->getErrors()) . '

'; + } else { + echo '

' . __('File successfully write') . '

'; + } + } if (count($combo) < 2) { echo '
' . __('There are no module to tweak') . '
' . @@ -87,65 +95,44 @@ class tweakStoresBehaviors return; } -/* - echo - '
' . - '

' . __('Update an existing module') . '

' . - '

' . __('Put URL to a dcstore.xml file for selected module to update it.') . '

' . - '

' . - form::combo('xml_id', $combo) . - '

' . - '

' . - form::field('xml_url', 40, 255, [ - 'extra_html' => 'required placeholder="' . __('URL') . '"' - ]) . - '

' . - '

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

' . - '

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

' . - '
'; -//*/ - echo - '
' . - '

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

' . - '

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

' . - '

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

' . - '

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

' . - '
'; - + if (empty($file_pattern)) { + echo sprintf( + '

%s

', + $core->adminurl->get('admin.plugins', ['module' => 'tweakStores', 'conf' => 1, 'redir' => $page_url]), + __('You must configure zip file pattern to complete xml code automaticaly.') + ); + } else { + echo + '
' . + '

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

' . + '

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

' . + '

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

' . + '

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

' . + '
'; + } if (!empty($_POST['buildxml_id'])) { echo '
' . '

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

'; if (!empty(tweakStores::$failed)) { - echo sprintf('
' . __('Failed to parse XML code : %s') . '
', implode(', ', tweakStores::$failed)); + echo '

' . sprintf(__('Failed to parse XML code: %s'), implode(', ', tweakStores::$failed)) . '

'; } if (!empty(tweakStores::$notice)) { - echo sprintf('
' . __('Code is not fully filled : %s') . '
', implode(', ', tweakStores::$notice)); + echo '

' . sprintf(__('Code is not fully filled: %s'), implode(', ', tweakStores::$notice)) . '

'; } if (!empty($xml_content)) { if (empty(tweakStores::$failed) && empty(tweakStores::$notice)) { - echo '
' . __('Code is complete') . '
'; + echo '

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

'; } echo - '
' . form::textArea('gen_xml', 165, 14, html::escapeHTML($xml_content), 'maximal') . '
'; + '
' . form::textArea('gen_xml', 165, 14, html::escapeHTML(str_replace('><', ">\n<", $xml_content)), 'maximal') . '
'; if (!empty($file_pattern) && $modules[$_POST['buildxml_id']]['root_writable'] && $core->auth->isSuperAdmin()) { - if ($core->error->flag()) { - echo '
' . implode(' ', $core->error->getErrors()) . '
'; - } elseif (!empty($_POST['write_xml'])) { - echo '
' . __('File successfully write') . '
'; - } + echo '

' . form::password(['your_pwd', 'your_pwd2'], 20, 255, @@ -155,19 +142,19 @@ class tweakStoresBehaviors ] ) . '

' . '

' . - form::hidden('buildxml_id', $_POST['buildxml_id']); + form::hidden('buildxml_id', $_POST['buildxml_id']) . + $core->formNonce() . '

'; } + echo sprintf( + '

%s

', + $core->adminurl->get('admin.plugins', ['module' => 'tweakStores', 'conf' => 1, 'redir' => $page_url]), + __('You can edit zip file pattern from configuration page.') + ); } echo - '

' . $core->formNonce() . '

' . '
'; } echo - '

' . - (empty($file_pattern) ? - __('You must configure zip file pattern to complete xml code automaticaly.') : - __('You can edit zip file pattern from configuration page.') - ). '

' . '
'; }