simpleWordsCloud/result.php

59 lines
1.3 KiB
PHP
Raw Normal View History

2020-11-15 21:51:28 +01:00
<?php
2020-11-23 11:01:37 +01:00
include('init.php');
2020-11-15 21:51:28 +01:00
include('templates/header.php');
2020-11-23 11:01:37 +01:00
if (isset($_GET['id'])) {
$id = $_GET['id'];
if (!$db->isCloud($id)) {
echo '<p>' . L::cloud_noId . '</p>';
$id = null;
}
}
2020-11-15 21:51:28 +01:00
2020-11-23 11:01:37 +01:00
if (isset($id)) {
$nbWords = $db->countWords($id);
if ($nbWords == 0) {
echo sprintf('<h2>%s</h2>', L::cloud_empty);
} else {
$jsWordcloud = true;
}
$voteUrl = 'index.php?id=' . $id;
$voteName = 'https://' . $_SERVER['HTTP_HOST'] . '/' . $voteUrl;
?>
<div class="label"><?php echo L::cloud_link_vote_title ?></div>
<div class="link">
<a href="<?php echo $voteUrl ?>" title="<?php echo L::cloud_link_vote_tooltip ?>"><?php echo $voteName ?></a>
</div>
2020-11-15 21:51:28 +01:00
<div id="my_canvas">
</div>
<?php
2020-11-23 11:01:37 +01:00
if ($nbWords > 0) {
?>
<details><summary><?php echo L::wordsList_title ?></summary>
<table>
<thead>
<tr>
<th><?php echo L::wordsList_word ?></th>
<th><?php echo L::wordsList_count ?></th>
<th><?php echo L::wordsList_percent ?></th>
</tr>
</thead>
<tbody>
<?php
foreach ($db->getWordsList($id) as $key => $word) {
echo '<tr>';
echo sprintf('<td>%s</td>', $word['word']);
echo sprintf('<td>%.0f</td>', $word['count']);
echo sprintf('<td>%.1f</td>', $word['percent']);
echo '</tr>';
}
?>
</thead>
</table>
</details>
<a href="download.php?id=<?php echo $id ?>"><?php echo L::wordsList_download ?></a>
2020-11-23 11:01:37 +01:00
<?php
}
}
2020-11-15 21:51:28 +01:00
include('templates/footer.php');