<?php
/*
PluginAdRotate
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/siteadminaction.class.php");
include_once(PLOG_CLASS_PATH.
    "class/data/validator/stringvalidator.class.php");
include_once(PLOG_CLASS_PATH.
    "class/data/validator/httpurlvalidator.class.php");
include_once(PLOG_CLASS_PATH.
    "class/data/validator/integervalidator.class.php");
include_once(PLOG_CLASS_PATH.
    "plugins/adrotate/class/view/adminadrotatestatisticsview.class.php");
include_once(PLOG_CLASS_PATH.
    "plugins/adrotate/class/dao/adrotateadsstats.class.php");
include_once(PLOG_CLASS_PATH.
    "plugins/adrotate/class/dao/adrotateadstats.class.php");

class AdminAdRotateAddAdAction extends SiteAdminAction
{
  function AdminAdRotateAddAdAction($actionInfo,$request)
  {
    $this->SiteAdminAction($actionInfo,$request);
    $this->registerFieldValidator("imageUrl",new HTTPUrlValidator());
    $this->registerFieldValidator("redirectUrl",new HTTPUrlValidator());
    $this->registerFieldValidator("alttext",new StringValidator());
    $this->registerFieldValidator("type",new IntegerValidator());
  }
  function perform()
  {
    $imgurl = $this->_request->getValue("imageUrl");
    $redirurl = $this->_request->getValue("redirectUrl");
    $alttext = $this->_request->getValue("alttext");
    $type = $this->_request->getValue("type");

    $newad = 
      new AdRotateAdStats('','','',$imgurl,$redirurl,'',$alttext,$type,'');
    $adscontainer = new AdRotateAdsStats();
    $adscontainer->addAd($newad);

    $this->_view = new AdminAdRotateStatisticsView($this->_blogInfo);
    $this->_view->setSuccessMessage("added - localize");
    $this->setCommonData();
    
    return true;
  }
}
?>
