PageRenderTime 36ms CodeModel.GetById 8ms RepoModel.GetById 1ms app.codeStats 0ms

/blocks/tags.php

http://github.com/MightyGorgon/icy_phoenix
PHP | 82 lines | 52 code | 13 blank | 17 comment | 3 complexity | 822e84eff8117d3f50b0c01ce06082cb 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. * masterdavid - Ronald John David
  14. * Bicet
  15. *
  16. */
  17. if (!defined('IN_ICYPHOENIX'))
  18. {
  19. die('Hacking attempt');
  20. }
  21. if(!function_exists('cms_block_tags'))
  22. {
  23. function cms_block_tags()
  24. {
  25. global $db, $cache, $config, $template, $lang, $block_id, $cms_config_vars;
  26. $template->_tpldata['tags_loop.'] = array();
  27. // This block requires jquery_ui
  28. $config['jquery_ui'] = true;
  29. $sql_sort = (empty($cms_config_vars['md_tags_words'][$block_id]) ? ("l.tag_count DESC, l.tag_text ASC") : ("RAND()"));
  30. $sql_limit = (int) $cms_config_vars['md_tags_words'][$block_id];
  31. $sql_limit = (($sql_limit < 0) || ($sql_limit > 500)) ? 50 : $sql_limit;
  32. $tags = array();
  33. $sql = "SELECT l.*
  34. FROM " . TOPICS_TAGS_LIST_TABLE . " l
  35. ORDER BY " . $sql_sort . "
  36. LIMIT 0, " . $sql_limit;
  37. // Cache results for one our!
  38. $result = $db->sql_query($sql, 3600, 'tags_');
  39. $tags = $db->sql_fetchrowset($result);
  40. $db->sql_freeresult($result);
  41. $row_class = '';
  42. $i = 0;
  43. foreach ($tags as $tag)
  44. {
  45. $row_class = ip_zebra_rows($row_class);
  46. $tag_font_size = intval(mt_rand(8, 12));
  47. $template->assign_block_vars('tags_loop', array(
  48. 'CLASS' => $row_class,
  49. 'ROW_NUMBER' => $i + 1,
  50. 'U_TAG_TEXT' => append_sid(CMS_PAGE_TAGS . '?mode=view&amp;tag_text=' . htmlspecialchars(urlencode($tag['tag_text']))),
  51. 'TAG_TEXT' => htmlspecialchars($tag['tag_text']),
  52. 'TAG_FONT_SIZE' => $tag_font_size,
  53. 'TAG_COUNT' => $tag['tag_count'],
  54. )
  55. );
  56. $i++;
  57. }
  58. $template->assign_vars(array(
  59. 'U_TAGS_SEARCH_PAGE' => append_sid(CMS_PAGE_TAGS),
  60. 'U_TAGS' => append_sid(CMS_PAGE_TAGS),
  61. 'S_TAGS_BLOCK_ID' => $block_id,
  62. 'S_TAGS_SEARCH' => !empty($cms_config_vars['md_tags_search'][$block_id]) ? true : false,
  63. 'S_TAGS_COUNT' => !empty($cms_config_vars['md_tags_count'][$block_id]) ? true : false,
  64. )
  65. );
  66. }
  67. }
  68. cms_block_tags();
  69. ?>