Source for file RSDEngine.php

Documentation is available at RSDEngine.php


1 <?php
2 // RSDEngine: The Rapid and Secure Development Engine
3 // Copyright (C) 2003 Lukas Feiler
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
19 /**
20 * @package RSDEngine
21 * @author Lukas Feiler <lukas.feiler@chello.at>
22 * @copyright Lukas Feiler 2003
23 * @filesource
24 */
25
26 /**PEAR::File is required by the class RSDEngine to perform some IO operations.
27 */
28 require_once('File.php');
29
30 /**RSArrayUtil is required by the class RSDEngine to trigger methods of RSDEngineTable that generate the selectIncluding* methods.
31 */
32 require_once('RSArrayUtil/RSArrayUtil.php');
33
34 /**RSValidation is required by the class RSDEngine for validation of user input.
35 */
36 require_once('RSValidation/RSValidation.php');
37
38 /**RSStringUtil is required by the class RSDEngine for some string operations.
39 */
40 require_once('RSStringUtil/RSStringUtil.php');
41
42 /**RSDEngine uses the error codes defined in RSErrorManager.php.
43 */
44 require_once('RSErrorManager/RSErrorManager.php');
45
46 /**RSIO is required by the class RSDEngine to perform some IO operations.
47 */
48 require_once('RSIO/RSIO.php');
49
50 /**RSDEngineTable is required by the class RSDEngine to generate classes for each table.
51 */
52 require_once('RSDEngineDBTable.php');
53
54 /**Base class for all File-Classes
55 */
56 require_once('RSDEngineFile.php');
57
58 /**Base class for all Class-Classes
59 */
60 require_once('RSDEngineClass.php');
61
62 /**Base class for all Function-Classes
63 */
64 require_once('RSDEngineFunction.php');
65
66 /**Generates logic for accassing the database schema described by $config['sql'].
67 */
68 require_once('RSDEngineDB.php');
69
70 /**Generates the application base class for database backended applications.
71 */
72 require_once('RSDEngineDBApplicationBaseClass.php');
73
74 /**Generates the application class for database backended applications.
75 */
76 require_once('RSDEngineDBApplicationClass.php');
77
78 /**Generates a class extending the Smarty base class.
79 */
80 require_once('RSDEngineSmartyClass.php');
81
82 /**Generates a class extending Smarty to provide a template engine.
83 */
84 require_once('RSDEngineSmartyBaseClass.php');
85
86 /**Generates the configuration file for the application class of a database backended application.
87 */
88 require_once('RSDEngineDBApplicationConfigFile.php');
89
90 /**Generates the index file for database backended applications.
91 */
92 require_once('RSDEngineDBApplicationIndexFile.php');
93
94 /**Generates the initialization file for database backended applications.
95 */
96 require_once('RSDEngineDBApplicationInitFile.php');
97
98 /**Generates the logout file for database backended applications created with authentication support.
99 */
100 require_once('RSDEngineDBApplicationLogoutFile.php');
101
102 /**Generates the private initialization file for database backended applications created with authentication support.
103 */
104 require_once('RSDEngineDBApplicationPrivateInitFile.php');
105
106 /**Generates the public initialization file for database backended applications created with authentication support.
107 */
108 require_once('RSDEngineDBApplicationPublicInitFile.php');
109
110 /**The base class for all controller classes.
111 */
112 require_once('RSDEngineControllerFile.php');
113
114 /**The base class for all template classes.
115 */
116 require_once('RSDEngineTemplateFile.php');
117
118 /**Generates the controller file for selecting records from a table.
119 */
120 require_once('RSDEngineDBControllerFileGet.php');
121
122 /**Generates the controller file for selecting a single record from a table.
123 */
124 require_once('RSDEngineDBControllerFileGetOne.php');
125
126 /**Generates the template file for selecting a single record from a table.
127 */
128 require_once('RSDEngineDBTemplateFileGetOne.php');
129
130 /**Generates the controller file for searching records in a table.
131 */
132 require_once('RSDEngineDBControllerFileSearch.php');
133
134 /**Generates the template file to be included by the search-template to display the records.
135 */
136 require_once('RSDEngineDBTemplateFileSearchRecord.php');
137
138 /**Generates the template file for searching records in a table.
139 */
140 require_once('RSDEngineDBTemplateFileSearch.php');
141
142 /**Generates the template file for selecting records from a table.
143 */
144 require_once('RSDEngineDBTemplateFileGet.php');
145
146 /**Generates the template file to be included by the get-template to display the records.
147 */
148 require_once('RSDEngineDBTemplateFileGetRecord.php');
149
150 /**Generates the template file for inserting records into a table.
151 */
152 require_once('RSDEngineDBTemplateFileCreate.php');
153
154 /**Generates the controller file for inserting records into a table.
155 */
156 require_once('RSDEngineDBControllerFileCreate.php');
157
158 /**Generates an error management class extending RSErrorManager.
159 */
160 require_once('RSDEngineErrorManagerClass.php');
161
162 /**Generates the template file for reporting fatal errors.
163 */
164 require_once('RSDEngineTemplateFileFatalError.php');
165
166 /**Generates the template file for informig the user about a denied permission.
167 */
168 require_once('RSDEngineTemplateFilePermissionDenied.php');
169
170 /**Generates the controller file for deleting recrods from a table.
171 */
172 require_once('RSDEngineDBControllerFileDelete.php');
173
174 /**Generates the template file for deleting recrods from a table.
175 */
176 require_once('RSDEngineDBTemplateFileDelete.php');
177
178 /**Generates the controller file for updating a recrod in a table.
179 */
180 require_once('RSDEngineDBControllerFileUpdate.php');
181
182 /**Generates the controller for for viewing the contents of the one column of a singel record of a table.
183 */
184 require_once('RSDEngineDBControllerFileGetStored.php');
185
186 /**Generates the template file for updating a recrod in a table.
187 */
188 require_once('RSDEngineDBTemplateFileUpdate.php');
189
190 /**Generates the controller file for updating a LiveUser right.
191 */
192 require_once('RSDEngineDBControllerFileUpdateRight.php');
193
194 /**Generates the template file for updating a LiveUser right.
195 */
196 require_once('RSDEngineDBTemplateFileUpdateRight.php');
197
198 /**Generates the controller file for updating a LiveUser area.
199 */
200 require_once('RSDEngineDBControllerFileUpdateArea.php');
201
202 /**Generates the template file for updating a LiveUser area.
203 */
204 require_once('RSDEngineDBTemplateFileUpdateArea.php');
205
206 /**Generates the controller file for updating a LiveUser group.
207 */
208 require_once('RSDEngineDBControllerFileUpdateGroup.php');
209
210 /**Generates the template file for updating a LiveUser group.
211 */
212 require_once('RSDEngineDBTemplateFileUpdateGroup.php');
213
214
215 /**Generates the smarty template file for the paging feature.
216 */
217 require_once('RSDEngineTemplateFilePaging.php');
218
219 /**The generated file is included by the template file header.tpl (created by RSDEngineTemplateFileHeader).
220 */
221 require_once('RSDEngineControllerFileHeader.php');
222
223 /**Generates the smarty header template.
224 */
225 require_once('RSDEngineTemplateFileHeader.php');
226
227 /**The generated file is included by the template file footer.tpl (created by RSDEngineTemplateFileFooter).
228 */
229 require_once('RSDEngineControllerFileFooter.php');
230
231 /**Generates the smarty footer template.
232 */
233 require_once('RSDEngineTemplateFileFooter.php');
234
235
236 /**Manages the occurence of errors.
237 */
238 require_once('RSDEngineErrorManager.php');
239
240 /**Creates a new instance of RSErrorManager and configures PEAR to hand all errors to that instance by default.
241 */
242 $rsdEngineErrorManager =& new RSDEngineErrorManager();
243 PEAR::setErrorHandling(PEAR_ERROR_CALLBACK,array(&$rsdEngineErrorManager,'catch'));
244
245
246
247 /**Rapid and Secure Development Engine - generates classes for accessing the database schema provided by the developer.
248 *
249 * @author Lukas Feiler <lukas.feiler@chello.at>
250 * @version 0.1.9
251 * @copyright Lukas Feiler 2003
252 * @package RSDEngine
253 */
254 class RSDEngine{
255
256 /**The directory to which the geraration output should be saved. Gets set inside the constructor method.
257 * @var String
258 */
259 var $dir;
260
261 /**An associative array containing the configuration information. Each entry is represented by a key-value pair. The key is the name of the configuration option while the value is its value (!).
262 *
263 * Gets set inside the method loadConfig.
264 * @see loadConfig
265 * @var Array
266 */
267 var $config;
268
269 /**The number of warnings that occurred.
270 *
271 * Gets incremented by logWarn.
272 * @see logWarn
273 * @var int
274 */
275 var $_warnings = 0;
276
277 /**Construtor method.
278 *
279 * Sets the property $dir
280 * @see dir
281 *
282 * @param String $dir The directory to which the geraration output should be saved.
283 */
284 function RSDEngine($dir)
285 {
286 $this->dir = $dir;
287 }
288
289 /**Triggers the generation.
290 *
291 * The result of the generation is saved in the directory $this->dir.
292 * @see dir
293 * @see config
294 * @access public
295 *
296 * @param Mixed An associative array containing all configuration information needed for this generation. Note that if the boolean value false is passed, $this->config is used as configuration.
297 * Please see the {@tutorial RSDEngine.pkg#input} for help on the configuration options.
298 */
299 function generate($config = false)
300 {
301 //we do not want to have a time limit
302 set_time_limit(0);
303
304 if (!is_array($config)) {
305 $config = $this->config;
306 }
307
308 //everybody needs a reference to this RSDEngine instance (at least to call log).
309 $config['rsdEngine'] =& $this;
310
311 //some default values
312 if ($config['smartyLeftDelimiter'] == "") {
313 $config['smartyLeftDelimiter'] = '{';
314 }
315 if ($config['smartyRightDelimiter'] == "") {
316 $config['smartyRightDelimiter'] = '}';
317 }
318 if ($config['authActivatedColumn'] == "") {
319 $config['authActivatedColumn'] = '1';
320 }
321 if ($config['validationClassName'] == "") {
322 $config['validationClassName'] = "RSValidation";
323 }
324 if ($config['validationClassFile'] == "") {
325 $config['validationClassFile'] = "RSValidation/RSValidation.php";
326 }
327
328
329 if ($config['liveUser']) {
330 $config['auth'] = false;
331 }
332
333 $this->saveConfig($config);
334
335 @mkdir($this->dir);
336 $this->copySkel($config);
337
338 if ($config['webApplication']) {
339 $modelDir = "$this->dir/code/model";
340 $codeDir = "$this->dir/code";
341 $templateDir = "$this->dir/code/view/templates";
342 } else {
343 $modelDir = "$this->dir/code";
344 $codeDir = "$this->dir/code";
345 }
346
347 $classes = array();
348 $functions = array();
349 $files = array();
350 if ($config['databaseBackend']) {
351 $rsdEngineDB =& new RSDEngineDB($config);
352
353 //RSDEngineDBApplicationBaseClass and dbApplicationConfigFile need access to that rsdEngine instance!
354 $config['rsdEngineDB'] =& $rsdEngineDB;
355
356
357 $files['dbApplicationConfigFile'] = new RSDEngineDBApplicationConfigFile($config);
358 $files['dbApplicationConfigFile']->setOutputDirectory($modelDir);
359
360 $files['dbApplicationInitFile'] = new RSDEngineDBApplicationInitFile($config);
361 $files['dbApplicationInitFile']->setOutputDirectory($modelDir);
362
363 if ($config['auth'] || $config['liveUser']) {
364 $files['dbApplicationLogoutFile'] = new RSDEngineDBApplicationLogoutFile($config);
365 $files['dbApplicationLogoutFile']->setOutputDirectory($codeDir);
366
367 $files['dbApplicationIndexFile'] = new RSDEngineDBApplicationIndexFile($config);
368 $files['dbApplicationIndexFile']->setOutputDirectory($codeDir);
369
370 $files['dbApplicationPrivateInitFile'] = new RSDEngineDBApplicationPrivateInitFile($config);
371 $files['dbApplicationPrivateInitFile']->setOutputDirectory($modelDir);
372
373 $files['dbApplicationPublicInitFile'] = new RSDEngineDBApplicationPublicInitFile($config);
374 $files['dbApplicationPublicInitFile']->setOutputDirectory($modelDir);
375 }
376
377 $classes['dbApplicationBaseClass'] = new RSDEngineDBApplicationBaseClass($config);
378 $classes['dbApplicationClass'] = new RSDEngineDBApplicationClass($config);
379 $classes['errorManagerClass'] = new RSDEngineErrorManagerClass($config);
380
381 $functions = $rsdEngineDB->getFunctions();
382
383
384 if ($config['webApplication']) {
385
386 $controllerFiles = $rsdEngineDB->getControllerFiles($config);
387 while (list($key, $val) = each($controllerFiles)) {
388 $controllerFiles[$key]->setOutputDirectory($codeDir);
389 $files[$key] =& $controllerFiles[$key];
390 }
391
392 $templateFiles = $rsdEngineDB->getTemplateFiles($config);
393 while (list($key, $val) = each($templateFiles)) {
394 $templateFiles[$key]->setOutputDirectory($templateDir);
395 $files[$key] =& $templateFiles[$key];
396 }
397
398 $fatalErrorTemplate = new RSDEngineTemplateFileFatalError($config);
399 $fatalErrorTemplate->setOutputDirectory($templateDir);
400 $files['fatalErrorTemplate'] = $fatalErrorTemplate;
401
402 $permissionDeniedTemplate = new RSDEngineTemplateFilePermissionDenied($config);
403 $permissionDeniedTemplate->setOutputDirectory($templateDir);
404 $files['permissionDeniedTemplate'] = $permissionDeniedTemplate;
405
406
407
408
409 $pagingTemplate = new RSDEngineTemplateFilePaging($config);
410 $pagingTemplate->setOutputDirectory($templateDir);
411 $files['pagingTemplate'] = $pagingTemplate;
412
413
414 $headerController = new RSDEngineControllerFileHeader($config);
415 $headerController->setOutputDirectory($codeDir);
416 $files['headerController'] = $headerController;
417
418 $headerTemplate = new RSDEngineTemplateFileHeader($config);
419 $headerTemplate->setOutputDirectory($templateDir);
420 $files['headerTemplate'] = $headerTemplate;
421
422
423 $footerController = new RSDEngineControllerFileFooter($config);
424 $footerController->setOutputDirectory($codeDir);
425 $files['footerController'] = $footerController;
426
427 $footerTemplate = new RSDEngineTemplateFileFooter($config);
428 $footerTemplate->setOutputDirectory($templateDir);
429 $files['footerTemplate'] = $footerTemplate;
430
431 }
432 }
433
434 if ($config['webApplication']) {
435 $classes['smartyBaseClass'] = new RSDEngineSmartyBaseClass($config);
436 $classes['smartyClass'] = new RSDEngineSmartyClass($config);
437 }
438
439 reset($classes);
440 while (list($key, $val) = each($classes)) {
441 $files[$key] = &$classes[$key]->toRSDFile();
442 $files[$key]->setOutputDirectory($modelDir);
443 }
444
445 while (list($key,$val) = each($functions)) {
446 $files[$key] = &$functions[$key]->toRSDFile();
447 $files[$key]->setOutputDirectory($modelDir);
448 }
449
450 $this->logInfo("------------------WRITING DATA TO DISK...------------------");
451 $keys = array_keys($files);
452 for ($i = 0; $i < count($keys); $i++) {
453 $files[$keys[$i]]->setRelatedFiles($files);
454 $files[$keys[$i]]->setRelatedClasses($classes);
455 $files[$keys[$i]]->setRelatedFunctions($functions);
456 $files[$keys[$i]]->writeToDirectory();
457 }
458
459
460 $tableClassFiles = array();
461 $tableClasses =& $rsdEngineDB->getClasses();
462 reset($tableClasses);
463 while (list($key, $val) = each($tableClasses)) {
464 $tableClassFiles[$key] = &$tableClasses[$key]->toRSDFile();
465 $tableClassFiles[$key]->setOutputDirectory($modelDir);
466 }
467 $keys = array_keys($tableClassFiles);
468 for ($i = 0; $i < count($keys); $i++) {
469 $tableClassFiles[$keys[$i]]->setRelatedFiles($tableClassFiles);
470 $tableClassFiles[$keys[$i]]->setRelatedClasses($classes);
471 $tableClassFiles[$keys[$i]]->setRelatedFunctions($functions);
472 $tableClassFiles[$keys[$i]]->writeToDirectory();
473 }
474
475 $this->_done();
476 }
477
478 function copySkel($config)
479 {
480 if ($config["skel"] != "") {
481 $this->_copySkelDir($config, $config["skel"] . "/", "$this->dir/", false);
482 }
483
484 if ($config['webApplication'] && $config["webApplicationSkel"] != "") {
485 $this->_copySkelDir($config, $config['webApplicationSkel']. "/", "$this->dir/", false);
486 }
487
488 $snr = new File_SearchReplace("", "", array(), array($this->dir . "/"));
489 $snr->setSearchFunction('normal');
490
491 $snr->setFind("%%PROJECT_NAME%%");
492 $snr->setReplace($config["projectName"]);
493 $snr->doSearch();
494
495 $snr->setFind("%%PROJECT_DESCRIPTION%%");
496 $snr->setReplace($config["projectDescription"]);
497 $snr->doSearch();
498
499 $snr->setFind("%%DOCBOOOK_AUTHORS%%");
500 $snr->setReplace($this->_authorsToDocBook($config['authors']));
501 $snr->doSearch();
502
503 $snr->setSearchFunction('preg');
504 $snr->setFind("/\*\ @copyright[^\n]*/");
505 $snr->setReplace("* @copyright " . $config['copyright']);
506 $snr->doSearch();
507 }
508
509 /**Copies a directory including all subdirectories and files.
510 *
511 * @param Array $config The configuration options stored in an associative arrray.
512 * @param String $from_path Source: the directory to copy. MUST end with a slash.
513 * @param String $to_path Destination: where the direcotry specified by the first argument should be copied to. MUST end with a slash.
514 * @param boolean $overwrite Whether to overwrite existing files.
515 */
516 function _copySkelDir($config, $from_path, $to_path, $overwrite = true)
517 {
518 $this_path = getcwd();
519 if (!is_dir($to_path)) {
520 mkdir($to_path, 0775);
521 }
522 if (is_dir($from_path)) {
523 chdir($from_path);
524 $handle=opendir('.');
525 while (($file = readdir($handle))!==false) {
526 if (($file != ".") && ($file != "..")) {
527 if (is_dir($file)) {
528 chdir($this_path);
529
530 $newDirName = $file;
531 $newDirName = str_replace(
532 "%%PROJECT_NAME%%",
533 $config["projectName"],
534 $newDirName
535 );
536 $newDirName = str_replace(
537 "%%PROJECT_DESCRIPTION%%",
538 $config["projectDescription"],
539 $newDirName
540 );
541
542 $this->_copySkelDir($config, $from_path.$file."/", $to_path.$newDirName."/", $overwrite);
543 chdir($this_path);
544 chdir($from_path);
545 }
546 if (is_file($file)) {
547 chdir($this_path);
548
549 $newFileName = $file;
550 $newFileName = str_replace(
551 "%%PROJECT_NAME%%",
552 $config["projectName"],
553 $newFileName
554 );
555 $newFileName = str_replace(
556 "%%PROJECT_DESCRIPTION%%",
557 $config["projectDescription"],
558 $newFileName
559 );
560 if (!file_exists($to_path.$newFileName) || $overwrite === true) {
561 copy($from_path.$file, $to_path.$newFileName);
562 }
563 chdir($from_path);
564 }
565 }
566 }
567 closedir($handle);
568 }
569 chdir($this_path);
570 }
571
572
573 /**Saves the configuration information for this version.
574 */
575 function saveConfig($config = false)
576 {
577 $this->logInfo("Writing config.ini to $this->dir...");
578
579 if (!is_array($config)) {
580 $config = $this->config;
581 }
582 $data = "[versions]\n";
583
584 reset($config);
585 while (list($name, $value) = each($config)) {
586 if ($name != 'sql' && $name != 'authors' && $name != 'install' && $name != 'readme' && $name != 'release' && $name != 'additionalConfig') {
587 if ($value != "") {
588 if ($value == 'false') {
589 $value = '"false"';
590 } elseif ($value == 'true') {
591 $value = '"true"';
592 }
593 $data .= "$name = $value\n";
594 }
595 }
596 }
597
598 $error = File::write("$this->dir/config.ini", $data, FILE_MODE_WRITE);
599 if (PEAR::isError($error)) {
600 $this->logWarn("Could not write config.ini: " . $error->getMessage() . "($this->dir/config.ini)");
601 }
602
603 $error = File::write("$this->dir/code/AUTHORS", $config['authors'], FILE_MODE_WRITE);
604 if (PEAR::isError($error)) {
605 $this->logWarn("Could not write AUTHORS: " . $error->getMessage() . "($this->dir/code/AUTHORS)");
606 }
607
608 $error = File::write("$this->dir/code/INSTALL", $config['install'], FILE_MODE_WRITE);
609 if (PEAR::isError($error)) {
610 $this->logWarn("Could not write INSTALL: " . $error->getMessage() . "($this->dir/code/INSTALL)");
611 }
612
613 $error = File::write("$this->dir/code/README", $config['readme'], FILE_MODE_WRITE);
614 if (PEAR::isError($error)) {
615 $this->logWarn("Could not write README: " . $error->getMessage() . "($this->dir/code/README)");
616 }
617
618 if (file_exists("$this->dir/code/RELEASE")) {
619 $data = RSIO::getFileContents("$this->dir/code/RELEASE");
620 if (PEAR::isError($data)) {
621 $data = "";
622 }
623 $data = substr($data,0,strpos($data,"\n")-1);
624
625 if (RSValidation::startsWith($data,'------- ')) {
626 $firstLine = "$data\n";
627 } else {
628 $firstLine = '';
629 }
630 } else {
631 $firstLine = '';
632 }
633 if (isset($config['release'])) {
634 $config['release'] = $firstLine . $config['release'];
635 } else {
636 $config['release'] = $firstLine;
637 }
638 $error = File::write("$this->dir/code/RELEASE", $config['release'], FILE_MODE_WRITE);
639 if (PEAR::isError($error)) {
640 $this->logWarn("Could not write RELEASE: " . $error->getMessage() . "($this->dir/code/RELEASE)");
641 }
642
643 //create a file called ddl.sql in the subdirectory design and write the provided SQL DDL to that file
644 $error = File::write("$this->dir/design/ddl.sql", $config['sql'], FILE_MODE_WRITE);
645 if (PEAR::isError($error)) {
646 $this->logWarn("Could not write ddl.sql: " . $error->getMessage() . "($this->dir/design/ddl.sql)");
647 }
648
649 //create a file called additionalConfig in the root directory of this version.
650 $error = File::write("$this->dir/additionalConfig", $config['additionalConfig'], FILE_MODE_WRITE);
651 if (PEAR::isError($error)) {
652 $this->logWarn("Could not write additionalConfig: " . $error->getMessage() . "($this->dir/additionalConfig)");
653 }
654 }
655
656
657 /**Loads the configuration information of this version into the associative array $this->config.
658 *
659 * The method performs the following operations to gain information about a project:
660 * It will read the file VERSION_ROOT/config.ini. It will try to read files named AUTHORS, README, RELEASE and INSTALL in that directory. It will try to read the file VERSION_ROOT/desing/ddl.sql.
661 * The returned array will contain fields for all agruments of the method EAF::createProject (exept $updateProject).
662 */
663 function loadConfig()
664 {
665 $this->config = array(
666 'copyright' => '',
667 'authors' => '',
668 'install' => '',
669 'readme' => '',
670 'projectName' => '',
671 'projectDescription' => '',
672 'updateVersionAfterRelease' => '',
673 'databaseName' => '',
674 'databaseUsername' => '',
675 'databasePassword' => '',
676 'databaseHost' => '',
677 'databaseType' => '',
678 'sql' => '',
679 'additionalConfig' => '',
680 'validationClassName' => '',
681 'validationClassFile' => '',
682 'databaseEnsureReferentialIntegrity' => '',
683 'tablePrefix' => '',
684 'columnPrefix' => '',
685 'webApplication' => '',
686 'databaseBackend' => '',
687 'auth' => '',
688 'versioning' => '',
689 'authTable' => '',
690 'authUsernameColumn' => '',
691 'authPasswordColumn' => '',
692 'authActivatedColumn' => '',
693 'authCryptType' => '',
694 'authSessionName' => '',
695 'authSessionTimeout' => '',
696 'authLogoutURL' => '',
697 'liveUser' => '',
698 'liveUserSessionName' => '',
699 'liveUserLoginSubmitMethod' => '',
700 'liveUserRememberMe' => '',
701 'liveUserRememberMeCookieName' => '',
702 'liveUserRememberMeCookieLifetime' => '',
703 'liveUserRememberMeCookieDomain' => '',
704 'liveUserRememberMeCookiePath' => '',
705 'liveUserRememberMeCookieSecretKey' => '',
706 'liveUserLogoutRedirectURL' => '',
707 'liveUserDestroySessionOnLogout' => '',
708 'liveUserAuthIdleTime' => '',
709 'liveUserAuthLoginTimeout' => '',
710 'liveUserAuthExpireTime' => '',
711 'liveUserAuthAllowDuplicateHandles' => '',
712 'liveUserAuthPasswordEncryptionMode' => '',
713 'liveUserRefreshRights' => '',
714 'liveUserAuthTable' => '',
715 'liveUserAuthTableColumnUserid' => '',
716 'liveUserAuthTableColumnHandle' => '',
717 'liveUserAuthTableColumnPassword' => '',
718 'liveUserAuthTableColumnLastLogin' => '',
719 'liveUserAuthTableColumnIsActive' => '',
720 'liveUserPermType' => '',
721 'liveUserPermTablePrefix' => '',
722 'liveUserAuthAdminClass' => '',
723 'liveUserAuthAdminFile' => '',
724 'liveUserPermAdminClass' => '',
725 'liveUserPermAdminFile' => '',
726 'makeSequenceAssumption' => '',
727 'makeIsValidAssumption' => '',
728 'showKeyColumns' => '',
729 'getOneSelectMethodName' => '',
730 'getSelectMethodName' => '',
731 'searchSelectMethodName' => '',
732 'recordsPerPage' => '',
733 'getPaging' => '',
734 'searchPaging' => '',
735 'phpDocumentorDir' => '',
736 'smartyDir' => '',
737 'smartyLeftDelimiter' => '',
738 'smartyRightDelimiter' => '',
739 'skel' => '',
740 'webApplicationSkel' => '',
741 'overwrite_controllers' => '',
742 'overwrite_templates' => '',
743 'mail' => '',
744 'mailDefaultSender' => '',
745 'mailType' => '',
746 'mailSendmailPath' => '',
747 'mailSendmailArgs' => '',
748 'mailSMTPHost' => '',
749 'mailSMTPPort' => '',
750 'mailSMTPAuth' => '',
751 'mailSMTPUsername' => '',
752 'mailSMTPPassword' => '',
753 'makeInputTypeAssumption' => '',
754 'separateRecordTemplate' => '',
755 'getPaging' => '',
756 'searchPaging' => '',
757 'allowUserOrderBy' => '',
758 'useHeader' => '',
759 'useFooter' => '',
760 'getControllersArePublic' => '',
761 'getOneControllersArePublic' => '',
762 'searchControllersArePublic' => '',
763 'deleteControllersArePublic' => '',
764 'updateControllersArePublic' => '',
765 'createControllersArePublic' => '',
766 'writePagingTemplate' => '',
767 'writeHeaderFiles' => '',
768 'writeFooterFiles' => '',
769 'writeControllerGet' => '',
770 'writeControllerGetOne' => '',
771 'writeControllerUpdate' => '',
772 'writeControllerDelete' => '',
773 'writeControllerSearch' => '',
774 'writeControllerCreate' => '',
775 'writeTemplateGet' => '',
776 'writeTemplateGetOne' => '',
777 'writeTemplateGetRecord' => '',
778 'writeTemplateUpdate' => '',
779 'writeTemplateDelete' => '',
780 'writeTemplateSearch' => '',
781 'writeTemplateSearchRecord' => '',
782 'writeTemplateCreate' => '',
783 'writeSmartyBaseClass' => '',
784 'writeSmartyChildClass' => '',
785 'writeConfigFile' => '',
786 'writeInitFile' => '',
787 'writePrivateInitFile' => '',
788 'writePublicInitFile' => '',
789 'writeIndexFile' => '',
790 'writeLogoutFile' => '',
791 'writeApplicationBaseClass' => '',
792 'writeApplicationChildClass' => '',
793 'writeTableBaseClasses' => '',
794 'writeTableChildClasses' => '',
795 'writeFatalErrorTemplate' => '',
796 'writePermissionDeniedTemplate' => '',
797 'writeErrorManagerClass' => '',
798 'fileStorageDirectory' => ''
799 );
800
801 if (is_file("$this->dir/config.ini")) {
802 $iniConfig = parse_ini_file("$this->dir/config.ini");
803 while (list($key, $val) = each($iniConfig)) {
804 $this->config[$key] = $iniConfig[$key];
805 }
806 }
807
808 $this->config['dir'] = $this->dir;
809
810 if (PEAR::isError($data = File::readAll("$this->dir/design/ddl.sql"))) {
811 $this->config['sql'] = '';
812 } else {
813 $this->config['sql'] = $data;
814 }
815
816 if (PEAR::isError($data = File::readAll("$this->dir/additionalConfig"))) {
817 $this->config['additionalConfig'] = '';
818 } else {
819 $this->config['additionalConfig'] = $data;
820 }
821
822 if (PEAR::isError($data = File::readAll("$this->dir/code/AUTHORS"))) {
823 $this->config['authors'] = '';
824 } else {
825 $this->config['authors'] = $data;
826 }
827
828 if (PEAR::isError($data = File::readAll("$this->dir/code/README"))) {
829 $this->config['readme'] = '';
830 } else {
831 $this->config['readme'] = $data;
832 }
833
834 if (PEAR::isError($data = File::readAll("$this->dir/code/INSTALL"))) {
835 $this->config['install'] = '';
836 } else {
837 $this->config['install'] = $data;
838 }
839
840 if (PEAR::isError($data = File::readAll("$this->dir/code/RELEASE"))) {
841 $this->config['release'] = '';
842 } else {
843 $firstLine = substr($data,0,strpos($data,"\n"));
844 if (RSValidation::startsWith($firstLine,'------- ')) {
845 $data = str_replace($firstLine,'',$data);
846 }
847 $this->config['release'] = $data;
848 }
849 }
850
851 /**Logs the message passed as argument.
852 * @access private
853 *
854 * @param String The message to log.
855 */
856 function _log($msg)
857 {
858 echo "$msg<br>\n";
859 flush();
860 }
861
862 /**Logs the info message passed as argument.
863 *
864 * @param String The message to log.
865 */
866 function logInfo($msg)
867 {
868 $this->_log("INFO: $msg");
869 }
870
871 /**Logs the warning message passed as argument.
872 *
873 * @param String The message to log.
874 */
875 function logWarn($msg)
876 {
877 $this->_warnings++;
878 $this->_log("<b>WARN: $msg</b>");
879 }
880
881 function _done()
882 {
883 $this->_log("<h1>DONE!</h1>");
884 if ($this->_warnings == 0) {
885 $this->_log("$this->_warnings Warnings!");
886 } else {
887 $this->_log("<b>$this->_warnings WARNINGS!</b>");
888 }
889 exit;
890 }
891
892 /**Returns a string containing DocBook Tags for the authors passed as argument.
893 *
894 * @param String $authors A newline-sperated list of authors in the format 'Firstname Lastname <email@domain>'.
895 * @return String A String containing DocBook tags for all authors.
896 */
897 function _authorsToDocBook($authors)
898 {
899 /*
900 Will produce something like that:
901 <author>
902 Joshua Eichorn
903 <authorblurb>
904 {@link mailto:jeichorn@phpdoc.org jeichorn@phpdoc.org}
905 </authorblurb>
906 </author>
907 */
908 $authorsArray = split("\n",$authors);
909 $authorTags = "";
910 while (list($key, $val) = each($authorsArray)) {
911 if (strpos($val,"<") !== false && strpos($val,">") !== false && strpos($val,">") > strpos($val,"<")) {
912 $authorName = substr($val,0,strpos($val,"<"));
913 $authorEmail = substr($val,strpos($val,"<")+1,strpos($val,">") - strpos($val,"<") - 1);
914 } else {
915 $authorName = $val;
916 $authorEmail = "";
917 }
918 $authorTags .= "\n" .
919 " <author>\n" .
920 " $authorName\n" .
921 " <authorblurb>\n";
922 if ($authorEmail != "") {
923 $authorTags .= " {@link mailto:$authorEmail $authorEmail}\n";
924 }
925
926 $authorTags .= " </authorblurb>\n" .
927 " </author>\n";
928 }
929 return $authorTags;
930 }
931 }
932 ?>

Documentation generated on Mon, 8 Dec 2003 13:10:43 +0100 by phpDocumentor 1.2.3