Merge branch 'master' of https://repo.hurasoft.com/tieptk/admin_hura_8
This commit is contained in:
42
README.md
42
README.md
@@ -2,25 +2,43 @@
|
|||||||
|
|
||||||
<p>Link thiết kế: <a href="https://www.figma.com/file/5Km584w3tlnwxOltV5KAjh/281123_HURA8?node-id=328%3A1204&mode=dev" target="_blank"> <strong>Giao diện Admin</strong> </a></p>
|
<p>Link thiết kế: <a href="https://www.figma.com/file/5Km584w3tlnwxOltV5KAjh/281123_HURA8?node-id=328%3A1204&mode=dev" target="_blank"> <strong>Giao diện Admin</strong> </a></p>
|
||||||
|
|
||||||
|
<p>Repo: <a href="https://repo.hurasoft.com/tieptk/admin_hura_8" target="_blank">https://repo.hurasoft.com/tieptk/admin_hura_8</a></p>
|
||||||
|
|
||||||
<h2>Cài đặt hệ thống</h2>
|
<h2>Cài đặt hệ thống</h2>
|
||||||
|
|
||||||
<p>Test và làm việc chính tại web: <a href="http://local.hura8_admin/"> http://local.hura8_admin/</a> </p>
|
<p>Test và làm việc chính tại web: <a href="http://local.hura8_admin/"> http://local.hura8_admin/</a> </p>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li>Tải phần mềm XAMPP tại https://www.apachefriends.org/download.html để chạy PHP</li>
|
<li>Tải phần mềm XAMPP tại <a href="https://www.apachefriends.org/download.html" target="_blank">https://www.apachefriends.org/download.html</a> để chạy PHP</li>
|
||||||
<li>Chỉnh file hosts trong máy tính: 127.0.0.1 local.hura8_admin</li>
|
<li>Chỉnh file hosts trong máy tính C:\Windows\System32\drivers\etc\hosts:
|
||||||
<li>Cài đặt httpd-vhosts.conf của XAMPP</li>
|
<pre><code>
|
||||||
|
127.0.0.1 local.hura8_admin
|
||||||
|
</code></pre>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
Cài đặt ../xampp/apache/conf/extra/httpd-vhosts.conf của apache trong XAMPP
|
||||||
|
<pre><code>
|
||||||
|
<VirtualHost *:80>
|
||||||
|
DocumentRoot "/thuc-muc-check-out/admin_hura_8"
|
||||||
|
ServerName local.hura8_admin
|
||||||
|
<Directory "/thuc-muc-check-out/admin_hura_8/">
|
||||||
|
Require all granted
|
||||||
|
</Directory>
|
||||||
|
</VirtualHost>
|
||||||
|
</code></pre>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
Cài đặt ../xampp/apache/conf/httpd.conf của apache trong XAMPP
|
||||||
|
<pre><code>
|
||||||
|
# AllowOverride controls what directives may be placed in .htaccess files.
|
||||||
|
# It can be "All", "None", or any combination of the keywords:
|
||||||
|
# AllowOverride FileInfo AuthConfig Limit
|
||||||
|
AllowOverride All
|
||||||
|
</code></pre>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<pre><code>
|
|
||||||
<VirtualHost *:80>
|
|
||||||
DocumentRoot "/thuc-muc-check-out/admin_hura_8"
|
|
||||||
ServerName local.hura8_admin
|
|
||||||
<Directory "/thuc-muc-check-out/admin_hura_8/">
|
|
||||||
Require all granted
|
|
||||||
</Directory>
|
|
||||||
</VirtualHost>
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
<h2>Cấu trúc thư mục</h2>
|
<h2>Cấu trúc thư mục</h2>
|
||||||
|
|
||||||
|
|||||||
@@ -43,11 +43,7 @@ class AppAdmin
|
|||||||
|
|
||||||
|
|
||||||
protected function getData() {
|
protected function getData() {
|
||||||
$module_file = join(DIRECTORY_SEPARATOR, [
|
$module_file = $this->getModuleFile();
|
||||||
"data",
|
|
||||||
$this->current_route_info["module"],
|
|
||||||
str_replace("-", "_", $this->current_route_info["view"]).".php"
|
|
||||||
]) ;
|
|
||||||
|
|
||||||
if(file_exists($module_file)) {
|
if(file_exists($module_file)) {
|
||||||
// print_r($this->current_route_info);
|
// print_r($this->current_route_info);
|
||||||
@@ -71,8 +67,21 @@ class AppAdmin
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected function getModuleFile() {
|
||||||
|
return join(DIRECTORY_SEPARATOR, [
|
||||||
|
"data",
|
||||||
|
$this->current_route_info["module"],
|
||||||
|
str_replace("-", "_", $this->current_route_info["view"]).".php"
|
||||||
|
]) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
protected function renderModule() {
|
protected function renderModule() {
|
||||||
|
|
||||||
|
if(!$this->current_route_info['module'] || !$this->current_route_info['view']) {
|
||||||
|
die("Module not exist");
|
||||||
|
}
|
||||||
|
|
||||||
$template_file_path = $this->tpl_path ."/". $this->current_route_info['module'];
|
$template_file_path = $this->tpl_path ."/". $this->current_route_info['module'];
|
||||||
$template_file_name = $this->current_route_info['view'].".html";
|
$template_file_name = $this->current_route_info['view'].".html";
|
||||||
$template_file_full_path = $template_file_path."/".$template_file_name;
|
$template_file_full_path = $template_file_path."/".$template_file_name;
|
||||||
@@ -80,7 +89,10 @@ class AppAdmin
|
|||||||
//check exist
|
//check exist
|
||||||
if(!@file_exists( $template_file_full_path)) {
|
if(!@file_exists( $template_file_full_path)) {
|
||||||
// attempt to auto create first
|
// attempt to auto create first
|
||||||
if(!$this->autoCreateTplFile( $template_file_path, $template_file_name )) {
|
// todo: this MUST BE TURNED OFF IN PRODUCTION, else many files will be created unintentionally
|
||||||
|
$module_file = $this->getModuleFile();
|
||||||
|
// only create if module file exist
|
||||||
|
if(file_exists($module_file) && !$this->autoCreateTplFile( $template_file_path, $template_file_name )) {
|
||||||
die("Please manually create template file at: ". $template_file_full_path);
|
die("Please manually create template file at: ". $template_file_full_path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ class Router {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check match pattern in $this->path_config
|
// check match pattern in $this->path_config
|
||||||
foreach ($this->path_config as $_config => $_route ) {
|
/*foreach ($this->path_config as $_config => $_route ) {
|
||||||
if(preg_match("{^".$_config."$}", $parsed['path'], $match )) {
|
if(preg_match("{^".$_config."$}", $parsed['path'], $match )) {
|
||||||
|
|
||||||
if(isset($_route['query']) && is_array($_route['query'])) {
|
if(isset($_route['query']) && is_array($_route['query'])) {
|
||||||
@@ -43,16 +43,20 @@ class Router {
|
|||||||
'match' => $match,
|
'match' => $match,
|
||||||
], $_route);
|
], $_route);
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
// auto parse path base on convention: admin/module/view/view_id
|
// auto parse path base on convention: admin/module/view/view_id
|
||||||
$ele = explode("/", $parsed['path']);
|
$ele = explode("/", $parsed['path']);
|
||||||
|
|
||||||
|
$module = $ele[2] ?? 'home';
|
||||||
|
$view = isset($ele[3]) ? $ele[3] : getRequest('view', 'home');
|
||||||
|
$view_id = isset($ele[4]) ? $ele[4] : getRequest('id', 'view_id');
|
||||||
|
|
||||||
// else error
|
// else error
|
||||||
return [
|
return [
|
||||||
'module' => $ele[2] ?? 'home',
|
'module' => preg_replace("/[^a-z0-9_\-]/i","", $module ) ,
|
||||||
'view' => isset($ele[3]) ? preg_replace("/[^a-z0-9_\-]/i","", $ele[3] ) : 'home',
|
'view' => preg_replace("/[^a-z0-9_\-]/i","", $view ) ,
|
||||||
'view_id' => isset($ele[4]) ? preg_replace("/[^a-z0-9_]/i","", $ele[4] ) : '',
|
'view_id' => preg_replace("/[^a-z0-9_]/i","", $view_id ),
|
||||||
'query' => $parsed['query'],
|
'query' => $parsed['query'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user