谁能帮忙注释下代码。有研究代码的来看ia谢谢了
function loadTempletFile($file,$refresh=false) {
global $royalfield,$messageStack;
$cachedir = DIR_FS_ROOT.'cache/templets/'.md5(strtolower(dirname($file))).'/';
$cachename = $cachedir.basename($file).'.php';
if(!$refresh&&is_file($cachename)&&filemtime($cachename)>filemtime($file)&&filemtime($cachename)>time()-864000){
return file_get_contents($cachename);
} else {
$filestr = $this->parseFileString($file);
$shiftpos = 0;
$this->templetstring = '<?php if(!defined("ROYALERP_INCLUDE")) die("<a href=\'http://www.royalerp.com\'>RoyalERP.com</a>");?>'.$this->loadTempletString($filestr,$shiftpos);
$this->templetstring = parseTagInnerHTML($this->templetstring,'royalfield',$default);
@mkdir_r($cachedir);
if(is_writable($cachedir)){
$fp = @fopen($cachename,"w") or die("RoaylERP Create File False");
fwrite($fp,$this->templetstring);
fclose($fp);
}
if ($messageStack->size > 0) {
$this->templetstring.= $messageStack->output();
}
return $this->templetstring;
}
}
function loadTempletFileString($data){
global $royalfield;
$filestr = $this->parseFileString($data,true);
$shiftpos = 0;
$this->templetstring = $this->loadTempletString($filestr,$shiftpos);
$this->templetstring = parseTagInnerHTML($this->templetstring,'royalfield',$default);
return $this->templetstring;
}
function parseFileString($file,$istext=false) {
if($istext){
$filestr= $file;
} else {
$filestr= ' '.file_get_contents($file);
}
$startpos = 0;
$includepos = strpos($filestr,'<include:',$startpos);
while(false!==$includepos) {
if($includepos>$startpos) {
$string=substr($filestr,$startpos,$includepos-1);
$spacepos = strpos($filestr,' ',$includepos);
if($spacepos>$includepos+9){
$tagname = substr($filestr,$includepos+9,$spacepos-$includepos-9);
$filenamepos = strpos($filestr,'filename',$includepos);
$filenamelastpos = strpos($filestr,'>',$includepos);
if($filestr[$filenamelastpos-1]=='/'){
$filenamelastpos++;
$tmpstr = substr($filestr,$filenamepos,$filenamelastpos-$filenamepos);
} else {
$filenamelastpos = strpos($filestr,'</include:'.$tagname.'>',$includepos);
$filenamelastpos += strlen($tagname)+11;
$tmpstr = substr($filestr,$filenamepos,$filenamelastpos-$filenamepos);
}
$filenames = explode('"',$tmpstr,3);
$tfile = DIR_FS_ROOT.'templets/'.DEFAULT_CSS_PATH.'/'.($tagname==''?'':$tagname.'/').$filenames[1];
if(file_exists($tfile)) {
$loadstring = file_get_contents($tfile);
} else {
$loadstring = "";
}
$laststring = substr($filestr,$filenamelastpos);
$filestr = $string . $loadstring .$laststring;
}
}
if($startpos<strlen($filestr)) {
$includepos = strpos($filestr,'<include:',$startpos);
} else {
break;
}
}
return trim($filestr);
}
function loadTempletString(&$filestr,&$shiftpos,$issub=false) {
$lastpos = $shiftpos;
$strlen = strlen($filestr);
$ret = "";
while ($shiftpos<$strlen) {
$matchs = array();
$subret = "";
if($filestr[$shiftpos]=='<'&&preg_match($this->reg_match_string,substr($filestr,$shiftpos,$this->maxtaglen+3),$matchs)) { //find
if($shiftpos>$lastpos){
$ret.=substr($filestr,$lastpos,$shiftpos-$lastpos);
$lastpos = $shiftpos;
}
$matchlen = strlen($matchs[0]);
$currenttag = substr($matchs[0],1,$matchlen-2);
$shiftpos+=$matchlen;
$index1 = strpos($filestr,' ',$shiftpos)-$shiftpos;
$index2 = strpos($filestr,'/>',$shiftpos)-$shiftpos;
$index3x = strpos($filestr,'>',$shiftpos);
$index3 = $index3x-$shiftpos;
if($index1<0)$index1=100000;
if($index2<0)$index2=100000;
if($index3<0)$index3=100000;
$minindex = min(min($index1,$index2),$index3);
$tagclass = substr($filestr,$shiftpos,$minindex);
$tagstring = '<'.$currenttag.':'.$tagclass;
$shiftpos+=strlen($tagclass);
while($shiftpos<$strlen){
if(substr($filestr,$shiftpos,2)=='/>'){ //tag end
if($shiftpos<=$index3x){
$tagstring.='>';
$ret.=$this->parseTempletTag($tagstring.'</'.substr($matchs[0],1).$tagclass.'>',$currenttag,$tagclass); //trans standard
$shiftpos+=2;
if($issub){
return $ret;
} else {
$lastpos = $shiftpos;
break;
}
} else {
$tagstring.=$filestr[$shiftpos];
$shiftpos++;
}
} else if(substr($filestr,$shiftpos,strlen('</'.substr($matchs[0],1).$tagclass.'>'))=='</'.substr($matchs[0],1).$tagclass.'>'){
$ret.=$this->parseTempletTag($tagstring.'</'.substr($matchs[0],1).$tagclass.'>',$currenttag,$tagclass);
$shiftpos+=strlen(substr($matchs[0],1).$tagclass)+3;
if($issub){
return $ret;
} else {
$lastpos = $shiftpos;
break;
}
} else if($filestr[$shiftpos]=='<'&&preg_match($this->reg_match_string,substr($filestr,$shiftpos,$this->maxtaglen+3))) {//enbed tag
$tmp = $this->loadTempletString($filestr,$shiftpos,true);
$subret.=$tmp;
$tagstring.=$tmp;
} else {
$tagstring.=$filestr[$shiftpos];
$shiftpos++;
}
}
} else {
$shiftpos++;
}
}
if($shiftpos>$lastpos){
$ret.=substr($filestr,$lastpos,$shiftpos-$lastpos);
$lastpos = $shiftpos;
}
return $ret;
}
function parseTempletTag($tagstring,$namespace='',$tagname=''){
global $db;
$pos = strpos($tagstring,'>');
require_once(DIR_FS_CLASSES.'xml.php');
$xml = new RoyalXmlParser();
$string = substr($tagstring,0,$pos);
if(substr($string,'-1')=='/')$string = substr($string,0,$pos-1);
$xml->parseString($string.'></'.$namespace.':'.$tagname.'>');
$tagarray = $xml->getTree();
$tagarray = $tagarray[$namespace.':'.$tagname];
switch ($namespace) {
case 'fun':
if(eip_not_null($tagarray['params'])){
$phpstring = '<?php echo '.$tagname.'('.$tagarray['params'].');?>';
} else {
$phpstring = '<?php echo '.$tagname.';?>';
}
return $phpstring;
case 'const':
return '<?php echo '.$tagname.';?>';
case 'exp':
return '<?php '.$tagname.';?>';
case 'var':
if(isset($tagarray['params'])&&$tagarray['params']!=""){
return '<?php echo $'.$tagname.'["'.$tagarray['params'].'"];?>';
}
return '<?php echo $'.$tagname.';?>';
case 'field':
return '<?php echo $royalfield["'.$tagname.'"];?>';
case 'sys':
$tagarray['innerHTML'] = substr($tagstring,$pos+1,strlen($tagstring)-strlen('</'.$namespace.':'.$tagname.'>')-$pos-1);
if(file_exists(DIR_FS_INCLUDES.'/tags/tag_'.$tagname.'.php')){
include_once(DIR_FS_INCLUDES.'/tags/tag_'.$tagname.'.php');
$funcname = $namespace.'_'.$tagname.'_tag';
$retvalue = "";
if($funcname($tagarray,$retvalue)){
return $retvalue;
}
} else {
return '';
}
default:
$tagarray['innerHTML'] = substr($tagstring,$pos+1,strlen($tagstring)-strlen('</'.$namespace.':'.$tagname.'>')-$pos-1);
if(file_exists(DIR_FS_ROOT.$namespace.'/tags/tag_'.$tagname.'.php')){
include_once(DIR_FS_ROOT.$namespace.'/tags/tag_'.$tagname.'.php');
$funcname = $namespace.'_'.$tagname.'_tag';
$retvalue = "";
if($funcname($tagarray,$retvalue)){
return $retvalue;
}
} else {
return '';
}
}
}
}
?>
...全文
相关推荐
DEBERES-SE-IA:人工雌虫,雌虫,雌蕊,雌蕊,雌蕊,雌虫
DEBERES-SE-IA 人工皮肤肌腱病专家
Swagger--分组 & 接口注释
本文详细介绍了如何在SpringBoot项目中集成Swagger,包括配置分组、接口注释的使用,以及如何创建和展示API文档中的实体模型。通过实例演示了如何设置不同分组的Docket,并展示了@ApiModel和@ApiParam注解在实体类和方法上的应用。
Ensemble-BioMart:得到基因注释信息(有参考基因组的物种)
本文介绍了如何利用Ensembl BioMart查询基因的不同编号系统,如从NCBI编号查询Ensembl编号,以及如何获取基因的英文简写和基因组坐标。对于非模式物种的基因功能注释,提到了特定物种如水稻和小麦的资源,并详细解析了Ensembl BioMart的使用步骤,包括选择数据集、过滤和属性设置,以获取基因的注释信息。
Android Studio快速编写 Flutter 代码提高开发效率
本文介绍了如何在Android Studio中通过快捷方式高效地创建Flutter Widget模板,如StatefulWidget、StatelessWidget、Scaffold + AppBar等,并展示了快速生成for循环代码的方法。此外,还分享了在Widget嵌套布局中删除或添加父Widget,添加try-catch块,以及复制、删除和注释代码的快捷技巧。
Microkernel mkx86-开源
ia32体系结构的开源微内核。 基本上,这是使用GNU C和nasm的全功能操作系统实现。 用西班牙语进行了完整注释,并带有解释系统调用,库函数,设计等的外部文档。


Framework
