UnLL LLLHLL\ LLxmlxmlnshttp://www.w3.org/XML/1998/namespacetpltagcondition== substr($name,0,6)){ // 特殊变量 return $this->parseThinkVar($name); }elseif(strpos($name,'.')) { $vars = explode('.',$name); $var = array_shift($vars); switch(strtolower(C('TMPL_VAR_IDENTIFY'))) { case 'array': // 识别为数组 $name = '$'.$var; foreach ($vars as $key=>$val){ if(0===strpos($val,'$')) { $name .= '["{'.$val.'}"]'; }else{ $name .= '["'.$val.'"]'; } } break; case 'obj': // 识别为对象 $name = '$'.$var; foreach ($vars as $key=>$val) $name .= '->'.$val; break; default: //0a(Un(UnLL LL@ L^ nL@ LLqUDLLA(Un(UnLLpL^ nL@ LLUnUnLL殊模板变量 * @access public * @param string $varStr 变量字符串 * @return string */ public function parseThinkVar($varStr){ if(is_array($varStr)){//用于正则替换回调函数 $varStr = $varStr[1]; } $vars = explode('.',$varStr); $vars[1] = strtoupper(trim($vars[1])); $parseStr = ''; if(count($vars)>=3){ $vars[2] = trim($vars[2]); switch($vars[1]){ case 'SERVER': $parseStr = '$_SERVER[\''.$vars[2].'\']';break; case 'GET': $parseStr = '$_GET[\''.$vars[2].'\']';break; case 'POST': $parseStr = '$_POST[\''.$vars[2].'\']';break; case 'COOKIE': if(isset($vars[3])) { $parseStr = '$_COOKIE[\''.$vars[2].'\'][\''.$vars[3].'\']'; }elseif(C('COOKIE_PREFIX')){ $parseStr = '$_COOKIE[\''.C('COOKIE_PREFIX').$vars[2].'\']'; }else{ $parseStr = '$_COOKIE[\''.$vars[2].'\']'; } break; case 'SESSION': if(isset($vars[3])) { $parseStr = '$_SESSION[\''.$vars[2].'\'][\''.$vars[3].'\']'; }elseif(C('SESSION_PREFIX')){ $parseStr = '$_SESSION[\''.C('SESSION_PREFIX').'\'][\''.$vars[2].'\']'; }else{ $parseStr = '$_SESSION[\''.$vars[2].'\']'; } break; case 'ENV': $parseStr = '$_ENV[\''.$vars[2].'\']';break; case 'REQUEST': $parseStr = '$_REQUEST[\''.$vars[2].'\']';break; case 'CONST': $parseStr = strtoupper($vars[2]);break; case 'LANG': $parseStr = 'L("'.$vars[2].'")';break; case 'CONFIG': $parseStr = 'C("'.$vars[2].'")';break; } }else if(count($vars)==2){ switch($vars[1]){ case 'NOW': $parseStr = "date('Y-m-d g:i a',time())";break; case 'VERSION': $parseStr = 'THINK_VERSION';break; case 'TEMPLATE':$parseStr = 'C("TEMPLATE_NAME")';break; case 'LDELIM': $parseStr = 'C("TMPL_L_DELIM")';break; case 'RDELIM': $parseStr = 'C("TMPL_R_DELIM")';break; default: if(defined($vars[1])) $parseStr = $vars[1]; } } return $parseStr; } // 获取标签定义 public function getTags(){ return $this->tags; } } = $this->config['taglUnUn`L`L中的继承标签 $find = preg_match('/'.$begin.'extend\s(.+?)\s*?\/'.$end.'/is',$content,$matches); if($find) { //替换extend标签 $content = str_replace($matches[0],'',$content); // 记录页面中的block标签 preg_replace_callback('/'.$begin.'block\sname=[\'"](.+?)[\'"]\s*?'.$end.'(.*?)'.$begin.'\/block'.$end.'/is', array($this, 'parseBlock'),$co