Skip to content

Commit

Permalink
fix(generateModel): 4.5 compatibility for lists
Browse files Browse the repository at this point in the history
  • Loading branch information
mrflos committed Dec 10, 2024
1 parent 39be761 commit ab404f5
Show file tree
Hide file tree
Showing 2 changed files with 172 additions and 94 deletions.
1 change: 1 addition & 0 deletions actions/generateModelAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
265 changes: 171 additions & 94 deletions javascripts/ferme-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('<div class="loading alert alert-info">'
+ '<span class="throbber">' + $translate.loading + '...</span> '
+ $translate.recuperation + ' ' + url
+ '</div>');
$results.append(
'<div class="loading alert alert-info">' +
'<span class="throbber">' +
$translate.loading +
'...</span> ' +
$translate.recuperation +
' ' +
url +
'</div>',
);
$.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 + '<br>';
})
.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 + '<br>';
}
}
}

$results.append('<h5>'
+ $translate.nbformsfound + ' : ' + count + '</h5><div class="cols3">' + output
+ '</div><hr>');
}).fail(function (jqXHR, textStatus, errorThrown) {
$results.append('<div class="alert alert-danger">' + $translate.noanswers + '.</div>');
});
$results.append(
'<h5>' +
$translate.nbformsfound +
' : ' +
count +
'</h5><div class="cols3">' +
output +
'</div><hr>',
);
})
.fail(function (jqXHR, textStatus, errorThrown) {
$results.append(
'<div class="alert alert-danger">' +
$translate.noanswers +
'.</div>',
);
});

// listes
$results.append('<div class="loading alert alert-info">'
+ '<span class="throbber">' + $translate.loading + '...</span> '
+ $translate.recuperation + ' ' + url
+ '</div>');
$results.append(
'<div class="loading alert alert-info">' +
'<span class="throbber">' +
$translate.loading +
'...</span> ' +
$translate.recuperation +
' ' +
url +
'</div>',
);
$.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 + '<br>';
})
.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 + '<br>';
}
}
}

$results.append('<h5>'
+ $translate.nblistsfound + ' : ' + count + '</h5><div class="cols3">' + output
+ '</div><hr>');
}).fail(function (jqXHR, textStatus, errorThrown) {
$results.append('<div class="alert alert-danger">'
+ $translate.noanswers + '.</div>');
});
$results.append(
'<h5>' +
$translate.nblistsfound +
' : ' +
count +
'</h5><div class="cols3">' +
output +
'</div><hr>',
);
})
.fail(function (jqXHR, textStatus, errorThrown) {
$results.append(
'<div class="alert alert-danger">' +
$translate.noanswers +
'.</div>',
);
});

// fiches
$results.append('<div class="loading alert alert-info">'
+ '<span class="throbber">' + $translate.loading + '...</span> '
+ $translate.recuperation + ' ' + url
+ '</div>');
$results.append(
'<div class="loading alert alert-info">' +
'<span class="throbber">' +
$translate.loading +
'...</span> ' +
$translate.recuperation +
' ' +
url +
'</div>',
);
$.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 + '<br>';
})
.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 + '<br>';
}
}
}

$results.append('<h5>'
+ $translate.nbentriesfound + ' : ' + count + '</h5><div class="cols3">' + output
+ '</div><hr>');
}).fail(function (jqXHR, textStatus, errorThrown) {
$results.append('<div class="alert alert-danger">'
+ $translate.noanswers + '.</div>');
});
$results.append(
'<h5>' +
$translate.nbentriesfound +
' : ' +
count +
'</h5><div class="cols3">' +
output +
'</div><hr>',
);
})
.fail(function (jqXHR, textStatus, errorThrown) {
$results.append(
'<div class="alert alert-danger">' +
$translate.noanswers +
'.</div>',
);
});

// pages
$results.append('<div class="loading alert alert-info">'
+ '<span class="throbber">' + $translate.loading + '...</span> '
+ $translate.recuperation + ' ' + url
+ '</div>');
$results.append(
'<div class="loading alert alert-info">' +
'<span class="throbber">' +
$translate.loading +
'...</span> ' +
$translate.recuperation +
' ' +
url +
'</div>',
);
$.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 + '<br>';
})
.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 + '<br>';
}
}
}

$results.append('<h5>'
+ $translate.nbpagesfound + ' : ' + count + '</h5><div class="cols3">' + output
+ '</div><hr>');
}).fail(function (jqXHR, textStatus, errorThrown) {
$results.append('<div class="alert alert-danger">'
+ $translate.noanswers + '.</div>');
});
$results.append(
'<h5>' +
$translate.nbpagesfound +
' : ' +
count +
'</h5><div class="cols3">' +
output +
'</div><hr>',
);
})
.fail(function (jqXHR, textStatus, errorThrown) {
$results.append(
'<div class="alert alert-danger">' +
$translate.noanswers +
'.</div>',
);
});
} else {
$results.append('<div class="alert alert-danger">'
+ $translate.notvalidurl + ' : ' + url
+ '</div>');
$results.append(
'<div class="alert alert-danger">' +
$translate.notvalidurl +
' : ' +
url +
'</div>',
);
}

$results.prepend('<button type="submit" class="btn btn-lg btn-block btn-primary">'
+ $translate.generatesqlfile
+ '</button>');
$results.prepend(
'<button type="submit" class="btn btn-lg btn-block btn-primary">' +
$translate.generatesqlfile +
'</button>',
);

return false;
});
});
});

0 comments on commit ab404f5

Please sign in to comment.