📄 pdf_schema.php
字号:
$first_level[] = $this->n; } $this->_out('<<'); $this->_out('/Title (' . $this->Outlines[1][$i] . ')'); $this->_out('/Parent ' . $parent[$level] . ' 0 R'); if ($prev != -1) { $this->_out('/Prev ' . ($memo_n + $prev + 1) . ' 0 R'); } if ($next != -1) { $this->_out('/Next ' . ($this->n + $next - $i) . ' 0 R'); } $this->_out('/Dest [' . (1 + (2 * $this->Outlines[2][$i])) . ' 0 R /XYZ null ' . $this->Outlines[3][$i] . ' null]'); if ($kids > 0) { $this->_out('/First ' . ($this->n + 1) . ' 0 R'); $this->_out('/Last ' . ($this->n + $last - $i) . ' 0 R'); $this->_out('/Count -' . $kids); } $this->_out('>>'); $this->_out('endobj'); } // First page of outlines $this->_newobj(); $this->def_outlines = $this->n; $this->_out('<<'); $this->_out('/Type'); $this->_out('/Outlines'); $this->_out('/First ' . $first_level[0] . ' 0 R'); $this->_out('/Last ' . $first_level[sizeof($first_level)-1] . ' 0 R'); $this->_out('/Count ' . sizeof($first_level)); $this->_out('>>'); $this->_out('endobj'); } } function _putresources() { parent::_putresources(); $this->_putbookmarks(); } function _putcatalog() { parent::_putcatalog(); if (count($this->Outlines) > 0) { $this->_out('/Outlines ' . $this->def_outlines . ' 0 R'); $this->_out('/PageMode /UseOutlines'); } } function SetWidths($w) { // column widths $this->widths = $w; } function Row($data, $links) { // line height $nb = 0; $data_cnt = count($data); for ($i = 0;$i < $data_cnt;$i++) $nb = max($nb, $this->NbLines($this->widths[$i], $data[$i])); $il = $this->FontSize; $h = ($il + 1) * $nb; // page break if necessary $this->CheckPageBreak($h); // draw the cells $data_cnt = count($data); for ($i = 0;$i < $data_cnt;$i++) { $w = $this->widths[$i]; // save current position $x = $this->GetX(); $y = $this->GetY(); // draw the border $this->Rect($x, $y, $w, $h); if (isset($links[$i])) { $this->Link($x, $y, $w, $h, $links[$i]); } // print text $this->MultiCell($w, $il + 1, $data[$i], 0, 'L'); // go to right side $this->SetXY($x + $w, $y); } // go to line $this->Ln($h); } function CheckPageBreak($h) { // if height h overflows, manual page break if ($this->GetY() + $h > $this->PageBreakTrigger) { $this->AddPage($this->CurOrientation); } } function NbLines($w, $txt) { // compute number of lines used by a multicell of width w $cw = &$this->CurrentFont['cw']; if ($w == 0) { $w = $this->w - $this->rMargin - $this->x; } $wmax = ($w-2 * $this->cMargin) * 1000 / $this->FontSize; $s = str_replace("\r", '', $txt); $nb = strlen($s); if ($nb > 0 and $s[$nb-1] == "\n") { $nb--; } $sep = -1; $i = 0; $j = 0; $l = 0; $nl = 1; while ($i < $nb) { $c = $s[$i]; if ($c == "\n") { $i++; $sep = -1; $j = $i; $l = 0; $nl++; continue; } if ($c == ' ') { $sep = $i; } $l += isset($cw[ord($c)])?$cw[ord($c)]:0 ; if ($l > $wmax) { if ($sep == -1) { if ($i == $j) { $i++; } } else { $i = $sep + 1; } $sep = -1; $j = $i; $l = 0; $nl++; } else { $i++; } } return $nl; }} // end of the "PMA_PDF" class/** * Draws tables schema * * @access private * @see PMA_RT */class PMA_RT_Table { /** * Defines private properties */ var $nb_fiels; var $table_name; var $width = 0; var $height; var $fields = array(); var $height_cell = 6; var $x, $y; var $primary = array(); /** * Sets the width of the table * * @param integer $ The font size * @global object The current PDF document * @access private * @see PMA_PDF */ function PMA_RT_Table_setWidth($ff) { // this looks buggy to me... does it really work if // there are fields that require wider cells than the name of the table? global $pdf; foreach ($this->fields AS $field) { $this->width = max($this->width, $pdf->GetStringWidth($field)); } $this->width += $pdf->GetStringWidth(' '); $pdf->SetFont($ff, 'B'); $this->width = max($this->width, $pdf->GetStringWidth(' ' . $this->table_name)); $pdf->SetFont($ff, ''); } // end of the "PMA_RT_Table_setWidth()" method /** * Sets the height of the table * * @access private */ function PMA_RT_Table_setHeight() { $this->height = (count($this->fields) + 1) * $this->height_cell; } // end of the "PMA_RT_Table_setHeight()" method /** * Do draw the table * * @param boolean $ Whether to display table position or not * @param integer $ The font size * @param boolean $ Whether to display color * @param integer $ The max. with among tables * @global object The current PDF document * @access private * @see PMA_PDF */ function PMA_RT_Table_draw($show_info, $ff, $setcolor = 0) { global $pdf, $with_doc; $pdf->PMA_PDF_setXyScale($this->x, $this->y); $pdf->SetFont($ff, 'B'); if ($setcolor) { $pdf->SetTextColor(200); $pdf->SetFillColor(0, 0, 128); } if ($with_doc) { $pdf->SetLink($pdf->PMA_links['RT'][$this->table_name]['-'], -1); } else { $pdf->PMA_links['doc'][$this->table_name]['-'] = ''; } if ($show_info) { $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]['-']); } else { $pdf->PMA_PDF_cellScale($this->width, $this->height_cell, $this->table_name, 1, 1, 'C', $setcolor, $pdf->PMA_links['doc'][$this->table_name]['-']); } $pdf->PMA_PDF_setXScale($this->x); $pdf->SetFont($ff, ''); $pdf->SetTextColor(0); $pdf->SetFillColor(255); foreach ($this->fields AS $field) { // loic1 : PHP3 fix // if (in_array($field, $this->primary)) { if ($setcolor) { if (in_array($field, $this->primary)) { $pdf->SetFillColor(215, 121, 123); } if ($field == $this->displayfield) { $pdf->SetFillColor(142, 159, 224); } } if ($with_doc) { $pdf->SetLink($pdf->PMA_links['RT'][$this->table_name][$field], -1); } else { $pdf->PMA_links['doc'][$this->table_name][$field] = ''; } $pdf->PMA_PDF_cellScale($this->width, $this->height_cell, ' ' . $field, 1, 1, 'L', $setcolor, $pdf->PMA_links['doc'][$this->table_name][$field]); $pdf->PMA_PDF_setXScale($this->x); $pdf->SetFillColor(255); } // end while /*if ($pdf->PageNo() > 1) { $pdf->PMA_PDF_die($GLOBALS['strScaleFactorSmall']); } */ } // end of the "PMA_RT_Table_draw()" method /** * The "PMA_RT_Table" constructor * * @param string $ The table name * @param integer $ The font size * @param integer $ The max. with among tables * @global object The current PDF document * @global integer The current page number (from the * $cfg['Servers'][$i]['table_coords'] table) * @global array The relations settings * @global string The current db name * @access private * @see PMA_PDF, PMA_RT_Table::PMA_RT_Table_setWidth, PMA_RT_Table::PMA_RT_Table_setHeight */ function PMA_RT_Table($table_name, $ff, &$same_wide_width) { global $pdf, $pdf_page_number, $cfgRelation, $db; $this->table_name = $table_name; $sql = 'DESCRIBE ' . PMA_backquote($table_name); $result = PMA_DBI_try_query($sql, null, PMA_DBI_QUERY_STORE); if (!$result || !PMA_DBI_num_rows($result)) { $pdf->PMA_PDF_die(sprintf($GLOBALS['strPdfInvalidTblName'], $table_name)); } // load fields while ($row = PMA_DBI_fetch_row($result)) { $this->fields[] = $row[0]; } // height and width $this->PMA_RT_Table_setWidth($ff); $this->PMA_RT_Table_setHeight(); if ($same_wide_width < $this->width) { $same_wide_width = $this->width; } // x and y $sql = 'SELECT x, y FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords']) . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'' . ' AND table_name = \'' . PMA_sqlAddslashes($table_name) . '\'' . ' AND pdf_page_number = ' . $pdf_page_number; $result = PMA_query_as_cu($sql, false, PMA_DBI_QUERY_STORE); if (!$result || !PMA_DBI_num_rows($result)) { $pdf->PMA_PDF_die(sprintf($GLOBALS['strConfigureTableCoord'], $table_name)); } list($this->x, $this->y) = PMA_DBI_fetch_row($result); $this->x = (double) $this->x; $this->y = (double) $this->y; // displayfield $this->displayfield = PMA_getDisplayField($db, $table_name); // index $result = PMA_DBI_query('SHOW INDEX FROM ' . PMA_backquote($table_name) . ';', null, PMA_DBI_QUERY_STORE); if (PMA_DBI_num_rows($result) > 0) { while ($row = PMA_DBI_fetch_assoc($result)) { if ($row['Key_name'] == 'PRIMARY') { $this->primary[] = $row['Column_name']; } } } // end if } // end of the "PMA_RT_Table()" method} // end class "PMA_RT_Table"/** * Draws relation links * * @access private * @see PMA_RT */class PMA_RT_Relation { /** * Defines private properties */ var $x_src, $y_src; var $src_dir ; var $dest_dir; var $x_dest, $y_dest; var $w_tick = 5; /** * Gets arrows coordinates * * @param string $ The current table name * @param string $ The relation column name * @return array Arrows coordinates * @access private */ function PMA_RT_Relation_getXy($table, $column) { $pos = array_search($column, $table->fields);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -