osousous
10-07-2007, 07:19 PM
There is an add on for a keword page, but I would like to put this into a module.
There is only one php file:
<?php
error_reporting(E_ALL & ~E_NOTICE);
define('THIS_SCRIPT','wordcloud');
$phrasegroups = array();
$specialtemplates = array();
$globaltemplates = array('shell_blank');
$actiontemplates = array();
require_once('./global.php');
$vbphrase['wordcloud_score'] = 'Score';
$vbphrase['wordcloud_word_cloud'] = 'Word Cloud';
$wordcloud_infos = $db->query_read("
SELECT SUM(score) AS f1, t2.title AS f2
FROM " . TABLE_PREFIX . "postindex AS t1, " . TABLE_PREFIX . "word AS t2
WHERE t1.wordid = t2.wordid GROUP BY t1.wordid ORDER BY f1 DESC LIMIT 100
");
$wordcloud_scoreinit = 0;
$wordcloud_fontinit = 144;
$wordcloud_htmlarray = array();
while ($wordcloud_info = $db->fetch_array($wordcloud_infos))
{
if (!$wordcloud_scoreinit)
{
$wordcloud_scoreinit = intval($wordcloud_info['f1']);
}
$wordcloud_scorerow = intval($wordcloud_info['f1']);
$wordcloud_wordrow = htmlspecialchars($wordcloud_info['f2']);
$wordcloud_queryrow = urlencode($wordcloud_info['f2']);
$wordcloud_fontrow = 10;
if ($wordcloud_scoreinit > 0)
{
$wordcloud_fontrow = intval($wordcloud_scorerow / $wordcloud_scoreinit * $wordcloud_fontinit);
}
if ($wordcloud_fontrow > 72)
{
$wordcloud_fontrow = 72;
}
if ($wordcloud_fontrow < 10)
{
$wordcloud_fontrow = 10;
}
$wordcloud_scorerow = vb_number_format($wordcloud_scorerow);
$wordcloud_htmlarray[] = '
<a style="text-decoration: none;" href="search.php?' . $vbulletin->vars->session['sessionurl'] .
'do=process&query=' . $wordcloud_queryrow .
'" title="' . $vbphrase['wordcloud_score'] . ': ' . $wordcloud_scorerow . '"><span style="font: ' .
$wordcloud_fontrow . 'px tahoma, verdana, geneva, arial, helvetica, sans-serif;">' .
$wordcloud_wordrow . '</span></a>
';
}
$db->free_result($wordcloud_infos);
shuffle($wordcloud_htmlarray);
$html = implode('', $wordcloud_htmlarray);
$html = '
<table border="0" width="90%" cellpadding="0" cellspacing="0" align="center"><tr><td align="center">
' . $html . '
</td></tr></table>
<br /><br />
';
$navbits = array('' => $vbphrase['wordcloud_word_cloud']);
$navbits = construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
eval('print_output("' . fetch_template('shell_blank') . '");');
?>
Any idea would be much appreciated!
There is only one php file:
<?php
error_reporting(E_ALL & ~E_NOTICE);
define('THIS_SCRIPT','wordcloud');
$phrasegroups = array();
$specialtemplates = array();
$globaltemplates = array('shell_blank');
$actiontemplates = array();
require_once('./global.php');
$vbphrase['wordcloud_score'] = 'Score';
$vbphrase['wordcloud_word_cloud'] = 'Word Cloud';
$wordcloud_infos = $db->query_read("
SELECT SUM(score) AS f1, t2.title AS f2
FROM " . TABLE_PREFIX . "postindex AS t1, " . TABLE_PREFIX . "word AS t2
WHERE t1.wordid = t2.wordid GROUP BY t1.wordid ORDER BY f1 DESC LIMIT 100
");
$wordcloud_scoreinit = 0;
$wordcloud_fontinit = 144;
$wordcloud_htmlarray = array();
while ($wordcloud_info = $db->fetch_array($wordcloud_infos))
{
if (!$wordcloud_scoreinit)
{
$wordcloud_scoreinit = intval($wordcloud_info['f1']);
}
$wordcloud_scorerow = intval($wordcloud_info['f1']);
$wordcloud_wordrow = htmlspecialchars($wordcloud_info['f2']);
$wordcloud_queryrow = urlencode($wordcloud_info['f2']);
$wordcloud_fontrow = 10;
if ($wordcloud_scoreinit > 0)
{
$wordcloud_fontrow = intval($wordcloud_scorerow / $wordcloud_scoreinit * $wordcloud_fontinit);
}
if ($wordcloud_fontrow > 72)
{
$wordcloud_fontrow = 72;
}
if ($wordcloud_fontrow < 10)
{
$wordcloud_fontrow = 10;
}
$wordcloud_scorerow = vb_number_format($wordcloud_scorerow);
$wordcloud_htmlarray[] = '
<a style="text-decoration: none;" href="search.php?' . $vbulletin->vars->session['sessionurl'] .
'do=process&query=' . $wordcloud_queryrow .
'" title="' . $vbphrase['wordcloud_score'] . ': ' . $wordcloud_scorerow . '"><span style="font: ' .
$wordcloud_fontrow . 'px tahoma, verdana, geneva, arial, helvetica, sans-serif;">' .
$wordcloud_wordrow . '</span></a>
';
}
$db->free_result($wordcloud_infos);
shuffle($wordcloud_htmlarray);
$html = implode('', $wordcloud_htmlarray);
$html = '
<table border="0" width="90%" cellpadding="0" cellspacing="0" align="center"><tr><td align="center">
' . $html . '
</td></tr></table>
<br /><br />
';
$navbits = array('' => $vbphrase['wordcloud_word_cloud']);
$navbits = construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
eval('print_output("' . fetch_template('shell_blank') . '");');
?>
Any idea would be much appreciated!