coding standards and PDF error handling
This commit is contained in:
@@ -24,6 +24,7 @@ $Source$
|
|||||||
* fpdf/*: removed ^M.
|
* fpdf/*: removed ^M.
|
||||||
* fpdf/fpdf.php3, lines 1205+: ensure user agent is detected whatever are
|
* fpdf/fpdf.php3, lines 1205+: ensure user agent is detected whatever are
|
||||||
the PHP version and the "register globals" value.
|
the PHP version and the "register globals" value.
|
||||||
|
* pdf_schema.php3; lang/*: coding standards and PDF error handling.
|
||||||
|
|
||||||
2002-05-17 Robin Johnson <robbat2@users.sourceforge.net>
|
2002-05-17 Robin Johnson <robbat2@users.sourceforge.net>
|
||||||
* config.inc.php3, libraries/common.lib.php3: IP-based Allow/Deny code
|
* config.inc.php3, libraries/common.lib.php3: IP-based Allow/Deny code
|
||||||
|
@@ -231,6 +231,8 @@ $strPartialText = 'Partial Texts';
|
|||||||
$strPassword = 'Password';
|
$strPassword = 'Password';
|
||||||
$strPasswordEmpty = 'The password is empty!';
|
$strPasswordEmpty = 'The password is empty!';
|
||||||
$strPasswordNotSame = 'The passwords aren\'t the same!';
|
$strPasswordNotSame = 'The passwords aren\'t the same!';
|
||||||
|
$strPdfInvalidPageNum = 'Undefined PDF page number!';
|
||||||
|
$strPdfInvalidTblName = 'The "%s" table doesn\'t exist!';
|
||||||
$strPHPVersion = 'PHP Version';
|
$strPHPVersion = 'PHP Version';
|
||||||
$strPmaDocumentation = 'phpMyAdmin documentation';
|
$strPmaDocumentation = 'phpMyAdmin documentation';
|
||||||
$strPmaUriError = 'The <tt>$cfg[\'PmaAbsoluteUri\']</tt> directive MUST be set in your configuration file!';
|
$strPmaUriError = 'The <tt>$cfg[\'PmaAbsoluteUri\']</tt> directive MUST be set in your configuration file!';
|
||||||
|
@@ -231,6 +231,8 @@ $strPartialText = 'Textes r
|
|||||||
$strPassword = 'Mot de passe';
|
$strPassword = 'Mot de passe';
|
||||||
$strPasswordEmpty = 'Le mot de passe est vide';
|
$strPasswordEmpty = 'Le mot de passe est vide';
|
||||||
$strPasswordNotSame = 'Les mots de passe doivent <20>tre identiques';
|
$strPasswordNotSame = 'Les mots de passe doivent <20>tre identiques';
|
||||||
|
$strPdfInvalidPageNum = 'Num<75>ro de page PDF non d<>fini !';
|
||||||
|
$strPdfInvalidTblName = 'La table "%s" n\'existe pas !';
|
||||||
$strPHPVersion = 'Version de PHP';
|
$strPHPVersion = 'Version de PHP';
|
||||||
$strPmaDocumentation = 'Documentation de phpMyAdmin';
|
$strPmaDocumentation = 'Documentation de phpMyAdmin';
|
||||||
$strPmaUriError = 'Le param<61>tre <tt>$cfg[\'PmaAbsoluteUri\']</tt> DOIT <20>tre renseign<67> dans votre fichier de configuration !';
|
$strPmaUriError = 'Le param<61>tre <tt>$cfg[\'PmaAbsoluteUri\']</tt> DOIT <20>tre renseign<67> dans votre fichier de configuration !';
|
||||||
|
219
pdf_schema.php3
219
pdf_schema.php3
@@ -23,14 +23,16 @@ define('FPDF_FONTPATH', './fpdf/font/');
|
|||||||
/**
|
/**
|
||||||
* Extends the "fpdf" class and prepares the work
|
* Extends the "fpdf" class and prepares the work
|
||||||
*/
|
*/
|
||||||
class PDF extends FPDF {
|
class PMA_PDF extends FPDF
|
||||||
|
{
|
||||||
var $x_min;
|
var $x_min;
|
||||||
var $y_min;
|
var $y_min;
|
||||||
var $l_marg;
|
var $l_marg;
|
||||||
var $t_marg;
|
var $t_marg;
|
||||||
var $scale;
|
var $scale;
|
||||||
|
|
||||||
function SetScale($scale = 1, $x_min = 0, $y_min = 0, $l_marg, $t_marg) {
|
function PMA_PDF_setScale($scale = 1, $x_min = 0, $y_min = 0, $l_marg, $t_marg)
|
||||||
|
{
|
||||||
$this->scale = $scale;
|
$this->scale = $scale;
|
||||||
$this->x_min = $x_min;
|
$this->x_min = $x_min;
|
||||||
$this->y_min = $y_min;
|
$this->y_min = $y_min;
|
||||||
@@ -38,13 +40,15 @@ class PDF extends FPDF {
|
|||||||
$this->t_marg = $t_marg;
|
$this->t_marg = $t_marg;
|
||||||
}
|
}
|
||||||
|
|
||||||
function cell_scale($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=0) {
|
function PMA_PDF_cellScale($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=0)
|
||||||
|
{
|
||||||
$h = $h/$this->scale;
|
$h = $h/$this->scale;
|
||||||
$w = $w/$this->scale;
|
$w = $w/$this->scale;
|
||||||
$this->Cell($w, $h, $txt, $border, $ln, $align, $fill);
|
$this->Cell($w, $h, $txt, $border, $ln, $align, $fill);
|
||||||
}
|
}
|
||||||
|
|
||||||
function Line_scale($x1, $y1, $x2, $y2) {
|
function PMA_PDF_lineScale($x1, $y1, $x2, $y2)
|
||||||
|
{
|
||||||
$x1 = ($x1 - $this->x_min) / $this->scale + $this->l_marg;
|
$x1 = ($x1 - $this->x_min) / $this->scale + $this->l_marg;
|
||||||
$y1 = ($y1 - $this->y_min) / $this->scale + $this->t_marg;
|
$y1 = ($y1 - $this->y_min) / $this->scale + $this->t_marg;
|
||||||
$x2 = ($x2 - $this->x_min) / $this->scale + $this->l_marg;
|
$x2 = ($x2 - $this->x_min) / $this->scale + $this->l_marg;
|
||||||
@@ -52,30 +56,78 @@ class PDF extends FPDF {
|
|||||||
$this->Line($x1, $y1, $x2, $y2);
|
$this->Line($x1, $y1, $x2, $y2);
|
||||||
}
|
}
|
||||||
|
|
||||||
function SetXY_scale($x, $y) {
|
function PMA_PDF_setXyScale($x, $y)
|
||||||
|
{
|
||||||
$x = ($x - $this->x_min) / $this->scale + $this->l_marg;
|
$x = ($x - $this->x_min) / $this->scale + $this->l_marg;
|
||||||
$y = ($y - $this->y_min) / $this->scale + $this->t_marg;
|
$y = ($y - $this->y_min) / $this->scale + $this->t_marg;
|
||||||
$this->SetXY($x, $y);
|
$this->SetXY($x, $y);
|
||||||
}
|
}
|
||||||
|
|
||||||
function SetX_scale($x) {
|
function PMA_PDF_setXScale($x)
|
||||||
|
{
|
||||||
$x = ($x - $this->x_min) / $this->scale + $this->l_marg;
|
$x = ($x - $this->x_min) / $this->scale + $this->l_marg;
|
||||||
$this->SetX($x);
|
$this->SetX($x);
|
||||||
}
|
}
|
||||||
|
|
||||||
function SetFontSize_scale($size) {
|
function PMA_PDF_setFontSizeScale($size)
|
||||||
|
{
|
||||||
// Set font size in points
|
// Set font size in points
|
||||||
$size = $size / $this->scale;
|
$size = $size / $this->scale;
|
||||||
$this->SetFontSize($size);
|
$this->SetFontSize($size);
|
||||||
}
|
}
|
||||||
|
|
||||||
function SetLineWidth_scale($width) {
|
function PMA_PDF_setLineWidthScale($width)
|
||||||
|
{
|
||||||
$width = $width / $this->scale;
|
$width = $width / $this->scale;
|
||||||
$this->SetLineWidth($width);
|
$this->SetLineWidth($width);
|
||||||
}
|
}
|
||||||
} // end class PDF
|
|
||||||
|
|
||||||
class RT {
|
/**
|
||||||
|
* Displays an error message
|
||||||
|
*
|
||||||
|
* @param string the error mesage
|
||||||
|
*
|
||||||
|
* @global array the PMA configuration array
|
||||||
|
* @global integer the current server id
|
||||||
|
* @global string the current language
|
||||||
|
* @global string the current database name
|
||||||
|
* @global string the current charset
|
||||||
|
* @global string the current text direction
|
||||||
|
* @global string a localized string
|
||||||
|
* @global string an other localized string
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function PMA_PDF_die($error_message = '')
|
||||||
|
{
|
||||||
|
global $cfg;
|
||||||
|
global $server, $lang, $db;
|
||||||
|
global $charset, $text_dir, $strRunning, $strDatabase;
|
||||||
|
|
||||||
|
include('./header.inc.php3');
|
||||||
|
|
||||||
|
echo '<p><b>PDF - '. $GLOBALS['strError'] . '</b></p>' . "\n";
|
||||||
|
if (!empty($error_message)) {
|
||||||
|
$error_message = htmlspecialchars($error_message);
|
||||||
|
}
|
||||||
|
echo '<p>' . "\n";
|
||||||
|
echo ' ' . $error_message . "\n";
|
||||||
|
echo '</p>' . "\n";
|
||||||
|
|
||||||
|
echo '<a href="db_details_structure.php3'
|
||||||
|
. '?lang=' . $lang
|
||||||
|
. '&server=' . $server
|
||||||
|
. '&db=' . urlencode($db)
|
||||||
|
. '">' . $GLOBALS['strBack'] . '</a>';
|
||||||
|
echo "\n";
|
||||||
|
|
||||||
|
include('./footer.inc.php3');
|
||||||
|
exit();
|
||||||
|
} // end of the "PMA_PDF_die()" function
|
||||||
|
} // end class "PMA_PDF"
|
||||||
|
|
||||||
|
class PMA_RT
|
||||||
|
{
|
||||||
var $tables = array();
|
var $tables = array();
|
||||||
var $relations = array();
|
var $relations = array();
|
||||||
var $ff = 'Arial';
|
var $ff = 'Arial';
|
||||||
@@ -89,10 +141,11 @@ class RT {
|
|||||||
var $l_marg = 10;
|
var $l_marg = 10;
|
||||||
var $r_marg = 10;
|
var $r_marg = 10;
|
||||||
|
|
||||||
function RT($scale, $which_rel, $show_info = 0, $change_color = 0 , $show_grid = 0) {
|
function PMA_RT($scale, $which_rel, $show_info = 0, $change_color = 0 , $show_grid = 0)
|
||||||
|
{
|
||||||
global $pdf;
|
global $pdf;
|
||||||
|
|
||||||
$pdf = new PDF('L');
|
$pdf = new PMA_PDF('L');
|
||||||
$pdf->cMargin = 0;
|
$pdf->cMargin = 0;
|
||||||
$pdf->Open();
|
$pdf->Open();
|
||||||
$pdf->AliasNbPages();
|
$pdf->AliasNbPages();
|
||||||
@@ -105,48 +158,48 @@ class RT {
|
|||||||
. ' WHERE pdf_page_number = ' . $which_rel;
|
. ' WHERE pdf_page_number = ' . $which_rel;
|
||||||
$result = mysql_query($sql);
|
$result = mysql_query($sql);
|
||||||
if (!$result || !mysql_num_rows($result)) {
|
if (!$result || !mysql_num_rows($result)) {
|
||||||
// TODO: defines the "back url"
|
$pdf->PMA_PDF_die($GLOBALS['strPdfInvalidPageNum']);
|
||||||
// PMA_mysqlDie($GLOBALS['strInvalidPageNum'], '', FALSE, '');
|
|
||||||
PMA_mysqlDie('strInvalidPageNum', '', FALSE, '');
|
|
||||||
}
|
}
|
||||||
while ($row = mysql_fetch_array($result)) {
|
while ($row = mysql_fetch_array($result)) {
|
||||||
$this->add_relation($row['master_table'] , $row['master_field'], $row['foreign_table'], $row['foreign_field']);
|
$this->PMA_RT_addRelation($row['master_table'] , $row['master_field'], $row['foreign_table'], $row['foreign_field']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($scale == 'auto') {
|
if ($scale == 'auto') {
|
||||||
$this->scale = ceil(max(($this->x_max - $this->x_min) / (297 - $this->r_marg - $this->l_marg), ($this->y_max - $this->y_min) / (210 - $this->t_marg - $this->b_marg)) * 100) / 100;
|
$this->scale = ceil(max(($this->x_max - $this->x_min) / (297 - $this->r_marg - $this->l_marg), ($this->y_max - $this->y_min) / (210 - $this->t_marg - $this->b_marg)) * 100) / 100;
|
||||||
$pdf->SetScale($this->scale, $this->x_min, $this->y_min, $this->l_marg, $this->t_marg);
|
$pdf->PMA_PDF_setScale($this->scale, $this->x_min, $this->y_min, $this->l_marg, $this->t_marg);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$this->scale = $scale;
|
$this->scale = $scale;
|
||||||
$pdf->SetScale($scale);
|
$pdf->PMA_PDF_setScale($scale);
|
||||||
}
|
}
|
||||||
$pdf->SetLineWidth_scale(0.1);
|
$pdf->PMA_PDF_setLineWidthScale(0.1);
|
||||||
|
|
||||||
$pdf->SetFontSize_scale(14);
|
$pdf->PMA_PDF_setFontSizeScale(14);
|
||||||
if ($show_grid) {
|
if ($show_grid) {
|
||||||
$this->Stroke_grid();
|
$this->PMA_RT_strokeGrid();
|
||||||
}
|
}
|
||||||
$this->draw_relations($change_color);
|
$this->PMA_RT_drawRelations($change_color);
|
||||||
$this->draw_tables($show_info);
|
$this->PMA_RT_drawTables($show_info);
|
||||||
|
|
||||||
$this->showRT();
|
$this->PMA_RT_showRt();
|
||||||
}
|
}
|
||||||
|
|
||||||
function add_relation($master_table , $master_field, $foreign_table, $foreign_field) {
|
function PMA_RT_addRelation($master_table , $master_field, $foreign_table, $foreign_field)
|
||||||
|
{
|
||||||
if (!isset($this->tables[$master_table])) {
|
if (!isset($this->tables[$master_table])) {
|
||||||
$this->tables[$master_table] = new rt_table($master_table, $this->ff);
|
$this->tables[$master_table] = new PMA_RT_Table($master_table, $this->ff);
|
||||||
$this->set_min_max($this->tables[$master_table]);
|
$this->PMA_RT_setMinMax($this->tables[$master_table]);
|
||||||
}
|
}
|
||||||
if (!isset($this->tables[$foreign_table])) {
|
if (!isset($this->tables[$foreign_table])) {
|
||||||
$this->tables[$foreign_table] = new rt_table($foreign_table, $this->ff);
|
$this->tables[$foreign_table] = new PMA_RT_Table($foreign_table, $this->ff);
|
||||||
$this->set_min_max($this->tables[$foreign_table]);
|
$this->PMA_RT_setMinMax($this->tables[$foreign_table]);
|
||||||
|
|
||||||
}
|
}
|
||||||
$this->relations[] = new rt_relation($this->tables[$master_table], $master_field, $this->tables[$foreign_table], $foreign_field);
|
$this->relations[] = new PMA_RT_Relation($this->tables[$master_table], $master_field, $this->tables[$foreign_table], $foreign_field);
|
||||||
}
|
}
|
||||||
|
|
||||||
function set_min_max($table) {
|
function PMA_RT_setMinMax($table)
|
||||||
|
{
|
||||||
$this->x_max = max($this->x_max, $table->x + $table->width);
|
$this->x_max = max($this->x_max, $table->x + $table->width);
|
||||||
$this->y_max = max($this->y_max, $table->y + $table->height);
|
$this->y_max = max($this->y_max, $table->y + $table->height);
|
||||||
$this->x_min = min($this->x_min, $table->x);
|
$this->x_min = min($this->x_min, $table->x);
|
||||||
@@ -154,21 +207,24 @@ class RT {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function draw_tables($show_info) {
|
function PMA_RT_drawTables($show_info)
|
||||||
|
{
|
||||||
foreach ($this->tables as $table) {
|
foreach ($this->tables as $table) {
|
||||||
$table->draw($show_info, $this->ff);
|
$table->PMA_RT_Table_draw($show_info, $this->ff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function draw_relations($change_color) {
|
function PMA_RT_drawRelations($change_color)
|
||||||
|
{
|
||||||
$i = 0;
|
$i = 0;
|
||||||
foreach ($this->relations as $relation) {
|
foreach ($this->relations as $relation) {
|
||||||
$relation->draw($change_color, $i);
|
$relation->PMA_RT_Relation_draw($change_color, $i);
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function Stroke_grid() {
|
function PMA_RT_strokeGrid()
|
||||||
|
{
|
||||||
global $pdf;
|
global $pdf;
|
||||||
$pdf->SetMargins(0, 0);
|
$pdf->SetMargins(0, 0);
|
||||||
$pdf->SetDrawColor(200, 200, 200);
|
$pdf->SetDrawColor(200, 200, 200);
|
||||||
@@ -188,23 +244,27 @@ class RT {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function showRT() {
|
function PMA_RT_showRt()
|
||||||
|
{
|
||||||
global $pdf, $db, $pdf_page_number;
|
global $pdf, $db, $pdf_page_number;
|
||||||
|
|
||||||
$pdf->SetDisplayMode('fullpage');
|
$pdf->SetDisplayMode('fullpage');
|
||||||
$pdf->Output($db . '_' . $pdf_page_number . '.pdf', TRUE);
|
$pdf->Output($db . '_' . $pdf_page_number . '.pdf', TRUE);
|
||||||
}
|
}
|
||||||
} // end class RT
|
} // end class "PMA_RT"
|
||||||
|
|
||||||
class rt_relation {
|
class PMA_RT_Relation
|
||||||
|
{
|
||||||
var $x_src, $y_src;
|
var $x_src, $y_src;
|
||||||
var $src_dir ;
|
var $src_dir ;
|
||||||
var $dest_dir;
|
var $dest_dir;
|
||||||
var $x_dest, $y_dest;
|
var $x_dest, $y_dest;
|
||||||
var $w_tick = 5;
|
var $w_tick = 5;
|
||||||
|
|
||||||
function rt_relation($master_table, $master_field, $foreign_table, $foreign_field) {
|
function PMA_RT_Relation($master_table, $master_field, $foreign_table, $foreign_field)
|
||||||
$src_pos = $this->get_xy($master_table , $master_field);
|
{
|
||||||
$dest_pos = $this->get_xy($foreign_table, $foreign_field);
|
$src_pos = $this->PMA_RT_Relation_getXy($master_table , $master_field);
|
||||||
|
$dest_pos = $this->PMA_RT_Relation_getXy($foreign_table, $foreign_field);
|
||||||
$src_left = $src_pos[0] - $this->w_tick;
|
$src_left = $src_pos[0] - $this->w_tick;
|
||||||
$src_right = $src_pos[1] + $this->w_tick;
|
$src_right = $src_pos[1] + $this->w_tick;
|
||||||
$dest_left = $dest_pos[0] - $this->w_tick;
|
$dest_left = $dest_pos[0] - $this->w_tick;
|
||||||
@@ -241,14 +301,15 @@ class rt_relation {
|
|||||||
$this->y_dest = $dest_pos[2];
|
$this->y_dest = $dest_pos[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_xy($table, $column) {
|
function PMA_RT_Relation_getXy($table, $column)
|
||||||
|
{
|
||||||
$pos = array_search($column, $table->fields);
|
$pos = array_search($column, $table->fields);
|
||||||
//x_left, x_right ,y
|
//x_left, x_right ,y
|
||||||
return array($table->x, $table->x + $table->width, $table->y + ($pos + 1.5) * $table->height_cell);
|
return array($table->x, $table->x + $table->width, $table->y + ($pos + 1.5) * $table->height_cell);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function draw($change_color, $i) {
|
function PMA_RT_Relation_draw($change_color, $i)
|
||||||
|
{
|
||||||
global $pdf;
|
global $pdf;
|
||||||
|
|
||||||
if ($change_color){
|
if ($change_color){
|
||||||
@@ -271,24 +332,25 @@ class rt_relation {
|
|||||||
$pdf->SetDrawColor(0);
|
$pdf->SetDrawColor(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
$pdf->SetLineWidth_scale(0.2);
|
$pdf->PMA_PDF_setLineWidthScale(0.2);
|
||||||
$pdf->Line_scale($this->x_src, $this->y_src, $this->x_src + $this->src_dir * $this->w_tick, $this->y_src);
|
$pdf->PMA_PDF_lineScale($this->x_src, $this->y_src, $this->x_src + $this->src_dir * $this->w_tick, $this->y_src);
|
||||||
$pdf->Line_scale($this->x_dest + $this->dest_dir * $this->w_tick, $this->y_dest, $this->x_dest, $this->y_dest);
|
$pdf->PMA_PDF_lineScale($this->x_dest + $this->dest_dir * $this->w_tick, $this->y_dest, $this->x_dest, $this->y_dest);
|
||||||
$pdf->SetLineWidth_scale(0.1);
|
$pdf->PMA_PDF_setLineWidthScale(0.1);
|
||||||
$pdf->Line_scale($this->x_src + $this->src_dir * $this->w_tick, $this->y_src, $this->x_dest + $this->dest_dir * $this->w_tick, $this->y_dest);
|
$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);
|
||||||
|
|
||||||
//arrow
|
//arrow
|
||||||
$root2 = 2 * sqrt(2);
|
$root2 = 2 * sqrt(2);
|
||||||
$pdf->Line_scale($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);
|
$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);
|
||||||
$pdf->Line_scale($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);
|
$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);
|
||||||
|
|
||||||
$pdf->Line_scale($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);
|
$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);
|
||||||
$pdf->Line_scale($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);
|
$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);
|
||||||
$pdf->SetDrawColor(0);
|
$pdf->SetDrawColor(0);
|
||||||
}
|
}
|
||||||
} // end class rt_relation
|
} // end class "PMA_RT_Relation"
|
||||||
|
|
||||||
class rt_table {
|
class PMA_RT_Table
|
||||||
|
{
|
||||||
var $nb_fiels;
|
var $nb_fiels;
|
||||||
var $table_name;
|
var $table_name;
|
||||||
var $width = 0;
|
var $width = 0;
|
||||||
@@ -297,19 +359,24 @@ class rt_table {
|
|||||||
var $height_cell = 6;
|
var $height_cell = 6;
|
||||||
var $x, $y;
|
var $x, $y;
|
||||||
|
|
||||||
function rt_table($table_name, $ff) {
|
function PMA_RT_Table($table_name, $ff)
|
||||||
|
{
|
||||||
|
global $pdf;
|
||||||
|
|
||||||
$this->table_name = $table_name;
|
$this->table_name = $table_name;
|
||||||
$sql = 'DESCRIBE ' . PMA_backquote($table_name);
|
$sql = 'DESCRIBE ' . PMA_backquote($table_name);
|
||||||
$result = mysql_query($sql);
|
$result = mysql_query($sql);
|
||||||
|
if (!$result || !mysql_num_rows($result)) {
|
||||||
|
$pdf->PMA_PDF_die(sprintf($GLOBALS['strInvalidTblName'], $table_name));
|
||||||
|
}
|
||||||
// load fields
|
// load fields
|
||||||
while ($row = mysql_fetch_array($result)) {
|
while ($row = mysql_fetch_array($result)) {
|
||||||
$this->fields[] = $row[0];
|
$this->fields[] = $row[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
//height and width
|
//height and width
|
||||||
$this->set_width($ff);
|
$this->PMA_RT_Table_setWidth($ff);
|
||||||
$this->set_height();
|
$this->PMA_RT_Table_setHeight();
|
||||||
|
|
||||||
//x and y
|
//x and y
|
||||||
$sql = 'SELECT x, y FROM '
|
$sql = 'SELECT x, y FROM '
|
||||||
@@ -317,13 +384,13 @@ class rt_table {
|
|||||||
. ' WHERE table_name = \'' . PMA_sqlAddslashes($table_name) . '\'';
|
. ' WHERE table_name = \'' . PMA_sqlAddslashes($table_name) . '\'';
|
||||||
$result = mysql_query($sql);
|
$result = mysql_query($sql);
|
||||||
if (!$result || !mysql_num_rows($result)) {
|
if (!$result || !mysql_num_rows($result)) {
|
||||||
// TODO: defines the "back url"
|
$pdf->PMA_PDF_die(sprintf($GLOBALS['strConfigureTableCoord'], $table_name));
|
||||||
PMA_mysqlDie(sprintf($GLOBALS['strConfigureTableCoord'], $table_name), '', FALSE, '');
|
|
||||||
}
|
}
|
||||||
list($this->x, $this->y) = mysql_fetch_array($result);
|
list($this->x, $this->y) = mysql_fetch_array($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
function set_width($ff) {
|
function PMA_RT_Table_setWidth($ff)
|
||||||
|
{
|
||||||
global $pdf;
|
global $pdf;
|
||||||
|
|
||||||
foreach ($this->fields as $field ) {
|
foreach ($this->fields as $field ) {
|
||||||
@@ -335,36 +402,38 @@ class rt_table {
|
|||||||
$pdf->SetFont($ff, '');
|
$pdf->SetFont($ff, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
function set_height() {
|
function PMA_RT_Table_setHeight()
|
||||||
|
{
|
||||||
$this->height = (sizeof($this->fields) + 1) * $this->height_cell;
|
$this->height = (sizeof($this->fields) + 1) * $this->height_cell;
|
||||||
}
|
}
|
||||||
|
|
||||||
function draw($show_info, $ff) {
|
function PMA_RT_Table_draw($show_info, $ff)
|
||||||
|
{
|
||||||
global $pdf;
|
global $pdf;
|
||||||
$pdf->SetXY_scale($this->x, $this->y);
|
|
||||||
|
$pdf->PMA_PDF_setXyScale($this->x, $this->y);
|
||||||
$pdf->SetFont($ff, 'B');
|
$pdf->SetFont($ff, 'B');
|
||||||
$pdf->SetTextColor(200);
|
$pdf->SetTextColor(200);
|
||||||
$pdf->SetFillColor(0, 0, 128);
|
$pdf->SetFillColor(0, 0, 128);
|
||||||
if ($show_info){
|
if ($show_info){
|
||||||
$pdf->Cell_scale($this->width, $this->height_cell, round($this->width) . 'x' . round($this->height) . ' ' . $this->table_name , 1, 1, 'C', 1);
|
$pdf->PMA_PDF_cellScale($this->width, $this->height_cell, round($this->width) . 'x' . round($this->height) . ' ' . $this->table_name , 1, 1, 'C', 1);
|
||||||
} else {
|
} else {
|
||||||
$pdf->Cell_scale($this->width, $this->height_cell, $this->table_name, 1, 1, 'C', 1);
|
$pdf->PMA_PDF_cellScale($this->width, $this->height_cell, $this->table_name, 1, 1, 'C', 1);
|
||||||
}
|
}
|
||||||
$pdf->SetX_scale($this->x);
|
$pdf->PMA_PDF_setXScale($this->x);
|
||||||
$pdf->SetFont($ff, '');
|
$pdf->SetFont($ff, '');
|
||||||
$pdf->SetTextColor(0);
|
$pdf->SetTextColor(0);
|
||||||
$pdf->SetFillColor(255);
|
$pdf->SetFillColor(255);
|
||||||
|
|
||||||
foreach ($this->fields as $field) {
|
foreach ($this->fields as $field) {
|
||||||
$pdf->Cell_scale($this->width, $this->height_cell, ' ' . $field, 1, 1, 'L', 1);
|
$pdf->PMA_PDF_cellScale($this->width, $this->height_cell, ' ' . $field, 1, 1, 'L', 1);
|
||||||
$pdf->SetX_scale($this->x);
|
$pdf->PMA_PDF_setXScale($this->x);
|
||||||
}
|
}
|
||||||
if ($pdf->PageNo() > 1) {
|
if ($pdf->PageNo() > 1) {
|
||||||
// TODO: defines the "back url"
|
$pdf->PMA_PDF_die($GLOBALS['strScaleFactorSmall']);
|
||||||
PMA_mysqlDie($GLOBALS['strScaleFactorSmall'], '', FALSE, '');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // end class rt_table
|
} // end class "PMA_RT_Table"
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -379,5 +448,5 @@ $show_table_dimension = (isset($show_table_dimension) && $show_table_dimension =
|
|||||||
|
|
||||||
mysql_select_db($db);
|
mysql_select_db($db);
|
||||||
|
|
||||||
$rt = new RT('auto', $pdf_page_number, $show_table_dimension, $show_color, $show_grid);
|
$rt = new PMA_RT('auto', $pdf_page_number, $show_table_dimension, $show_color, $show_grid);
|
||||||
?>
|
?>
|
||||||
|
Reference in New Issue
Block a user