function addMoreCell($title, &$cPage)
 {
     if ($this->shouldShowMore()) {
         // Now increase the current page so it will point to the next
         $obj = new WiziappMoreCellItem('L1', array(sprintf($title, $this->leftToShow), $this->page + 1));
         $moreComponent = $obj->getComponent();
         $cPage[] = $moreComponent;
         if (isset($GLOBALS['WiziappEtagOverride'])) {
             $GLOBALS['WiziappEtagOverride'] .= serialize($moreComponent);
         }
     }
 }
Ejemplo n.º 2
0
function wiziapp_buildCategoryPage($category_id)
{
    $screen_conf = $GLOBALS['WiziappScreens']->getScreenLayout('posts');
    $pageNumber = isset($_GET['wizipage']) ? $_GET['wizipage'] : 0;
    $numberOfPosts = WiziappConfig::getInstance()->posts_list_limit;
    $offset = $numberOfPosts * $pageNumber;
    $cat = get_category($category_id);
    $title = wiziapp_apply_request_title($cat->cat_name);
    $query = "cat={$category_id}&orderby=post_date&posts_per_page=" . $numberOfPosts . "&offset=" . $offset;
    // Find the total number of posts in the blog
    $totalPostsInCat = $cat->count;
    if ($totalPostsInCat < $offset) {
        echo json_encode(wiziapp_prepareSectionScreen(array(), $title, "List"));
        exit;
    }
    if ($numberOfPosts < $totalPostsInCat) {
        $showMore = $totalPostsInCat - $numberOfPosts;
    } else {
        $showMore = FALSE;
    }
    $posts = wiziapp_buildPostListPage($query, '', $screen_conf['items'], TRUE, $showMore, FALSE);
    $postsCount = count($posts);
    $totalShownPosts = $totalPostsInCat - ($offset + $postsCount);
    if ($totalShownPosts < $numberOfPosts) {
        $showMore = $totalShownPosts;
    } else {
        $showMore = $numberOfPosts;
    }
    if ($showMore) {
        $obj = new WiziappMoreCellItem('L1', array(sprintf(__("Load %d more items", 'wiziapp'), $showMore), $pageNumber + 1));
        $moreComponent = $obj->getComponent();
        $posts[] = $moreComponent;
    }
    $section = array();
    $section[] = array('section' => array('title' => '', 'id' => 'recent', 'items' => $posts));
    echo json_encode(wiziapp_prepareSectionScreen($section, $title, "List"));
    //    echo json_encode(wiziapp_prepareSectionScreen(array($posts), $title, "List"));
}