<?php

class Cms_Cms_SettingController extends Pampa_Controller_Action_Cms {

  private $modelSettings;

  public function init() {
    $this->modelSettings = new Model_Cms_Settings();

    parent::init();
  }

  public function indexAction() {
    
  }

  public function editAction(){
    $this->view->setting = $this->modelSettings->find(1)->current();
  }

  public function updateAction() {
    if(!$this->_request->isPost()) {
      $this->_redirector->gotoSimple("index");
    } else {

      // update the row
      $update = $this->modelSettings->update($_POST['setting']);

      if($update->error) {
        // send the error
        $this->sendError($update->message);
      } else {
        // send the success
        $this->sendSuccess('Item updated!', $this->getUrlTo('cms_setting', 'edit', array('id' => $update->id)));
      }
    }
  }
}