|
|
|
@ -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()). ", ";
|
|
|
|
|
|
|
|
|
|
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/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;
|
|
|
|
|
}
|
|
|
|
|
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/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/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");
|
|
|
|
|