📄 latex.php
字号:
<?php/* $Id: latex.php 8995 2006-04-28 08:51:35Z nijel $ */// vim: expandtab sw=4 ts=4 sts=4:/** * Set of functions used to build dumps of tables */if (isset($plugin_list)) { $hide_structure = false; if ($plugin_param['export_type'] == 'table' && !$plugin_param['single_table']) { $hide_structure = true; } $plugin_list['latex'] = array( 'text' => 'strLaTeX', 'extension' => 'tex', 'mime_type' => 'application/x-tex', 'options' => array( array('type' => 'bool', 'name' => 'caption', 'text' => 'strLatexIncludeCaption'), ), 'options_text' => 'strLaTeXOptions', ); /* Structure options */ if (!$hide_structure) { $plugin_list['latex']['options'][] = array('type' => 'bgroup', 'name' => 'structure', 'text' => 'strStructure', 'force' => 'data'); $plugin_list['latex']['options'][] = array('type' => 'text', 'name' => 'structure_caption', 'text' => 'strLatexCaption'); $plugin_list['latex']['options'][] = array('type' => 'text', 'name' => 'structure_continued_caption', 'text' => 'strLatexContinuedCaption'); $plugin_list['latex']['options'][] = array('type' => 'text', 'name' => 'structure_label', 'text' => 'strLatexLabel'); if (!empty($GLOBALS['cfgRelation']['relation'])) { $plugin_list['latex']['options'][] = array('type' => 'bool', 'name' => 'relation', 'text' => 'strRelations'); } if (!empty($GLOBALS['cfgRelation']['commwork']) || PMA_MYSQL_INT_VERSION >= 40100) { $plugin_list['latex']['options'][] = array('type' => 'bool', 'name' => 'comments', 'text' => 'strComments'); } if (!empty($GLOBALS['cfgRelation']['mimework'])) { $plugin_list['latex']['options'][] = array('type' => 'bool', 'name' => 'mime', 'text' => 'strMIME_MIMEtype'); } $plugin_list['latex']['options'][] = array('type' => 'egroup'); } /* Data */ $plugin_list['latex']['options'][] = array('type' => 'bgroup', 'name' => 'data', 'text' => 'strData', 'force' => 'structure'); $plugin_list['latex']['options'][] = array('type' => 'bool', 'name' => 'columns', 'text' => 'strPutColNames'); $plugin_list['latex']['options'][] = array('type' => 'text', 'name' => 'data_caption', 'text' => 'strLatexCaption'); $plugin_list['latex']['options'][] = array('type' => 'text', 'name' => 'data_continued_caption', 'text' => 'strLatexContinuedCaption'); $plugin_list['latex']['options'][] = array('type' => 'text', 'name' => 'data_label', 'text' => 'strLatexLabel'); $plugin_list['latex']['options'][] = array('type' => 'text', 'name' => 'null', 'text' => 'strReplaceNULLBy'); $plugin_list['latex']['options'][] = array('type' => 'egroup');} else {/** * Escapes some special characters for use in TeX/LaTeX * * @param string the string to convert * * @return string the converted string with escape codes * * @access private */function PMA_texEscape($string) { $escape = array('$', '%', '{', '}', '&', '#', '_', '^'); $cnt_escape = count($escape); for ($k=0; $k < $cnt_escape; $k++) { $string = str_replace($escape[$k], '\\' . $escape[$k], $string); } return $string;}/** * Outputs comment * * @param string Text of comment * * @return bool Whether it suceeded */function PMA_exportComment($text) { return PMA_exportOutputHandler('% ' . $text . $GLOBALS['crlf']);}/** * Outputs export footer * * @return bool Whether it suceeded * * @access public */function PMA_exportFooter() { return TRUE;}/** * Outputs export header * * @return bool Whether it suceeded * * @access public */function PMA_exportHeader() { global $crlf; global $cfg; $head = '% phpMyAdmin LaTeX Dump' . $crlf . '% version ' . PMA_VERSION . $crlf . '% http://www.phpmyadmin.net' . $crlf . '%' . $crlf . '% ' . $GLOBALS['strHost'] . ': ' . $cfg['Server']['host']; if (!empty($cfg['Server']['port'])) { $head .= ':' . $cfg['Server']['port']; } $head .= $crlf . '% ' . $GLOBALS['strGenTime'] . ': ' . PMA_localisedDate() . $crlf . '% ' . $GLOBALS['strServerVersion'] . ': ' . substr(PMA_MYSQL_INT_VERSION, 0, 1) . '.' . (int) substr(PMA_MYSQL_INT_VERSION, 1, 2) . '.' . (int) substr(PMA_MYSQL_INT_VERSION, 3) . $crlf . '% ' . $GLOBALS['strPHPVersion'] . ': ' . phpversion() . $crlf; return PMA_exportOutputHandler($head);}/** * Outputs database header * * @param string Database name * * @return bool Whether it suceeded * * @access public */function PMA_exportDBHeader($db) { global $crlf; $head = '% ' . $crlf . '% ' . $GLOBALS['strDatabase'] . ': ' . (isset($GLOBALS['use_backquotes']) ? PMA_backquote($db) : '\'' . $db . '\''). $crlf . '% ' . $crlf; return PMA_exportOutputHandler($head);}/** * Outputs database footer * * @param string Database name * * @return bool Whether it suceeded * * @access public */function PMA_exportDBFooter($db) { return TRUE;}/** * Outputs create database database * * @param string Database name * * @return bool Whether it suceeded * * @access public */function PMA_exportDBCreate($db) { return TRUE;}/** * Outputs the content of a table in LaTeX table/sideways table environment * * @param string the database name * @param string the table name * @param string the end of line sequence * @param string the url to go back in case of error * @param string SQL query for obtaining data * * @return bool Whether it suceeded * * @access public */function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) { $result = PMA_DBI_try_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED); $columns_cnt = PMA_DBI_num_fields($result); for ($i = 0; $i < $columns_cnt; $i++) { $columns[$i] = PMA_DBI_field_name($result, $i); } unset($i); $buffer = $crlf . '%' . $crlf . '% ' . $GLOBALS['strData'] . ': ' . $table . $crlf . '%' . $crlf . ' \\begin{longtable}{|'; for ($index=0;$index<$columns_cnt;$index++) { $buffer .= 'l|'; } $buffer .= '} ' . $crlf ; $buffer .= ' \\hline \\endhead \\hline \\endfoot \\hline ' . $crlf; if (isset($GLOBALS['latex_caption'])) { $buffer .= ' \\caption{' . str_replace('__TABLE__', PMA_texEscape($table), $GLOBALS['latex_data_caption']) . '} \\label{' . str_replace('__TABLE__', $table, $GLOBALS['latex_data_label']) . '} \\\\'; } if (!PMA_exportOutputHandler($buffer)) { return FALSE; } // show column names if (isset($GLOBALS['latex_columns'])) { $buffer = '\\hline '; for ($i = 0; $i < $columns_cnt; $i++) { $buffer .= '\\multicolumn{1}{|c|}{\\textbf{' . PMA_texEscape(stripslashes($columns[$i])) . '}} & '; } $buffer = substr($buffer, 0, -2) . '\\\\ \\hline \hline '; if (!PMA_exportOutputHandler($buffer . ' \\endfirsthead ' . $crlf)) { return FALSE; } if (isset($GLOBALS['latex_caption'])) { if (!PMA_exportOutputHandler('\\caption{' . str_replace('__TABLE__', PMA_texEscape($table), $GLOBALS['latex_data_continued_caption']) . '} \\\\ ')) return FALSE; } if (!PMA_exportOutputHandler($buffer . '\\endhead \\endfoot' . $crlf)) { return FALSE; } } else { if (!PMA_exportOutputHandler('\\\\ \hline')) { return FALSE; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -