【php开源代码栏目提醒】:网学会员鉴于大家对php开源代码十分关注,论文会员在此为大家搜集整理了“TagLibCx.class.php”一文,供大家参考学习
<?php
// +----------------------------------------------------------------------
// | Think
PHP // +----------------------------------------------------------------------
// | Copyright (c) 2008 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
// $Id$
import('Think.Template.TagLib');
/**
+------------------------------------------------------------------------------
* CX鏍囩搴撹В鏋愮被
+------------------------------------------------------------------------------
* @category Think
* @package Think
* @subpackage Template
* @author liu21st <liu21st@gmail.com>
* @version $Id$
+------------------------------------------------------------------------------
*/
class TagLibCx extends TagLib
{//绫诲畾涔夊紑濮?
/**
+----------------------------------------------------------
* include鏍囩瑙f瀽
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
* @param string $attr 鏍囩灞炴?
* @param string $content 鏍囩鍐呭
+----------------------------------------------------------
* @return string
+----------------------------------------------------------
* @throws ThinkExecption
+----------------------------------------------------------
*/
public function _include($attr)
{
$tag = $this->parseXmlAttr($attr,'include');
$file = $tag['file'];
if(is_file($file)) {
$parseStr = file_get_contents($file);
return $this->tpl->parse($parseStr);
}else {
return $this->tpl->parseInclude($file);
}
}
/**
+----------------------------------------------------------
* comment鏍囩瑙f瀽
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
* @param string $attr 鏍囩灞炴?
+----------------------------------------------------------
* @return string
+----------------------------------------------------------
* @throws ThinkExecption
+----------------------------------------------------------
*/
public function _comment($attr)
{
return '';
}
/**
+----------------------------------------------------------
* php鏍囩瑙f瀽
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
* @param string $attr 鏍囩灞炴?
* @param string $content 鏍囩鍐呭
+----------------------------------------------------------
* @return string
+----------------------------------------------------------
* @throws ThinkExecption
+----------------------------------------------------------
*/
public function _php($attr,$content) {
$parseStr = '<?php '.$content.' ?>';
return $parseStr;
}
/**
+----------------------------------------------------------
* iterator鏍囩瑙f瀽 寰幆杈撳嚭iterator鍙橀噺鐨勫?
* 鏍煎紡锛?
* <iterate name="userList" id="user" empty="" >
* {user.username}
* {user.email}
* </iterate>
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
* @param string $attr 鏍囩灞炴?
* @param string $content 鏍囩鍐呭
+----------------------------------------------------------
* @return string|void
+----------------------------------------------------------
*/
public function _iterate($attr,$content)
{
static $_iterateParseCache = array();
//濡傛灉宸茬粡瑙f瀽杩囷紝鍒欑洿鎺ヨ繑鍥炲彉閲忓?
$cacheIterateId = md5($attr.$content);
if(isset($_iterateParseCache[$cacheIterateId]))
return $_iterateParseCache[$cacheIterateId];
$tag = $this->parseXmlAttr($attr,'iterate');
$name = $tag['name'];
$id = $tag['id'];
$empty = isset($tag['empty'])?$tag['empty']:'';
$offset = isset($tag['offset'])?$tag['offset']:0;
$length = isset($tag['length'])?$tag['length']:'';
$key = !