fix svgtopdf
[pear] / XML / SvgToPdfAlt / Tspan.php
1 <?php
2
3 /* the actual text container..
4
5 does a quick bit of parsing to see if it a {template}var ..
6 */ 
7
8 class XML_SvgToPDFAlt_Tspan extends XML_SvgToPDFAlt_Base { 
9
10     function fromNode($node) {
11         parent::fromNode($node);
12         if (isset($this->x)) {
13                unset($this->x); 
14         }
15         if (isset($this->y)) {
16                unset($this->y); 
17         }
18         static $trans = false;
19         if (!$trans) {
20             $trans = array_flip(get_html_translation_table(HTML_ENTITIES));
21         }
22         if (@$this->content) {
23             if (strpos($this->content,'&') !== false) {
24                 $this->content = strtr($this->content, $trans);
25                 $this->content = str_replace('&apos;',"'",$this->content);
26
27                 $this->content =  preg_replace_callback(
28                         '/&#(\d+);/m',
29                             function($m) {
30                             
31                                 return mb_chr($m[1]);
32                             }  ,$this->content);
33             }
34             if (@$node->language) {
35                 // todo - other conversions....
36
37                 //$this->content = mb_convert_encoding($this->content,'BIG-5','UTF-8');
38
39                 
40             }
41
42             if (false === strpos($this->content,'{')) {
43                 return;
44             }
45             preg_match_all('/\{([a-z0-9_.]+(\(\))?)\}/i',$this->content,$matches);
46 //echo "<PRE>";            print_r($matches);
47             //if (false !== strpos($this->content,'(')) {
48                 
49             //    echo "<PRE>";print_R($matches);
50             //    exit;
51             //}
52             
53             $this->args = $matches[1];
54             foreach($this->args as $v) {
55                 $this->content  = str_replace('{'.$v.'}', '%s',$this->content);
56             }
57             //$this->content = preg_replace('/\{('.implode('|',$matches[1]).')\}/','%s',$this->content);
58         }
59         
60     }
61             
62
63
64
65 }