From: Kilian Saffran Date: Mon, 7 Dec 2020 06:47:25 +0000 (+0100) Subject: v20201206 X-Git-Url: http://cloud.dks.lu/git/?a=commitdiff_plain;h=2b4c89e64f37c21801e855b23d473903e188b14e;p=oldbell_lu.git v20201206 --- diff --git a/admin/.htaccess b/admin/.htaccess index edc875e..cb2a886 100644 --- a/admin/.htaccess +++ b/admin/.htaccess @@ -4,6 +4,8 @@ DirectoryIndex index.php index.html php_flag display_startup_errors off php_flag display_errors off php_flag html_errors off +php_value post_max_size 32M +php_value upload_max_filesize 32M RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule "^(.*)$" "index.php" [NC,L,QSA] \ No newline at end of file diff --git a/admin/db.php b/admin/db.php index 46cce8c..3a4a355 100644 --- a/admin/db.php +++ b/admin/db.php @@ -74,6 +74,9 @@ $html["sql"] = $updsql; $html["data"] = $db->exec($updsql); + } elseif(isset($params["getconfig"])){ + $helper = new helper(); + $html["data"] = $helper->getiniconfig($params["getconfig"]); } elseif(isset($params["logout"])){ $html["data"] = $sess->deleteSession($vars["sid"]); diff --git a/admin/js/filedata.js b/admin/js/filedata.js index 3c60908..090f980 100644 --- a/admin/js/filedata.js +++ b/admin/js/filedata.js @@ -2,12 +2,14 @@ let filedata = { getfileinfo: function (fileobjid){ var files = {"count":0,"size":0,"sizehr":"0 bytes","fileinfo":[]}; var nBytes = 0; - var oFiles = document.getElementById(fileobjid).files; - files.count = oFiles.length; - for (var nFileId = 0; nFileId < files.count; nFileId++) { - var nfo = {"name":name,"type":type,"size":oFiles[nFileId].size,"sizehr":filedata.sizeHumanReadble(oFiles[nFileId].size)} - files.fileinfo.push(nfo); - nBytes += oFiles[nFileId].size; + if (document.getElementById(fileobjid).files.length != 0){ + var oFiles = document.getElementById(fileobjid).files; + files.count = oFiles.length; + for (var nFileId = 0; nFileId < files.count; nFileId++) { + var nfo = {"name":oFiles[nFileId].name,"type":oFiles[nFileId].type,"size":oFiles[nFileId].size,"sizehr":filedata.sizeHumanReadble(oFiles[nFileId].size)} + files.fileinfo.push(nfo); + nBytes += oFiles[nFileId].size; + } } files.size = nBytes; files.sizehr = filedata.sizeHumanReadble(nBytes); @@ -16,9 +18,9 @@ let filedata = { sizeHumanReadble: function(nBytes){ var sOutput = nBytes + " bytes" for (var aMultiples = ["KB", "MB", "GB"], nMultiple = 0, nApprox = nBytes / 1024; nApprox > 1; nApprox /= 1024, nMultiple++) { - sOutput = nApprox.toFixed(3) + " " + aMultiples[nMultiple] + " (" + nBytes + " bytes)"; + sOutput = nApprox.toFixed(2) + " " + aMultiples[nMultiple] + " (" + nBytes + " bytes)"; } - return sOutput; + return sOutput.replace(/\./,','); } } \ No newline at end of file diff --git a/admin/js/modules/galleries.js b/admin/js/modules/galleries.js index 064c5a2..09c1ee6 100644 --- a/admin/js/modules/galleries.js +++ b/admin/js/modules/galleries.js @@ -13,10 +13,13 @@ let galleries = { // //e.preventDefault(); // galleries.edit(); // }, + rowFormatter:function(row, data){}, rowContext:function(e, row){ e.preventDefault(); }, columns: [ - {title: "Gallerie", field: "gallery"}, - {title: "description",field: "description"} + {title: "Image", field: "picture",formatter:previewFormatter,width:200}, + {title: "Gallerie", field: "gallery",width: 150}, + {title: "description",field: "description"}, + {title: "Élements",field: "items",formatter:"number", width: 50} ] }); @@ -45,4 +48,9 @@ let galleries = { remove: function(){ } -} \ No newline at end of file +} + +let previewFormatter = function(cell, formatterParams){ + + return '
'; +}; \ No newline at end of file diff --git a/admin/js/modules/gallery.js b/admin/js/modules/gallery.js index 7a699e5..f1bc06a 100644 --- a/admin/js/modules/gallery.js +++ b/admin/js/modules/gallery.js @@ -1,8 +1,9 @@ let gallery = { id_gallery: null, gallery_folder: null, + maxuploadsize: null, tbl: null, - selects: {}, + selects: {"movegalleryitem_id_gallery":null}, viewpanel: function(id){ gallery.id_gallery=id; let sel = galleries.tbl.getSelectedData(); @@ -27,6 +28,10 @@ let gallery = { altFormat: "d.m.Y",dateFormat: "Y-m-d","locale": "fr", // onClose: function(selectedDates, dateStr, instance) {} }); + gallery.selects["movegalleryitem_id_gallery"] = new SlimSelect({ + select: "#movegalleryitem_id_gallery", + showSearch: false + }); tinymce.init({ selector: '#galleryitem_description,#galleries_description', plugins: 'paste importcss searchreplace autolink directionality visualblocks visualchars template charmap nonbreaking advlist lists textpattern noneditable charmap autoresize ', @@ -64,12 +69,7 @@ let gallery = { selectable: true, selectableRangeMode:"click", - //autoResize:false, - rowFormatter:function(row, data){ - //console.log(row); - - - }, + rowFormatter:function(row, data){}, rowContext:function(e, row){ e.preventDefault(); }, columns: [ {title: "Image", field: "filename",formatter:pictureFormatter,width:200}, @@ -79,6 +79,7 @@ let gallery = { {title: "fin publication",field: "unpublishdate",width: 100,formatter:"datetime",headerSort:true,formatterParams:{inputFormat:"YYYY-MM-DD",outputFormat:"DD.MM.YYYY",invalidPlaceholder:""}}, ] }); + gallery.getGalleries(); }, gettabledata: function(){ postData({"cl":"gallery","fn":"getItems","id":gallery.id_gallery}).then(data => { @@ -87,7 +88,21 @@ let gallery = { }) }, add: function(){ - myapp.viewdialog("addgalleryitem"); + postData({"getconfig":"post_max_size"}).then(data => { + console.log(data.data) + gallery.maxuploadsize = data.data.post_max_size; + gallery.showUploadSize(); + myapp.viewdialog("addgalleryitem"); + }); + + }, + showUploadSize: function(){ + let uplfiles = document.getElementById("addgalleryitem_file"); + let uplsize= filedata.getfileinfo("addgalleryitem_file"); + let maxsize = filedata.sizeHumanReadble(gallery.maxuploadsize); + + document.getElementById("addgalleryitem_maxfilesize").value=maxsize; + document.getElementById("addgalleryitem_filesize").value=uplsize.sizehr; }, uploadItem: async function(){ let data = {}; @@ -98,9 +113,6 @@ let gallery = { } myapp.closedlg("addgalleryitem"); var uplfiles = document.getElementById("addgalleryitem_file"); - //console.log("files:",uplfiles.files); - //let progresssteps = uplfiles.files.length; - //let cstep = 1; myapp.openDataLoad("Téléchargement en cours","Attendez s.v.p.!",null); postFile(uplfiles,data).then(filesdata => { console.log(filesdata); @@ -110,37 +122,6 @@ let gallery = { }); }); }, - // uploadRequest: async function(uplfile,upldata){ - // await postFile(uplfile,upldata).then(filedata => { - // console.log("file uploaded ", filedata.file); - // postData({"cl":"gallery","fn":"addItem","idgallery":gallery.id_gallery,"filename":filedata.file}).then( data => { - // console.log("finally data", data); - // // if (last == true){ - // // gallery.gettabledata(); - // // myapp.closeDataLoad(); - // // } - // // return data.data; - // // }) - // }); - // }); - // }, - // 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(); @@ -164,6 +145,27 @@ let gallery = { } }, + move: function(){ + let sel = gallery.tbl.getSelectedData(); + if(sel[0]){ + + } + }, + moveItem: function(){ + let sel = gallery.tbl.getSelectedData(); + let newgallery = gallery.selects["movegalleryitem_id_gallery"].selected(); + for (s in sel){ + ids.push(sel[s].id); + } + console.log("IDs to move",ids); + if (ids.length > 0){ + postData({"cl":"gallery","fn":"moveItems","idgallery":newgallery,"ids":ids}).then(data => { + console.log(data.data + " files moved!"); + gallery.tbl.deselectRow(ids); + gallery.gettabledata(); + }); + } + }, edit: function(){ let sel = this.tbl.getSelectedData(); //console.log(sel); @@ -202,6 +204,11 @@ let gallery = { }, changeDefaultImage: function(file){ document.getElementById("gpreview").src = 'media/galleries/' + file+ "?" + moment().format('YYYYMMDDhhmmss') ; + }, + getGalleries: function(){ + postData({"cl":"gallery","fn":"getAll"}).then(data => { + dataform.fillselectlist(gallery.selects["movegalleryitem_id_gallery"],data.data,'id','gallery'); + }); } } diff --git a/admin/lib/config.php b/admin/lib/config.php index f45be8c..ce76134 100644 --- a/admin/lib/config.php +++ b/admin/lib/config.php @@ -1,4 +1,6 @@ "/oldbelladmin/", "cookie" => "oldbell_lu", @@ -19,21 +21,4 @@ "sitename" => "oldbell.lu", "sitetemplatepath" => $_SERVER["DOCUMENT_ROOT"].'/oldbell_lu' ); - - // function getparams(){ - // $get_arr = array(); - // if ($_SERVER['QUERY_STRING'] != ""){ - // $xar = explode("&", $_SERVER['QUERY_STRING']); - // #print_r($xar); - // if (count($xar) > 0){ - // foreach ($xar as $tmp_arr_param) { - // $split_param = explode("=", $tmp_arr_param); - // if ($split_param[1]){ - // $get_arr[$split_param[0]] = urldecode($split_param[1]); - // } - // } - // } - // } - // return $get_arr; - // } ?> \ No newline at end of file diff --git a/admin/lib/helper.php b/admin/lib/helper.php new file mode 100644 index 0000000..69b2b0c --- /dev/null +++ b/admin/lib/helper.php @@ -0,0 +1,29 @@ + $this->getbytes(ini_get($name)),"hr".$name => ini_get($name)); + } + return array($name => ini_get($name)); + } +} + + +?> \ No newline at end of file diff --git a/admin/lib/modules/Gallery.php b/admin/lib/modules/Gallery.php index 58cf9d2..9761bd0 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 order by gallery;"; + $sql = "select g.*,count(gi.id) as items from galleries g left join galleryitems gi on (g.id=gi.id_gallery) group by g.id order by g.gallery;"; return $this->dbh->queryarray($sql); } @@ -91,6 +91,25 @@ class gallery { return count($fdata); } + public function moveItems($idgallery,$ids){ + foreach ($ids as $key => $value){ + $ids[$key] = $this->dbh->value($value); + } + $sqlgal = "SELECT link from galleries where id=".$this->dbh->value($idgallery).";"; + $gal = $this->dbh->query($sqlgal); + $sqlfile = "SELECT gi.id,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).");"; + $fdata = $this->dbh->queryarray($sqlfile); + foreach ($fdata as $key => $fd){ + $sqlupd ="UPDATE galleryitems set id_gallery=".$this->dbh->value($idgallery).",filename=replace(".$this->dbh->value($fd["link"]).",".$this->dbh->value($gal["link"])."),thumbname=replace(".$this->dbh->value($fd["link"]).",".$this->dbh->value($gal["link"]).") WHERE id=".$this->dbh->value($fd["id"]).";"; + $this->dbh->exec($sqlupd); + rename($this->cfg["adminmediapath"]."galleries/".$fd["link"]."/".$fd["filename"],$this->cfg["adminmediapath"]."galleries/".$gal["link"]."/".str_replace($fd["link"],$gal["link"],$fd["filename"])); + rename($this->cfg["adminmediapath"]."galleries/".$fd["link"]."/thumb/".$fd["thumbname"],$this->cfg["adminmediapath"]."galleries/".$gal["link"]."/thumb/".str_replace($fd["link"],$gal["link"],$fd["thumbname"])); + rename($this->cfg["webmediapath"]."galleries/".$fd["link"]."/".$fd["filename"],$this->cfg["webmediapath"]."galleries/".$gal["link"]."/".str_replace($fd["link"],$gal["link"],$fd["filename"])); + rename($this->cfg["webmediapath"]."galleries/".$fd["link"]."/thumb/".$fd["thumbname"],$this->cfg["webmediapath"]."galleries/".$gal["link"]."/thumb/".str_replace($fd["link"],$gal["link"],$fd["thumbname"])); + } + return count($fdata); + } + public function updateItemData($id,$data){ $updsql = $this->dbh->createUpdateDDL("public","galleryitems",array("id" => $this->dbh->value($id)),$data); $this->dbh->exec($updsql); diff --git a/admin/lib/phpini.php b/admin/lib/phpini.php new file mode 100644 index 0000000..f600a36 --- /dev/null +++ b/admin/lib/phpini.php @@ -0,0 +1,4 @@ + \ No newline at end of file diff --git a/admin/tmpl/elements/dialogs/dlg_gallerymoveitem.html.mustache b/admin/tmpl/elements/dialogs/dlg_gallerymoveitem.html.mustache new file mode 100644 index 0000000..a9d8d16 --- /dev/null +++ b/admin/tmpl/elements/dialogs/dlg_gallerymoveitem.html.mustache @@ -0,0 +1,25 @@ + diff --git a/admin/tmpl/elements/dialogs/dlgaddgalleryitem.html.mustache b/admin/tmpl/elements/dialogs/dlgaddgalleryitem.html.mustache index 422c299..a658c9a 100644 --- a/admin/tmpl/elements/dialogs/dlgaddgalleryitem.html.mustache +++ b/admin/tmpl/elements/dialogs/dlgaddgalleryitem.html.mustache @@ -14,9 +14,21 @@
- +
+
+ +
+ + +
+
+ + +
+ +
diff --git a/admin/tmpl/pages/galleries.html.mustache b/admin/tmpl/pages/galleries.html.mustache index 7284dd7..bd3030d 100644 --- a/admin/tmpl/pages/galleries.html.mustache +++ b/admin/tmpl/pages/galleries.html.mustache @@ -2,6 +2,7 @@ {{> panels/pnl_gallery.html.mustache }} {{> dialogs/dlgaddgalleryitem.html.mustache }} {{> dialogs/dlg_galleryitem.html.mustache }} +{{> dialogs/dlg_gallerymoveitem.html.mustache }} {{> dialogs/confirm.html.mustache }} {{> dialogs/dataload.html.mustache }} diff --git a/admin/upload.php b/admin/upload.php index 45c693d..c329630 100644 --- a/admin/upload.php +++ b/admin/upload.php @@ -1,8 +1,8 @@