added remaining upload types, updated templates for new file types

pull/84/head
Ro 3 years ago
parent 523b611ac5
commit 2210e39aee

@ -110,7 +110,10 @@ class DashControl
}
$imageList = explode(",", $page["feature"]);
$fileList = explode(",", $page["files"]);
$images = [];
$files = [];
foreach ($imageList as $item) {
$image = trim($item);
if ($item != null || $item != "") {
@ -118,6 +121,13 @@ class DashControl
}
}
foreach ($fileList as $item) {
$file = trim($item);
if ($item != null || $item != "") {
array_push($files, $item);
}
}
$pageOptions = [
"title" => "Fipamo | Edit Page",
"page" => $page,
@ -125,6 +135,7 @@ class DashControl
"token" => Session::get("form_token"),
"status" => Session::active(),
"images" => $images,
"files"=>$files,
"views" => $views,
];
break;

@ -57,6 +57,7 @@ class Book
//var_dump($files);
if ($task != "create") {
$imageList = "";
$fileList = "";
//var_dump($files["page_files"] );
foreach ($files["page_files"] as $file) {
$type = $file->getClientMediaType();
@ -84,19 +85,45 @@ class Book
$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/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();
*/
}
} else {
//if no files, do no file stuff
/*
if (isset($body["feature_image"])) {
$url = explode("/", $body["feature_image"]);
$feature =
@ -113,8 +140,9 @@ class Book
"/" .
$url[8];
} else {
$task == "create" ? ($feature = "") : ($feature = $body["feature"]);
//$task == "create" ? ($feature = "") : ($feature = $body["feature"]);
}
*/
}
if ($task == "delete") {
@ -140,6 +168,7 @@ class Book
$body["id"] = $id;
$body["uuid"] = $uuid;
$body["feature"] = $feature;
$body["files"] = $files;
$body["path"] = $path;
$body["author"] = $member["handle"];
$body["created"] = $created->format("Y-m-d\TH:i:sP");
@ -163,8 +192,7 @@ class Book
$settings = $config->getSettings();
$message = "";
if (
$settings["global"]["renderOnSave"] == "true" &&
if ($settings["global"]["renderOnSave"] == "true" &&
$settings["global"]["dynamicRender"] == "false"
) {
$render = new Render();

@ -99,14 +99,31 @@ class Contents
$sanitizer = $builder->build($detergent);
$scrubbed = $sanitizer->sanitize($result->getContent());
$featureList = explode(",", $meta["feature"]);
$docs = '';
if (isset($meta["files"])) {
$fileList = explode(",", $meta["files"]);
$docs = $meta["files"];
} else {
$fileList = [];
$docs = '';
}
$media = [];
$files = [];
foreach ($featureList as $file) {
$item = trim($file);
$ext = explode(".", $item);
$ext = pathinfo($item, PATHINFO_EXTENSION);
if ($item != null || $item != "") {
array_push($media, ["file"=>$item, "type"=>trim($ext)]);
}
}
foreach ($fileList as $file) {
$item = trim($file);
$ext = pathinfo($item, PATHINFO_EXTENSION);
if ($item != null || $item != "") {
array_push($media, ["file"=>$item, "type"=>trim($ext[1])]);
array_push($files, ["file"=>$item, "type"=>trim($ext)]);
}
}
@ -116,6 +133,7 @@ class Contents
"uuid" => $meta["uuid"],
"title" => $meta["title"],
"feature" => $meta["feature"],
"files" => $docs,
"path" => $meta["path"],
"layout" => $meta["layout"],
"tags" => $meta["tags"],
@ -135,6 +153,7 @@ class Contents
"content" => $parsed->getContent(),
"html" => $scrubbed,
"media" => $media,
"docs"=>$files
];
//checks for duplicates
$uuid = $meta["uuid"];

@ -100,6 +100,9 @@ class DocTools
"feature: " .
$object["feature"] .
"\n" .
"files: " .
$object["files"] .
"\n" .
"path: " .
$object["path"] .
"\n" .

@ -15,6 +15,7 @@
{% set date = page['created'] %}
{% set updated = page['updated'] %}
{% set media = page['media'] %}
{% set files = page['docs'] %}
{% else %}
{% set id = '' %}
{% set uuid = '' %}
@ -27,6 +28,7 @@
{% set date = '' %}
{% set updated = '' %}
{% set media = '' %}
{% set files = '' %}
{% endif %}
{% block title %}
@ -71,7 +73,24 @@
</div>
FILES
<div id="page-files-list"></div>
<div id="page-files-list">
{% if files|length > 1 %}
{% for item in files %}
{% if item.type == "mp3"%}
<div id="{{loop.index0}}" class="audio-item" data-source="{{ item.file }}"></div>
{% else %}
<div id="{{loop.index0}}" class="file-item" data-source="{{ item.file }}"></div>
{% endif %}
{% endfor %}
{% else %}
{% if item.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 %}
{% endif %}
</div>
</div>
</div>
@ -141,5 +160,5 @@
{% endblock %}
{% block javascripts %}
<script src="/assets/scripts/Start.js?=dfnmf" type="text/javascript"></script>
<script src="/assets/scripts/Start.js?=erty" type="text/javascript"></script>
{% endblock %}

@ -27,7 +27,7 @@
{% for page in data['pages'] %}
{% if page.media[0].type == 'mp4' %}
<a href="/dashboard/page/edit/{{ page.uuid }}" id="{{ page.uuid }}" class="page-link">
<a href="/dashboard/page/edit/{{ page.uuid }}" id="{{ page.uuid }}" class="post-video-link">
<video class="post-video" loop muted autoplay>
<source src="{{ page.media[0].file }}" type="video/mp4">

@ -3218,10 +3218,10 @@ select {
margin: 0;
padding: 0;
}
#post-edit-index #post-edit-index-wrapper #post-feature #page-file-manager #page-file-wrapper #page-images-list {
#post-edit-index #post-edit-index-wrapper #post-feature #page-file-manager #page-file-wrapper #page-images-list, #post-edit-index #post-edit-index-wrapper #post-feature #page-file-manager #page-file-wrapper #page-files-list {
padding: 10px 0 0 0;
}
#post-edit-index #post-edit-index-wrapper #post-feature #page-file-manager #page-file-wrapper #page-images-list .img-item {
#post-edit-index #post-edit-index-wrapper #post-feature #page-file-manager #page-file-wrapper #page-images-list .img-item, #post-edit-index #post-edit-index-wrapper #post-feature #page-file-manager #page-file-wrapper #page-files-list .img-item {
height: 150px;
width: 23.8%;
border-radius: 3px;
@ -3229,7 +3229,7 @@ select {
display: inline-block;
cursor: pointer;
}
#post-edit-index #post-edit-index-wrapper #post-feature #page-file-manager #page-file-wrapper #page-images-list .audio-item {
#post-edit-index #post-edit-index-wrapper #post-feature #page-file-manager #page-file-wrapper #page-images-list .audio-item, #post-edit-index #post-edit-index-wrapper #post-feature #page-file-manager #page-file-wrapper #page-files-list .audio-item {
height: 150px;
width: 23.8%;
border-radius: 3px;
@ -3239,7 +3239,7 @@ select {
background: #1D3040;
background: url("/assets/images/global/upload-audio.png") no-repeat center center/cover;
}
#post-edit-index #post-edit-index-wrapper #post-feature #page-file-manager #page-file-wrapper #page-images-list .video-item {
#post-edit-index #post-edit-index-wrapper #post-feature #page-file-manager #page-file-wrapper #page-images-list .video-item, #post-edit-index #post-edit-index-wrapper #post-feature #page-file-manager #page-file-wrapper #page-files-list .video-item {
height: 150px;
width: 23.8%;
border-radius: 3px;
@ -3249,6 +3249,16 @@ select {
background: #1D3040;
background: url("/assets/images/global/upload-video.png") no-repeat center center/cover;
}
#post-edit-index #post-edit-index-wrapper #post-feature #page-file-manager #page-file-wrapper #page-images-list .file-item, #post-edit-index #post-edit-index-wrapper #post-feature #page-file-manager #page-file-wrapper #page-files-list .file-item {
height: 150px;
width: 23.8%;
border-radius: 3px;
margin: 0 10px 10px 0;
display: inline-block;
cursor: pointer;
background: #1D3040;
background: url("/assets/images/global/upload-doc.png") no-repeat center center/cover;
}
#post-edit-index #post-edit-index-wrapper #edit-post {
width: 100%;
max-width: 880px;

