Subversion Repositories PHPX

Compare Revisions

Last modification

Ignore whitespace Rev 79 → Rev 80

/trunk/footnotes.class.php
1,7 → 1,7
<?php
 
/**
* A footnote list contains {@link #Footnote Footnotes}
* A footnote list contains {@link Footnote Footnotes}
*
* @author Thomas 'PointedEars' Lahn &lt;php@PointedEars.de&gt;
*/
13,22 → 13,22
* @var Array
*/
protected $_footnotes;
 
/**
* Last used number sign for a footnote
*
* @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,23 → 86,23
{
$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
*/
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,33 → 114,33
{
return 1;
}
 
/* Sort footnotes either numerically or alphabetically */
/* TODO: Sort "1b" before "12a" */
if ($a->sign < $b->sign)
{
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 &lt;php@PointedEars.de&gt;
*/
164,21 → 164,21
* @var string
*/
protected $_name = '';
 
/**
* The sign used for referring to this footnote
*
* @var string
*/
protected $_sign = '';
 
/**
* The text for this footnote
*
* @var string
*/
protected $_text = '';
 
protected $_prefix = '';
protected $_suffix = '';
protected $_tooltip = '';
190,14 → 190,14
* @var boolean
*/
protected $_html4Compat = false;
 
/**
* The number of times this footnote has been referred
*
* @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,17 → 269,17
. '</a></sup>';
 
++$this->_references;
 
return $ret;
}
 
/**
* Prints this footnote in a footnote list
*/
public function printMe()
{
$s = $this->_name;
 
echo " <tr>
<th><sup><a" . ($this->_html4Compat ? " name='footnote-{$s}'" : "")
. " id='footnote-{$s}' class='footnote'