forked from MightyGorgon/icy_phoenix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwordgraph.php
83 lines (69 loc) · 1.87 KB
/
wordgraph.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
/**
*
* @package Icy Phoenix
* @version $Id$
* @copyright (c) 2008 Icy Phoenix
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
*
* @Extra credits for this file
* Jeremy Conley - ([email protected]) - (www.pentapenguin.com)
*
*/
define('IN_ICYPHOENIX', true);
if (!defined('IP_ROOT_PATH')) define('IP_ROOT_PATH', './');
if (!defined('PHP_EXT')) define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1));
include(IP_ROOT_PATH . 'common.' . PHP_EXT);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
// End session management
$words_array = array();
$sql = 'SELECT w.word_text, COUNT(*) AS word_count
FROM ' . SEARCH_WORD_TABLE . ' AS w, ' . SEARCH_MATCH_TABLE . ' AS m
WHERE m.word_id = w.word_id
GROUP BY m.word_id
ORDER BY word_count DESC LIMIT ' . intval($config['word_graph_max_words']);
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$word = strtolower($row['word_text']);
$word_count = $row['word_count'];
$words_array[$word] = $word_count;
}
$minimum = 1000000;
$maximum = -1000000;
foreach (array_keys($words_array) as $word)
{
if ($words_array[$word] > $maximum)
{
$maximum = $words_array[$word];
}
if ($words_array[$word] < $minimum)
{
$minimum = $words_array[$word];
}
}
$words = array_keys($words_array);
sort($words);
foreach ($words as $word)
{
$ratio = intval(mt_rand(8, 14));
$template->assign_block_vars('wordgraph_loop', array(
'WORD' => ($config['word_graph_word_counts']) ? $word . ' (' . $words_array[$word] . ')' : $word,
'WORD_FONT_SIZE' => $ratio,
'WORD_SEARCH_URL' => append_sid(CMS_PAGE_SEARCH . '?search_keywords=' . urlencode($word)),
)
);
}
$template->assign_vars(array(
'L_PAGE_TITLE' => $lang['Wordgraph'],
'L_WORDGRAPH' => $lang['Wordgraph'],
)
);
full_page_generation('wordgraph_body.tpl', $lang['Wordgraph'], '', '');
?>