diff --git a/src/BackendBehaviors.php b/src/BackendBehaviors.php index cfdb8a3..55f0309 100644 --- a/src/BackendBehaviors.php +++ b/src/BackendBehaviors.php @@ -14,20 +14,22 @@ declare(strict_types=1); namespace Dotclear\Plugin\tweakStores; -/* dotclear ns */ use dcCore; use dcModuleDefine; use dcModules; use dcPage; - -/* clearbricks ns */ -use files; -use form; -use html; -use text; -use xmlTag; - -/* php ns */ +use Dotclear\Helper\File\Files; +use Dotclear\Helper\Html\Form\{ + Hidden, + Label, + Para, + Password, + Select, + Textarea +}; +use Dotclear\Helper\Html\Html; +use Dotclear\Helper\Html\XmlTag; +use Dotclear\Helper\Text; use DOMDocument; use Exception; @@ -83,10 +85,10 @@ class BackendBehaviors $module = $modules->getDefine($_POST['ts_id'] ?? '-'); $combo = self::comboModules($modules, $excludes); - $form = '

' . - form::combo('ts_id', $combo, $module->isDefined() ? html::escapeHTML($module->get('id')) : '-') . - '

'; + $form = (new Para())->class('field')->items([ + (new Label(__('Module to parse:')))->for('ts_id')->class('required'), + (new Select('ts_id'))->default($module->isDefined() ? Html::escapeHTML($module->get('id')) : '-')->items($combo), + ])->render(); # check dcstore repo $url = ''; @@ -107,10 +109,10 @@ class BackendBehaviors curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_REFERER, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - $file_content = curl_exec($ch); + $file_content = (string) curl_exec($ch); curl_close($ch); } else { - $file_content = file_get_contents($url); + $file_content = (string) file_get_contents($url); } } catch (Exception $e) { $file_content = __('Failed to read third party repository'); @@ -169,11 +171,14 @@ class BackendBehaviors '

' . $url . '

' . ( empty($file_content) ? '' : - '
' . form::textArea('file_xml', 165, 14, [
-                    'default'    => html::escapeHTML(self::prettyXML($file_content)),
-                    'class'      => 'maximal',
-                    'extra_html' => 'readonly="true"',
-                ]) . '
' . + '
' .
+                    (new Textarea('file_xml', Html::escapeHTML(self::prettyXML($file_content))))
+                    ->cols(165)
+                    ->rows(14)
+                    ->readonly(true)
+                    ->class('maximal')
+                    ->render() .
+                '
' . ( !$user_ui_colorsyntax ? '' : dcPage::jsRunCodeMirror('editor', 'file_xml', 'dotclear', $user_ui_colorsyntax_theme) @@ -201,7 +206,7 @@ class BackendBehaviors if (!empty($_POST['build_xml'])) { echo '
' . - '

' . sprintf(__('Generated code for module: %s'), html::escapeHTML($module->get('id'))) . '

'; + '

' . sprintf(__('Generated code for module: %s'), Html::escapeHTML($module->get('id'))) . '

'; if (!empty(self::$failed)) { echo '

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

'; @@ -214,11 +219,14 @@ class BackendBehaviors echo '

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

'; } echo - '
' . form::textArea('gen_xml', 165, 14, [
-                    'default'    => html::escapeHTML(self::prettyXML($xml_content)),
-                    'class'      => 'maximal',
-                    'extra_html' => 'readonly="true"',
-                ]) . '
' . + '
' .
+                    (new Textarea('gen_xml', Html::escapeHTML(self::prettyXML($xml_content))))
+                    ->cols(165)
+                    ->rows(14)
+                    ->readonly(true)
+                    ->class('maximal')
+                    ->render() .
+                '
' . ( !$user_ui_colorsyntax ? '' : dcPage::jsRunCodeMirror('editor', 'gen_xml', 'dotclear', $user_ui_colorsyntax_theme) @@ -229,19 +237,13 @@ class BackendBehaviors && dcCore::app()->auth->isSuperAdmin() ) { echo - '

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

