PageRenderTime 34ms CodeModel.GetById 9ms RepoModel.GetById 0ms app.codeStats 0ms

/wordgraph.php

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