<?php
/**
*
*
* @version $Id$
* @copyright 2003
**/
include_once ('Configer.php');
class ConfigWriter {
var $classes = "";
function ConfigWriter($_classes) {
$this->classes = $_classes;
}
function write() {
foreach($this->classes as $class) {
if($class->tagname == "class") {
$name = $class->get_attribute("name");
$table = $class->get_attribute("table");
$c = new Configer("config/".$name.".properties", true, true);
$c->setSectionValue("class", "table", $table);
$classChildren = $class->children();
foreach($classChildren as $classChild) {
switch($classChild->tagname) {
case "primaryKey":
$field = $classChild->get_attribute("field");
$autoIncrement = $classChild->get_attribute("autoIncrement");
$c->setSectionValue("class", "primaryKey", $field);
$c->setSectionValue("class", "autoIncrement", $autoIncrement);
break;
case "property":
$property = $classChild->get_attribute("name");
$field = $classChild->get_attribute("field");
$c->setSectionValue("fields", $field, $property);
break;
case "relationship":
$type = $classChild->get_attribute("type");
$name = $classChild->get_attribute("name");
$linkOn = $classChild->get_attribute("linkOn");
$c->setSectionValue("relationships", $name, $type);
$c->setSectionValue($name, "linkOn", $linkOn);
if ($type == "oneToMany") {
$objectArray = $classChild->get_attribute("objectArray");
$c->setSectionValue($name, "objectArray", $objectArray);
}
break;
}
}
$c->save();
}
}
}
}
?>