From 458d1e35e29733506af59e009fe515a68f780b66 Mon Sep 17 00:00:00 2001 From: Mike Beck Date: Mon, 3 Jun 2002 09:17:05 +0000 Subject: [PATCH] Done some Changes to enable easier working on pdf pages --- config.inc.php3 | 3 + db_details_structure.php3 | 53 +++++++--- pdf_pages.php3 | 209 ++++++++++++++++++++++++++++++++++++++ pdf_schema.php3 | 48 +++++++-- 4 files changed, 290 insertions(+), 23 deletions(-) create mode 100755 pdf_pages.php3 diff --git a/config.inc.php3 b/config.inc.php3 index cd7b55d60..2a62485a4 100755 --- a/config.inc.php3 +++ b/config.inc.php3 @@ -54,6 +54,7 @@ $cfg['Servers'][$i]['table_info'] = ''; // table to describe the dis // - leave blank for no display fields support $cfg['Servers'][$i]['table_coords'] = ''; // table to describe the tables position for the PDF // schema - leave blank for no PDF schema support +$cfg['Servers'][$i]['pdf_pages'] = ''; // table to describe pages of relationpdf $cfg['Servers'][$i]['AllowDeny']['order'] // Host authentication order, leave blank to not use = ''; $cfg['Servers'][$i]['AllowDeny']['rules'] // Host authentication rules, leave blank for defaults @@ -77,6 +78,7 @@ $cfg['Servers'][$i]['bookmarktable'] = ''; $cfg['Servers'][$i]['relation'] = ''; $cfg['Servers'][$i]['table_info'] = ''; $cfg['Servers'][$i]['table_coords'] = ''; +$cfg['Servers'][$i]['pdf_pages'] = ''; $cfg['Servers'][$i]['AllowDeny']['order'] = ''; $cfg['Servers'][$i]['AllowDeny']['rules'] @@ -99,6 +101,7 @@ $cfg['Servers'][$i]['bookmarktable'] = ''; $cfg['Servers'][$i]['relation'] = ''; $cfg['Servers'][$i]['table_info'] = ''; $cfg['Servers'][$i]['table_coords'] = ''; +$cfg['Servers'][$i]['pdf_pages'] = ''; $cfg['Servers'][$i]['AllowDeny']['order'] = ''; $cfg['Servers'][$i]['AllowDeny']['rules'] diff --git a/db_details_structure.php3 b/db_details_structure.php3 index 2b2ee7482..c8c3a3ec9 100644 --- a/db_details_structure.php3 +++ b/db_details_structure.php3 @@ -440,25 +440,46 @@ echo ' ' . ' ' . "\n"; if (!empty($cfg['Server']['table_coords']) && $num_tables > 0) { ?> - +
  • -
    - - - -  :
    -   -
    - -
    - -
    - - -    -
    + +
  • + 0){ + ?> +
  • +
    + + + +  :
    +   +
    + +
    + +
    + + +    +
    +
  • + '; diff --git a/pdf_pages.php3 b/pdf_pages.php3 new file mode 100755 index 000000000..6986ada75 --- /dev/null +++ b/pdf_pages.php3 @@ -0,0 +1,209 @@ +0){ + if($arrvalue['delete'] == 'y'){ + $ch_query = 'DELETE FROM '.PMA_backquote($cfg['Server']['table_coords']) . + ' WHERE table_name = \''.$arrvalue['name'] . '\'' . + ' AND pdf_page_number = '.$chpage; + }else{ + $ch_query = 'UPDATE '.PMA_backquote($cfg['Server']['table_coords']) . + ' SET x='.$arrvalue['x'] . ', y= '. $arrvalue['y'] . + ' WHERE table_name = \''.$arrvalue['name'] . '\'' . + ' AND pdf_page_number = '.$chpage; + } + }else{ + $ch_query = 'INSERT INTO '.PMA_backquote($cfg['Server']['table_coords']) . + ' VALUES (\''.$arrvalue['name'].'\','.$chpage.','. + $arrvalue['x'].','.$arrvalue['y'].')'; + } + mysql_query($ch_query) or PMA_mysqlDie('', $ch_query, '', $err_url_0); + } + } + break; + } + } + // now first show some possibility to choose a page for the pdf + $page_query = 'SELECT * FROM ' .PMA_backquote($cfg['Server']['pdf_pages']); + $page_rs = mysql_query($page_query) or PMA_mysqlDie('', $page_query, '', $err_url_0); + if(mysql_num_rows($page_rs)>0){ + ?> +
    + + + + + + + '; + while ($curr_page = @mysql_fetch_array($page_rs)) { + echo ''; + } + ?> + +
    + +
    + + + + + + + + +
    + 0){ + ?> +

    +
    + + + + + + + + + '; + echo ''."\n"; + echo ''."\n"; + echo ''."\n"; + echo ''."\n"; + echo ''."\n"; + $i++; + } + // do one more empty row + echo ''; + echo ''."\n"; + echo ''."\n"; + echo ''."\n"; + echo ''."\n"; + echo ''."\n"; + echo '
    XY
    '.$strDelete.'
    '.$strDelete.'
    '."\n"; + } +} + + +/** + * Displays the footer + */ +echo "\n"; +require('./footer.inc.php3'); +?> diff --git a/pdf_schema.php3 b/pdf_schema.php3 index df16985e7..f8e9f5ddb 100644 --- a/pdf_schema.php3 +++ b/pdf_schema.php3 @@ -369,12 +369,16 @@ class PMA_RT_Table $pdf->SetFont($ff, ''); $pdf->SetTextColor(0); $pdf->SetFillColor(255); - + reset($this->fields); while (list(, $field) = each($this->fields)) { + if($field == $this->primary){$pdf->SetFillColor(215,121,123);} + if($field == $this->displayfield){$pdf->SetFillColor(142,159,224);} $pdf->PMA_PDF_cellScale($this->width, $this->height_cell, ' ' . $field, 1, 1, 'L', 1); $pdf->PMA_PDF_setXScale($this->x); - } + $pdf->SetFillColor(255); + } + if ($pdf->PageNo() > 1) { $pdf->PMA_PDF_die($GLOBALS['strScaleFactorSmall']); } @@ -427,6 +431,28 @@ class PMA_RT_Table list($this->x, $this->y) = mysql_fetch_array($result); $this->x = (double) $this->x; $this->y = (double) $this->y; + + //displayfield + $sql = 'SELECT display_field from '.PMA_backquote($GLOBALS['cfg']['Server']['table_info']) + . ' WHERE table_name = \'' . PMA_sqlAddslashes($table_name) . '\''; + $result = mysql_query($sql); + if(mysql_num_rows($result)>0){ + list($this->displayfield) = mysql_fetch_array($result); + } + while ($row = mysql_fetch_array($result)) { + $this->displayfield = $row['display_field ']; + } + // index + $sql = 'SHOW index from '.PMA_backquote($table_name); + $result = mysql_query($sql); + + if(mysql_num_rows($result)>0){ + while ($row = mysql_fetch_array($result)) { + if($row['Key_name'] == 'PRIMARY'){ + $this->primary = $row['Column_name']; + } + } + } } // end of the "PMA_RT_Table()" method } // end class "PMA_RT_Table" @@ -777,18 +803,26 @@ class PMA_RT $pdf->SetFont($this->ff, '', 14); $pdf->SetAutoPageBreak('auto'); - // Gets relations to display and exits if none + // get tables on this page + $tab_sql = 'SELECT table_name from '.PMA_backquote($GLOBALS['cfg']['Server']['table_coords']) . + ' WHERE pdf_page_number = ' . $which_rel; + $tab_rs = mysql_query($tab_sql) or PMA_mysqlDie('', $tab_sql, '', $err_url_0); + while ($curr_table = @mysql_fetch_array($tab_rs)) { + $alltables[] = $curr_table['table_name']; + $intable = "'" . implode("','",$alltables) . "'"; + } $sql = 'SELECT * FROM ' . PMA_backquote($GLOBALS['cfg']['Server']['relation']) - . ' WHERE pdf_page_number = ' . $which_rel; + . ' WHERE master_table in (' . $intable . ') ' + . ' AND foreign_table in (' . $intable . ')'; $result = mysql_query($sql); if (!$result || !mysql_num_rows($result)) { $pdf->PMA_PDF_die($GLOBALS['strPdfInvalidPageNum']); - } // end if + } while ($row = mysql_fetch_array($result)) { $this->PMA_RT_addRelation($row['master_table'] , $row['master_field'], $row['foreign_table'], $row['foreign_field']); - } // end while - + } + // Defines the scale factor 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;