pageByPageno() static public method

static public pageByPageno ( $pageno )
Example #1
0
        } else {
            # page
            if ($preview_pathspec !== null) {
                $post = GBPage::findByName($preview_pathspec, $version);
            } else {
                $post = GBPage::find(urldecode($gb_request_uri), $version);
            }
            if ($post === false) {
                gb::$is_404 = true;
            } else {
                gb::$title[] = $post->title;
            }
            gb::$is_page = true;
        }
        # post 404?
        if (isset($post) && $post && gb::$is_preview === false && ($post->draft === true || $post->published->time > time())) {
            gb::$is_404 = true;
        }
    } else {
        # posts
        $postspage = GBPost::pageByPageno(isset($_REQUEST['page']) ? intval($_REQUEST['page']) : 0);
        gb::$is_posts = true;
        gb::$is_404 = $postspage === false;
    }
    # unset temporary variables (not polluting global namespace)
    unset($preview_pathspec);
    unset($strptime);
    unset($version);
    gb::event('will-handle-request');
    # from here on, the caller will have to do the rest
}
Example #2
0
}
function _post_tuple_sortfunc($a, $b)
{
    return $b[0]->modified->time - $a[0]->modified->time;
}
function _muxed_posts_sortfunc($a, $b)
{
    return $b[0][0]->modified->time - $a[0][0]->modified->time;
}
# Add published and scheduled posts
$pageno = 0;
# pages are 0 (zero) indiced
$maxpages = 5;
$num_more_postpages = 0;
do {
    $postspage = GBPost::pageByPageno($pageno);
    if (!$postspage) {
        break;
    }
    foreach ($postspage->posts as $rank => $post) {
        if (!isset($muxed_posts[$post->name])) {
            $muxed_posts[$post->name] = array();
        }
        if ($post->published->time > time()) {
            $muxed_posts[$post->name][] = array($post, st::SCHEDULED . ($post->draft ? st::DRAFT : ''));
            uasort($muxed_posts[$post->name], '_post_tuple_sortfunc');
        } else {
            #$online[] = $post;
            $muxed_posts[$post->name][] = array($post, st::STAGED . ($post->draft ? st::DRAFT : ''));
        }
    }