parseXmlAttr() public method

TagLib标签属性分析 返回标签属性数组
public parseXmlAttr ( $attr, $tag ) : array
return array
コード例 #1
0
ファイル: TagLibPin.class.php プロジェクト: dlpc/weixin_shop
 public function __call($method, $args)
 {
     $tag = substr($method, 1);
     if (!isset($this->tags[$tag])) {
         return false;
     }
     //解析标签属性
     $_tag = parent::parseXmlAttr($args[0], $tag);
     $_tag['cache'] = isset($_tag['cache']) ? intval($_tag['cache']) : 0;
     $_tag['return'] = isset($_tag['return']) ? trim($_tag['return']) : 'data';
     $_tag['type'] = isset($_tag['type']) ? trim($_tag['type']) : '';
     if (!$_tag['type']) {
         return false;
     }
     $parse_str = '<?php ';
     if ($_tag['cache']) {
         //标签名-属性-属性值 组合标识
         ksort($_tag);
         $tag_id = md5($tag . '&' . implode('&', array_keys($_tag)) . '&' . implode('&', array_values($_tag)));
         //缓存代码开始
         $parse_str .= '$' . $_tag['return'] . ' = S(\'' . $tag_id . '\');';
         $parse_str .= 'if (false === $' . $_tag['return'] . ') { ';
     }
     $action = $_tag['type'];
     $class = '$tag_' . $tag . '_class';
     $parse_str .= $class . ' = new ' . $tag . 'Tag;';
     $parse_str .= '$' . $_tag['return'] . ' = ' . $class . '->' . $action . '(' . self::arr_to_html($_tag) . ');';
     if ($_tag['cache']) {
         //缓存代码结束
         $parse_str .= 'S(\'' . $tag_id . '\', $' . $_tag['return'] . ', ' . $_tag['cache'] . ');';
         $parse_str .= ' }';
     }
     $parse_str .= '?>';
     $parse_str .= $args[1];
     return $parse_str;
 }