display per session status clean up
This commit is contained in:
parent
9cf0cbfbe4
commit
bc6fc33592
6 changed files with 53 additions and 25 deletions
|
@ -36,8 +36,6 @@ class APIControl
|
|||
break;
|
||||
}
|
||||
|
||||
//there's only one verion of the api for now
|
||||
$result = [];
|
||||
switch (isset($args["third"]) ? $args["third"] : "none") {
|
||||
case "login":
|
||||
$result = Auth::login($body);
|
||||
|
|
|
@ -55,15 +55,15 @@ class DashControl
|
|||
"status" => Session::active(),
|
||||
];
|
||||
} else {
|
||||
header("Location: /dashboard");
|
||||
die();
|
||||
$pageOptions = [
|
||||
"title" => "Fipamo | Create Page",
|
||||
"mode" => $mode,
|
||||
"status" => Session::active(),
|
||||
];
|
||||
}
|
||||
} else {
|
||||
$template = "dash/start.twig";
|
||||
$pageOptions = [
|
||||
"title" => "Welcome to Fipamo",
|
||||
"status" => Session::active(),
|
||||
];
|
||||
header("Location: /dashboard");
|
||||
die();
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
|
@ -171,23 +171,21 @@ class Book
|
|||
$writePath = "../content/pages/" . $path . "/" . $body["slug"] . ".md";
|
||||
}
|
||||
|
||||
if ($task == "create") {
|
||||
if (!is_dir("../content/pages/" . $path)) {
|
||||
//Directory does not exist, so lets create it.
|
||||
mkdir("../content/pages/" . $path, 0755, true);
|
||||
}
|
||||
file_put_contents($writePath, $write);
|
||||
} else {
|
||||
($new = fopen($writePath, "w")) or die("Unable to open file!");
|
||||
fwrite($new, $write);
|
||||
fclose($new);
|
||||
}
|
||||
$status = DocTools::write($task, $path, $writePath, $write);
|
||||
|
||||
$response = [
|
||||
"message" => "File edited. Nice work",
|
||||
"type" => $task == "write" ? "postUpdated" : "postAdded",
|
||||
"id" => $uuid,
|
||||
];
|
||||
if ($status) {
|
||||
$response = [
|
||||
"message" => "File edited. Nice work",
|
||||
"type" => $task == "write" ? "postUpdated" : "postAdded",
|
||||
"id" => $uuid,
|
||||
];
|
||||
} else {
|
||||
$response = [
|
||||
"message" => "Uh oh. File save problem. Don't panic",
|
||||
"type" => "postError",
|
||||
"id" => $uuid,
|
||||
];
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
|
29
brain/utility/DocTools.inc.php
Normal file
29
brain/utility/DocTools.inc.php
Normal file
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
class DocTools
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public static function write($task, $path, $fileLocation, $fileContents)
|
||||
{
|
||||
try {
|
||||
if ($task == "create") {
|
||||
if (!is_dir("../content/pages/" . $path)) {
|
||||
//Directory does not exist, so lets create it.
|
||||
mkdir("../content/pages/" . $path, 0755, true);
|
||||
}
|
||||
file_put_contents($fileLocation, $fileContents);
|
||||
} else {
|
||||
($new = fopen($fileLocation, "w")) or die("Unable to open file!");
|
||||
fwrite($new, $fileContents);
|
||||
fclose($new);
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (Error $error) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -12,6 +12,7 @@ include "../brain/data/Auth.inc.php";
|
|||
include "../brain/utility/StringTools.inc.php";
|
||||
include "../brain/data/Session.inc.php";
|
||||
include "../brain/utility/FileUploader.inc.php";
|
||||
include "../brain/utility/DocTools.inc.php";
|
||||
|
||||
$app = AppFactory::create();
|
||||
$twig = Twig::create("../brain/views/");
|
||||
|
|
|
@ -93,6 +93,7 @@ export default class Base {
|
|||
notify.alert(err, false);
|
||||
});
|
||||
}
|
||||
/**
|
||||
handleRestore(e) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
|
@ -113,6 +114,7 @@ export default class Base {
|
|||
notify.alert(err, false);
|
||||
});
|
||||
}
|
||||
**/
|
||||
handleOptions(e) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
|
|
Loading…
Reference in a new issue