The branch, master has been updated
via f6f133eb09532943976cd38d40d794a008bbccc5 (commit)
via 235e14d41ea6eafd0aa81ea726af5a64346eebb9 (commit)
via 0d7d007995ab59833b4132e8cee7e1093a07960b (commit)
via 17cbe2959294811d8fca81d575dbd20b0efe06d7 (commit)
from e9ea3b59a37239034b9690a16d86acb1d6166d57 (commit)
- Log -----------------------------------------------------------------
commit f6f133eb09532943976cd38d40d794a008bbccc5
Author: Michal Čihař <[email protected]>
Date: Wed Aug 10 14:33:03 2011 +0200
Avoid duplicating bookmark code from TCPDF, where it works
commit 235e14d41ea6eafd0aa81ea726af5a64346eebb9
Author: Michal Čihař <[email protected]>
Date: Wed Aug 10 14:29:36 2011 +0200
Indentaion
commit 0d7d007995ab59833b4132e8cee7e1093a07960b
Author: Michal Čihař <[email protected]>
Date: Wed Aug 10 14:29:22 2011 +0200
Unify code for PDF footer
commit 17cbe2959294811d8fca81d575dbd20b0efe06d7
Author: Michal Čihař <[email protected]>
Date: Wed Aug 10 14:24:22 2011 +0200
Start base class for all PDF output
-----------------------------------------------------------------------
Summary of changes:
libraries/PDF.class.php | 51 ++++++++
libraries/export/pdf.php | 36 +-----
libraries/schema/Pdf_Relation_Schema.class.php | 146 +++---------------------
3 files changed, 69 insertions(+), 164 deletions(-)
create mode 100644 libraries/PDF.class.php
diff --git a/libraries/PDF.class.php b/libraries/PDF.class.php
new file mode 100644
index 0000000..719df87
--- /dev/null
+++ b/libraries/PDF.class.php
@@ -0,0 +1,51 @@
+<?php
+/* vim: set expandtab sw=4 ts=4 sts=4: */
+/**
+ * TCPDF wrapper class.
+ */
+
+require_once './libraries/tcpdf/tcpdf.php';
+
+/**
+ * PDF font to use.
+ */
+define('PMA_PDF_FONT', 'DejaVuSans');
+
+/**
+ * PDF export base class providing basic configuration.
+ */
+class PMA_PDF extends TCPDF
+{
+ var $footerset;
+
+ public function __construct($orientation='P', $unit='mm', $format='A4',
$unicode=true, $encoding='UTF-8', $diskcache=false)
+ {
+ parent::__construct();
+ $this->SetAuthor('phpMyAdmin ' . PMA_VERSION);
+ $this->AliasNbPages();
+ $this->AddFont('DejaVuSans', '', 'dejavusans.php');
+ $this->AddFont('DejaVuSans', 'B', 'dejavusansb.php');
+ $this->AddFont('DejaVuSerif', '', 'dejavuserif.php');
+ $this->AddFont('DejaVuSerif', 'B', 'dejavuserifb.php');
+ $this->SetFont(PMA_PDF_FONT, '', 14);
+ $this->setFooterFont(array(PMA_PDF_FONT, '', 14));
+ }
+
+ /**
+ * This function must be named "Footer" to work with the TCPDF library
+ */
+ function Footer()
+ {
+ // Check if footer for this page already exists
+ if (!isset($this->footerset[$this->page])) {
+ $this->SetY(-15);
+ $this->SetFont(PMA_PDF_FONT, '', 14);
+ $this->Cell(0, 6, __('Page number:') . ' ' .
$this->getAliasNumPage() . '/' . $this->getAliasNbPages(), 'T', 0, 'C');
+ $this->Cell(0, 6, PMA_localisedDate(), 0, 1, 'R');
+ $this->SetY(20);
+
+ // set footerset
+ $this->footerset[$this->page] = 1;
+ }
+ }
+}
diff --git a/libraries/export/pdf.php b/libraries/export/pdf.php
index 3cc0acf..61c8dce 100644
--- a/libraries/export/pdf.php
+++ b/libraries/export/pdf.php
@@ -30,24 +30,17 @@ if (isset($plugin_list)) {
);
} else {
- /**
- * Font used in PDF.
- *
- * @todo Make this configuratble (at least Sans/Serif).
- */
- define('PMA_PDF_FONT', 'DejaVuSans');
- require_once './libraries/tcpdf/tcpdf.php';
+ require_once './libraries/PDF.class.php';
/**
* Adapted from a LGPL script by Philip Clarke
* @package phpMyAdmin-Export
* @subpackage PDF
*/
- class PMA_PDF extends TCPDF
+ class PMA_Export_PDF extends PMA_PDF
{
var $tablewidths;
var $headerset;
- var $footerset;
function checkPageBreak($h=0, $y='', $addpage=true) {
if ($this->empty_string($y)) {
@@ -125,20 +118,6 @@ if (isset($plugin_list)) {
$this->dataY = $maxY;
}
- function Footer()
- {
- // Check if footer for this page already exists
- if (!isset($this->footerset[$this->page])) {
- $this->SetY(-15);
- //Page number
- $this->setFooterFont(PMA_PDF_FONT, '', 14);
- $this->Cell(0, 6, __('Page number:') . ' ' .
$this->getAliasNumPage() . '/' . $this->getAliasNbPages(), 'T', 0, 'C');
-
- // set footerset
- $this->footerset[$this->page] = 1;
- }
- }
-
function morepagestable($lineheight=8)
{
// some things to set and 'remember'
@@ -354,9 +333,9 @@ if (isset($plugin_list)) {
} // end of mysql_report function
- } // end of PMA_PDF class
+ } // end of PMA_Export_PDF class
- $pdf = new PMA_PDF('L', 'pt', 'A3');
+ $pdf = new PMA_Export_PDF('L', 'pt', 'A3');
/**
* Finalize the pdf.
@@ -389,13 +368,6 @@ if (isset($plugin_list)) {
global $pdf_report_title;
global $pdf;
- $pdf->AddFont('DejaVuSans', '', 'dejavusans.php');
- $pdf->AddFont('DejaVuSans', 'B', 'dejavusansb.php');
- $pdf->AddFont('DejaVuSerif', '', 'dejavuserif.php');
- $pdf->AddFont('DejaVuSerif', 'B', 'dejavuserifb.php');
- $pdf->SetFont(PMA_PDF_FONT, '', 11.5);
- $pdf->setFooterFont(array(PMA_PDF_FONT, '', 11.5));
- $pdf->AliasNbPages();
$pdf->Open();
$attr=array('titleFontSize' => 18, 'titleText' => $pdf_report_title);
diff --git a/libraries/schema/Pdf_Relation_Schema.class.php
b/libraries/schema/Pdf_Relation_Schema.class.php
index a4d1260..f65fcc2 100644
--- a/libraries/schema/Pdf_Relation_Schema.class.php
+++ b/libraries/schema/Pdf_Relation_Schema.class.php
@@ -7,13 +7,7 @@
include_once("Export_Relation_Schema.class.php");
-/**
- * Font used in PDF.
- *
- * @todo Make this configuratble (at least Sans/Serif).
- */
-define('PMA_PDF_FONT', 'DejaVuSans');
-require_once './libraries/tcpdf/tcpdf.php';
+require_once './libraries/PDF.class.php';
/**
* Extends the "TCPDF" class and helps
@@ -22,7 +16,7 @@ require_once './libraries/tcpdf/tcpdf.php';
* @access public
* @see TCPDF
*/
-class PMA_PDF extends TCPDF
+class PMA_Schema_PDF extends PMA_PDF
{
/**
* Defines properties
@@ -242,112 +236,8 @@ class PMA_PDF extends TCPDF
{
global $with_doc;
if ($with_doc) {
- $this->SetY(-15);
- $this->SetFont($this->_ff, '', 14);
- $this->Cell(0, 6, __('Page number:') . ' ' .
$this->getAliasNumPage() . '/' . $this->getAliasNbPages(), 'T', 0, 'C');
- $this->Cell(0, 6, PMA_localisedDate(), 0, 1, 'R');
- $this->SetY(20);
- }
- }
-
- /**
- * 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();
+ parent::Footer();
}
- $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)
@@ -449,7 +339,7 @@ class PMA_PDF extends TCPDF
* and helps in drawing/generating the Tables in PDF document.
*
* @name Table_Stats
- * @see PMA_PDF
+ * @see PMA_Schema_PDF
*/
class Table_Stats
{
@@ -481,7 +371,7 @@ class Table_Stats
* @global object The current PDF document
* @global array The relations settings
* @global string The current db name
- * @see PMA_PDF, Table_Stats::Table_Stats_setWidth,
+ * @see PMA_Schema_PDF, Table_Stats::Table_Stats_setWidth,
Table_Stats::Table_Stats_setHeight
*/
function __construct($tableName, $fontSize, $pageNumber, &$sameWideWidth,
$showKeys = false, $showInfo = false)
@@ -565,7 +455,7 @@ class Table_Stats
* @param integer fontSize The font size
* @global object The current PDF document
* @access private
- * @see PMA_PDF
+ * @see PMA_Schema_PDF
*/
function _setWidth($fontSize)
{
@@ -603,7 +493,7 @@ class Table_Stats
* @param boolean setColor Whether to display color
* @global object The current PDF document
* @access public
- * @see PMA_PDF
+ * @see PMA_Schema_PDF
*/
public function tableDraw($fontSize, $withDoc, $setColor = 0)
{
@@ -661,7 +551,7 @@ class Table_Stats
* in PDF document.
*
* @name Relation_Stats
- * @see
PMA_PDF::SetDrawColor,PMA_PDF::PMA_PDF_setLineWidthScale,PMA_PDF::PMA_PDF_lineScale
+ * @see
PMA_Schema_PDF::SetDrawColor,PMA_Schema_PDF::PMA_PDF_setLineWidthScale,PMA_Schema_PDF::PMA_PDF_lineScale
*/
class Relation_Stats
{
@@ -751,7 +641,7 @@ class Relation_Stats
* @param integer i The id of the link to draw
* @global object The current PDF document
* @access public
- * @see PMA_PDF
+ * @see PMA_Schema_PDF
*/
public function relationDraw($changeColor, $i)
{
@@ -831,7 +721,7 @@ class PMA_Pdf_Relation_Schema extends
PMA_Export_Relation_Schema
* @global string The current db name
* @global array The relations settings
* @access private
- * @see PMA_PDF
+ * @see PMA_Schema_PDF
*/
function __construct()
{
@@ -849,18 +739,10 @@ class PMA_Pdf_Relation_Schema extends
PMA_Export_Relation_Schema
$this->setExportType($_POST['export_type']);
// Initializes a new document
- $pdf = new PMA_PDF($this->orientation, 'mm', $this->paper);
+ $pdf = new PMA_Schema_PDF($this->orientation, 'mm', $this->paper);
$pdf->SetTitle(sprintf(__('Schema of the %s database - Page %s'),
$GLOBALS['db'], $this->pageNumber));
$pdf->setCMargin(0);
$pdf->Open();
- $pdf->SetAuthor('phpMyAdmin ' . PMA_VERSION);
- $pdf->AliasNbPages();
- $pdf->AddFont('DejaVuSans', '', 'dejavusans.php');
- $pdf->AddFont('DejaVuSans', 'B', 'dejavusansb.php');
- $pdf->AddFont('DejaVuSerif', '', 'dejavuserif.php');
- $pdf->AddFont('DejaVuSerif', 'B', 'dejavuserifb.php');
- $pdf->SetFont($this->_ff, '', 14);
- $pdf->setFooterFont(array($this->_ff, '', 14));
$pdf->SetAutoPageBreak('auto');
$alltables = $this->getAllTables($db,$this->pageNumber);
@@ -978,9 +860,9 @@ class PMA_Pdf_Relation_Schema extends
PMA_Export_Relation_Schema
/**
* Draws the grid
*
- * @global object the current PMA_PDF instance
+ * @global object the current PMA_Schema_PDF instance
* @access private
- * @see PMA_PDF
+ * @see PMA_Schema_PDF
*/
private function _strokeGrid()
{
@@ -1057,7 +939,7 @@ class PMA_Pdf_Relation_Schema extends
PMA_Export_Relation_Schema
* @global integer The current page number (from the
* $cfg['Servers'][$i]['table_coords'] table)
* @access private
- * @see PMA_PDF
+ * @see PMA_Schema_PDF
*/
private function _showOutput($pageNumber)
{
hooks/post-receive
--
phpMyAdmin
------------------------------------------------------------------------------
uberSVN's rich system and user administration capabilities and model
configuration take the hassle out of deploying and managing Subversion and
the tools developers use with it. Learn more about uberSVN and get a free
download at: http://p.sf.net/sfu/wandisco-dev2dev
_______________________________________________
Phpmyadmin-git mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/phpmyadmin-git