forked from projects/fipamo
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//there's only one verion of the api for now
|
|
||||||
$result = [];
|
|
||||||
switch (isset($args["third"]) ? $args["third"] : "none") {
|
switch (isset($args["third"]) ? $args["third"] : "none") {
|
||||||
case "login":
|
case "login":
|
||||||
$result = Auth::login($body);
|
$result = Auth::login($body);
|
||||||
|
|
|
@ -55,16 +55,16 @@ class DashControl
|
||||||
"status" => Session::active(),
|
"status" => Session::active(),
|
||||||
];
|
];
|
||||||
} else {
|
} else {
|
||||||
header("Location: /dashboard");
|
|
||||||
die();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$template = "dash/start.twig";
|
|
||||||
$pageOptions = [
|
$pageOptions = [
|
||||||
"title" => "Welcome to Fipamo",
|
"title" => "Fipamo | Create Page",
|
||||||
|
"mode" => $mode,
|
||||||
"status" => Session::active(),
|
"status" => Session::active(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
header("Location: /dashboard");
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case "logout":
|
case "logout":
|
||||||
|
|
|
@ -171,23 +171,21 @@ class Book
|
||||||
$writePath = "../content/pages/" . $path . "/" . $body["slug"] . ".md";
|
$writePath = "../content/pages/" . $path . "/" . $body["slug"] . ".md";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($task == "create") {
|
$status = DocTools::write($task, $path, $writePath, $write);
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if ($status) {
|
||||||
$response = [
|
$response = [
|
||||||
"message" => "File edited. Nice work",
|
"message" => "File edited. Nice work",
|
||||||
"type" => $task == "write" ? "postUpdated" : "postAdded",
|
"type" => $task == "write" ? "postUpdated" : "postAdded",
|
||||||
"id" => $uuid,
|
"id" => $uuid,
|
||||||
];
|
];
|
||||||
|
} else {
|
||||||
|
$response = [
|
||||||
|
"message" => "Uh oh. File save problem. Don't panic",
|
||||||
|
"type" => "postError",
|
||||||
|
"id" => $uuid,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
return $response;
|
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/utility/StringTools.inc.php";
|
||||||
include "../brain/data/Session.inc.php";
|
include "../brain/data/Session.inc.php";
|
||||||
include "../brain/utility/FileUploader.inc.php";
|
include "../brain/utility/FileUploader.inc.php";
|
||||||
|
include "../brain/utility/DocTools.inc.php";
|
||||||
|
|
||||||
$app = AppFactory::create();
|
$app = AppFactory::create();
|
||||||
$twig = Twig::create("../brain/views/");
|
$twig = Twig::create("../brain/views/");
|
||||||
|
|
|
@ -93,6 +93,7 @@ export default class Base {
|
||||||
notify.alert(err, false);
|
notify.alert(err, false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
handleRestore(e) {
|
handleRestore(e) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
@ -113,6 +114,7 @@ export default class Base {
|
||||||
notify.alert(err, false);
|
notify.alert(err, false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
**/
|
||||||
handleOptions(e) {
|
handleOptions(e) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
Loading…
Reference in a new issue