Skip to content

Commit

Permalink
reorganize files
Browse files Browse the repository at this point in the history
  • Loading branch information
waldronmatt committed Oct 22, 2020
1 parent df927ed commit f5ec66a
Show file tree
Hide file tree
Showing 21 changed files with 187 additions and 189 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

A drag & drop event calendar with data permanence.

![FullCalendar with data permanence](img/main.png)
![FullCalendar with data permanence](main.png)

## Purpose

Expand Down
51 changes: 0 additions & 51 deletions class.Event.php

This file was deleted.

40 changes: 0 additions & 40 deletions class.Recurrence.php

This file was deleted.

66 changes: 0 additions & 66 deletions class.Week.php

This file was deleted.

14 changes: 7 additions & 7 deletions addEvent-json.php → core/add-event-json.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
// ini_set('display_startup_errors', 1);
// error_reporting(E_ALL);

require_once('sanitize.php');
require_once('../utils/sanitize.php');

require 'class.Event.php';
require 'class.Recurrence.php';
require 'class.Week.php';
require '../logic/class.Event.php';
require '../logic/class.Recurrence.php';
require '../logic/class.Week.php';

// if event post
if (isset($_POST['title'])) {

// get dates data
$jsonString = file_get_contents('json/events.json');
$jsonString = file_get_contents('../data/events.json');
$data = json_decode($jsonString, true);

$id = end($data)['id'];
Expand Down Expand Up @@ -49,7 +49,7 @@
// store dates
$events = array_merge($data, $addRecurrenceEvents);
$newJsonString = json_encode($events);
file_put_contents('json/events.json', $newJsonString);
file_put_contents('../data/events.json', $newJsonString);

// if single event
} else {
Expand All @@ -68,7 +68,7 @@
// store dates
$data[] = $addSingleEvent;
$newJsonString = json_encode($data);
file_put_contents('json/events.json', $newJsonString);
file_put_contents('../data/events.json', $newJsonString);
}
}
// back to fullCalendar
Expand Down
4 changes: 2 additions & 2 deletions addEvent.php → core/add-event.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
require_once('auth.php');
require_once('sanitize.php');
require_once('./utils/auth.php');
require_once('./utils/sanitize.php');

if (isset($_POST['title'])) {
$title = sanitizeInput($_POST['title']);
Expand Down
4 changes: 2 additions & 2 deletions editEventDate-json.php → core/edit-date-json.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

if (isset($_POST['Event'][0]) && isset($_POST['Event'][1]) && isset($_POST['Event'][2])) {
$jsonString = file_get_contents('json/events.json');
$jsonString = file_get_contents('../data/events.json');
$data = json_decode($jsonString, true);

$start = explode(" ", $_POST['Event'][1]);
Expand All @@ -20,7 +20,7 @@
}
}
$newJsonString = json_encode($data);
file_put_contents('json/events.json', $newJsonString);
file_put_contents('../data/events.json', $newJsonString);

}
//header('Location: '.$_SERVER['HTTP_REFERER']);
Expand Down
2 changes: 1 addition & 1 deletion editEventDate.php → core/edit-date.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

// Connexion à la base de données
require_once('auth.php');
require_once('./utils/auth.php');

