<? include_once("ngenie.lib.php");
$doc = new nGenie(); $lines = file("test_ngenie.dat"); foreach ($lines as $line) { $line = trim($line); if (preg_match("/\[([a-z_]+)\]/i", $line, $matches)) { $current_section = $matches[1]; } else { $data[$current_section][] = $line; } } //print_r($data); $doc->start("test_ngenie.tpl"); if (count($data["Authors"])) { $authors_block = new block("authors_block"); foreach ($data["Authors"] as $key => $author_name) { $author = new block("author"); $author->set_param("AUTHOR_NAME", $author_name); $authors_block->set_block("AUTHOR", $author); } $doc->set_block("AUTHORS", $authors_block); } if (count($data["Colors"])) { $color_table_block = new block("color_table_block"); foreach ($data["Colors"] as $key => $color_line) { list($color_name, $color) = split("=", $color_line); $color_cell = new block("color_cell_block"); $color_cell->set_param("COLOR", $color); $color_cell->set_param("COLOR_NAME", $color_name); $color_table_block->set_block("COLOR_CELL", $color_cell); } $doc->set_block("COLOR_TABLE", $color_table_block); } $doc->output(); ?>
|