<?php
	
	lt_include( PLOG_CLASS_PATH."class/view/admin/adminplugintemplatedview.class.php" );
	lt_include( PLOG_CLASS_PATH."class/dao/articles.class.php" );
	lt_include( PLOG_CLASS_PATH."class/config/siteconfig.class.php" );
	lt_include( PLOG_CLASS_PATH."class/data/pager/pager.class.php" );

	class AdminViewTrashView extends AdminPluginTemplatedView
	{

	    var $_page;
	    
		function AdminViewTrashView( $blogInfo )
		{
			$this->AdminPluginTemplatedView( $blogInfo, "trash", "viewtrash" );
			$this->_page = $this->getCurrentPageFromRequest();
			
			$blogSettings = $blogInfo->getSettings();

			$this->_itemsPerPage = $blogSettings->getValue( "show_posts_max" );
			if( $this->_itemsPerPage > SiteConfig::getHardShowPostsMax()) 
				$this->_itemsPerPage = SiteConfig::getHardShowPostsMax();
    	}
		
		function render()
		{
            $articles = new Articles();
            $blogId = $this->_blogInfo->getId();
            $userId = $this->_userInfo->getId();

                // TODO: check $this->userHasPermission( "update_all_user_articles" ))
                //       and show all articles for the blog?

			$posts = $articles->getBlogArticles( $blogId, -1, $this->_itemsPerPage, 0, POST_STATUS_DELETED, $userId, 0, '', $this->_page);

			// get the total number of posts
			$numPosts = $articles->getNumBlogArticles( $blogId, -1, 0, POST_STATUS_DELETED, $userId, 0, '');
			
			
			$pager = new Pager( "?op=viewTrash&amp;page=", $this->_page, $numPosts,	$this->_itemsPerPage );

            $this->setValue( "posts", $posts );
			
			// throw the event in case somebody is listening to it
			$this->notifyEvent( EVENT_POSTS_LOADED, Array( "posts" => &$posts ));
			
            $this->setValue( "pager", $pager );
			
			parent::render();
		}
	}
?>