simpleWordsCloud/result.php

69 lines
1.7 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'];
2020-11-25 23:24:43 +01:00
if (!$db->loadCloud($id)) {
2020-11-23 11:01:37 +01:00
echo '<p>' . L::cloud_noId . '</p>';
$id = null;
}
}
2021-01-11 18:05:46 +01:00
?>
<h2><?php echo L::cloud_links_warning ?></h2>
<?php
2020-11-25 23:24:43 +01:00
if ($db->isCloudSet()) {
$nbWords = $db->countWords();
2020-11-23 11:01:37 +01:00
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;
2021-01-11 18:05:46 +01:00
$viewUrl = 'result.php?id=' . $id;
$viewName = 'https://' . $_SERVER['HTTP_HOST'] . '/' . $viewUrl;
2020-11-23 11:01:37 +01:00
?>
2021-01-11 18:05:46 +01:00
<div class="label"><?php echo L::cloud_link_view_title ?></div>
<div class="link">
<a href="<?php echo $viewUrl ?>" title="<?php echo L::cloud_link_view_tooltip ?>"><?php echo $viewName ?></a>
</div>
2020-11-23 11:01:37 +01:00
<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>
<div class="download_link">
<a href="download.php?id=<?php echo $id ?>"><?php echo L::wordsList_download ?></a>
</div>
2020-11-23 11:01:37 +01:00
<?php
}
}
2020-11-15 21:51:28 +01:00
include('templates/footer.php');