1<?php
2
3require_once(HTML2PS_DIR.'box.note-call.class.php');
4
5/**
6 * Support for CSS 3 position: footnote.
7 *
8 * Scans for elements having position: footnote and replaces them with
9 * BoxNoteCall object (which contains reference to original data and
10 * handles footnote rendering)
11 */
12class PreTreeFilterFootnotes extends PreTreeFilter {
13  function process(&$tree, $data, &$pipeline) {
14    if (is_a($tree, 'GenericContainerBox')) {
15      for ($i=0; $i<count($tree->content); $i++) {
16        /**
17         * No need to check this conition for text boxes, as they do not correspond to
18         * HTML elements
19         */
20        if (!is_a($tree->content[$i], 'TextBox')) {
21          if ($tree->content[$i]->get_css_property(CSS_POSITION) == POSITION_FOOTNOTE) {
22            $tree->content[$i]->setCSSProperty(CSS_POSITION, POSITION_STATIC);
23
24            $note_call =& BoxNoteCall::create($tree->content[$i], $pipeline);
25            $tree->content[$i] =& $note_call;
26
27            $pipeline->_addFootnote($note_call);
28          } else {
29            $this->process($tree->content[$i], $data, $pipeline);
30          };
31        };
32      };
33    };
34
35    return true;
36  }
37}
38?>