예제 #1
0
function tbody($params)
{
    global $conn, $modul, $sub_page, $pages;
    if (!isset($sub_page) or $sub_page == 0) {
        $sub_page = 1;
    }
    if ($modul == 'content_tree') {
        if (isset($params['FILTER'])) {
            $arr_tmp = create_tree('content_tree', 0, $params['FILTER']);
        } else {
            $arr_tmp = create_tree('content_tree', 0);
        }
        if ($arr_tmp) {
            $tbody = "<div class='table-body tree'>";
            $tbody .= tree_nav_table($params, 'content', $arr_tmp, tree_get_parents('content_tree', NULL));
            $tbody .= "</div><!-- /.table-body -->";
        }
    } else {
        if (!isset($params['FILTER'])) {
            $params['FILTER'] = NULL;
        } elseif (!isset($params['SORT'])) {
            $params['SORT'] = NULL;
        }
        if (!isset($params['GROUP'])) {
            $params['GROUP'] = NULL;
        }
        if (!isset($params['ADD'])) {
            $params['ADD'] = NULL;
        }
        $result = db_mysql_query(select_tbody($params['TABLE'], $params['SORT'], $params['FILTER'], $params['GROUP'], $params['ADD'], 100), $conn);
        if ($sub_page <= 1) {
            $sql_sub = "SELECT * FROM information_schema.COLUMNS WHERE TABLE_NAME = '" . $_SESSION['TABLE_PREFIX'] . $modul . "' AND COLUMN_NAME = 'sort_order' ";
            $result_sub = db_mysql_query($sql_sub, $conn);
            if ($modul == 'content_tree') {
                $tbody = "<div class='table-body tree'>";
            } else {
                if (db_mysql_num_rows($result_sub)) {
                    $tbody = "<div class='table-body sortable'>";
                } else {
                    $tbody = "<div class='table-body " . $modul . "'>";
                }
            }
        }
        while ($arr = db_mysql_fetch_array($result)) {
            $tbody .= "<div class='table-row' id='" . $arr['id'] . "' >";
            foreach ($params['TABLE'] as $key => $value) {
                $data = init($arr[$key], $value, $key);
                if ($value == 'activate') {
                    $tbody .= "<div class='table-cell icon-only " . $key . "'>";
                    if ($arr[$key]) {
                        $tbody .= "<a href='#' class='icon-cell " . $key . "_de" . $value . "' data-content='" . $modul . "' id='" . $arr['id'] . "' ><i class='icon-" . $value . "-active'></i>";
                    } else {
                        $tbody .= "<a href='#' class='icon-cell " . $key . "_" . $value . "' data-content='" . $modul . "' id='" . $arr['id'] . "' ><i class='icon-" . $value . "'></i>";
                    }
                    $tbody .= "</div><!-- /.table-cell -->";
                } else {
                    $tbody .= "<div class='table-cell " . $key . "'>" . $data . "</div><!-- /.table-cell -->";
                }
            }
            if (count(array_filter($params['CONSTRUCT']))) {
                $width = 40 + 26 * count(array_filter($params['CONSTRUCT']));
                $tbody .= "<div class='table-cell tools' style='width: " . $width . "px;'>";
                foreach ($params['CONSTRUCT'] as $key => $value) {
                    if ($value === true) {
                        if ($key == 'activate') {
                            if (!isset($arr['c_default']) or $arr['c_default'] == 0) {
                                if ($arr['c_active']) {
                                    $tbody .= "<a href='#' class='icon-cell de" . $key . "' data-content='" . $modul . "' id='" . $arr['id'] . "' ><i class='icon-" . $key . "-active'></i>";
                                } else {
                                    $tbody .= "<a href='#' class='icon-cell " . $key . "' data-content='" . $modul . "' id='" . $arr['id'] . "' ><i class='icon-" . $key . "'></i>";
                                }
                                $tbody .= "</a>";
                            }
                        } elseif ($key == 'delete') {
                            if (!isset($arr['c_default']) or $arr['c_default'] == 0) {
                                $tbody .= "<a href='#' class='icon-cell " . $key . "' data-content='" . $modul . "' id='" . $arr['id'] . "' ><i class='icon-" . $key . "'></i></a>";
                            }
                        } else {
                            $tbody .= "<a href='#' class='icon-cell " . $key . "' data-content='" . $modul . "' id='" . $arr['id'] . "' ><i class='icon-" . $key . "'></i></a>";
                        }
                    }
                }
                $tbody .= "</div><!-- /.table-cell -->";
            }
            $tbody .= "</div><!-- /.table-row -->";
        }
        if (ceil($pages) != $sub_page) {
            $next_page = $sub_page + 1;
            $tbody .= "<form id='next_rows' method='POST'>";
            $tbody .= "<input type='hidden' name='modul' value='" . $modul . "'>";
            $tbody .= "<input type='hidden' name='params' value='" . serialize($params) . "'>";
            $tbody .= "<input type='hidden' name='sub_page' value='" . $next_page . "'>";
            $tbody .= "</form>";
        }
        $tbody .= "</div><!-- /.table-body -->";
    }
    if (isset($tbody)) {
        print $tbody;
    }
}
예제 #2
0
function tree_nav_table($params, $title, $t_data, $parents = NULL, $i = 1, $id_parent = NULL, $tbody = '')
{
    global $modul;
    foreach ($t_data as $t_key => $t_value) {
        $tbody .= "<div class='table-row'>";
        foreach ($params['TABLE'] as $key => $value) {
            $data = init($t_value[$key], $value, $key);
            if ($value == 'activate') {
                $tbody .= "<div class='table-cell icon-only " . $key . "'>";
                if ($t_value[$key]) {
                    $tbody .= "<a href='#' class='icon-cell " . $key . "_de" . $value . "' data-content='" . $modul . "' id='" . $t_value['id'] . "' ><i class='icon-" . $value . "-active'></i>";
                } else {
                    $tbody .= "<a href='#' class='icon-cell " . $key . "_" . $value . "' data-content='" . $modul . "' id='" . $t_value['id'] . "' ><i class='icon-" . $value . "'></i>";
                }
                $tbody .= "</div><!-- /.table-cell -->";
            } else {
                $tbody .= "<div class='table-cell " . $key . "'>";
                for ($y = 2; $y <= $i; $y++) {
                    $tbody .= "<span class='spacer'></span>";
                }
                $tbody .= "<i class='icon-tree'></i>" . $data . "</div><!-- /.table-cell -->";
            }
        }
        $width = 40 + 26 * count($params['CONSTRUCT']);
        $tbody .= "<div class='table-cell tools' style='width: " . $width . "px;'>";
        foreach ($params['CONSTRUCT'] as $key => $value) {
            if ($value === true) {
                if ($key == 'activate') {
                    if ($t_value['c_active']) {
                        $tbody .= "<a href='#' class='icon-cell de" . $key . "' data-content='" . $modul . "' id='" . $t_value['id'] . "' ><i class='icon-" . $key . "-active'></i>";
                    } else {
                        $tbody .= "<a href='#' class='icon-cell " . $key . "' data-content='" . $modul . "' id='" . $t_value['id'] . "' ><i class='icon-" . $key . "'></i>";
                    }
                    $tbody .= "</a>";
                } else {
                    $tbody .= "<a href='#' class='icon-cell " . $key . "' data-content='" . $modul . "' id='" . $t_value['id'] . "' ><i class='icon-" . $key . "'></i></a>";
                }
            }
        }
        $tbody .= "</div><!-- /.table-cell -->";
        $tbody .= "</div><!-- /.table-row -->";
        if ($t_value['id_parent'] == $id_parent) {
            $i = 1;
        }
        if (isset($t_value['children'])) {
            $tbody .= tree_nav_table($params, $title, $t_value['children'], $parents, $i + 1, $t_value['id_parent'], '');
        }
    }
    return $tbody;
}