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 SettingsIndex from './SettingsIndex';
|
||||
import NaviIndex from './NavIndex';
|
||||
import PostIndex from "./PostIndex";
|
||||
import SettingsIndex from "./SettingsIndex";
|
||||
import NaviIndex from "./NavIndex";
|
||||
|
||||
export default class DashManager {
|
||||
//--------------------------
|
||||
// constructor
|
||||
//--------------------------
|
||||
constructor() {
|
||||
this.currentDisplay = '';
|
||||
this.urlPieces = document.URL.split('/');
|
||||
this.chooseDisplay(this.urlPieces[5], this.urlPieces[6]);
|
||||
}
|
||||
//--------------------------
|
||||
// methods
|
||||
//--------------------------
|
||||
start() {}
|
||||
//--------------------------
|
||||
// constructor
|
||||
//--------------------------
|
||||
constructor() {
|
||||
this.currentDisplay = "";
|
||||
this.urlPieces = document.URL.split("/");
|
||||
this.chooseDisplay(this.urlPieces[4], this.urlPieces[5]);
|
||||
}
|
||||
//--------------------------
|
||||
// methods
|
||||
//--------------------------
|
||||
start() {}
|
||||
|
||||
chooseDisplay(section, page) {
|
||||
this.currentDisplay = '';
|
||||
switch (section) {
|
||||
case 'page':
|
||||
this.currentDisplay = new PostIndex(page);
|
||||
break;
|
||||
case 'settings':
|
||||
this.currentDisplay = new SettingsIndex();
|
||||
break;
|
||||
case 'navigation':
|
||||
this.currentDisplay = new NaviIndex();
|
||||
break;
|
||||
chooseDisplay(section, page) {
|
||||
this.currentDisplay = "";
|
||||
switch (section) {
|
||||
case "page":
|
||||
this.currentDisplay = new PostIndex(page);
|
||||
break;
|
||||
case "settings":
|
||||
this.currentDisplay = new SettingsIndex();
|
||||
break;
|
||||
case "navigation":
|
||||
this.currentDisplay = new NaviIndex();
|
||||
break;
|
||||
|
||||
default:
|
||||
//just chill
|
||||
break;
|
||||
}
|
||||
this.start();
|
||||
}
|
||||
//--------------------------
|
||||
// event handlers
|
||||
//--------------------------
|
||||
default:
|
||||
//just chill
|
||||
break;
|
||||
}
|
||||
this.start();
|
||||
}
|
||||
//--------------------------
|
||||
// event handlers
|
||||
//--------------------------
|
||||
}
|
||||
|
@ -1,30 +1,30 @@
|
||||
import PageEditor from './PageEditor';
|
||||
import PageEditor from "./PageEditor";
|
||||
export default class PostIndex {
|
||||
//--------------------------
|
||||
// constructor
|
||||
//--------------------------
|
||||
constructor(page) {
|
||||
this.currentPage = null;
|
||||
this.choosePage(page);
|
||||
this.start();
|
||||
}
|
||||
//--------------------------
|
||||
// methods
|
||||
//--------------------------
|
||||
start() {}
|
||||
choosePage(page) {
|
||||
this.currentPage = '';
|
||||
switch (page) {
|
||||
case 'edit':
|
||||
case 'add':
|
||||
this.currentPage = new PageEditor();
|
||||
break;
|
||||
default:
|
||||
//just chill
|
||||
break;
|
||||
}
|
||||
}
|
||||
//--------------------------
|
||||
// event handlers
|
||||
//--------------------------
|
||||
//--------------------------
|
||||
// constructor
|
||||
//--------------------------
|
||||
constructor(page) {
|
||||
this.currentPage = null;
|
||||
this.choosePage(page);
|
||||
this.start();
|
||||
}
|
||||
//--------------------------
|
||||
// methods
|
||||
//--------------------------
|
||||
start() {}
|
||||
choosePage(page) {
|
||||
this.currentPage = "";
|
||||
switch (page) {
|
||||
case "edit":
|
||||
case "add":
|
||||
this.currentPage = new PageEditor();
|
||||
break;
|
||||
default:
|
||||
//just chill
|
||||
break;
|
||||
}
|
||||
}
|
||||
//--------------------------
|
||||
// event handlers
|
||||
//--------------------------
|
||||
}
|
||||
|
Loading…
Reference in New Issue