How does the HTML template for the PHPCMS homepage load?
How to look at it does not look out, its portal file is how to load the HTML homepage template.
There is a basee.php class, which seems to be responsible for loading, but there is a little to understand it how to load it?
/**
* base.php Phpcms Frame Entry file
*
* @copyright (C) 2005-2010 phpcms
* @licensehttp://www.phpcms.cn/license/
* @lastmodify2010-6-7
*/
Define (' In_phpcms ', true);
Phpcms Frame Path
Define (' Pc_path ', DirName (__file__). Directory_separator);
if (!defined (' Phpcms_path ')) define (' Phpcms_path ', Pc_path. ' ... '). Directory_separator);
Cache folder Address
Define (' Cache_path ', Phpcms_path. ' Caches '. Directory_separator);
Host Protocol
Define (' Site_protocol ', isset ($_server[' server_port ') && $_server[' server_port '] = = ' 443 '? ' https://': '/http ');
Host name of the current access
Define (' Site_url ', (isset ($_server[' http_host '))? $_server[' Http_host ']: ");
Source
Define (' Http_referer ', isset ($_server[' http_referer '])? $_server[' Http_referer ']: ');
System Start time
Define (' Sys_start_time ', Microtime ());
Load Common function libraries
Pc_base::load_sys_func (' Global ');
Pc_base::load_sys_func (' extention ');
Pc_base::auto_load_func ();
Pc_base::load_config (' System ', ' errorlog ')? Set_error_handler (' My_error_handler '): error_reporting (E_error | e_warning | E_parse);
Set local slack
Function_exists (' Date_default_timezone_set ') && date_default_timezone_set (pc_base::load_config (' System '), ' timezone '));
Define (' CHARSET ', pc_base::load_config (' System ', ' CHARSET '));
Output page Character set
Header (' content-type:text/html; charset= '. CHARSET);
Define (' Sys_time ', Time ());
Define the site root path
Define (' Web_path ', pc_base::load_config (' System ', ' Web_path '));
JS Path
Define (' Js_path ', pc_base::load_config (' System ', ' Js_path '));
CSS Path
Define (' Css_path ', pc_base::load_config (' System ', ' Css_path '));
IMG Path
Define (' Img_path ', pc_base::load_config (' System ', ' Img_path '));
Dynamic Program Path
Define (' App_path ', pc_base::load_config (' System ', ' App_path '));
Apply a static file path
Define (' Plugin_statics_path ', Web_path. ' statics/plugin/');
if (pc_base::load_config (' System ', ' gzip ') && function_exists (' Ob_gzhandler ')} {
Ob_start (' Ob_gzhandler ');
} else {
Ob_start ();
}
Class Pc_base {
/**
* Initialize Application
*/
public static function Creat_app () {
Return Self::load_sys_class (' Application ');
}
/**
* Load System class method
* @param string $classname class name
* @param string $path extended Address
* @param intger $initialize is initialized
*/
public static function Load_sys_class ($classname, $path = ", $initialize = 1) {
Return Self::_load_class ($classname, $path, $initialize);
}
/**
* Load Application class method
* @param string $classname class name
* @param string $m module
* @param intger $initialize is initialized
*/
public static function Load_app_class ($classname, $m = ", $initialize = 1) {
$m = Empty ($m) && defined (' Route_m ')? Route_m: $m;
if (empty ($m)) return false;
Return Self::_load_class ($classname, ' modules '. Directory_separator. $m. Directory_separator. ' Classes ', $initialize);
}
/**
* Load Data Model
* @param string $classname class name
*/
public static function Load_model ($classname) {
Return Self::_load_class ($classname, ' model ');
}
/**
* Load class file functions
* @param string $classname class name
* @param string $path extended Address
* @param intger $initialize is initialized
*/
private static function _load_class ($classname, $path = ", $initialize = 1) {
Static $classes = Array ();
if (empty ($path)) $path = ' libs '. Directory_separator. ' Classes ';
$key = MD5 ($path. $classname);
if (Isset ($classes [$key])) {
if (!empty ($classes [$key])) {
return $classes [$key];
} else {
return true;
}
}
if (File_exists (Pc_path. $path. Directory_separator. $classname. Class.php ')) {
Include Pc_path. $path. Directory_separator. $classname. Class.php ';
$name = $classname;
if ($my _path = Self::my_path (Pc_path. $path. Directory_separator. $classname. Class.php ')) {
Include $my _path;
$name = ' my_ '. $classname;
}
if ($initialize) {
$classes [$key] = new $name;
} else {
$classes [$key] = true;
}
return $classes [$key];
} else {
return false;
}
}
/**
* Load the system's function library
* @param string $func function library name
*/
public static function Load_sys_func ($func) {
Return Self::_load_func ($func);
}
/**
* Auto Load AutoLoad directory under function library
* @param string $func function library name
*/
public static function Auto_load_func ($path = ") {
Return Self::_auto_load_func ($path);
}
/**
* Load Application Function library
* @param string $func function library name
* @param string $m model name
*/
public static function Load_app_func ($func, $m = ") {
$m = Empty ($m) && defined (' Route_m ')? Route_m: $m;
if (empty ($m)) return false;
Return Self::_load_func ($func, ' modules '. Directory_separator. $m. Directory_separator. ' Functions ');
}
/**
* Loading plug-in class library
*/
public static function Load_plugin_class ($classname, $identification = ", $initialize = 1) {
$identification = Empty ($identification) && defined (' plugin_id ')? PLUGIN_ID: $identification;
if (empty ($identification)) return false;
Return Pc_base::load_sys_class ($classname, ' plugin '. Directory_separator. $identification. Directory_separator. ' Classes ', $initialize);
}
/**
* Load Plugin function library
* @param string $func function file name
* @param string $identification plug-in identity
*/
public static function Load_plugin_func ($func, $identification) {
Static $funcs = Array ();
$identification = Empty ($identification) && defined (' plugin_id ')? PLUGIN_ID: $identification;
if (empty ($identification)) return false;
$path = ' plugin '. Directory_separator. $identification. Directory_separator. ' Functions '. Directory_separator. $func. Func.php ';
$key = MD5 ($path);
if (Isset ($funcs [$key])) return true;
if (File_exists (Pc_path. $path)) {
Include Pc_path. $path;
} else {
$funcs [$key] = false;
return false;
}
$funcs [$key] = true;
return true;
}
/**
* Load plug-in data model
* @param string $classname class name
*/
public static function Load_plugin_model ($classname, $identification) {
$identification = Empty ($identification) && defined (' plugin_id ')? PLUGIN_ID: $identification;
$path = ' plugin '. Directory_separator. $identification. Directory_separator. ' Model ';
Return Self::_load_class ($classname, $path);
}
/**
* Load Function Library
* @param string $func function library name
* @param string $path Address
*/
private static function _load_func ($func, $path = ") {
Static $funcs = Array ();
if (empty ($path)) $path = ' libs '. Directory_separator. ' Functions ';
$path. = Directory_separator. $func. Func.php ';
$key = MD5 ($path);
if (Isset ($funcs [$key])) return true;
if (File_exists (Pc_path. $path)) {
Include Pc_path. $path;
} else {
$funcs [$key] = false;
return false;
}
$funcs [$key] = true;
return true;
}
/**
* Load Function Library
* @param string $func function library name
* @param string $path Address
*/
private static function _auto_load_func ($path = ") {
if (empty ($path)) $path = ' libs '. Directory_separator. ' Functions '. Directory_separator. ' AutoLoad ';
$path. = Directory_separator. ' *.func.php ';
$auto _funcs = Glob (Pc_path. Directory_separator. $path);
if (!empty ($auto _funcs) && Is_array ($auto _funcs)) {
foreach ($auto _funcs as $func _path) {
Include $func _path;
}
}
}
/**
* Do you have an extension file of your own?
* @param string $filepath path
*/
public static function My_path ($filepath) {
$path = PathInfo ($filepath);
if (file_exists ($path [' dirname '). Directory_separator. ' My_ '. $path [' basename ']) {
return $path [' dirname ']. Directory_separator. ' My_ '. $path [' basename '];
} else {
return false;
}
}
/**
* Load configuration file
* @param string $file configuration file
* @param string $key The configuration recommended to get
* @param string $default default configuration. This value occurs when the Get configuration item fails.
* @param boolean $reload forced reload.
*/
public static function Load_config ($file, $key = ", $default =", $reload = False) {
Static $configs = Array ();
if (! $reload && isset ($configs [$file]) {
if (empty ($key)) {
return $configs [$file];
} elseif (Isset ($configs [$file] [$key])) {
return $configs [$file] [$key];
} else {
return $default;
}
}
$path = Cache_path. ' Configs '. Directory_separator. $file. PHP ';
if (file_exists ($path)) {
$configs [$file] = include $path;
}
if (empty ($key)) {
return $configs [$file];
} elseif (Isset ($configs [$file] [$key])) {
return $configs [$file] [$key];
} else {
return $default;
}
}
}
------to solve the idea----------------------
Default route settings: caches/configs/route.php ' Default ' =>array (' m ' = = ' content ', ' c ' = ' = ' index ', ' a ' = ' = ' init '),
Execution process: A=init, C=index, M=content, base.php,
Path: function init inside the phpcms/modules/content/index.php ()