home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Freeware / Programare / groupoffice-com-2.01 / modules / daogen / generateCode.php < prev    next >
PHP Script  |  2004-03-08  |  2KB  |  97 lines

  1. <?php
  2. /*
  3. Copyright T & M Web Enterprises 2003
  4. Author: Mike Hostetler <mike@tm-web.com>
  5. Version: 1.0 Release date: 01 November 2003
  6.  
  7. This program is free software; you can redistribute it and/or modify it
  8. under the terms of the GNU General Public License as published by the
  9. Free Software Foundation; either version 2 of the License, or (at your
  10. option) any later version.
  11. */
  12.  
  13. /**
  14.  *
  15.  *@NAME:        generateCode
  16.  *@PURPOSE:        To call each of the actions and display the output
  17.  *@REMARKS:        This serves as the default action for the entire module
  18.  *
  19.  */
  20. $post = $_POST;
  21.  
  22. import('action','generateVo');
  23. import('action','generateDao');
  24.  
  25. //Remove empty column names
  26. foreach($post['db_colname'] as $k => $v) {
  27.     if($v == "") {
  28.         //We have an empty entry, remove it
  29.         unset($post['db_colname'][$k]);
  30.         unset($post['vartype_db_varname'][$k]);
  31.         unset($post['db_varname'][$k]);
  32.         unset($post['vo_label'][$k]);
  33.         $post['db_varcount']--;
  34.     }
  35. }
  36. foreach( $post['db_varname'] as $k => $v )
  37. {
  38.     if( $v == "" )
  39.     {
  40.         $post['db_varname'][$k] = $post['db_colname'][$k];
  41.     }
  42.  
  43. }
  44. echo "<br>";
  45. $tabtable = new tabtable('gen_type', 'DAO Generator', '600', '400');
  46. $tabtable->add_tab('new', 'New DAO');
  47. $tabtable->add_tab('sql', 'SQL Based');
  48. $tabtable->add_tab('base', 'Base Classes');
  49. $tabtable->print_head();
  50. ?>
  51. <div align="center"><a href="index.php">[Start Over]</a></div>
  52. <table border="0" cellpadding="5" cellspacing="0">
  53. <tr>
  54.     <td><h1>Data Access Object Code</h1>
  55.     <br>Copy this code into a file named the same as the classname
  56.     <br>(Value object is below)
  57.     </td>
  58. </tr>
  59. <tr>
  60.     <td>
  61.     <?php
  62. print "<pre>";
  63. echo '<textarea name="dao" cols=80 rows=15>';
  64. //print_r($post);
  65. print htmlspecialchars("<?php\n");
  66. $dao = generateDao($post['classname'],$post['tablename'],$post['pk_num'],$post['col_num'],$post['colname'],$post['varname'],$post['type_colname'],$post['ordering']);
  67. print ($dao);
  68. print htmlspecialchars("\n?>");
  69. echo '</textarea>';
  70. print "</pre>";
  71. ?>
  72.     </td>
  73. </tr>
  74. <tr>
  75.     <td><h1>Value Object Code</h1>
  76.     <br>Copy this code into a file named the same as the classname
  77.     </td>
  78. </tr>
  79. <tr>
  80.     <td>
  81.     <?php
  82. print "<pre>";
  83. print "<textarea name=\"valueObj\" cols=\"80\" rows=\"15\">";
  84. print htmlspecialchars("<?php\n");
  85. $vo = generateVo($post['classname'],$post['varname']);
  86. print ($vo);
  87. print htmlspecialchars("\n?>");
  88. echo '</textarea>';
  89. print "</pre>";
  90. ?>
  91.     </td>
  92. </tr>
  93. </table>
  94. <?php
  95. $tabtable->print_foot();
  96. ?>
  97.