function print_file_types_table($return = false)
{
    $condition = get_filter_by_fr_category_accessibility();
    $types = process_sql("SELECT tdownload_type.id AS id,\n\t\t\t\t\t\t\t\ttdownload_type.name AS name,\n\t\t\t\t\t\t\t\ttdownload_type.description AS description,\n\t\t\t\t\t\t\t\ttdownload_type.icon AS icon,\n\t\t\t\t\t\t\t\tCOUNT(tdownload.id) AS num_files,\n\t\t\t\t\t\t\t\tMAX(tdownload.date) AS last_update\n\t\t\t\t\t\tFROM tdownload, tdownload_type, tdownload_type_file\n\t\t\t\t\t\tWHERE tdownload.id = tdownload_type_file.id_download\n\t\t\t\t\t\t\tAND tdownload_type.id = tdownload_type_file.id_type\n\t\t\t\t\t\t\t{$condition}\n\t\t\t\t\t\tGROUP BY name\n\t\t\t\t\t\tORDER BY last_update DESC");
    if (!$types) {
        $types = array();
    }
    $without_type = process_sql("SELECT -1 AS id,\n\t\t\t\t\t\t\t\t\t\t'' AS name,\n\t\t\t\t\t\t\t\t\t\t'' AS description,\n\t\t\t\t\t\t\t\t\t\t'default.png' AS icon,\n\t\t\t\t\t\t\t\t\t\tCOUNT(id) AS num_files,\n\t\t\t\t\t\t\t\t\t\tMAX(date) AS last_update\n\t\t\t\t\t\t\t\tFROM tdownload\n\t\t\t\t\t\t\t\tWHERE id NOT IN (SELECT id_download FROM tdownload_type_file)\n\t\t\t\t\t\t\t\t\t{$condition}\n\t\t\t\t\t\t\t\tORDER BY last_update DESC");
    if ($without_type) {
        $without_type = $without_type[0];
        $without_type["name"] = __('Without type');
        if (!$types) {
            $types[0] = $without_type;
        } elseif ($types[0]["last_update"] < $without_type["last_update"]) {
            array_unshift($types, $without_type);
        } elseif ($types[count($types) - 1]["last_update"] > $without_type["last_update"]) {
            array_push($types, $without_type);
        } else {
            $types_aux = array();
            for ($i = 0; $i < count($types); $i++) {
                $types_aux[] = $types[$i];
                if (isset($types[$i]["last_update"]) && isset($types[$i + 1]["last_update"])) {
                    if ($types[$i]["last_update"] > $without_type["last_update"] && $types[$i + 1]["last_update"] < $without_type["last_update"]) {
                        $types_aux[] = $without_type;
                    }
                }
            }
            $types = $types_aux;
            $types_aux = null;
        }
    }
    $table = new stdClass();
    $table->width = '100%';
    $table->class = 'blank';
    $table->style = array();
    $table->style[0] = "min-width:50%; width:50%; max-width:50%";
    $table->style[1] = "min-width:50%; width:50%; max-width:50%";
    $table->valign = array();
    $table->valign[0] = "top";
    $table->valign[1] = "top";
    $table->data = array();
    $column_num = 2;
    $column_count = 0;
    $column = 0;
    foreach ($types as $type) {
        $table_type = new stdClass();
        $table_type->width = '100%';
        $table_type->class = 'search-table-white';
        $table_type->style = array();
        $table_type->style[0] = "vertical-align:top; min-width:25px; width:25px; max-width:25px";
        $table_type->data = array();
        if ((int) $type["num_files"] > 0) {
            $file_releases = get_file_releases(0, $type["id"], 10, true);
            $fr_names = __('Last updated file releases') . ":";
            foreach ($file_releases as $fr) {
                $fr_names .= "\n" . $fr;
            }
        } else {
            $fr_names = "";
        }
        $table_type->data[0][0] = print_image("images/download_type/" . $type["icon"], true);
        $table_type->data[0][1] = "<a style='font-weight: bold;' href='index.php?sec=download&sec2=operation/download/browse&id_type=" . $type["id"] . "'>" . $type["name"] . "</a>";
        $table_type->data[0][1] .= " <div style='display:inline;' title='{$fr_names}'>(" . (int) $type["num_files"] . ")</div>";
        $table_type->data[0][1] .= "<br>";
        $table_type->data[0][1] .= "<div>" . $type["description"] . "</div>";
        $table_type->data[0][1] .= "<div style='color: #FF9933;'><i>" . __('Last update') . ": " . human_time_comparation($type["last_update"]) . "</i></div>";
        $table->data[0][$column] .= print_table($table_type, true);
        $column_count += 1;
        $column += 1;
        if ($column_count >= $column_num) {
            $column_count = 0;
            $column = 0;
        }
    }
    print_table($table, $return);
}
Exemplo n.º 2
0
 // ==================================================================
 $sql_filter = "";
 if ($free_text != "") {
     $sql_filter .= " AND name LIKE '%{$free_text}%' OR description LIKE '%{$free_text}%'";
 }
 if ($id_category > 0) {
     $sql_filter .= " AND id_category = {$id_category} ";
 }
 if ($id_type > 0) {
     $sql_filter .= " AND id IN (SELECT id_download FROM tdownload_type_file WHERE id_type = {$id_type}) ";
 }
 if ($id_type == -1) {
     $sql_filter .= " AND id NOT IN (SELECT id_download FROM tdownload_type_file) ";
 }
 $offset = get_parameter("offset", 0);
 $condition = get_filter_by_fr_category_accessibility();
 $count = get_db_sql("SELECT COUNT(id) FROM tdownload WHERE 1=1 {$condition} {$sql_filter}");
 pagination($count, "index.php?sec=download&sec2=operation/download/browse&id_category={$id_category}&id_type={$id_type}&free_text={$free_text}", $offset);
 $sql = "SELECT * FROM tdownload WHERE 1=1 {$condition} {$sql_filter} ORDER BY date DESC, name LIMIT {$offset}, " . $config["block_size"];
 $color = 0;
 $downloads = process_sql($sql);
 if ($downloads == false) {
     $downloads = array();
     echo "<h3 class='error'>" . __('No Downloads found') . "</h3>";
 } else {
     $table = new stdClass();
     $table->width = '99%';
     $table->class = 'listing';
     $table->head = array();
     $table->data = array();
     $table->colspan = array();