@ -1810,7 +1810,7 @@ class PostActions {
pageInfo.append('form_token', document.getElementById('form_token').value);
if (files.length > 0 && files != null) for(var i = 0; i < files.length; i++){
var file = files[i];
if (file.type.match('image.*') || file.type.match('video.mp4')) pageInfo.append('page_files[]', file, file.name);
if (file.type.match('image.*') || file.type.match('video.mp4') || file.type.match('audio.mpeg') || file.type.match('application.pdf') || file.type.match('text.plain') || file.type.match('text.rtf')) pageInfo.append('page_files[]', file, file.name);
else reject('Not an image file');
}
else //check to see if image exists
@ -5417,7 +5417,10 @@ class FileManager {
'image/png',
'image/svg',
'audio/mpeg',
'video/mp4'
'video/mp4',
'application/pdf',
'text/plain',
'text/rtf'
];
this.files = [];
this.sortedFiles = [];
@ -5444,7 +5447,21 @@ class FileManager {
if (item.className == 'img-item') url = item.style.backgroundImage.slice(4, -1).replace(/"/g, '');
else url = item.getAttribute('data-source');
currentFiles.push({
id: item.getAttribute('id'),
earl: url
});
}
this.reindexFiles(currentFiles, 0);
}
});
_sortablejsDefault.default.create(this.fileList, {
onUpdate: (e)=>{
notify.alert('REINDEXING FILES', null);
let currentFiles = [];
let items = e.target.children;
for(let index = 0; index < items.length; index++){
var item = items[index];
let url = item.getAttribute('data-source');
currentFiles.push({
earl: url
});
}
@ -5476,7 +5493,8 @@ class FileManager {
var self = this;
this.files = []; //clear files array
this.imageList.innerHTML = '';
for(var i = 0, file; file = files[i]; i++){
this.fileList.innerHTML = '';
for(var i = 0, file1; file1 = files[i]; i++){
var reader = new FileReader(); // Closure to capture the file information
reader.onload = ((theFile)=>{
return function(f) {
@ -5516,12 +5534,23 @@ class FileManager {
case 'audio/mpeg':
var sound = document.createElement('div');
sound.className = 'audio-item';
sound.setAttribute('data-source', f.target.result);
self.fileList.appendChild(sound);
self.files.push(theFile);
break;
case 'application/pdf':
case 'text/plain':
case 'text/rtf':
var file = document.createElement('div');
file.className = 'file-item';
file.setAttribute('data-source', f.target.result);
self.fileList.appendChild(file);
self.files.push(theFile);
break;
}
};
})(file); // Read in the image file as a data URL.
reader.readAsDataURL(file);
})(file1); // Read in the image file as a data URL.
reader.readAsDataURL(file1);
}
}
// event handlers

@ -59,7 +59,14 @@ export default class PostActions {
if (files.length > 0 && files != null) {
for (var i = 0; i < files.length; i++) {
var file = files[i];
if (file.type.match('image.*') || file.type.match('video.mp4')) {
if (
file.type.match('image.*') ||
file.type.match('video.mp4') ||
file.type.match('audio.mpeg') ||
file.type.match('application.pdf') ||
file.type.match('text.plain') ||
file.type.match('text.rtf')
) {
pageInfo.append('page_files[]', file, file.name);
} else {
reject('Not an image file');

@ -18,7 +18,10 @@ export default class FileManager {
'image/png',
'image/svg',
'audio/mpeg',
'video/mp4'
'video/mp4',
'application/pdf',
'text/plain',
'text/rtf'
];
this.files = [];
this.sortedFiles = [];
@ -48,7 +51,22 @@ export default class FileManager {
}
currentFiles.push({
id: item.getAttribute('id'),
earl: url
});
}
this.reindexFiles(currentFiles, 0);
}
});
Sortable.create(this.fileList, {
onUpdate: e => {
notify.alert('REINDEXING FILES', null);
let currentFiles = [];
let items = e.target.children;
for (let index = 0; index < items.length; index++) {
var item = items[index];
let url = item.getAttribute('data-source');
currentFiles.push({
earl: url
});
}
@ -82,6 +100,7 @@ export default class FileManager {
var self = this;
this.files = []; //clear files array
this.imageList.innerHTML = '';
this.fileList.innerHTML = '';
for (var i = 0, file; (file = files[i]); i++) {
var reader = new FileReader();
// Closure to capture the file information
@ -126,31 +145,22 @@ export default class FileManager {
video.setAttribute('data-source', f.target.result);
self.imageList.appendChild(video);
self.files.push(theFile);
/*
var video = document.createElement('video');
video.setAttribute('id', escape(theFile.name));
video.className = 'video-item';
video.src = f.target.result;
video.controls = 'controls';
video.type = f.type;
self.imageList.appendChild(video);
*/
break;
case 'audio/mpeg':
var sound = document.createElement('div');
sound.className = 'audio-item';
sound.setAttribute('data-source', f.target.result);
self.fileList.appendChild(sound);
/*
var sound = document.createElement('audio');
sound.setAttribute('id', escape(theFile.name));
sound.className = 'audio-item';
sound.src = f.target.result;
sound.controls = 'controls';
sound.type = f.type;
self.imageList.appendChild(sound);
*/
self.files.push(theFile);
break;
case 'application/pdf':
case 'text/plain':
case 'text/rtf':
var file = document.createElement('div');
file.className = 'file-item';
file.setAttribute('data-source', f.target.result);
self.fileList.appendChild(file);
self.files.push(theFile);
break;
}
};

@ -296,7 +296,7 @@
width: 100%
margin: 0
padding: 0
#page-images-list
#page-images-list, #page-files-list
padding: 10px 0 0 0
.img-item
height: 150px
@ -323,6 +323,15 @@
cursor: pointer
background: $primary
background: url('/assets/images/global/upload-video.png') no-repeat center center / cover
.file-item
height: 150px
width: 23.8%
border-radius: 3px
margin: 0 10px 10px 0
display: inline-block
cursor: pointer
background: $primary
background: url('/assets/images/global/upload-doc.png') no-repeat center center / cover
#edit-post

Loading…
Cancel
Save