<?php
/**
 * Static content controller.
 *
 * This file will render views from views/pages/
 *
 * PHP 5
 *
 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
 * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
 * @link          http://cakephp.org CakePHP(tm) Project
 * @package       app.Controller
 * @since         CakePHP(tm) v 0.2.9
 * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
 */

App::uses('EvPagesController', 'EvCore.Controller');

/**
 * Static content controller
 *
 * @package       app.Controller
 */
class PagesController extends EvPagesController {

    public $translation; // Create a new global var for the translation plugin

    public function beforeFilter()
    {
        parent::beforeFilter();

        // Load in the EvTranslation component
        $this->translation = $this->Components->load('EvTranslation.Translation');
        $this->translation->init($this->request); // Initialise the translations
    }


/**
 * Example template extras method for a page with a 'homepage' view template.
 */
    protected function _getHomepageExtras() {
        //header("Location: /quote_builder");die();
        //return;
    }

    public function _adminFormFields() {

        $fields = parent::_adminFormFields();

        // Populate the translations fields
        $this->set('translations', $this->translation->_adminFormFieldsTranslated($this->request, $fields));

        return $fields;

    }

    public function admin_edit($id = null) {

        parent::admin_edit($id);
        $this->view = 'admin_form'; // This is used to override the scaffolding view so we can load in translations.

    }
}
