| 1,7 → 1,7 |
| <?php |
| |
| /** |
| * A footnote list contains {@link #Footnote Footnotes} |
| * A footnote list contains {@link Footnote Footnotes} |
| * |
| * @author Thomas 'PointedEars' Lahn <php@PointedEars.de> |
| */ |
| 13,7 → 13,7 |
| * @var Array |
| */ |
| protected $_footnotes; |
| |
| |
| /** |
| * Last used number sign for a footnote |
| * |
| 20,15 → 20,15 |
| * @var int |
| */ |
| protected $_lastNumberSign; |
| |
| |
| protected $_defaultPrefix; |
| protected $_defaultSuffix; |
| |
| |
| protected $_makeTooltip; |
| |
| /* (non-PHPdoc) @see Footnote::_html4Compat */ |
| protected $_html4Compat; |
| |
| |
| public function __construct($defaultPrefix = '', $defaultSuffix = '', $makeTooltip = false, $html4Compatible = false) |
| { |
| $this->clear(); |
| 37,7 → 37,7 |
| $this->_makeTooltip = $makeTooltip; |
| $this->_html4Compat = $html4Compatible; |
| } |
| |
| |
| public function __get($name) |
| { |
| if (property_exists($this, "_$name")) |
| 48,7 → 48,7 |
| throw new InvalidArgumentException( |
| 'No such property ' . get_class($this) . "::\$$name"); |
| } |
| |
| |
| /** |
| * Clears the footnote list |
| */ |
| 57,7 → 57,7 |
| $this->_footnotes = array(); |
| $this->_lastNumberSign = 0; |
| } |
| |
| |
| /** |
| * Adds a footnote to the list (unless already specified) |
| * |
| 75,7 → 75,7 |
| public function add($name, $sign = '', $text = '', $tooltip = null) |
| { |
| $footnotes =& $this->_footnotes; |
| |
| |
| if (!isset($footnotes[$name])) |
| { |
| if (!$sign) |
| 86,16 → 86,16 |
| { |
| $this->_lastNumberSign = $sign; |
| } |
| |
| |
| $footnotes[$name] = new Footnote($name, $sign, $text, |
| $this->_defaultSuffix, $this->_defaultPrefix, |
| $this->_makeTooltip ? ($tooltip !== null ? $tooltip : $text) : '', |
| $this->_html4Compat); |
| } |
| |
| |
| return $footnotes[$name]->getRef(); |
| } |
| |
| |
| /** |
| * Prints the list of footnotes |
| */ |
| 102,7 → 102,7 |
| public function printMe() |
| { |
| $footnotes =& $this->_footnotes; |
| |
| |
| uasort($footnotes, function ($a, $b) { |
| /* Sort numbered footnotes first */ |
| if (is_int($a->sign) && !is_int($b->sign)) |
| 114,7 → 114,7 |
| { |
| return 1; |
| } |
| |
| |
| /* Sort footnotes either numerically or alphabetically */ |
| /* TODO: Sort "1b" before "12a" */ |
| if ($a->sign < $b->sign) |
| 121,26 → 121,26 |
| { |
| return -1; |
| } |
| |
| |
| if ($a->sign > $b->sign) |
| { |
| return 1; |
| } |
| |
| |
| return 0; |
| }); |
| |
| |
| ?><table class="footnotes"> |
| <?php |
| |
| |
| foreach ($footnotes as $name => &$footnote) |
| { |
| $footnote->printMe(); |
| } |
| |
| |
| ?></table><?php |
| } |
| |
| |
| /** |
| * Prints the list of footnotes and clears the list in memory |
| */ |
| 152,7 → 152,7 |
| } |
| |
| /** |
| * A footnote to be used in a {@link #FootnoteList "footnote list"} |
| * A footnote to be used in a {@link FootnoteList "footnote list"} |
| * |
| * @author Thomas 'PointedEars' Lahn <php@PointedEars.de> |
| */ |
| 164,7 → 164,7 |
| * @var string |
| */ |
| protected $_name = ''; |
| |
| |
| /** |
| * The sign used for referring to this footnote |
| * |
| 171,7 → 171,7 |
| * @var string |
| */ |
| protected $_sign = ''; |
| |
| |
| /** |
| * The text for this footnote |
| * |
| 178,7 → 178,7 |
| * @var string |
| */ |
| protected $_text = ''; |
| |
| |
| protected $_prefix = ''; |
| protected $_suffix = ''; |
| protected $_tooltip = ''; |
| 190,7 → 190,7 |
| * @var boolean |
| */ |
| protected $_html4Compat = false; |
| |
| |
| /** |
| * The number of times this footnote has been referred |
| * |
| 197,7 → 197,7 |
| * @var int |
| */ |
| protected $_references = 0; |
| |
| |
| /** |
| * Creates a footnote |
| * |
| 244,7 → 244,7 |
| throw new InvalidArgumentException( |
| 'No such property ' . get_class($this) . "::\$$name"); |
| } |
| |
| |
| /** |
| * Returns the reference for this footnote |
| * |
| 269,10 → 269,10 |
| . '</a></sup>'; |
| |
| ++$this->_references; |
| |
| |
| return $ret; |
| } |
| |
| |
| /** |
| * Prints this footnote in a footnote list |
| */ |
| 279,7 → 279,7 |
| public function printMe() |
| { |
| $s = $this->_name; |
| |
| |
| echo " <tr> |
| <th><sup><a" . ($this->_html4Compat ? " name='footnote-{$s}'" : "") |
| . " id='footnote-{$s}' class='footnote' |