pouet mise a jour pouet

This commit is contained in:
2019-03-05 14:20:14 +01:00
parent 0ebf00dd4c
commit bd886e444e
15 changed files with 259 additions and 123 deletions

View File

@ -14,18 +14,17 @@ class PostController extends Controller {
* @title Modification d'article
*/
public function postEdit() {
if(isset($_GET["post"]) && isset($_GET["title"]) && isset($_GET["category"]) && isset($_GET["content"]) && isset($_GET["tags"])) {
if(isset($_GET["post"]) && isset($_POST["title"]) && isset($_POST["category"]) && isset($_POST["content"]) && isset($_POST["tags"])) {
var_dump($_POST["content"]);
$post = Post::get($_GET["post"]);
$post->setTitle($_GET["title"]);
$post->setContent($_GET["content"]);
$post->setCategory($_GET["category"]);
$post->setTitle($_POST["title"]);
$post->setContent($_POST["content"]);
$post->setCategory($_POST["category"]);
$tags = explode(",", $_GET["tags"]);
$tags = explode(",", $_POST["tags"]);
$tgs = array();
foreach ($tags as $tag) {
var_dump($tag);
var_dump(Tag::getByName($tag));
if(!(Tag::getByName($tag))) {
$tgs[] = Tag::add((new Tag())->setName($tag))->getId();
} else {
@ -47,21 +46,16 @@ class PostController extends Controller {
*/
public function postAdd() {
var_dump($_GET);
// die;
if(isset($_GET["title"]) && isset($_GET["category"]) && isset($_GET["content"]) && isset($_GET["tags"])) {
if(isset($_POST["title"]) && isset($_POST["category"]) && isset($_POST["content"]) && isset($_POST["tags"])) {
$post = new Post();
$post->setTitle($_GET["title"]);
$post->setContent($_GET["content"]);
$post->setCategory($_GET["category"]);
$post->setTitle($_POST["title"]);
$post->setContent($_POST["content"]);
$post->setCategory($_POST["category"]);
// $post->setAuthor();
$tags = explode(",", $_GET["tags"]);
$tags = explode(",", $_POST["tags"]);
$tgs = array();
foreach ($tags as $tag) {
var_dump($tag);
var_dump(Tag::getByName($tag));
if(!(Tag::getByName($tag))) {
$tgs[] = Tag::add((new Tag())->setName($tag))->getId();
} else {
@ -86,4 +80,32 @@ class PostController extends Controller {
public function post() {
return file_get_contents(DIR."/html/post.html");
}
/**
* @route /^\/post\/[0-9]+\/upload\/$/
*/
public function upload() {
if($_GET["post"] && $_FILES["file"]) {
$post = $_GET['post'];
if($post == "new") $post = "temp";
$uploadFolder = DIR."/../uploads/posts/".$_GET["post"]."/";
if(!file_exists($uploadFolder)) {
mkdir($uploadFolder, 0660, true);
}
if(isset($_FILES["file"]) && !empty($_FILES["file"])) {
var_dump($_FILES["file"]);
move_uploaded_file($_FILES["file"]["tmp_name"], $uploadFolder.$_FILES["file"]["name"]);
// require_once "functions.php";
// file_put_contents($uploadFolder."/pouet.jpg", base64_decode($_POST["image"]));
// base64_to_jpeg($_POST["image"], $uploadFolder."/pouet.jpg");
// file_put_content($uploadFolder."/pouet.jpg", base64_decode(preg_replace('#^data:image/\w+;base64,#i', '', $_POST["image"])));
}
}
}
}