fpdf fixes
[pear] / XML / SvgToPdf / 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_SvgToPDF_Tspan extends XML_SvgToPDF_Base { 
9
10     var $content = ''; // applies to tspan only..
11     var $x = false;
12     var $y = false;
13     var $args = array(); // arguments..
14     var $role;
15     
16     function fromXmlNode($node) {
17         parent::fromXmlNode($node);
18         $this->x = false;
19         $this->y = false;
20         $this->content = $node->textContent;
21         /*
22         if (isset($this->x)) {
23                unset($this->x); 
24         }
25         if (isset($this->y)) {
26                unset($this->y); 
27         }
28         */
29         static $trans = false;
30         if (!$trans) {
31             $trans = array_flip(get_html_translation_table(HTML_ENTITIES));
32         }
33         
34         if (strlen($this->content)) {
35             // convert &amp; etc. 
36             if (strpos($this->content,'&') !== false) {
37                 $this->content = strtr($this->content, $trans);
38                 $this->content = str_replace('&apos;',"'",$this->content);
39
40                 $this->content =  preg_replace_callback('/&#(\d+);/m', array($this, 'content_replace'),
41                                     $this->content);
42             }
43             if (!empty($node->language)) {
44                 // todo - other conversions....
45                 $this->content = mb_convert_encoding($this->content,'BIG-5','UTF-8');
46
47             }
48             // dynamic parts..
49             if (false === strpos($this->content,'{')) {
50                 return;
51             }
52             preg_match_all('/\{([a-z0-9_.]+(\(\))?)\}/i',$this->content,$matches);
53  
54             $this->args = $matches[1];
55             foreach($this->args as $v) {
56                 $this->content  = str_replace('{'.$v.'}', '%s',$this->content);
57             }
58             //$this->content = preg_replace('/\{('.implode('|',$matches[1]).')\}/','%s',$this->content);
59         }
60         
61     
62     }
63     
64     function content_replace($matches) { // php5.2 needs this to be a function... 
65             return chr($matches[1]);
66     }
67     
68     
69     function shift($x,$y) // disable shifting on text
70     {
71         return;
72     }
73     function transform() 
74     {
75         
76     }
77    
78
79
80
81 }