Пример #1
0
/**
 * 分页处理函数
 *
 * @params  intval  $rows_page    每页行数
 * @params  intval  $rows_total   总共行数
 * @params  string  $pages_group  多少页号为一组
 *
 * @return  string  分页HTML
 **/
function pager($rows_page, $rows_total, $pages_group = 5)
{
    /* 参数初始化 */
    $pages_total = floor(($rows_total + $rows_page - 1) / $rows_page);
    $pages_total = $pages_total <= 0 ? 1 : $pages_total;
    /* 获得当前页 */
    $cur = pager_current($rows_page, $rows_total, $page_param);
    $url = pager_url_rebuild();
    /* 构建HTML */
    /* 分析 */
    if ($cur > floor($pages_group / 2)) {
        $beg = $cur - floor($pages_group / 2);
        $end = $cur + floor($pages_group / 2) - 1 + ceil($pages_group % 2);
        if ($end > $pages_total) {
            $beg -= $end - $pages_total;
            $beg < 1 ? $beg = 1 : '';
        }
    } else {
        $beg = 1;
        $end = $pages_group;
    }
    /* 第一页 */
    if ($beg > 1) {
        $html .= '<a href="' . $url . '1" class="first">1</a>&nbsp;';
        $html .= '<a href="' . $url . ($cur - 10 < 1 ? 1 : $cur - 10) . ')" class="first">..</a>&nbsp;';
    }
    /* 分页组 */
    for ($i = $beg; $i <= $end; $i++) {
        if ($i > $pages_total) {
            break;
        }
        $html .= '<a href="' . $url . $i . '" class="';
        $html .= $i == $cur ? 'on' : 'num';
        $html .= '">' . $i . '</a>&nbsp;';
    }
    /* 尾页 */
    if ($end < $pages_total) {
        $html .= '<a href="' . $url . ($cur + 10 > $pages_total ? $pages_total : $cur + 10) . ')" class="last">..</a>';
        $html .= '<a href="' . $url . $pages_total . '" class="last">' . $pages_total . '</a>';
    }
    /* 返回 */
    return $html;
}
Пример #2
0
/**
 * 分页处理函数
 *
 * @params int  $rows_page    每页行数
 * @params int  $rows_total   总共行数
 * @params str  $pages_group  多少页号为一组
 *
 * @return str  分页HTML
 **/
function pager($rows_page, $rows_total, $pages_group = 5)
{
    /* 参数初始化 */
    $pages_total = floor(($rows_total + $rows_page - 1) / $rows_page);
    $pages_total = $pages_total <= 0 ? 1 : $pages_total;
    /* 获得当前页 */
    $cur = pager_current($rows_page, $rows_total, $page_param);
    /* 构建HTML */
    /* 分析 */
    if ($cur > floor($pages_group / 2)) {
        $beg = $cur - floor($pages_group / 2);
        $end = $cur + floor($pages_group / 2) - 1 + ceil($pages_group % 2);
        if ($end > $pages_total) {
            $beg -= $end - $pages_total;
            $beg < 1 ? $beg = 1 : '';
        }
    } else {
        $beg = 1;
        $end = $pages_group;
    }
    /* 第一页 */
    if ($beg > 1) {
        $_html .= '<a href="javascript:ListTable.pageTo(1)" class="first">1</a>';
        $_html .= '<a href="javascript:ListTable.pageTo(' . ($cur - 10 < 1 ? 1 : $cur - 10) . ')" class="first">..</a>&nbsp;';
    }
    /* 分页组 */
    for ($i = $beg; $i <= $end; $i++) {
        if ($i > $pages_total) {
            break;
        }
        $_html .= '<a href="javascript:ListTable.pageTo(' . $i . ')" class="';
        $_html .= $i == $cur ? 'on' : 'num';
        $_html .= '">' . $i . '</a>&nbsp;';
    }
    /* 尾页 */
    if ($end < $pages_total) {
        $_html .= '<a href="javascript:ListTable.pageTo(' . ($cur + 10 > $pages_total ? $pages_total : $cur + 10) . ')" class="last">..</a>';
        $_html .= '<a href="javascript:ListTable.pageTo(' . $pages_total . ')" class="last">' . $pages_total . '</a>';
    }
    /* 记录条数信息 */
    $_html .= '<a class="info">[ ' . (($cur - 1) * $rows_page + 1) . '/' . $rows_total . ' ]</a>';
    /* 返回 */
    return $_html;
}
Пример #3
0
/**
 * 获取插件列表
 *
 * @params arr  $plugins  所有插件
 */
function list_plugin()
{
    /* 获取所有插件 */
    $plugins = all_plugin();
    /* 设置分页数据和信息 */
    $p['rows_page'] = intval($_REQUEST['rows_page']) ? intval($_REQUEST['rows_page']) : 5;
    $p['rows_total'] = count($plugins);
    $p['html'] = pager($p['rows_page'], $p['rows_total']);
    $p['cur_page'] = pager_current($p['rows_page'], $p['rows_total']);
    $p['row_start'] = ($p['cur_page'] - 1) * $p['rows_page'];
    $list['data'] = array_slice($plugins, $p['row_start'], $p['rows_page']);
    $list['pager'] = $p;
    /* 返回 */
    return $list;
}
Пример #4
0
/**
 * 日志列表
 *
 * @params arr  $_REQUEST       全局搜索条件
 *                              SQL自定义所需字段 order_fd, order_type, rows_page
 * @return arr  $list
 *         arr  $list['data']   分页数据
 *         arr  $list['pager']  分页信息( html, rows_page, pages_group, rows_total, cur_page, row_start )
 */
