Add a lot

This commit is contained in:
2018-11-27 13:59:21 +09:00
parent d9e043c468
commit 561bfbf475
37 changed files with 8589 additions and 7952 deletions

View File

@@ -6,67 +6,67 @@ use CAUProject3Contact\Config;
class ControllerSite {
private $data;
private $head;
private $footer;
private $data;
private $head;
private $footer;
public function __construct() {
$this->data = [];
$this->head = [];
$this->footer = [];
}
public function __construct() {
$this->data = [];
$this->head = [];
$this->footer = [];
}
protected function view( $header = true, $footer = true ) {
ob_start();
extract( $this->data );
protected function view( $header = true, $footer = true ) {
ob_start();
extract( $this->data );
if ( empty( $this->head['title'] ) ) {
$this->head['title'] = Config::TITLE_HEADER;
}
if ( empty( $this->head['description'] ) ) {
$this->head['description'] = Config::DESCRIPTION_HEADER;
}
if ( $header ) {
require 'src/View/Site/tpl/head.php';
}
if ( empty( $this->head[ 'title' ] ) ) {
$this->head[ 'title' ] = Config::TITLE_HEADER;
}
if ( empty( $this->head[ 'description' ] ) ) {
$this->head[ 'description' ] = Config::DESCRIPTION_HEADER;
}
if ( $header ) {
require 'src/View/Site/tpl/head.php';
}
require 'src/View/' . str_replace( '\\', '/', preg_replace( '#^' . Config::NAMESPACE . '\\\Controller\\\#', '', get_class( $this ) ) ) . '.php';
require 'src/View/' . str_replace( '\\', '/', preg_replace( '#^' . Config::NAMESPACE . '\\\Controller\\\#', '', get_class( $this ) ) ) . '.php';
if ( $footer ) {
require 'src/View/Site/tpl/footer.php';
}
if ( $footer ) {
require 'src/View/Site/tpl/footer.php';
}
ob_end_flush();
exit();
}
ob_end_flush();
exit();
}
protected function addHead( $head ) {
$this->head += $head;
}
protected function addHead( $head ) {
$this->head += $head;
}
protected function addData( $data ) {
$this->data += $data;
}
protected function addData( $data ) {
$this->data += $data;
}
protected function addFooter( $footer ) {
$this->footer += $footer;
}
protected function addFooter( $footer ) {
$this->footer += $footer;
}
/**
* @param $data
*/
protected function returnJson( $data ) {
header( 'Content-Type: application/json' );
echo json_encode( $data );
exit();
}
/**
* @param $data
*/
protected function returnJson( $data ) {
header( 'Content-Type: application/json' );
echo json_encode( $data );
exit();
}
protected function throwError( $msg, $code = '' ) {
header( 'Content-Type: application/json' );
echo json_encode( [ 'status' => 'echec', 'msg' => $msg, 'code' => $code ], JSON_PRETTY_PRINT );
exit();
}
protected function throwError( $msg, $code = '' ) {
header( 'Content-Type: application/json' );
echo json_encode( [ 'status' => 'echec', 'msg' => $msg, 'code' => $code ], JSON_PRETTY_PRINT );
exit();
}
}
?>