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 = [];
|
||||
foreach ($imageList as $item) {
|
||||
$image = trim($item);
|
||||
if ($item != null || $item != "") {
|
||||
array_push($images, $item);
|
||||
if (!empty($image)) {
|
||||
array_push($images, $image);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($fileList as $item) {
|
||||
$file = trim($item);
|
||||
if ($item != null || $item != "") {
|
||||
array_push($files, $item);
|
||||
if (!empty($file)) {
|
||||
array_push($files, $file);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -53,96 +53,67 @@ class Book
|
|||
$path = date("Y") . "/" . date("m");
|
||||
}
|
||||
|
||||
if (isset($files)) {
|
||||
//var_dump($files);
|
||||
if ($task != "create") {
|
||||
$imageList = "";
|
||||
$fileList = "";
|
||||
$page_feature = '';
|
||||
$page_files = '';
|
||||
|
||||
if (isset($files["page_files"])) {
|
||||
$imageList = "";
|
||||
$fileList = "";
|
||||
//var_dump($files["page_files"] );
|
||||
foreach ($files["page_files"] as $file) {
|
||||
$type = $file->getClientMediaType();
|
||||
switch ($type) {
|
||||
case "image/jpeg":
|
||||
case "image/png":
|
||||
case "image/gif":
|
||||
case "image/svg":
|
||||
$imagesPath = "/assets/images/blog/" . $path . "/";
|
||||
$imageList =
|
||||
$imageList . $imagesPath . urlencode($file->getClientFileName()). ", ";
|
||||
foreach ($files["page_files"] as $file) {
|
||||
$type = $file->getClientMediaType();
|
||||
switch ($type) {
|
||||
case "image/jpeg":
|
||||
case "image/png":
|
||||
case "image/gif":
|
||||
case "image/svg":
|
||||
$imagesPath = "/assets/images/blog/" . $path . "/";
|
||||
$imageList =
|
||||
$imageList . $imagesPath . urlencode($file->getClientFileName()). ", ";
|
||||
|
||||
FileUploader::uploadFile(
|
||||
"../public/assets/images/blog/" . $path . "/",
|
||||
$file
|
||||
);
|
||||
break;
|
||||
case "video/mp4":
|
||||
$videosPath = "/assets/video/blog/" . $path . "/";
|
||||
$imageList =
|
||||
$imageList . $videosPath . urlencode($file->getClientFileName()) . ", ";
|
||||
FileUploader::uploadFile(
|
||||
"../public/assets/images/blog/" . $path . "/",
|
||||
$file
|
||||
);
|
||||
break;
|
||||
case "video/mp4":
|
||||
$videosPath = "/assets/video/blog/" . $path . "/";
|
||||
$imageList =
|
||||
$imageList . $videosPath . urlencode($file->getClientFileName()) . ", ";
|
||||
|
||||
FileUploader::uploadFile(
|
||||
"../public/assets/video/blog/" . $path . "/",
|
||||
$file
|
||||
);
|
||||
break;
|
||||
case "audio/mpeg":
|
||||
$soundPath = "/assets/sound/blog/" . $path . "/";
|
||||
$fileList = $fileList . $soundPath . urlencode($file->getClientFileName()). ", ";
|
||||
FileUploader::uploadFile(
|
||||
"../public/assets/video/blog/" . $path . "/",
|
||||
$file
|
||||
);
|
||||
break;
|
||||
case "audio/mpeg":
|
||||
$soundPath = "/assets/sound/blog/" . $path . "/";
|
||||
$fileList = $fileList . $soundPath . urlencode($file->getClientFileName()). ", ";
|
||||
|
||||
FileUploader::uploadFile(
|
||||
"../public/assets/sound/blog/" . $path . "/",
|
||||
$file
|
||||
);
|
||||
break;
|
||||
case 'application/pdf':
|
||||
case 'text/plain':
|
||||
case 'text/rtf':
|
||||
$docPath = "/assets/docs/blog/" . $path . "/";
|
||||
$fileList = $fileList . $docPath . urlencode($file->getClientFileName()). ", ";
|
||||
FileUploader::uploadFile(
|
||||
"../public/assets/sound/blog/" . $path . "/",
|
||||
$file
|
||||
);
|
||||
break;
|
||||
case 'application/pdf':
|
||||
case 'text/plain':
|
||||
case 'text/rtf':
|
||||
$docPath = "/assets/docs/blog/" . $path . "/";
|
||||
$fileList = $fileList . $docPath . urlencode($file->getClientFileName()). ", ";
|
||||
|
||||
FileUploader::uploadFile(
|
||||
"../public/assets/docs/blog/" . $path . "/",
|
||||
$file
|
||||
);
|
||||
break;
|
||||
}
|
||||
FileUploader::uploadFile(
|
||||
"../public/assets/docs/blog/" . $path . "/",
|
||||
$file
|
||||
);
|
||||
break;
|
||||
}
|
||||
$feature = $imageList;
|
||||
$files = $fileList;
|
||||
//var_dump($feature);
|
||||
//return ["message" => "JUST DEBUGGING"];
|
||||
} else {
|
||||
//if creating a new page, from file payload and set $feature and $files
|
||||
/*
|
||||
$feature =
|
||||
"/assets/images/blog/" .
|
||||
$path .
|
||||
"/" .
|
||||
$image["feature_image"]->getClientFileName();
|
||||
*/
|
||||
}
|
||||
$page_feature = $imageList;
|
||||
$page_files = $fileList;
|
||||
} 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 no files, just reset string from page object
|
||||
$page_feature = $page["feature"];
|
||||
$page_files = $page["files"];
|
||||
}
|
||||
|
||||
if ($task == "delete") {
|
||||
|
@ -167,8 +138,8 @@ class Book
|
|||
|
||||
$body["id"] = $id;
|
||||
$body["uuid"] = $uuid;
|
||||
$body["feature"] = $feature;
|
||||
$body["files"] = $files;
|
||||
$body["feature"] = $page_feature;
|
||||
$body["files"] = $page_files;
|
||||
$body["path"] = $path;
|
||||
$body["author"] = $member["handle"];
|
||||
$body["created"] = $created->format("Y-m-d\TH:i:sP");
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<div id="dash-login">
|
||||
<div id="dash-form" class="dash-form">
|
||||
<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="password" name="password" class="form-control" placeholder="Password" required">
|
||||
<button id="login-btn" class='login-btn' type='submit'>
|
||||
|
|
|
@ -44,8 +44,17 @@
|
|||
<div id="post-edit-index-wrapper">
|
||||
<div id="post-feature">
|
||||
{% if page['feature'] == null %}
|
||||
<div id="featured-image-drop">
|
||||
DRAG AND DROP IMAGE OR <label for="featured-image-upload">CLICK TO CHOSE</label>
|
||||
<div id="page-file-manager">
|
||||
<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>
|
||||
{% else %}
|
||||
<div id="page-file-manager">
|
||||
|
@ -64,11 +73,14 @@
|
|||
{% endif %}
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
{% if item.type == "mp4"%}
|
||||
<div id="0" class="video-item" data-source="{{ media[0].file }}"></div>
|
||||
{% if media[0] != '' %}
|
||||
{% if media[0].type == "mp4"%}
|
||||
<div id="0" class="video-item" data-source="{{ media[0].file }}"></div>
|
||||
{% else %}
|
||||
<div id="0" class="img-item" style="background: url({{ media[0].file }}) no-repeat center center / cover"></div>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
|
@ -83,11 +95,16 @@
|
|||
{% endif %}
|
||||
{% endfor %}
|
||||
{% 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>
|
||||
{% else %}
|
||||
<div id="0" class="file-item" data-source="{{ files[0].file }}"></div>
|
||||
{% endif %}
|
||||
|
||||
{% else %}
|
||||
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
|
|
|
@ -5483,7 +5483,6 @@ class FileManager {
|
|||
], path[6], {
|
||||
type: blob.type
|
||||
});
|
||||
console.log('FRESH FILE', fresh);
|
||||
this.files.push(fresh);
|
||||
if (this.files.length <= count - 1) this.reindexFiles(sortOrder, ++step);
|
||||
else notify.alert('FILES READY TO UPLOAD', true);
|
||||
|
@ -5511,7 +5510,7 @@ class FileManager {
|
|||
image.title = escape(theFile.name);
|
||||
var span = document.createElement('div');
|
||||
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);
|
||||
self.storage.push([
|
||||
{
|
||||
|
@ -5568,13 +5567,11 @@ class FileManager {
|
|||
break;
|
||||
case 'change':
|
||||
case 'drop':
|
||||
e.type == 'drop' ? rawList = e.dataTransfer.files : rawList = e.target.files; //this.sortFiles(freshList);
|
||||
for(var i = 0, f; f = rawList[i]; i++){
|
||||
// check witch files are cool to upload
|
||||
console.log('TYPE', f.type);
|
||||
if (this.accetableFiles.includes(f.type)) sortedList.push(f);
|
||||
else notOnTheList.push(f);
|
||||
} //send for sorting
|
||||
e.type == 'drop' ? rawList = e.dataTransfer.files : rawList = e.target.files;
|
||||
for(var i = 0, f; f = rawList[i]; i++)// check witch files are cool to upload
|
||||
if (this.accetableFiles.includes(f.type)) sortedList.push(f);
|
||||
else notOnTheList.push(f);
|
||||
//send for sorting
|
||||
self.sortFiles(sortedList);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -86,7 +86,6 @@ export default class FileManager {
|
|||
var path = sortOrder[step].earl.split('/');
|
||||
utils.imgLoad(sortOrder[step].earl).then(blob => {
|
||||
var fresh = new File([blob], path[6], { type: blob.type });
|
||||
console.log('FRESH FILE', fresh);
|
||||
this.files.push(fresh);
|
||||
if (this.files.length <= count - 1) {
|
||||
this.reindexFiles(sortOrder, ++step);
|
||||
|
@ -124,7 +123,6 @@ export default class FileManager {
|
|||
f.target.result +
|
||||
') no-repeat center center / cover';
|
||||
span.className = 'img-item';
|
||||
//span.setAttribute('data-source', theFile.name);
|
||||
image.setAttribute('id', i);
|
||||
self.storage.push([
|
||||
{
|
||||
|
@ -190,10 +188,8 @@ export default class FileManager {
|
|||
e.type == 'drop'
|
||||
? (rawList = e.dataTransfer.files)
|
||||
: (rawList = e.target.files);
|
||||
//this.sortFiles(freshList);
|
||||
for (var i = 0, f; (f = rawList[i]); i++) {
|
||||
// check witch files are cool to upload
|
||||
console.log('TYPE', f.type);
|
||||
if (this.accetableFiles.includes(f.type)) {
|
||||
sortedList.push(f);
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue