您的位置:首页 > 编程语言 > PHP开发

phpcms源码跟踪(1)

2016-06-28 12:14 543 查看
本次跟踪解决几个问题:

1、缓存文件从哪里来,过程中被删除了怎么办

2、模板html是如何被引入的

进入首页时,通过最初的调用,进入控制器\phpcms\modules\content\index.php::init()中

[code]//首页
publicfunctioninit(){
if(isset($_GET['siteid'])){
$siteid=intval($_GET['siteid']);//当前站点id函数intval作用变量转成整数类型
}else{
$siteid=1;
}
$siteid=$GLOBALS['siteid']=max($siteid,1);
define('SITEID',$siteid);
$_userid=$this->_userid;
$_username=$this->_username;
$_groupid=$this->_groupid;
//SEO搜索引擎优化信息
$SEO=seo($siteid);//SEO搜索引擎优化信息
$sitelist=getcache('sitelist','commons');//缓存后台设置的所有站点配置信息
$default_style=$sitelist[$siteid]['default_style'];//当前站点默认模板风格配置
$CATEGORYS=getcache('category_content_'.$siteid,'commons');//当前站点所有栏目详细配置信息
includetemplate('content','index',$default_style);//调用第三步:模板调用
}


$siteid=1

$path.$classname=libs\classescache_factory

publicfunctionget()中

$filepath=CACHE_PATH.'caches_'.$module.'/caches_'.$type.'/'=C:\phpwork\bangth_com\src\caches\caches_commons/caches_data/

$filename=sitelist.cache.php
$filepath=CACHE_PATH.'caches_'.$module.'/caches_'.$type.'/'=C:\phpwork\bangth_com\src\caches\caches_commons/caches_data/
$filename=category_content_1.cache.php
通过
$data=@require($filepath.$filename);获取缓存中的数据
$CATEGORYS=getcache('category_content_'.$siteid,'commons');获取到栏目数据
functiontemplate($module='content',$template='index',$style='default')中
$compiledtplfile=PHPCMS_PATH.'caches'.DIRECTORY_SEPARATOR.'caches_template'.DIRECTORY_SEPARATOR.$style.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.$template.'.php'
=C:\phpwork\bangth_com\src\caches\caches_template\default\content\index.php
PC_PATH.'templates'.DIRECTORY_SEPARATOR.$style.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.$template.'.html'
=C:\phpwork\bangth_com\src\phpcms\templates\default\content\index.html
publicfunctiontemplate_compile('content','index',$style='default')完成根据模板编译成php文件的过程
$tplfile=C:\phpwork\bangth_com\src\phpcms\templates\default\content\index.html
NB的是通过
publicfunctiontemplate_parse($str)
将html模板文件转化为php文件
转化完成后通过之前
publicfunctioninit()函数中最后一行:include调用生成的\caches\caches_template\default\content\index.php

                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: