<?php
// auto-generated by sfPropelCrud
// date: 2007/06/12 16:50:00
?>
<?php

/**
 * cat actions.
 *
 * @package    tvtl
 * @subpackage cat
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 3335 2007-01-23 16:19:56Z fabien $
 */
class catActions extends sfActions
{
  public function executeIndex()
  {
    return $this->forward('cat', 'list');
  }

  public function executeList()
  {
    $this->tblcategorys = TblcategoryPeer::doSelect(new Criteria());
  }

  public function executeShow()
  {
    $this->tblcategory = TblcategoryPeer::retrieveByPk($this->getRequestParameter('cg_id'));
    $this->forward404Unless($this->tblcategory);
  }

  public function executeCreate()
  {
    $this->tblcategory = new Tblcategory();

    $this->setTemplate('edit');
  }

  public function executeEdit()
  {
    $this->tblcategory = TblcategoryPeer::retrieveByPk($this->getRequestParameter('cg_id'));
    $this->forward404Unless($this->tblcategory);
  }

  public function executeUpdate()
  {
    if (!$this->getRequestParameter('cg_id'))
    {
      $tblcategory = new Tblcategory();
    }
    else
    {
      $tblcategory = TblcategoryPeer::retrieveByPk($this->getRequestParameter('cg_id'));
      $this->forward404Unless($tblcategory);
    }

    $tblcategory->setCgId($this->getRequestParameter('cg_id'));
    $tblcategory->setCgName($this->getRequestParameter('cg_name'));
    $tblcategory->setCgParentid($this->getRequestParameter('cg_parentid'));
    $tblcategory->setCgChild($this->getRequestParameter('cg_child'));
    $tblcategory->setCgFamily($this->getRequestParameter('cg_family'));
    $tblcategory->setCgDesc($this->getRequestParameter('cg_desc'));
    $tblcategory->setCgVisited($this->getRequestParameter('cg_visited'));
    $tblcategory->setCgImage($this->getRequestParameter('cg_image'));

    $tblcategory->save();

    return $this->redirect('cat/show?cg_id='.$tblcategory->getCgId());
  }

  public function executeDelete()
  {
    $tblcategory = TblcategoryPeer::retrieveByPk($this->getRequestParameter('cg_id'));

    $this->forward404Unless($tblcategory);

    $tblcategory->delete();

    return $this->redirect('cat/list');
  }
}
