4e217fb5a0b1f0ebc5ac3d2b57577c971e406a98
[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) { return chr($m[1]); }  ,$this->content);
30             }
31             if (@$node->language) {
32                 // todo - other conversions....
33
34                 $this->content = mb_convert_encoding($this->content,'BIG-5','UTF-8');
35
36                 
37             }
38
39             if (false === strpos($this->content,'{')) {
40                 return;
41             }
42             preg_match_all('/\{([a-z0-9_.]+(\(\))?)\}/i',$this->content,$matches);
43 //echo "<PRE>";            print_r($matches);
44             //if (false !== strpos($this->content,'(')) {
45                 
46             //    echo "<PRE>";print_R($matches);
47             //    exit;
48             //}
49             
50             $this->args = $matches[1];
51             foreach($this->args as $v) {
52                 $this->content  = str_replace('{'.$v.'}', '%s',$this->content);
53             }
54             //$this->content = preg_replace('/\{('.implode('|',$matches[1]).')\}/','%s',$this->content);
55         }
56         
57     }
58             
59
60
61
62 }