CPradoViewRenderer
鍖 | system.web.renderers |
---|---|
缁ф壙 | class CPradoViewRenderer » CViewRenderer » CApplicationComponent » CComponent |
瀹炵幇 | IViewRenderer, IApplicationComponent |
婧愯嚜 | 1.0 |
鐗堟湰 | $Id: CPradoViewRenderer.php 2799 2011-01-01 19:31:13Z qiang.xue $ |
婧愮爜 | framework/web/renderers/CPradoViewRenderer.php |
CPradoViewRenderer瀹炵幇涓涓鍥炬覆鏌撳櫒锛屽畠鍏佽鐢ㄦ埛浣跨敤绫讳技浜嶱RADO妯℃澘鐨勬ā鏉胯娉曘
瑕佷娇鐢–PradoViewRenderer, 鍦ㄥ簲璇ョ▼搴忛厤缃枃浠朵腑閰嶇疆涓涓悕涓"viewRenderer"鐨勫簲鐢ㄧ粍浠讹細
CPradoViewRenderer 鍏佽浣犵敤涓嬮潰鐨勮娉曟潵鍐欒鍥炬枃浠讹細
瑕佷娇鐢–PradoViewRenderer, 鍦ㄥ簲璇ョ▼搴忛厤缃枃浠朵腑閰嶇疆涓涓悕涓"viewRenderer"鐨勫簲鐢ㄧ粍浠讹細
array( 'components'=>array( ...... 'viewRenderer'=>array( 'class'=>'CPradoViewRenderer', ), ), )
CPradoViewRenderer 鍏佽浣犵敤涓嬮潰鐨勮娉曟潵鍐欒鍥炬枃浠讹細
// PHP tags: <%= expression %> // <?php echo expression ?> <% statement %> // <?php statement ?></li> // component tags: <com:WigetClass name1="value1" name2='value2' name3={value3} > // <?php $this->beginWidget('WigetClass', // array('name1'=>"value1", 'name2'=>'value2', 'name3'=>value3)); ?> </com:WigetClass > // <?php $this->endWidget('WigetClass'); ?> <com:WigetClass name1="value1" name2='value2' name3={value3} /> // <?php $this->widget('WigetClass', // array('name1'=>"value1", 'name2'=>'value2', 'name3'=>value3)); ?> // cache tags: <cache:fragmentID name1="value1" name2='value2' name3={value3} > // <?php if($this->beginCache('fragmentID', // array('name1'=>"value1", 'name2'=>'value2', 'name3'=>value3))): ?> </cache:fragmentID > // <?php $this->endCache('fragmentID'); endif; ?> // clip tags: <clip:clipID > // <?php $this->beginClip('clipID'); ?> </clip:clipID > // <?php $this->endClip('clipID'); ?> // comment tags: <!--- comments ---> // the whole tag will be stripped off
鍏叡灞炴
灞炴 | 绫诲瀷 | 鎻忚堪 | 瀹氫箟鍦 |
---|---|---|---|
behaviors | array | 杩欎釜搴旂敤缁勪欢闄勫姞鐨勮涓恒 杩欐琛屼负灏嗗湪搴旂敤缁勪欢璋冪敤init鏃堕檮鍔犲湪搴旂敤缁勪欢涓娿 璇峰弬鐓CModel::behaviors濡備綍鎸囧畾姝ゅ睘鎬у笺 | CApplicationComponent |
fileExtension | string | 瑙嗗浘鏂囦欢鐨勬墿灞曞悕. | CViewRenderer |
filePermission | integer | 瑙f瀽鍚庣敓鎴愮殑涓存椂鐩綍鍜屼复鏃舵枃浠剁殑鏉冮檺銆 榛樿涓0755 (owner rwx, group rx and others rx). | CViewRenderer |
isInitialized | boolean | 妫鏌ュ簲鐢ㄧ粍浠舵槸鍚﹀凡缁忓垵濮嬪寲銆 | CApplicationComponent |
useRuntimePath | boolean | 鏄惁灏嗚В鏋愮殑缁撴灉淇濆瓨鍦ㄥ簲鐢ㄧ▼搴忕殑runtime鐩綍銆 榛樿涓簍rue銆 濡傛灉璁剧疆涓篺alse锛岃В鏋愮粨鏋滃皢浠ユ枃浠跺舰寮忎繚瀛樺湪鍜屾簮瑙嗗浘鏂囦欢鐩稿悓鐨勭洰褰曚笅 鏂囦欢鍚嶅皢浼氭槸婧愯鍥炬枃浠跺悕鍔犱笂瀛楁瘝c銆 | CViewRenderer |
鍏叡鏂规硶
鍙椾繚鎶ゆ柟娉
鏂规硶 | 鎻忚堪 | 瀹氫箟鍦 |
---|---|---|
generateViewFile() | 瑙f瀽婧愯鍥炬枃浠讹紝淇濆瓨缁撴灉鍒板彟涓涓枃浠躲 | CPradoViewRenderer |
getViewFile() | 鐢熸垚缁撴灉瑙嗗浘鏂囦欢鐨勮矾寰勩 | CViewRenderer |
鏂规硶璇︾粏
generateViewFile()
鏂规硶
protected void generateViewFile(string $sourceFile, string $viewFile)
| ||
$sourceFile | string | 婧愯鍥炬枃浠惰矾寰 |
$viewFile | string | 浣滀负缁撴灉鐨勮鍥炬枃浠惰矾寰 |
婧愮爜锛 framework/web/renderers/CPradoViewRenderer.php#81 (鏄剧ず)
protected function generateViewFile($sourceFile,$viewFile)
{
static $regexRules=array(
'<%=?\s*(.*?)\s*%>', // PHP statements or expressions
'<\/?(com|cache|clip):([\w\.]+)\s*((?:\s*\w+\s*=\s*\'.*?(?<!\\\\)\'|\s*\w+\s*=\s*".*?(?<!\\\\)"|\s*\w+\s*=\s*\{.*?\})*)\s*\/?>', // component tags
'<!---.*?--->', // template comments
);
$this->_sourceFile=$sourceFile;
$this->_input=file_get_contents($sourceFile);
$n=preg_match_all('/'.implode('|',$regexRules).'/msS',$this->_input,$matches,PREG_SET_ORDER|PREG_OFFSET_CAPTURE);
$textStart=0;
$this->_output="<?php /* source file: $sourceFile */ ?>\n";
for($i=0;$i<$n;++$i)
{
$match=&$matches[$i];
$str=$match[0][0];
$matchStart=$match[0][1];
$matchEnd=$matchStart+strlen($str)-1;
if($matchStart>$textStart)
$this->_output.=substr($this->_input,$textStart,$matchStart-$textStart);
$textStart=$matchEnd+1;
if(strpos($str,'<com:')===0) // opening component tag
{
$type=$match[3][0];
if($str[strlen($str)-2]!=='/') // open tag
$this->_output.=$this->processBeginWidget($type,$match[4][0],$match[2][1]);
else
$this->_output.=$this->processWidget($type,$match[4][0],$match[2][1]);
}
else if(strpos($str,'</com:')===0) // closing component tag
$this->_output.=$this->processEndWidget($match[3][0],$match[2][1]);
else if(strpos($str,'<cache:')===0) // opening cache tag
{
$id=$match[3][0];
if($str[strlen($str)-2]!=='/') // open tag
$this->_output.=$this->processBeginCache($id,$match[4][0],$match[2][1]);
else
$this->_output.=$this->processCache($id,$match[4][0],$match[2][1]);
}
else if(strpos($str,'</cache:')===0) // closing cache tag
$this->_output.=$this->processEndCache($match[3][0],$match[2][1]);
else if(strpos($str,'<clip:')===0) // opening clip tag
{
$id=$match[3][0];
if($str[strlen($str)-2]!=='/') // open tag
$this->_output.=$this->processBeginClip($id,$match[4][0],$match[2][1]);
else
$this->_output.=$this->processClip($id,$match[4][0],$match[2][1]);
}
else if(strpos($str,'</clip:')===0) // closing clip tag
$this->_output.=$this->processEndClip($match[3][0],$match[2][1]);
else if(strpos($str,'<%=')===0) // expression
$this->_output.=$this->processExpression($match[1][0],$match[1][1]);
else if(strpos($str,'<%')===0) // statement
$this->_output.=$this->processStatement($match[1][0],$match[1][1]);
}
if($textStart<strlen($this->_input))
$this->_output.=substr($this->_input,$textStart);
file_put_contents($viewFile,$this->_output);
}
瑙f瀽婧愯鍥炬枃浠讹紝淇濆瓨缁撴灉鍒板彟涓涓枃浠躲 杩欎釜鏂规硶鏄埗绫绘墍蹇呴』鐨勩