forked from projects/fipamo
cleaned up create page process, update page edit template to handle empty files
This commit is contained in:
parent
2210e39aee
commit
1351b98ee4
6 changed files with 88 additions and 107 deletions
|
@ -116,15 +116,15 @@ class DashControl
|
||||||
$files = [];
|
$files = [];
|
||||||
foreach ($imageList as $item) {
|
foreach ($imageList as $item) {
|
||||||
$image = trim($item);
|
$image = trim($item);
|
||||||
if ($item != null || $item != "") {
|
if (!empty($image)) {
|
||||||
array_push($images, $item);
|
array_push($images, $image);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($fileList as $item) {
|
foreach ($fileList as $item) {
|
||||||
$file = trim($item);
|
$file = trim($item);
|
||||||
if ($item != null || $item != "") {
|
if (!empty($file)) {
|
||||||
array_push($files, $item);
|
array_push($files, $file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,9 +53,10 @@ class Book
|
||||||
$path = date("Y") . "/" . date("m");
|
$path = date("Y") . "/" . date("m");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($files)) {
|
$page_feature = '';
|
||||||
//var_dump($files);
|
$page_files = '';
|
||||||
if ($task != "create") {
|
|
||||||
|
if (isset($files["page_files"])) {
|
||||||
$imageList = "";
|
$imageList = "";
|
||||||
$fileList = "";
|
$fileList = "";
|
||||||
//var_dump($files["page_files"] );
|
//var_dump($files["page_files"] );
|
||||||
|
@ -107,42 +108,12 @@ class Book
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$feature = $imageList;
|
$page_feature = $imageList;
|
||||||
$files = $fileList;
|
$page_files = $fileList;
|
||||||
//var_dump($feature);
|
|
||||||
//return ["message" => "JUST DEBUGGING"];
|
|
||||||
} else {
|
} else {
|
||||||
//if creating a new page, from file payload and set $feature and $files
|
//if no files, just reset string from page object
|
||||||
/*
|
$page_feature = $page["feature"];
|
||||||
$feature =
|
$page_files = $page["files"];
|
||||||
"/assets/images/blog/" .
|
|
||||||
$path .
|
|
||||||
"/" .
|
|
||||||
$image["feature_image"]->getClientFileName();
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//if no files, do no file stuff
|
|
||||||
/*
|
|
||||||
if (isset($body["feature_image"])) {
|
|
||||||
$url = explode("/", $body["feature_image"]);
|
|
||||||
$feature =
|
|
||||||
"/" .
|
|
||||||
$url[3] .
|
|
||||||
"/" .
|
|
||||||
$url[4] .
|
|
||||||
"/" .
|
|
||||||
$url[5] .
|
|
||||||
"/" .
|
|
||||||
$url[6] .
|
|
||||||
"/" .
|
|
||||||
$url[7] .
|
|
||||||
"/" .
|
|
||||||
$url[8];
|
|
||||||
} else {
|
|
||||||
//$task == "create" ? ($feature = "") : ($feature = $body["feature"]);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($task == "delete") {
|
if ($task == "delete") {
|
||||||
|
@ -167,8 +138,8 @@ class Book
|
||||||
|
|
||||||
$body["id"] = $id;
|
$body["id"] = $id;
|
||||||
$body["uuid"] = $uuid;
|
$body["uuid"] = $uuid;
|
||||||
$body["feature"] = $feature;
|
$body["feature"] = $page_feature;
|
||||||
$body["files"] = $files;
|
$body["files"] = $page_files;
|
||||||
$body["path"] = $path;
|
$body["path"] = $path;
|
||||||
$body["author"] = $member["handle"];
|
$body["author"] = $member["handle"];
|
||||||
$body["created"] = $created->format("Y-m-d\TH:i:sP");
|
$body["created"] = $created->format("Y-m-d\TH:i:sP");
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<div id="dash-login">
|
<div id="dash-login">
|
||||||
<div id="dash-form" class="dash-form">
|
<div id="dash-form" class="dash-form">
|
||||||
<img id="the-logo" src="/assets/images/global/fipamo-logo.svg"/>
|
<img id="the-logo" src="/assets/images/global/fipamo-logo.svg"/>
|
||||||
<form id="login" class='login' name="login">
|
<form id="login" class='login' name="login" method="POST">
|
||||||
<input type="text" name="handle" class="form-control" placeholder="Handle" required ">
|
<input type="text" name="handle" class="form-control" placeholder="Handle" required ">
|
||||||
<input type="password" name="password" class="form-control" placeholder="Password" required">
|
<input type="password" name="password" class="form-control" placeholder="Password" required">
|
||||||
<button id="login-btn" class='login-btn' type='submit'>
|
<button id="login-btn" class='login-btn' type='submit'>
|
||||||
|
|
|
@ -44,8 +44,17 @@
|
||||||
<div id="post-edit-index-wrapper">
|
<div id="post-edit-index-wrapper">
|
||||||
<div id="post-feature">
|
<div id="post-feature">
|
||||||
{% if page['feature'] == null %}
|
{% if page['feature'] == null %}
|
||||||
<div id="featured-image-drop">
|
<div id="page-file-manager">
|
||||||
DRAG AND DROP IMAGE OR <label for="featured-image-upload">CLICK TO CHOSE</label>
|
<div id="page-file-wrapper">
|
||||||
|
<div id="page-file-drop">
|
||||||
|
<label for="page-files-upload">DRAG AND DROP FILES OR CLICK TO SELECT</label>
|
||||||
|
</div>
|
||||||
|
IMAGES AND VIDEO
|
||||||
|
<div id="page-images-list"></div>
|
||||||
|
FILES
|
||||||
|
<div id="page-files-list"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
<div id="page-file-manager">
|
<div id="page-file-manager">
|
||||||
|
@ -64,11 +73,14 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% else %}
|
{% else %}
|
||||||
{% if item.type == "mp4"%}
|
{% if media[0] != '' %}
|
||||||
|
{% if media[0].type == "mp4"%}
|
||||||
<div id="0" class="video-item" data-source="{{ media[0].file }}"></div>
|
<div id="0" class="video-item" data-source="{{ media[0].file }}"></div>
|
||||||
{% else %}
|
{% else %}
|
||||||
<div id="0" class="img-item" style="background: url({{ media[0].file }}) no-repeat center center / cover"></div>
|
<div id="0" class="img-item" style="background: url({{ media[0].file }}) no-repeat center center / cover"></div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% else %}
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -83,11 +95,16 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% else %}
|
{% else %}
|
||||||
{% if item.type == "mp3"%}
|
{% if files[0] != '' %}
|
||||||
|
{% if files[0].type == "mp3"%}
|
||||||
<div id="0" class="audio-item" data-source="{{ files[0].file }}"></div>
|
<div id="0" class="audio-item" data-source="{{ files[0].file }}"></div>
|
||||||
{% else %}
|
{% else %}
|
||||||
<div id="0" class="file-item" data-source="{{ files[0].file }}"></div>
|
<div id="0" class="file-item" data-source="{{ files[0].file }}"></div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% else %}
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -5483,7 +5483,6 @@ class FileManager {
|
||||||
], path[6], {
|
], path[6], {
|
||||||
type: blob.type
|
type: blob.type
|
||||||
});
|
});
|
||||||
console.log('FRESH FILE', fresh);
|
|
||||||
this.files.push(fresh);
|
this.files.push(fresh);
|
||||||
if (this.files.length <= count - 1) this.reindexFiles(sortOrder, ++step);
|
if (this.files.length <= count - 1) this.reindexFiles(sortOrder, ++step);
|
||||||
else notify.alert('FILES READY TO UPLOAD', true);
|
else notify.alert('FILES READY TO UPLOAD', true);
|
||||||
|
@ -5511,7 +5510,7 @@ class FileManager {
|
||||||
image.title = escape(theFile.name);
|
image.title = escape(theFile.name);
|
||||||
var span = document.createElement('div');
|
var span = document.createElement('div');
|
||||||
span.style.background = 'url(' + f.target.result + ') no-repeat center center / cover';
|
span.style.background = 'url(' + f.target.result + ') no-repeat center center / cover';
|
||||||
span.className = 'img-item'; //span.setAttribute('data-source', theFile.name);
|
span.className = 'img-item';
|
||||||
image.setAttribute('id', i);
|
image.setAttribute('id', i);
|
||||||
self.storage.push([
|
self.storage.push([
|
||||||
{
|
{
|
||||||
|
@ -5568,13 +5567,11 @@ class FileManager {
|
||||||
break;
|
break;
|
||||||
case 'change':
|
case 'change':
|
||||||
case 'drop':
|
case 'drop':
|
||||||
e.type == 'drop' ? rawList = e.dataTransfer.files : rawList = e.target.files; //this.sortFiles(freshList);
|
e.type == 'drop' ? rawList = e.dataTransfer.files : rawList = e.target.files;
|
||||||
for(var i = 0, f; f = rawList[i]; i++){
|
for(var i = 0, f; f = rawList[i]; i++)// check witch files are cool to upload
|
||||||
// check witch files are cool to upload
|
|
||||||
console.log('TYPE', f.type);
|
|
||||||
if (this.accetableFiles.includes(f.type)) sortedList.push(f);
|
if (this.accetableFiles.includes(f.type)) sortedList.push(f);
|
||||||
else notOnTheList.push(f);
|
else notOnTheList.push(f);
|
||||||
} //send for sorting
|
//send for sorting
|
||||||
self.sortFiles(sortedList);
|
self.sortFiles(sortedList);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,7 +86,6 @@ export default class FileManager {
|
||||||
var path = sortOrder[step].earl.split('/');
|
var path = sortOrder[step].earl.split('/');
|
||||||
utils.imgLoad(sortOrder[step].earl).then(blob => {
|
utils.imgLoad(sortOrder[step].earl).then(blob => {
|
||||||
var fresh = new File([blob], path[6], { type: blob.type });
|
var fresh = new File([blob], path[6], { type: blob.type });
|
||||||
console.log('FRESH FILE', fresh);
|
|
||||||
this.files.push(fresh);
|
this.files.push(fresh);
|
||||||
if (this.files.length <= count - 1) {
|
if (this.files.length <= count - 1) {
|
||||||
this.reindexFiles(sortOrder, ++step);
|
this.reindexFiles(sortOrder, ++step);
|
||||||
|
@ -124,7 +123,6 @@ export default class FileManager {
|
||||||
f.target.result +
|
f.target.result +
|
||||||
') no-repeat center center / cover';
|
') no-repeat center center / cover';
|
||||||
span.className = 'img-item';
|
span.className = 'img-item';
|
||||||
//span.setAttribute('data-source', theFile.name);
|
|
||||||
image.setAttribute('id', i);
|
image.setAttribute('id', i);
|
||||||
self.storage.push([
|
self.storage.push([
|
||||||
{
|
{
|
||||||
|
@ -190,10 +188,8 @@ export default class FileManager {
|
||||||
e.type == 'drop'
|
e.type == 'drop'
|
||||||
? (rawList = e.dataTransfer.files)
|
? (rawList = e.dataTransfer.files)
|
||||||
: (rawList = e.target.files);
|
: (rawList = e.target.files);
|
||||||
//this.sortFiles(freshList);
|
|
||||||
for (var i = 0, f; (f = rawList[i]); i++) {
|
for (var i = 0, f; (f = rawList[i]); i++) {
|
||||||
// check witch files are cool to upload
|
// check witch files are cool to upload
|
||||||
console.log('TYPE', f.type);
|
|
||||||
if (this.accetableFiles.includes(f.type)) {
|
if (this.accetableFiles.includes(f.type)) {
|
||||||
sortedList.push(f);
|
sortedList.push(f);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue