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