' . + (new Para())->class('field')->items([ + (new Label(__('Your password:')))->for('your_pwd2')->class('required'), + (new Password(['your_pwd', 'your_pwd2']))->size(20)->maxlenght(255)->required(true)->placeholder(__('Password'))->autocomplete('current-password'), + ])->render() . '

' . '' . __('Copy to clipboard') . '' . - form::hidden('ts_id', $_POST['ts_id']) . + (new Hidden('ts_id', $_POST['ts_id']))->render() . dcCore::app()->formNonce() . '

'; } echo sprintf( @@ -273,7 +275,7 @@ class BackendBehaviors private static function parseFilePattern(dcModuleDefine $module, string $file_pattern): string { - return text::tidyURL(str_replace( + return Text::tidyURL(str_replace( [ '%type%', '%id%', @@ -292,7 +294,7 @@ class BackendBehaviors private static function generateXML(dcModuleDefine $module, string $file_pattern): string { - $rsp = new xmlTag('module'); + $rsp = new XmlTag('module'); self::$notice = []; self::$failed = []; @@ -355,29 +357,29 @@ class BackendBehaviors if (empty($module->get('dc_min'))) { self::$notice[] = 'no minimum dotclear version'; } else { - $rsp->insertNode(new xmlTag('da:dcmin', $module->get('dc_min'))); + $rsp->insertNode(new XmlTag('da:dcmin', $module->get('dc_min'))); } # details if (empty($module->get('details'))) { self::$notice[] = 'no details URL'; } else { - $rsp->insertNode(new xmlTag('da:details', $module->get('details'))); + $rsp->insertNode(new XmlTag('da:details', $module->get('details'))); } # section if (!empty($module->get('section'))) { - $rsp->insertNode(new xmlTag('da:section', $module->get('section'))); + $rsp->insertNode(new XmlTag('da:section', $module->get('section'))); } # support if (empty($module->get('support'))) { self::$notice[] = 'no support URL'; } else { - $rsp->insertNode(new xmlTag('da:support', $module->get('support'))); + $rsp->insertNode(new XmlTag('da:support', $module->get('support'))); } - $res = new xmlTag('modules', $rsp); + $res = new XmlTag('modules', $rsp); $res->insertAttr('xmlns:da', 'http://dotaddict.org/da/'); return self::prettyXML($res->toXML()); @@ -395,7 +397,7 @@ class BackendBehaviors } try { - files::putContent($module->get('root') . DIRECTORY_SEPARATOR . 'dcstore.xml', $content); + Files::putContent($module->get('root') . DIRECTORY_SEPARATOR . 'dcstore.xml', $content); } catch (Exception $e) { self::$failed[] = $e->getMessage(); diff --git a/src/Config.php b/src/Config.php index ac36b9b..ad945cc 100644 --- a/src/Config.php +++ b/src/Config.php @@ -14,7 +14,6 @@ declare(strict_types=1); namespace Dotclear\Plugin\tweakStores; -/* dotclear ns */ use dcCore; use dcNsProcess; use dcPage; @@ -28,8 +27,6 @@ use Dotclear\Helper\Html\Form\{ Note, Para }; - -/* php ns */ use Exception; class Config extends dcNsProcess @@ -94,7 +91,7 @@ class Config extends dcNsProcess // s_file_pattern (new Para())->items([ (new Label(__('Predictable URL to zip file on the external repository')))->for('ts_file_pattern'), - (new Input('ts_file_pattern'))->size(65)->maxlenght(255)->value($s->file_pattern), + (new Input('ts_file_pattern'))->size(65)->maxlenght(255)->class('maximal')->value($s->file_pattern), ]), (new Note())->text(__('You can use widcard like %author%, %type%, %id%, %version%.'))->class('form-note'), (new Note())->text(__('For example on github https://github.com/MyGitName/%id%/releases/download/v%version%/%type%-%id%.zip'))->class('form-note'),