~coughphp/coughphp/2.0

« back to all changes in this revision

Viewing changes to design/old code/cough_web_panel_old.php

  • Committer: Anthony Bush
  • Date: 2008-08-23 03:35:08 UTC
  • mfrom: (262.1.18 coughphp-release-1.3)
  • Revision ID: anthony@anthonybush.com-20080823033508-uy4yn5pmio6wcetv
Accept release-1.3 branch changes into trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?php
2
 
 
3
 
/**
4
 
 * Cough Web Panel - A quick, simple, interface to the CoughGenerator
5
 
 * class.
6
 
 * 
7
 
 * @author Anthony Bush
8
 
 * @version $Id$
9
 
 * @copyright Anthony Bush (http://anthonybush.com/), 30 April, 2007
10
 
 * @package default
11
 
 **/
12
 
 
13
 
// Get the cough generator classes
14
 
include('cough_generator_classes.php');
15
 
 
16
 
// Setup some web panel contants
17
 
define('CONFIG_FILE_SUFFIX', '.php');
18
 
define('CONFIG_PATH', dirname(__FILE__) . '/config/');
19
 
 
20
 
// Load the configs
21
 
$configs = array();
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);
26
 
                if (isset($config)) {
27
 
                        $configs[$file] = $config;
28
 
                        unset($config);
29
 
                }
30
 
        }
31
 
}
32
 
 
33
 
echo '<pre>';
34
 
print_r($configs);
35
 
echo '</pre>';
36
 
die();
37
 
 
38
 
                ##############
39
 
                # Controller #
40
 
                ##############
41
 
 
42
 
                $flashMessage = '';
43
 
                
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);
55
 
                                $generation->save();
56
 
                        } else {
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";
62
 
                                }
63
 
                        }
64
 
                        $warnings = $generator->getWarnings();
65
 
                        $removedFiles = $generator->getRemovedFiles();
66
 
                        $modifiedFiles = $generator->getModifiedFiles();
67
 
                        $addedFiles = $generator->getAddedFiles();
68
 
                }
69
 
 
70
 
 
71
 
                ########
72
 
                # View #
73
 
                ########
74
 
 
75
 
?>
76
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
77
 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
78
 
 
79
 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
80
 
<head>
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">
84
 
        /* <![CDATA[ */
85
 
                
86
 
                /* Generations Table */
87
 
                .genenerations {
88
 
                        border-top: 1px solid #999;
89
 
                        border-left: 1px solid #999;
90
 
                }
91
 
                .genenerations th {
92
 
                        background: #ccc;
93
 
                        padding: 3px;
94
 
                        border-right: 1px solid #999;
95
 
                        border-bottom: 1px solid #999;
96
 
                }
97
 
                .genenerations td {
98
 
                        padding: 3px;
99
 
                        border-right: 1px solid #999;
100
 
                        border-bottom: 1px solid #999;
101
 
                }
102
 
                
103
 
                /* Results */
104
 
                .results {
105
 
                        border: 1px solid #999;
106
 
                        margin: 1em 0;
107
 
                        background: #ccc;
108
 
                }
109
 
                .result_message {
110
 
                        background: #FFFF99;
111
 
                        padding: 5px;
112
 
                        border-bottom: 1px solid #999;
113
 
                }
114
 
                .message {
115
 
                        border: 1px solid #999;
116
 
                        background: #eee;
117
 
                        margin: 5px;
118
 
                }
119
 
                .message .title {
120
 
                        padding: 3px 5px;
121
 
                }
122
 
                .message .content {
123
 
                        font-family: monospace;
124
 
                        background: #fff;
125
 
                        padding: 5px;
126
 
                        white-space: nowrap;
127
 
                        overflow: auto;
128
 
                }
129
 
        /* ]]> */
130
 
        </style>
131
 
</head>
132
 
<body>
133
 
 
134
 
<h1>Cough Web Panel</h1>
135
 
 
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>
137
 
 
138
 
<table border="0" cellspacing="0" cellpadding="0" class="genenerations">
139
 
        <tr>
140
 
                <th>Database</th>
141
 
                <th>Class Prefix</th>
142
 
                <th>Last generated on</th>
143
 
                <th>Last generated by</th>
144
 
                <th>Controls</th>
145
 
        </tr>
146
 
<?php foreach ($generations as $generationID => $generation): ?>
147
 
        <tr>
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&amp;generate=<?=$generation->getKeyID()?>">Regenerate</a></td>
153
 
        </tr>
154
 
<?php endforeach; ?>
155
 
</table>
156
 
 
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" />
159
 
</form>
160
 
 
161
 
 
162
 
<?php if ( ! empty($flashMessage)): ?>
163
 
 
164
 
<div class="results">
165
 
 
166
 
        <div class="result_message"><?=$flashMessage?></div>
167
 
 
168
 
        <div class="message">
169
 
                <div class="title">Warnings</div>
170
 
                <div class="content">
171
 
                
172
 
                        <?php
173
 
                        if (empty($warnings)) {
174
 
                                echo 'No Warnings';
175
 
                        } else {
176
 
                                foreach ($warnings as $warning) {
177
 
                                        echo $warning . "<br />\n";
178
 
                                }
179
 
                        }
180
 
                        ?>
181
 
                
182
 
                </div>
183
 
        </div>
184
 
        
185
 
        <div class="message">
186
 
                <div class="title">Added Files</div>
187
 
                <div class="content">
188
 
                
189
 
                        <?php
190
 
                        if (empty($addedFiles)) {
191
 
                                echo 'No Added Files';
192
 
                        } else {
193
 
                                foreach ($addedFiles as $filename) {
194
 
                                        echo $filename . "<br />\n";
195
 
                                }
196
 
                                echo "<br />\n";
197
 
                                echo 'cvs add ' . str_replace(SHARED_PATH, '', implode(' ', $addedFiles)) . '';
198
 
                        }
199
 
                        ?>
200
 
                
201
 
                </div>
202
 
        </div>
203
 
        
204
 
        <div class="message">
205
 
                <div class="title">Removed Files</div>
206
 
                <div class="content">
207
 
                
208
 
                        <?php
209
 
                        if (empty($removedFiles)) {
210
 
                                echo 'No Removed Files';
211
 
                        } else {
212
 
                                foreach ($removedFiles as $filename) {
213
 
                                        echo $filename . "<br />\n";
214
 
                                }
215
 
                                echo "<br />\n";
216
 
                                echo 'cvs remove ' . str_replace(SHARED_PATH, '', implode(' ', $removedFiles)) . '';
217
 
                        }
218
 
                        ?>
219
 
                
220
 
                </div>
221
 
        </div>
222
 
        
223
 
        <div class="message">
224
 
                <div class="title">Modified Files</div>
225
 
                <div class="content">
226
 
                
227
 
                        <?php
228
 
                        if (empty($modifiedFiles)) {
229
 
                                echo 'No Modified Files';
230
 
                        } else {
231
 
                                foreach ($modifiedFiles as $filename) {
232
 
                                        echo $filename . "<br />\n";
233
 
                                }
234
 
                        }
235
 
                        ?>
236
 
                
237
 
                </div>
238
 
        </div>
239
 
        
240
 
</div>
241
 
 
242
 
<?php endif; ?>
243
 
 
244
 
 
245
 
</body>
246
 
</html>