You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.1 KiB
PHTML
53 lines
1.1 KiB
PHTML
4 years ago
|
<?php
|
||
|
|
||
|
use Slim\Views\Twig;
|
||
|
|
||
|
class SettingsAPI
|
||
|
{
|
||
|
public function __construct()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
public static function handleSettingsTask($request, $args)
|
||
|
{
|
||
|
$task = $args["fourth"];
|
||
|
echo $task;
|
||
|
switch ($task) {
|
||
|
case "publish":
|
||
|
$view = Twig::fromRequest($request);
|
||
|
|
||
|
$template = "dash/start.twig";
|
||
|
$pageOptions = [
|
||
|
"title" => "Welcome to Fucking Fipamo",
|
||
|
"status" => false,
|
||
|
];
|
||
|
|
||
|
$html = $view->fetch($template, $pageOptions);
|
||
|
|
||
|
$location = "../content/test.html";
|
||
|
if (!is_file($location)) {
|
||
|
file_put_contents($location, $html);
|
||
|
} else {
|
||
|
($new = fopen($location, "w")) or die("Unable to open file!");
|
||
|
fwrite($new, $html);
|
||
|
fclose($new);
|
||
|
}
|
||
|
|
||
|
$result = [
|
||
|
"message" => "Site published. GOOD EFFORT",
|
||
|
"type" => "TASK_NONE",
|
||
|
];
|
||
|
|
||
|
break;
|
||
|
default:
|
||
|
$result = [
|
||
|
"message" => "Hm, no task. That's unfortunate",
|
||
|
"type" => "TASK_NONE",
|
||
|
];
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
return $result;
|
||
|
}
|
||
|
}
|