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 / yaml.php < prev   
Encoding:
PHP Script  |  2008-06-23  |  2.9 KB  |  155 lines

  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4.  * Set of functions used to build YAML dumps of tables
  5.  *
  6.  * @version $Id: yaml.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['yaml'] = array(
  17.         'text' => 'YAML',
  18.         'extension' => 'yml',
  19.         'mime_type' => 'text/yaml',
  20.         'force_file' => true,
  21.           'options' => array(
  22.             array('type' => 'hidden', 'name' => 'data'),
  23.             ),
  24.         'options_text' => 'strOptions',
  25.         );
  26. } else {
  27.  
  28. /**
  29.  * Set of functions used to build exports of tables
  30.  */
  31.  
  32. /**
  33.  * Outputs comment
  34.  *
  35.  * @param   string      Text of comment
  36.  *
  37.  * @return  bool        Whether it suceeded
  38.  */
  39. function PMA_exportComment($text)
  40. {
  41.     return TRUE;
  42. }
  43.  
  44. /**
  45.  * Outputs export footer
  46.  *
  47.  * @return  bool        Whether it suceeded
  48.  *
  49.  * @access  public
  50.  */
  51. function PMA_exportFooter()
  52. {
  53.     return TRUE;
  54. }
  55.  
  56. /**
  57.  * Outputs export header
  58.  *
  59.  * @return  bool        Whether it suceeded
  60.  *
  61.  * @access  public
  62.  */
  63. function PMA_exportHeader()
  64. {
  65.     return TRUE;
  66. }
  67.  
  68. /**
  69.  * Outputs database header
  70.  *
  71.  * @param   string      Database name
  72.  *
  73.  * @return  bool        Whether it suceeded
  74.  *
  75.  * @access  public
  76.  */
  77. function PMA_exportDBHeader($db)
  78. {
  79.     return TRUE;
  80. }
  81.  
  82. /**
  83.  * Outputs database footer
  84.  *
  85.  * @param   string      Database name
  86.  *
  87.  * @return  bool        Whether it suceeded
  88.  *
  89.  * @access  public
  90.  */
  91. function PMA_exportDBFooter($db)
  92. {
  93.     return TRUE;
  94. }
  95.  
  96. /**
  97.  * Outputs create database database
  98.  *
  99.  * @param   string      Database name
  100.  *
  101.  * @return  bool        Whether it suceeded
  102.  *
  103.  * @access  public
  104.  */
  105. function PMA_exportDBCreate($db)
  106. {
  107.     return TRUE;
  108. }
  109.  
  110. /**
  111.  * Outputs the content of a table in YAML format
  112.  *
  113.  * @param   string      the database name
  114.  * @param   string      the table name
  115.  * @param   string      the end of line sequence
  116.  * @param   string      the url to go back in case of error
  117.  * @param   string      SQL query for obtaining data
  118.  *
  119.  * @return  bool        Whether it suceeded
  120.  *
  121.  * @access  public
  122.  */
  123. function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
  124. {
  125.     $result      = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
  126.  
  127.     $columns_cnt = PMA_DBI_num_fields($result);
  128.     for ($i = 0; $i < $columns_cnt; $i++) {
  129.         $columns[$i] = stripslashes(PMA_DBI_field_name($result, $i));
  130.     }
  131.     unset($i);
  132.  
  133.     $cnt = 0;
  134.     $buffer = '';
  135.     while ($record = PMA_DBI_fetch_row($result)) {
  136.         $cnt++;
  137.         $buffer = $cnt . ":$crlf";
  138.         for ($i = 0; $i < $columns_cnt; $i++) {
  139.             if (isset($record[$i]) && !is_null($record[$i])) {
  140.                 $buffer .= '  ' . $columns[$i] . ': '  . htmlspecialchars($record[$i]) . $crlf;
  141.             }
  142.         }
  143.  
  144.         if (!PMA_exportOutputHandler($buffer)) {
  145.             return FALSE;
  146.         }
  147.     }
  148.     PMA_DBI_free_result($result);
  149.  
  150.     return TRUE;
  151. }
  152.  
  153. }
  154. ?>
  155.