Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update system/controller.php #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 22 additions & 14 deletions system/controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,47 @@

class Controller {

public function loadModel($name)
{
require(APP_DIR .'models/'. strtolower($name) .'.php');
public function loadModel($name){
require(APP_DIR .'models'. DS . strtolower($name) .'.php');

$model = new $name;
return $model;
}

public function loadView($name)
{
public function loadView($name){
$view = new View($name);
return $view;
}

public function loadPlugin($name)
{
require(APP_DIR .'plugins/'. strtolower($name) .'.php');
public function loadPlugin($name){
require(APP_DIR .'plugins'. DS . strtolower($name) .'.php');
}

public function loadHelper($name)
{
require(APP_DIR .'helpers/'. strtolower($name) .'.php');
public function loadHelper($name){
require(APP_DIR .'helpers'. DS . strtolower($name) .'.php');
$helper = new $name;
return $helper;
}

public function redirect($loc)
{
public function redirect($loc){
global $config;

header('Location: '. $config['base_url'] . $loc);
}

public function render($response=array(), $tipo='json'){
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Return Response to Ajax request!

$tipo = strtolower($tipo);
if($tipo === 'json'){
die(json_encode($response));
}
else if($tipo === 'jsonp'){
die($_REQUEST['callback'] . '(' . json_encode($response) . ');' );
}
else{
die($response);
}
}

}

?>
?>