home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Servidores / xampp-win32-1.6.7-installer.exe / phpMyAdmin / libraries / export / htmlexcel.php < prev    next >
Encoding:
PHP Script  |  2008-06-23  |  4.5 KB  |  190 lines

  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4.  * Set of functions used to build CSV dumps of tables
  5.  *
  6.  * @version $Id: htmlexcel.php 11326 2008-06-17 21:32:48Z lem9 $
  7.  */
  8. if (! defined('PHPMYADMIN')) {
  9.     exit;
  10. }
  11.  
  12. /**
  13.  *
  14.  */
  15. if (isset($plugin_list)) {
  16.     $plugin_list['htmlexcel'] = array(
  17.         'text' => 'strHTMLExcel',
  18.         'extension' => 'xls',
  19.         'mime_type' => 'application/vnd.ms-excel',
  20.         'force_file' => true,
  21.         'options' => array(
  22.             array('type' => 'text', 'name' => 'null', 'text' => 'strReplaceNULLBy'),
  23.             array('type' => 'bool', 'name' => 'columns', 'text' => 'strPutColNames'),
  24.             array('type' => 'hidden', 'name' => 'data'),
  25.             ),
  26.         'options_text' => 'strOptions',
  27.         );
  28. } else {
  29.  
  30. /**
  31.  * Outputs comment
  32.  *
  33.  * @param   string      Text of comment
  34.  *
  35.  * @return  bool        Whether it suceeded
  36.  */
  37. function PMA_exportComment($text) {
  38.     return TRUE;
  39. }
  40.  
  41. /**
  42.  * Outputs export footer
  43.  *
  44.  * @return  bool        Whether it suceeded
  45.  *
  46.  * @access  public
  47.  */
  48. function PMA_exportFooter() {
  49.     if (!PMA_exportOutputHandler('
  50. </table>
  51. </div>
  52. </body>
  53. </html>
  54. ')) {
  55.         return FALSE;
  56.     }
  57.     return TRUE;
  58. }
  59.  
  60. /**
  61.  * Outputs export header
  62.  *
  63.  * @return  bool        Whether it suceeded
  64.  *
  65.  * @access  public
  66.  */
  67. function PMA_exportHeader() {
  68.     global $charset, $charset_of_file;
  69.     if (!PMA_exportOutputHandler('
  70. <html xmlns:o="urn:schemas-microsoft-com:office:office"
  71. xmlns:x="urn:schemas-microsoft-com:office:excel"
  72. xmlns="http://www.w3.org/TR/REC-html40">
  73.  
  74. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  75. <html>
  76. <head>
  77.     <meta http-equiv="Content-type" content="text/html;charset=' . (isset($charset_of_file) ? $charset_of_file : $charset) .'" />
  78. <style id="Classeur1_16681_Styles">
  79. </style>
  80.  
  81. </head>
  82. <body>
  83.  
  84. <div id="Classeur1_16681" align=center x:publishsource="Excel">
  85.  
  86. <table x:str border=0 cellpadding=0 cellspacing=0 width=100% style="border-collapse: collapse">
  87. ')) {
  88.         return FALSE;
  89.     }
  90.  
  91.     return TRUE;
  92. }
  93.  
  94. /**
  95.  * Outputs database header
  96.  *
  97.  * @param   string      Database name
  98.  *
  99.  * @return  bool        Whether it suceeded
  100.  *
  101.  * @access  public
  102.  */
  103. function PMA_exportDBHeader($db) {
  104.     return TRUE;
  105. }
  106.  
  107. /**
  108.  * Outputs database footer
  109.  *
  110.  * @param   string      Database name
  111.  *
  112.  * @return  bool        Whether it suceeded
  113.  *
  114.  * @access  public
  115.  */
  116. function PMA_exportDBFooter($db) {
  117.     return TRUE;
  118. }
  119.  
  120. /**
  121.  * Outputs create database database
  122.  *
  123.  * @param   string      Database name
  124.  *
  125.  * @return  bool        Whether it suceeded
  126.  *
  127.  * @access  public
  128.  */
  129. function PMA_exportDBCreate($db) {
  130.     return TRUE;
  131. }
  132.  
  133. /**
  134.  * Outputs the content of a table in CSV format
  135.  *
  136.  * @param   string      the database name
  137.  * @param   string      the table name
  138.  * @param   string      the end of line sequence
  139.  * @param   string      the url to go back in case of error
  140.  * @param   string      SQL query for obtaining data
  141.  *
  142.  * @return  bool        Whether it suceeded
  143.  *
  144.  * @access  public
  145.  */
  146. function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
  147.     global $what;
  148.  
  149.     // Gets the data from the database
  150.     $result      = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
  151.     $fields_cnt  = PMA_DBI_num_fields($result);
  152.  
  153.     // If required, get fields name at the first line
  154.     if (isset($GLOBALS[$what . '_columns'])) {
  155.         $schema_insert = '<tr>';
  156.         for ($i = 0; $i < $fields_cnt; $i++) {
  157.             $schema_insert .= '<td class=xl2216681 nowrap><b>' . htmlspecialchars(stripslashes(PMA_DBI_field_name($result, $i))) . '</b></td>';
  158.         } // end for
  159.         $schema_insert .= '</tr>';
  160.         if (!PMA_exportOutputHandler($schema_insert)) {
  161.             return FALSE;
  162.         }
  163.     } // end if
  164.  
  165.     // Format the data
  166.     while ($row = PMA_DBI_fetch_row($result)) {
  167.         $schema_insert = '<tr>';
  168.         for ($j = 0; $j < $fields_cnt; $j++) {
  169.             if (!isset($row[$j]) || is_null($row[$j])) {
  170.                 $value = $GLOBALS[$what . '_null'];
  171.             } elseif ($row[$j] == '0' || $row[$j] != '') {
  172.                 $value = $row[$j];
  173.             } else {
  174.                 $value = '';
  175.             }
  176.             $schema_insert .= '<td class=xl2216681 nowrap>' . htmlspecialchars($value) . '</td>';
  177.         } // end for
  178.         $schema_insert .= '</tr>';
  179.         if (!PMA_exportOutputHandler($schema_insert)) {
  180.             return FALSE;
  181.         }
  182.     } // end while
  183.     PMA_DBI_free_result($result);
  184.  
  185.     return TRUE;
  186. }
  187.  
  188. }
  189. ?>
  190.