From d659a777f49f60717b9f227cafa4c9ce89a5cd74 Mon Sep 17 00:00:00 2001 From: hieutmd Date: Mon, 29 Jan 2024 11:56:08 +0700 Subject: [PATCH] c --- inc/Hura8/AppAdmin.php | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/inc/Hura8/AppAdmin.php b/inc/Hura8/AppAdmin.php index f7d99be..a94e554 100644 --- a/inc/Hura8/AppAdmin.php +++ b/inc/Hura8/AppAdmin.php @@ -43,11 +43,7 @@ class AppAdmin protected function getData() { - $module_file = join(DIRECTORY_SEPARATOR, [ - "data", - $this->current_route_info["module"], - str_replace("-", "_", $this->current_route_info["view"]).".php" - ]) ; + $module_file = $this->getModuleFile(); if(file_exists($module_file)) { // print_r($this->current_route_info); @@ -71,6 +67,15 @@ 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() { if(!$this->current_route_info['module'] || !$this->current_route_info['view']) { @@ -84,7 +89,10 @@ class AppAdmin //check exist if(!@file_exists( $template_file_full_path)) { // 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); } }