Commit 25bc303e authored by Orbmancer's avatar Orbmancer
Browse files

functionnal save & load

parent 92ddf7a4
<?php
class Data {
public static function saveXML($data, $name, $x, $y, $TD = 1){
if(file_put_contents('data/td'.$TD.'/'.$x.'_'.$y.'-'.$name.'.vvvvvv', $data)){
echo 'Okay man !';
}
}
public static function loadXML($TD){
$output = array();
$dir = 'data/td'.$TD.'/';
if ($handle = opendir($dir)) {
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != "..") {
$output[] = file_get_contents($dir.$entry);
}
}
closedir($handle);
}
return $output;
}
}
......@@ -30,19 +30,19 @@
<br/>
<div class="row">
<div class="col-md-6 col-md-offset-3">
<form class="form-horizontal">
<form class="form-horizontal" action="merge.php" method="POST">
<fieldset>
<div class="form-group">
<label for="inputName" class="col-lg-2 control-label">Level name</label>
<div class="col-lg-10">
<input type="text" class="form-control" id="inputName" placeholder="Level Name">
<input type="text" class="form-control" name="name" id="inputName" placeholder="Level Name">
</div>
</div>
<div class="form-group">
<label for="textArea" class="col-lg-2 control-label">Level content</label>
<div class="col-lg-10">
<textarea class="form-control" rows="3" id="textArea"></textarea>
<span class="help-block">The content of</span>
<textarea class="form-control" name="data" rows="3" id="textArea"></textarea>
<span class="help-block">The content of your actual level</span>
</div>
</div>
<div class="form-group">
......@@ -50,13 +50,13 @@
<div class="col-lg-10">
<div class="radio">
<label>
<input type="radio" name="optionsRadios" id="optionsRadios1" value="option1" checked="">
<input type="radio" name="td" id="optionsRadios1" value="1" checked="">
TD 13h15-16h15
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="optionsRadios" id="optionsRadios2" value="option2">
<input type="radio" name="td" id="optionsRadios2" value="2">
TD 16h30-19h30
</label>
</div>
......@@ -65,7 +65,7 @@
<div class="form-group">
<label class="col-lg-2 control-label">Where to put the level ?</label>
<div class="col-lg-5">
<select class="form-control" id="x">
<select class="form-control" name="x">
<option>1</option>
<option>2</option>
<option>3</option>
......@@ -74,7 +74,7 @@
</select>
</div>
<div class="col-lg-5">
<select class="form-control" id="y">
<select class="form-control" name="y">
<option>1</option>
<option>2</option>
<option>3</option>
......
<?php
/**
* Created by PhpStorm.
* User: Damien
* Date: 01/06/2015
* Time: 15:23
*/
\ No newline at end of file
error_reporting(E_ALL);
ini_set('display_errors', 1);
require 'Data.class.php';
$name = $_POST['name'];
$data = $_POST['data'];
$x = $_POST['x'];
$y = $_POST['y'];
$td = $_POST['td'];
var_dump($name);
var_dump($data);
var_dump($x);
var_dump($y);
var_dump($td);
Data::saveXML($data, $name, $x, $y, $td);
echo '<br/>';
var_dump(Data::loadXML($td));
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment