'Title to display before tags', 'display_max' => 'Maximum number of tags to display', 'steps' => 'Odd number of scaling steps to use', 'size_min' => 'Minimum font size to use', 'size_max' => 'Maximum font size to use', 'size_unit' => 'Css font size unit', 'skip_single' => 'Do not display tags containing only one post', 'show_numposts' => 'Show number of posts next to each tag' ); var $_frontend; // options var $title = "Tag cloud"; var $display_max = 30; var $steps = 5; var $size_min = 0.5; var $size_max = 1.5; var $size_unit = 'em'; var $skip_single = false; var $show_numposts = false; function TagCloud(&$frontend, $args, $dummy_run=false) { $this->LightPressPlugin($frontend, $args, $dummy_run); if (!$dummy_run && ($frontend->view_type != 'html' || $frontend->context['hierarchy'][0] != 'tagcloud')) $this->active = false; } function run($hook, &$post) { if (!$this->active) return ($this->hide()); $cache =& $this->_frontend->cache; if ($cache && $cache->active) { // try to fetch the cached snippet $result = $cache->getCache('_plugin_tagcloud',''); if ($result) { $this->_frontend->tpl->setVar('PLUGIN_TAGCLOUD', $result); return; } } $tags = $this->_frontend->getTags(); $limit = (int)$this->display_max; if ($limit > 0 && count($tags) > $limit) $tags = array_slice($tags, 0, $limit); ksort($tags); $min = 9999; $max = 0; foreach ($tags as $tag_name=>$tag) { $numposts = (int)$tag['numposts']; if ($this->skip_single && $numposts <= 1) { unset($tags[$tag_name]); continue; } $tags[$tag_name]['numposts'] = $numposts; if ($numposts > $max) $max = $numposts; else if ($numposts < $min) $min = $numposts; } $dist = ($max - $min) / $this->steps; $step = ($this->size_max - $this->size_min) / $this->steps; if ($this->title) $buffer = "