3 // vim: expandtab sw=4 ts=4 sts=4:
5 * Contributed by Maxime Delorme and merged by lem9
9 * Gets some core scripts
11 require_once('./libraries/common.lib.php');
14 * Settings for relation stuff
16 require_once('./libraries/relation.lib.php');
17 require_once('./libraries/transformations.lib.php');
19 $cfgRelation = PMA_getRelationsParam();
22 * Now in ./libraries/relation.lib.php we check for all tables
23 * that we need, but if we don't find them we are quiet about it
24 * so people can work without.
25 * This page is absolutely useless if you didn't set up your tables
26 * correctly, so it is a good place to see which tables we can and
29 if (!$cfgRelation['pdfwork']) {
30 echo '<font color="red">' . $strError . '</font><br />' . "\n";
31 $url_to_goto = '<a href="' . $cfg['PmaAbsoluteUri'] . 'chk_rel.php?' . $url_query . '">';
32 echo sprintf($strRelationNotWorking, $url_to_goto, '</a>') . "\n";
36 * Gets the "fpdf" libraries and defines the pdf font path, use unicode version for unicode.
38 define('FPDF_FONTPATH', './libraries/fpdf/font/');
39 if ($charset == 'utf-8') {
40 define('PMA_PDF_FONT', 'FreeSans');
41 require_once('./libraries/fpdf/ufpdf.php');
42 class PMA_FPDF
extends UFPDF
{
45 define('PMA_PDF_FONT', 'Arial');
46 require_once('./libraries/fpdf/fpdf.php');
47 class PMA_FPDF
extends FPDF
{
52 * Extends the "FPDF" class and prepares the work
57 class PMA_PDF
extends PMA_FPDF
{
59 * Defines private properties
68 var $Outlines = array();
74 * The PMA_PDF constructor
76 * This function just refers to the "FPDF" constructor: with PHP3 a class
77 * must have a constructor
79 * @param string $ The page orientation (p, portrait, l or landscape)
80 * @param string $ The unit for sizes (pt, mm, cm or in)
81 * @param mixed $ The page format (A3, A4, A5, letter, legal or an array
86 function PMA_PDF($orientation = 'L', $unit = 'mm', $format = 'A4')
88 $this->Alias
= array() ;
89 $this->FPDF($orientation, $unit, $format);
90 } // end of the "PMA_PDF()" method
91 function SetAlias($name, $value)
93 $this->Alias
[$name] = $value ;
97 if (count($this->Alias
) > 0) {
99 foreach ($this->Alias
AS $alias => $value) {
100 for ($n = 1;$n <= $nb;$n++
)
101 $this->pages
[$n] = $this->_strreplace($alias, $value, $this->pages
[$n]);
108 * Sets the scaling factor, defines minimum coordinates and margins
110 * @param double $ The scaling factor
111 * @param double $ The minimum X coordinate
112 * @param double $ The minimum Y coordinate
113 * @param double $ The left margin
114 * @param double $ The top margin
117 function PMA_PDF_setScale($scale = 1, $x_min = 0, $y_min = 0, $l_marg = -1, $t_marg = -1)
119 $this->scale
= $scale;
120 $this->x_min
= $x_min;
121 $this->y_min
= $y_min;
122 if ($this->l_marg
!= -1) {
123 $this->l_marg
= $l_marg;
125 if ($this->t_marg
!= -1) {
126 $this->t_marg
= $t_marg;
128 } // end of the "PMA_PDF_setScale" function
130 * Outputs a scaled cell
132 * @param double $ The cell width
133 * @param double $ The cell height
134 * @param string $ The text to output
135 * @param mixed $ Wether to add borders or not
136 * @param integer $ Where to put the cursor once the output is done
137 * @param string $ Align mode
138 * @param integer $ Whether to fill the cell with a color or not
142 function PMA_PDF_cellScale($w, $h = 0, $txt = '', $border = 0, $ln = 0, $align = '', $fill = 0, $link = '')
144 $h = $h / $this->scale
;
145 $w = $w / $this->scale
;
146 $this->Cell($w, $h, $txt, $border, $ln, $align, $fill, $link);
147 } // end of the "PMA_PDF_cellScale" function
149 * Draws a scaled line
151 * @param double $ The horizontal position of the starting point
152 * @param double $ The vertical position of the starting point
153 * @param double $ The horizontal position of the ending point
154 * @param double $ The vertical position of the ending point
158 function PMA_PDF_lineScale($x1, $y1, $x2, $y2)
160 $x1 = ($x1 - $this->x_min
) / $this->scale +
$this->l_marg
;
161 $y1 = ($y1 - $this->y_min
) / $this->scale +
$this->t_marg
;
162 $x2 = ($x2 - $this->x_min
) / $this->scale +
$this->l_marg
;
163 $y2 = ($y2 - $this->y_min
) / $this->scale +
$this->t_marg
;
164 $this->Line($x1, $y1, $x2, $y2);
165 } // end of the "PMA_PDF_lineScale" function
167 * Sets x and y scaled positions
169 * @param double $ The x position
170 * @param double $ The y position
174 function PMA_PDF_setXyScale($x, $y)
176 $x = ($x - $this->x_min
) / $this->scale +
$this->l_marg
;
177 $y = ($y - $this->y_min
) / $this->scale +
$this->t_marg
;
178 $this->SetXY($x, $y);
179 } // end of the "PMA_PDF_setXyScale" function
181 * Sets the X scaled positions
183 * @param double $ The x position
187 function PMA_PDF_setXScale($x)
189 $x = ($x - $this->x_min
) / $this->scale +
$this->l_marg
;
191 } // end of the "PMA_PDF_setXScale" function
193 * Sets the scaled font size
195 * @param double $ The font size (in points)
197 * @see FPDF::SetFontSize()
199 function PMA_PDF_setFontSizeScale($size)
201 // Set font size in points
202 $size = $size / $this->scale
;
203 $this->SetFontSize($size);
204 } // end of the "PMA_PDF_setFontSizeScale" function
206 * Sets the scaled line width
208 * @param double $ The line width
210 * @see FPDF::SetLineWidth()
212 function PMA_PDF_setLineWidthScale($width)
214 $width = $width / $this->scale
;
215 $this->SetLineWidth($width);
216 } // end of the "PMA_PDF_setLineWidthScale" function
218 * Displays an error message
220 * @param string $ the error mesage
221 * @global array the PMA configuration array
222 * @global integer the current server id
223 * @global string the current language
224 * @global string the charset to convert to
225 * @global string the current database name
226 * @global string the current charset
227 * @global string the current text direction
228 * @global string a localized string
229 * @global string an other localized string
232 function PMA_PDF_die($error_message = '')
235 global $server, $lang, $convcharset, $db;
236 global $charset, $text_dir, $strRunning, $strDatabase;
238 require_once('./libraries/header.inc.php');
240 echo '<p><b>PDF - ' . $GLOBALS['strError'] . '</b></p>' . "\n";
241 if (!empty($error_message)) {
242 $error_message = htmlspecialchars($error_message);
245 echo ' ' . $error_message . "\n";
248 echo '<a href="db_details_structure.php?' . PMA_generate_common_url($db)
249 . '">' . $GLOBALS['strBack'] . '</a>';
252 require_once('./libraries/footer.inc.php');
253 } // end of the "PMA_PDF_die()" function
255 * Aliases the "Error()" function from the FPDF class to the
256 * "PMA_PDF_die()" one
258 * @param string $ the error mesage
262 function Error($error_message = '')
264 $this->PMA_PDF_die($error_message);
265 } // end of the "Error()" method
269 // We only show this if we find something in the new pdf_pages table
271 // This function must be named "Header" to work with the FPDF library
272 global $cfgRelation, $db, $pdf_page_number, $with_doc;
274 $test_query = 'SELECT * FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['pdf_pages'])
275 . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
276 . ' AND page_nr = \'' . $pdf_page_number . '\'';
277 $test_rs = PMA_query_as_cu($test_query);
278 $pages = @PMA_DBI_fetch_assoc
($test_rs);
279 $this->SetFont('', 'B', 14);
280 $this->Cell(0, 6, ucfirst($pages['page_descr']), 'B', 1, 'C');
281 $this->SetFont('', '');
287 // This function must be named "Footer" to work with the FPDF library
291 $this->SetFont('', '', 14);
292 $this->Cell(0, 6, $GLOBALS['strPageNumber'] . ' ' . $this->PageNo() . '/{nb}', 'T', 0, 'C');
293 $this->Cell(0, 6, PMA_localisedDate(), 0, 1, 'R');
297 function Bookmark($txt, $level = 0, $y = 0)
300 $this->Outlines
[0][] = $level;
301 $this->Outlines
[1][] = $txt;
302 $this->Outlines
[2][] = $this->page
;
306 $this->Outlines
[3][] = round($this->hPt
- $y * $this->k
, 2);
309 function _putbookmarks()
311 if (count($this->Outlines
) > 0) {
312 // Save object number
314 // Take the number of sub elements for an outline
315 $nb_outlines = sizeof($this->Outlines
[0]);
316 $first_level = array();
319 for ($i = 0; $i < $nb_outlines; $i++
) {
320 $level = $this->Outlines
[0][$i];
327 // Take the previous outline in the same level
328 while ($this->Outlines
[0][$cursor] > $level && $cursor > 0)
330 if ($this->Outlines
[0][$cursor] == $level) {
334 if ($i < $nb_outlines-1) {
336 while (isset($this->Outlines
[0][$cursor]) && $this->Outlines
[0][$cursor] > $level) {
337 // Take the immediate kid in level + 1
338 if ($this->Outlines
[0][$cursor] == $level +
1) {
345 // Take the next outline in the same level
346 while ($this->Outlines
[0][$cursor] > $level && ($cursor +
1 < sizeof($this->Outlines
[0])))
348 if ($this->Outlines
[0][$cursor] == $level) {
353 $parent[$level +
1] = $this->n
;
355 $first_level[] = $this->n
;
358 $this->_out('/Title (' . $this->Outlines
[1][$i] . ')');
359 $this->_out('/Parent ' . $parent[$level] . ' 0 R');
361 $this->_out('/Prev ' . ($memo_n +
$prev +
1) . ' 0 R');
364 $this->_out('/Next ' . ($this->n +
$next - $i) . ' 0 R');
366 $this->_out('/Dest [' . (1 +
(2 * $this->Outlines
[2][$i])) . ' 0 R /XYZ null ' . $this->Outlines
[3][$i] . ' null]');
368 $this->_out('/First ' . ($this->n +
1) . ' 0 R');
369 $this->_out('/Last ' . ($this->n +
$last - $i) . ' 0 R');
370 $this->_out('/Count -' . $kids);
373 $this->_out('endobj');
375 // First page of outlines
377 $this->def_outlines
= $this->n
;
379 $this->_out('/Type');
380 $this->_out('/Outlines');
381 $this->_out('/First ' . $first_level[0] . ' 0 R');
382 $this->_out('/Last ' . $first_level[sizeof($first_level)-1] . ' 0 R');
383 $this->_out('/Count ' . sizeof($first_level));
385 $this->_out('endobj');
389 function _putresources()
391 parent
::_putresources();
392 $this->_putbookmarks();
395 function _putcatalog()
397 parent
::_putcatalog();
398 if (count($this->Outlines
) > 0) {
399 $this->_out('/Outlines ' . $this->def_outlines
. ' 0 R');
400 $this->_out('/PageMode /UseOutlines');
403 function SetWidths($w)
409 function Row($data, $links)
413 $data_cnt = count($data);
414 for ($i = 0;$i < $data_cnt;$i++
)
415 $nb = max($nb, $this->NbLines($this->widths
[$i], $data[$i]));
416 $il = $this->FontSize
;
417 $h = ($il +
1) * $nb;
418 // page break if necessary
419 $this->CheckPageBreak($h);
421 $data_cnt = count($data);
422 for ($i = 0;$i < $data_cnt;$i++
) {
423 $w = $this->widths
[$i];
424 // save current position
428 $this->Rect($x, $y, $w, $h);
429 if (isset($links[$i])) {
430 $this->Link($x, $y, $w, $h, $links[$i]);
433 $this->MultiCell($w, $il +
1, $data[$i], 0, 'L');
435 $this->SetXY($x +
$w, $y);
441 function CheckPageBreak($h)
443 // if height h overflows, manual page break
444 if ($this->GetY() +
$h > $this->PageBreakTrigger
) {
445 $this->AddPage($this->CurOrientation
);
449 function NbLines($w, $txt)
451 // compute number of lines used by a multicell of width w
452 $cw = &$this->CurrentFont
['cw'];
454 $w = $this->w
- $this->rMargin
- $this->x
;
456 $wmax = ($w-2 * $this->cMargin
) * 1000 / $this->FontSize
;
457 $s = str_replace("\r", '', $txt);
459 if ($nb > 0 and $s[$nb-1] == "\n") {
480 $l +
= isset($cw[ord($c)])?
$cw[ord($c)]:0 ;
499 } // end of the "PMA_PDF" class
501 * Draws tables schema
508 * Defines private properties
514 var $fields = array();
515 var $height_cell = 6;
517 var $primary = array();
520 * Sets the width of the table
522 * @param integer $ The font size
523 * @global object The current PDF document
527 function PMA_RT_Table_setWidth($ff)
529 // this looks buggy to me... does it really work if
530 // there are fields that require wider cells than the name of the table?
533 foreach ($this->fields
AS $field) {
534 $this->width
= max($this->width
, $pdf->GetStringWidth($field));
536 $this->width +
= $pdf->GetStringWidth(' ');
537 $pdf->SetFont($ff, 'B');
538 $this->width
= max($this->width
, $pdf->GetStringWidth(' ' . $this->table_name
));
539 $pdf->SetFont($ff, '');
540 } // end of the "PMA_RT_Table_setWidth()" method
542 * Sets the height of the table
546 function PMA_RT_Table_setHeight()
548 $this->height
= (count($this->fields
) +
1) * $this->height_cell
;
549 } // end of the "PMA_RT_Table_setHeight()" method
553 * @param boolean $ Whether to display table position or not
554 * @param integer $ The font size
555 * @param boolean $ Whether to display color
556 * @param integer $ The max. with among tables
557 * @global object The current PDF document
561 function PMA_RT_Table_draw($show_info, $ff, $setcolor = 0)
563 global $pdf, $with_doc;
565 $pdf->PMA_PDF_setXyScale($this->x
, $this->y
);
566 $pdf->SetFont($ff, 'B');
568 $pdf->SetTextColor(200);
569 $pdf->SetFillColor(0, 0, 128);
572 $pdf->SetLink($pdf->PMA_links
['RT'][$this->table_name
]['-'], -1);
574 $pdf->PMA_links
['doc'][$this->table_name
]['-'] = '';
578 $pdf->PMA_PDF_cellScale($this->width
, $this->height_cell
, sprintf('%.0f', $this->width
) . 'x' . sprintf('%.0f', $this->height
) . ' ' . $this->table_name
, 1, 1, 'C', $setcolor, $pdf->PMA_links
['doc'][$this->table_name
]['-']);
580 $pdf->PMA_PDF_cellScale($this->width
, $this->height_cell
, $this->table_name
, 1, 1, 'C', $setcolor, $pdf->PMA_links
['doc'][$this->table_name
]['-']);
582 $pdf->PMA_PDF_setXScale($this->x
);
583 $pdf->SetFont($ff, '');
584 $pdf->SetTextColor(0);
585 $pdf->SetFillColor(255);
587 foreach ($this->fields
AS $field) {
589 // if (in_array($field, $this->primary)) {
591 if (in_array($field, $this->primary
)) {
592 $pdf->SetFillColor(215, 121, 123);
594 if ($field == $this->displayfield
) {
595 $pdf->SetFillColor(142, 159, 224);
599 $pdf->SetLink($pdf->PMA_links
['RT'][$this->table_name
][$field], -1);
601 $pdf->PMA_links
['doc'][$this->table_name
][$field] = '';
604 $pdf->PMA_PDF_cellScale($this->width
, $this->height_cell
, ' ' . $field, 1, 1, 'L', $setcolor, $pdf->PMA_links
['doc'][$this->table_name
][$field]);
605 $pdf->PMA_PDF_setXScale($this->x
);
606 $pdf->SetFillColor(255);
608 /*if ($pdf->PageNo() > 1) {
609 $pdf->PMA_PDF_die($GLOBALS['strScaleFactorSmall']);
611 } // end of the "PMA_RT_Table_draw()" method
613 * The "PMA_RT_Table" constructor
615 * @param string $ The table name
616 * @param integer $ The font size
617 * @param integer $ The max. with among tables
618 * @global object The current PDF document
619 * @global integer The current page number (from the
620 * $cfg['Servers'][$i]['table_coords'] table)
621 * @global array The relations settings
622 * @global string The current db name
624 * @see PMA_PDF, PMA_RT_Table::PMA_RT_Table_setWidth,
625 PMA_RT_Table::PMA_RT_Table_setHeight
627 function PMA_RT_Table($table_name, $ff, &$same_wide_width)
629 global $pdf, $pdf_page_number, $cfgRelation, $db;
631 $this->table_name
= $table_name;
632 $sql = 'DESCRIBE ' . PMA_backquote($table_name);
633 $result = PMA_DBI_try_query($sql, null, PMA_DBI_QUERY_STORE
);
634 if (!$result ||
!PMA_DBI_num_rows($result)) {
635 $pdf->PMA_PDF_die(sprintf($GLOBALS['strPdfInvalidTblName'], $table_name));
638 while ($row = PMA_DBI_fetch_row($result)) {
639 $this->fields
[] = $row[0];
642 $this->PMA_RT_Table_setWidth($ff);
643 $this->PMA_RT_Table_setHeight();
644 if ($same_wide_width < $this->width
) {
645 $same_wide_width = $this->width
;
648 $sql = 'SELECT x, y FROM '
649 . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords'])
650 . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
651 . ' AND table_name = \'' . PMA_sqlAddslashes($table_name) . '\''
652 . ' AND pdf_page_number = ' . $pdf_page_number;
653 $result = PMA_query_as_cu($sql, false, PMA_DBI_QUERY_STORE
);
655 if (!$result ||
!PMA_DBI_num_rows($result)) {
656 $pdf->PMA_PDF_die(sprintf($GLOBALS['strConfigureTableCoord'], $table_name));
658 list($this->x
, $this->y
) = PMA_DBI_fetch_row($result);
659 $this->x
= (double) $this->x
;
660 $this->y
= (double) $this->y
;
662 $this->displayfield
= PMA_getDisplayField($db, $table_name);
664 $result = PMA_DBI_query('SHOW INDEX FROM ' . PMA_backquote($table_name) . ';', null, PMA_DBI_QUERY_STORE
);
665 if (PMA_DBI_num_rows($result) > 0) {
666 while ($row = PMA_DBI_fetch_assoc($result)) {
667 if ($row['Key_name'] == 'PRIMARY') {
668 $this->primary
[] = $row['Column_name'];
672 } // end of the "PMA_RT_Table()" method
673 } // end class "PMA_RT_Table"
675 * Draws relation links
680 class PMA_RT_Relation
{
682 * Defines private properties
687 var $x_dest, $y_dest;
691 * Gets arrows coordinates
693 * @param string $ The current table name
694 * @param string $ The relation column name
695 * @return array Arrows coordinates
698 function PMA_RT_Relation_getXy($table, $column)
700 $pos = array_search($column, $table->fields
);
701 // x_left, x_right, y
702 return array($table->x
, $table->x + +
$table->width
, $table->y +
($pos +
1.5) * $table->height_cell
);
703 } // end of the "PMA_RT_Relation_getXy()" method
705 * Do draws relation links
707 * @param boolean $ Whether to use one color per relation or not
708 * @param integer $ The id of the link to draw
709 * @global object The current PDF document
713 function PMA_RT_Relation_draw($change_color, $i)
730 list ($a, $b, $c) = $case[$d];
731 $e = (1 - ($j - 1) / 6);
732 $pdf->SetDrawColor($a * 255 * $e, $b * 255 * $e, $c * 255 * $e);
734 $pdf->SetDrawColor(0);
735 } // end if... else...
736 $pdf->PMA_PDF_setLineWidthScale(0.2);
737 $pdf->PMA_PDF_lineScale($this->x_src
, $this->y_src
, $this->x_src +
$this->src_dir
* $this->w_tick
, $this->y_src
);
738 $pdf->PMA_PDF_lineScale($this->x_dest +
$this->dest_dir
* $this->w_tick
, $this->y_dest
, $this->x_dest
, $this->y_dest
);
739 $pdf->PMA_PDF_setLineWidthScale(0.1);
740 $pdf->PMA_PDF_lineScale($this->x_src +
$this->src_dir
* $this->w_tick
, $this->y_src
, $this->x_dest +
$this->dest_dir
* $this->w_tick
, $this->y_dest
);
742 $root2 = 2 * sqrt(2);
743 $pdf->PMA_PDF_lineScale($this->x_src +
$this->src_dir
* $this->w_tick
* 0.75, $this->y_src
, $this->x_src +
$this->src_dir
* (0.75 - 1 / $root2) * $this->w_tick
, $this->y_src +
$this->w_tick
/ $root2);
744 $pdf->PMA_PDF_lineScale($this->x_src +
$this->src_dir
* $this->w_tick
* 0.75, $this->y_src
, $this->x_src +
$this->src_dir
* (0.75 - 1 / $root2) * $this->w_tick
, $this->y_src
- $this->w_tick
/ $root2);
746 $pdf->PMA_PDF_lineScale($this->x_dest +
$this->dest_dir
* $this->w_tick
/ 2, $this->y_dest
, $this->x_dest +
$this->dest_dir
* (0.5 +
1 / $root2) * $this->w_tick
, $this->y_dest +
$this->w_tick
/ $root2);
747 $pdf->PMA_PDF_lineScale($this->x_dest +
$this->dest_dir
* $this->w_tick
/ 2, $this->y_dest
, $this->x_dest +
$this->dest_dir
* (0.5 +
1 / $root2) * $this->w_tick
, $this->y_dest
- $this->w_tick
/ $root2);
748 $pdf->SetDrawColor(0);
749 } // end of the "PMA_RT_Relation_draw()" method
751 * The "PMA_RT_Relation" constructor
753 * @param string $ The master table name
754 * @param string $ The relation field in the master table
755 * @param string $ The foreign table name
756 * @param string $ The relation field in the foreign table
758 * @see PMA_RT_Relation::PMA_RT_Relation_getXy
760 function PMA_RT_Relation($master_table, $master_field, $foreign_table, $foreign_field)
762 $src_pos = $this->PMA_RT_Relation_getXy($master_table, $master_field);
763 $dest_pos = $this->PMA_RT_Relation_getXy($foreign_table, $foreign_field);
764 $src_left = $src_pos[0] - $this->w_tick
;
765 $src_right = $src_pos[1] +
$this->w_tick
;
766 $dest_left = $dest_pos[0] - $this->w_tick
;
767 $dest_right = $dest_pos[1] +
$this->w_tick
;
769 $d1 = abs($src_left - $dest_left);
770 $d2 = abs($src_right - $dest_left);
771 $d3 = abs($src_left - $dest_right);
772 $d4 = abs($src_right - $dest_right);
773 $d = min($d1, $d2, $d3, $d4);
776 $this->x_src
= $src_pos[0];
778 $this->x_dest
= $dest_pos[0];
779 $this->dest_dir
= -1;
780 } elseif ($d == $d2) {
781 $this->x_src
= $src_pos[1];
783 $this->x_dest
= $dest_pos[0];
784 $this->dest_dir
= -1;
785 } elseif ($d == $d3) {
786 $this->x_src
= $src_pos[0];
788 $this->x_dest
= $dest_pos[1];
791 $this->x_src
= $src_pos[1];
793 $this->x_dest
= $dest_pos[1];
796 $this->y_src
= $src_pos[2];
797 $this->y_dest
= $dest_pos[2];
798 } // end of the "PMA_RT_Relation()" method
799 } // end of the "PMA_RT_Relation" class
801 * Draws and send the database schema
808 * Defines private properties
810 var $tables = array();
811 var $relations = array();
812 var $ff = PMA_PDF_FONT
;
826 * Sets X and Y minimum and maximum for a table cell
828 * @param string $ The table name
831 function PMA_RT_setMinMax($table)
833 $this->x_max
= max($this->x_max
, $table->x +
$table->width
);
834 $this->y_max
= max($this->y_max
, $table->y +
$table->height
);
835 $this->x_min
= min($this->x_min
, $table->x
);
836 $this->y_min
= min($this->y_min
, $table->y
);
837 } // end of the "PMA_RT_setMinMax()" method
839 * Defines relation objects
841 * @param string $ The master table name
842 * @param string $ The relation field in the master table
843 * @param string $ The foreign table name
844 * @param string $ The relation field in the foreign table
846 * @see PMA_RT_setMinMax
848 function PMA_RT_addRelation($master_table, $master_field, $foreign_table, $foreign_field)
850 if (!isset($this->tables
[$master_table])) {
851 $this->tables
[$master_table] = new PMA_RT_Table($master_table, $this->ff
, $this->tablewidth
);
852 $this->PMA_RT_setMinMax($this->tables
[$master_table]);
854 if (!isset($this->tables
[$foreign_table])) {
855 $this->tables
[$foreign_table] = new PMA_RT_Table($foreign_table, $this->ff
, $this->tablewidth
);
856 $this->PMA_RT_setMinMax($this->tables
[$foreign_table]);
858 $this->relations
[] = new PMA_RT_Relation($this->tables
[$master_table], $master_field, $this->tables
[$foreign_table], $foreign_field);
859 } // end of the "PMA_RT_addRelation()" method
863 * @global object the current PMA_PDF instance
867 function PMA_RT_strokeGrid()
871 $pdf->SetMargins(0, 0);
872 $pdf->SetDrawColor(200, 200, 200);
873 // Draws horizontal lines
874 for ($l = 0; $l < 21; $l++
) {
875 $pdf->line(0, $l * 10, $pdf->fh
, $l * 10);
878 $pdf->SetXY(0, $l * 10);
879 $label = (string) sprintf('%.0f', ($l * 10 - $this->t_marg
) * $this->scale +
$this->y_min
);
880 $pdf->Cell(5, 5, ' ' . $label);
883 // Draws vertical lines
884 for ($j = 0; $j < 30 ;$j++
) {
885 $pdf->line($j * 10, 0, $j * 10, $pdf->fw
);
886 $pdf->SetXY($j * 10, 0);
887 $label = (string) sprintf('%.0f', ($j * 10 - $this->l_marg
) * $this->scale +
$this->x_min
);
888 $pdf->Cell(5, 7, $label);
890 } // end of the "PMA_RT_strokeGrid()" method
892 * Draws relation arrows
894 * @param boolean $ Whether to use one color per relation or not
896 * @see PMA_RT_Relation::PMA_RT_Relation_draw()
898 function PMA_RT_drawRelations($change_color)
901 foreach ($this->relations
AS $relation) {
902 $relation->PMA_RT_Relation_draw($change_color, $i);
905 } // end of the "PMA_RT_drawRelations()" method
909 * @param boolean $ Whether to display table position or not
911 * @see PMA_RT_Table::PMA_RT_Table_draw()
913 function PMA_RT_drawTables($show_info, $draw_color = 0)
915 foreach ($this->tables
AS $table) {
916 $table->PMA_RT_Table_draw($show_info, $this->ff
, $draw_color);
918 } // end of the "PMA_RT_drawTables()" method
920 * Ouputs the PDF document to a file
922 * @global object The current PDF document
923 * @global string The current database name
924 * @global integer The current page number (from the
925 * $cfg['Servers'][$i]['table_coords'] table)
929 function PMA_RT_showRt()
931 global $pdf, $db, $pdf_page_number, $cfgRelation;
933 $pdf->SetFontSize(14);
934 $pdf->SetLineWidth(0.2);
935 $pdf->SetDisplayMode('fullpage');
936 // Get the name of this pdfpage to use as filename (Mike Beck)
937 $_name_sql = 'SELECT page_descr FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['pdf_pages'])
938 . ' WHERE page_nr = ' . $pdf_page_number;
939 $_name_rs = PMA_query_as_cu($_name_sql);
941 $_name_row = PMA_DBI_fetch_row($_name_rs);
942 $filename = $_name_row[0] . '.pdf';
944 // i don't know if there is a chance for this to happen, but rather be on the safe side:
945 if (empty($filename)) {
946 $filename = $pdf_page_number . '.pdf';
948 // $pdf->Output($db . '_' . $filename, TRUE);
949 $pdf->Output($db . '_' . $filename, 'I'); // destination: Inline
950 } // end of the "PMA_RT_showRt()" method
952 * The "PMA_RT" constructor
954 * @param mixed $ The scaling factor
955 * @param integer $ The page number to draw (from the
956 * $cfg['Servers'][$i]['table_coords'] table)
957 * @param boolean $ Whether to display table position or not
958 * @param boolean $ Was originally whether to use one color per
959 * relation or not, now enables/disables color
960 * everywhere, due to some problems printing with color
961 * @param boolean $ Whether to draw grids or not
962 * @param boolean $ Whether all tables should have the same width or not
963 * @global object The current PDF document
964 * @global string The current db name
965 * @global array The relations settings
969 function PMA_RT($which_rel, $show_info = 0, $change_color = 0, $show_grid = 0, $all_tab_same_wide = 0, $orientation = 'L', $paper = 'A4')
971 global $pdf, $db, $cfgRelation, $with_doc;
973 $this->same_wide
= $all_tab_same_wide;
974 // Initializes a new document
975 $pdf = new PMA_PDF('L', 'mm', $paper);
976 $pdf->title
= sprintf($GLOBALS['strPdfDbSchema'], $GLOBALS['db'], $which_rel);
979 $pdf->SetTitle($pdf->title
);
980 $pdf->SetAuthor('phpMyAdmin ' . PMA_VERSION
);
981 $pdf->AliasNbPages();
983 if ($GLOBALS['charset'] == 'utf-8') {
984 // Force FreeSans for utf-8
985 $this->ff
= 'FreeSans';
986 $pdf->AddFont('FreeSans', '', 'FreeSans.php');
987 $pdf->AddFont('FreeSans', 'B', 'FreeSansBold.php');
988 } elseif ($GLOBALS['charset'] == 'iso-8859-2') {
989 // fonts added to phpMyAdmin and considered non-standard by fpdf
990 // (Note: those tahoma fonts are iso-8859-2 based)
991 $this->ff
== 'tahoma';
992 $pdf->AddFont('tahoma', '', 'tahoma.php');
993 $pdf->AddFont('tahoma', 'B', 'tahomab.php');
995 $this->ff
== 'helvetica';
997 $pdf->SetFont($this->ff
, '', 14);
998 $pdf->SetAutoPageBreak('auto');
999 // Gets tables on this page
1000 $tab_sql = 'SELECT table_name FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords'])
1001 . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
1002 . ' AND pdf_page_number = ' . $which_rel;
1003 $tab_rs = PMA_query_as_cu($tab_sql, null, PMA_DBI_QUERY_STORE
);
1004 if (!$tab_rs ||
!PMA_DBI_num_rows($tab_rs) > 0) {
1005 $pdf->PMA_PDF_die($GLOBALS['strPdfNoTables']);
1006 // die('No tables');
1007 } while ($curr_table = @PMA_DBI_fetch_assoc
($tab_rs)) {
1008 $alltables[] = PMA_sqlAddslashes($curr_table['table_name']);
1009 // $intable = '\'' . implode('\', \'', $alltables) . '\'';
1013 $pdf->SetAutoPageBreak('auto', 15);
1015 PMA_RT_DOC($alltables);
1016 $pdf->SetAutoPageBreak('auto');
1023 $pdf->SetLink($pdf->PMA_links
['RT']['-'], -1);
1024 $pdf->Bookmark($GLOBALS['strRelationalSchema']);
1025 $pdf->SetAlias('{00}', $pdf->PageNo()) ;
1032 foreach ($alltables AS $table) {
1033 if (!isset($this->tables
[$table])) {
1034 $this->tables
[$table] = new PMA_RT_Table($table, $this->ff
, $this->tablewidth
);
1037 if ($this->same_wide
) {
1038 $this->tables
[$table]->width
= $this->tablewidth
;
1040 $this->PMA_RT_setMinMax($this->tables
[$table]);
1042 // Defines the scale factor
1043 $this->scale
= ceil(max(($this->x_max
- $this->x_min
) / ($pdf->fh
- $this->r_marg
- $this->l_marg
), ($this->y_max
- $this->y_min
) / ($pdf->fw
- $this->t_marg
- $this->b_marg
)) * 100) / 100;
1044 $pdf->PMA_PDF_setScale($this->scale
, $this->x_min
, $this->y_min
, $this->l_marg
, $this->t_marg
);
1045 // Builds and save the PDF document
1046 $pdf->PMA_PDF_setLineWidthScale(0.1);
1049 $pdf->SetFontSize(10);
1050 $this->PMA_RT_strokeGrid();
1052 $pdf->PMA_PDF_setFontSizeScale(14);
1053 // $sql = 'SELECT * FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['relation'])
1054 // . ' WHERE master_db = \'' . PMA_sqlAddslashes($db) . '\' '
1055 // . ' AND foreign_db = \'' . PMA_sqlAddslashes($db) . '\' '
1056 // . ' AND master_table IN (' . $intable . ')'
1057 // . ' AND foreign_table IN (' . $intable . ')';
1058 // $result = PMA_query_as_cu($sql);
1061 // previous logic was checking master tables and foreign tables
1062 // but I think that looping on every table of the pdf page as a master
1063 // and finding its foreigns is OK (then we can support innodb)
1064 $seen_a_relation = false;
1065 foreach ($alltables AS $one_table) {
1066 $exist_rel = PMA_getForeigners($db, $one_table, '', 'both');
1068 $seen_a_relation = true;
1069 foreach ($exist_rel AS $master_field => $rel) {
1070 // put the foreign table on the schema only if selected
1072 // (do not use array_search() because we would have to
1073 // to do a === FALSE and this is not PHP3 compatible)
1074 if (in_array($rel['foreign_table'], $alltables)) {
1075 $this->PMA_RT_addRelation($one_table, $master_field, $rel['foreign_table'], $rel['foreign_field']);
1080 // loic1: also show tables without relations
1081 // $norelations = TRUE;
1082 // if ($result && PMA_DBI_num_rows($result) > 0) {
1083 // $norelations = FALSE;
1084 // while ($row = PMA_DBI_fetch_assoc($result)) {
1085 // $this->PMA_RT_addRelation($row['master_table'], $row['master_field'], $row['foreign_table'], $row['foreign_field']);
1088 // if ($norelations == FALSE) {
1089 if ($seen_a_relation) {
1090 $this->PMA_RT_drawRelations($change_color);
1093 $this->PMA_RT_drawTables($show_info, $change_color);
1095 $this->PMA_RT_showRt();
1096 } // end of the "PMA_RT()" method
1097 } // end of the "PMA_RT" class
1099 function PMA_RT_DOC($alltables)
1101 global $db, $pdf, $orientation, $paper;
1103 $pdf->addpage($GLOBALS['orientation']);
1104 $pdf->Cell(0, 9, $GLOBALS['strTableOfContents'], 1, 0, 'C');
1107 foreach ($alltables AS $table) {
1108 $pdf->PMA_links
['doc'][$table]['-'] = $pdf->AddLink();
1111 $pdf->Cell(0, 6, $GLOBALS['strPageNumber'] . ' {' . sprintf("%02d", $i) . '}', 0, 0, 'R', 0, $pdf->PMA_links
['doc'][$table]['-']);
1113 $pdf->Cell(0, 6, $i . ' ' . $table, 0, 1, 'L', 0, $pdf->PMA_links
['doc'][$table]['-']);
1115 $result = PMA_DBI_query('SHOW FIELDS FROM ' . PMA_backquote($table) . ';');
1116 while ($row = PMA_DBI_fetch_assoc($result)) {
1118 $field_name = $row['Field'];
1119 $pdf->PMA_links
['doc'][$table][$field_name] = $pdf->AddLink();
1120 // $pdf->Cell(0, 6, $field_name,0,1,'L',0, $pdf->PMA_links['doc'][$table][$field_name]);
1122 $lasttable = $table;
1125 $pdf->PMA_links
['RT']['-'] = $pdf->AddLink();
1127 $pdf->Cell(0, 6, $GLOBALS['strPageNumber'] . ' {00}', 0, 0, 'R', 0, $pdf->PMA_links
['doc'][$lasttable]['-']);
1129 $pdf->Cell(0, 6, $i . ' ' . $GLOBALS['strRelationalSchema'], 0, 1, 'L', 0, $pdf->PMA_links
['RT']['-']);
1131 foreach ($alltables AS $table) {
1133 $pdf->addpage($GLOBALS['orientation']);
1134 $pdf->Bookmark($table);
1135 $pdf->SetAlias('{' . sprintf("%02d", $z) . '}', $pdf->PageNo()) ;
1136 $pdf->PMA_links
['RT'][$table]['-'] = $pdf->AddLink();
1137 $pdf->SetLink($pdf->PMA_links
['doc'][$table]['-'], -1);
1138 $pdf->SetFont('', 'B', 18);
1139 $pdf->Cell(0, 8, $z . ' ' . $table, 1, 1, 'C', 0, $pdf->PMA_links
['RT'][$table]['-']);
1140 $pdf->SetFont('', '', 8);
1143 $cfgRelation = PMA_getRelationsParam();
1144 if ($cfgRelation['commwork'] || PMA_MYSQL_INT_VERSION
>= 40100) {
1145 $comments = PMA_getComments($db, $table);
1147 if ($cfgRelation['mimework']) {
1148 $mime_map = PMA_getMIME($db, $table, true);
1152 * Gets table informations
1154 $result = PMA_DBI_query('SHOW TABLE STATUS LIKE \'' . PMA_sqlAddslashes($table, true) . '\';', null, PMA_DBI_QUERY_STORE
);
1155 $showtable = PMA_DBI_fetch_assoc($result);
1156 $num_rows = (isset($showtable['Rows']) ?
$showtable['Rows'] : 0);
1157 $show_comment = (isset($showtable['Comment']) ?
$showtable['Comment'] : '');
1158 $create_time = (isset($showtable['Create_time']) ?
PMA_localisedDate(strtotime($showtable['Create_time'])) : '');
1159 $update_time = (isset($showtable['Update_time']) ?
PMA_localisedDate(strtotime($showtable['Update_time'])) : '');
1160 $check_time = (isset($showtable['Check_time']) ?
PMA_localisedDate(strtotime($showtable['Check_time'])) : '');
1162 PMA_DBI_free_result($result);
1166 * Gets table keys and retains them
1168 $result = PMA_DBI_query('SHOW KEYS FROM ' . PMA_backquote($table) . ';');
1172 $indexes_info = array();
1173 $indexes_data = array();
1174 $pk_array = array(); // will be use to emphasis prim. keys in the table
1176 while ($row = PMA_DBI_fetch_assoc($result)) {
1177 // Backups the list of primary keys
1178 if ($row['Key_name'] == 'PRIMARY') {
1179 $primary .= $row['Column_name'] . ', ';
1180 $pk_array[$row['Column_name']] = 1;
1182 // Retains keys informations
1183 if ($row['Key_name'] != $lastIndex) {
1184 $indexes[] = $row['Key_name'];
1185 $lastIndex = $row['Key_name'];
1187 $indexes_info[$row['Key_name']]['Sequences'][] = $row['Seq_in_index'];
1188 $indexes_info[$row['Key_name']]['Non_unique'] = $row['Non_unique'];
1189 if (isset($row['Cardinality'])) {
1190 $indexes_info[$row['Key_name']]['Cardinality'] = $row['Cardinality'];
1192 // I don't know what does following column mean....
1193 // $indexes_info[$row['Key_name']]['Packed'] = $row['Packed'];
1194 $indexes_info[$row['Key_name']]['Comment'] = $row['Comment'];
1196 $indexes_data[$row['Key_name']][$row['Seq_in_index']]['Column_name'] = $row['Column_name'];
1197 if (isset($row['Sub_part'])) {
1198 $indexes_data[$row['Key_name']][$row['Seq_in_index']]['Sub_part'] = $row['Sub_part'];
1202 PMA_DBI_free_result($result);
1206 * Gets fields properties
1208 $result = PMA_DBI_query('SHOW FIELDS FROM ' . PMA_backquote($table) . ';', null, PMA_DBI_QUERY_STORE
);
1209 $fields_cnt = PMA_DBI_num_rows($result);
1210 // Check if we can use Relations (Mike Beck)
1211 if (!empty($cfgRelation['relation'])) {
1212 // Find which tables are related with the current one and write it in
1214 $res_rel = PMA_getForeigners($db, $table);
1216 if (count($res_rel) > 0) {
1225 * Displays the comments of the table if MySQL >= 3.23
1229 if (!empty($show_comment)) {
1230 $pdf->Cell(0, 3, $GLOBALS['strTableComments'] . ' : ' . $show_comment, 0, 1);
1234 if (!empty($create_time)) {
1235 $pdf->Cell(0, 3, $GLOBALS['strStatCreateTime'] . ': ' . $create_time, 0, 1);
1239 if (!empty($update_time)) {
1240 $pdf->Cell(0, 3, $GLOBALS['strStatUpdateTime'] . ': ' . $update_time, 0, 1);
1244 if (!empty($check_time)) {
1245 $pdf->Cell(0, 3, $GLOBALS['strStatCheckTime'] . ': ' . $check_time, 0, 1);
1249 if ($break == true) {
1250 $pdf->Cell(0, 3, '', 0, 1);
1255 $pdf->SetFont('', 'B');
1256 if (isset($orientation) && $orientation == 'L') {
1257 $pdf->Cell(25, 8, ucfirst($GLOBALS['strField']), 1, 0, 'C');
1258 $pdf->Cell(20, 8, ucfirst($GLOBALS['strType']), 1, 0, 'C');
1259 $pdf->Cell(20, 8, ucfirst($GLOBALS['strAttr']), 1, 0, 'C');
1260 $pdf->Cell(10, 8, ucfirst($GLOBALS['strNull']), 1, 0, 'C');
1261 $pdf->Cell(20, 8, ucfirst($GLOBALS['strDefault']), 1, 0, 'C');
1262 $pdf->Cell(25, 8, ucfirst($GLOBALS['strExtra']), 1, 0, 'C');
1263 $pdf->Cell(45, 8, ucfirst($GLOBALS['strLinksTo']), 1, 0, 'C');
1265 if ($paper == 'A4') {
1266 $comments_width = 67;
1268 // this is really intended for 'letter'
1269 // TODO: find optimal width for all formats
1270 $comments_width = 50;
1272 $pdf->Cell($comments_width, 8, ucfirst($GLOBALS['strComments']), 1, 0, 'C');
1273 $pdf->Cell(45, 8, 'MIME', 1, 1, 'C');
1274 $pdf->SetWidths(array(25, 20, 20, 10, 20, 25, 45, $comments_width, 45));
1276 $pdf->Cell(20, 8, ucfirst($GLOBALS['strField']), 1, 0, 'C');
1277 $pdf->Cell(20, 8, ucfirst($GLOBALS['strType']), 1, 0, 'C');
1278 $pdf->Cell(20, 8, ucfirst($GLOBALS['strAttr']), 1, 0, 'C');
1279 $pdf->Cell(10, 8, ucfirst($GLOBALS['strNull']), 1, 0, 'C');
1280 $pdf->Cell(15, 8, ucfirst($GLOBALS['strDefault']), 1, 0, 'C');
1281 $pdf->Cell(15, 8, ucfirst($GLOBALS['strExtra']), 1, 0, 'C');
1282 $pdf->Cell(30, 8, ucfirst($GLOBALS['strLinksTo']), 1, 0, 'C');
1283 $pdf->Cell(30, 8, ucfirst($GLOBALS['strComments']), 1, 0, 'C');
1284 $pdf->Cell(30, 8, 'MIME', 1, 1, 'C');
1285 $pdf->SetWidths(array(20, 20, 20, 10, 15, 15, 30, 30, 30));
1287 $pdf->SetFont('', '');
1289 while ($row = PMA_DBI_fetch_assoc($result)) {
1290 $bgcolor = ($i %
2) ?
$GLOBALS['cfg']['BgcolorOne'] : $GLOBALS['cfg']['BgcolorTwo'];
1293 $type = $row['Type'];
1294 // reformat mysql query output - staybyte - 9. June 2001
1295 // loic1: set or enum types: slashes single quotes inside options
1296 if (preg_match('@^(set|enum)\((.+)\)$@i', $type, $tmp)) {
1297 $tmp[2] = substr(preg_replace("@([^,])''@", "\\1\\'", ',' . $tmp[2]), 1);
1298 $type = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')';
1305 $type_nowrap = ' nowrap="nowrap"';
1306 $type = preg_replace('@BINARY@i', '', $type);
1307 $type = preg_replace('@ZEROFILL@i', '', $type);
1308 $type = preg_replace('@UNSIGNED@i', '', $type);
1313 $binary = stristr($row['Type'], 'BINARY');
1314 $unsigned = stristr($row['Type'], 'UNSIGNED');
1315 $zerofill = stristr($row['Type'], 'ZEROFILL');
1317 $strAttribute = ' ';
1319 $strAttribute = 'BINARY';
1322 $strAttribute = 'UNSIGNED';
1325 $strAttribute = 'UNSIGNED ZEROFILL';
1327 if (!isset($row['Default'])) {
1328 if ($row['Null'] != '' && $row['Null'] != 'NO') {
1329 $row['Default'] = 'NULL';
1332 $field_name = $row['Field'];
1334 $pdf->PMA_links
['RT'][$table][$field_name] = $pdf->AddLink();
1335 $pdf->Bookmark($field_name, 1, -1);
1336 $pdf->SetLink($pdf->PMA_links
['doc'][$table][$field_name], -1);
1337 $pdf_row = array($field_name,
1340 ($row['Null'] == '' ||
$row['Null'] == 'NO') ?
$GLOBALS['strNo'] : $GLOBALS['strYes'],
1341 ((isset($row['Default'])) ?
$row['Default'] : ''),
1343 ((isset($res_rel[$field_name])) ?
$res_rel[$field_name]['foreign_table'] . ' -> ' . $res_rel[$field_name]['foreign_field'] : ''),
1344 ((isset($comments[$field_name])) ?
$comments[$field_name] : ''),
1345 ((isset($mime_map) && isset($mime_map[$field_name])) ?
str_replace('_', '/', $mime_map[$field_name]['mimetype']) : '')
1347 $links[0] = $pdf->PMA_links
['RT'][$table][$field_name];
1348 if (isset($res_rel[$field_name]['foreign_table']) AND
1349 isset($res_rel[$field_name]['foreign_field']) AND
1350 isset($pdf->PMA_links
['doc'][$res_rel[$field_name]['foreign_table']][$res_rel[$field_name]['foreign_field']])
1353 $links[6] = $pdf->PMA_links
['doc'][$res_rel[$field_name]['foreign_table']][$res_rel[$field_name]['foreign_field']];
1357 $pdf->Row($pdf_row, $links);
1359 /*$pdf->Cell(20, 8, $field_name, 1, 0, 'L', 0, $pdf->PMA_links['RT'][$table][$field_name]);
1360 //echo ' ' . $field_name . ' ' . "\n";
1362 $pdf->Cell(20, 8, $type, 1, 0, 'L');
1363 $pdf->Cell(20, 8, $strAttribute, 1, 0, 'L');
1364 $pdf->Cell(15, 8, , 1, 0, 'L');
1365 $pdf->Cell(15, 8, ((isset($row['Default'])) ? $row['Default'] : ''),1,0,'L');
1366 $pdf->Cell(15, 8, $row['Extra'], 1, 0, 'L');
1368 if (isset($res_rel[$field_name])) {
1369 $pdf->Cell(30, 8, $res_rel[$field_name]['foreign_table'] . ' -> ' . $res_rel[$field_name]['foreign_field'],1,0,'L');
1372 if ($cfgRelation['commwork']) {
1373 if (isset($comments[$field_name])) {
1374 $pdf->Cell(0, 8, $comments[$field_name], 1, 0, 'L');
1378 $pdf->SetFont('', '', 14);
1379 PMA_DBI_free_result($result);
1381 } // end function PMA_RT_DOC
1386 if (!isset($pdf_page_number)) {
1387 $pdf_page_number = 1;
1390 $show_grid = (isset($show_grid) && $show_grid == 'on') ?
1 : 0;
1391 $show_color = (isset($show_color) && $show_color == 'on') ?
1 : 0;
1392 $show_table_dimension = (isset($show_table_dimension) && $show_table_dimension == 'on') ?
1 : 0;
1393 $all_tab_same_wide = (isset($all_tab_same_wide) && $all_tab_same_wide == 'on') ?
1 : 0;
1394 $with_doc = (isset($with_doc) && $with_doc == 'on') ?
1 : 0;
1395 $orientation = (isset($orientation) && $orientation == 'P') ?
'P' : 'L';
1396 $paper = isset($paper) ?
$paper : 'A4';
1397 PMA_DBI_select_db($db);
1399 $rt = new PMA_RT($pdf_page_number, $show_table_dimension, $show_color, $show_grid, $all_tab_same_wide, $orientation, $paper);