<?php $settings = sfConfig::get('app_admin_' . $this->getModuleName()) ?>
<?php $model_columns = array() ?>
<?php foreach ($this->getTableMap()->getColumns() as $column): ?>
<?php $model_columns[$column->getPhpName()] = $column ?>
<?php endforeach ?>
[?php

/**
 * <?php echo $this->getModuleName() ?> actions.
 *
 * @package    ##PROJECT_NAME##
 * @subpackage <?php echo $this->getModuleName() ?>

 * @author     ##AUTHOR_NAME##
 * @version    SVN: $Id: actions.class.php 8507 2008-04-17 17:32:20Z fabien $
 */
class <?php echo $this->getGeneratedModuleName() ?>Actions extends wpActions
{
  public function executeIndex()
  {
	$criteria = new Criteria();

	$sort_method = $this->getCriteriaSortMethod();

	switch ($this->sort = $this->getRequestParameter('sort', '<?php echo $settings['default_sort'] ?>')) {
<?php foreach ($settings['columns'] as $php_name => $column_properties): ?>
<?php if ($column_properties['sort'] != $settings['default_sort']): ?>
	  case '<?php echo $column_properties['sort'] ?>':
		$criteria->$sort_method(<?php echo $this->getClassName() ?>Peer::<?php echo $column_properties['peer'] ?>);
		break;
<?php endif ?>
<?php endforeach ?>
	  default:
		$criteria->$sort_method(<?php echo $this->getClassName() ?>Peer::<?php echo $settings['default_peer'] ?>);
	}

	$pager = new sfPropelPager('<?php echo $this->getClassName() ?>', sfConfig::get('app_pager'));
	$pager->setCriteria($criteria);
	$pager->setPage($this->getRequestParameter('page', 1));
	$pager->init();
	$this->pager = $pager;

	$this-><?php echo $this->getSingularName() ?>List = $pager->getResults();
  }

<?php if (isset($this->params['with_show']) && $this->params['with_show']): ?>
  public function executeShow($request)
  {
    $this-><?php echo $this->getSingularName() ?> = <?php echo $this->getClassName() ?>Peer::retrieveByPk(<?php echo $this->getRetrieveByPkParamsForAction(49, '$request->getParameter') ?>);
    $this->forward404Unless($this-><?php echo $this->getSingularName() ?>, '<?php echo ucfirst($settings['singular']) ?> #' . <?php echo $this->getRetrieveByPkParamsForAction(43, '$request->getParameter') ?> . ' inconnu.');
  }

<?php endif; ?>
<?php if (isset($this->params['non_atomic_actions']) && $this->params['non_atomic_actions']): ?>
  public function executeEdit($request)
  {
    $this->form = new <?php echo $this->getClassName() ?>Form(<?php echo $this->getClassName() ?>Peer::retrieveByPk(<?php echo $this->getRetrieveByPkParamsForEdit(49, $this->getSingularName()) ?>));

    if ($request->isMethod('post'))
    {
      $this->form->bind($request->getParameter('<?php echo $this->getSingularName() ?>'));
      if ($this->form->isValid())
      {
        $<?php echo $this->getSingularName() ?> = $this->form->save();

        $this->redirect('<?php echo $this->getModuleName() ?>/edit?<?php echo $this->getPrimaryKeyUrlParams() ?>);
      }
    }
  }
<?php else: ?>
  public function executeCreate()
  {
    $this->form = new <?php echo $this->getClassName() ?>Form();

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

  public function executeEdit($request)
  {
    $this->form = new <?php echo $this->getClassName() ?>Form(<?php echo $this->getClassName() ?>Peer::retrieveByPk(<?php echo $this->getRetrieveByPkParamsForAction(49, '$request->getParameter') ?>));
  }

  public function executeUpdate($request)
  {
    $this->forward404Unless($request->isMethod('post'));

    $this->form = new <?php echo $this->getClassName() ?>Form(<?php echo $this->getClassName() ?>Peer::retrieveByPk(<?php echo $this->getRetrieveByPkParamsForAction(49, '$request->getParameter') ?>));

    $this->form->bind($request->getParameter('<?php echo $this->getSingularName() ?>'));
    if ($this->form->isValid())
    {
      $<?php echo $this->getSingularName() ?> = $this->form->save();

      wpFlashMessages::addConfirmation('<?php echo ucfirst($settings['singular']) ?> "' . $<?php echo $this->getSingularName() ?>-><?php echo $settings['confirm_method'] ?>() . '" sauvé avec succès.');
	  $this->redirect('<?php echo $this->getModuleName() ?>/index');
    }

    $this->setTemplate('edit');
  }
<?php endif; ?>

  public function executeDelete($request)
  {
    $this->forward404Unless($<?php echo $this->getSingularName() ?> = <?php echo $this->getClassName() ?>Peer::retrieveByPk(<?php echo $this->getRetrieveByPkParamsForAction(43, '$request->getParameter') ?>), '<?php echo ucfirst($settings['singular']) ?> #' . <?php echo $this->getRetrieveByPkParamsForAction(43, '$request->getParameter') ?> . ' inconnu.');

    $<?php echo $this->getSingularName() ?>->delete();

    wpFlashMessages::addConfirmation('<?php echo ucfirst($settings['singular']) ?> "' . $<?php echo $this->getSingularName() ?>-><?php echo $settings['confirm_method'] ?>() . '" supprimé avec succès.');
	$this->redirect('<?php echo $this->getModuleName() ?>/index');
  }
}