⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pdf_schema.php

📁 WEBGAME源码,有架设说明,只是非常简单
💻 PHP
📖 第 1 页 / 共 4 页
字号:
<?php/* $Id: pdf_schema.php 9658 2006-11-02 12:56:57Z nijel $ */// vim: expandtab sw=4 ts=4 sts=4:/** * Contributed by Maxime Delorme and merged by lem9 *//** * Gets some core scripts */require_once('./libraries/common.lib.php');/** * Settings for relation stuff */require_once('./libraries/relation.lib.php');require_once('./libraries/transformations.lib.php');$cfgRelation = PMA_getRelationsParam();/** * Now in ./libraries/relation.lib.php we check for all tables * that we need, but if we don't find them we are quiet about it * so people can work without. * This page is absolutely useless if you didn't set up your tables * correctly, so it is a good place to see which tables we can and * complain ;-) */if (!$cfgRelation['pdfwork']) {    echo '<font color="red">' . $strError . '</font><br />' . "\n";    $url_to_goto = '<a href="' . $cfg['PmaAbsoluteUri'] . 'chk_rel.php?' . $url_query . '">';    echo sprintf($strRelationNotWorking, $url_to_goto, '</a>') . "\n";}/** * Font used in PDF. * * @todo Make this configuratble (at least Sans/Serif). */define('PMA_PDF_FONT', 'DejaVuSans');require_once('./libraries/tcpdf/tcpdf.php');/** * Extends the "FPDF" class and prepares the work * * @access public * @see FPDF */class PMA_PDF extends TCPDF {    /**     * Defines private properties     */    var $x_min;    var $y_min;    var $l_marg = 10;    var $t_marg = 10;    var $scale;    var $title;    var $PMA_links;    var $Outlines = array();    var $def_outlines;    var $Alias ;    var $widths;    /**     * The PMA_PDF constructor     *     * This function just refers to the "FPDF" constructor: with PHP3 a class     * must have a constructor     *     * @param string $ The page orientation (p, portrait, l or landscape)     * @param string $ The unit for sizes (pt, mm, cm or in)     * @param mixed $ The page format (A3, A4, A5, letter, legal or an array     *                  with page sizes)     * @access public     * @see FPDF::FPDF()     */    function PMA_PDF($orientation = 'L', $unit = 'mm', $format = 'A4')    {        $this->Alias = array() ;        $this->TCPDF($orientation, $unit, $format);    } // end of the "PMA_PDF()" method    function SetAlias($name, $value)    {        $this->Alias[$name] = $value ;    }    function _putpages()    {        if (count($this->Alias) > 0) {            $nb = $this->page;            foreach ($this->Alias AS $alias => $value) {                for ($n = 1;$n <= $nb;$n++)					$this->pages[$n]=str_replace($alias, $value, $this->pages[$n]);            }        }        parent::_putpages();    }    /**     * Sets the scaling factor, defines minimum coordinates and margins     *     * @param double $ The scaling factor     * @param double $ The minimum X coordinate     * @param double $ The minimum Y coordinate     * @param double $ The left margin     * @param double $ The top margin     * @access public     */    function PMA_PDF_setScale($scale = 1, $x_min = 0, $y_min = 0, $l_marg = -1, $t_marg = -1)    {        $this->scale = $scale;        $this->x_min = $x_min;        $this->y_min = $y_min;        if ($this->l_marg != -1) {            $this->l_marg = $l_marg;        }        if ($this->t_marg != -1) {            $this->t_marg = $t_marg;        }    } // end of the "PMA_PDF_setScale" function    /**     * Outputs a scaled cell     *     * @param double $ The cell width     * @param double $ The cell height     * @param string $ The text to output     * @param mixed $ Wether to add borders or not     * @param integer $ Where to put the cursor once the output is done     * @param string $ Align mode     * @param integer $ Whether to fill the cell with a color or not     * @access public     * @see FPDF::Cell()     */    function PMA_PDF_cellScale($w, $h = 0, $txt = '', $border = 0, $ln = 0, $align = '', $fill = 0, $link = '')    {        $h = $h / $this->scale;        $w = $w / $this->scale;        $this->Cell($w, $h, $txt, $border, $ln, $align, $fill, $link);    } // end of the "PMA_PDF_cellScale" function    /**     * Draws a scaled line     *     * @param double $ The horizontal position of the starting point     * @param double $ The vertical position of the starting point     * @param double $ The horizontal position of the ending point     * @param double $ The vertical position of the ending point     * @access public     * @see FPDF::Line()     */    function PMA_PDF_lineScale($x1, $y1, $x2, $y2)    {        $x1 = ($x1 - $this->x_min) / $this->scale + $this->l_marg;        $y1 = ($y1 - $this->y_min) / $this->scale + $this->t_marg;        $x2 = ($x2 - $this->x_min) / $this->scale + $this->l_marg;        $y2 = ($y2 - $this->y_min) / $this->scale + $this->t_marg;        $this->Line($x1, $y1, $x2, $y2);    } // end of the "PMA_PDF_lineScale" function    /**     * Sets x and y scaled positions     *     * @param double $ The x position     * @param double $ The y position     * @access public     * @see FPDF::SetXY()     */    function PMA_PDF_setXyScale($x, $y)    {        $x = ($x - $this->x_min) / $this->scale + $this->l_marg;        $y = ($y - $this->y_min) / $this->scale + $this->t_marg;        $this->SetXY($x, $y);    } // end of the "PMA_PDF_setXyScale" function    /**     * Sets the X scaled positions     *     * @param double $ The x position     * @access public     * @see FPDF::SetX()     */    function PMA_PDF_setXScale($x)    {        $x = ($x - $this->x_min) / $this->scale + $this->l_marg;        $this->SetX($x);    } // end of the "PMA_PDF_setXScale" function    /**     * Sets the scaled font size     *     * @param double $ The font size (in points)     * @access public     * @see FPDF::SetFontSize()     */    function PMA_PDF_setFontSizeScale($size)    {        // Set font size in points        $size = $size / $this->scale;        $this->SetFontSize($size);    } // end of the "PMA_PDF_setFontSizeScale" function    /**     * Sets the scaled line width     *     * @param double $ The line width     * @access public     * @see FPDF::SetLineWidth()     */    function PMA_PDF_setLineWidthScale($width)    {        $width = $width / $this->scale;        $this->SetLineWidth($width);    } // end of the "PMA_PDF_setLineWidthScale" function    /**     * 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 charset to convert to     * @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, $convcharset, $db;        global $charset, $text_dir, $strRunning, $strDatabase;        require_once('./libraries/header.inc.php');        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_structure.php?' . PMA_generate_common_url($db)         . '">' . $GLOBALS['strBack'] . '</a>';        echo "\n";        require_once('./libraries/footer.inc.php');    } // end of the "PMA_PDF_die()" function    /**     * Aliases the "Error()" function from the FPDF class to the     * "PMA_PDF_die()" one     *     * @param string $ the error mesage     * @access public     * @see PMA_PDF_die     */    function Error($error_message = '')    {        $this->PMA_PDF_die($error_message);    } // end of the "Error()" method    function Header()    {        // $datefmt        // We only show this if we find something in the new pdf_pages table        // This function must be named "Header" to work with the FPDF library        global $cfgRelation, $db, $pdf_page_number, $with_doc;        if ($with_doc) {            $test_query = 'SELECT * FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['pdf_pages'])             . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''             . ' AND page_nr = \'' . $pdf_page_number . '\'';            $test_rs = PMA_query_as_cu($test_query);            $pages = @PMA_DBI_fetch_assoc($test_rs);            $this->SetFont('', 'B', 14);            $this->Cell(0, 6, ucfirst($pages['page_descr']), 'B', 1, 'C');            $this->SetFont('', '');            $this->Ln();        }    }    function Footer()    {        // This function must be named "Footer" to work with the FPDF library        global $with_doc;        if ($with_doc) {            $this->SetY(-15);            $this->SetFont('', '', 14);            $this->Cell(0, 6, $GLOBALS['strPageNumber'] . ' ' . $this->PageNo() . '/{nb}', 'T', 0, 'C');            $this->Cell(0, 6, PMA_localisedDate(), 0, 1, 'R');            $this->SetY(20);        }    }    function Bookmark($txt, $level = 0, $y = 0)    {        // Add a bookmark        $this->Outlines[0][] = $level;        $this->Outlines[1][] = $txt;        $this->Outlines[2][] = $this->page;        if ($y == -1) {            $y = $this->GetY();        }        $this->Outlines[3][] = round($this->hPt - $y * $this->k, 2);    }    function _putbookmarks()    {        if (count($this->Outlines) > 0) {            // Save object number            $memo_n = $this->n;            // Take the number of sub elements for an outline            $nb_outlines = sizeof($this->Outlines[0]);            $first_level = array();            $parent = array();            $parent[0] = 1;            for ($i = 0; $i < $nb_outlines; $i++) {                $level = $this->Outlines[0][$i];                $kids = 0;                $last = -1;                $prev = -1;                $next = -1;                if ($i > 0) {                    $cursor = $i-1;                    // Take the previous outline in the same level                    while ($this->Outlines[0][$cursor] > $level && $cursor > 0)                    $cursor--;                    if ($this->Outlines[0][$cursor] == $level) {                        $prev = $cursor;                    }                }                if ($i < $nb_outlines-1) {                    $cursor = $i + 1;                    while (isset($this->Outlines[0][$cursor]) && $this->Outlines[0][$cursor] > $level) {                        // Take the immediate kid in level + 1                        if ($this->Outlines[0][$cursor] == $level + 1) {                            $kids++;                            $last = $cursor;                        }                        $cursor++;                    }                    $cursor = $i + 1;                    // Take the next outline in the same level                    while ($this->Outlines[0][$cursor] > $level && ($cursor + 1 < sizeof($this->Outlines[0])))                    $cursor++;                    if ($this->Outlines[0][$cursor] == $level) {                        $next = $cursor;                    }                }                $this->_newobj();                $parent[$level + 1] = $this->n;                if ($level == 0) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -