From ab404f50d51c9f465eb7b0c13ab654fb23fabac7 Mon Sep 17 00:00:00 2001 From: Florian Schmitt Date: Tue, 10 Dec 2024 09:49:30 +0300 Subject: [PATCH] fix(generateModel): 4.5 compatibility for lists --- actions/generateModelAction.php | 1 + javascripts/ferme-import.js | 265 +++++++++++++++++++++----------- 2 files changed, 172 insertions(+), 94 deletions(-) diff --git a/actions/generateModelAction.php b/actions/generateModelAction.php index 64ec9e7..c1ab848 100755 --- a/actions/generateModelAction.php +++ b/actions/generateModelAction.php @@ -124,6 +124,7 @@ public function generateSqlModel($data) $pages = json_decode(html_entity_decode($data['wiki-import-pages']), 1); if (is_array($pages) && !empty($pages)) { + $tabpages = []; $sql .= '# YesWiki pages' . "\n"; foreach ($pages as $page) { // remove hardcoded source urls in pages diff --git a/javascripts/ferme-import.js b/javascripts/ferme-import.js index 909d6b5..c7cdc99 100644 --- a/javascripts/ferme-import.js +++ b/javascripts/ferme-import.js @@ -24,136 +24,213 @@ $(document).ready(function () { var url = $('#url-import').val(); // expression réguliere pour trouver une url valide - var rgHttpUrl = new RegExp(/((([A-Za-z]{3,9}:(?:\/\/)?)(?:[\-;:&=\+\$,\w]+@)?[A-Za-z0-9\.\-]+|(?:www\.|[\-;:&=\+\$,\w]+@)[A-Za-z0-9\.\-]+)((?:\/[\+~%\/\.\w\-_]*)?\??(?:[\-\+=&;%@\.\w_]*)#?(?:[\.\!\/\\\w]*))?)/, 'i'); - + var rgHttpUrl = new RegExp( + /((([A-Za-z]{3,9}:(?:\/\/)?)(?:[\-;:&=\+\$,\w]+@)?[A-Za-z0-9\.\-]+|(?:www\.|[\-;:&=\+\$,\w]+@)[A-Za-z0-9\.\-]+)((?:\/[\+~%\/\.\w\-_]*)?\??(?:[\-\+=&;%@\.\w_]*)#?(?:[\.\!\/\\\w]*))?)/, + 'i', + ); + // on formate l url pour acceder au service json de yeswiki url = url.split('/wakka.php'); url = url[0].split('/index.php'); url = url[0].split('/?'); url = url[0].replace(/\/+$/g, '') + '/'; - - if (rgHttpUrl.test(url)) { + if (rgHttpUrl.test(url)) { // formulaires - $results.append('
' - + '' + $translate.loading + '... ' - + $translate.recuperation + ' ' + url - + '
'); + $results.append( + '
' + + '' + + $translate.loading + + '... ' + + $translate.recuperation + + ' ' + + url + + '
', + ); $.ajax({ method: 'GET', url: url + '?BazaR/json&demand=forms', - }).done(function (data) { - $results.find('.loading').remove(); - var count = 0; - $('#wiki-import-forms').val(htmlEntities(JSON.stringify(data))); - var output = ''; - for (var form in data) { - if (data.hasOwnProperty(form)) { - count++; - output += data[form].bn_label_nature + '
'; + }) + .done(function (data) { + $results.find('.loading').remove(); + var count = 0; + $('#wiki-import-forms').val(htmlEntities(JSON.stringify(data))); + var output = ''; + for (var form in data) { + if (data.hasOwnProperty(form)) { + count++; + output += data[form].bn_label_nature + '
'; + } } - } - $results.append('
' - + $translate.nbformsfound + ' : ' + count + '
' + output - + '

'); - }).fail(function (jqXHR, textStatus, errorThrown) { - $results.append('
' + $translate.noanswers + '.
'); - }); + $results.append( + '
' + + $translate.nbformsfound + + ' : ' + + count + + '
' + + output + + '

', + ); + }) + .fail(function (jqXHR, textStatus, errorThrown) { + $results.append( + '
' + + $translate.noanswers + + '.
', + ); + }); // listes - $results.append('
' - + '' + $translate.loading + '... ' - + $translate.recuperation + ' ' + url - + '
'); + $results.append( + '
' + + '' + + $translate.loading + + '... ' + + $translate.recuperation + + ' ' + + url + + '
', + ); $.ajax({ method: 'GET', url: url + '?BazaR/json&demand=lists', - }).done(function (data) { - $results.find('.loading').remove(); - var count = 0; - $('#wiki-import-lists').val(htmlEntities(JSON.stringify(data))); - var output = ''; - for (var list in data) { - if (data.hasOwnProperty(list)) { - count++; - output += data[list].titre_liste + '
'; + }) + .done(function (data) { + $results.find('.loading').remove(); + var count = 0; + $('#wiki-import-lists').val(htmlEntities(JSON.stringify(data))); + var output = ''; + for (var list in data) { + if (data.hasOwnProperty(list)) { + count++; + output += data[list].titre_liste ?? data[list].title + '
'; + } } - } - $results.append('
' - + $translate.nblistsfound + ' : ' + count + '
' + output - + '

'); - }).fail(function (jqXHR, textStatus, errorThrown) { - $results.append('
' - + $translate.noanswers + '.
'); - }); + $results.append( + '
' + + $translate.nblistsfound + + ' : ' + + count + + '
' + + output + + '

', + ); + }) + .fail(function (jqXHR, textStatus, errorThrown) { + $results.append( + '
' + + $translate.noanswers + + '.
', + ); + }); // fiches - $results.append('
' - + '' + $translate.loading + '... ' - + $translate.recuperation + ' ' + url - + '
'); + $results.append( + '
' + + '' + + $translate.loading + + '... ' + + $translate.recuperation + + ' ' + + url + + '
', + ); $.ajax({ method: 'GET', url: url + '?api/entries', - }).done(function (data) { - $results.find('.loading').remove(); - var count = 0; - $('#wiki-import-entries').val(htmlEntities(JSON.stringify(data))); - var output = ''; - for (var item in data) { - if (data.hasOwnProperty(item)) { - count++; - output += data[item].bf_titre + '
'; + }) + .done(function (data) { + $results.find('.loading').remove(); + var count = 0; + $('#wiki-import-entries').val(htmlEntities(JSON.stringify(data))); + var output = ''; + for (var item in data) { + if (data.hasOwnProperty(item)) { + count++; + output += data[item].bf_titre + '
'; + } } - } - $results.append('
' - + $translate.nbentriesfound + ' : ' + count + '
' + output - + '

'); - }).fail(function (jqXHR, textStatus, errorThrown) { - $results.append('
' - + $translate.noanswers + '.
'); - }); + $results.append( + '
' + + $translate.nbentriesfound + + ' : ' + + count + + '
' + + output + + '

', + ); + }) + .fail(function (jqXHR, textStatus, errorThrown) { + $results.append( + '
' + + $translate.noanswers + + '.
', + ); + }); // pages - $results.append('
' - + '' + $translate.loading + '... ' - + $translate.recuperation + ' ' + url - + '
'); + $results.append( + '
' + + '' + + $translate.loading + + '... ' + + $translate.recuperation + + ' ' + + url + + '
', + ); $.ajax({ method: 'GET', url: url + '?BazaR/json&demand=pages', - }).done(function (data) { - $results.find('.loading').remove(); - var count = 0; - $('#wiki-import-pages').val(htmlEntities(JSON.stringify(data))); - var output = ''; - for (var page in data) { - if (data.hasOwnProperty(page)) { - count++; - output += data[page].tag + '
'; + }) + .done(function (data) { + $results.find('.loading').remove(); + var count = 0; + $('#wiki-import-pages').val(htmlEntities(JSON.stringify(data))); + var output = ''; + for (var page in data) { + if (data.hasOwnProperty(page)) { + count++; + output += data[page].tag + '
'; + } } - } - $results.append('
' - + $translate.nbpagesfound + ' : ' + count + '
' + output - + '

'); - }).fail(function (jqXHR, textStatus, errorThrown) { - $results.append('
' - + $translate.noanswers + '.
'); - }); + $results.append( + '
' + + $translate.nbpagesfound + + ' : ' + + count + + '
' + + output + + '

', + ); + }) + .fail(function (jqXHR, textStatus, errorThrown) { + $results.append( + '
' + + $translate.noanswers + + '.
', + ); + }); } else { - $results.append('
' - + $translate.notvalidurl + ' : ' + url - + '
'); + $results.append( + '
' + + $translate.notvalidurl + + ' : ' + + url + + '
', + ); } - $results.prepend(''); + $results.prepend( + '', + ); return false; }); -}); +}); \ No newline at end of file