<?php

class Cms_Cms_LogController extends Pampa_Controller_Action_Cms {

  /**
   * @var Model_Cms_Logs
   */
  private $modelCmsLogs;

  public function init(){
    // the models
    $this->modelCmsLogs = new Model_Cms_Logs();

    parent::init();
  }

  public function indexAction() {
    $this->_forward("list");
  }

  public function listAction() {

    // setup the list filters
    $filters = array(
      "t" => $this->_getParam("t", 30),
      "p" => $this->_getParam("p", 1),
      "s" => $this->_getParam("s"),
    );

    $this->view->filters = $filters;

    // retrieves the items list
    $this->view->items = $this->modelCmsLogs->adminList($filters);
  }

  public function viewAction()
  {
    // log id
    $log_id = $this->_getParam("id");

    if(empty($log_id)){
      $this->_redirector->gotoSimple("list");
    }

    // the log row
    $log = $this->modelCmsLogs->find($log_id)->current();
    $this->view->log = $log;

    Pampa_Log::log("Viewd log #{$log->id} {$log->user}");
  }

}