function list_admin_log()
{
    $p = $f = $list = array();
    /* 过滤条件初始化*/
    $f['info'] = trim($_REQUEST['info']) != '' ? trim($_REQUEST['info']) : null;
    $f['admin'] = trim($_REQUEST['admin']) != '' ? trim($_REQUEST['admin']) : null;
    $f['datef'] = strtotime($_REQUEST['datef']) ? trim($_REQUEST['datef']) : null;
    $f['datet'] = strtotime($_REQUEST['datet']) ? trim($_REQUEST['datet']) : null;
    /* 排序字段初始化 */
    $fields = array();
    $f['order_fd'] = in_array($_REQUEST['order_fd'], $fields) ? $_REQUEST['order_fd'] : 'admin_log_id';
    $f['order_type'] = $_REQUEST['order_type'] == 'ASC' ? 'ASC' : 'DESC';
    /* 构建总记录数SQL */
    $sql = ' SELECT count(*) FROM ' . tname('admin_log');
    /* 构建过滤条件SQL */
    $where = ' WHERE 1=1';
    $where .= $f['info'] === null ? '' : ' AND info LIKE "%' . mysql_like_slash($f['info']) . '%"';
    $where .= $f['admin'] === null ? '' : ' AND admin_name="' . mysql_like_slash($f['admin']) . '"';
    $where .= $f['datef'] === null ? '' : ' AND in_time>=' . strtotime($f['datef']) / 100000 * 100000;
    $where .= $f['datet'] === null ? '' : ' AND in_time<=' . (strtotime($f['datet']) / 100000 * 100000 + 86399);
    /* 设置分页信息 */
    $p['rows_page'] = intval($_REQUEST['rows_page']) ? intval($_REQUEST['rows_page']) : 16;
    $p['rows_total'] = $GLOBALS['db']->getOne($sql . $where);
    $p['html'] = pager($p['rows_page'], $p['rows_total']);
    $p['cur_page'] = pager_current($p['rows_page'], $p['rows_total']);
    $p['row_start'] = ($p['cur_page'] - 1) * $p['rows_page'];
    $f['page'] = $p['cur_page'];
    $f['rows_page'] = $p['rows_page'];
    /* 构建分页内容SQL */
    $sql = ' SELECT * FROM ' . tname('admin_log') . ' ' . $where;
    $sql .= ' ORDER BY ' . $f['order_fd'] . ' ' . $f['order_type'];
    $sql .= ' LIMIT ' . $p['row_start'] . ',' . $p['rows_page'];
    /* 列表对象赋值 */
    $list['data'] = $GLOBALS['db']->getAll($sql);
    $list['pager'] = $p;
    $list['filter'] = $f;
    /* 返回 */
    return $list;
}
Пример #5
0
/**
 * 权限列表
 *
 * @params arr  $_REQUEST       全局搜索条件
 *                              SQL自定义所需字段 order_fd, order_type, page, rows_page
 * @return arr  $list
 *         arr  $list['data']   分页数据
 *         arr  $list['pager']  分页信息( html, rows_page, pages_group, rows_total, cur_page, row_start )
 */
function list_privilege()
{
    $p = $f = $list = array();
    /* 过滤条件初始化*/
    $f['module_ids'] = is_numeric($_REQUEST['module_id']) ? sub_module_id(array('module_id' => $_REQUEST['module_id'])) : null;
    /* 排序字段初始化 */
    $f['order_fd'] = 'p.module_id, p.`order`';
    $f['order_type'] = 'ASC';
    /* 构建总记录数SQL */
    $sql = 'SELECT count(*) FROM ' . tname('privilege') . ' AS p';
    /* 构建过滤条件SQL */
    $where = ' WHERE 1=1';
    $where .= $f['module_ids'] === null ? '' : ' AND p.module_id IN("' . implode('","', $f['module_ids']) . '")';
    /* 设置分页信息 */
    $p['rows_page'] = intval($_REQUEST['rows_page']) ? intval($_REQUEST['rows_page']) : 16;
    $p['rows_total'] = $GLOBALS['db']->getOne($sql . $where);
    $p['html'] = pager($p['rows_page'], $p['rows_total']);
    $p['cur_page'] = pager_current($p['rows_page'], $p['rows_total']);
    $p['row_start'] = ($p['cur_page'] - 1) * $p['rows_page'];
    $f['page'] = $p['cur_page'];
    $f['rows_page'] = $p['rows_page'];
    /* 构建分页内容SQL */
    $sql = ' SELECT p.*, m.name AS module_name';
    $sql .= ' FROM ' . tname('privilege') . ' AS p LEFT JOIN ' . tname('module') . ' AS m USING(module_id)' . $where;
    $sql .= ' ORDER BY ' . $f['order_fd'] . ' ' . $f['order_type'];
    $sql .= ' LIMIT ' . $p['row_start'] . ',' . $p['rows_page'];
    /* 列表对象赋值 */
    $list['data'] = $GLOBALS['db']->getAll($sql);
    $list['pager'] = $p;
    $list['filter'] = $f;
    /* 返回 */
    return $list;
}