From: Kilian Saffran Date: Wed, 2 Dec 2020 06:45:39 +0000 (+0100) Subject: v20201201 X-Git-Url: http://cloud.dks.lu/git/?a=commitdiff_plain;h=393da861334516235de3a66716aa857508a6bbcc;p=oldbell_lu.git v20201201 --- diff --git a/.vscode/snippets.code-snippets b/.vscode/snippets.code-snippets new file mode 100644 index 0000000..e2af45f --- /dev/null +++ b/.vscode/snippets.code-snippets @@ -0,0 +1,120 @@ +{ + "input-hidden": { + "scope":"html", + "prefix":"input-hidden", + "body":[""] + }, + "input-date": { + "scope":"html", + "prefix":"input-date", + "body":["
", + "\t", + "\t", + "
"] + }, + "input-text": { + "scope":"html", + "prefix":"input-text", + "body":["
", + "\t", + "\t", + "
"] + }, + "input-number": { + "scope":"html", + "prefix":"input-number", + "body":["
", + "\t", + "\t", + "
"] +}, + "form":{ + "scope":"html", + "prefix":"form", + "body":"
$0
" + }, + "row": { + "scope":"html", + "prefix":"row", + "body":"
$0
" + }, + "cellrow": { + "scope":"html", + "prefix":"cellrow", + "body":"
$0
" + }, + "panel": { + "scope":"html", + "prefix":"panel", + "body":["
","$0","
"] + }, + "select": { + "scope":"html", + "prefix": "select", + "body":[ + "
", + "\t", + "\t", + "
"] + }, + "textarea": { + "scope":"html", + "prefix":"textarea", + "body":[ + "
", + "\t", + "\t", + "
" + ] + }, + "topbarlistpage":{ + "scope":"html", + "prefix":"topbar-listpage", + "body":["
", + "Home", + "
${1:Page Title}
", + "
", + "\t", + "\t", + "\t", + "\t", + "
", + "
", + "\t", + "
", + "
", + "\t
", + "\t\t", + "\t\t", + "\t\t", + "\t\t ", + "\t
", + "
", + "
"] + }, + "topbarformpage":{ + "scope":"html", + "prefix":"topbar-formpage", + "body": [ + "
", + "\t", + "\t
${2: title}
", + "
"] + } + // Place your oldbell_lu workspace snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and + // description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope + // is left empty or omitted, the snippet gets applied to all languages. The prefix is what is + // used to trigger the snippet and the body will be expanded and inserted. Possible variables are: + // $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. + // Placeholders with the same ids are connected. + // Example: + // "Print to console": { + // "scope": "javascript,typescript", + // "prefix": "log", + // "body": [ + // "console.log('$1');", + // "$2" + // ], + // "description": "Log output to console" + // } +} \ No newline at end of file diff --git a/admin/db.php b/admin/db.php index 582dff7..81e179c 100644 --- a/admin/db.php +++ b/admin/db.php @@ -64,8 +64,14 @@ } } elseif(isset($params["savefield"])){ - db.exec("UPDATE ".$params["table"]." set ".$params["column"]."=".$db->value($params["value"])." where id=".$db->value($params["id"]).";"); + $html["data"] = $db->exec("UPDATE ".$params["table"]." set ".$params["column"]."=".$db->value($params["value"])." where id=".$db->value($params["id"]).";"); } + elseif(isset($params["saveform"])){ + $updsql = $db->createUpdateDDL($params["schema"],$params["table"],$params["idents"],$params["data"]); + $html["sql"] = $updsql; + $html["data"] = $db->exec($updsql); + + } elseif(isset($params["logout"])){ $html["data"] = $sess->deleteSession($vars["sid"]); } diff --git a/admin/img/POT-logo.png b/admin/img/POT-logo.png deleted file mode 100644 index e2c8028..0000000 Binary files a/admin/img/POT-logo.png and /dev/null differ diff --git a/admin/img/appicon.png b/admin/img/appicon.png new file mode 100644 index 0000000..1c7c093 Binary files /dev/null and b/admin/img/appicon.png differ diff --git a/admin/img/bg1.jpg b/admin/img/bg1.jpg deleted file mode 100644 index 80c5326..0000000 Binary files a/admin/img/bg1.jpg and /dev/null differ diff --git a/admin/img/favicon/android-icon-144x144.png b/admin/img/favicon/android-icon-144x144.png index 7fbdb59..8df528c 100644 Binary files a/admin/img/favicon/android-icon-144x144.png and b/admin/img/favicon/android-icon-144x144.png differ diff --git a/admin/img/favicon/android-icon-192x192.png b/admin/img/favicon/android-icon-192x192.png index 01c2cfc..a8b9976 100644 Binary files a/admin/img/favicon/android-icon-192x192.png and b/admin/img/favicon/android-icon-192x192.png differ diff --git a/admin/img/favicon/android-icon-36x36.png b/admin/img/favicon/android-icon-36x36.png index c5144c1..09ba178 100644 Binary files a/admin/img/favicon/android-icon-36x36.png and b/admin/img/favicon/android-icon-36x36.png differ diff --git a/admin/img/favicon/android-icon-48x48.png b/admin/img/favicon/android-icon-48x48.png index e515672..c61b749 100644 Binary files a/admin/img/favicon/android-icon-48x48.png and b/admin/img/favicon/android-icon-48x48.png differ diff --git a/admin/img/favicon/android-icon-72x72.png b/admin/img/favicon/android-icon-72x72.png index bde7f5f..3f90064 100644 Binary files a/admin/img/favicon/android-icon-72x72.png and b/admin/img/favicon/android-icon-72x72.png differ diff --git a/admin/img/favicon/android-icon-96x96.png b/admin/img/favicon/android-icon-96x96.png index af43b21..40c5797 100644 Binary files a/admin/img/favicon/android-icon-96x96.png and b/admin/img/favicon/android-icon-96x96.png differ diff --git a/admin/img/favicon/apple-icon-114x114.png b/admin/img/favicon/apple-icon-114x114.png index 12f42e1..da605c2 100644 Binary files a/admin/img/favicon/apple-icon-114x114.png and b/admin/img/favicon/apple-icon-114x114.png differ diff --git a/admin/img/favicon/apple-icon-120x120.png b/admin/img/favicon/apple-icon-120x120.png index cababd5..2ca25ed 100644 Binary files a/admin/img/favicon/apple-icon-120x120.png and b/admin/img/favicon/apple-icon-120x120.png differ diff --git a/admin/img/favicon/apple-icon-144x144.png b/admin/img/favicon/apple-icon-144x144.png index 89f9182..8df528c 100644 Binary files a/admin/img/favicon/apple-icon-144x144.png and b/admin/img/favicon/apple-icon-144x144.png differ diff --git a/admin/img/favicon/apple-icon-152x152.png b/admin/img/favicon/apple-icon-152x152.png index 3843942..b7e831c 100644 Binary files a/admin/img/favicon/apple-icon-152x152.png and b/admin/img/favicon/apple-icon-152x152.png differ diff --git a/admin/img/favicon/apple-icon-180x180.png b/admin/img/favicon/apple-icon-180x180.png index 363c190..d2d9272 100644 Binary files a/admin/img/favicon/apple-icon-180x180.png and b/admin/img/favicon/apple-icon-180x180.png differ diff --git a/admin/img/favicon/apple-icon-57x57.png b/admin/img/favicon/apple-icon-57x57.png index 00952f2..9f3ad02 100644 Binary files a/admin/img/favicon/apple-icon-57x57.png and b/admin/img/favicon/apple-icon-57x57.png differ diff --git a/admin/img/favicon/apple-icon-60x60.png b/admin/img/favicon/apple-icon-60x60.png index 60589f6..2321b98 100644 Binary files a/admin/img/favicon/apple-icon-60x60.png and b/admin/img/favicon/apple-icon-60x60.png differ diff --git a/admin/img/favicon/apple-icon-72x72.png b/admin/img/favicon/apple-icon-72x72.png index bde7f5f..3f90064 100644 Binary files a/admin/img/favicon/apple-icon-72x72.png and b/admin/img/favicon/apple-icon-72x72.png differ diff --git a/admin/img/favicon/apple-icon-76x76.png b/admin/img/favicon/apple-icon-76x76.png index 0dedab8..2d9dc55 100644 Binary files a/admin/img/favicon/apple-icon-76x76.png and b/admin/img/favicon/apple-icon-76x76.png differ diff --git a/admin/img/favicon/apple-icon-precomposed.png b/admin/img/favicon/apple-icon-precomposed.png index 01c2cfc..7f064ab 100644 Binary files a/admin/img/favicon/apple-icon-precomposed.png and b/admin/img/favicon/apple-icon-precomposed.png differ diff --git a/admin/img/favicon/apple-icon.png b/admin/img/favicon/apple-icon.png index 01c2cfc..7f064ab 100644 Binary files a/admin/img/favicon/apple-icon.png and b/admin/img/favicon/apple-icon.png differ diff --git a/admin/img/favicon/browserconfig.xml b/admin/img/favicon/browserconfig.xml index 856ab2c..c554148 100644 --- a/admin/img/favicon/browserconfig.xml +++ b/admin/img/favicon/browserconfig.xml @@ -1,2 +1,2 @@ - + #ffffff \ No newline at end of file diff --git a/admin/img/favicon/favicon-16x16.png b/admin/img/favicon/favicon-16x16.png index 82491e2..a9695bc 100644 Binary files a/admin/img/favicon/favicon-16x16.png and b/admin/img/favicon/favicon-16x16.png differ diff --git a/admin/img/favicon/favicon-32x32.png b/admin/img/favicon/favicon-32x32.png index 9a97d71..947a450 100644 Binary files a/admin/img/favicon/favicon-32x32.png and b/admin/img/favicon/favicon-32x32.png differ diff --git a/admin/img/favicon/favicon-96x96.png b/admin/img/favicon/favicon-96x96.png index aa085fe..40c5797 100644 Binary files a/admin/img/favicon/favicon-96x96.png and b/admin/img/favicon/favicon-96x96.png differ diff --git a/admin/img/favicon/favicon.ico b/admin/img/favicon/favicon.ico index c15bc10..f1499f4 100644 Binary files a/admin/img/favicon/favicon.ico and b/admin/img/favicon/favicon.ico differ diff --git a/admin/img/favicon/manifest.json b/admin/img/favicon/manifest.json index dd3947d..013d4a6 100644 --- a/admin/img/favicon/manifest.json +++ b/admin/img/favicon/manifest.json @@ -1,40 +1,41 @@ { - "name": "OldBell", + "name": "App", "icons": [ { - "src": "android-icon-36x36.png", + "src": "\/android-icon-36x36.png", "sizes": "36x36", - "type": "image/png" + "type": "image\/png", + "density": "0.75" }, { - "src": "android-icon-48x48.png", + "src": "\/android-icon-48x48.png", "sizes": "48x48", - "type": "image/png" + "type": "image\/png", + "density": "1.0" }, { - "src": "android-icon-72x72.png", + "src": "\/android-icon-72x72.png", "sizes": "72x72", - "type": "image/png" + "type": "image\/png", + "density": "1.5" }, { - "src": "android-icon-96x96.png", + "src": "\/android-icon-96x96.png", "sizes": "96x96", - "type": "image/png" + "type": "image\/png", + "density": "2.0" }, { - "src": "android-icon-144x144.png", + "src": "\/android-icon-144x144.png", "sizes": "144x144", - "type": "image/png" + "type": "image\/png", + "density": "3.0" }, { - "src": "android-icon-192x192.png", + "src": "\/android-icon-192x192.png", "sizes": "192x192", - "type": "image/png" + "type": "image\/png", + "density": "4.0" } - ], - "lang": "fr-FR", - "start_url": "http://dks-laptop/oldbell_lu/index.html", - "display": "standalone", - "background_color": "white", - "theme_color": "white" + ] } \ No newline at end of file diff --git a/admin/img/favicon/ms-icon-144x144.png b/admin/img/favicon/ms-icon-144x144.png index dabb8ae..8df528c 100644 Binary files a/admin/img/favicon/ms-icon-144x144.png and b/admin/img/favicon/ms-icon-144x144.png differ diff --git a/admin/img/favicon/ms-icon-150x150.png b/admin/img/favicon/ms-icon-150x150.png index 2392f7b..d8758d1 100644 Binary files a/admin/img/favicon/ms-icon-150x150.png and b/admin/img/favicon/ms-icon-150x150.png differ diff --git a/admin/img/favicon/ms-icon-310x310.png b/admin/img/favicon/ms-icon-310x310.png index 156de84..29343d4 100644 Binary files a/admin/img/favicon/ms-icon-310x310.png and b/admin/img/favicon/ms-icon-310x310.png differ diff --git a/admin/img/favicon/ms-icon-70x70.png b/admin/img/favicon/ms-icon-70x70.png index c604174..d8fdee3 100644 Binary files a/admin/img/favicon/ms-icon-70x70.png and b/admin/img/favicon/ms-icon-70x70.png differ diff --git a/admin/img/logo.png b/admin/img/logo.png new file mode 100644 index 0000000..a0061fd Binary files /dev/null and b/admin/img/logo.png differ diff --git a/admin/img/logo1.png b/admin/img/logo1.png new file mode 100644 index 0000000..5570514 Binary files /dev/null and b/admin/img/logo1.png differ diff --git a/admin/img/logo_512.png b/admin/img/logo_512.png deleted file mode 100644 index 37e2068..0000000 Binary files a/admin/img/logo_512.png and /dev/null differ diff --git a/admin/img/oldbell_icon.svg b/admin/img/oldbell_icon.svg new file mode 100644 index 0000000..5f29013 --- /dev/null +++ b/admin/img/oldbell_icon.svg @@ -0,0 +1,257 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/admin/img/oldbell_logo.svg b/admin/img/oldbell_logo.svg new file mode 100644 index 0000000..0e0ca78 --- /dev/null +++ b/admin/img/oldbell_logo.svg @@ -0,0 +1,270 @@ + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/admin/img/oldbell_logo2.svg b/admin/img/oldbell_logo2.svg new file mode 100644 index 0000000..5ceb722 --- /dev/null +++ b/admin/img/oldbell_logo2.svg @@ -0,0 +1,292 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/admin/img/potbg.jpg b/admin/img/potbg.jpg deleted file mode 100644 index 5167072..0000000 Binary files a/admin/img/potbg.jpg and /dev/null differ diff --git a/admin/img/poticon512.png b/admin/img/poticon512.png deleted file mode 100644 index bce391c..0000000 Binary files a/admin/img/poticon512.png and /dev/null differ diff --git a/admin/img/potlogowhite.svg b/admin/img/potlogowhite.svg deleted file mode 100644 index 7c2ec3b..0000000 --- a/admin/img/potlogowhite.svg +++ /dev/null @@ -1,133 +0,0 @@ - -image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/admin/img/pottop.png b/admin/img/pottop.png deleted file mode 100644 index 5f159c5..0000000 Binary files a/admin/img/pottop.png and /dev/null differ diff --git a/admin/img/toplogo.png b/admin/img/toplogo.png deleted file mode 100644 index 37e2068..0000000 Binary files a/admin/img/toplogo.png and /dev/null differ diff --git a/admin/js/dataform.js b/admin/js/dataform.js index 0b9098f..2d8551f 100644 --- a/admin/js/dataform.js +++ b/admin/js/dataform.js @@ -1,19 +1,9 @@ let dataform = { - // saveform: function(frmid){ - // var flds=dataform.getformcontent(frmid,null); - // console.log("TODO: save to db",flds); - // delete flds["null"]; - // return false; - // }, - // saveformdata: function(flds){ - // delete flds["null"]; - // console.log("TODO: save to db",flds); - // return false; - // }, - formsaved: function(data){ + + formsaved: function(msg){ var sb = document.getElementById("snackbar"); sb.className="show green"; - sb.innerHTML = 'Les données ont été sauvegardées!'; + sb.innerHTML = msg; setTimeout(function(){ sb.className = sb.className.replace("show green", ""); }, 3000); return false; }, @@ -25,15 +15,12 @@ let dataform = { } for (var i = 0; i < frm.elements.length; i++) { var field = frm.elements[i]; - if (((field.getAttribute("name") != 'null') && (field.tagName == "INPUT" || field.tagName == "SELECT" || field.tagName == "TEXTAREA")) && (field.id)){ - // if (field.classList.contains("tagedit")){ - // var fvalue=field.value.trim(); - // var ndata = null; - // if (fvalue != ""){ - // ndata = fvalue.split(","); - // } - // flds[field.getAttribute("name")] = ndata; - // } + if ((field.tagName == "INPUT" || field.tagName == "SELECT" || field.tagName == "TEXTAREA") && (field.id)){ + if (field.dataset.table){ + if (!flds[field.dataset.table]){ + flds[field.dataset.table] = {}; + } + } if (field.tagName == "TEXTAREA" ){ if (field.classList.contains("richeditarea")){ flds[field.dataset.table][field.dataset.column] = tinymce.get(field.id).getContent(); @@ -62,7 +49,7 @@ let dataform = { } } else { - console.log("Field",field,field.id, field.value); + //console.log("Field",field,field.id, field.value); flds[field.dataset.table][field.dataset.column] = field.value; } } diff --git a/admin/js/modules/galleries.js b/admin/js/modules/galleries.js index c0ba7a0..064c5a2 100644 --- a/admin/js/modules/galleries.js +++ b/admin/js/modules/galleries.js @@ -21,6 +21,7 @@ let galleries = { }); galleries.gettbldata(); + gallery.init(); }, gettbldata: function(){ postData({"cl":"gallery","fn":"getAll"}).then(data => { diff --git a/admin/js/modules/gallery.js b/admin/js/modules/gallery.js index ded9441..7a0203b 100644 --- a/admin/js/modules/gallery.js +++ b/admin/js/modules/gallery.js @@ -1,3 +1,5 @@ + + let gallery = { id_gallery: null, gallery_folder: null, @@ -11,6 +13,7 @@ let gallery = { postData({"cl":"gallery","fn":"get","id":gallery.id_gallery}).then(data => { console.log("Gallery Data:",data.data); dataform.fillform("galleries",gallery.selects,data.data); + gallery.changeDefaultImage(data.data.picture); gallery.gettabledata(); myapp.viewpanel("gallery"); @@ -44,24 +47,25 @@ let gallery = { importcss_append: true, noneditable_noneditable_class: "mceNonEditable", contextmenu: false, - setup: function(editor) { - editor.on('blur', function(e) { - console.log("tmce blur:",e.target.id); - if (e.target.id == "galleries_description"){ - //dataform.savefield(document.getElementById(e.id)); - console.log("TODO: savefield"); - } - // - //e.id - //console.log('The Editor has initialized.'); - }); - } + // setup: function(editor) { + // editor.on('blur', function(e) { + // console.log("tmce blur:",e.target.id); + // // if (e.target.id == "galleries_description"){ + // // //dataform.savefield(document.getElementById(e.id)); + // // console.log("TODO: savefield"); + // // } + // // + // //e.id + // //console.log('The Editor has initialized.'); + // }); + // } }); gallery.tbl =new Tabulator("#tbl_galleryitems",{ height: "calc(100vh - 60px)", layout: "fitColumns", - responsiveLayout:true, - selectable: 1, + + selectable: true, + selectableRangeMode:"click", autoResize:false, rowFormatter:function(row, data){ //console.log(row); @@ -72,7 +76,7 @@ let gallery = { columns: [ {title: "Image", field: "filename",formatter:pictureFormatter,width:200}, {title: "Type", field: "filetype" ,width: 100}, - {title: "description",field: "description"}, + {title: "description",field: "description", formatter:"html"}, {title: "publication",field: "publishdate",width: 100,formatter:"datetime",headerSort:true,formatterParams:{inputFormat:"YYYY-MM-DD",outputFormat:"DD.MM.YYYY",invalidPlaceholder:""}}, {title: "fin publication",field: "unpublishdate",width: 100,formatter:"datetime",headerSort:true,formatterParams:{inputFormat:"YYYY-MM-DD",outputFormat:"DD.MM.YYYY",invalidPlaceholder:""}}, ] @@ -92,59 +96,65 @@ let gallery = { data["folder"] = "galleries/" + this.gallery_folder; myapp.closedlg("addgalleryitem"); var uplfiles = document.getElementById("addgalleryitem_file"); - console.log("files:",uplfiles.files); - progresssteps = uplfiles.files.length * 2; - cstep = 0; + //console.log("files:",uplfiles.files); + let progresssteps = uplfiles.files.length * 2; + let cstep = 1; myapp.openDataLoad("Téléchargement en cours","Attendez s.v.p.!",progresssteps); for (let i = 0; i < uplfiles.files.length; i++) { + console.log("Upload File " + uplfiles.files[i].name,cstep); myapp.setDataLoadMsg("Upload File " + uplfiles.files[i].name,cstep); - postFile(uplfiles.files[i],data).then(filedata => { - console.log("File uploaded!",filedata); - cstep++; - myapp.setDataLoadMsg("Process File " + uplfiles.files[i].name,cstep); - postData({"cl":"gallery","fn":"addItem","idgallery":gallery.id_gallery,"filename":filedata.file}).then( data => { - console.log(data," added!"); - if (cstep >= progresssteps){ - gallery.gettabledata(); - myapp.closeDataLoad(); - } - }) .catch(err => { - - console.log("postData RETURN ERROR",err); - console.log(err); - gallery.gettabledata(); - myapp.closeDataLoad(); - return false; - }); - }).catch(err => { - console.log("postFile RETURN ERROR",err); - gallery.gettabledata(); - myapp.closeDataLoad(); - return false; - }); + let filedata = postFileSync(uplfiles.files[i],data); cstep++; + let retdata = postDataSync({"cl":"gallery","fn":"addItem","idgallery":gallery.id_gallery,"filename":filedata.file}); + cstep++; } - - - + gallery.gettabledata(); + myapp.closeDataLoad(); + return false; }, + // addItem: function(filename,last){ + // console.log("Add Item " + filename); + // postData({"cl":"gallery","fn":"addItem","idgallery":gallery.id_gallery,"filename":filename}).then( data => { + // if (last == true){ + // gallery.gettabledata(); + // myapp.closeDataLoad(); + // } + // return data.data; + // }).catch(err => { + // if (last == true){ + // gallery.gettabledata(); + // myapp.closeDataLoad(); + // } + // console.log("postData RETURN ERROR",err); + // }); + + // }, confirmRemove: function(){ var sel = gallery.tbl.getSelectedData(); - //delcallback = ; - if (sel[0]) { - myapp.confirm("Supprimer l'élément?","êtes vous sûre de supprimer cet élément?","oui","non","gallery.remove();"); + + if (sel.length >= 1){ + myapp.confirm("Supprimer l'élément?","êtes vous sûre de supprimer les élément selectionnées?","oui","non","gallery.remove();"); } }, remove: function(){ - var sel = gallery.tbl.getSelectedData(); - postData({"cl":"gallery","fn":"remove","id":id}).then(data => { - gallery.tbl.deselectRow(sel[0].id); - gallery.gettabledata(); - }); + let sel = gallery.tbl.getSelectedData(); + let ids = []; + for (s in sel){ + ids.push(sel[s].id); + } + console.log("IDs to remove",ids); + if (ids.length > 0){ + postData({"cl":"gallery","fn":"removeItems","idgallery":gallery.id_gallery,"ids":ids}).then(data => { + console.log(data.data + " files deleted!"); + gallery.tbl.deselectRow(ids); + gallery.gettabledata(); + }); + } + }, edit: function(){ let sel = this.tbl.getSelectedData(); - console.log(sel); + //console.log(sel); dataform.cleanform("galleryitem"); if (sel[0]){ dataform.fillform("galleryitem",{},sel[0]); @@ -152,13 +162,34 @@ let gallery = { } }, save: function(){ - myapp.closedlg("galleryitem"); + let sel = gallery.tbl.getSelectedData(); + let fdata = dataform.getformcontent("galleryitem"); + //console.log("formdata",fdata); + let idents = {"id":sel[0].id}; + postData({"saveform":1,"table":"galleryitems","schema":"public","idents":idents,"data":fdata["galleryitems"]}).then(data => { + console.log(data); + gallery.gettabledata(); + dataform.formsaved('Les données ont été savegardés'); + myapp.closedlg("galleryitem"); + }).catch(err => { + + }); }, editImage: function(){ let sel = this.tbl.getSelectedData(); }, setAsDefault: function(){ let sel = this.tbl.getSelectedData(); + if (sel[0]){ + postData({"cl":"gallery","fn":"setDefaultImage","thumbname":sel[0].thumbname,"galleryfolder":gallery.gallery_folder}).then(data => { + console.log(data); + gallery.changeDefaultImage(data.data.file); + }); + } + + }, + changeDefaultImage: function(file){ + document.getElementById("gpreview").src = 'media/galleries/' + file; } } diff --git a/admin/js/modules/index.js b/admin/js/modules/index.js index 12e871f..237d9b1 100644 --- a/admin/js/modules/index.js +++ b/admin/js/modules/index.js @@ -1,3 +1,5 @@ -function initpage(){ +let index = { + init: function(){ -} \ No newline at end of file + } +} diff --git a/admin/js/modules/webarticle.js b/admin/js/modules/webarticle.js index 6af843b..f5b8033 100644 --- a/admin/js/modules/webarticle.js +++ b/admin/js/modules/webarticle.js @@ -6,5 +6,6 @@ let webarticle = { }, viewpanel: function(id){ webarticle.current_id=id; + myapp.viewpanel('webarticle'); } } \ No newline at end of file diff --git a/admin/js/modules/webarticles.js b/admin/js/modules/webarticles.js index 7b55bb4..e62758f 100644 --- a/admin/js/modules/webarticles.js +++ b/admin/js/modules/webarticles.js @@ -2,22 +2,55 @@ let webarticles = { tbl: null, selects:{}, init: function(){ - + webarticles.tbl = new Tabulator("#tbl_webarticles",{ + height: "calc(100vh - 60px)", + layout: "fitColumns", + responsiveLayout:true, + selectable: 1, + // rowDblClick:function(e, row){ + // //e.preventDefault(); + // galleries.edit(); + // }, + rowContext:function(e, row){ e.preventDefault(); }, + columns: [ + {title: "titre", field: "title",headerFilter:"input"}, + {title: "categories",field: "categories",headerFilter:"input"}, + {title: "publié",field:"ispublished",hozAlign:"center",width: 40,headerSort: false,formatter:"tickCross", formatterParams:{allowEmpty:true,allowTruthy: false},headerVertical:true}, + {title: 'début',field:"publishdate",width: 100,formatter:"datetime",headerSort:false,formatterParams:{inputFormat:"YYYY-MM-DD",outputFormat:"DD.MM.YYYY",invalidPlaceholder:""}}, + {title: "fin",field:"unpublishdate",width: 100,formatter:"datetime",headerSort:false,formatterParams:{inputFormat:"YYYY-MM-DD",outputFormat:"DD.MM.YYYY",invalidPlaceholder:""}}, + ] + }); + webarticles.gettabledata(); }, gettabledata: function(){ - + postData({"cl":"webarticles","fn":"getAll"}).then(data => { + webarticles.tbl.setData(data.data); + }); }, add: function(){ - + postData({"cl":"webarticles","fn":"add"}).then(data => { + webarticles.gettabledata(); + }); }, edit: function(){ - + var sel = webarticles.tbl.getSelectedData(); + if (sel[0]){ + webarticle.viewpanel(sel[0].id); + } }, confirmRemove: function(){ - + var sel = webarticles.tbl.getSelectedData(); + //delcallback = ; + if (sel[0]) { + myapp.confirm("Supprimer article?","êtes vous sûre de supprimer ce article?","oui","non","webarticles.remove();"); + } }, remove: function(){ - + var sel = webarticles.tbl.getSelectedData(); + postData({"cl":"webarticles","fn":"delete","id":id}).then(data => { + webarticles.tbl.deselectRow(sel[0].id); + webarticles.gettabledata(); + }); } } \ No newline at end of file diff --git a/admin/js/request.js b/admin/js/request.js index ea9533d..a6acc3b 100644 --- a/admin/js/request.js +++ b/admin/js/request.js @@ -20,15 +20,30 @@ async function postData(data = {}) { return response.json(); } +function postDataSync(data = {}) { + const response = await fetch(api + 'db.php', { + method: 'POST', + mode: 'same-origin', + cache: 'no-cache', + credentials: 'same-origin', + headers: { + 'Content-Type': 'application/json' + + }, + redirect: 'follow', + referrerPolicy: 'strict-origin', + body: JSON.stringify(data) + }); + + return response.json(); +} + async function postFile(fileobj,data = {}) { var mfd = new FormData(); for (var o in data){ mfd.append(o,data[o]); } - //var fileobj = document.getElementById(fileobjid); - //console.log("files:",fileobj.files); - // for (let i = 0; i < fileobj.files.length; i++) { - + console.log("Upload:" + fileobj.name); mfd.append('file', fileobj,fileobj.name); // } const response = await fetch(api + 'upload.php', { @@ -43,22 +58,31 @@ async function postFile(fileobj,data = {}) { // referrerPolicy: 'strict-origin', body: mfd }); - console.log(response); + console.log("postFIle response",response); return response.json(); } -// var report ={ -// generate: function(repname,filename,data){ -// showdataloaddlg("Création PDF encours","Attendez s.v.p."); -// postData("report.cgi",{"generate":repname,"file": filename + ".pdf","data":data}).then (data => {closedataloaddlg();report.openreport(data);}); -// return false; -// }, -// openreport(data){ -// if (data && data.file){ -// window.open(api + "report.cgi?open=" + encodeURIComponent(data.file)); -// } -// } -// } +function postFileSync(fileobj,data = {}) { + var mfd = new FormData(); + for (var o in data){ + mfd.append(o,data[o]); + } + mfd.append('file', fileobj,fileobj.name); + const response = await fetch(api + 'upload.php', { + method: 'POST', + // mode: 'same-origin', + // cache: 'no-cache', + // credentials: 'same-origin', + // headers: { + // 'Content-Type': undefined + // }, + // redirect: 'follow', + // referrerPolicy: 'strict-origin', + body: mfd + }); + console.log("postFIle response",response); + return response.json(); +} // async function syncData(url,username,password, data = {}) { // //var decodedString = Base64.decode(encodedString); diff --git a/admin/lib/image.php b/admin/lib/image.php index 3289116..7a56cb8 100644 --- a/admin/lib/image.php +++ b/admin/lib/image.php @@ -3,7 +3,7 @@ class image{ #private $picdef= array("density" => 72,"img_height" => 380,"img_width" => 700, "thumb_width" => 128, "thumb_height" => 128); private $picdef= array(); - public function __construct($npicdef,$env){ + public function __construct($npicdef){ foreach ($npicdef as $key => $value){ $this->picdef[$key] = $value["pref"]; } @@ -60,16 +60,17 @@ class image{ return $outfile; } - public function createthump($imgfile,$outpath){ + public function createthumb($imgfile,$outpath){ $fpinfo = pathinfo($imgfile); - + error_log($imgfile); + error_log(print_r($fpinfo,true)); $outfile = $outpath.'/thumb/'.$fpinfo['filename'].'.'.$fpinfo['extension']; - if (!id_dir($outpath.'/thumb')){ + if (!is_dir($outpath.'/thumb')){ mkdir($outpath.'/thumb'); } if ($imgfile == $outfile) { return null;} - - system('convert -thumbnail x'.$this->picdef['thumbwidth'].' -background black -alpha remove "'.$imgfile.'" "'.$outfile.'"'); + error_log('convert -thumbnail x'.$this->picdef['thumb_height'].' -background black -alpha remove "'.$imgfile.'" "'.$outfile.'"'); + system('convert -thumbnail x'.$this->picdef['thumb_height'].' -background black -alpha remove "'.$imgfile.'" "'.$outfile.'"'); // if ($type == "cube"){ // system("convert ".$imgfile." -gravity center -crop ".$this->picdef['thumbwidth']."x".$this->picdef['thumbheight']."+0+0 +repage \"".$outfile."\""); // } diff --git a/admin/lib/modules/Gallery.php b/admin/lib/modules/Gallery.php index 08575a2..395ed6f 100644 --- a/admin/lib/modules/Gallery.php +++ b/admin/lib/modules/Gallery.php @@ -8,7 +8,7 @@ class gallery { } public function getAll(){ - $sql = "select * from galleries"; + $sql = "select * from galleries order by gallery;"; return $this->dbh->queryarray($sql); } @@ -18,11 +18,20 @@ class gallery { } public function getItems($id){ - $sql = "select * from galleryitems where id_gallery='".$id."'"; + $sql = "select * from galleryitems where id_gallery='".$id."' order by filename;"; return $this->dbh->queryarray($sql); } + public function setDefaultImage($thumbname,$galleryfolder){ + $thbinfo = pathinfo($thumbname); + copy($this->cfg["adminmediapath"]."/galleries/".$galleryfolder."/thumb/".$thumbname,$this->cfg["adminmediapath"]."/galleries/".$galleryfolder."/".$galleryfolder.".".$thbinfo['extension']); + copy($this->cfg["webmediapath"]."/galleries/".$galleryfolder."/thumb/".$thumbname,$this->cfg["webmediapath"]."/galleries/".$galleryfolder."/".$galleryfolder.".".$thbinfo['extension']); + $sql = "update galleries set picture=".$galleryfolder.".".$thbinfo['extension']." where link=".$galleryfolder.";"; + return array("folder" => $galleryfolder, "file" => $galleryfolder.".".$thbinfo['extension']); + } + public function addItem($filename,$idgallery){ + error_log("Add gallery item: ".$filename." => ".$idgallery); $gld = $this->dbh->query("select id,link from galleries where id=".$this->dbh->value($idgallery).";"); $filepath = $this->cfg["adminmediapath"].'galleries/'.$gld["link"].'/'.$filename; if (file_exists($filepath)){ @@ -33,8 +42,9 @@ class gallery { $findo =pathinfo($filename); $thumbname=$finfo["basename"].'.png'; } - $data = array("id" => $newitemid,"id_gallery" => $gld["id"],"filename" => $filename,"filetype" => $mt,"thumnname" => $thumbname); + $data = array("id" => $newitemid,"id_gallery" => $gld["id"],"filename" => $filename,"filetype" => $mt,"thumbname" => $thumbname); $inssql = $this->dbh->createInsertDDL("public","galleryitems",$data); + error_log("SQL:".$inssql); $this->dbh->exec($inssql); $this->setItemCopies($newitemid); } else { @@ -43,12 +53,9 @@ class gallery { return 1; } - public function setDefaultImage($idgallery,$id){ - - } - private function setItemCopies($id){ $gld = $this->dbh->query("SELECT gi.filename,g.link,gi.filetype,gi.thumbname from public.galleries g join public.galleryitems gi on (g.id=gi.id_gallery) where gi.id=".$this->dbh->value($id).";"); + error_log(print_r($gld,true)); $imgopts = $this->dbh->querybykey("id","select id,pref from defaultdata where category='gallery';"); $img = new image($imgopts); $filepath = $this->cfg["adminmediapath"]."galleries/".$gld["link"]."/".$gld["filename"]; @@ -64,16 +71,21 @@ class gallery { return 1; } - public function removeItem($idgallery,$id){ - $sqlfile = "SELECT gi.filename,g.link,gi.filetype,gi.thumbname from public.galleries g join public.galleryitems gi on (g.id=gi.id_gallery) where gi.id=".$this->dbh->value($id)." AND gi.id_gallery=".$this->dbh->value($idgallery).";"; - $sqldel ="DELETE FROM galleryitems WHERE id=".$this->dbh->value($id)." and id_gallery=".$this->dbh->value($idgallery).";"; - $fdata = $this->dbh->query($sqlfile); + public function removeItems($idgallery,$ids){ + foreach ($ids as $key => $value){ + $ids[$key] = $this->dbh->value($value); + } + $sqlfile = "SELECT gi.filename,g.link,gi.filetype,gi.thumbname from public.galleries g join public.galleryitems gi on (g.id=gi.id_gallery) where gi.id in (".implode(',',$ids).") AND gi.id_gallery=".$this->dbh->value($idgallery).";"; + $sqldel ="DELETE FROM galleryitems WHERE id in (".implode(',',$ids).") and id_gallery=".$this->dbh->value($idgallery).";"; + $fdata = $this->dbh->queryarray($sqlfile); $this->dbh->exec($sqldel); - unlink($this->cfg["adminmediapath"]."galleries/".$gld["link"]."/".$gld["filename"]); - unlink($this->cfg["adminmediapath"]."galleries/".$gld["link"]."/thumb/".$gld["thumbname"]); - unlink($this->cfg["webmediapath"]."galleries/".$gld["link"]."/".$gld["filename"]); - unlink($this->cfg["webmediapath"]."galleries/".$gld["link"]."/thumb/".$gld["thumbname"]); - return 1; + foreach ($fdata as $key => $fd){ + unlink($this->cfg["adminmediapath"]."galleries/".$fd["link"]."/".$fd["filename"]); + unlink($this->cfg["adminmediapath"]."galleries/".$fd["link"]."/thumb/".$fd["thumbname"]); + unlink($this->cfg["webmediapath"]."galleries/".$fd["link"]."/".$fd["filename"]); + unlink($this->cfg["webmediapath"]."galleries/".$fd["link"]."/thumb/".$fd["thumbname"]); + } + return count($fdata); } public function updateItemData($id,$data){ diff --git a/admin/lib/modules/WebArticles.php b/admin/lib/modules/WebArticles.php index 6312661..c1fb5d7 100644 --- a/admin/lib/modules/WebArticles.php +++ b/admin/lib/modules/WebArticles.php @@ -9,5 +9,48 @@ class webarticles { public function __destruct(){ $this->dbh = null; } + + public function getAll(){ + $sql = "select id, title,regexp_replace(categories::text,'[\"|\[|\]]','','g') as categories, case when CURRENT_DATE between publishdate and unpublishdate then true else null end as ispublished,publishdate, unpublishdate from webarticles order by title,publishdate;"; + return $this->dbh->queryarray($sql); + } + + public function get($id){ + $sql = "select * from webarticles where id=".$this->dbh->value($id).";"; + return $this->dbh->query($sql); + } + + public function add(){ + $tblvals = array("id" => $this->dbh->newuuid(),"title" => "nouveau article"); + $sql = $this->dbh->createInsertDDL("public","webarticles",$tblvals); + $this->dbh->exec($sql); + return array("id" => $tblvals["id"]); + } + + public function delete($id){ + $this->dbh->exec("DELETE from webarticles where id=".$this->dbh->value($id).";"); + return 1; + } + + public function update($id,$data){ + $updsql = $this->dbh->createUpdateDDL("public","webarticles",array("id" => $this->dbh->value($id)),$data); + $this->dbh->exec($updsql); + return 1; + } + + public function getCategories(){ + $sql = "select distinct(json_array_elements_text(categories)) as categories from webarticles order by categories;"; + return $this->dbh->queryarray($sql); + } + + public function duplicate($id){ + $copydata = $this->dbh->query("select * from webarticles where id=".$this->dbh->value($id).";"); + $copydata["id"] = $this->dbh->newuuid(); + $copydata["title"] = $copydata["title"]." Copy"; + $copydata["link"] = null; + $sql = $this->dbh->createInsertDDL("public","webarticles",$copydata); + $this->dbh->exec($sql); + return array("id" => $copydata["id"]); + } } ?> \ No newline at end of file diff --git a/admin/lib/modules/webpages.php b/admin/lib/modules/webpages.php new file mode 100644 index 0000000..dbcb00c --- /dev/null +++ b/admin/lib/modules/webpages.php @@ -0,0 +1,56 @@ +dbh = $dblink; + $this->cfg = $cfg; + } + public function __destruct(){ + $this->dbh = null; + } + public function getAll(){ + $sql = "select id, title order by title;"; + return $this->dbh->queryarray($sql); + } + + public function get($id){ + $sql = "select * from webpages where id=".$this->dbh->value($id).";"; + return $this->dbh->query($sql); + } + + public function add(){ + $tblvals = array("id" => $this->dbh->newuuid(),"title" => "nouveau article"); + $sql = $this->dbh->createInsertDDL("public","webpages",$tblvals); + $this->dbh->exec($sql); + return array("id" => $tblvals["id"]); + } + + public function delete($id){ + $this->dbh->exec("DELETE from webpages where id=".$this->dbh->value($id).";"); + return 1; + } + + public function update($id,$data){ + $updsql = $this->dbh->createUpdateDDL("public","webpages",array("id" => $this->dbh->value($id)),$data); + $this->dbh->exec($updsql); + return 1; + } + + public function getCategories(){ + $sql = "select distinct(json_array_elements_text(categories)) as categories from webpages order by categories;"; + return $this->dbh->queryarray($sql); + } + + public function duplicate($id){ + $copydata = $this->dbh->query("select * from webpages where id=".$this->dbh->value($id).";"); + $copydata["id"] = $this->dbh->newuuid(); + $copydata["title"] = $copydata["title"]." Copy"; + $copydata["link"] = null; + $sql = $this->dbh->createInsertDDL("public","webpages",$copydata); + $this->dbh->exec($sql); + + + } +} +?> \ No newline at end of file diff --git a/admin/lib/modules/websites.php b/admin/lib/modules/websites.php deleted file mode 100644 index 7450e84..0000000 --- a/admin/lib/modules/websites.php +++ /dev/null @@ -1,29 +0,0 @@ -dbh = $dblink; - $this->cfg = $cfg; - } - public function __destruct(){ - $this->dbh = null; - } - public function addWebsite($id){ - - } - - public function updateWebsite($id,$data){ - - } - - public function removeWebsite($id){ - - } - - public function duplicateWebsite($id){ - - } - - } -?> \ No newline at end of file diff --git a/admin/tmpl/elements/dialogs/dlg_galleryitem.html.mustache b/admin/tmpl/elements/dialogs/dlg_galleryitem.html.mustache index aa2c158..1a8b7da 100644 --- a/admin/tmpl/elements/dialogs/dlg_galleryitem.html.mustache +++ b/admin/tmpl/elements/dialogs/dlg_galleryitem.html.mustache @@ -8,30 +8,27 @@
- - -
-
- - +
+
+ + +
+
+ + +
-
- - +
+
+ + +
-
-
-
- - -
-
- - +
- +
\ No newline at end of file diff --git a/admin/tmpl/elements/panels/pnl_galleries.html.mustache b/admin/tmpl/elements/panels/pnl_galleries.html.mustache index 837aa03..057d113 100644 --- a/admin/tmpl/elements/panels/pnl_galleries.html.mustache +++ b/admin/tmpl/elements/panels/pnl_galleries.html.mustache @@ -16,7 +16,7 @@ - {{! }} + diff --git a/admin/tmpl/elements/panels/pnl_gallery.html.mustache b/admin/tmpl/elements/panels/pnl_gallery.html.mustache index cf77ec5..db1b729 100644 --- a/admin/tmpl/elements/panels/pnl_gallery.html.mustache +++ b/admin/tmpl/elements/panels/pnl_gallery.html.mustache @@ -3,7 +3,7 @@
Gallerie
- + @@ -42,11 +42,19 @@
- + +
+
+ +
+ +
+
+
-
+
diff --git a/admin/tmpl/elements/panels/pnl_webarticle.html.mustache b/admin/tmpl/elements/panels/pnl_webarticle.html.mustache index 86c4562..c3e1bde 100644 --- a/admin/tmpl/elements/panels/pnl_webarticle.html.mustache +++ b/admin/tmpl/elements/panels/pnl_webarticle.html.mustache @@ -1,6 +1,34 @@ +
+
+ +
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+ +
+ +
-
\ No newline at end of file diff --git a/admin/tmpl/elements/panels/pnl_webarticles.html.mustache b/admin/tmpl/elements/panels/pnl_webarticles.html.mustache index 55c8936..89de36c 100644 --- a/admin/tmpl/elements/panels/pnl_webarticles.html.mustache +++ b/admin/tmpl/elements/panels/pnl_webarticles.html.mustache @@ -1,7 +1,7 @@
Home -
Pages
+
News & Articles
diff --git a/admin/tmpl/index.html.mustache b/admin/tmpl/index.html.mustache index 3939baa..e0b3f18 100644 --- a/admin/tmpl/index.html.mustache +++ b/admin/tmpl/index.html.mustache @@ -37,7 +37,7 @@
{{ pagedata }}
- +
diff --git a/admin/tmpl/pages/galleries.html.mustache b/admin/tmpl/pages/galleries.html.mustache index fc4310b..7284dd7 100644 --- a/admin/tmpl/pages/galleries.html.mustache +++ b/admin/tmpl/pages/galleries.html.mustache @@ -9,6 +9,5 @@ diff --git a/admin/tmpl/pages/index.html.mustache b/admin/tmpl/pages/index.html.mustache index 29730e6..abb5b93 100644 --- a/admin/tmpl/pages/index.html.mustache +++ b/admin/tmpl/pages/index.html.mustache @@ -1,5 +1,5 @@
- +
{{ config.sitename }}
Logout
diff --git a/admin/upload.php b/admin/upload.php index c7409ee..23bb36b 100644 --- a/admin/upload.php +++ b/admin/upload.php @@ -26,9 +26,9 @@ if (!is_dir($cfg["adminmediapath"].$mfolder)){ mkdir($cfg["adminmediapath"].$mfolder); } - else { - error_log("mediafolder: ".$cfg["adminmediapath"].$mfolder." exists!"); - } + // else { + // error_log("mediafolder: ".$cfg["adminmediapath"].$mfolder." exists!"); + // } $cnum = date('YmdHis'); $cfiles = glob($cfg["adminmediapath"].$mfolder .'/'. "*"); $xfiles = count($cfiles) + 1;