simpleWordsCloud/result.php

57 lines
1.3 KiB
PHP

<?php
include('init.php');
include('templates/header.php');
if (isset($_GET['id'])) {
$id = $_GET['id'];
if (!$db->isCloud($id)) {
echo '<p>' . L::cloud_noId . '</p>';
$id = null;
}
}
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>
<div id="my_canvas">
</div>
<?php
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>
<?php
}
}
include('templates/footer.php');