page editing cleaned up, fixed date formatting, fixed page filtering, add Image API path
parent
395850adb8
commit
1b9252fef0
@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class ImagesAPI
|
||||||
|
{
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function uploadImage($request)
|
||||||
|
{
|
||||||
|
$image = $request->getUploadedFiles();
|
||||||
|
$path = date("Y") . "/" . date("m");
|
||||||
|
|
||||||
|
$uploadPath = "../public/assets/images/blog/" . $path;
|
||||||
|
|
||||||
|
FileUploader::uploadFile($uploadPath, $image["post_image"]);
|
||||||
|
|
||||||
|
$response = [
|
||||||
|
"message" => "Image Added. Very slick",
|
||||||
|
"type" => "postImageAdded",
|
||||||
|
"url" =>
|
||||||
|
"/assets/images/blog/" .
|
||||||
|
$path .
|
||||||
|
"/" .
|
||||||
|
$image["post_image"]->getClientFileName(),
|
||||||
|
];
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
use Psr\Http\Message\UploadedFileInterface;
|
||||||
|
//include "brain/data/Auth.inc.php";
|
||||||
|
|
||||||
|
class FileUploader
|
||||||
|
{
|
||||||
|
public static function uploadFile(
|
||||||
|
string $directory,
|
||||||
|
UploadedFileInterface $file
|
||||||
|
) {
|
||||||
|
try {
|
||||||
|
if (!is_dir($directory)) {
|
||||||
|
//Directory does not exist, so lets create it.
|
||||||
|
mkdir($directory, 0755, true);
|
||||||
|
}
|
||||||
|
//$upload = move_uploaded_file($file->getClientFileName(), $directory);
|
||||||
|
//$extension = pathinfo($file->getClientFilename(), PATHINFO_EXTENSION);
|
||||||
|
|
||||||
|
// see http://php.net/manual/en/function.random-bytes.php
|
||||||
|
//$basename = bin2hex(random_bytes(8));
|
||||||
|
//$filename = sprintf("%s.%0.8s", $basename, $extension);
|
||||||
|
|
||||||
|
$file->moveTo($directory . "/" . $file->getClientFileName());
|
||||||
|
} catch (Error $e) {
|
||||||
|
echo "failed to upload image: " . $e->getMessage();
|
||||||
|
throw new Error("Failed to upload image file");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,41 +1,41 @@
|
|||||||
import PostIndex from './PostIndex';
|
import PostIndex from "./PostIndex";
|
||||||
import SettingsIndex from './SettingsIndex';
|
import SettingsIndex from "./SettingsIndex";
|
||||||
import NaviIndex from './NavIndex';
|
import NaviIndex from "./NavIndex";
|
||||||
|
|
||||||
export default class DashManager {
|
export default class DashManager {
|
||||||
//--------------------------
|
//--------------------------
|
||||||
// constructor
|
// constructor
|
||||||
//--------------------------
|
//--------------------------
|
||||||
constructor() {
|
constructor() {
|
||||||
this.currentDisplay = '';
|
this.currentDisplay = "";
|
||||||
this.urlPieces = document.URL.split('/');
|
this.urlPieces = document.URL.split("/");
|
||||||
this.chooseDisplay(this.urlPieces[5], this.urlPieces[6]);
|
this.chooseDisplay(this.urlPieces[4], this.urlPieces[5]);
|
||||||
}
|
}
|
||||||
//--------------------------
|
//--------------------------
|
||||||
// methods
|
// methods
|
||||||
//--------------------------
|
//--------------------------
|
||||||
start() {}
|
start() {}
|
||||||
|
|
||||||
chooseDisplay(section, page) {
|
chooseDisplay(section, page) {
|
||||||
this.currentDisplay = '';
|
this.currentDisplay = "";
|
||||||
switch (section) {
|
switch (section) {
|
||||||
case 'page':
|
case "page":
|
||||||
this.currentDisplay = new PostIndex(page);
|
this.currentDisplay = new PostIndex(page);
|
||||||
break;
|
break;
|
||||||
case 'settings':
|
case "settings":
|
||||||
this.currentDisplay = new SettingsIndex();
|
this.currentDisplay = new SettingsIndex();
|
||||||
break;
|
break;
|
||||||
case 'navigation':
|
case "navigation":
|
||||||
this.currentDisplay = new NaviIndex();
|
this.currentDisplay = new NaviIndex();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
//just chill
|
//just chill
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
this.start();
|
this.start();
|
||||||
}
|
}
|
||||||
//--------------------------
|
//--------------------------
|
||||||
// event handlers
|
// event handlers
|
||||||
//--------------------------
|
//--------------------------
|
||||||
}
|
}
|
||||||
|
@ -1,30 +1,30 @@
|
|||||||
import PageEditor from './PageEditor';
|
import PageEditor from "./PageEditor";
|
||||||
export default class PostIndex {
|
export default class PostIndex {
|
||||||
//--------------------------
|
//--------------------------
|
||||||
// constructor
|
// constructor
|
||||||
//--------------------------
|
//--------------------------
|
||||||
constructor(page) {
|
constructor(page) {
|
||||||
this.currentPage = null;
|
this.currentPage = null;
|
||||||
this.choosePage(page);
|
this.choosePage(page);
|
||||||
this.start();
|
this.start();
|
||||||
}
|
}
|
||||||
//--------------------------
|
//--------------------------
|
||||||
// methods
|
// methods
|
||||||
//--------------------------
|
//--------------------------
|
||||||
start() {}
|
start() {}
|
||||||
choosePage(page) {
|
choosePage(page) {
|
||||||
this.currentPage = '';
|
this.currentPage = "";
|
||||||
switch (page) {
|
switch (page) {
|
||||||
case 'edit':
|
case "edit":
|
||||||
case 'add':
|
case "add":
|
||||||
this.currentPage = new PageEditor();
|
this.currentPage = new PageEditor();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
//just chill
|
//just chill
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//--------------------------
|
//--------------------------
|
||||||
// event handlers
|
// event handlers
|
||||||
//--------------------------
|
//--------------------------
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue