From ba4ca85fd1b1dcf3e9a46279545f05cc21234c2a Mon Sep 17 00:00:00 2001 From: hieutmd Date: Mon, 29 Jan 2024 10:58:52 +0700 Subject: [PATCH 1/2] c --- README.md | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 964330f..bf2abb0 100644 --- a/README.md +++ b/README.md @@ -2,25 +2,43 @@

Link thiết kế: Giao diện Admin

+

Repo: https://repo.hurasoft.com/tieptk/admin_hura_8

+

Cài đặt hệ thống

Test và làm việc chính tại web: http://local.hura8_admin/

-

-    <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> 
-
+

Cấu trúc thư mục

From 507ea95304f8d1ec928b0595203afddf6396fdea Mon Sep 17 00:00:00 2001 From: hieutmd Date: Mon, 29 Jan 2024 11:46:07 +0700 Subject: [PATCH 2/2] c --- inc/Hura8/AppAdmin.php | 4 ++++ inc/Hura8/Router.php | 14 +++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/inc/Hura8/AppAdmin.php b/inc/Hura8/AppAdmin.php index 58de2ea..f7d99be 100644 --- a/inc/Hura8/AppAdmin.php +++ b/inc/Hura8/AppAdmin.php @@ -73,6 +73,10 @@ class AppAdmin 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_name = $this->current_route_info['view'].".html"; $template_file_full_path = $template_file_path."/".$template_file_name; diff --git a/inc/Hura8/Router.php b/inc/Hura8/Router.php index 1361840..61d07e4 100644 --- a/inc/Hura8/Router.php +++ b/inc/Hura8/Router.php @@ -29,7 +29,7 @@ class Router { } // 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(isset($_route['query']) && is_array($_route['query'])) { @@ -43,16 +43,20 @@ class Router { 'match' => $match, ], $_route); } - } + }*/ // auto parse path base on convention: admin/module/view/view_id $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 return [ - 'module' => $ele[2] ?? 'home', - 'view' => isset($ele[3]) ? preg_replace("/[^a-z0-9_\-]/i","", $ele[3] ) : 'home', - 'view_id' => isset($ele[4]) ? preg_replace("/[^a-z0-9_]/i","", $ele[4] ) : '', + 'module' => preg_replace("/[^a-z0-9_\-]/i","", $module ) , + 'view' => preg_replace("/[^a-z0-9_\-]/i","", $view ) , + 'view_id' => preg_replace("/[^a-z0-9_]/i","", $view_id ), 'query' => $parsed['query'], ]; }