Subversion Repositories PHPX

Compare Revisions

Last modification

Ignore whitespace Rev 12 → Rev 13

/trunk/footnotes.class.php
21,9 → 21,17
*/
protected $lastNumberSign;
public function __construct()
protected $defaultPrefix;
protected $defaultSuffix;
protected $makeTooltip;
public function __construct($defaultPrefix = '', $defaultSuffix = '', $makeTooltip = false)
{
$this->clear();
$this->defaultPrefix = $defaultPrefix;
$this->defaultSuffix = $defaultSuffix;
$this->makeTooltip = $makeTooltip;
}
/**
47,7 → 55,7
* @return string
* The code for printing the footnote reference.
*/
public function add($name, $sign = '', $text = '')
public function add($name, $sign = '', $text = '', $tooltip = null)
{
$footnotes =& $this->footnotes;
62,7 → 70,9
$this->lastNumberSign = $sign;
}
$footnotes[$name] = new Footnote($name, $sign, $text);
$footnotes[$name] = new Footnote($name, $sign, $text,
$this->defaultSuffix, $this->defaultPrefix,
$this->makeTooltip ? ($tooltip !== null ? $tooltip : $text) : '');
}
return $footnotes[$name]->getRef();
142,6 → 152,10
*/
protected $text = '';
protected $prefix = '';
protected $suffix = '';
protected $tooltip = '';
/**
* The number of times this footnote has been referred
*
158,12 → 172,20
* The sign that should be used for referring to this footnote
* @param string $text
* The text for this footnote
* @param string $suffix
* The suffix for this footnote
* @param string $prefix
* The prefix for this footnote
*/
public function __construct($name, $sign, $text)
public function __construct($name, $sign, $text, $suffix = '', $prefix = '',
$tooltip = '')
{
$this->name = $name;
$this->sign = $sign;
$this->text = $text;
$this->suffix = $suffix;
$this->prefix = $prefix;
$this->tooltip = $tooltip;
}
 
/**
202,7 → 224,15
. ($this->references === 0
? " name='fn-{$s}-ref' id='fn-{$s}-ref'"
: '')
. " class='footnote'>{$this->sign}</a></sup>";
. " class='footnote'"
. ($this->tooltip
? ' title="'
. preg_replace('/"/', '&quot;',
trim(reduceWhitespace(strip_tags($this->tooltip))))
. '"'
: '')
. "'>{$this->prefix}{$this->sign}{$this->suffix}"
. '</a></sup>';
 
++$this->references;
218,8 → 248,9
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'>&#8593;</a></th>
>{$this->sign}</a></sup><a
href='#fn-{$s}-ref' name='footnote-{$s}' id='footnote-{$s}'
class='backref'>&#8593;</a></th>
<td>{$this->text}</td>
</tr>
";