<?php
/*
Plugin - PlogBirthdays
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.
    "plugins/plogbirthdays/class/view/adminplogbirthdaysview.class.php");
include_once(PLOG_CLASS_PATH.
    "class/data/pager/pager.class.php");
include_once(PLOG_CLASS_PATH.
    "plugins/plogbirthdays/class/dao/plogbirthdays.class.php");

class AdminPlogBirthdaysViewAction extends SiteAdminAction
{
  function perform()
  {
    $pbdays = new PlogBirthdays();
    $page = $this->getCurrentPageFromRequest();
    $totalBdays = $pbdays->getBirthdayCount();
    /* this constant defined by adminplogbirthdaysview */
    $bdays = $pbdays->getBirthdays(PLUGIN_PLOGBIRTHDAYS_BIRTHDAYS_PER_PAGE,
        $page);

    $this->_view = new AdminPlogBirthdaysView(
        $this->_blogInfo,$page,$totalBdays,"plogbirthdaysView");

    $this->_view->setValue("birthdays",$bdays);

    $this->setCommonData();
    return true;
  }

  /* this is a poor hack... */
  function getCurrentPageFromRequest()
  {
    /* Luckly these constants are defined by 
     * view.class.php extended from adminplogbirthdaysview.class.php
     *
     * This method is stolen from view to abstract the page
     * some from view... make these actions useful
     *
     * Integer validator is already included by view (like the defines)
     * no need to include it again...
     */
    $page = HttpVars::getRequestValue( VIEW_DEFAULT_PAGE_PARAMETER );

    $val = new IntegerValidator();
    if( !$val->validate( $page ))
      $page = VIEW_DEFAULT_START_PAGE;                                         
 
    return $page;
  }
}


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