Use an i18n tool
This commit is contained in:
parent
e487438606
commit
16dec853f9
12 changed files with 662 additions and 97 deletions
89
create.php
89
create.php
|
@ -1,88 +1,75 @@
|
|||
<?php
|
||||
|
||||
include('init.php');
|
||||
include('templates/header.php');
|
||||
include('db.php');
|
||||
|
||||
if (empty($_POST)) {
|
||||
?>
|
||||
<div id="cloud_create">
|
||||
<form method="post" action="create.php">
|
||||
<div class="cloud_create_element">
|
||||
<label id="ftext_l" for="ftext">Description du nuage</label>
|
||||
<textarea id="ftext" name="ftext" rows="3" cols="60" placeholder="Votre texte ici"></textarea>
|
||||
<label id="ftext_l" for="ftext"><?php echo L::cloud_description ?></label>
|
||||
<textarea id="ftext" name="ftext" rows="3" cols="50" placeholder="<?php echo L::cloud_description_message ?>"></textarea>
|
||||
</div>
|
||||
<div class="cloud_create_element">
|
||||
<label for="fduration">
|
||||
<span title="Durée après laquelle le nuage sera supprimé">
|
||||
Durée de vie du nuage
|
||||
</span>
|
||||
</label>
|
||||
<label for="fduration"><span title="<?php echo L::cloud_duration_tooltip ?>"><?php echo L::cloud_duration ?></span></label>
|
||||
<select id="fduration" name="fduration">
|
||||
<?php
|
||||
foreach (DataBase::OPTIONS_DURATION as $name => $duration) {
|
||||
echo sprintf('<option valu="%s">%s</option>', $name, $name);
|
||||
echo sprintf('<option value="%s">%s</option>', $name, constant('L::duration_' . $name));
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="cloud_create_element">
|
||||
<label for="fsize">Nombre de mots maximum par entrée</label>
|
||||
<input type="number" id="fsize" name="fsize" min="1" max="9">
|
||||
<label for="fsize"><?php echo L::cloud_size ?></label>
|
||||
<input type="number" id="fsize" name="fsize" min="1" max="9" value=<?php echo DataBase::DEFAULT_SIZE ?>>
|
||||
</div>
|
||||
<input type="submit" value="Créer">
|
||||
<input type="submit" id="cloud_create_submit" value="<?php echo L::create ?>">
|
||||
</form>
|
||||
</div>
|
||||
<?php
|
||||
} else {
|
||||
|
||||
$db = new DataBase();
|
||||
if (!$db->isInit()) {
|
||||
echo 'Error db init';
|
||||
return;
|
||||
}
|
||||
|
||||
$db->cleanCloud();
|
||||
|
||||
$length = 6;
|
||||
$token = bin2hex(random_bytes($length));
|
||||
if (isset($_POST['fsize']) && is_numeric($_POST['fsize'])) {
|
||||
$size = $_POST['fsize'];
|
||||
} else {
|
||||
$size = 3;
|
||||
}
|
||||
if (isset($_POST['ftext'])) {
|
||||
$text = $_POST['ftext'];
|
||||
} else {
|
||||
$text = '';
|
||||
}
|
||||
if (isset($_POST['fduration']) && in_array($_POST['fduration'], DataBase::OPTIONS_DURATION)) {
|
||||
$duration = $_POST['fduration'];
|
||||
} else {
|
||||
$duration = DataBase::DEFAULT_DURATION;
|
||||
}
|
||||
$cpt = 0;
|
||||
while (!$db->createCloud($token, $text, $size, $duration) && $cpt < 10) {
|
||||
$length = 6;
|
||||
$token = bin2hex(random_bytes($length));
|
||||
$cpt++;
|
||||
}
|
||||
$viewUrl = 'result.php?id=' . $token;
|
||||
$viewName = $_SERVER['HTTP_ORIGIN'] . '/'. $viewUrl;
|
||||
$voteUrl = 'index.php?id=' . $token;
|
||||
$voteName = $_SERVER['HTTP_ORIGIN'] . '/' . $voteUrl;
|
||||
if (isset($_POST['fsize']) && is_numeric($_POST['fsize'])) {
|
||||
$size = $_POST['fsize'];
|
||||
} else {
|
||||
$size = 3;
|
||||
}
|
||||
if (isset($_POST['ftext'])) {
|
||||
$text = $_POST['ftext'];
|
||||
} else {
|
||||
$text = '';
|
||||
}
|
||||
if (isset($_POST['fduration']) && in_array($_POST['fduration'], DataBase::OPTIONS_DURATION)) {
|
||||
$duration = $_POST['fduration'];
|
||||
} else {
|
||||
$duration = DataBase::DEFAULT_DURATION;
|
||||
}
|
||||
$cpt = 0;
|
||||
while (!$db->createCloud($token, $text, $size, $duration) && $cpt < 10) {
|
||||
$token = bin2hex(random_bytes($length));
|
||||
$cpt++;
|
||||
}
|
||||
$viewUrl = 'result.php?id=' . $token;
|
||||
$viewName = 'https://' . $_SERVER['HTTP_HOST'] . '/' . $viewUrl;
|
||||
$voteUrl = 'index.php?id=' . $token;
|
||||
$voteName = 'https://' . $_SERVER['HTTP_HOST'] . '/' . $voteUrl;
|
||||
?>
|
||||
|
||||
<h2>Attention, il n'y a aucun moyen de retrouver ces liens par la suite.</h2>
|
||||
<h2><?php echo L::cloud_links_warning ?></h2>
|
||||
<div id="cloud_links">
|
||||
<div id="cloud_links_results" class="cloud_link">
|
||||
<div class="label">Voici le lien pour <b>visualiser</b> le nuage de mots, il permet de voir le résultat.</div>
|
||||
<div class="label"><?php echo L::cloud_link_view_title ?></div>
|
||||
<div class="link">
|
||||
<a href="<?php echo $viewUrl ?>"><?php echo $viewName ?></a>
|
||||
<a href="<?php echo $viewUrl ?>" title="<?php echo L::cloud_link_view_tooltip ?>"><?php echo $viewName ?></a>
|
||||
</div>
|
||||
</div>
|
||||
<div id="cloud_links_vote" class="cloud_link">
|
||||
<div class="label">Voici le lien pour <b>participer</b> au nuage, c'est le lien à partager avec les autres personnes.</div>
|
||||
<div class="label"><?php echo L::cloud_link_vote_title ?></div>
|
||||
<div class="link">
|
||||
<a href="<?php echo $voteUrl ?>"><?php echo $voteName ?></a>
|
||||
<a href="<?php echo $voteUrl ?>" title="<?php echo L::cloud_link_vote_tooltip ?>"><?php echo $voteName ?></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue