Esempio n. 1
0
<?php

// widgets/tags/index.php
if (defined('MAIN_INIT')) {
    $widget_id = gcms::rndName(10);
    $keyword = array();
    $keyword[] = '<div id=' . $widget_id . ' class=widget-tags>';
    $sql = 'SELECT * FROM `' . DB_TAGS . '` ORDER BY `count` ASC';
    $tag_result = $cache->get($sql);
    if (!$tag_result) {
        $tag_result = $db->customQuery($sql);
        $cache->save($sql, $tag_result);
    }
    if (sizeof($tag_result) > 0) {
        $min = 1000000;
        $max = 0;
        $nmax = sizeof($tag_result) - 1;
        $min = isset($tag_result[1]) ? $tag_result[1]['count'] : 0;
        $max = isset($tag_result[$nmax - 1]) ? $tag_result[$nmax - 1]['count'] : 0;
        $step = $max - $min > 0 ? ($max - $min) / 7 : 0.1;
        for ($i = $nmax; $i >= 0; $i--) {
            $value = $tag_result[$i]['count'];
            $key = $tag_result[$i]['tag'];
            $id = $tag_result[$i]['id'];
            if ($i == 0) {
                $classname = 'class0';
            } elseif ($i == $nmax) {
                $classname = 'class9';
            } else {
                $classname = 'class' . (floor(($value - $min) / $step) + 1);
            }