<?php
require_once MODX_CORE_PATH . 'model/modx/modrequest.class.php';
class troskControllerRequest extends modRequest {
    public $trosk = null;
    public $actionVar = 'action';
    public $defaultAction = 'index';
 
    function __construct(Trosk &$trosk) {
        parent :: __construct($trosk->modx);
        $this->trosk =& $trosk;
    }
 
    public function handleRequest() {
        $this->loadErrorHandler();
 
        /* save page to manager object. allow custom actionVar choice for extending classes. */
        $this->action = isset($_REQUEST[$this->actionVar]) ? $_REQUEST[$this->actionVar] : $this->defaultAction;
        $modx =& $this->modx;
        $trosk =& $this->trosk;
        $viewHeader = include $this->trosk->config['corePath'].'controllers/mgr/header.php';
 
        $f = $this->trosk->config['corePath'].'controllers/mgr/'.$this->action.'.php';
        if (file_exists($f)) {
            $viewOutput = include $f;
        } else {
            $viewOutput = 'Controller not found: '.$f;
        }
        return $viewHeader.$viewOutput;
    }
}