<?php
/*
Plugin - PlogStaticRotator
Copyright (C) 2005 Matthew Wood
                                                                                
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
*/

include_once(PLOG_CLASS_PATH."class/action/admin/blogowneradminaction.class.php");
include_once(PLOG_CLASS_PATH.
    "plugins/plogstaticrotator/class/view/adminstaticcontentview.class.php");
include_once(PLOG_CLASS_PATH.
    "plugins/plogstaticrotator/class/dao/plogstaticrotatorcontents.class.php");
include_once(PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php");

class AdminPlogStaticRotatorNewAction extends BlogOwnerAdminAction
{
  function AdminPlogStaticRotatorNewAction($actionInfo,$request)
  {
    $this->BlogOwnerAdminAction($actionInfo,$request);
    $this->registerFieldValidator('title',new StringValidator());
    $this->registerFieldValidator('content',new StringValidator());
    $this->_view = new AdminStaticContentView(
      $this->_blogInfo,"admincontentview");
    $this->setValidationErrorView($this->_view);
  }
  function perform()
  {
    $contentModel = new PlogStaticRotatorContents();
    $blogid = $this->_blogInfo->getId();
    $title = $this->_request->getValue("title");
    $content = $this->_request->getValue("content");

    $contentObj = new PlogStaticRotatorContent(-1,$blogid,$title,$content);

    $contentModel->addContent($contentObj);
    
    $contents = $contentModel->getAllContent($this->_blogInfo->getId());
    
    $this->_view->setValue("contents",$contents);
    $this->setCommonData();
    return true;
  }
}

/* vim:sw=2:ai:expandtab:cin:
*/
?>
