general fixes
This commit is contained in:
parent
05ee8bbeb8
commit
09a0367bdc
|
|
@ -20,8 +20,13 @@ class EntryPoint {
|
|||
$route = $this->routes->getDefaultRoute();
|
||||
}
|
||||
|
||||
if (count(\explode('/', $route)) == 1) {
|
||||
$controllerName = \explode('/', $route)[0];
|
||||
$functionName = "";
|
||||
}
|
||||
else {
|
||||
list($controllerName, $functionName) = \explode('/', $route);
|
||||
|
||||
}
|
||||
if ($functionName == '') {
|
||||
$functionName = 'home';
|
||||
}
|
||||
|
|
@ -30,7 +35,13 @@ class EntryPoint {
|
|||
$functionName = $functionName . 'Submit';
|
||||
}
|
||||
|
||||
$page = $this->routes->getController($controllerName)->$functionName();
|
||||
$page = $this->routes->getController($controllerName);
|
||||
if ($page == null) {
|
||||
$page = $this->routes->notFound();
|
||||
}
|
||||
else {
|
||||
$page = $page->$functionName();
|
||||
}
|
||||
$content = $this->loadTemplate('../templates/' . $page['template'], $page['vars']);
|
||||
$nav = $this->loadTemplate('../templates/nav.html.php', $page['vars']);
|
||||
$title = $page['title'];
|
||||
|
|
|
|||
|
|
@ -8,10 +8,16 @@ class Routes implements \CSY2028\Routes {
|
|||
|
||||
$controllers = [];
|
||||
//TODO: Add Controllers
|
||||
$controllers['jobs'] = new \jobs\controllers\Jobs($jobsTable, $catsTable);
|
||||
$controllers['jobs'] = new \jobs\controllers\Jobs($jobsTable, $catsTable, $appsTable);
|
||||
|
||||
if (array_key_exists($name, $controllers)) {
|
||||
return $controllers[$name];
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function getDefaultRoute() {
|
||||
return 'jobs/home';
|
||||
|
|
@ -30,4 +36,20 @@ class Routes implements \CSY2028\Routes {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
public function notFound() {
|
||||
$cats = new \CSY2028\DatabaseTable('category', 'id', '\jobs\Entity\Category');
|
||||
return ['template' => 'response.html.php',
|
||||
'title' => 'Jo\'s Jobs- 404 Not Found',
|
||||
'vars' => ['cats' => $cats->findAll(),
|
||||
'response' => '404 Page Not Found']
|
||||
];
|
||||
}
|
||||
|
||||
public function nav() {
|
||||
$cats = new \CSY2028\DatabaseTable('category', 'id', '\jobs\Entity\Category');
|
||||
return ['template' => 'nav.html.php',
|
||||
'vars' => ['cats' => $cats->findAll()]
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
session_start();
|
||||
require '../autoload.php';
|
||||
$routes = new \jobs\Routes();
|
||||
$entryPoint = new \CSY2028\EntryPoint($routes);
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
<h2><?=$job->title?></h2>
|
||||
<h3><?=$job->salary?></h2>
|
||||
<p><?=nl2br($job->description)?></p>
|
||||
<a class="more" href="/apply.php">Apply for this job</a>
|
||||
<a class="more" href="/jobs/apply?id=<?=$job->id?>">Apply for this job</a>
|
||||
</div>
|
||||
</li>
|
||||
<?php } ?>
|
||||
|
|
|
|||
Loading…
Reference in New Issue