<?php

    include_once( MOBILE_PLOG_CLASS_PATH."class/view/mobileview.class.php" );
    include_once( PLOG_CLASS_PATH."class/data/pager/pager.class.php" );
    
    class MobileDefaultView extends MobileView
    {
    
        var $_page;
    
        function MobileDefaultView( $blogInfo, $tInfo )
        {
            $this->MobileView( $blogInfo, $tInfo, "main" );
        }
        
        function render()
        {
            // load the current page
            $this->_page = $this->getCurrentPageFromRequest();
        
            // load some posts
            $articles = new Articles();
            $blogArticles = $articles->getBlogArticles( $this->_blogInfo->getId(),
                                                        -1,
                                                        $this->_tInfo->getNumItemsPerPage(),
                                                        0,
                                                        POST_STATUS_PUBLISHED,
                                                        0,
                                                        0,
                                                        "",
                                                        $this->_page );
            // number of articles
            $numPosts = $articles->getNumBlogArticles( $this->_blogInfo->getId(),
                                                        -1,
                                                        $this->_tInfo->getNumItemsPerPage(),
                                                        -1,
                                                        POST_STATUS_PUBLISHED,
                                                        0,
                                                        0,
                                                        "",
                                                        $this->_page );       
            
            // pass them to the template
            $this->setValue( "posts", $blogArticles );
            
            // create the pager and pass it to the template too
            $murl = new MobileRequestGenerator( $this->_blogInfo );            
            $pager = new Pager( $murl->getMobileUrl()."?op=Default&amp;blogId=".
                                $this->_blogInfo->getId()."&amp;page=",
                                $this->_page,
                                $numPosts,
                                $this->_tInfo->getNumItemsPerPage());
            $this->setValue( "pager", $pager );                                
            
            parent::render();        
        }
    }
?>