if (isset($_POST['Event'][0]) && isset($_POST['Event'][1]) && isset($_POST['Event'][2])){

Expand Down
14 changes: 7 additions & 7 deletions editEventTitle-json.php → core/edit-title-json.php
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
<?php

if (isset($_POST['delete']) && isset($_POST['id'])) {
$jsonString = file_get_contents('json/events.json');
$jsonString = file_get_contents('../data/events.json');
$data = json_decode($jsonString, true);
foreach ($data as $key => $entry) {
if ($entry['id'] == $_POST['id']) {
unset($data[$key]);
}
}
$newJsonString = json_encode($data);
file_put_contents('json/events.json', $newJsonString);
file_put_contents('../data/events.json', $newJsonString);

} else if (isset($_POST['deleteRecurrence']) && isset($_POST['rid'])) {
$jsonString = file_get_contents('json/events.json');
$jsonString = file_get_contents('../data/events.json');
$data = json_decode($jsonString, true);
foreach ($data as $key => $entry) {
if ($entry['rid'] == $_POST['rid']) {
unset($data[$key]);
}
}
$newJsonString = json_encode($data);
file_put_contents('json/events.json', $newJsonString);
file_put_contents('../data/events.json', $newJsonString);

} else if (isset($_POST['title']) && isset($_POST['description']) && isset($_POST['color']) && isset($_POST['id'])) {
$jsonString = file_get_contents('json/events.json');
$jsonString = file_get_contents('../data/events.json');
$data = json_decode($jsonString, true);
foreach ($data as $key => $entry) {
if ($entry['id'] == $_POST['id']) {
Expand All @@ -33,9 +33,9 @@
}
}
$newJsonString = json_encode($data);
file_put_contents('json/events.json', $newJsonString);
file_put_contents('../data/events.json', $newJsonString);

}
header('Location: index-json.php');
header('Location: ../index-json.php');

?>
4 changes: 2 additions & 2 deletions editEventTitle.php → core/editEventTitle.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

require_once('auth.php');
require_once('./utils/auth.php');
if (isset($_POST['delete']) && isset($_POST['id'])){


Expand Down Expand Up @@ -40,7 +40,7 @@
}

}
header('Location: index.php');
header('Location: ../index.php');


?>
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions index-json.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
<div class="modal fade" id="ModalAdd" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<form class="form-horizontal" method="POST" action="addEvent-json.php">
<form class="form-horizontal" method="POST" action="./core/add-event-json.php">
<div class="modal-header">
<h4 class="modal-title" id="myModalLabel">Add Event</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
Expand Down Expand Up @@ -254,7 +254,7 @@
<div class="modal fade" id="ModalEdit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<form class="form-horizontal" method="POST" action="editEventTitle-json.php">
<form class="form-horizontal" method="POST" action="./core/edit-title-json.php">
<div class="modal-header">
<h4 class="modal-title" id="myModalLabel">Edit Event</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
Expand Down Expand Up @@ -402,7 +402,7 @@
},
eventAfterRender: function(eventObj, $el) {
var request = new XMLHttpRequest();
request.open('GET', 'json/events.json', true);
request.open('GET', 'data/events.json', true);
request.onload = function () {
$el.popover({
title: eventObj.title,
Expand Down Expand Up @@ -462,7 +462,7 @@ function edit(event) {
Event[2] = end;
$.ajax({
url: 'editEventDate-json.php',
url: './core/edit-date-json.php',
type: "POST",
data: {Event:Event},
success: function(rep) {
Expand Down
9 changes: 4 additions & 5 deletions index.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
require_once('auth.php');
require_once('./utils/auth.php');


$sql = "SELECT id, title, description, start, end, color FROM events ";
Expand Down Expand Up @@ -93,7 +93,7 @@
<div class="modal fade" id="ModalAdd" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<form class="form-horizontal" method="POST" action="addEvent.php">
<form class="form-horizontal" method="POST" action="./core/add-event.php">

<div class="modal-header">
<h4 class="modal-title" id="myModalLabel">Add Event</h4>
Expand Down Expand Up @@ -158,8 +158,7 @@
<div class="modal fade" id="ModalEdit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<form class="form-horizontal" method="POST" action="editEventTitle.php">
<form class="form-horizontal" method="POST" action="editEventTitle.php">
<form class="form-horizontal" method="POST" action="./core/edit-title.php">
<div class="modal-header">
<h4 class="modal-title" id="myModalLabel">Edit Event</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
Expand Down Expand Up @@ -353,7 +352,7 @@ function edit(event){
Event[2] = end;

$.ajax({
url: 'editEventDate.php',
url: './core/edit-date.php',
type: "POST",
data: {Event:Event},
success: function(rep) {
Expand Down
Loading

0 comments on commit f5ec66a

Please sign in to comment.