Made model files optional. Perhaps not ideal in true OO scenarios, but whatever.
git-svn-id: http://svn.cleancode.org/svn/pickles@32 4d10bc64-7434-11dc-a737-d2d0f8310089
This commit is contained in:
parent
8c14ec379d
commit
fca966c017
1 changed files with 41 additions and 41 deletions
|
@ -39,57 +39,57 @@ class Controller extends Object {
|
||||||
else {
|
else {
|
||||||
// Load the model
|
// Load the model
|
||||||
$file = '../models/' . $name . '.php';
|
$file = '../models/' . $name . '.php';
|
||||||
|
|
||||||
|
if (strpos($name, '/') === false) {
|
||||||
|
$class = $name;
|
||||||
|
$section = $name;
|
||||||
|
$event = null;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$class = str_replace('/', '_', $name);
|
||||||
|
list($section, $event) = split('/', $name);
|
||||||
|
}
|
||||||
|
|
||||||
if (file_exists($file)) {
|
if (file_exists($file)) {
|
||||||
require_once $file;
|
require_once $file;
|
||||||
|
|
||||||
if (strpos($name, '/') === false) {
|
|
||||||
$class = $name;
|
|
||||||
$section = $name;
|
|
||||||
$event = null;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$class = str_replace('/', '_', $name);
|
|
||||||
list($section, $event) = split('/', $name);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (class_exists($class)) {
|
if (class_exists($class)) {
|
||||||
$this->model = new $class;
|
$this->model = new $class;
|
||||||
|
}
|
||||||
if ($this->model->get('auth') == false) {
|
}
|
||||||
$this->model->set('auth', $this->config->get('behavior', 'auth'));
|
else {
|
||||||
}
|
$this->model = new Model();
|
||||||
|
}
|
||||||
if ($this->model->get('view') == false) {
|
|
||||||
if ($this->config->get('behavior', 'view') != false) {
|
if ($this->model->get('auth') == false) {
|
||||||
$view = $this->config->get('behavior', 'view');
|
$this->model->set('auth', $this->config->get('behavior', 'auth'));
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
// Perhaps Smarty shouldn't be assumed at this point...
|
if ($this->model->get('view') == false) {
|
||||||
$view = isset($argv) ? 'CLI' : 'Smarty';
|
if ($this->config->get('behavior', 'view') != false) {
|
||||||
}
|
$view = $this->config->get('behavior', 'view');
|
||||||
|
|
||||||
$this->model->set('view', $view);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->model->get('auth') === true && $controller != 'CLI') {
|
|
||||||
Security::authenticate();
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->model->set('name', $name);
|
|
||||||
$this->model->set('section', $section);
|
|
||||||
$this->model->set('event', $event);
|
|
||||||
|
|
||||||
$this->model->__default();
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// @todo
|
// Perhaps Smarty shouldn't be assumed at this point...
|
||||||
exit();
|
$view = isset($argv) ? 'CLI' : 'Smarty';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load the viewer
|
$this->model->set('view', $view);
|
||||||
$this->viewer = Viewer::factory($this->model);
|
|
||||||
$this->viewer->display();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->model->get('auth') === true && $controller != 'CLI') {
|
||||||
|
Security::authenticate();
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->model->set('name', $name);
|
||||||
|
$this->model->set('section', $section);
|
||||||
|
$this->model->set('event', $event);
|
||||||
|
|
||||||
|
$this->model->__default();
|
||||||
|
|
||||||
|
// Load the viewer
|
||||||
|
$this->viewer = Viewer::factory($this->model);
|
||||||
|
$this->viewer->display();
|
||||||
}
|
}
|
||||||
|
|
||||||
//var_dump($name, $this->session, $_SESSION, $_SERVER);
|
//var_dump($name, $this->session, $_SESSION, $_SERVER);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue