/** * The "PMA_Pdf_Relation_Schema" constructor * * @global object The current PDF Schema document * @global string The current db name * @global array The relations settings * @access private * @see PMA_Schema_PDF */ function __construct() { global $pdf, $db; $this->setPageNumber($_POST['pdf_page_number']); $this->setShowGrid(isset($_POST['show_grid'])); $this->setShowColor(isset($_POST['show_color'])); $this->setShowKeys(isset($_POST['show_keys'])); $this->setTableDimension(isset($_POST['show_table_dimension'])); $this->setAllTableSameWidth(isset($_POST['all_table_same_wide'])); $this->setWithDataDictionary($_POST['with_doc']); $this->setOrientation($_POST['orientation']); $this->setPaper($_POST['paper']); $this->setExportType($_POST['export_type']); // Initializes a new document $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->SetAutoPageBreak('auto'); $alltables = $this->getAllTables($db, $this->pageNumber); if ($this->withDoc) { $pdf->SetAutoPageBreak('auto', 15); $pdf->setCMargin(1); $this->dataDictionaryDoc($alltables); $pdf->SetAutoPageBreak('auto'); $pdf->setCMargin(0); } $pdf->Addpage(); if ($this->withDoc) { $pdf->SetLink($pdf->PMA_links['RT']['-'], -1); $pdf->Bookmark(__('Relational schema')); $pdf->SetAlias('{00}', $pdf->PageNo()); $this->topMargin = 28; $this->bottomMargin = 28; } /* snip */ foreach ($alltables as $table) { if (!isset($this->tables[$table])) { $this->tables[$table] = new Table_Stats($table, $this->_ff, $this->pageNumber, $this->_tablewidth, $this->showKeys, $this->tableDimension); } if ($this->sameWide) { $this->tables[$table]->width = $this->_tablewidth; } $this->_setMinMax($this->tables[$table]); } // Defines the scale factor $this->scale = ceil(max(($this->_xMax - $this->_xMin) / ($pdf->getPageWidth() - $this->rightMargin - $this->leftMargin), ($this->_yMax - $this->_yMin) / ($pdf->getPageHeight() - $this->topMargin - $this->bottomMargin)) * 100) / 100; $pdf->PMA_PDF_setScale($this->scale, $this->_xMin, $this->_yMin, $this->leftMargin, $this->topMargin); // Builds and save the PDF document $pdf->PMA_PDF_setLineWidthScale(0.1); if ($this->showGrid) { $pdf->SetFontSize(10); $this->_strokeGrid(); } $pdf->PMA_PDF_setFontSizeScale(14); // previous logic was checking master tables and foreign tables // but I think that looping on every table of the pdf page as a master // and finding its foreigns is OK (then we can support innodb) $seen_a_relation = false; foreach ($alltables as $one_table) { $exist_rel = PMA_getForeigners($db, $one_table, '', 'both'); if ($exist_rel) { $seen_a_relation = true; foreach ($exist_rel as $master_field => $rel) { // put the foreign table on the schema only if selected // by the user // (do not use array_search() because we would have to // to do a === false and this is not PHP3 compatible) if (in_array($rel['foreign_table'], $alltables)) { $this->_addRelation($one_table, $master_field, $rel['foreign_table'], $rel['foreign_field'], $this->tableDimension); } } // end while } // end if } // end while if ($seen_a_relation) { $this->_drawRelations($this->showColor); } $this->_drawTables($this->showColor); $this->_showOutput($this->pageNumber); exit; }
/** * The "PMA_Pdf_Relation_Schema" constructor * * @global object $pdf The current PDF Schema document * @access private * @see PMA_Schema_PDF */ function __construct() { parent::__construct(); global $pdf; $this->setShowGrid(isset($_REQUEST['pdf_show_grid'])); $this->setShowColor(isset($_REQUEST['pdf_show_color'])); $this->setShowKeys(isset($_REQUEST['pdf_show_keys'])); $this->setTableDimension(isset($_REQUEST['pdf_show_table_dimension'])); $this->setAllTablesSameWidth(isset($_REQUEST['pdf_all_tables_same_width'])); $this->setWithDataDictionary(isset($_REQUEST['pdf_with_doc'])); $this->setTableOrder($_REQUEST['pdf_table_order']); $this->setOrientation($_REQUEST['pdf_orientation']); $this->setPaper($_REQUEST['pdf_paper']); // Initializes a new document $pdf = new PMA_Schema_PDF($this->orientation, 'mm', $this->paper, $this->pageNumber, $this->_withDoc); $pdf->SetTitle(sprintf(__('Schema of the %s database'), $GLOBALS['db'])); $pdf->setCMargin(0); $pdf->Open(); $pdf->SetAutoPageBreak('auto'); $pdf->setOffline($this->offline); $alltables = $this->getTablesFromRequest(); if ($this->getTableOrder() == 'name_asc') { sort($alltables); } else { if ($this->getTableOrder() == 'name_desc') { rsort($alltables); } } if ($this->_withDoc) { $pdf->SetAutoPageBreak('auto', 15); $pdf->setCMargin(1); $this->dataDictionaryDoc($alltables); $pdf->SetAutoPageBreak('auto'); $pdf->setCMargin(0); } $pdf->Addpage(); if ($this->_withDoc) { $pdf->SetLink($pdf->PMA_links['RT']['-'], -1); $pdf->Bookmark(__('Relational schema')); $pdf->SetAlias('{00}', $pdf->PageNo()); $this->_topMargin = 28; $this->_bottomMargin = 28; } /* snip */ foreach ($alltables as $table) { if (!isset($this->_tables[$table])) { $this->_tables[$table] = new Table_Stats_Pdf($table, null, $this->pageNumber, $this->_tablewidth, $this->showKeys, $this->tableDimension, $this->offline); } if ($this->sameWide) { $this->_tables[$table]->width = $this->_tablewidth; } $this->_setMinMax($this->_tables[$table]); } // Defines the scale factor $this->_scale = ceil(max(($this->_xMax - $this->_xMin) / ($pdf->getPageWidth() - $this->_rightMargin - $this->_leftMargin), ($this->_yMax - $this->_yMin) / ($pdf->getPageHeight() - $this->_topMargin - $this->_bottomMargin)) * 100) / 100; $pdf->setScale($this->_scale, $this->_xMin, $this->_yMin, $this->_leftMargin, $this->_topMargin); // Builds and save the PDF document $pdf->setLineWidthScale(0.1); if ($this->_showGrid) { $pdf->SetFontSize(10); $this->_strokeGrid(); } $pdf->setFontSizeScale(14); // previous logic was checking master tables and foreign tables // but I think that looping on every table of the pdf page as a master // and finding its foreigns is OK (then we can support innodb) $seen_a_relation = false; foreach ($alltables as $one_table) { $exist_rel = PMA_getForeigners($GLOBALS['db'], $one_table, '', 'both'); if (!$exist_rel) { continue; } $seen_a_relation = true; foreach ($exist_rel as $master_field => $rel) { // put the foreign table on the schema only if selected // by the user // (do not use array_search() because we would have to // to do a === false and this is not PHP3 compatible) if ($master_field != 'foreign_keys_data') { if (in_array($rel['foreign_table'], $alltables)) { $this->_addRelation($one_table, $master_field, $rel['foreign_table'], $rel['foreign_field']); } continue; } foreach ($rel as $one_key) { if (!in_array($one_key['ref_table_name'], $alltables)) { continue; } foreach ($one_key['index_list'] as $index => $one_field) { $this->_addRelation($one_table, $one_field, $one_key['ref_table_name'], $one_key['ref_index_list'][$index]); } } } // end while } // end while if ($seen_a_relation) { $this->_drawRelations(); } $this->_drawTables(); }