-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
518 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
/** | ||
* @author : Waris Agung Widodo | ||
* @Date : 2017-07-05 12:15:12 | ||
* @Last Modified by : ido | ||
* @Last Modified time : 2017-07-05 15:08:08 | ||
* | ||
* Copyright (C) 2017 Waris Agung Widodo ([email protected]) | ||
*/ | ||
|
||
require_once 'Controller.php'; | ||
|
||
class BiblioController extends Controller | ||
{ | ||
protected $sysconf; | ||
protected $db; | ||
|
||
function __construct($sysconf, $obj_db) | ||
{ | ||
$this->sysconf = $sysconf; | ||
$this->db = $obj_db; | ||
} | ||
|
||
public function detail($id, $token) | ||
{ | ||
require_once __DIR__ . './../../../lib/api.inc.php'; | ||
$biblio = api::biblio_load($this->db, $id); | ||
parent::withJson($biblio[0]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
/** | ||
* @author : Waris Agung Widodo | ||
* @Date : 2017-07-05 12:17:02 | ||
* @Last Modified by : ido | ||
* @Last Modified time : 2017-07-05 13:53:28 | ||
* | ||
* Copyright (C) 2017 Waris Agung Widodo ([email protected]) | ||
*/ | ||
|
||
class Controller | ||
{ | ||
|
||
public function withJson($array) | ||
{ | ||
header('Content-type: application/json'); | ||
echo json_encode($array); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
/** | ||
* @author : Waris Agung Widodo | ||
* @Date : 2017-07-05 13:05:36 | ||
* @Last Modified by : ido | ||
* @Last Modified time : 2017-07-05 13:12:51 | ||
* | ||
* Copyright (C) 2017 Waris Agung Widodo ([email protected]) | ||
*/ | ||
|
||
require_once 'Controller.php'; | ||
|
||
class HomeController extends Controller | ||
{ | ||
|
||
public function index() | ||
{ | ||
$response = array( | ||
'error' => false, | ||
'message' => 'Sugeng rawuh is selamat datang.' | ||
); | ||
parent::withJson($response); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
/** | ||
* @author : Waris Agung Widodo | ||
* @Date : 2017-07-04 15:28:21 | ||
* @Last Modified by : ido | ||
* @Last Modified time : 2017-07-05 15:04:29 | ||
* | ||
* Copyright (C) 2017 Waris Agung Widodo ([email protected]) | ||
*/ | ||
|
||
/*---------- Require dependencies ----------*/ | ||
require 'lib/router.inc.php'; | ||
require __DIR__ . '/controllers/HomeController.php'; | ||
require __DIR__ . '/controllers/BiblioController.php'; | ||
|
||
/*---------- Create router object ----------*/ | ||
$router = new Router($sysconf, $dbs); | ||
$router->setBasePath('api'); | ||
|
||
/*---------- Create routes ----------*/ | ||
$router->map('GET', '/', 'HomeController:index'); | ||
$router->map('GET', '/biblio/[i:id]/[a:token]', 'BiblioController:detail'); | ||
|
||
/*---------- Run matching route ----------*/ | ||
$router->run(); | ||
|
||
// doesn't need template | ||
exit(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.