4
* Cough Web Panel - A quick, simple, interface to the CoughGenerator
9
* @copyright Anthony Bush (http://anthonybush.com/), 30 April, 2007
13
// Get the cough generator classes
14
include('cough_generator_classes.php');
16
// Setup some web panel contants
17
define('CONFIG_FILE_SUFFIX', '.php');
18
define('CONFIG_PATH', dirname(__FILE__) . '/config/');
22
$configDir = dir(CONFIG_PATH);
23
while ($file = $configDir->read()) {
24
if (strpos($file, '.') !== 0 && strstr($file, CONFIG_FILE_SUFFIX) == CONFIG_FILE_SUFFIX) {
25
include_once(CONFIG_PATH . $file);
27
$configs[$file] = $config;
44
// Action: Generate Cough Classes
45
if (isset($_GET['generate'])) {
46
$databaseID = intval($_GET['generate']);
47
$generation = new CoughGeneration($databaseID);
48
$dbName = $generation->getDatabaseName();
49
$classPrefix = $generation->getClassPrefix();
50
$generator = new AcademicSuperstoreGenerator();
51
if ($generator->generate($dbName, $classPrefix)) {
52
$flashMessage = 'Success generating ' . $dbName . " classes.<br />\n";
53
$generation->setGenerationDate(date('Y-m-d H:i:s'));
54
$generation->setGeneratedBy($user);
57
$flashMessage = 'Failure generating ' . $dbName . " classes<br />\n";
58
$errorMessages = $generator->getErrorMessages();
59
if ( ! empty($errorMessages)) {
60
$flashMessage .= 'Error(s) reported by CoughGenerator:' . "<br />\n";
61
$flashMessage .= implode('<br />', $errorMessages) . "<br />\n";
64
$warnings = $generator->getWarnings();
65
$removedFiles = $generator->getRemovedFiles();
66
$modifiedFiles = $generator->getModifiedFiles();
67
$addedFiles = $generator->getAddedFiles();
76
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
77
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
79
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
81
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
82
<title>Cough Web Panel</title>
83
<style type="text/css" media="screen">
86
/* Generations Table */
88
border-top: 1px solid #999;
89
border-left: 1px solid #999;
94
border-right: 1px solid #999;
95
border-bottom: 1px solid #999;
99
border-right: 1px solid #999;
100
border-bottom: 1px solid #999;
105
border: 1px solid #999;
112
border-bottom: 1px solid #999;
115
border: 1px solid #999;
123
font-family: monospace;
134
<h1>Cough Web Panel</h1>
136
<p>This page contains a list of the databases for which we are currently letting CoughGenerator generate code for. To (re)generate code for a database and all its tables, click the 'Regenerate' link for that database. It will generate the results to the 'shared/models/generated/' folder on the '<?=$user?>' fork, at which point <?=$user?> will need to commit the generated code for others to use it.</p>
138
<table border="0" cellspacing="0" cellpadding="0" class="genenerations">
141
<th>Class Prefix</th>
142
<th>Last generated on</th>
143
<th>Last generated by</th>
146
<?php foreach ($generations as $generationID => $generation): ?>
148
<td><?=$generation->getDatabaseName()?></td>
149
<td><?=$generation->getClassPrefix()?></td>
150
<td><?=$generation->getGenerationDate()?></td>
151
<td><?=$generation->getGeneratedBy()?></td>
152
<td><a href="?page=cough_web_panel&generate=<?=$generation->getKeyID()?>">Regenerate</a></td>
157
<form action="<?=$_SERVER['REQUEST_URI']?>" method="post" style="margin-top: 1em;">
158
<input type="submit" value="Add a database to above:">: <input type="text" name="add_database" /> with class prefix <input type="text" name="class_prefix" />
162
<?php if ( ! empty($flashMessage)): ?>
164
<div class="results">
166
<div class="result_message"><?=$flashMessage?></div>
168
<div class="message">
169
<div class="title">Warnings</div>
170
<div class="content">
173
if (empty($warnings)) {
176
foreach ($warnings as $warning) {
177
echo $warning . "<br />\n";
185
<div class="message">
186
<div class="title">Added Files</div>
187
<div class="content">
190
if (empty($addedFiles)) {
191
echo 'No Added Files';
193
foreach ($addedFiles as $filename) {
194
echo $filename . "<br />\n";
197
echo 'cvs add ' . str_replace(SHARED_PATH, '', implode(' ', $addedFiles)) . '';
204
<div class="message">
205
<div class="title">Removed Files</div>
206
<div class="content">
209
if (empty($removedFiles)) {
210
echo 'No Removed Files';
212
foreach ($removedFiles as $filename) {
213
echo $filename . "<br />\n";
216
echo 'cvs remove ' . str_replace(SHARED_PATH, '', implode(' ', $removedFiles)) . '';
223
<div class="message">
224
<div class="title">Modified Files</div>
225
<div class="content">
228
if (empty($modifiedFiles)) {
229
echo 'No Modified Files';
231
foreach ($modifiedFiles as $filename) {
232
echo $filename . "<br />\n";