simpleWordsCloud/result.php

68 lines
1.7 KiB
PHP

<?php
include('init.php');
include('templates/header.php');
if (isset($_GET['id'])) {
$id = $_GET['id'];
if (!$db->loadCloud($id)) {
echo '<p>' . L::cloud_noId . '</p>';
$id = null;
}
}
?>
<h2><?php echo L::cloud_links_warning ?></h2>
<?php
if ($db->isCloudSet()) {
$nbWords = $db->countWords();
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;
$viewUrl = 'result.php?id=' . $id;
$viewName = 'https://' . $_SERVER['HTTP_HOST'] . '/' . $viewUrl;
?>
<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>
<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>
<div class="download_link">
<a href="download.php?id=<?php echo $id ?>"><?php echo L::wordsList_download ?></a>
</div>
<?php
}
}
include('templates/footer.php');