php_flag display_startup_errors off\r
php_flag display_errors off\r
php_flag html_errors off\r
+php_value post_max_size 32M\r
+php_value upload_max_filesize 32M\r
RewriteCond %{REQUEST_FILENAME} !-f\r
RewriteCond %{REQUEST_FILENAME} !-d\r
RewriteRule "^(.*)$" "index.php" [NC,L,QSA]
\ No newline at end of file
$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"]);
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);
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
// //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}
]
});
remove: function(){
}
-}
\ No newline at end of file
+}
+
+let previewFormatter = function(cell, formatterParams){
+
+ return '<div><img style="height: 75px;" src="media/galleries/' + cell.getValue()+'" /></div>';
+};
\ No newline at end of file
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();
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 ',
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},
{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 => {
})
},
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 = {};
}
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);
});
});
},
- // 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();
}
},
+ 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);
},
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');
+ });
}
}
<?php
+
+
$cfg = array(
"basepath" => "/oldbelladmin/",
"cookie" => "oldbell_lu",
"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
--- /dev/null
+<?php
+
+class helper {
+ private $picdef= array();
+ public function __construct(){
+
+ }
+ public function __destruct(){
+
+ }
+ function getbytes ($size_str){
+ switch (substr ($size_str, -1))
+ {
+ case 'M': case 'm': return (int)$size_str * 1048576;
+ case 'K': case 'k': return (int)$size_str * 1024;
+ case 'G': case 'g': return (int)$size_str * 1073741824;
+ default: return $size_str;
+ }
+ }
+ function getiniconfig($name){
+ if ($name == "post_max_size" || $name == "upload_max_filesize"){
+ return array($name => $this->getbytes(ini_get($name)),"hr".$name => ini_get($name));
+ }
+ return array($name => ini_get($name));
+ }
+}
+
+
+?>
\ No newline at end of file
}
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);
}
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);
--- /dev/null
+<?php
+ // ini_set('post_max_size', '32000');
+ // ini_set('upload_max_filesize', '32000');
+?>
\ No newline at end of file
--- /dev/null
+<div id="dlg_movegalleryitem" class="modal">
+ <div class="modal-content animate-top card-4">
+ <header>
+ <span onclick="document.getElementById('dlg_movegalleryitem').style.display='none'; return false;"
+ class="button toolbarbtn display-topright" ><span class="icon icon-remove" style="font-size: 18px;"></span></span>
+ <h3 id="dlgmovegalleryitem_title">Déplacer Image/Video</h3>
+ </header>
+ <div class="container">
+ <div id="dlg_movegalleryitem_infomsg"></div>
+ <form id="frm_movegalleryitem">
+ <div class="row">
+ <div class="cell" style="width: 400px;">
+ <label class="label" for="movegalleryitem_id_gallery">Déplacer vers</label>
+ <select class="select border data_movegalleryitem" data-column="id_gallery" data-id="" data-selected="" data-table="galleryitems" id="movegalleryitem_id_gallery"></select>
+ </div>
+ </div>
+
+ </form>
+ </div>
+ <footer>
+ <button class="button theme-light margin-right border" onclick="document.getElementById('dlg_movegalleryitem').style.display='none'; return false;"><span class="icon icon-remove"></span> Annuler</button>
+ <button class="button actionbtn margin-right border" onclick="gallery.moveItem();"><span class="icon icon-save"></span> Déplacer</button>
+ </footer>
+ </div>
+</div>
<div class="row">
<div class="cell container" style="width: 400px;">
<label for="addgalleryitem_file" class="label">Fichier</label>
- <input type="file" class="input data_addgalleryitem " id="addgalleryitem_file" data-column="filename" data-table="galleryitems" multiple data-id="" value="" />
+ <input type="file" class="input data_addgalleryitem " id="addgalleryitem_file" data-column="filename" data-table="galleryitems" multiple data-id="" value="" onchange="gallery.showUploadSize();"/>
</div>
</div>
+ <div class="row">
+
+ <div class="cell container" style="width: 300px;">
+ <label class="label" for="addgalleryitem_filesize">taille</label>
+ <input class="input border text data_formname readonly" data-column="column" data-id="" data-table="table" id="addgalleryitem_filesize" readonly>
+ </div>
+ <div class="cell container" style="width: 300px;">
+ <label class="label" for="addgalleryitem_maxfilesize">max taille</label>
+ <input class="input border text data_formname readonly" data-column="column" data-id="" data-table="table" id="addgalleryitem_maxfilesize" readonly>
+ </div>
+
+ </div>
<div class="row">
<div class="cell" style="width: 100%">
<div class="container">
{{> 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 }}
<script type="text/javascript" src="js/modules/galleries.js?v={{config.appversion}}"></script>
<?php
+ require("lib/phpini.php");
require("lib/config.php");
require("lib/database.php");
require("lib/session.php");
- ini_set('upload_max_filesize', your_value_here);
$db = new database($cfg["db"]);
$sess = new session($db);
$vars = array();