3 /* code that deals with svg groups
4 it does alot of smart stuff to handle 'dynamic' blocks
9 class XML_SvgToPDFAlt_G extends XML_SvgToPDFAlt_Base {
11 function fromNode($node) {
12 parent::fromNode($node);
14 if (!@$this->children) {
23 foreach(array_keys($this->children) as $k) {
24 if (!is_a($this->children[$k], 'XML_SvgToPDF_Text')) {
28 if (!isset($this->children[$k]->children[0]->content) ||
29 (strpos($this->children[$k]->children[0]->content,'=') === false)) {
34 foreach($this->children[$k]->children as $o) {
35 list($l,$r) = explode('=',$o->content);
40 unset($this->children[$k]);
51 //look for the bounding box..
53 foreach(array_keys($this->children) as $k) {
54 if (!is_a($this->children[$k], 'XML_SvgToPDF_Rect')) {
57 if (@$this->children[$k]->nonprintable == 'true') {
58 $boundingbox = clone($this->children[$k]);
59 $this->children[$k]->style['fill'] = 'none';
60 // unset($this->children[$k]);
67 $this->boundingbox = $boundingbox;
68 $this->settings = $settings;
69 $this->shiftChildren($this->boundingbox->x,$this->boundingbox->y);
72 function shift($x,$y) {
74 if ($this->boundingbox) {
78 $this->shiftChildren($x,$y);
84 function writePDF($pdf,$data) {
85 // g group = does it have a
87 if (!@$this->children) {
92 if (empty($this->settings)) {
93 return $this->childrenWritePDF($pdf,$data);
96 if (substr($this->settings['dynamic'],-2,2) == '()') {
98 $use = $data->{substr($this->settings['dynamic'],0,-2)}();
101 $use = @$data[$this->settings['dynamic']];
105 if ($use === false) {
109 if (!is_array($use) || !$use) {
110 return $this->childrenWritePDF($pdf,$data);
116 $this->x = $x = $this->boundingbox->x;
117 $this->y =$y = $this->boundingbox->y;
118 $w = $this->boundingbox->width;
119 $h = $this->boundingbox->height;
122 //echo '<PRE>';print_r($this);exit;
123 // shift... ** this does not handle groups!!!
126 $keys = array_keys($use);
128 $kmax = count($keys);
129 //XML_SvgToPDF::debug(array($x,$y,$w,$h));
130 //XML_SvgToPDF::debug($keys);
131 XML_SvgToPDF::debug($this->settings);
132 for($r=0;$r<$this->settings['rows'];$r++) {
134 for($c=0;$c<$this->settings['cols'];$c++) {
136 XML_SvgToPDF::debug(array($xx,$yy));
137 foreach(array_keys($this->children) as $k) {
138 if (!$this->children[$k]) {
141 $this->children[$k]->xx = $xx;
142 $this->children[$k]->yy = $yy;
143 $this->children[$k]->maxWidth = $w - 20;
144 $this->children[$k]->writePDF($pdf,$use[$keys[$kpos]]);
147 if ($kpos >= $kmax) {