Exemple #1
0
function render_iterator($class, $page_limit, $template)
{
    list($params, $limit, $page) = build_iterator_where($page_limit);
    $item_count = ORM::count($class, $params);
    $pager_calculator = new PagerCalculator($item_count, $limit);
    $page = $pager_calculator->calculate($page);
    $offset = $pager_calculator->get_offset();
    $limit = $pager_calculator->get_limit();
    $maxpage = $pager_calculator->get_maxpage();
    $items = ORM::all($class, $params, array('ctime', 'desc'), array($offset, $limit));
    $urlparams = array('page' => $page, 'nick' => isset($params['nick']) && $params['nick'] !== null ? rawurlencode($params['nick']) : null, 'day' => isset($params['ctime']) && isset($_GET['day']) ? $_GET['day'] : null, 'week' => isset($params['ctime']) && isset($_GET['week']) ? $_GET['week'] : null, 'url' => isset($params['original_url']) && isset($_GET['url']) ? $_GET['url'] : null, 'limit' => $limit != $page_limit && isset($_GET['limit']) ? $limit : null);
    extract($GLOBALS);
    // since this is an ajax query with only the data included, we can set expires header safely when not on the last page
    if (is_xhr_request() && $page !== $maxpage) {
        header('Expires: ' . date('r', strtotime('+1 week', $_SERVER['REQUEST_TIME'])));
    }
    include APPROOT . '/' . $template;
}
Exemple #2
0
<?php

define('APPROOT', dirname(__FILE__) . '/');
include APPROOT . 'lib/bootstrap.php';
if (is_xhr_request()) {
    $css_files = array();
    $js_files = array();
    $template = 'html/pager.html.php';
} else {
    $template = 'html/index.html.php';
}
$hidden_images = cookie_list('hideimages');
$visited_pages = cookie_list('visited_pages');
$autofillable = true;
render_iterator('Pic', PAGE_LIMIT_PIC, $template);