Beispiel #1
0
function display_category($table)
{
    global $cfg, $lang, $cat_num, $log_table, $info_table;
    $query_string = htmlspecialchars($_SERVER['QUERY_STRING']);
    $cat_name_array = cat_name_array($table);
    if ($table == $log_table) {
        $show_categories = $cfg['show_categories'];
        $category_style = $cfg['category_style'];
    } elseif ($table == $info_table) {
        $show_categories = $cfg['show_bin_categories'];
        $category_style = $cfg['bin_category_style'];
    } else {
        $show_categories = '';
        $category_style = '';
    }
    $category_list = '';
    if ($show_categories == 'yes') {
        if ($category_style == 1) {
            // Form Style
            if ($cat_num == 'yes') {
                foreach ($cat_name_array as $str => $num) {
                    $category_list .= '<option value="' . htmlspecialchars($str) . '">' . htmlspecialchars($str) . ' (' . $num . ")</option>\n";
                }
            } else {
                foreach ($cat_name_array as $str) {
                    $category_list .= '<option>' . htmlspecialchars($str) . "</option>\n";
                }
            }
            //////////////// Presentation! /////////////////
            $category_menu = <<<EOD
<form id="category" action="./category.php?{$query_string}" method="get">
<div>
<select name="k" tabindex="4" onchange="if(document.forms.category.k.value != '-'){this.form.submit();}" title="{$lang['category']}">
<option value="-" selected="selected">{$lang['category']}</option>
<option value="-" disabled="disabled">- - -</option>
{$category_list}</select>
<noscript> 
<div class="noscript">
<input type="submit" accesskey="s" tabindex="4" value="Go" />
</div>
</noscript>
</div>
</form>
EOD;
        } elseif ($category_style == 2) {
            // List Style
            if ($cat_num == 'yes') {
                foreach ($cat_name_array as $str => $num) {
                    $category_list .= '<li><a href="./category.php?k=' . rawurlencode($str) . '">' . htmlspecialchars($str) . ' (' . $num . ")</a></li>\n";
                }
            } else {
                foreach ($cat_name_array as $str) {
                    $category_list .= '<li><a href="./category.php?k=' . rawurlencode($str) . '">' . htmlspecialchars($str) . "</a></li>\n";
                }
            }
            //////////////// Presentation! /////////////////
            $category_menu = <<<EOD

<div class="menu">
<h2>{$lang['category']}</h2>
<ul>
{$category_list}</ul>
</div>
EOD;
        } else {
            // Tag Style (Original code by Hetima)
            $ul_start = '<ul>';
            $ul_end = '</ul>';
            $tag_list = '';
            if (count($cat_name_array) >= 8) {
                $ul_start = '<div class="tag-list">' . "\n";
                $ul_end = '</div>';
                $tag_level_4 = 100;
                $tag_level_3 = 10;
                $tag_level_2 = 2;
                $tag_level_1 = 0;
                //calc
                $i = 0;
                $s_array = array_values($cat_name_array);
                rsort($s_array, SORT_NUMERIC);
                $tag_level_4 = $s_array[1];
                $tag_level_3 = $s_array[3];
                $tag_level_2 = $s_array[7];
                foreach ($cat_name_array as $str => $num) {
                    if ($num >= $tag_level_4) {
                        $span_prop = '4';
                    } elseif ($num >= $tag_level_3) {
                        $span_prop = '3';
                    } elseif ($num >= $tag_level_2) {
                        $span_prop = '2';
                    } else {
                        $span_prop = '1';
                    }
                    $tag_list .= '<span class="tag-level-' . $span_prop . '">' . '<a href="./category.php?k=' . rawurlencode($str) . '" ' . 'title="' . htmlspecialchars($str) . '(' . $num . ')">' . htmlspecialchars($str) . "</a></span> \n";
                }
            } else {
                foreach ($cat_name_array as $str => $num) {
                    $tag_list .= '<li><a href="./category.php?k=' . rawurlencode($str) . '">' . htmlspecialchars($str) . ' (' . $num . ")</a></li>\n";
                }
            }
            //////////////// Presentation! /////////////////
            $category_menu = <<<EOD
<div class="menu">
<h2>Tags</h2>
{$ul_start}{$tag_list}{$ul_end}
</div>
EOD;
        }
    } else {
        $category_menu = '';
    }
    return $category_menu;
}
Beispiel #2
0
/**
 * Choose Cateogry for Binary File
 */
function add_bin_categories()
{
    global $cfg, $lang, $row, $info_table;
    $category_name = $row['bin_category'];
    $bin_categories = <<<EOD
<p>
<label for="bin-category">{$lang['category']} : </label><br />
<input type="text" id="bin-category" name="bin_category" size="40" value="{$category_name}" tabindex="1" class="bordered" />
<select tabindex="1" title="{$lang['category']}" onchange="document.forms.addform.bin_category.value += this.options[this.selectedIndex].value+ ',';"> 
<option value=""  selected="selected">{$lang['category']}</option>
<option value="-" disabled="disabled"> - - - </option> 
EOD;
    if ($cfg['show_bin_cat_num'] == 'yes') {
        foreach (cat_name_array($info_table) as $str => $num) {
            $bin_categories .= '<option value="' . htmlspecialchars($str) . '">' . htmlspecialchars($str) . ' (' . $num . ")</option>\n";
        }
    } else {
        foreach (cat_name_array($info_table) as $str) {
            $bin_categories .= '<option>' . htmlspecialchars($str) . "</option>\n";
        }
    }
    $bin_categories .= <<<EOD
</select>
</p>
EOD;
    return $bin_categories;
}