58,10 → 58,10 |
$sign = ++$this->lastNumberSign; |
} |
|
$footnotes[$name] = new Footnote($sign, $text); |
$footnotes[$name] = new Footnote($name, $sign, $text); |
} |
|
return $footnotes[$name]->printRef(); |
return $footnotes[$name]->getRef(); |
} |
|
/** |
71,11 → 71,33 |
{ |
$footnotes =& $this->footnotes; |
|
function cmp($a, $b) |
{ |
if ($a->sign < $b->sign) |
{ |
return -1; |
} |
else if ($a->sign > $b->sign) |
{ |
return 1; |
} |
else |
{ |
return 0; |
} |
} |
|
uasort($footnotes, 'cmp'); |
|
?><table class="footnotes"> |
<?php |
|
foreach ($footnotes as $name => &$footnote) |
{ |
/* TODO */ |
$footnote->printMe(); |
} |
|
?></table><?php |
} |
|
/** |
96,6 → 118,13 |
class Footnote |
{ |
/** |
* The name of this footnote |
* |
* @var string |
*/ |
protected $name = ''; |
|
/** |
* The sign used for referring to this footnote |
* |
* @var string |
110,27 → 139,69 |
protected $text = ''; |
|
/** |
* The number of times this footnote has been referred |
* |
* @var int |
*/ |
protected $references = 0; |
|
/** |
* Creates a footnote |
* |
* @param string $name |
* The name of this footnote |
* @param string $sign |
* The sign that should be used for referring to this footnote |
* @param string $text |
* The text for this footnote |
*/ |
public function __construct($sign, $text) |
public function __construct($name, $sign, $text) |
{ |
$this->name = $name; |
$this->sign = $sign; |
$this->text = $text; |
} |
|
/** |
* Universal getter |
* |
* @param string $name |
* Name of the property to be read-accessed. Currently only 'sign' |
* is supported. |
* @throws Exception if a non-existing property is accessed |
* @return mixed |
* Property value |
*/ |
public function __get($name) |
{ |
if ($name === 'sign') |
{ |
return $this->sign; |
} |
else |
{ |
throw new Exception('No such property ' . get_class($this) . "::\$$name"); |
} |
} |
|
/** |
* Returns the reference for this footnote |
* |
* @return string |
*/ |
public function printRef() |
public function getRef() |
{ |
return "<sup>$sign</sup>"; |
$s = $this->name; |
|
$ret = "<sup><a href='#footnote-{$s}'" |
. ($this->references === 0 |
? " name='fn-{$s}-ref' id='fn-{$s}-ref'" |
: '') |
. " class='footnote'>{$this->sign}</a></sup>"; |
|
++$this->references; |
|
return $ret; |
} |
|
/** |
138,7 → 209,15 |
*/ |
public function printMe() |
{ |
/* TODO */ |
$s = $this->name; |
|
echo " <tr> |
<th><sup><a name='footnote-{$s}' id='footnote-{$s}' class='footnote' |
>{$this->sign}</a></sup><a href='#fn-{$s}-ref' name='footnote-{$s}' |
id='footnote-{$s}' class='backref'>↑</a></th> |
<td>{$this->text}</td> |
</tr> |
"; |
} |
} |
|