<?php

    include_once( PLOG_CLASS_PATH."class/action/blogaction.class.php" );
    include_once( PLOG_CLASS_PATH."class/view/plugintemplatedview.class.php" );

    include_once( PLOG_CLASS_PATH."plugins/shoutbox/class/dao/shoutbox.class.php" );

    /**
     * shows a form with the current configuration
    */
    class PluginShoutboxHistoryAction extends BlogAction {
        
        function PluginShoutboxHistoryAction( $actionInfo, $request ) {
            $this->BlogAction( $actionInfo, $request );
        }
        
        function perform() {
            // load some configuration settings
            $blogSettings = $this->_blogInfo->getSettings();

            // Get the shoutbox entries
            $s = new Shoutbox($this->_blogInfo->getId(), $blogSettings);
            
            // create a view and export the settings to the template
            //$this->_view = new PluginTemplatedView($this->_blogInfo, "shoutbox", "shoutbox_history" );
            $this->_view = new BlogView($this->_blogInfo, "shoutbox_history" );
            $this->_view->setValue( "pluginEnabled", $pluginEnabled );
            //$this->_view->setValue( "Shoutboxet", $Shoutboxet );

            $reqPage = (int)$this->_request->getValue('page');
            if($reqPage < 1)
              $reqPage = 1;
            
            if($reqPage > 1)
              $this->_view->setValue("prev_page", $reqPage - 1);
            
            if($reqPage <= $s->getLastPage())
              $this->_view->setValue("next_page", $reqPage + 1);

            $this->_view->setValue("shoutsHistory", $s->getShoutsArray($reqPage));


            $this->setCommonData();
            
            CacheControl::resetBlogCache($this->_blogInfo->getId());
            
            return true;
        }
}
?>