Done some Changes to enable easier working on pdf pages
This commit is contained in:
@@ -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']
|
||||
|
@@ -440,25 +440,46 @@ echo ' ' . ' <input type="submit" value="' . $strGo . '" />' . "\n";
|
||||
if (!empty($cfg['Server']['table_coords'])
|
||||
&& $num_tables > 0) {
|
||||
?>
|
||||
<!-- PDF schema -->
|
||||
<!-- Work on PDF Pages -->
|
||||
<li>
|
||||
<form method="post" action="pdf_schema.php3">
|
||||
<input type="hidden" name="server" value="<?php echo $server; ?>" />
|
||||
<input type="hidden" name="lang" value="<?php echo $lang; ?>" />
|
||||
<input type="hidden" name="db" value="<?php echo $db; ?>" />
|
||||
<?php echo $strDisplayPDF; ?> :<br />
|
||||
<?php echo $strPageNumber; ?>
|
||||
<input type="text" name="pdf_page_number" size="3" class="textfield" value="1" /><br />
|
||||
<input type="checkbox" name="show_grid" id="show_grid_opt" />
|
||||
<label for="show_grid_opt"><?php echo $strShowGrid; ?></label><br />
|
||||
<input type="checkbox" name="show_color" id="show_color_opt" checked="checked" />
|
||||
<label for="show_color_opt"><?php echo $strShowColor; ?></label><br />
|
||||
<input type="checkbox" name="show_table_dimension" id="show_table_dim_opt" />
|
||||
<label for="show_table_dim_opt"><?php echo $strShowTableDimension; ?></label>
|
||||
<input type="submit" value="<?php echo $strGo; ?>" />
|
||||
</form>
|
||||
<?php
|
||||
$takeaway = $url_query . '&table=' . urlencode($cfg['Server']['pdf_pages']);
|
||||
?>
|
||||
<a href="pdf_pages.php3?<?php echo $takeaway; ?>"><?php echo $strEditPDFPages ;?></a>
|
||||
</li>
|
||||
<!-- PDF schema -->
|
||||
<?php
|
||||
// We only show this if we find something in the new pdf_pages table
|
||||
@mysql_select_db($db);
|
||||
$test_query = 'SELECT * FROM ' . PMA_backquote($cfg['Server']['pdf_pages']);
|
||||
$test_rs = mysql_query($test_query) or PMA_mysqlDie('', $test_query, '', $err_url_0);
|
||||
if(mysql_num_rows($test_rs) > 0){
|
||||
?>
|
||||
<li>
|
||||
<form method="post" action="pdf_schema.php3">
|
||||
<input type="hidden" name="server" value="<?php echo $server; ?>" />
|
||||
<input type="hidden" name="lang" value="<?php echo $lang; ?>" />
|
||||
<input type="hidden" name="db" value="<?php echo $db; ?>" />
|
||||
<?php echo $strDisplayPDF; ?> :<br />
|
||||
<?php echo $strPageNumber; ?>
|
||||
<select name="pdf_page_number">
|
||||
<?php
|
||||
while ($pages = @mysql_fetch_array($test_rs)) {
|
||||
echo '<option value="'.$pages['page_nr'].'">'.$pages['page_nr'].': '.$pages['page_descr'].'</option>'."\n";
|
||||
}
|
||||
?>
|
||||
</select><br />
|
||||
<input type="checkbox" name="show_grid" id="show_grid_opt" />
|
||||
<label for="show_grid_opt"><?php echo $strShowGrid; ?></label><br />
|
||||
<input type="checkbox" name="show_color" id="show_color_opt" checked="checked" />
|
||||
<label for="show_color_opt"><?php echo $strShowColor; ?></label><br />
|
||||
<input type="checkbox" name="show_table_dimension" id="show_table_dim_opt" />
|
||||
<label for="show_table_dim_opt"><?php echo $strShowTableDimension; ?></label>
|
||||
<input type="submit" value="<?php echo $strGo; ?>" />
|
||||
</form>
|
||||
</li>
|
||||
<?php
|
||||
} // end if
|
||||
} // end if
|
||||
|
||||
echo "\n" . '</ul>';
|
||||
|
209
pdf_pages.php3
Executable file
209
pdf_pages.php3
Executable file
@@ -0,0 +1,209 @@
|
||||
<?php
|
||||
/**
|
||||
* pdf_pages.php3 mikebeck 2002-05-23
|
||||
* create and edit the pages to output in pdf
|
||||
*
|
||||
* requires a separate table:
|
||||
* CREATE TABLE `PMA_pdf_pages` (
|
||||
* `page_nr` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
* `page_descr` VARCHAR(50) NOT NULL
|
||||
* ) TYPE = MYISAM
|
||||
* COMMENT = 'PDF Relationpages for PMA';
|
||||
*
|
||||
* also requires a new variable in config.inc.php3:
|
||||
* $cfg['Servers'][$i]['pdf_pages'] = 'PMA_pdf_pages'; // table to describe pages of relationpdf
|
||||
*/
|
||||
/**
|
||||
* Gets some core libraries
|
||||
*/
|
||||
require('./libraries/grab_globals.lib.php3');
|
||||
require('./libraries/common.lib.php3');
|
||||
require('./tbl_properties_common.php3');
|
||||
require('./tbl_properties_table_info.php3');
|
||||
|
||||
/**
|
||||
* Select page:
|
||||
*/
|
||||
|
||||
if (!empty($cfg['Server']['pdf_pages'])){
|
||||
// First we get all tables in the current db
|
||||
$tab_query = 'SHOW TABLES FROM ' . PMA_backquote($db);
|
||||
$tab_rs = mysql_query($tab_query) or PMA_mysqlDie('', $tab_query, '', $err_url_0);
|
||||
$selectboxall[] = '--';
|
||||
while ($curr_table = @mysql_fetch_array($tab_rs)) {
|
||||
// i'd like to check if all required tables are present
|
||||
// and otherwise give some hint
|
||||
if($curr_table[0] == $cfg['Server']['relation']){$relex =1;}else{
|
||||
if($curr_table[0] == $cfg['Server']['table_info']){$info =1;}else{
|
||||
if($curr_table[0] == $cfg['Server']['table_coords']){$coords =1;}else{
|
||||
// if it is not one of the PMA tables add it to the
|
||||
// selectbox
|
||||
$selectboxall[] = $curr_table[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// now check if we found all required tables
|
||||
// this will fail if either the variable was not set or the table does not
|
||||
// exist
|
||||
//
|
||||
// i'd like to have a link to the appropiate chapter of the documentation
|
||||
// within the strings i am using now, but that requires the
|
||||
// documentation.html to have some anchors
|
||||
if(!isset($relex)){die($strRelationNotSet);}
|
||||
if(!isset($info)) {die($strInfoNotSet);}
|
||||
if(!isset($coords)){die($strCoordsNotSet);}
|
||||
|
||||
// now is the time to work on all changes
|
||||
if(isset($do)){
|
||||
switch($do){
|
||||
case 'createpage':
|
||||
if(!isset($newpage) || $newpage==''){
|
||||
$newpage = $strNoDescription;
|
||||
}
|
||||
$ins_query = 'INSERT INTO ' . PMA_backquote($cfg['Server']['pdf_pages']) .
|
||||
' (page_descr) VALUES (\'' . $newpage . '\')';
|
||||
mysql_query($ins_query) or PMA_mysqlDie('', $ins_query, '', $err_url_0);
|
||||
break;
|
||||
case 'edcoord':
|
||||
while (list($key,$arrvalue) = each($ctable)) {
|
||||
if(!isset($arrvalue['x']) || $arrvalue['x'] == ''){$arrvalue['x']=0;}
|
||||
if(!isset($arrvalue['y']) || $arrvalue['y'] == ''){$arrvalue['y']=0;}
|
||||
if(isset($arrvalue['name']) && $arrvalue['name'] != '--'){
|
||||
$test_query = 'SELECT * FROM '.PMA_backquote($cfg['Server']['table_coords']) .
|
||||
' WHERE table_name = \''.$arrvalue['name'] . '\'' .
|
||||
' AND pdf_page_number = '.$chpage;
|
||||
$test_rs = mysql_query($test_query) or PMA_mysqlDie('', $test_query, '', $err_url_0);
|
||||
if(mysql_num_rows($test_rs)>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){
|
||||
?>
|
||||
<form action="pdf_pages.php3" method="post" name="selpage">
|
||||
<?php echo $strChoosePage; ?>
|
||||
<input type="hidden" name="db" value="<?php echo $db; ?>" />
|
||||
<input type="hidden" name="lang" value="<?php echo $lang; ?>" />
|
||||
<input type="hidden" name="server" value="<?php echo $server; ?>" />
|
||||
<input type="hidden" name="table" value="<?php echo $table; ?>" />
|
||||
<input type="hidden" name="do" value="choosepage" />
|
||||
<?php
|
||||
echo '<select name="chpage" onChange="this.form.submit()">';
|
||||
while ($curr_page = @mysql_fetch_array($page_rs)) {
|
||||
echo '<option value="'.$curr_page['page_nr'].'"';
|
||||
if($chpage==$curr_page['page_nr']){echo ' selected="selected"';}
|
||||
echo '>';
|
||||
echo $curr_page['page_nr'] . ': '.$curr_page['page_descr'].'</option>';
|
||||
}
|
||||
?>
|
||||
<input type="submit" value="<?php echo $strGo; ?>" />
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
// possibility to create a new page:
|
||||
?>
|
||||
<form action="pdf_pages.php3" method="post" name="crpage">
|
||||
<?php echo $strCreatePage; ?>
|
||||
<input type="hidden" name="db" value="<?php echo $db; ?>" />
|
||||
<input type="hidden" name="lang" value="<?php echo $lang; ?>" />
|
||||
<input type="hidden" name="server" value="<?php echo $server; ?>" />
|
||||
<input type="hidden" name="table" value="<?php echo $table; ?>" />
|
||||
<input type="hidden" name="do" value="createpage" />
|
||||
<input type="text" name="newpage" size="20" maxlength="50" />
|
||||
<input type="submit" value="<?php echo $strGo; ?>" />
|
||||
</form>
|
||||
<?php
|
||||
// now if we allready have choosen a pagenumer then we should show the tables involved
|
||||
if(isset($chpage) && $chpage>0){
|
||||
?>
|
||||
<hr /><h2><?php echo $strSelectTables ;?></h2>
|
||||
<form action="pdf_pages.php3" method="post" name="edcoord">
|
||||
<input type="hidden" name="db" value="<?php echo $db; ?>" />
|
||||
<input type="hidden" name="lang" value="<?php echo $lang; ?>" />
|
||||
<input type="hidden" name="server" value="<?php echo $server; ?>" />
|
||||
<input type="hidden" name="table" value="<?php echo $table; ?>" />
|
||||
<input type="hidden" name="chpage" value="<?php echo $chpage; ?>" />
|
||||
<input type="hidden" name="do" value="edcoord" />
|
||||
<table border=0>
|
||||
<tr><th><?php echo $strTable;?></th><th><?php echo $strDelete;?></th><th>X</th><th>Y</th></tr>
|
||||
<?php
|
||||
if(isset($ctable)){unset($ctable);}
|
||||
$page_query = 'SELECT * FROM' . PMA_backquote($cfg['Server']['table_coords']) .
|
||||
' WHERE pdf_page_number='.$chpage;
|
||||
$page_rs = mysql_query($page_query) or PMA_mysqlDie('', $page_query, '', $err_url_0);
|
||||
$i=0;
|
||||
while ($sh_page = @mysql_fetch_array($page_rs)) {
|
||||
echo '<tr ';
|
||||
if($i % 2==0){
|
||||
echo 'bgcolor="'.$cfg['BgcolorOne'].'"';
|
||||
}else{
|
||||
echo 'bgcolor="'.$cfg['BgcolorTwo'].'"';
|
||||
}
|
||||
echo '>';
|
||||
echo '<td><select name="ctable['.$i.'][name]">';
|
||||
reset($selectboxall);
|
||||
while (list($key,$value) = each($selectboxall)) {
|
||||
echo '<option value="'.$value.'"';
|
||||
if($value==$sh_page['table_name']){
|
||||
echo ' selected="selected"';
|
||||
}
|
||||
echo '>'.$value.'</option>'."\n";
|
||||
}
|
||||
echo '</select></td>'."\n";
|
||||
echo '<td><INPUT type="checkbox" name="ctable['.$i.'][delete]" value="y" />'.$strDelete.'</td>'."\n";
|
||||
echo '<td><INPUT type="text" name="ctable['.$i.'][x]" value="'.$sh_page['x'].'"></td>'."\n";
|
||||
echo '<td><INPUT type="text" name="ctable['.$i.'][y]" value="'.$sh_page['y'].'"></td>'."\n";
|
||||
echo '</tr>'."\n";
|
||||
$i++;
|
||||
}
|
||||
// do one more empty row
|
||||
echo '<tr ';
|
||||
if($i % 2==0){
|
||||
echo 'bgcolor="'.$cfg['BgcolorOne'].'"';
|
||||
}else{
|
||||
echo 'bgcolor="'.$cfg['BgcolorTwo'].'"';
|
||||
}
|
||||
echo '>';
|
||||
echo '<td><select name="ctable['.$i.'][name]">';
|
||||
reset($selectboxall);
|
||||
while (list($key,$value) = each($selectboxall)) {
|
||||
echo '<option value="'.$value.'"';
|
||||
echo '>'.$value.'</option>'."\n";
|
||||
}
|
||||
echo '</select></td>'."\n";
|
||||
echo '<td><INPUT type="checkbox" name="ctable['.$i.'][delete]" value="y" />'.$strDelete.'</td>'."\n";
|
||||
echo '<td><INPUT type="text" name="ctable['.$i.'][x]"></td>'."\n";
|
||||
echo '<td><INPUT type="text" name="ctable['.$i.'][y]"></td>'."\n";
|
||||
echo '</tr>'."\n";
|
||||
echo '</table><input type="submit" value="'.$strGo.'" /></form>'."\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Displays the footer
|
||||
*/
|
||||
echo "\n";
|
||||
require('./footer.inc.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;
|
||||
|
Reference in New Issue
Block a user