-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathapp_create_beans.php
132 lines (111 loc) · 4.63 KB
/
app_create_beans.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?php
include_once("mysqlreflection.config.php");
define("DESTINATION_PATH",dirname(__FILE__) . "/beans/");
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/html">
<head>
<title>MySQL Database Bean Builder</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Bootstrap core CSS -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet" media="screen">
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.2/html5shiv.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.js"></script>
<![endif]-->
<style>
.progress {
background: rgba(204, 237, 220, 1);
border: 5px solid rgba(56, 46, 166, 0.27);
border-radius: 10px; height: 36px;
}
</style>
<script>
var globalCount =0 ;
var globalPercent = 0;
</script>
<body>
<div class="container">
<h1>MySQL Database Beans generator</h1>
<h3>This utility performs automatically a source code generation of PHP
Classes from MySQL tables </h3>
<h4>Current database :<?= DBNAME ?> (to change it edit mysqlreflection.config.php)</h4>
<h4>Destination path :<?= DESTINATION_PATH ?></h4>
<a class="btn btn-success" onclick="document.getElementById('results').value = ''" href="?build=1"><span class="glyphicon glyphicon-wrench"></span> Generate classes</a>
<a href="../builders/index" class="btn btn-info"><span class="glyphicon glyphicon-home"></span> Home</a>
<br /> <br />
<div class="progress progress-striped">
<div class="progress-bar" role="progressbar" aria-valuenow="0"
aria-valuemin="0" aria-valuemax="100" style="width:0%">
</div>
</div>
<div class="text-center">
<textarea cols="140" rows="20" id="results" name "results"></textarea>
</div>
</div>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.4/js/bootstrap.min.js"></script>
<script>
function aggiornaProgressBar(done=false) {
var step = 2;
var progress = $('.progress-bar');
var currentValue = parseInt(progress.attr("aria-valuenow"));
globalCount = globalCount +1;
globalPercent = globalPercent +1;
if (currentValue==100) {
currentValue = 50;
}
currentValue += 1;
progress.attr("aria-valuenow",currentValue);
var percValue = currentValue + '%';
progress.css('width',percValue);
var textarea = document.getElementById('results');
textarea.scrollTop = textarea.scrollHeight;
if (done) {
progress.attr("aria-valuenow",100);
progress.css('width',"100%");
percValue = "Done. " + globalCount + " classes were generated";
}
progress.html(percValue);
}
function aggiornaTextArea(msg){
var m = msg + '
';
$('#results').append(m);
}
function setNumberOfTables(ntables){
if (numberOfTables === 'undefined' || !numberOfTables)
var numberOfTables=ntables;
}
</script>
</body>
<?php
if (isset($_GET["build"])) {
/**
* Demo application: generate classes from a mysql db schema
*/
// CLI mode
// error_reporting(E_ALL);
// include_once("mysqlreflection/mysqlreflection.config.php");
// header('Content-Type: text/html; charset=utf-8');
$msg = "Building classes for mysql schema:[" . DBNAME . "]";
// CLI mode
// echo $msg;
echo "<script>$('#results').append('" . $msg . "');</script>";
// Destination path for the generated classes
$destinationPath = DESTINATION_PATH;
// $destinationPath = "source/";
// Create reflection object and invoke classes generation from the specified schema into mysql_connection.inc.php
$reflection = new MVCMySqlSchemaReflection();
// Generates the classes into the given path. During the generation it outputs the results.
$reflection->generateClassesFromSchema($destinationPath);
// CLI Mode
// echo "<hr>Done.";
// echo "<script> window.scrollTo(0,document.body.scrollHeight);</script>";
echo "<script>$('#results').append('" . "Done." . "
" . "');</script>";
echo "<script>aggiornaProgressBar(true);</script>";
}
?>