} //get the properties, based on type build constructor $properties = loadProperties($classDir); //get the methods $methods = loadMethods($classDir); //start the file $file = $language->startClass($class, $definition); if ($definition['mixin']) { //load mixin methods and properties foreach ($definition['mixin'] as $module) { $moduleDir = fileName(PACKAGEDIR, $package, MODULEDIR, $module); $properties = array_merge($properties, loadProperties($moduleDir)); $methods = array_merge($methods, loadMethods($moduleDir)); } } //build the construct method based on the private propeties $constructor = ''; foreach ($properties as $property) { $file .= $language->addProperty($property); $constructor .= $language->selfAssign($property, $language->newObject($property->type, $property->default)); } $file .= "\n"; $methods[$language->constructorName] = (object) array('name' => $language->constructorName, 'scope' => 'public', 'args' => '()', 'body' => $constructor); foreach ($methods as $method) { $file .= $language->method($method); } //write file file_put_contents(fileName(GENERATEDIR, "class.{$class}.php"), $file . '}'); } generateClass('SomeApplication', 'Person');
<form method="post"> <input name="name" style="width:100%;padding: 30px; text-align: center; background: #fcfcfc; box-sizing: border-box;font-size: 20px; font-weight: bold" autofocus> </form> <?php if (isset($_POST['name'])) { $schema = getSchema(trim($_POST['name'])); generateClass($schema); echo "<div style='width:100%;padding: 30px; text-align: center; background: green; box-sizing: border-box;font-size: 20px; font-weight: bold'>Done</div>"; } function getSchema($name) { $schema = new stdClass(); $schema->name = $name; $schema->url = "http://schema.org/" . $name; $schema->properties = array(); $yql_base_url = "http://query.yahooapis.com/v1/public/yql"; $yql_query = "select * from html where url=\"http://schema.org/" . $name . "\" AND xpath=\"//div[@id='mainContent']\""; $yql_query_url = $yql_base_url . "?q=" . urlencode($yql_query); $yql_query_url .= "&format=json"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $yql_query_url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); $content = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); $jsonObject = json_decode($content); $result = $jsonObject->query->results; if ($jsonObject->query->count > 0) { if (is_array($result->div->table)) { $result->div->table = $result->div->table[0];
// Done $output .= generateClassFetchData($tableName, $className, $fields); // Done $output .= generateClassGetID($className, $fields); // DONE foreach ($fields as $fieldName => $field) { $output .= generateClassGetField($className, $fieldName, $field); // Done } $output .= generateClassDelete($tableName, $fields); $output .= generateClassUpdate($tableName, $className, $fields); // Done $output .= generateClassBottom($className); // Done return $output; } global $conn; if ($argc < 2) { print "Usage: " . $argv[0] . " <table_name>\n"; exit - 1; } $tableName = $argv[1]; $meta = pg_meta_data($conn, $tableName); if (!is_array($meta)) { print "Error: table {$tableName} not found\n"; exit - 1; } print generateHeader($tableName); print generate_GETOBJECT($tableName); print generateClass($tableName, $meta);