1
0
mirror of https://github.com/phpmyadmin/phpmyadmin.git synced 2026-10-31 10:54:46 +03:00

Avoid duplicating bookmark code from TCPDF, where it works

This commit is contained in:
Michal Čihař
2011-08-10 14:33:03 +02:00
parent 235e14d41e
commit f6f133eb09

View File

@@ -240,106 +240,6 @@ class PMA_Schema_PDF extends PMA_PDF
}
}
/**
* Add a bookmark
*/
function Bookmark($txt, $level = 0, $y = 0, $page = '')
{
$this->Outlines[0][] = $level;
$this->Outlines[1][] = $txt;
$this->Outlines[2][] = $this->page;
if ($y == -1) {
$y = $this->GetY();
}
$this->Outlines[3][] = round($this->hPt - $y * $this->k, 2);
}
function _putbookmarks()
{
if (count($this->Outlines) > 0) {
// Save object number
$memo_n = $this->n;
// Take the number of sub elements for an outline
$nb_outlines = sizeof($this->Outlines[0]);
$first_level = array();
$parent = array();
$parent[0] = 1;
for ($i = 0; $i < $nb_outlines; $i++) {
$level = $this->Outlines[0][$i];
$kids = 0;
$last = -1;
$prev = -1;
$next = -1;
if ($i > 0) {
$cursor = $i-1;
// Take the previous outline in the same level
while ($this->Outlines[0][$cursor] > $level && $cursor > 0)
$cursor--;
if ($this->Outlines[0][$cursor] == $level) {
$prev = $cursor;
}
}
if ($i < $nb_outlines-1) {
$cursor = $i + 1;
while (isset($this->Outlines[0][$cursor]) && $this->Outlines[0][$cursor] > $level) {
// Take the immediate kid in level + 1
if ($this->Outlines[0][$cursor] == $level + 1) {
$kids++;
$last = $cursor;
}
$cursor++;
}
$cursor = $i + 1;
// Take the next outline in the same level
while ($this->Outlines[0][$cursor] > $level && ($cursor + 1 < sizeof($this->Outlines[0])))
$cursor++;
if ($this->Outlines[0][$cursor] == $level) {
$next = $cursor;
}
}
$this->_newobj();
$parent[$level + 1] = $this->n;
if ($level == 0) {
$first_level[] = $this->n;
}
$this->_out('<<');
$this->_out('/Title (' . $this->Outlines[1][$i] . ')');
$this->_out('/Parent ' . $parent[$level] . ' 0 R');
if ($prev != -1) {
$this->_out('/Prev ' . ($memo_n + $prev + 1) . ' 0 R');
}
if ($next != -1) {
$this->_out('/Next ' . ($this->n + $next - $i) . ' 0 R');
}
$this->_out('/Dest [' . (1 + (2 * $this->Outlines[2][$i])) . ' 0 R /XYZ null ' . $this->Outlines[3][$i] . ' null]');
if ($kids > 0) {
$this->_out('/First ' . ($this->n + 1) . ' 0 R');
$this->_out('/Last ' . ($this->n + $last - $i) . ' 0 R');
$this->_out('/Count -' . $kids);
}
$this->_out('>>');
$this->_out('endobj');
}
// First page of outlines
$this->_newobj();
$this->def_outlines = $this->n;
$this->_out('<<');
$this->_out('/Type');
$this->_out('/Outlines');
$this->_out('/First ' . $first_level[0] . ' 0 R');
$this->_out('/Last ' . $first_level[sizeof($first_level)-1] . ' 0 R');
$this->_out('/Count ' . sizeof($first_level));
$this->_out('>>');
$this->_out('endobj');
}
}
function _putresources()
{
parent::_putresources();
$this->_putbookmarks();
}
function SetWidths($w)
{
// column widths